disAlertCaracteresInvalidos_ESP = "Caracteres Invalidos:";
disAlertCaracteresInvalidos_ING = "Invalid Characters:";

var elfoco = false;     //Para saber que adulto - Niño fue seleccionado
var IdSeat_foco;        //Que id del Adulto - Niño fue seleccionado
var Avion_Select;       //Indica que Avion esta Revisando
//Ayuda de Paquetes  
var Tmpmoveobj;
var Tmpobj;             //objeto que se va a buscar la posicion..

/*function changeScrollBar () {		
	document.body.style.scrollbarBaseColor =  "#E8C071";
	document.body.style.scrollbarArrowColor = "#0A0000";
	document.body.style.scrollbar3dlightColor = "#F40061";
	document.body.style.scrollbarDarkShadowColor = "#000E93";
	document.body.style.scrollbarFaceColor = "#E8AB1E";
	document.body.style.scrollbarHighlightColor = "#698700";
	document.body.style.scrollbarShadowColor = "#00747C";
	document.body.style.scrollbarTrackColor = "#005B0A";
}*/

function SubmitFromArray(formaArr)
{   
	var error = false; //Por default no hubo error para que haga solo el envio.
		
	//Para cuando tenga onsubmit el form
	if(typeof(formaArr.onsubmit) != "undefined" && formaArr.onsubmit != null )   //Si tiene la propíedad de onsubmit  la ejecuto
	{
	  if (formaArr.onsubmit()==true)
	    error = false;  //todo bien
	  else
	    error = true;  //hubo un error
	}   
				
	if (error == false)  //Si no hay error hago el submit del form..
	  formaArr.submit();
}

function SubmitFromArrayManual(formaArr,onsubmit,action)
{   
	var error = false; //Por default no hubo error para que haga solo el envio.
		
	//Para cuando tenga onsubmit el form
	if(typeof(formaArr.onsubmit) != "undefined" && formaArr.onsubmit != null && onsubmit != "")   //Si tiene la propíedad de onsubmit  la ejecuto
	{	
	  formaArr.onsubmit = onsubmit;  //cambio 
	  if (formaArr.onsubmit()==true)
	    error = false;  //todo bien
	  else
	    error = true;  //hubo un error
	}   
				
	if (error == false) {  //Si no hay error hago el submit del form..
	  if(typeof(formaArr.action) != "undefined" && formaArr.action != null && action != "")   //verifico si existe atributo 
		 formaArr.action = action;		
		 
	  formaArr.submit();
	}
}

// Put Focus if Called
if (window.focus) {
	self.focus();
}	
function changeactionform(forma,url){
	forma.action = url;        
}

//Funcion que Cambia la Accion del Formulario de "PAGINAS DE DESTINOS"
function ChangeActionHotel(forma,objval,url,urlgral){

	//del Arreglo optengo la carpeta del destino
	var carpetaDestino = (arrayDestinos[objval.value] != null ) ? arrayDestinos[objval.value] : "";	
		
	if (carpetaDestino != "" ) {	
		url = url.replace("<path>",carpetaDestino);	//Arma la ruta del destino
		forma.action = url; 								//cambio la action del form de destinos
	}else {			
		forma.action = urlgral; 	//cambia action y manda a la Pagina General
	}	
	
}

//funcion que cambia la accion del formulario segun el Operador de traslados
function ChangeActionShuttles(forma,ruta,airport){
	
	//debe tener formato  "Aiport" | "Clave Operador"
	if (airport.value != '')  {
		var result = airport.value.split("|");
		
			airport	 = (result[0] != null && result[0] != "undefined")? result[0] : '';  //Obtengo Nombre Corto o Aeropuerto
			operador = (result[1] != null && result[1] != "undefined")? result[1] : '';  //Obtengo clave del Operador
	} else {
		airport = ''; operador = '';
	}
	
	ruta = ruta.replace('<air>',airport);		//pongo el aeropuerto
	if (operador != ''){
		if (ruta.indexOf("?") > -1)  //Tiene en la ruta "?"
			ruta = ruta + "&ID=" + operador;	//Pongo "&ID=" + ClvOperador
		else	
			ruta = ruta + "?ID=" + operador;	//Pongo "?ID=" + ClvOperador
	}			
	forma.action = ruta;						//cambio la accion del formulario
}

// openWindow function for photo gallery
function openGallery(src) {
	popupWin = window.open(src,'gallery', 'top=25,left=25,width=422,height=390,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}
// openWindow function for photo gallery
function openMeetingMap(src) {
	popupWin = window.open(src,'gallery', 'top=25,left=25,width=400,height=300,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}
// openWindow function for calendar
function openCalendar(src) {
	popupWin = window.open(src,'calendar', 'top=35,left=35,width=373,height=380,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for room info
function openRoomInfo(src) {
	popupWin = window.open(src,'Rooms', 'top=25,left=25,width=415,height=300,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for billing and cancelation policies
function openTerms(src) {
	popupWin = window.open(src,'Terms', 'top=25,left=25,width=465,height=300,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for print rates
function openRates(src) {
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openRatesHotelList_T1(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=T1MSNMX&Type=Hotels&View=List&Idioma=ESP&moneda=PE&destino=' + destino + '&dia_desde=' + document.forma.dia_desde.value +  '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&dia_hasta=' + document.forma.dia_hasta.value +  '&mes_hasta=' + document.forma.mes_hasta.value + '&anio_hasta=' + document.forma.anio_hasta.value 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}
         
function openRatesHotelList_Todito(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=todito&Type=Hotels&View=List&Idioma=ESP&moneda=PE&destino=' + destino + '&dia_desde=' + document.forma.dia_desde.value +  '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&dia_hasta=' + document.forma.dia_hasta.value +  '&mes_hasta=' + document.forma.mes_hasta.value + '&anio_hasta=' + document.forma.anio_hasta.value 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openRatesHotelList_T1_2(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=T1MSNMX&Type=Hotels&View=List&Idioma=ESP&moneda=PE&destino=' + destino + '&dia_desde=' + document.forma.dia_desde.value +  '&mes_desde=' + document.forma.mes_desde.value + '&anio_desde=' + document.forma.anio_desde.value + '&nights=' + document.forma.nights.value 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openRatesTourList_T1(asoc,idioma,destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=T1MSNMX&Type=Tours&View=List&Idioma=ESP&moneda=PE&destino=' + destino 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openRatesTourList_Todito(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/Reservations/Partners.aspx?asoc=todito&Type=Tours&View=List&Idioma=ESP&moneda=PE&destino=' + destino 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

//http://www.e-travelsolution.com/reservations/partners.aspx?view=info&airport=cun&type=Transfers&Asoc=livcun

function openRatesTransferList_T1(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/reservations/partners.aspx?view=info&airport=' + destino +  '&type=Transfers&Asoc=t1msnmx&Menu=yes' 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')		
}

function openRatesTransferList_Todito(destino) {
	var src
	src= 'http://www.e-travelsolution.com.mx/reservations/partners.aspx?view=info&airport=' + destino +  '&type=Transfers&Asoc=todito&Menu=yes' 
	popupWin = window.open(src,'Print', 'top=25,left=25,width=710,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// openWindow function for tour info
function openInfoTour(src) {
	popupWin = window.open(src,'Tour', 'top=25,left=25,width=550,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open('','newWindow',"width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function openWindowMap(src,imageWidth,imageHeight) {
	popupWin = window.open(src,'Map', 'top=25,left=25,width='+imageWidth+',height='+imageHeight+',buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

function Redirect(forma,url) {
	forma.action=url;
	forma.submit();
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// openWindow function for tour info or hotel info asoc
function OpenPopAsoc(src, tipo) {
	popupWin = window.open(src,tipo, 'top=25,left=25,width=635,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')
}

// <a href="#" onClick="javascript:openCalendar('/_lib/asp/popCalendarTour/?clav_tour=2&clav_servicio=1&clav_ciudad_origen=CUN&Month=9&Year=2005');"

// openWindow function for tour info or Hotel asoc in Pop Up
function OpenPopAsocRedirect(forma, src, tipo) {
    //forma.target=window.open(src,tipo, 'top=25,left=25,width=635,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
    //forma.target='_blank';
	//forma.action=src;
	//forma.submit();
	}
	
	
	
function submitoptions(idioma,recalcular,action)
{
	error = false;
	if (document.forma.Check_transfer) {
		if (document.forma.Check_transfer.checked == true & (document.forma.AirlineReturn.value == " || document.forma.AirlineGo.value == " )) {
			if (idioma == "ing") {
				alert("Please Indicate the airline and flight number for your airport shuttle") ;
				return ;
			}
			if (idioma == "esp")
			{
				alert("Por favor indique la aerolinea y vuelo para su traslado del aeropuerto") ;
				return ;
			}
		}
		
	    if (recalcular == "yes") {
			document.forma.submit();
		    return;
	    }
	    if (recalcular == "no") {
			document.forma.action = action;
	        document.forma.submit();
	    }
	    return true;	
	} else {
		if (recalcular == "yes") {
			document.forma.submit();
		    return;
	    }
	    if (recalcular == "no") {
	        document.forma.action = action;
	        //document.forma.submit();
	    }
		document.forma.submit();
	}
}


	
function submitoptions2(idioma,recalcular,action)
{	
	if (typeof fortyone != "undefined" && fortyone !=null)
		fortyone.collect('userPrefs');
		
	error = false;
	if (document.forma.Check_transfer) {
		if (document.forma.Check_transfer.checked == true & (document.forma.AirlineReturn.value == " || document.forma.AirlineGo.value == " )) {
			if (idioma == "ing") {
				alert("Please Indicate the airline and flight number for your airport shuttle") ;
				return ;
			}
			if (idioma == "esp")
			{
				alert("Por favor indique la aerolinea y vuelo para su traslado del aeropuerto") ;
				return ;
			}
		}
		
	    if (recalcular == "yes") {
			document.forma.submit();
		    return;
	    }
	    if (recalcular == "no") {
			document.forma.action = action;
	        document.forma.submit();
	    }
	    return true;	
	} else {
		if (recalcular == "yes") {
			document.forma.submit();
		    return;
	    }
	    if (recalcular == "no") {
	        document.forma.action = action;
	        //document.forma.submit();
	    }
		document.forma.submit();
	}
}



function ol(elURL) {
	window.open(elURL)
}
  

// **********************************************************************************************************
//                       FUNCIONES PARA PAQUETES DE AVION + HOTEL
// **********************************************************************************************************
   
function showPage(sshow)
{
	//0 = Oculta
	//1 = Mostrar		
	var obj = document.getElementById('cajon')	
	//Si existe oculta el div de pagina espera
	if (obj != null) {		
		if (sshow == 1) 
			eval ("document.getElementById('cajon').style.display=''");  
		else 
			eval ("document.getElementById('cajon').style.display='none'");  		
	}
 }
 //funcion que cambia el valor de un objeto dentro de un formulario
 //[forma] = string ó Objeto 
 //[obj]   = string,  
 //[valor] = cualquiera,  
function changevalueObj(forma,obj,value) {  
	
	var _obj = eval("document." + forma + "." + obj);
	if (typeof _obj!= "undefined" && _obj!=null)
		_obj.value = value;
	
 }

//pasa un cadena de objetos ej. 'NumPagina,Sort,Orden','1,A,7' 
// Add Hidden = 'Hora_Entrega,Hora_Devolucion','18,19' 
 function changevalueObjs(forma,objs,tvalues) {  
  	//Tipo de delimitador de datos 
  	var delimitadorObj	  = (objs.indexOf(",") > -1) ?  "," : "|";
 	var delimitadorValues = (tvalues.indexOf(",") > -1) ?  "," : "|";
 			
 	objs = objs.split(delimitadorObj);  //Separo los Objetos con el delimitador
 	tvalues = tvalues.split(delimitadorValues);  //Separo los valores con el delimitador
 	  	
	for(var i=0;i<objs.length;i++) { 	
		var _obj = objs[i];  //Nombre del Primer Objeto encontrado
		if(typeof _obj == "string") { 
			_obj = eval("document." + forma + "." + _obj )
			if (typeof _obj != "undefined" && _obj != null)
				if (typeof tvalues[i] != "undefined" && tvalues[i] != null )
					_obj.value = tvalues[i];  //paso su valor
		}
		
	}	
}

//Funcion que Almacena todos los valores de Elementos que le diga  a un hidden = 'Hora_Entrega,Hora_Devolucion' ->  almacena temporalmente
 function setValuesHidden(forma,objs,setValHidden) {  
 
	//Si no existe el elemento donde voy a almacenar lo saco
	if (typeof setValHidden == 'undefined' || setValHidden == null)
		return false;
		
	//Si no tiene elementos por barrer lo saco ->Formato de Objetos:  'anio_desde,mes_desde,etc..'
	if (objs == '')
	  	return false;
	  	
  	var delimitadorObj	  = (objs.indexOf(",") > -1) ?  "," : "|"; //obtiene tipo de delimitador
  	  	
  	//Formato de Objetos:  'anio_desde,mes_desde,etc..'
 	objs = objs.split(delimitadorObj);  //Separo los Objetos con el delimitador
 	setValHidden.value = '';  //Limpio antes de volver a armar
	for(var i=0;i<objs.length;i++) { 	
		var _obj = objs[i];  //Nombre del Primer Objeto encontrado
		if(typeof _obj == "string") {
			//Verifico si el formulario ya es objeto o String	
			_obj = (typeof forma == "string") ? eval("document." + forma + "." + _obj) : eval("document." + forma.name + "." + _obj); 			
			if (typeof _obj != "undefined" && _obj != null)
				setValHidden.value += _obj.value + '|'; //Almacena el comportamiento del Usuario en hidden
		}		
	}	
}

//Funcion que Obtiene todos los valores de Elementos que le diga  a un hidden = 'Hora_Entrega,Hora_Devolucion' ->  almacenado temporalmente
 function getValuesHidden(forma,objs,getValHidden) {  
 
	//Si no existe el elemento donde voy a almacenar lo saco
	if (typeof getValHidden == 'undefined' || getValHidden == null)
		return false;
	
	//Si no tiene valores el hidden lo saco	
	if (getValHidden.value == '')
		return false;
		  	
  	//Formato de Objetos:  'anio_desde,mes_desde,etc..'
  	var delimitadorObj	  = (objs.indexOf(",") > -1) ?  "," : "|";
  	
  	//Formato de Datos:  '1,2,etc..'
 	var delimitadorValues = (getValHidden.value.indexOf(",") > -1) ?  "," : "|";
  	
 	objs = objs.split(delimitadorObj);  //Separo los Objetos con el delimitador 		
 	getValHidden = getValHidden.value.split(delimitadorValues);  //Separo los valores con el delimitador del elem hidden
 	
	for(var i=0;i<objs.length;i++) { 	
		var _obj = objs[i];  //Nombre del Primer Objeto encontrado
		if(typeof _obj == "string") {
			//Verifico si el formulario ya es objeto o String	
			_obj = (typeof forma == "string") ? eval("document." + forma + "." + _obj) : eval("document." + forma.name + "." + _obj);
			if (typeof _obj != "undefined" && _obj != null)
				_obj.value = getValHidden[i]; //Obtiene valor del elemento 
		}		
	}	
}

 
//Mas Vuelos de paquetes
function Next_Flights(maxGroups)
{	
	var i = 0;
	var presiono = document.getElementById('cuenta').value;
	presiono++;
	document.getElementById('cuenta').value = presiono; //paso el valor nuevo al

	for (i=1; i<=maxGroups; i++) {
		//Si ya revaso el maximo ?
		if (presiono > maxGroups ) {
			Hide_Flights(maxGroups);  //Oculto los Objetos
			document.getElementById('cuenta').value = 1;  //Regreso al primer valor
			eval ("document.getElementById('flight_group_1').style.display=''"); 
		} else {
			if (i == presiono)
				eval ("document.getElementById('flight_group_" + i +"').style.display=''"); 
			else
				eval ("document.getElementById('flight_group_" + i +"').style.display='none'"); 
		}
	}   
}

//Menos Vuelos de paquetes
function Previus_Flights(maxGroups)
{ 
	var i = 0;
	var presiono = document.getElementById('cuenta').value;
	presiono--;
	document.getElementById('cuenta').value = presiono; //paso el valor nuevo al

	//Hide_Flights (maxGroups)
	for (i=1; i<=maxGroups; i++) {
		//Si ya revaso el maximo ?
		if (presiono < 1 ) {             
			Hide_Flights(maxGroups);  //Oculto los Objetos
			document.getElementById('cuenta').value = maxGroups;  //Regreso al primer valor
			eval ("document.getElementById('flight_group_" + maxGroups +  "').style.display=''"); 
		} else {
			if (i == presiono) 
				eval ("document.getElementById('flight_group_" + i +"').style.display=''"); 
			else
				eval ("document.getElementById('flight_group_" + i +"').style.display='none'"); 		
		}
	}
}
  
//Oculta Todos los Vuelos
function Hide_Flights (maxGroups) 
{ 
	var i;
	for (i=1; i<=maxGroups; i++) {
		eval ("document.getElementById('flight_group_" + i +"').style.display='none'"); 
	}
}

//Oculta Todos Asientos de Adultos - Niños del Todos los Aviones
function Hide_Adults_Childs(max) { 
	var i;
	for (i=1; i<=max; i++){
		eval ("document.getElementById('Avion_SeatsAdNi_" + i +"').style.display='none'"); 
	}    
}
  
function Hide_Airplane(max) { 
	var i;
	for (i=1; i<=max; i++) {
		eval ("document.getElementById('avion_" + i +"').style.display='none'"); 
	}    
}

function Show_Airplane(avion,max) {        

    //elfoco  = false           //Bronca al poner el dato se queda con el enfoque anterior  del primer vuelo   
    Hide_Airplane(max);        //Oculto todos los Aviones 
    Hide_Adults_Childs(max);  //Oculto el Grupos de Asientos del Avion ( Adultos - Niños )
    
    //Muestro el Avion del Vuelo Seleccionado
    eval ("document.getElementById('avion_" + avion +"').style.display=''");   
    //Muestro el Grupo de Asientos del Vuelo Seleccionado  ( Adultos - Niños )
    eval ("document.getElementById('Avion_SeatsAdNi_" + avion +"').style.display=''");   
    //Busco el nombre del Vuelo seleccionado
    Name_Flight_Select(avion,max);
    //Cambio la Clase del Vuelos Seleccioando  
    change_class(avion,max);
    //Paso que Avion fue seleccionado    (Variable Global)      
    Avion_Select =  avion;          
}
  
//Busco y paso el nombre del Vuelo seleccionado
function Name_Flight_Select(vuelo,max) { 
	var i;
	var myName="";
	for (i=1; i<=max; i++) {
		//Tomo el nombre del Vuelo Seleccionado 
		if (vuelo == i) {            
			myName = eval ("document.getElementById('Name_flight" + i +"').value");  //busco el nombre de vuelo selccionado           
			document.getElementById('Name_Selectflight').value = myName;   //paso el valor a un oculto           
		}
	}    
}
  
function change_class(avion,max) { 
	var i; 
	//Hago  el barrido de todos los Vuelos
	for (i=1; i<=max; i++) {        
		//Cambio la clase del Vuelo Seleccionado
		if (avion == i)        
			eval ("document.getElementById('myclass_" + i +"').className='FlightSelect'"); //cambio la clase a SELECCIONADO
		else        
			eval ("document.getElementById('myclass_" + i +"').className='FlightNonSelect'"); //cambio la clase a NO SELECCIONADO    
	}    
}
  
// **********************************************************************************************************
//                        VENTANA  EMERGENTE QUE INDICA EN QUE ASIENTO DEL AVION ESTOY UBICADO
// **********************************************************************************************************
/*var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_ie =  (appVer.indexOf('msie') != -1) && (!is_opera);*/

function getScrollXY() {
	var scrOfX = 35, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number')  {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;		
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )  {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}

function getWindowSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth, myHeight];
}
//Regresa Objeto(s)
function $() {    
	var _IdArray=new Array();	
	for(var i=0;i<arguments.length;i++) { 	
		var _Id=arguments[i];
		if(typeof _Id == "string") { 
			_Id = document.getElementById(_Id); //objeto por Id
		}
		if(arguments.length==1) {
			return _Id;
		}
		_IdArray.push(_Id);
	}
	return _IdArray;
}
//Regresa elementos por Tag Name(s)
function $TagName() {
	var _tagNameArray=new Array();	
	for(var i=0;i<arguments.length;i++) { 	
		var _tagName = arguments[i];
		if(typeof _tagName == "string") { 
			_tagName = document.getElementsByTagName(_tagName); //Tag Name
		}
		if(arguments.length==1) {
			return _tagName;
		}
		_tagNameArray.push(_tagName);
	}
	return _tagNameArray;
	
}

function showPopupWithContent(content,obj,idhtml,posPopUp)  {  

    var mleft;
    var mTop;
	var popupDiv = $('hdPopupDiv');  
	var popupContentDiv = $('hdPopupContent');	
	var popupWidthContainer = parseInt(popupWidth);
	//popupHeaderDiv.style.width = popupWidthContainer;
	//popupTitleDiv.innerHTML = '<strong>' + popupTitle + '</strong><img src="/_lib/images/info.gif" border="0" align="right" width="19">';
	//popupTitleDiv.style.overflow = "hidden";
	//popupTitleDiv.style.whiteSpace = "nowrap";
	//popupTitleDiv.style.width = popupWidth;//parseInt(popupWidth)-65;
    //popupActionsDiv.style.width = popupWidth;

	var popupHtml = content;
	//popupCloseButton.style.visibility = "visible";
	//popupCloseButton.style.display = "inline";
   	//popupCloseButton.style.left = ((popupWidth)/2)-56;
	//popupContentDiv.style.width = popupWidth-20;
	//popupContentDiv.style.height = parseInt(popupHeight)- 50;
	
	popupContentDiv.innerHTML = popupHtml;   //"<div>"+ popupHtml+"</div>";
	popupDiv.style.display = "block";
	
	var windowSize = getWindowSize();	
	//var scrollXY = getScrollXY();
	popupDiv.style.width = popupWidthContainer;
	popupDiv.style.position = "absolute";

	popupDiv.style.background = "#FFFFFF";
	//popupDiv.style.border = "1px solid #000000";	
	var posElementXY = getPositionElement(obj);
	
	//idhtml = vacio entonces arma el html en java
	if (idhtml == "") {    
	
	    // Left: I=izquierda, C=centrado, D=derecha
		switch (posPopUp) {
			case "I": mleft = (posElementXY[0] - popupWidthContainer + 20);  break;
			case "C": mleft = (posElementXY[0] - popupWidthContainer/2 + 10); break;
			case "D": mleft = (posElementXY[0] + 20);	break;
			default: mleft = (posElementXY[0] + 20);
		}
		mTop = (posElementXY[1] + 20);	 //Top
	} else 	{   
		//Cuando envio el Html ( Tomo de la Pagina )
	    mleft = (posElementXY[0] + 50);  //Left
        mTop = (posElementXY[1] + 38);	 //Top
    }
	
	popupDiv.style.left = mleft; //left del Objeto  //((windowSize[0] - popupWidth ) / 2) + scrollXY[0];
	popupDiv.style.top = mTop;  //Top del Objeto  //((windowSize[1] - popupHeight) / 2) + scrollXY[1];
	popupDiv.style.zIndex = 100;
	
	displayLayer('hdPopupDiv',true);
}
function displayLayerAsObj(divObj, popup) 
{
    if(popup == true) {
		divObj.style.zIndex = 100;
	}
	divObj.style.visibility = "visible";
	divObj.style.display = "inline";
}
//Me da la Posicion Izquierda del elemento
function getPositionElement(elem) {   
	
	var curleft=0;  //default left
	var curtop=0;   //default top       
	var obj = $(elem);   //tomo el nombre del elemento y convierto en objeto

	//Si tenemos al objeto
	if (obj != null) {       
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;  //tomo la posicion left del objeto
			curtop = obj.offsetTop;  //tomo el tope del objeto
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
            }
		}
		curleft=parseInt(curleft);
		curtop=parseInt(curtop); 
	}   
	return [curleft, curtop];
} 

function displayLayer(layerName, popup) {
	var currentLayer = $(layerName);
	displayLayerAsObj(currentLayer, popup);
}
function hideLayer(layerName)  {   
	DisplayObj(layerName,0);
    /*var divObj = $(layerName);    
	divObj.style.visibility = "hidden";
	divObj.style.display = "none";*/
}
function hidePopup(layerName) 
{    
	var Version =navigator.appVersion.substring(22,25);
	Version = parseInt(Version);	
	if (navigator.appName=="Microsoft Internet Explorer")
		if (Version < 7)	    
			Mostrar_Elementos();
	hideLayer(layerName); 
}

 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";
	}	    
  }

function displayMesagge(event,ColBde_Tit,titseat,tittext,width,height,obj,idhtml) {  
 
    var ruta_imagen = document.getElementById('Ruta_Imagen'); 
    //Verifico que si exista el elemento Ruta de Imagen del Sitio
    ruta_imagen = (typeof ruta_imagen != "undefined" && ruta_imagen != null) ? ruta_imagen.value : "";
    
    
    var content ="";
    var htmlTemp="";
        
	popupWidth = width;
	popupHeight = height;
		
	//Si no tiene valor  color le pongo Blanco
	if (ColBde_Tit=="") 
		ColBde_Tit = "#FFFFFF";  //Blanco
	
	
	//Significa que no trae Html debo pintar el que Armo en el Java
	if (idhtml =="") {
	
		//Nombre del Vuelo Seleccionado
	    popupTitle = document.getElementById('Name_Selectflight');  	    
	    popupTitle = (typeof popupTitle != "undefined" && popupTitle !=null) ? popupTitle.value : "";
	    
	    var num_seat = getSeat(obj);  //tomo el numero del asiento
    		
        //Armo el Html de la Ventana Emergente de las Cabinas de Avion		
    	
	    content += '<div style="height:100%; width:' + (popupWidth-5) + '; font-family: Trebuchet MS, Verdana;">'; 		
        content += '<table width=' + width + ' border="0" cellspacing="0" cellpadding="1" style="font-size:14px;">';
        /*content += '  <tr>';
        content += '    <td align="center" colspan="2" bgcolor="' + ColBde_Tit + '"><strong>' +  popupTitle +  '</strong></td>';
        content += '    <td bgcolor="'+  ColBde_Tit + '"><img src="' + ruta_imagen +    '/infoA.gif" width="19" height="19" border="0" align="right"></td>';
        content += '  </tr>';*/
        content += '  <tr>';
        content += '    <td valign="middle">';
        //'Segun el sitio pongo Ruta de Iamgen del Asiento      
        content += '<img src="' + ruta_imagen +    '/As_Disp.gif" border="0" vspace="2" hspace="2" align="right" />';
        content += '</td>';
        //Available Space
        content += '    <td style="font-size:12px">&nbsp;' +  tittext + '&nbsp;<strong>' + num_seat + '</strong></td>';
        content += '    <td>&nbsp;</td>';
        content += '  </tr>';
        /*content += '  <tr>';
        content += '    <td >&nbsp;</td>';       
        //Titulo Seat   y Numero de Asiento
        content += '    <td style="font-size:12px"><strong>' +  titseat  +  ':</strong>&nbsp;' + num_seat + '</td>';
        content += '    <td>&nbsp;</td>';
        content += '  </tr>';
        content += '  <tr>';
        content += '    <td align="center"><img src="' + ruta_imagen +    '/avionI.gif" width="26" height="22" border="0" align="left" /></td>';
        content += '    <td>&nbsp;</td>';
        content += '    <td>&nbsp;</td>';
        content += '  </tr>';*/
        content += '</table>';
        content += '</div>';
        
    } else  {	    
		//Regreso el Html que le paso	    
	    htmlTemp = arrWindows_html[idhtml];
	    content += '<div style="height:100%; width:' + (popupWidth-5) + '; font-family: Trebuchet MS, Verdana;">'; 
	    content += htmlTemp;  //el Html que quiero mostrar
	    content += '</div>';	    
	}	  
	//alert(content);
	showPopupWithContent(content,obj,idhtml,'D');	  //Escupo el Html que le pase o que Armo en Html   
}

//Funcion que Regresa el Nombre del Asiento que recibe el enfoque  
function getSeat(obj) {	
    var objseat = $(obj);   //Obtengo el Objeto asiento       
    var val = objseat.alt;    //tomo su valor del alt        
    return val;  //Regreso el valor del asiento "ALT"   
}

//Pone el asiento selecionado al los Adultos - Niños
function setSeatAdNi(obj,maxAd,maxNi) {       

    //Nota:   obj = ( Nombre del Objeto 'V1_Seat1_1')
    var objseat = $(obj);           //Convierto en objeto el asiento
    var myseat = getSeat(obj);      //Obtengo el nombre del asiento           
    var maxObj = maxAd + maxNi;     //Sumo el total de Adultos + Niños
    var armaObj;                    //Armo el nombre del objeto asiento
    var tmparmaObj;                 //Armo el nombre para cuando busco si el asiento fue asignado
    var arrayBusca;                  //Regreso true ó false de encontardo y indice del  encontrado
    var obj_tomoval;                //Nombre del Objeto asiento de donde tomo el valor
    var armaObjPos;                 //Objeto donde esta ubicado el foco
    
    arrayBusca = Busca_Valor(myseat,maxObj);    //Busco si ya esta asignado el asiento asignado       
    armaObjPos = $('V' + Avion_Select + '_ubicado');   //elemento seleccionado ( Asiento )
    
    //Ya estaba ubicado anteriormente ? 
    if (armaObjPos.value=="") {
		elfoco = false;  //Obligo que sea automatico por lo tanto pondra al primer elemento vacio el asiento      
    } else {
		elfoco = true;  //Obligo que sea por seleccion     
		IdSeat_foco = armaObjPos.value;   //Obtengo la Posicion donde se quedo  Valor Hidden   
    }
                 
    //Elemento con FOCO ( Cuando se selecciono directamente el adulto - niño )
    if  (elfoco == true) {
    
        armaObj = $('V' + Avion_Select + '_Seat_' + IdSeat_foco);           //asiento con el foco
        obj_tomoval = $('V' + Avion_Select + '_obj_click_' + IdSeat_foco);   //de que objeto asiento se tomo el valor
        tmparmaObj = $('V' + Avion_Select + '_Seat_' + arrayBusca[1]);      //Objeto en donde se encontro el valor
        
        //encontro el numero de asiento (ya se asigno anteriormente)
        if (arrayBusca[0] == true) {         
        
            //Si son iguales los valores  limpio al adulto - Niño          
            if (armaObj.value ==  tmparmaObj.value) {                           
              My_Seat(objseat,'AS_Disp.gif');   //Cambio su estado a disponible
              armaObj.value = "";               //limpio Numero de asiento Aduulto - Niño                                                        
              obj_tomoval.value = "";           //Limpio el nombre del objeto de donde tomo el valor
            }               
        } else {      
                     
			//si tiene dato ? SI ==  Tiene el objeto de donde tomo el valor
            if (obj_tomoval.value != "") { 
                  var obj_ant = $(obj_tomoval.value);  //Objeto anterior de donde se tomo el valor del asiento                        
                  My_Seat(obj_ant,'AS_Disp.gif');      //Cambio su estado a disponible                  
            }                
            My_Seat(objseat,'AS_Asign.gif');         //My asiento    
            armaObj.value =  myseat;                 //asigno el asiento al adulto - niño  
            obj_tomoval.value = obj;                 //paso el nombre del objeto 
                                   
            //elfoco = false;                  //Llena de manera automatica 
        }       
       
    } else  { //Elemento sin FOCO
        //Recorro el Total de Objetos Adultos - Niños
        for (var i=1; i<=maxObj; i++ ) {           
        
            armaObj = $('V' + Avion_Select + '_Seat_' + i);                       //Obtengo el Objeto asiento
            obj_tomoval = $('V' + Avion_Select + '_obj_click_' + i);              //de que objeto asiento se tomo el valor           
            tmparmaObj = $('V' + Avion_Select + '_Seat_' + arrayBusca[1]);        //Objeto donde encontro el asiento
            
             //  ya fue asignado ? True = Asignado,     false = "NO Asignado"
             if (arrayBusca[0] == true) {                              
				if (armaObj.value ==  tmparmaObj.value)                   
					break;  //no hago nada                
					
             } else {
                  //el Valor del Objeto esta Vacio ?  Si = Pongo valor del Asiento  
                  if (armaObj.value == "")  {                         
                      My_Seat(objseat,'AS_Asign.gif');        //My asiento 
                      armaObj.value =  myseat;                //Pongo numero de asiento al Objeto asiento
                      obj_tomoval.value = obj;                //paso el nombre del objeto 
                      ImgApunta_AdultNinio(i,maxObj,'A');     //Apuntador (Imagen) -- Se si el Objeto tiene el Foco                      
                      break;
                  } 
             }           
        }
    }       
}

//Apunta la posicion del asiento con una imagen
function ImgApunta_AdultNinio(ind,max,tipo) {  //ImgApunta_Asiento

   //elfoco = false;  //por default no tiene el enfoque el asiento
      
    var ruta_img = document.getElementById('Ruta_Imagen').value;   //Obtengo la Ruta de imagen segun el sitio
    var img_Select =  ruta_img + '/arrowsmall.gif';  //Img Adulto seleccionado
    var img_NoSelect =  ruta_img + '/spacer.gif';   //Img Adulto No seleccionado        
    var armaObj;
    var armaObjPos;  //Indica cual es el Objeto que esta actualmente posicionado vuelo X Vuelo
       
    //Recorro el Total de Objetos Adultos - Niños
    for (var i=1; i<=max; i++ ) {     
      //Significa que es por asignacion por seleccion
      if (tipo ==  "") {              
		armaObjPos = $('V' + Avion_Select + '_ubicado');      
        armaObjPos.value = ind;  //Paso el Objeto en donde esta posicionado      
        armaObj = $('V' + Avion_Select + '_apunta_' + i);  //Objeto apuntado (  Imagen Bullet azul )
        armaObj.src =  img_Select;   //imagen arrow (seleccionado)
        
        //es el elemento Seleccionado ?  
        if (ind == i) {
            IdSeat_foco = ind;                            //Asiento que tiene el foco
            elfoco = true;                                //Tiene el enfoque el objeto
        } else {
			armaObj.src = img_NoSelect;       //imagen spacer (No seleccionado)  
        }      
      } else  {  //Asignacion Automatica
        //elfoco = false;   //cambio a Manual        
        armaObj = $('V' + Avion_Select + '_apunta_' + i);  //apuntador Imagen Bullet Azul                 
        var j = ind + 1;   //siguiente elemento        
        armaObj.src = img_NoSelect;  //apuntado Imagen no seleccionado
        
        if (j<=max) { //Si es menor del Maximo? 
          armaObj = $('V' + Avion_Select + '_apunta_' + j);  //apunto siguiente elemento "Imagen seleccionado"          
          armaObj.src =  img_Select;                        //Cambio la Imagen asiento a ( My Asiento )
        }   
      }      
    }              
}

//Busca en los Adultos el numero de asiento  y valida si ya fue asignado anteriormente
function Busca_Valor(val,maxObj) {   

    //var qVuelo =  Avion_Select; //Variable Global con Vuelo Seleccionado  
    var encontro = false;  var encontroInd =0;
    var armaObj;  //Objeto Asiento seleccionado
    
    for (var i=1; i<=maxObj; i++ ) {   
		armaObj = $('V' + Avion_Select + '_Seat_' + i);  //Armo el Objeto Asiento 
        
        //Valor que paso, es Igual al valor del elemento seleccionado ?
        if (val == armaObj.value) {        
			return [true,i];  //Fue encontrado y Regreso su indice 
            break;
        }               
    }           
    return [encontro,encontroInd];
}

//Busca Si los elementos estan llenos
function Cuenta_Vacios(maxObj,avion) {       

    var contador=0;  //Contador de elementos vacios
    var armaObj;     //Objeto Asiento seleccionado
    
    for (var i=1; i<=maxObj; i++ ) {   
        armaObj = $('V' + avion + '_Seat_' + i);          
        if (armaObj.value == "") {        
            contador += 1;
        }               
    }           
    return [contador];  //Regresa el numero de elemtos vacios ( Asientos )
}

//Cambia la Imagen del asiento que ya se asigno al pasajero
function My_Seat(objseat,imagen) { 

  var ruta_imagen = document.getElementById('Ruta_Imagen').value;  //Ruta de Imagen segun el sitio
  objseat.src =  ruta_imagen + '/'  +  imagen;                     //Cambio la imagen del asiento asignado
}

//Valida que se haya capturado los datos obligatorios de los Pasajeros
function ValidatePassengers(maxAd,maxni) {
  disTelPasajeroING = "The phone number is invalid";
  disTelPasajeroESP = "Verifique el numero de telefono";
  var mensaje;  
  var armaObj;     //Objetos de Datos de Pasajeros  
  var max = maxAd + maxni;
  var error= false;
    
  //Recorro todos los elementos Obligatorios de Datos Personales de Pasajeros
  for (var i=1; i<=max; i++ ) {   
		//Valida (First Name )
		armaObj = $('first_name_' + i);
		if  (armaObj.value == "") { 
			error= true;          
			break;
		}        
		//Valida (Last Name)
		armaObj = $('last_name_' + i);
		if  (armaObj.value == "") { 
			error= true;          
			break;
		}  
		//Valida (Issue country)
		armaObj = $('issue_country_' + i);
		if  (armaObj.value == "") { 
			error= true;          
			break;
		}
        
		//Datos Adicionales de Adultos ( contact name - contact phone )
		if (i==1 & maxAd > 0 ) { 
			//Valida ( Contact Name )       
			armaObj = $('contact_name_' + i);
			if  (armaObj.value == "") { 
				error= true;             
				break;
			}  
			//Valida ( Contact Phone )       
			armaObj = $('contact_phone_' + i);
			if  (armaObj.value == "") { 
				error= true;             
				break;
			}            
			if (!validaPhone(armaObj.value)) {
				error=true;
				Apunta_Pasajeros("si",i,max);

				//Valido el Idioma para mandar el mensaje 
				mensaje = (document.getElementById('Idioma').value.toLowerCase() == "ing" ) ? disTelPasajeroING : disTelPasajeroESP;
				alert(mensaje);
				armaObj.focus();
      			return false;      
				break;
			}           
		}
		//Valida las Edades de los Niños
		if (i>maxAd & maxni > 0) {
			//Valida ( Contact Name )       
			armaObj = $('EdadNino_' + i);
			if  (armaObj.value == -1) {  //Sibolo "?"  No se capturo nada aun
				error= true;
				break;             
			}
		}        
  }
     
  //Convierte a imagenes sin apuntar
  if (error ==false) { 
	Apunta_Pasajeros("no",1,max);
  } else {      
  
      //Al final mando mensaje de datos faltantes
      Apunta_Pasajeros("si",i,max);
      SendMsgError();
      armaObj.focus();
      return false;      
  }
  return true;
}

function validaPhone(value) {
  var str =value; // email string
  //var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  //var reg1 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;  
  var reg1 = /((\(\d{3,4}\)|\d{3,4}-)\d{4,9}(-\d{1,5}|\d{0}))|(\d{7,12})/;
  
  if (!reg1.test(str)) { // if syntax is valid  
    return false;
  }    
  return true;
}

function SendMsgError() {
	disMandatoryFieldING = "Please fill all mandatory fields";
	disMandatoryFieldESP = "Por favor llenar todos los campos obligatorios";

	//Valido segun Idioma el mensaje a mostrar
	var mensaje = (document.getElementById('Idioma').value.toLowerCase() == "ing" ) ? disMandatoryFieldING : disMandatoryFieldESP;
	alert(mensaje); 
}

//Apunta a los pasajeros en donde le hace falta algun dato obligatorio
function Apunta_Pasajeros(valida,ind,max) { 

  var armaObj;  
  //1=  Cambia de imagen apuntando o No apuntando //0=  No importa y muestra todos sin apuntar  
  //Recorro todos los elementos
  for (var i=1; i<=max; i++ ) {
	armaObj = $('foco_' + i); 
    if (valida == "si")
		//es el indice que estoy revisando (Indice es Igual= Pongo Imagen Flechita y diferente  = spacer)         
		armaObj.src = (ind == i) ? document.getElementById('Ruta_Imagen').value + "/arrowsmall.gif" : document.getElementById('Ruta_Imagen').value + "/spacer.gif";    	        
     else  
		//Vuelo a cambiar a imagen sin apuntar
        armaObj.src = document.getElementById('Ruta_Imagen').value + "/spacer.gif";          
  }
}

//funcion que Pasa el Pais a todos los demas pasajeros que no tenga pais especificado
function LlenaPaisPasajeros(maxpas,ind) {
    var armaObj;
    var armaObjVal = $('issue_country' + ind);  //tomo su valor de este objeto
     
     //Si tiene dato pongo a los demas 
     if (armaObjVal.value != "") {
		for (var i=1; i<=maxpas; i++ ) {
            //Tomo su valor y propago a los demas que no tengan  
            armaObj = $('issue_country_' + i);
            //Solo a los que no tengan valor 
            if (armaObj.value == "")            
				armaObj.value = armaObjVal.value;  //Le paso su valor a los demas                          
        }
     }    
}

//Pasa la Clave iata del Aeropuerto cuando es Cancun, cabos y vallarta
function pasaCiudad() {   

    var armaObjCiudades;  //objeto donde tomo su clave
    var armaObjClavCiudad; //objeto donde paso la clave           
    armaObjCiudades = $('ciudades');                    //objeto ciudades (destino)           
    armaObjClavCiudad = $('Clav_ciudad');               //objeto clav_ciudad (destino)    
    armaObjClavCiudad.value = armaObjCiudades.value;    //Si es Combo Ciudades tomo  value = Clave  Text = Nombre del aeropuerto
}

//Pasa el nombre de la ciudad desde combo con Clave nombre
function pasaCodeAirport() {   
    var armaObjLeavingfrom;  //objeto donde tomo su clave
    var armaObjCodeAirport; //objeto donde paso la clave    
    armaObjLeavingfrom = $('Leavingfrom');               //objeto clav_ciudad (destino)    
    armaObjCodeAirport = $('CodeAirport');               //objeto ciudades (origen)       
    armaObjCodeAirport.value = armaObjLeavingfrom.value;    //Si es Combo Leaving from tomo  value = Clave  Text = Nombre del aeropuerto
}

//obj.-  Objeto que recibe el foco
//descripcion:  Descripcion de Inicio  "City Name..."  ó dif
//mandatory:  
//			True :  (Ajax toma el primer elemento de la lista)
//			False:  (Tomo la descripcion de Inicio y limpio clave hidden )

var descripcionGral = '';
var mandatory = true;
function ClearField(Obj,descripcion,pmandatory) {    

	descripcionGral = descripcion;  //Descripcion de Inicio 	
	mandatory = (pmandatory != null && typeof pmandatory == "boolean" ) ? pmandatory: true;  //Por default es obligatorio
	
    var descObj = Obj.value;
    ///if ((Cadena == "City Name or Airport Code") || (Cadena == "Teclee el nombre de la ciudad ó codigo del Aeropuerto")) {     
    if (descObj == descripcion) {
        Obj.value="";    
        //Obj.className="iputmust";
     } else {
        Obj.focus();
        Obj.select();
     }
}


//Mueve a la posicion el elemento que le pacen..
//objMove: Objeto que se mueve
//objPos : Objeto donde quiero que se posicione "objMove"
//alignType: 
//		[elem]	 .- Posicion en base al objeto
//		[screen] .- Posicion en base a la pantalla
//align:  Alineado Izquierda, Derecha, Arriba, Abajo, centro
//addLeft:  Valor que agrega posicion Izquerda
//addTop :  Valor que agrega al Tope de la posicion 
function setPositionElement(objPos,objMove,alignType,align,addLeft,addTop) {  
   
    objPos = (typeof Tmpobj     != null && typeof Tmpobj     != "undefined") ? Tmpobj : objPos;         //Tomo del Global
    objMove= (typeof Tmpmoveobj != null && typeof Tmpmoveobj != "undefined") ? Tmpmoveobj : objMove; //Toma de los Globales
    
    objPos  = $(objPos);  //tomo id 
    objMove = $(objMove);  //tomo id o elemento a mover
    alignType = (alignType != null) ? alignType : "";
    
    //Obtengo valores adicionales
    addLeft = (typeof addLeft =="number") ?  parseInt(addLeft) : 0;
    addTop  = (typeof addTop  =="number") ?  parseInt(addTop)  : 0;
    
    //Que exista el elemento que se movera
    if (typeof objMove != "undefined") {
	   
		var posElementXY;
		var mLeft = 0;
		var mTop  = 0;        
        switch (alignType.toLowerCase())
        {
			case "elem":  //X y Y del elemento
				posElementXY = getPositionElement(objPos);  
				mLeft = posElementXY[0];		
				mTop  = posElementXY[1];		
				break; 
			case "elem2":  //X y Y del elemento
				posElementXY = getPositionElement(objPos);  
				var h = 0;
				if (objPos.offsetHeight > 0)
					h = objPos.offsetHeight;
				else
					h = objPos.scrollHeight;
				
				mLeft = posElementXY[0];		
				mTop  = (posElementXY[1] + h);	
				
				objMove.style.position = "absolute";  //para que permita moverlo
					
				break; 	
			case "add":  //X y Y del elemento + adicional
				posElementXY = getPositionElement(objPos);  
				mLeft = (posElementXY[0] + addLeft);	//Posicion Izq + Valor Adicional Izq
				mTop  = (posElementXY[1] + addTop );	//Posicion Top + Valor Adicional Top
				break; 
			case "screen":  //W y H de Pantalla
				posElementXY = getWindowSize() 
				var scrollXY = getScrollXY();		 				
				mLeft = ((posElementXY[0] - objMove.clientWidth)  /2) + scrollXY[0];//Left (Mitad de Pantalla)
				mTop  = ((posElementXY[1] - objMove.clientHeight) /2) + scrollXY[1];//Top  (Alto de Pantalla)
				break;
			case "value":  //Tomo los valores que me pasen
				mLeft = addLeft
				mTop = addTop
			default:
				posElementXY = getPositionElement(objPos);  //X y Y Posicion elemento
				mLeft = (posElementXY[0] + objPos.clientWidth ); //Posicion Izq + Valor Ancho Ele
				mTop  = (posElementXY[1] + objPos.clientHeight); //Posicion Izq + Valor Alto Ele
				break;
        }
                        
        //objMove.style.width = objPos.clientWidth;        
	    objMove.style.left = mLeft + "px"; //left del Objeto  
	    objMove.style.top = mTop  + "px";	//Top del Objeto  
	    objMove.style.zIndex = 70;
	    
	  			 
	    	
	} 
}

//funcion que mueve html de un contenedor a otro que lo llame
function MoveElemAddOns(forma,objPos,objMove,clasAct,classNew,objs,getValHidden,idimg,imgopen,imgclose) {  
    objPosInsert = $('B' + objPos);  //Elemento contendero Hijo del que llama para incrustar el html
    objMoveContent = $(objMove + 'Content');  //HTML que se mueve
    objPapa = objMoveContent.parentNode; //Obtengo el Papa Contenedor del HTML que se mueve
    
    //Obtengo la Ruta de Imagenes
    var rutaImagen = $('Ruta_Imagen');
    rutaImagen = (typeof rutaImagen != 'undefined' && rutaImagen != null) ? rutaImagen.value : "";
    
    //Obtengo las Imagenes
    imgopen  = (typeof imgopen != 'undefined' && imgopen != null) ? imgopen : "spacer.gif";
    imgclose = (typeof imgclose != 'undefined' && imgclose != null) ? imgclose : "spacer.gif";
        
    //Si es el mismo que lo llamo no hago nada
    if (('b' + objPos.toLowerCase()) == objMoveContent.parentNode.id.toLowerCase())	{		
		return false;
    }
    if (typeof objPosInsert == 'undefined' || objPosInsert == null)	return false;  //saco sin hacer nada		
	if (typeof objMoveContent == 'undefined' || objMoveContent == null) return false;  //saco sin hacer nada			
	var content = '';
	//Si existe el elemento que voy a mover  Saco el HTML de contenedor y muevo a otro contenedor que lo llamo
	if (typeof objPapa != 'undefined' &&  objPapa != null) 
		content = objPapa.innerHTML;    
		
   	//Si tiene contenido lo muevo 
   	if (content != '') { 
   		if (typeof idimg != 'undefined'){
   			var idxAnt = 0;  var idxAct = 0
   			idxAnt = (typeof objPapa.idx !='undefined' && objPapa.idx != null) ? objPapa.idx : 0  //tomo posicion del contenedor
   			idxAct = (typeof objPosInsert.idx !='undefined' && objPosInsert.idx != null) ? objPosInsert.idx : 0  //tomo posicion del contenedor
   			   			
   			if (idxAnt > 0 &&  idxAct > 0) {
   				var _imgAnt =  idimg.replace((idxAct+''),(idxAnt+''));   				
   				DisplayObj(objPapa.id,0);VerMas(objPapa.id,_imgAnt,rutaImagen,imgopen,imgopen); //Posicion de imagen anterior
   			}
			DisplayObj(objPosInsert.id,0); VerMas(objPosInsert.id,idimg,rutaImagen,imgopen,imgclose);
		}
   		objPapa.innerHTML = '';  objPosInsert.innerHTML = content;  //Inserto el html al que llama
   	}
	
	//Tomo el año actual
	var anioActual = new Date();  anioActual = anioActual.getFullYear();
	
	//Ejecuto Nuevamente el script de Fechas de Calendario
	FechaGet(forma.fechaFrom_pickup,forma.anio_pickup,forma.mes_pickup,forma.dia_pickup);
	FechaGet(forma.fechaTo_dropoff,forma.anio_dropoff,forma.mes_dropoff,forma.dia_dropoff);
	fillMonthsSelect(forma.anio_pickup.value,forma.mes_pickup,forma.dia_pickup, false);
    fillMonthsSelect(forma.anio_dropoff.value,forma.mes_dropoff,forma.dia_dropoff, false);
	CalendarLoad(forma.fechaFrom_pickup,'CalFrom_pickup',''+ anioActual,''+ (anioActual + 1));
	CalendarLoad(forma.fechaTo_dropoff,'CalTo_dropoff',''+ anioActual,''+ (anioActual + 1));
	
	//Funcion que extrae el valor actual seleccionado de los elementos
	getValuesHidden(forma,objs,getValHidden);
	
}
//Funcion que revisa que elemento de radios button fue seleccionado
function selectCheck(elem,pos) {	
	//elem.type == "checkbox"
	for (var i=0; i<=elem.length - 1; i++) {
		if (i==pos)
			elem[i].checked = true;  //Selecciona
		else
			elem[i].checked = false; //Deseleccona
	}		
			
}
function selectCheckBox (elem,activo) {
	//puede estar el elemento como hidden  ó checkbox
	if (elem.type = "checkbox") {
		if (activo)
			elem.checked = true;	
		else
			elem.checked = false;	
	}	
}


function Ocultar_Flash() {    
	var x = document.getElementsByTagName("Object"); 	
	for (i=0;i<x.length;i++) {	    
		x[i].style.visibility= "hidden";
	}
}
     
function Mostrar_Flash() {
	var x=document.getElementsByTagName("Object");
	for (i=0;i<x.length;i++) {
		x[i].style.visibility= "visible";
	}
}

//funcion que muestra la descripcion de la Categoria seleccionada (Lista de Hoteles)
function ttCategory(_id,clvCat,nombCat,colorBor,evento) {

	if (clvCat == '') return;  
	
	var idiomaCategoria = 'ING';
	var ruta_imagen = '';
	var txtCategoria = '';
	if($('Ruta_Imagen') != null) ruta_imagen =  $('Ruta_Imagen').value;  //Ruta de imagen del Sitio	
	if($('Idioma') != null) idiomaCategoria = $('Idioma').value;		//Idioma del Sitio: ING o ESP
	//Existe el Array 
	if (typeof(descCateg) != "undefined") txtCategoria = descCateg[clvCat];  //Tomo el valor del arreglo
	
	var content = '<div style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif;text-align: left; font-weight: bold; border-bottom: 1px solid ' + colorBor + '; margin: 2px 5px 2px 5px; padding-bottom: 2px; font-size:13px;">';
		content += '<img src="' + ruta_imagen + '/Cat_' + clvCat + '_' + idiomaCategoria + '.gif" border="0" align="absbottom"/>&nbsp;' + nombCat + '</div>';
		content += '<div style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif;text-align: justify; padding: 5px; font-size:10px;"><img src="' + ruta_imagen + '/CatBig_' + clvCat + '_' + idiomaCategoria + '.gif" align="left" style="margin-right:5px;"/>' + txtCategoria + '</div>';
		
	tooltip.show(_id,content,0,true,evento,200);
}

disHide_esp = "Ocultar";  disHide_ing = "Hide"; disShow_esp = "Mostrar";  disShow_ing = "Show"; 
//Si Visible:		Oculto Obj --> con title de Mostrar		
//Si NO Visible:	Muestro Obj --> con title de Ocultar
function VerMas(Iddiv,Idimg,RutaImg,imgShow,imgHide) { 

	var imgObj = $(Idimg);	//Idimg		-->  Nombre del Id de la Imagen click (Cambia su Title)
	var divObj = $(Iddiv);	//Iddiv		-->  Nombre del Id del Div Oculta / Muestra
							//imgShow	-->  Nombre de Imagen con Extension Cuando el Objeto esta Visible
							//imgHide	-->  Nombre de Imagen con Extension Cuando el Objeto NO esta Visible
	var title;				
	var pIdioma	= "ing"		
		
	//Obtengo el Idioma del Sitio	
	if (document.getElementById("Idioma") !=null)		
		pIdioma = document.getElementById("Idioma").value;  //tomo el Idioma	
	
	if (divObj.style.display == "") {
		//Titulo Imagen Mostrar o Ocultar
		title = (pIdioma.toLowerCase() == "ing") ? disShow_ing : disShow_esp;
		divObj.style.display = "none";			//Oculta el div
		imgObj.title = title;					//Nuevo titulo de la Imagen  
		imgObj.src = RutaImg + '/' + imgShow;	//Imagen Mostrar		
	} else {	
		//Titulo Imagen.- es el Opuesto a la Accion de hizo
		title = (pIdioma.toLowerCase() == "ing") ? disHide_ing : disHide_esp;			
		divObj.style.display = '';		//Muestra el Div
		imgObj.title = title;					//Nuevo titulo de la Imagen  
		imgObj.src = RutaImg + '/' + imgHide;	//Imagen de Ocultar
	}
}

function VerMasSin(Iddiv) { 
	var divObj = $(Iddiv);	//Iddiv		-->  Nombre del Id del Div Oculta / Muestra
	
	if (divObj.style.display == "") divObj.style.display = "none";	//Oculta el div  	
	else divObj.style.display = '';									//Muestra el Div
}

var tooltip=function(){	
	//Var. ToolTip
	var id = 'help';
	var top = 5;
	var left = 5;
	var maxwidth = 300; //Ancho  Maximo del ToolTip
	var minwidth = 150; //Ancho Minimo del ToolTip
	var tt,t,c,b,h;
	var ie = document.all ? true : false; 
	var widthObj = 0;var cad='';
	return{		
		show:function(_id,_textHTML,_width,_hide,evento,_minwidth,_maxwidth){
			
			//Si NO recibe Texto 
			if (typeof _textHTML =='undefined' || _textHTML ==null || _textHTML == '') return;
			
			//Trae Nombre ?  Tomo su nombre si No la de dafault
			id = (typeof _id !='undefined' &&  _id !=null) ? _id : id;
			
			//Valida que ya exista el elemento con ese ID
			if(document.getElementById(id) != null) {
				//Es el mismo Objeto ? Si Borra el documento
				if(tt.id.toLowerCase() != id.toLowerCase()) {
					tt = null;
					document.body.removeChild(document.getElementById(id));
				}
			}
			else {
				tt = null;
			}
					
			//Valida que la variable tt sea null para crear el elemento
			if(tt == null){
				if(typeof _minwidth != 'undefined') minwidth = _minwidth;
				if(typeof _maxwidth != 'undefined') maxwidth = _maxwidth;
				widthObj = _width;
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
			}  //debugger;
			//tt.style.opacity = 97;
			//tt.style.filter = 'alpha(opacity=97)';
			c.innerHTML = _textHTML;
			tt.style.display = 'block';
			tt.style.width = _width ? _width + 'px' : 'auto';			//Si no hay _width de default toma width=auto
			tt.style.left = (ie ? event.clientX : evento.pageX) + 'px'; //Posicion del evento
			if(tt.offsetWidth > maxwidth){ tt.style.width = maxwidth + 'px'	}
			//Si es caja que se mueve con el mouse
			_hide = (_hide != null  && typeof _hide  == "boolean") ? _hide :  true;
			

			if (_hide) { 
				document.onmousemove = this.pos; 
			} 
			else {
				document.onmousemove = ""; //por click
				tooltip.pos(evento);
			}
			//Valida que el objeto este visible, que sea IE y que sea version menor a 7
			if (tt.style.display != "none" && ie && navigator.appVersion.substring(22,25) < 7) Ocultar_Elementos();

		},
		pos:function(e){
			//scrollTop y scrollLeft: para Doctype HTML usa document.body y para XHTML se usa document.documentElement
			//offsetWidth y offsetHeight: se usa document.documentElement para todo tipo de Doctype
			var u = ie ?  event.clientY + document.body.scrollTop + document.documentElement.scrollTop : e.pageY;
			var l = ie ?  event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft : e.pageX;
			var difHeight = (ie ? (document.body.scrollTop + document.documentElement.scrollTop) : 0) + document.documentElement.offsetHeight - u; 
			//Hay espacio abajo antes de que termina la pagina para que muestre el objeto?
			if(difHeight < tt.offsetHeight) 
			   tt.style.top = (u - tt.offsetHeight - top) + 'px'; //Mueve el Objeto hacia Abajo del Posicion del Mouse
			else 
			   tt.style.top = (u + top) + 'px';  //Mueve el Objeto hacia Arriba del Posicion del Mouse
			//tt.style.top = (u + top) + 'px'; 					//Mueve el Objeto hacia Abajo de la Posicion del Mouse
			var difWidth = (widthObj != 0 ) ? widthObj : minwidth //Existe ancho minimo?
			if((document.documentElement.offsetWidth - l)  < difWidth) {  	//(Ancho pagina - posicion evento) < ancho del objeto
				tt.style.width = difWidth;
				tt.style.left = ((ie ? event.clientX : e.pageX)) - difWidth - left + 'px';
			}
			else tt.style.left = (l + left) + 'px';
			if(tt.offsetWidth > maxwidth){ tt.style.width = maxwidth + 'px'	} // Tamaño maximo del objeto
		},
		hide:function(id){
			var e = $(id); 
			if(e != null) {	
				// Valida que sea IE y que sea version menor a 7
				if(ie && navigator.appVersion.substring(22,25) < 7) Mostrar_Elementos();
				document.onmousemove = "";
				eval("e.style.display = 'none'");				
			}
		}
	};
}();


/* ------------------------------------------------- */
/* Inicia: Funciones de FILTROS AVANZADOS DE HOTELES */
function uncompressHotels(){
	var _indices_match = new Array();
	for(var i=0;i<a_hotels.length;i++){
		_indices_match[i] = i;
	}
	return _indices_match;
}

//Recibe el arreglo de indeces (indices_match), la posicion del filtro a buscar (posArray) y el id del elemento a buscar
function matchGeneral(indices_match,posArray,tipo,idElemento1,idElemento2) {
	
	var _indices_match = new Array();
	var _array_interno = new Array();
	var _valor1 = new String; _valor1 = "";
	var _valor2 = new String; _valor2 = "";
	var _coincide = new Boolean; _coincide = false;
	_valor1 = $(idElemento1).value;	//Primer valor del split del arreglo grande
	if(tipo == "Entre") { 
		_valor1 = $(idElemento1).value.split("|")[0];	//Primer valor del split del arreglo grande
		_valor2 = $(idElemento2).value.split("|")[0];	//		Ej.: 5 de "5|S3"		
	}
	if(tipo == "Entre" && _valor1 == "" && _valor2 != "") _valor1 = "0";			//Ej.: Categorias: Todas hasta _valor2
	if(tipo == "Entre" && _valor2 == "" && _valor1 != "") _valor2 = "9999999999";	//Ej.: Categorias: Desde _valor1 hasta todas
	if(_valor1 != "") { //Tiene valor el primer elemento?
		for(var i=0;i<indices_match.length;i++){ //Recorre el arreglo de indices que cumplen con los filtros anteriores
			_array_interno = a_hotels[indices_match[i]].split("|");
			_coincide = false;
			
			switch (tipo) {
				case "Simple": 	if(_array_interno[posArray] == _valor1) _coincide = true; break;
				case "Comas": 	if(_array_interno[posArray].indexOf(_valor1) >= 0) _coincide = true; break; 
				case "Entre": 	if(parseInt(_array_interno[posArray]) >= parseInt(_valor1) && parseInt(_array_interno[posArray]) <= parseInt(_valor2)) _coincide = true; break;
			}
			
			if(_coincide == true)
				_indices_match[_indices_match.length] = indices_match[i];	//Agrego al nuevo arreglo de indices
		}
	}	
	else _indices_match = indices_match;
	return _indices_match;
}

function matchCheckBox (indices_match,posArray,idElemento) {
	var _indices_match=new Array();
	var _bits = new String;
	var _listCheckBox=$(idElemento).getElementsByTagName("input"); //Todos los input dentro del ID recibido
	var _listChecked=new Array();
	var _coincide = new Boolean; _coincide = false;
	var _hiddenValor = "" //Cadena de valores CheckBox seleccionados
	//debugger;
	for(var i=0;i<_listCheckBox.length;i++){ //Obtiene todos los CheckBox dentro del ID recibido
		if(_listCheckBox[i].checked){
			_listChecked[_listChecked.length]=_listCheckBox[i].getAttribute("filter"); //Atributo con el bit que representa
			_hiddenValor += _listCheckBox[i].value + ','; 
		}
	}
	$(idElemento + 'Buscar').value = _hiddenValor;	//Elemento Hidden
	if(_listChecked.length==0){ //Existen seleccionados?
		return indices_match;
	}
	for(var i=0;i<indices_match.length;i++){ //Recorre el arreglo de indices que cumplen con los filtros anteriores
		_array_interno = a_hotels[indices_match[i]].split("|"); 
		_bits=parseInt(_array_interno[posArray],32).toString(2); //Convierte a bits (base 2) el valor de la BD en base 32
		
		for(var j=0;j<_listChecked.length;j++){ //Recorre la lista con CheckBox seleccionado
			if(_bits.charAt(_bits.length-1-_listChecked[j])=="1") _coincide=true; 	//Tiene 1 en el bit que indica el CheckBox?
			else { _coincide=false;j=_listChecked.length; }							//No coinciden
		}
		if(_coincide)
			_indices_match[_indices_match.length] = indices_match[i];	//Agrego al nuevo arreglo de indices
	}
	return _indices_match;
}

function revisaFiltros() {
	//indices_match: arreglo con los indices de a_hotels que cumplen con los filtros
	var indices_match = uncompressHotels();
	indices_match = (indices_match.length > 0) ? matchGeneral(indices_match,1,"Simple","fLocation") : "";			//Ubicacion
	indices_match = (indices_match.length > 0) ? matchGeneral(indices_match,2,"Simple","fCiudad") : "";				//Ciudad
	indices_match = (indices_match.length > 0) ? matchGeneral(indices_match,3,"Simple","fCadena") : "";				//Cadena
	indices_match = (indices_match.length > 0) ? matchGeneral(indices_match,4,"Comas","fPlan") : "";					//Planes
	indices_match = (indices_match.length > 0) ? matchGeneral(indices_match,5,"Entre","fCatDesde","fCatHasta") : "";	//Categoria
	indices_match = (indices_match.length > 0) ? matchGeneral(indices_match,6,"Entre","fPrecioDe","fPrecioHasta") : "";	//Tarifa
	indices_match = (indices_match.length > 0) ? matchCheckBox(indices_match,7,"fTemas") : "";				//Temas en base 32
	var element  = 	document.forms['frmFilters'].getElementsByTagName("input");
	for (var i=0;  i<element.length; i++) {
		if (element[i].name.toLowerCase() =='submit') {		
			if (indices_match.length <=0)
				element[i].style.display = 'none';	 //desactiva		
			else
				element[i].style.display = ''; //activa
		}
	}	
	$("TotalFiltros").innerHTML = indices_match.length;
}
/* Fin: Funciones de FILTROS AVANZADOS DE HOTELES */
/* ---------------------------------------------- */


function ExtraeValores (tour,cboservicio,cbociudad,cbohorario,arrCiudades,arrHorarios,defciudad,defhora,pos) { 
	var arra = arrCiudades; LimpiaCombo(cbociudad); var j= 0;
	
	if (typeof arrCiudades == "undefined" && arrCiudades == null) 
		arrCiudades = '';
	
	if (typeof arrHorarios == "undefined" && arrHorarios == null) 
		arrHorarios = '';	
	
	var primera = true;
	for (var i=0;  i<arra.length; i++) {	
		var arraVal = new Array(); arraVal = arra[i].split("|"); var obj;	
		if (arraVal != null){
	   		if (typeof arraVal[0] != "undefined" && arraVal[0] != null) //Clave de Tour
				if (typeof arraVal[1] != "undefined" &&  arraVal[1] != null) //Clave de Servicio
					if (typeof arraVal[2] != "undefined" && arraVal[2] != null) //Clave Ciudad
						if (typeof arraVal[3] != "undefined" && arraVal[3] != null) { //nombre de ciudad
							//Es el mismo Tour y Servicio
							if (parseInt(arraVal[0]) == parseInt(tour) && parseInt(arraVal[1]) == parseInt(cboservicio) && (arraVal[3]+'')!= '') 
							{
								if (defciudad == arraVal[2]) {
									cbociudad.options[j] = new Option(arraVal[3], arraVal[2],true,true); //seleccionado	
								}else{
									//Si viene vacio por default selecciono el primero
									if (primera && defciudad =='') {
										cbociudad.options[j] = new Option(arraVal[3], arraVal[2],true,true);	//seleccionado
										primera = false;
									} else {
										cbociudad.options[j] = new Option(arraVal[3], arraVal[2],false,false);	//No seleccionado
									}
								}
								//Oculto Combo de Ciudade y titulo				
								if (cbociudad.value == "NOCIUDAD") {						
									eval("document.getElementById('SaliendoDe" + pos + "').style.display='none'");
									eval("document.getElementById('SaliendoDeTxt" + pos + "').style.display='none'");
								}else{
									eval("document.getElementById('SaliendoDe" + pos + "').style.display=''");
									eval("document.getElementById('SaliendoDeTxt" + pos +"').style.display=''");
								}
								j+=1; //Incremento de Opciones Reales										
							}	
						}	   
		}
				
	}
	//Cargo Horarios	
	var arraH = arrHorarios; LimpiaCombo(cbohorario); primera = true; j=0;
	//Barro los Valores
	for (var i=0;  i<arraH.length; i++) {
		var arraValH = new Array();		
		arraValH = arraH[i].split("|");		
		
		if (arraValH != null) {
		   //tomo la Clave del tour
		   if (typeof arraValH[0] != "undefined" && arraValH[0] != null) //Clave de Tour
	         if (typeof arraValH[1] != "undefined" && arraValH[1] !=null) //Clave de Servicio
				if (typeof arraValH[2] != "undefined" && arraValH[2] != null) { //Hora

					//Es el mismo Tour y Servicio y no viene vacio o cero							
					if (parseInt(arraValH[0]) == parseInt(tour) && parseInt(arraValH[1]) == parseInt(cboservicio) && (arraValH[2]+'') != '0') 
					{										
					
						//Es la misma hora seleccionada
						if (defhora == arraValH[2]) {						
							cbohorario.options[j] = new Option(arraValH[2], arraValH[2],true,true); //seleccionado						
						}else{										
							if (primera && defhora == ""){							
								cbohorario.options[j] = new Option(arraValH[2], arraValH[2],true,true); //seleccionado
								primera = false;							
							}else {							
								cbohorario.options[j] = new Option(arraValH[2], arraValH[2],false,false); //No seleccionado							
							}
						}
						j+=1; //Incremento de Opciones Reales
					}
					//Para esconderlo si no trae Valores	
					if (cbohorario.value == "0" || cbohorario.value == "") {
						eval("document.getElementById('elHorario" + pos + "').style.display='none'");
						eval("document.getElementById('elHorarioTxt" + pos + "').style.display='none'");										
					} else {
						eval("document.getElementById('elHorario" + pos + "').style.display=''");
						eval("document.getElementById('elHorarioTxt" + pos + "').style.display=''");
        
					}
					
				}
		}
			
	}
}
function LimpiaCombo(combo)							
    {
	 while (combo.options.length > 0) 
		{						
		       combo.options[0] = null;							
		}															
    }   
    

//funcion que valida que no se pongan ciertos caracteres
function validacaracteres(e){
	var idioma =  document.getElementById('Idioma');
	var idioma = (typeof idioma !='undefined' && idioma !=null)? idioma.value:'ING';
	var mensaje='';
	tecla = (document.all) ? e.keyCode : e.which;	
	if (tecla==8) return true; //espacio	
	//Valor Hexadecimal "7C"  -->  "u00" + "7C"
	//            |     ¬     &     ~     ^     °     %     {     ¨     }     ñ     Ñ     á     é     í     ó     ú     Á     É     Í     Ó     Ú   
	patron =/[\u007C\u00AC\u0026\u007E\u005E\u00B0\u0025\u007B\u00A8\u007D\u00F1\u00D1\u00E1\u00E9\u00ED\u00F3\u00FA\u00C1\u00C9\u00CD\u00D3\u00DA]/;
	te = String.fromCharCode(tecla);
	if (patron.test(te)){	
		mensaje = (idioma.toLowerCase() == 'esp') ? disAlertCaracteresInvalidos_ESP : disAlertCaracteresInvalidos_ING;
		mensaje +="\n";
		mensaje +="\t" + "\u007C, \u00AC, \u0026, \u007E, \u005E, \u00B0, \u0025, \u007B, \u00A8, \u007D, \u00F1, \u00D1, \u00E1, \u00E9, \u00ED, \u00F3, \u00FA, \u00C1, \u00C9, \u00CD, \u00D3, \u00DA ";
		alert(mensaje);
	}
	return !patron.test(te);

} 

//funcion k valida que se pongan numeros
function validanumeros(e){
	tecla = (document.all) ? e.keyCode : e.which; // 2
	if (tecla==8) return true;
	patron =/[0123456789]/;	
	te = String.fromCharCode(tecla);
	return patron.test(te);
}     

