 var anchoDivP; 
addNamespace("MS.Web.AutoComplete");
MS.Web.AutoComplete = Class.create();
Object.extend(MS.Web.AutoComplete.prototype, {
	timer: null,
	count: 10,
	pos: 0,
	waitAfterInput: 300,  /// 230
	minChars: 1,          ///  parametro que indica hasta cuantos caracteres empieza hacer la busqueda
	children: null,
	
	changeHighlight: function() {
		var l = this.getLength();
				
		for(var i=0; i<this.count && i<l; i++) {
					
		    /*if (this.getItem(0).Status=="-?-") // '-?-' = Indicador de que no hay datos
		        this.div.childNodes[i].className = "itemx";
		    else */
			if(i == this.pos)				
				this.div.childNodes[i].className = "item selected";
			else
				this.div.childNodes[i].className = "item";
		}
	},	
	getItem: function(idx) {
		return null;
	},
	getLength: function() {
		return 0;
	},
	getDisplay: function(item,pos) {
		return [item,pos];
	},
	getValue: function(item) {
		return item;
	},
	hide: function() {	    
		this.div.style.display = "none";  //AA
		this.ele.style.background= "white";	 //Original: this.ele.style.background= "";		
		var Version =navigator.appVersion.substring(22,25);
		Version = parseInt(Version);
		if (navigator.appName=="Microsoft Internet Explorer")
			if (Version < 7)
				Mostrar_Elementos();		
	},
	show: function() {        
	
	    this.changeHighlight();
		this.div.style.background= "#FFFFFF";		
	    this.div.style.display = "inline"; //AA	
	    
	    //alert('Padre:' + this.ele.id + ' W:' + this.ele.offsetWidth + ' xxx ' + ' Padre:' + this.div.id + ' W:' + this.div.offsetWidth + ' XX Hij:' + this.div.childNodes[0].offsetWidth);
	    	    	    
	    //(Tamaņo Cada Item  * # elementos)  = Alto de la Lista 
	    /*if (this.div.childNodes[0].offsetHeight > 0) //alto del primer elemento	    	    
	        this.div.style.height =  (this.div.childNodes[0].offsetHeight * this.count + 1) + "px";*/
	    	    	    
		var Version =navigator.appVersion.substring(22,25);
		Version = parseInt(Version); 
		if (navigator.appName=="Microsoft Internet Explorer") 
			if (Version < 7)
				Ocultar_Elementos();							
	},
	focusTextbox: function() {
		this.ele.focus();
	},
	select: function() {
		
		//debugger;		
		if(this.pos > -1) {			
			var v = this.getValue(this.getItem(this.pos));
					
			//  '-?-' = indicador del 1er Registro "No es Seleccionable" (Msg No Results)
			if (v == SimbDatos) { 
			    this.ele.value = descripcionGral; //Pongo mensaje de Inicio
			} else {				
			    if (v=="") v = this.ele.value;  //Paso su mismo valor obj.
			    if(v != this.ele.value) 
			    {				
				    this.ele.value = v; //Pongo valor seleccionado de la Lista
				    if(this.children != null)
					    for(var i=0; i<this.children.length; i++) {
						    this.children[i].onparentchange(v);
					    }
			    }
			}
		}
		this.hide();	
	},
	onkeydown: function(e) {
		var key = MS.Keys.getCode(e);
		switch(key) {
			case MS.Keys.TAB:
			case MS.Keys.ENTER:
				this.select();
				if(key == MS.Keys.ENTER) MS.cancelEvent(e);
				break;

			case MS.Keys.ESC:			   
				this.ele.style.background= "white"; //Original: this.ele.style.background= "";
				this.hide();
				break;

			case MS.Keys.KEYUP:
					
				if(this.pos > 0) this.pos--;
				this.changeHighlight();
				break;

			case MS.Keys.KEYDOWN:
			
				if(this.pos < this.getLength() -1 && this.pos < this.count -1) this.pos++;
				this.changeHighlight();
				break;
		}
	},
	onkeyup: function(e) {
		switch(MS.Keys.getCode(e)) {
			case MS.Keys.TAB:
			case MS.Keys.ENTER:
			case MS.Keys.ESC:
			case MS.Keys.KEYUP:
			case MS.Keys.KEYDOWN:
			case MS.Keys.KEYLEFT:
			case MS.Keys.KEYRIGHT:
			case MS.Keys.ALT:
			case MS.Keys.SHIFT:
			case MS.Keys.CTRL:
				break;

			default:
					
			
			/****************************************************************************************/			
			/*               AL INTENTAR BUSCAR RECONSTRUYE NUEVAMENTE                             */
			/****************************************************************************************/			
			/*	
				if (this.ele.id=="Leavingfrom")	
					var divs = document.getElementById("Leavingfrom_list");
				else
					var divs = document.getElementById("Nombre_list");
				*/
				
				//alert('onkeyup');
				var divs = document.getElementById(this.ele.id + "_list")
				this.div = divs;
				this.div.id = this.ele.id + "_list";				
				this.div.style.background = "#FFFFFF";				
				this.div.style.border = "1px solid #000000";  
						
				var r = MS.Position.getBounds(this.ele);								

				var obj = this.ele;				
				var curleft =0;
				var curtop = 0;
				
				if (obj.offsetParent) 
				{
					curleft = obj.offsetLeft;
					curtop = obj.offsetTop;
					while (obj = obj.offsetParent) 
					{
						curleft += obj.offsetLeft;
						curtop += obj.offsetTop;
					}
				}				
				curleft=parseInt(curleft);
				curtop=parseInt(curtop);
				curtop += 23;	
				r.top = curtop;
				r.left = curleft; 				
				this.ele.rect = r;				
			    anchoDivP = (r.width)+ 20;  //Ancho Div Padre  //asp*
				this.div.style.width =  anchoDivP + "px";  //ancho del Input desgloce ( Div Padre )
				//MS.Position.setBounds(this.div, r);
			/****************************************************************************************/
                
				if(this.ele.value.length == 0)		
				{
					this.ele.style.background= "white"; //Original: this.ele.style.background= "";
				}
                /*Indicador de Reloj*/
				if(this.ele.value.length <= this.minChars)
				{
					this.ele.style.background= "white url('/_Lib/Images/indicator.gif') no-repeat right"; 
					//Original: this.ele.style.background= "url('/_Lib/Images/indicator.gif') no-repeat right";
					return false;										
				}
				//Tiempo que tarda para el mostrado de la lista	               		
				if(this.timer != null) 
				{
					this.ele.style.background= "white"; //Original: this.ele.style.background= "white";
					clearTimeout(this.timer);
				}					
				this.timer = setTimeout(this.getData.bind(this), this.waitAfterInput);				 
							
				break;
		}
	},
	onfocus: function(e) { 
		this.changeHighlight();
	},
	onblur: function(e) {
		
		this.select();
		setTimeout(this.hide.bind(this), 200);	// 200 msec for onclick event of item
	},
	onmouseover: function(e) { 		
		this.pos = MS.getTarget(e).idx;
		this.changeHighlight();
	},
	onclick: function(e) {			
		this.pos = MS.getTarget(e).idx;
		//this.changeHighlight();//// esta funcion se ciclo cuando en la lista no nos regresa elemento
		this.select();
	},
	ondblclick: function(e) {
		if(this.ele.value == "")
			this.getData();
	},
	onchange: function(e) {			
		if(this.children != null)				
			for(var i=0; i<this.children.length; i++) {
				this.children[i].onparentchange(this.ele.value);
			}
	},
	onparentchange: function(v) {		   
		this.ele.value = "";
		//this.ele.style.display = "none";		//xx
	},
	updateList: function() {
			
		var hayDatos =false;    //default No hay datos en la lista	
		var myData;             //Almaceno el valor que trae por Fila
		var l = this.getLength();
		var objPadre = this.ele;  //Objeto Padre (Tipo text ķ Combo)
		var objLista = this.div;  //Objeto Lista de Datos  1.... n  
		//var objListaItem;       //Items 1....n de la Lista   
										
		//Lleno el Div con los nombres de los Aereop y Banderitas
		for(var i=0; i<l && i<this.count; i++) {
						
			myData = this.getDisplay(this.getItem(i),i);  //Trae el valor de cada Fila (Aerp, Hoteles, etc... y Banderita)
			
			//SI vienen con info al menos un elemento		
			if (myData!= "") hayDatos = true;   //Si hubo al menos un elemento por mostrar
						
			// MS.setText(this.div.childNodes[i], this.getDisplay(this.getItem(i)));
			// obtenemos los datos del dataTable para pintarlos en la lista
						
			objLista.childNodes[i].innerHTML = myData;	//paso su texto al item de la lista					
			objLista.childNodes[i].style.display = "block";							
					
		}
		      
		if(this.pos > l) this.pos = this.getLength()-1;
			
		for(var i=l; i<this.count; i++) {		
			objLista.childNodes[i].style.display = "none";	
													
		}						
		if(this.pos > l -1) {
			this.pos = l-1;
		}
		
		
		//Si hubo Datos ?  True = Muestro False =  Oculto
		if (hayDatos == true)
		    this.show();
		else
		    this.hide();
		
        /*if(this.div.childNodes[0].clientHeight == 0) {
			this.show();			
			return;
		}

		var h = (l < this.count ? l : this.count) //* this.div.childNodes[0].clientHeight;		
		//si hay elementos
		if(h > 0) {			
			this.show();			
		} else 
			this.hide();
		*/	
			
			
	},
	getData: function() {
	},
	ondata: function() {
		this.updateList();
	},
	onresize: function() {
		
		        /****************************************************************************************/
		        /*                  AL MINIMIZAR  O MAXIMIZAR RECONSTRUYE                               */
		        /****************************************************************************************/
        		/*				
				if (this.ele.id=="Leavingfrom")	
					var divs = document.getElementById("Leavingfrom_list");
				else
					var divs = document.getElementById("Nombre_list");
				*/
				var divs = document.getElementById(this.ele.id + "_list")
				this.div = divs;
				this.div.id = this.ele.id + "_list";				
				this.div.style.background = "#FFFFFF";				
				this.div.style.border = "1px solid #000000";  
				
				//alert('onresize');
						
				var r = MS.Position.getBounds(this.ele);								

				var obj = this.ele;
				var curleft = curtop = 0;
				var curleft =0;
				var curtop = 0;
				
				if (obj.offsetParent) 
				{
					var curleft = obj.offsetLeft;
					var curtop = obj.offsetTop;
					while (obj = obj.offsetParent) 
					{
						curleft += obj.offsetLeft;
						curtop += obj.offsetTop;
					}
				}
				
				curleft=parseInt(curleft);
				curtop=parseInt(curtop);
				curtop += 23;	
				r.top = curtop;
				r.left = curleft; 
				this.ele.rect = r;		
				this.div.style.width =  anchoDivP + "px";
				//MS.Position.setBounds(this.div, r);
	/****************************************************************************************/
			
	},
	
	/****************************************************************************************/
	/*              INITIALIZE ( CREA TODA LA ESTRUCTURA DE LOS "N" ELEMENTOS DEL DIV )     */
	/****************************************************************************************/
	initialize: function(id, count, parent) {
		this.ele = document.getElementById(id);  //$(id);
		
		if(this.ele == null || this.ele.tagName != "INPUT") throw "Control could not be found.";
		this.count = count != null && !isNaN(count) ? count : this.count;

		if(parent != null) {	// no the parent control, instance of MS.Web.AutoComplete
			parent.children = [];
			parent.children.push(this);
		
		}
		
		addEvent(this.ele, "keydown", this.onkeydown.bind(this));
		addEvent(this.ele, "keyup", this.onkeyup.bind(this));
		addEvent(this.ele, "blur", this.onblur.bind(this));
		addEvent(this.ele, "focus", this.onfocus.bind(this));
		addEvent(this.ele, "change", this.onchange.bind(this));
		addEvent(this.ele, "dblclick", this.ondblclick.bind(this));
		
	
		/*if (this.ele.id=="Leavingfrom")	
			var divs = document.getElementById("Leavingfrom_list");
		else
			var divs = document.getElementById("Nombre_list");
		*/
		var divs = document.getElementById(this.ele.id + "_list")
		this.div = divs;
		this.div.style.display = "none";	
		this.div.style.border = "1px solid #000000";  
				
		var r = MS.Position.getBounds(this.ele);	
				
		//alert('initialize');							

		var obj = this.ele;
		var curleft = curtop = 0;
		var curleft =0;
		var curtop = 0;
		
		if (obj.offsetParent) 
		{
			var curleft = obj.offsetLeft;
			var curtop = obj.offsetTop;
			while (obj == obj.offsetParent)   
			{
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
		}
		
		curleft=parseInt(curleft);
		curtop=parseInt(curtop);
		curtop += 23;	
		r.top = curtop;
	    r.left = curleft; 
	   	    
		this.ele.rect = r;				
		anchoDivP = this.ele.offsetWidth + 20;  //Tomo Ancho del Padre
	    this.div.style.background = "#FFFFFF";	    
		this.div.style.width = anchoDivP + "px";  //Ancho Padre + 20  = Lista de Hoteles	
		this.div.style.height = "auto";
		//this.div.style.height = (16 * this.count) + "px";
		this.div.style.position = "absolute"; 
		this.div.style.zIndex = 100;    
				
		 
		//MS.Position.setBounds(this.div, r); // nota : posisiona al div a un nivel inferior de los combos
		for(var i=0; i<this.count; i++) {
			var d = document.createElement("div");
			this.div.appendChild(d);				
			//d.style.width = (this.div.offsetWidth + 20) + "px";  /*hIJITOS*/   //asp*
			//d.style.whiteSpace = "nowrap";
			d.style.overflow = "hidden";			
			d.id = this.ele.id + "_item";  //nombre id de c/u elementos de la lista
			d.className = this.ele.id + "_item";  //Le pone el nombre de la clase a los hijitos
			d.idx = i;
						
			addEvent(d, "mouseover", this.onmouseover.bind(this));
			addEvent(d, "click", this.onclick.bind(this));
			MS.setText(d, " ");
		}
						
		addEvent(window, "resize", this.onresize.bind(this));		
		//this.div.innerHTML="a<!--[if lte IE 6.5]><iframe></iframe><![endif]-->";
		delete r;
	}
}, false);


MS.Web.AutoCompleteDataTable = Class.create();
Object.extend(MS.Web.AutoCompleteDataTable.prototype, MS.Web.AutoComplete.prototype, true);

Object.extend(MS.Web.AutoCompleteDataTable.prototype, {
	dt: null,
	
	getItem: function(idx) {
		if (this.dt != null)
			if(idx >= 0 && idx < this.dt.Rows.length)
				return this.dt.Rows[idx];
			return null;
	},
	getLength: function() {
		if(this.dt != null && this.dt.Rows != null) {
			return this.dt.Rows.length;
		}
		return 0;
	},
	callback: function(res) {
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		this.dt = res.value;
		this.ondata();
	}
	
}, true);

 function Ocultar_Elementos()
  {
	var x=document.getElementsByTagName("SELECT");  
	for (i=0;i<x.length;i++)
	{
		x(i).style.visibility= "hidden";
	}  
  }
     
  function Mostrar_Elementos()
  {
	var x=document.getElementsByTagName("SELECT");  
	for (i=0;i<x.length;i++)
	{
		x(i).style.visibility= "visible";
	}	    
  }

 /* ------------------------------------	TEMAS - CADENAS	------------------------------------ */
  
	var Tipo_Servicio;
	var Idioma;
	var Sitio;
	
	var txtDestinoESP = 'Todos los Destinos'; 
	var txtDestinoING = 'All Destinations';
	var txtHotelESP = 'Todos los Hoteles'; 
	var txtHotelING = 'All Hotels';
			
	//Valido que existe el Objeto Idioma  
	if (document.getElementById('Idioma') == null)	
		Idioma = 'ING'
	else
		Idioma  = document.getElementById('Idioma').value; //Idioma del sitio
	
	//Valido que existe el Objeto pbCiudades
	if (document.getElementById('pbCiudades') == null)	
		Sitio = 0
	else
		Sitio  = document.getElementById('pbCiudades').value;   //Destinos ķ Ciudades del AJAX
	
	/*Funcion que carga los destinos por cadena*/	
	function Carga_Destino_Cadenas(destino,hotel){
					
		var Cadena = '';				
		var radio = document.getElementById("RadioH");
		
		if (radio.checked==true)
			Tipo_Servicio ='H';
		else
			Tipo_Servicio ='HF';
		
		var Combo;
		if (Tipo_Servicio =='HF')		
			Combo = document.getElementById("CadenaHF");
		else
			Combo = document.getElementById("CadenaH");
		
		// Verificamos que tipo de Objeto es, para saber sonde debemos obtener el valor de la cadena 
		/// Combo o del Hidden
		if (Combo.type =="select-one") 
				Cadena = Combo.options[Combo.selectedIndex].value;
		else
				Cadena = Combo.value;
		
		var dt = AutoComplete.search_Destino_Cadena(Tipo_Servicio, Cadena, Idioma, Sitio).value;

		if 	(dt == null)				
			return;
			
		// objeto en donde vamos a almacenar la informacion
		var cbo;
		
		if (Tipo_Servicio =='HF')		
			cbo = document.getElementById("ciudades");
		else
			cbo = document.getElementById("Destino");
					
		cleanSelect (cbo);
		
		//Primer Opcion del Combo de Destinos
		if (Idioma.toUpperCase() == "ESP")
			cbo.options[0] = new Option(txtDestinoESP, 0);	
		else
			cbo.options[0] = new Option(txtDestinoING, 0);	
		
		//Lleno el Combo con los Destinos
		for (var i=0; i<dt.Rows.length; i++){
				
			//Valido si la clave del Destino es la Misma seleccionada Anteriormente
		    if (dt.Rows[i].Clav_Destino == destino)
				cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Destino, dt.Rows[i].Clav_Destino,true,true); //Opcion seleccionada
		    else
				cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Destino, dt.Rows[i].Clav_Destino,false,false); //No seleccionadas
		    					  
		}
				
		if (Tipo_Servicio =='H')
		    Carga_Hoteles_Cadenas(hotel)
		    
	}

	/*Carga los Hoteles por cadena*/		
	function Carga_Hoteles_Cadenas(hotel){		
		var Cadena = '';		
		//var Destino ;
		var Combo;				
		//var Combo  = document.getElementById("CadenaH");
		var radio = document.getElementById("RadioH");
		
		if (radio.checked==true){		
			Combo = document.getElementById("CadenaH");
			Tipo_Servicio ='H';
		}			
		else{
			Combo = document.getElementById("CadenaHF");
			Tipo_Servicio ='HF';
		}
			
		if (Combo.type =="select-one") 
				Cadena = Combo.options[Combo.selectedIndex].value;
		else
				Cadena = Combo.value;		
							
		
		var Combo  = document.getElementById("Destino");						
		//Destino = Combo.value;  //  Combo.options[Combo.selectedIndex].value;
		
		// objeto en donde vamos a almacenar la informacion						
		var cbo  = document.getElementById("_Nombre");
			
			
		//Es un Combo ?
		//if (cbo.type =="select-one") { 
				
			var dt = AutoComplete.search_Hoteles_Cadenas(Tipo_Servicio, Cadena, Combo.value, Idioma , Sitio).value;
			
			if 	(dt == null)				
				return;
			cleanSelect (cbo);
			
			//Primer Opcion del Combo de Hoteles
			if (Idioma.toUpperCase() == "ESP")
				cbo.options[0] = new Option(txtHotelESP, '');	
			else
				cbo.options[0] = new Option(txtHotelING, '');		
			
			//Lleno el Combo de Hoteles
			for (var i=0; i<dt.Rows.length; i++){
				//Valido si la Clave que me envian es igual a la de los Datos Si es Igual lo Selecciono
				if (dt.Rows[i].Nombre_Hotel == hotel) 					//dt.Rows[i].Clav_Hotel
					cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Hotel, dt.Rows[i].Nombre_Hotel,true,true); //El Seleccionado
				else
					cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Hotel, dt.Rows[i].Nombre_Hotel,false,false);	//No Seleccionados			
									
			}
		//}	
		
	}
	
	//--------------------------------------Temas---------------------------------------------

	/*Funcion que carga los destinos por cadena*/	
	function Carga_Destino_Temas(destino){			
					
		var radio = document.getElementById("RadioH");
		if (radio.checked==true)
			Tipo_Servicio ='H';
		else
			Tipo_Servicio ='HF';
		
		var combo;
		if (Tipo_Servicio =='HF')
			Combo  = document.getElementById("TemaHF");
		else
			Combo  = document.getElementById("TemaH");
				
		var dt = AutoComplete.search_destino_temas(Tipo_Servicio, Combo.value, Idioma, Sitio).value;

		if 	(dt == null)				
			return;
		
		// objeto en donde vamos a almacenar la informacion
		//var cbo  = document.getElementById("Destino");
		var cbo  = document.getElementById("Destino");
					
		cleanSelect (cbo);
			
		//Primer Opcion del Combo de Destinos
		if (Idioma.toUpperCase() == "ESP")
			cbo.options[0] = new Option(txtDestinoESP, 0);	
		else
			cbo.options[0] = new Option(txtDestinoING, 0);	
			
		//Lleno el combo de Temas de Hotel 
		for (var i=0; i<dt.Rows.length; i++){
		
			//Seleccciono cuando sean igual el valor del destino
		    if (dt.Rows[i].Clav_Destino == destino)
				cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Destino, dt.Rows[i].Clav_Destino,true,true);
		    else 		    
				cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Destino, dt.Rows[i].Clav_Destino,false,false);
			
		}
		
		
	}

	/*Carga los Hoteles por cadena*/		
	function Carga_Hoteles_Temas(hotel){
							
		var CboDestino;
		var CboTema;
		
		if (Tipo_Servicio =='HF')
			CboTema  = document.getElementById("TemaHF");
		else
			CboTema  = document.getElementById("TemaH");
		
		//Cadena = Combo.options[Combo.selectedIndex].value;
		
		CboDestino  = document.getElementById("Destino");
		///Destino = Combo.options[Combo.selectedIndex].value;

		// objeto en donde vamos a almacenar la informacion						
		var cbo  = document.getElementById("_Nombre");
		
		
		//obj.type = select-one  (es un combo)	
		//obj.type = text  (es un Text)	
		
		//Es un Combo ? 
		if (obj.type == "select-one") {
		
			var dt = AutoComplete.search_Hoteles_Cadenas(Tipo_Servicio, CboTema.value, CboDestino.value, Idioma , Sitio).value;
			
			//Si hay Datos
			if 	(dt == null)				
				return;
			cleanSelect (cbo);
		
			//Primer Opcion del Combo de Hoteles
			if (Idioma.toUpperCase() == "ESP")
				cbo.options[0] = new Option(txtHotelESP, '');	
			else
				cbo.options[0] = new Option(txtHotelING, '');	
		
			//dt.Rows[i].Clav_Hotel
			for (var i=0; i<dt.Rows.length; i++){
				//Si el nombre es igual al que le envie lo selecciona
				if (dt.Rows[i].Nombre_Hotel = hotel)
					cbo.options[i] = new Option(dt.Rows[i].Nombre_Hotel, dt.Rows[i].Nombre_Hotel,true,true);
				else		
					cbo.options[i] = new Option(dt.Rows[i].Nombre_Hotel, dt.Rows[i].Nombre_Hotel,false,false);
				
			}		
		
		
		}else  //Para Tipo Text
		{
			
			
		}
				
	}  
	
	
	/*					SECCION DE BUSCADOR DE DEALS  (CARGA DESTINOS POR CADENA DE HOTELES)					*/
	
	/*Funcion que carga los destinos por cadena*/	
	function Carga_Destino_Cadenas_Deals(destino,hotel){
					
		var Cadena = '';				
		var Combo;
		
		Tipo_Servicio ='H';	  //Tipo de Servicio	
		Combo = document.getElementById("CadenaH");
		
		// Verificamos que tipo de Objeto es, para saber sonde debemos obtener el valor de la cadena 
		/// Combo o del Hidden
		if (Combo.type =="select-one") 
				Cadena = Combo.options[Combo.selectedIndex].value;
		else
				Cadena = Combo.value;
		
		var dt = AutoComplete.search_Destino_Cadena(Tipo_Servicio, Cadena, Idioma, Sitio).value;

		if 	(dt == null)				
			return;
			
		// objeto en donde vamos a almacenar la informacion
		var cbo;
		
		if (Tipo_Servicio =='HF')		
			cbo = document.getElementById("ciudades");
		else
			cbo = document.getElementById("Destino");
					
		cleanSelect (cbo);
		
		//Primer Opcion del Combo de Destinos
		if (Idioma.toUpperCase() == "ESP")
			cbo.options[0] = new Option(txtDestinoESP, 0);	
		else
			cbo.options[0] = new Option(txtDestinoING, 0);	
		
		//Lleno el Combo con los Destinos
		for (var i=0; i<dt.Rows.length; i++){
				
			//Valido si la clave del Destino es la Misma seleccionada Anteriormente
		    if (dt.Rows[i].Clav_Destino == destino)
				cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Destino, dt.Rows[i].Clav_Destino,true,true); //Opcion seleccionada
		    else
				cbo.options[i+1] = new Option(dt.Rows[i].Nombre_Destino, dt.Rows[i].Clav_Destino,false,false); //No seleccionadas
		    					  
		}
			    
	}


/* Limpiamos los combos para volverlos a llenar */
	function cleanSelect(combo){
		while (combo.options.length > 0) {
			combo.options[0] = null;
		}
	}


	/*Llama esta funcion en caso de error y asi podamos hacer cual fue la causa*/									
	/*Nota: Esta funcion se tiene que anexar al final de cada llamada al procedimiento*/
	/*Ejemplo */											
	/* AutoComplete.search_Destino_Cadena(Tipo_Servicio, Cadena, Idioma, Sitio, ServerSideAdd_CallBack ).value; */
	//-----------------------------------------------------------------------------------^
	function ServerSideAdd_CallBack(response){
		if (response.error != null){
			alert (response.error.Message);
			return;
		}	
	}

	/*Oculta el combo de Hotel*/
	function Oculta_Hotel(){			
		var radio = document.getElementById("RadioH");
		if (radio.checked==true)
			Tipo_Servicio ='H';
		else
			Tipo_Servicio ='HF';
			
		var cbo  = document.getElementById("Nombre");
		
		if (Tipo_Servicio == 'HF')
			cbo.style.visibility='hidden';
		else
			cbo.style.visibility='visible';				
		
		Carga_Destino_Cadenas();
		Carga_Hoteles_Cadenas('');
	}


