// ########## CAMPOS ##########

ORIGEN = "<label>Origen<br /><input type='text' name='origen' id='origen' autocomplete='off' class='textinput' /></label>";
ORIGEN_ = "<label style='display:none'></label>";
FLIGHTTYPE = "<tr id='flightTypeTr'><td><input type='radio' name='flightType' value='oneway' id='oneway' onclick='flightFields(this.value)' /><label>S&#243;lo ida</label></td><td><input type='radio' name='flightType' value='return' id='return' onclick='flightFields(this.value)' checked='checked' /><label>Ida y vuelta</label></td></tr>";
FLIGHTTYPE_ = "<tr id='flightTypeTr' style='display:none'><td></td></tr>";
NUMEROHAB = "<tr id='numeroDeHabitaciones'><td colspan='2'><label>N&#250;mero de habitaciones <input type='hidden' id='hab' value='1' /></label><select name='habitaciones' id='habitaciones' onchange='modifyHab(this.value);'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></td></tr>";
NUMEROHAB_ = "<tr id='numeroDeHabitaciones' style='display:none'><td colspan='2'></td></tr>";
HORAS = "<option value='-1'>Cualquiera</option><option value='0'>00:00</option><option value='1'>01:00</option><option value='2'>02:00</option><option value='3'>03:00</option><option value='4'>04:00</option><option value='5'>05:00</option><option value='6'>06:00</option><option value='7'>07:00</option><option value='8'>08:00</option><option value='9'>09:00</option><option value='10'>10:00</option><option value='11'>11:00</option><option value='12'>12:00</option><option value='13'>13:00</option><option value='14'>14:00</option><option value='15'>15:00</option><option value='16'>16:00</option><option value='17'>17:00</option><option value='18'>18:00</option><option value='19'>19:00</option><option value='20'>20:00</option><option value='21'>21:00</option><option value='22'>22:00</option><option value='23'>23:00</option>";

HORASALIDA = "<tr id='horaSalida'><td><label>Hora<br /><select name='iHora' id='iHora' class='hora'>" + HORAS + "</select></label></td></tr>";
HORASALIDA_= "<tr id='horaSalida' style='display:none'><td></td></tr>";

HORAREGRESO ="<tr id='horaRegreso'><td><label>Hora<br /><select name='fHora' id='fHora' class='hora'>" + HORAS + "</select></label></td></tr>";
HORAREGRESO_="<tr id='horaRegreso' style='display:none'><td></td></tr>";
HOTELNAME = "<tr id='hotelNametr'><td colspan='2'><label>Nombre del Hotel <input type='text' name='hotelName' id='hotelName' class='textinput' /></label></td></tr>";
HOTELNAME_ = "<tr id='hotelNametr' style='display:none'><td colspan='2'></td></tr>";
PROMOCODE = "<tr id='promotionCodetr'><td colspan='2'><label>C&#243;digo de la promoci&#243;n<br /><input type='text' name='promoCode' id='promoCode' class='textinput' /></label></td></tr>";
PROMOCODE_= "<tr id='promotionCodetr' style='display:none'><td colspan='2'></td></tr>";
DIRECTFLIGHT = "<tr id='directFlighttr'><td colspan='2'><input type='checkbox' name='directFlight' id='directFlight' /><label>Vuelo directo</label></td></tr>";
DIRECTFLIGHT_ = "<tr id='directFlighttr' style='display:none'><td colspan='2'></td></tr>";
BUSQUEDAA="<table cellspacing='0' cellpadding='0' id='advancedSearch'><tr id='directFlighttr'><td colspan='2'></td></tr><tr id='hotelNametr'><td colspan='2'></td></tr></table>";
CHILDRENPANEL_="<table id='childrenPanel' cellspacing='0' cellpadding='0'></table>";
GUESTS = "<table id='guest'><tr id='guests_row0'><td><label>Adultos <select name='noAdultos_0' id='noAdultos_0' class='selectinput'><option value='1' selected='selected'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select></label></td><td><label>Ni&#241;os <select name='noChildren_0' id='noChildren_0' onchange='modifyChildren(this.id, this.value)'><option value='0' selected='selected'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select></label><input type='hidden' name='childrenAge_0' id='childrenAge_0' value='0' /></td></tr></table>";
GUESTS_ = "<div id='guest'><input type='hidden' name='noAdultos_0' id='noAdultos_0' value='1'/><input type='hidden' name='noChildren_0' id='noChildren_0' value='0'/><input type='hidden' name='childrenAge_0' id='childrenAge_0' value='0' /></div>";
CPMESSAGE= "<table id='childrenPanelMessage' cellpadding='0' cellspacing='7'><tr><td>Edades de los ni&#241;os:</td></tr><tr><td></td></tr><tr><td>Los impuestos o tarifas aplicables a ni&#241;os menores a dos a&#241;os deber&#225;n ser pagados en el aeropuerto de origen.</td></tr></table>";
CPMESSAGE_= "<table id='childrenPanelMessage'style='display:none'><tr><td></td></tr></table>";
SPINNER= "<div id='hidepage' style='z-index:1004; position: fixed; left:0px; top:0px; background-color: #FFFFFF;text-align:center; background-color: #FFFFFF; height: 100%; width: 100%; display:block;'><table width='100%' height='100%' ><tr><td align='center'><object height='394px' width='717px' align='middle' id='loader2' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'><param value='" + configForm.spinerURL +"' name='movie'/><embed height='394px' width='717px' align='middle' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' allowscriptaccess='sameDomain' name='loader' wmode='transparent' quality='high' src='" + configForm.spinerURL +"' class='spinner'/></object><br/><span class='spinnerText'>Por favor, espera mientras buscamos tu viaje...</span></td></tr></table></div>";
CAMPOSREGRESO = "<table cellspacing='0' cellpadding='0' id='camposRegreso'><tbody><tr><td><label>Regreso<br /><input type='text' readonly='readonly' class='fecha date-pick' id='fecha-Fin' name='y'/><input type='hidden' id='fechaFin' name='fechaFin' value=''/></label></td></tr>" + HORAREGRESO +"</tbody></table>";
CAMPOSREGRESO_ = "<table id='camposRegreso' style='display:none'><tr><td><input type='hidden' id='fecha-Fin'/><input type='hidden' id='fechaFin' name='fechaFin' value=''/></td></tr></table>";
ADVANSEDSEARCH = "<table width='196' cellspacing='6' border='0' id='searchPanelAdvanced'><tbody><tr><td class='checkinput' colspan='2'><br><input type='checkbox' onclick='advancedSearch(this);' id='advanced' name='advanced'><label> M&#225;s opciones de b&#250;squeda</label></td></tr><tr><td><table cellspacing='0' cellpadding='0' class='notShow' id='advancedSearch'><tbody><tr id='directFlighttr'><td colspan='2'></td></tr><tr id='hotelNametr'><td colspan='2'></td></tr></tbody></table></td></tr><tr><td align='center' colspan='2'><input type='hidden' value='pos' name='wl'></td></tr> </tbody></table>";
ADVANSEDSEARCH_ = "<table id='searchPanelAdvanced' style='display:none;'><tr><td></td></tr></tbody></table>";
//-----------------------------

// ###########################  OBJETO DE CONFIGURACION #################################

function submitForm(){
	if (validateFields()){
		
		$('#form1').attr("action", configForm.myLocation);
		document.form1.submit();
		$('#titleCerrar').addClass("notShow");
		waitFor();
	}
}

function initialize(){
	setOfferedProducts();
	setChecked(document.getElementsByName("viaje"), configForm.defautlProduct)
	configureFields(getCheckedValue(document.getElementsByName("viaje")));
	$('#hotelNametr').replaceWith(HOTELNAME_);
	$('#directFlighttr').replaceWith(DIRECTFLIGHT_);
	setBrowserType();
	
	if (configForm.tipoNavegador == 'ie' & configForm.versionNavegador == '6'){
		PNG_loader();
	}
}

function setOfferedProducts(){
	if (configForm.productsOffered.indexOf("|H|")  >= 0) $('#viaje_0').parent().addClass("show-inline"); else $('#viaje_0').parent().addClass("notShow");
	if (configForm.productsOffered.indexOf("|F|")  >= 0) $('#viaje_1').parent().addClass("show-inline"); else $('#viaje_1').parent().addClass("notShow");
	if (configForm.productsOffered.indexOf("|HF|") >= 0) $('#viaje_2').parent().addClass("show-inline"); else $('#viaje_2').parent().addClass("notShow");
	if (configForm.productsOffered.indexOf("|V|")  >= 0) $('#viaje_3').parent().addClass("show-inline"); else $('#viaje_3').parent().addClass("notShow");
	if (configForm.productsOffered.indexOf("|E|")  >= 0) $('#viaje_4').parent().addClass("show-inline"); else $('#viaje_4').parent().addClass("notShow");
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	for(var i = 0; i < radioObj.length; i++)
		if(radioObj[i].checked)
			return radioObj[i].value;
	return "";
}

function setChecked(radioObj, Value) {
	if(!radioObj)
		return;
	for(var i = 0; i < radioObj.length; i++)
		if(radioObj[i].value == Value) {
			radioObj[i].checked = 'checked';
			return;
		}
}
//-----------------------------------------------------------------------------------------


//	#################### 	FUNCION PARA LIMPIAR LOS CAMPOS		################################

function clearForm(){
	$('#origen').val('');
	$('#origenHidden').val('');
	$('#destino').val('');
	$('#destinoHidden').val('');
	$('#fecha-Inicio').val('');
	$('#fecha-Fin').val('');
	$('#fechaInicio').val('');
	$('#fechaFin').val('');
	if (configForm.selectedProduct != 'E'){
		$('#noAdultos_0').get(0).selectedIndex = 0;
		$('#noChildren_0').get(0).selectedIndex = 0;
		$('#guest').replaceWith(GUESTS);
	}
	$('#childrenPanel').replaceWith(CHILDRENPANEL_);
	$('#childrenPanelMessage').replaceWith(CPMESSAGE_);
	$('#origen').removeClass('missingField');
	$('#destino').removeClass('missingField');
	$('#fecha-Inicio').removeClass('missingField');
	$('#fecha-Fin').removeClass('missingField');
	$('#errors div').remove();
}


//------------------------------------------------------------------------------------------

// #################  FUNCIONES MOSTRAR y/o OCULTAR CAMPOS DEPENDIENDO DE LA BUSQUEDA ###########


function configureFields(searchType){	
	configForm.selectedProduct = searchType;
	switch (searchType){
		case 'HF'	:	$('#flightTypeTr').replaceWith(FLIGHTTYPE_);
						$('#origentr').children(":eq(0)").children(":eq(0)").replaceWith(ORIGEN);
						autocomplete_origen();
						$('#numeroDeHabitaciones').replaceWith(NUMEROHAB);
						$('#horaSalida').replaceWith(HORASALIDA);
						$('#horaRegreso').replaceWith(HORAREGRESO);
						$('#promotionCodetr').replaceWith(PROMOCODE);
						$("#guest").replaceWith(GUESTS);
						$('#searchPanelAdvanced').replaceWith(ADVANSEDSEARCH);
						if ($("#advanced").get(0).checked){
							$('#hotelNametr').replaceWith(HOTELNAME);
							$('#directFlighttr').replaceWith(DIRECTFLIGHT);
						}
						configForm.autocompleteOrigenMode = 'airport';
						configForm.autocompleteDestinoMode = 'city';
						configForm.iAge = configForm.PackageInfantMaxAge;
						configForm.cAge = configForm.PackageChildMaxAge;
						break;
		case 'F'	:	$('#flightTypeTr').replaceWith(FLIGHTTYPE);
						$('#origentr').children(":eq(0)").children(":eq(0)").replaceWith(ORIGEN);
						autocomplete_origen();
						$('#numeroDeHabitaciones').replaceWith(NUMEROHAB_);
						$('#horaSalida').replaceWith(HORASALIDA);
						$('#horaRegreso').replaceWith(HORAREGRESO);
						$('#promotionCodetr').replaceWith(PROMOCODE_);
						$("#guest").replaceWith(GUESTS);
						$('#searchPanelAdvanced').replaceWith(ADVANSEDSEARCH);
						if ($("#advanced").get(0).checked){
							$('#hotelNametr').replaceWith(HOTELNAME_);
							$('#directFlighttr').replaceWith(DIRECTFLIGHT);
						}
						
						configForm.autocompleteOrigenMode = 'city';
						configForm.autocompleteDestinoMode = 'airport';
						configForm.iAge = configForm.AirInfantMaxAge;
						configForm.cAge = configForm.AirChildMaxAge;
						break ;
		case 'H'	:	$('#flightTypeTr').replaceWith(FLIGHTTYPE_);
						$('#origentr').children(":eq(0)").children(":eq(0)").replaceWith(ORIGEN_);
						$('#numeroDeHabitaciones').replaceWith(NUMEROHAB);
						$('#horaSalida').replaceWith(HORASALIDA_);
						$('#horaRegreso').replaceWith(HORAREGRESO_);
						$('#promotionCodetr').replaceWith(PROMOCODE);
						$("#guest").replaceWith(GUESTS);
						$('#searchPanelAdvanced').replaceWith(ADVANSEDSEARCH);
						if ($("#advanced").get(0).checked){
							$('#hotelNametr').replaceWith(HOTELNAME);
							$('#directFlighttr').replaceWith(DIRECTFLIGHT_);
						
						}
						
						configForm.autocompleteOrigenMode = 'city';
						configForm.autocompleteDestinoMode = 'city';
						configForm.iAge = configForm.HotelInfantMaxAge;
						configForm.cAge = configForm.HotelChildMaxAge;
						break;
		case 'V'	:	$('#flightTypeTr').replaceWith(FLIGHTTYPE_);
						$('#origentr').children(":eq(0)").children(":eq(0)").replaceWith(ORIGEN_);
						$('#numeroDeHabitaciones').replaceWith(NUMEROHAB_);
						$('#horaSalida').replaceWith(HORASALIDA);
						$('#horaRegreso').replaceWith(HORAREGRESO);
						$('#promotionCodetr').replaceWith(PROMOCODE_);
						$("#childrenPanelMessage").replaceWith(CPMESSAGE_);
						$("#guest").replaceWith(GUESTS);
						$('#searchPanelAdvanced').replaceWith(ADVANSEDSEARCH_);
						
						configForm.autocompleteOrigenMode = 'city';
						configForm.autocompleteDestinoMode = 'city';
						configForm.iAge = configForm.HotelInfantMaxAge;
						configForm.cAge = configForm.HotelChildMaxAge;
						break;
		case 'E'	:	$("#guest").replaceWith(GUESTS_);
						$('#flightTypeTr').replaceWith(FLIGHTTYPE_);
						$('#origentr').children(":eq(0)").children(":eq(0)").replaceWith(ORIGEN_);
						$('#numeroDeHabitaciones').replaceWith(NUMEROHAB_);
						$('#horaSalida').replaceWith(HORASALIDA_);
						$('#horaRegreso').replaceWith(HORAREGRESO_);
						$('#promotionCodetr').replaceWith(PROMOCODE_);
						$("#childrenPanelMessage").replaceWith(CPMESSAGE_);
						$("#guest").replaceWith(GUESTS_);
						
						$('#searchPanelAdvanced').replaceWith(ADVANSEDSEARCH_);
						
						configForm.autocompleteOrigenMode = 'city';
						configForm.autocompleteDestinoMode = 'city';
						configForm.iAge = configForm.HotelInfantMaxAge;
						configForm.cAge = configForm.HotelChildMaxAge;
						break;
	}
	clearForm();
}

function flightFields (type){
	switch (type){
		case 'return' 	:	$('#camposRegreso').replaceWith(CAMPOSREGRESO);
							calendarios();
							break;
		case 'oneway'	:	$('#camposRegreso').replaceWith(CAMPOSREGRESO_);
	}
}

function advancedSearch(checkbox){
	if (!checkbox)
		return;
	$('#advancedSearch').replaceWith(BUSQUEDAA);
	if (checkbox.checked){
		switch (configForm.selectedProduct){
			case 'HF'	:	$('#hotelNametr').replaceWith(HOTELNAME);
							$('#directFlighttr').replaceWith(DIRECTFLIGHT);
							break;
			case 'F'	:	$('#hotelNametr').replaceWith(HOTELNAME_);
							$('#directFlighttr').replaceWith(DIRECTFLIGHT);
							break ;
			case 'H'	:	$('#hotelNametr').replaceWith(HOTELNAME);
							$('#directFlighttr').replaceWith(DIRECTFLIGHT_);
		}
	}
		
}

//--------------------------------------------------------------------------------------------------

// #############   FUNCIONES PARA VALIDACION DEL FORMULARIOS   #####################################

function validateFields(){
	var missingFields = '';
	
	if (configForm.selectedProduct == 'H' | configForm.selectedProduct == 'V' | configForm.selectedProduct == 'E'){
		if ($('#destino').get(0).value.length < 3 ){
			$('#destino').addClass('missingField');
			missingFields += '<li>Destino</li>';
		}else 
			$('#destino').removeClass('missingField');
	}else{
		if ($('#origen').get(0).value.length < 3 ){
			$('#origen').addClass('missingField');
			missingFields += '<li>Origen</li>';
		}else 
			$('#origen').removeClass('missingField');
		if ($('#destino').get(0).value.length < 3 ){
			$('#destino').addClass('missingField');
			missingFields += '<li>Destino</li>';
		}else 
			$('#destino').removeClass('missingField');
	}
	
	if ($('#fecha-Inicio').get(0).value.length < 8 ){
		$('#fecha-Inicio').addClass('missingField');
		missingFields += '<li>Salida</li>';
	}else $('#fecha-Inicio').removeClass('missingField');
	if ($('#fecha-Fin').get(0).value.length < 8 ){
		$('#fecha-Fin').addClass('missingField');
		missingFields += '<li>Regreso</li>';
	}else $('#fecha-Fin').removeClass('missingField');
					
	if (missingFields.length > 0){
		$('#errors div').remove();
		$('#errors').append('<div class="errors">' + configForm.missingFieldMessage +'<ul>'+ missingFields + '</ul></div>');
		return false;
	}
	return true;
	
}

//-----------------------------------------------------------------------------------------------------------

//   ###########################	FUNCION PARA MOSTRAR EL SPINNER		############3########################

function waitFor() {
	$('body').children().remove();
	$('body').append(SPINNER);
	
}
//-----------------------------------------------------------------------------------------------------------
			

// #####################	FUNCIONES PARA HABITACIONES Y NIŅOS		#############################################
			
function modifyHab(number){
var id = document.getElementById("hab").value;
	id--;
	number--;
	while(id > number){
		removeFormField("#guests_row" + id);
		removeFormField("#cdph_" + id);
		id--;
	}
	while(id < number){
		id++;
		addFormField("#guest",id,"<tr id='guests_row" + id + "'><td><label>Adultos <select name='noAdultos_"+id+"' id='noAdultos_" + id + "'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option></select></label></td><td><label>Ni&ntilde;os <select name='noChildren_"+id+"' id='noChildren_"+id+"' onChange='modifyChildren(this.id, this.value)'><option value='0' selected='selected'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select></label></td></tr>");		
		addFormField("#guest",id,"<input type='hidden' name='childrenAge_"+id+"' id='childrenAge_"+id+"' value='0' />");
	}
	id++;
	document.getElementById("hab").value = id;
}
/*
id - indice de la fila
index - valor acual del numero de ninios
objValue - numero de ninios deseados
*/
function modifyChildren2(objId,objValue){
	var id=objId.substring(objId.indexOf('_')+1);
	var index=document.getElementById("childrenAge_"+id).value;
	var parent=($("#childrenPanel").children(":eq(0)").children(":eq("+id+")").children(":eq(1)"));

	if(objValue==0)
		$("#childrenPanel").children(":eq(0)").children(":eq("+id+")").removeClass("show").addClass("notShow");
	else 
		$("#childrenPanel").children(":eq(0)").children(":eq("+id+")").removeClass("notShow").addClass("show");
	parent.children().remove();
	index=0;
	while(index < objValue){
		index++;
		parent.append("<span>Ni&ntilde;o "+index+" <select name='childAge_"+id+"_"+index+"' id='childAge_"+id+"_"+index+"'></select></span>");
		for (var i= parseInt(configForm.iAge) +1 ; i <= configForm.cAge; i++ )
			$("#childAge_" + id + "_" + index).append("<option value='" + i +"'>"+ i +"</option>");
	}
	$("#childrenAge_"+id).val(index);
}


function modifyChildren(objId,objValue){
	var id=objId.substring(objId.indexOf('_')+1);
	var index=document.getElementById("childrenAge_"+id).value;
	var parent=$("#childrenPanel");
	var tds = parent.find('tr');
	var exist = 0;
	var brother = '';
	
	
	
	if(objValue==0){
		$("#cdph_" + id).remove();
		if ($("#childrenPanel").find('tr').length < 1){
			$("#childrenPanelMessage").replaceWith(CPMESSAGE_);
		}
		return;
	}
	
	if (configForm.selectedProduct != 'H')
		$("#childrenPanelMessage").replaceWith(CPMESSAGE);
	
	
	var newtr= "<tr id='cdph_" + id +"'><td class='hab'>Hab. " + (parseInt(id)+1) + "</td><td class='habTd'>"
	
	while(index < objValue){
		index++;
		newtr += "<span>Ni&ntilde;o "+index+" <select name='childAge_"+id+"_"+index+"' id='childAge_"+id+"_"+index+"'>";
		for (var i= parseInt(configForm.iAge) +1 ; i <= configForm.cAge; i++ )
			newtr += "<option value='" + i +"'>"+ i +"</option>";
		newtr += "</select></span>";
		
	}
	
	newtr +="</td></tr>";
	
	tds.each(function(){
		hid = "cdph_" + id;
		if ($(this).attr("id") == hid & exist==0){
			exist=1;
		}
	});
	
	tds.each(function(){
		tdn = $(this).attr("id").substring($(this).attr("id").indexOf('_')+1);
		if (tdn < id){
			brother = $(this).attr("id");
		}
	});
	
	if (exist == 0 & brother == ''){
		parent.prepend(newtr);
	}else if (exist ==1){
		$("#cdph_" + id).replaceWith(newtr);
	}else{
		$("#" + brother ).after(newtr);
	}
	

			
}

function addFormField(parent,id, obj) {
	$(parent).append(obj);
}

function removeFormField(id) {
	$(id).remove();
}

//------------------------------------------------------------------------------------------------		

// ###################################### GOOGLE ANALYTICS #########################################

function analytics(){
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	try {
		var pageTracker = _gat._getTracker(configForm.GoogleAnalyticsAccount);
		pageTracker._trackPageview();
	} catch(err) {}
}
//--------------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------------		

// ###################################### CAMBIO DE LOCALIDADES #########################################

var cityLocations = [ 
						{ valor: 'CITY_ACA_MX', 	texto: 'Acapulco'},
						{ valor: 'CITY_AGU_MX', 	texto: 'Aguascalientes'},
						{ valor: 'CITY_CUN_MX', 	texto: 'Cancun'},
						{ valor: 'CITY_CTM_MX', 	texto: 'Chetumal'},
						{ valor: 'CITY_CUU_MX', 	texto: 'Chihuahua'},
						{ valor: 'CITY_CME_MX', 	texto: 'Ciudad del Carmen'},
						{ valor: 'CITY_CJS_MX', 	texto: 'Ciudad Juarez'},
						{ valor: 'StaMxVeCoatz398', texto: 'Coatzacoalcos'},
						{ valor: 'CITY_CLQ_MX', 	texto: 'Colima'},
						{ valor: 'CITY_CZM_MX', 	texto: 'Cozumel'},
						{ valor: 'CITY_CUL_MX', 	texto: 'Culiacan'},
						{ valor: 'CITY_DGO_MX', 	texto: 'Durango'},
						{ valor: 'CITY_GDL_MX', 	texto: 'Guadalajara'},
						{ valor: 'CITY_HMO_MX', 	texto: 'Hermosillo'},
						{ valor: 'CITY_LAP_MX', 	texto: 'La Paz'},
						{ valor: 'REG_MX_LosCabo', 	texto: 'Cabo'},
						{ valor: 'CITY_MZT_MX', 	texto: 'Mazatlan'},
						{ valor: 'CITY_MXL_MX', 	texto: 'Mexicali'},
						{ valor: 'CITY_MEX_MX', 	texto: 'Ciudad de Mexico'},
						{ valor: 'CITY_LOV_MX', 	texto: 'Monclova'},
						{ valor: 'CITY_MTY_MX', 	texto: 'Monterrey'},
						{ valor: 'CITY_MLM_MX', 	texto: 'Morelia'},
						{ valor: 'CITY_NLD_MX', 	texto: 'Nuevo Laredo'},
						{ valor: 'CITY_OAX_MX', 	texto: 'Oaxaca'},
						{ valor: 'CITY_PAZ_MX', 	texto: 'Poza Rica'},
						{ valor: 'CITY_PBC_MX', 	texto: 'Puebla'},
						{ valor: 'CITY_PVR_MX', 	texto: 'Puerto Vallarta'},
						{ valor: 'CITY_QRO_MX', 	texto: 'Queretaro'},
						{ valor: 'CITY_REX_MX', 	texto: 'Reynosa'},
						{ valor: 'CITY_SLW_MX', 	texto: 'Saltillo'},
						{ valor: 'CITY_SLP_MX', 	texto: 'San Luis Potosi'},
						{ valor: 'CITY_TAM_MX', 	texto: 'Tampico'},
						{ valor: 'CITY_TIJ_MX', 	texto: 'Tijuana'},
						{ valor: 'CITY_TLC_MX', 	texto: 'Toluca'},
						{ valor: 'CITY_TRC_MX', 	texto: 'Torreon'},
						{ valor: 'CITY_TGZ_MX', 	texto: 'Tuxtla'},
						{ valor: 'CITY_VER_MX', 	texto: 'Veracruz'},
						{ valor: 'CITY_VSA_MX', 	texto: 'Villahermosa'},
						{ valor: 'CITY_BHZ_MG_BR', 	texto: 'Belo Horizonte'},
						{ valor: 'CITY_RIO_RJ_BR', 	texto: 'Rio de Janeiro'},
						{ valor: 'CITY_SAO_SP_BR', 	texto: 'Sao Paulo'},
						{ valor: 'CITY_BUE_BA_AR', 	texto: 'Buenos Aires'}
					];

var airLocations = [ 
						{ valor: 'AIR_ACA_MX', 		texto: 'Acapulco'},
						{ valor: 'AIR_AGU_MX', 		texto: 'Aguascalientes'},
						{ valor: 'AIR_CUN_MX', 		texto: 'Cancun'},
						{ valor: 'AIR_CTM_MX', 		texto: 'Chetumal'},
						{ valor: 'AIR_CUU_MX', 		texto: 'Chihuahua'},
						{ valor: 'AIR_CME_MX', 		texto: 'Ciudad del Carmen'},
						{ valor: 'AIR_CJS_MX', 		texto: 'Ciudad Juarez'},
						{ valor: 'AirMxMinatit419', texto: 'Coatzacoalcos'},
						{ valor: 'AirMxManzani054', texto: 'Colima'},
						{ valor: 'AIR_CZM_MX', 		texto: 'Cozumel'},
						{ valor: 'AIR_CUL_MX', 		texto: 'Culiacan'},
						{ valor: 'StaEsPaDuran429', texto: 'Durango'},
						{ valor: 'AIR_GDL_MX', 		texto: 'Guadalajara'},
						{ valor: 'AIR_HMO_MX', 		texto: 'Hermosillo'},
						{ valor: 'AIR_LAP_MX', 		texto: 'La Paz'},
						{ valor: 'AIR_SJD_MX', 		texto: 'Cabo'},
						{ valor: 'AIR_MZT_MX', 		texto: 'Mazatlan'},
						{ valor: 'AIR_MXL_MX', 		texto: 'Mexicali'},
						{ valor: 'AirMxBenitoJ875', texto: 'Ciudad de Mexico'},
						{ valor: 'AIR_LOV_MX', 		texto: 'Monclova'},
						{ valor: 'AirMx545', 		texto: 'Monterrey'},
						{ valor: 'AIR_MLM_MX', 		texto: 'Morelia'},
						{ valor: 'AIR_NLD_MX', 		texto: 'Nuevo Laredo'},
						{ valor: 'AIR_OAX_MX', 		texto: 'Oaxaca'},
						{ valor: 'AIR_PAZ_MX', 		texto: 'Poza Rica'},
						{ valor: 'AIR_TCN_MX', 		texto: 'Puebla'},
						{ valor: 'AIR_PVR_MX', 		texto: 'Puerto Vallarta'},
						{ valor: 'AIR_QRO_MX', 		texto: 'Queretaro'},
						{ valor: 'AIR_REX_MX', 		texto: 'Reynosa'},
						{ valor: 'AIR_SLW_MX', 		texto: 'Saltillo'},
						{ valor: 'AIR_SLP_MX', 		texto: 'San Luis Potosi'},
						{ valor: 'AIR_TAM_MX', 		texto: 'Tampico'},
						{ valor: 'AIR_TIJ_MX', 		texto: 'Tijuana'},
						{ valor: 'AIR_TLC_MX', 		texto: 'Toluca'},
						{ valor: 'AIR_TRC_MX', 		texto: 'Torreon'},
						{ valor: 'AirMxLlanoSa895', texto: 'Tuxtla'},
						{ valor: 'AirMxVeracru521', texto: 'Veracruz'},
						{ valor: 'AIR_VSA_MX', 		texto: 'Villahermosa'},
						{ valor: 'AIR_CNF_MG_BR', 	texto: 'Belo Horizonte'},
						{ valor: 'AIR_SDU_RJ_BR', 	texto: 'Rio de Janeiro'},
						{ valor: 'AIR_GRU_SP_BR', 	texto: 'Sao Paulo'},
						{ valor: 'AirArBa722', 		texto: 'Buenos Aires'}
					];
					
function setHF(){
	var sele = document.getElementById('destinoHidden');
	while (sele.options[1])
		sele.options[1] = null;
	for (i=0; cityLocations[i]; i++){
		opt = new Option(cityLocations[i].texto,cityLocations[i].valor);
		sele.options[sele.options.length] = opt;
	}
}

function setF(){
	var sele = document.getElementById('destinoHidden');
	while (sele.options[1])
		sele.options[1] = null;
	for (i=0; airLocations[i]; i++){
		opt = new Option(airLocations[i].texto,airLocations[i].valor);
		sele.options[sele.options.length] = opt;
	}
}

//--------------------------------------------------------------------------------------------------

//############################ TIPO DE NAVEGADOR ####################



   function setBrowserType(){
    var aBrowFull = new Array("opera", "msie", "netscape", "gecko", "mozilla");
    var aBrowVers = new Array("opera", "msie", "netscape", "rv",    "mozilla"   );
    var aBrowAbrv = new Array("op",    "ie",   "ns",       "mo",    "ns"   );
    var sInfo = navigator.userAgent.toLowerCase();;

    sBrowser = "";
    for (var i = 0; i < aBrowFull.length; i++){
     if ((sBrowser == "") && (sInfo.indexOf(aBrowFull[i]) != -1)){
	  configForm.tipoNavegador = sBrowser = aBrowAbrv[i];
	  configForm.versionNavegador = String(parseFloat(sInfo.substr(sInfo.indexOf(aBrowVers[i]) + aBrowVers[i].length + 1)));
     }
    }
   }
   //--------------------------------------------------------------------------------------------------

//############################ IMAGENES .png TRANSPARENTES IE6 ####################

function PNG_loader() {
   for(var i=0; i<document.images.length; i++) {
      var img = document.images[i];
	  
      var imgName = img.src.toUpperCase();
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		
         var imgID = (img.id) ? "id='" + img.id + "' " : "";
         var imgClass = (img.className) ? "class='" + img.className + "' " : "";
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
         var imgStyle = "display:inline-block;" + img.style.cssText + ";";
         if (img.align == "left") imgStyle += "float:left;";
         if (img.align == "right") imgStyle += "float:right;";
         if (img.parentElement.href) imgStyle += "cursor:hand;";
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + imgStyle
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
         img.outerHTML = strNewHTML;
         i--;
      }
   }
}

function autocomplete_origen(){
	$('input#origen').jSuggest({
			url: 		configForm.ajaxURL + "?locationType=" + configForm.autocompleteOrigenMode + "&searchableOnly=false",
			type: 		"GET",
			data: 		"ajaxSearch", 
			autoChange:	false,
			id: 		"origen"
		});	
}

function autocomplete_destino(){
	$('input#destino').jSuggest({
			url: 		configForm.ajaxURL + "?locationType=" + configForm.autocompleteDestinoMode + "&searchableOnly=false",
			type: 		"GET",
			data: 		"ajaxSearch", 
			autoChange:	false,
			id: 		"destino"
		});	
}

function calendarios(){
	$('#fecha-Inicio').datePicker({clickInput:true,createButton:false});
	$('#fecha-Fin').datePicker({clickInput:true,createButton:false});
	$('.date-pick').datePickerMultiMonth({numMonths: 2});
	$('.date-pick').dpSetOffset(0, 115);
    $('.date-pick').dpSetPosition($.dpConst.POS_AUTO, $.dpConst.POS_AUTO);
}