
function getMovie() {
    var M$ =  navigator.appName.indexOf("Microsoft")!=-1
    return (M$ ? window : document)["map"]
}

function map_DoFSCommand(command, args) {
if(command == "from") {
	nuselectfrom(args);
	}
}

$(document).ready(
function(){
var first1 = 0;
var first2 = 0;
   $("select#searchFly_flyFrom, select#searchFly_flyTo").change(
   		function () {
			var str = "";
			var sname = $(this).attr("id");
			if(sname == "searchFly_flyFrom"){
		          $("select#searchFly_flyFrom option:selected").each(
				  	function () {
		              str = $(this).attr("value");
        	      });
			if(first1 > 0){
				try{  
					getMovie().sendFromJS(str,'from'); 
				}catch(e){}
				}
			$("select#searchFly_flyTo").attr("disabled","");
			if(str == 9999){ 
				$("select#searchFly_flyTo").attr("disabled","disabled");  
				$("select#searchFly_flyTo option[value='']").attr("selected","selected"); }
				first1=1;
			}
			if(sname == "searchFly_flyTo"){
	          $("select#searchFly_flyTo option:selected").each(
			  	function () {
              		str = $(this).attr("value");
	              });
			if(first2 > 0){    
				try{
					getMovie().sendFromJS(str,'to'); 
				}catch(e){}
				}
			if(str == ''){ 
				$("select#searchFly_flyTo option[value='']").attr("selected","selected"); 
				}
			first2=1;
			}
        }).trigger('change');
  });


function from(nnn){
	if(nnn == 9999){
		$("select#searchFly_flyFrom option[value='']").attr("selected","selected");	
	}else{
		$("select#searchFly_flyFrom option[value='"+nnn+"']").attr("selected","selected");
	}

	this.idFrom = 'searchFly_flyFrom';
	this.idTo = 'searchFly_flyTo';
		fillArrvSelect();
	if(nnn == 9999) {  
		$("select#searchFly_flyTo").attr("disabled","disabled");
		$("select#searchFly_flyTo option[value='']").attr("selected","selected");  
	}else{
		$("select#searchFly_flyTo").attr("disabled","");
		}
	}

function to(nnn){
	if(nnn == 9999){
	    $("select#searchFly_flyTo option[value='']").attr("selected","selected");
	}else{
	    $("select#searchFly_flyTo option[value='"+nnn+"']").attr("selected","selected");	
	}
}
