
/*
test by marian

28 04 2006 --> 15:42

*/


var IE = (document.all) ? true : false;

var destinos=new Array;
var cabeceraModal='';
var siteAct="";
var startSession=0;
var reg=0;

//####-Funciones para el control de las pesetañas de la cabecera-####//
function cambiaBuscador(ind)
{
	var buscadores= new Array('searchFlightForm','buscadorHoteles','','dynamicSearchForm');
	
	startSession=0;
	
	/*deshabilito vacacional temporalmente*/
	
	if(ind == 2)
		{
		location.href=vacacionalpath;
		return;
		}
	else{
		cargaFechas('',buscadores[ind]);
	}
	for (a=0;a<4;a++)
	{
		if(a==ind)
		{
			document.getElementById("buscador"+a).style.visibility='visible';
		}
		else
		{		
			document.getElementById("buscador"+a).style.visibility='hidden';
		}
	}	
}

//####-Funciones para el control de Iframe de ciudades-####// 

var formIf="";
var fieldIf="";
var fieldValueIf="";
var fieldValueIsIATA="";
var doc="document.forms";
//var rngDia=2;

document.write('<iframe src=\"/viajes/jsp/generic/vacio.jsp\" id=\"buscadorCiudadesIF\" frameborder=\"no\" scrolling=\"no\">');
document.write('</iframe>');

function abreBuscadorCiudades(nameForm,nameField,nameFieldValue,nameFieldIsIATA, typeOfSearch, site){
	
	formIf=nameForm;
	fieldIf=nameField;
	fieldValueIf=nameFieldValue;
	fieldValueIsIATA=nameFieldIsIATA;
	document.getElementById('buscadorCiudadesIF').style.display="block";
	var ruta='';
	if(typeOfSearch=='flight'){
		document.getElementById('buscadorCiudadesIF').style.height='328px';
		document.getElementById('buscadorCiudadesIF').style.width='353px';
		//ruta=""+contextRoot+"jsp/generic/searchCities/"+site+"/ventanaModal_SearchCities.jsp";
		ruta=""+contextRoot+"jsp/templates/"+site+"/flight/searchCities/ventanaModal_SearchCities.jsp";
	}
	else{
		document.getElementById('buscadorCiudadesIF').style.height='310px';
		document.getElementById('buscadorCiudadesIF').style.width='452px';	
		//ruta=""+contextRoot+"jsp/generic/searchCities/"+site+"/ventanaModal_SearchCities_hotel.jsp";
		ruta=""+contextRoot+"jsp/templates/"+site+"/hotel/searchCities/ventanaModal_SearchCities_hotel.jsp";
	}
	
	if(site=="marpt"){
		document.getElementById('buscadorCiudadesIF').style.width='470px';
		if(typeOfSearch=='hotel'){document.getElementById('buscadorCiudadesIF').style.height='244px';}	
	}
	
	if(site=="acmes"){
		document.getElementById('buscadorCiudadesIF').style.width='353px';
		document.getElementById('buscadorCiudadesIF').style.height='453px';
		if(typeOfSearch=='hotel'){
			document.getElementById('buscadorCiudadesIF').style.height='302px';
			document.getElementById('buscadorCiudadesIF').style.width='452px';
		}
	}
	
	if(site=="spaes"){
		if(typeOfSearch=='hotel'){
			document.getElementById('buscadorCiudadesIF').style.width='352px';
		}
	}
	
	if(site=="spaen" || site=="spaca"){
		if(typeOfSearch=='hotel'){
			document.getElementById('buscadorCiudadesIF').style.width='352px';
		}
	}
	
	document.getElementById('buscadorCiudadesIF').src=ruta;
}

function obtenerPosicion(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }

  return (y);
}

function obtenerPosicionX(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }

  return (x);
}

function ocultaIf(otros){

	document.getElementById('buscadorCiudadesIF').style.display="none";
	if(fieldIf!="")
		eval(''+doc+'["'+formIf+'"].'+fieldIf+'.focus()');
	if(otros){
		eval(''+doc+'["'+formIf+'"].'+fieldIf+'.value="Escriba ciudad..."');
	}
}

function alerta(seleccionado,seleccionadoValue){
	eval(''+doc+'["'+formIf+'"].'+fieldIf+'.value=seleccionado');
	if(fieldValueIf!='')
		eval(''+doc+'["'+formIf+'"].'+fieldValueIf+'.value=seleccionadoValue');
	if(fieldValueIsIATA!='')
		eval(''+doc+'["'+formIf+'"].'+fieldValueIsIATA+'.value=true');
	document.getElementById('buscadorCiudadesIF').style.display="none";
}

//####-Fin funciones para el control de Iframe de ciudades-####//	


//####-Funciones para el control de Calendario-####// 

var formName="";
var fieldName="";
var fieldNameR="";
var tpS;
var tpR;
var tpCal;
var fieldSalidaD="";
var fieldSalidaM="";
var fieldRegresoD="";
var fieldRegresoM="";
var anioDep="";
var fieldVisible="";

document.write('<iframe src="" id="calendarioIF" frameborder="no" scrolling="no">');
document.write('</iframe>');

function cargaFechasSalida(formulario){

	var fechaAct=new Date();
	var mesAct= fechaAct.getMonth();
	var diaAct= fechaAct.getDate();
	firstDay=firstDayMonth(fechaAct)-1;
	eval('document.forms["'+formulario+'"].'+fieldSalidaD+'.options.length=0');
	
	eval('document.forms["'+formulario+'"].'+fieldSalidaM+'.selectedIndex=('+mesAct+')');
	
	for(s=0;s<lastDay(fechaAct);s++)	{

			var fecD=diaSemana[firstDay].substr(0,3)+' '+(s+1);
		
		if(s>=(diaAct-1)){
			eval('document.forms["'+formulario+'"].'+fieldSalidaD+'.options.length++');
			eval('document.forms["'+formulario+'"].'+fieldSalidaD+'.options['+((s+1)-diaAct)+'].text="'+fecD+'"');
		}
			
			if(firstDay<6){firstDay++}
			else{firstDay=0;}
		
		}	
}

function getDayName(y,m,d) {
  var wd=new Date(y,m,d);
  return diaSemana[wd.getDay()].substring(0,3);
}

function get2Digits(n) {
  return ((n<10)?"0":"")+n;
}




function cargaFechas(typ,formulario,newMes,newAnio){
	/*alert('typ= '+typ);
	alert('formulario= '+formulario);
	alert('newMes= '+newMes);
	alert('newAnio= '+newAnio);*/
	
	var actualD = new Date();
	dia=actualD.getDate();
	mes=actualD.getMonth();
	anio=actualD.getYear();
	
	if(!IE){anio=(anio+1900)}
	
	var campo0;
	var campo1;
	var campo2;
	var campo3;
	
	var indSel=1;
	
	campo0=fieldSalidaD;
	campo1=fieldSalidaM;
	campo2=fieldRegresoD;
	campo3=fieldRegresoM;
	
	var fd;
	var nd=new Date(anio,mes,dia);
	
	if(startSession==0){
		
		var mesesArr = new Array();
		var mesesVal = new Array();
	
		var longMonth=eval('document.forms["'+formulario+'"].'+campo1+'.options.length');
		
		var numIni = (mes-eval('document.forms["'+formulario+'"].'+campo1+'.options[0].value'))
		var numL = 0;
		
		if(numIni==0){
			numL= longMonth-eval('document.forms["'+formulario+'"].'+campo1+'.options[0].value')
		}
		
		for(a=numIni;a<(longMonth-eval('document.forms["'+formulario+'"].'+campo1+'.options[0].value'));a++){
		
			var textArr= eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].text')
			var defTextArr = textArr;
			
			if(textArr.length>3){
				defTextArr = textArr.substr(0,3)
			}
			
			else{defTextArr = eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].text')}
			mesesArr.push(defTextArr+'-'+anio);
			mesesVal.push(eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].value'));
		}
		
		for(a=numL;a<longMonth;a++){
		
			var textArr0 = eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].text');
			var defTextArr0 = textArr0;
			
			if(textArr0.length>3){
				var defTextArr0 = textArr0.substr(0,3)
			}
		
			mesesArr.push(defTextArr0+'-'+(anio+1))
			mesesVal.push(eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].value'))
		}
		
		eval('document.forms["'+formulario+'"].'+campo1+'.options.length=0')
		if(campo3!='')eval('document.forms["'+formulario+'"].'+campo3+'.options.length=0')
		
		for(a=0;a<longMonth;a++){
			eval('document.forms["'+formulario+'"].'+campo1+'.options.length++')
			eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].text=mesesArr['+a+']')
			eval('document.forms["'+formulario+'"].'+campo1+'.options['+a+'].value=mesesVal['+a+']')
			
			if(campo3!=''){
				eval('document.forms["'+formulario+'"].'+campo3+'.options.length++')
				eval('document.forms["'+formulario+'"].'+campo3+'.options['+a+'].text=mesesArr['+a+']')
				eval('document.forms["'+formulario+'"].'+campo3+'.options['+a+'].value=mesesVal['+a+']')
			}
		}		
		
		eval('document.forms["'+formulario+'"].'+campo1+'.options.selectedIndex=0')
		
		startSession=1;
		
	}
	
	if(!newMes && newMes!=0){
		
		fd=new Date(anio,mes,0);
		firstDay=firstDayMonth(nd);
		if(firstDay!=0){firstDay--;}
		else {firstDay=6}		
		
		if(typ=='s'){
			
			eval('document.forms["'+formulario+'"].'+campo0+'.options.length=0');
			
			for(s=0;s<lastDay(nd);s++){
				
				var fecD=diaSemana[firstDay].substr(0,3)+' '+(s+1);
				if(s>=(dia-1)){
					eval('document.forms["'+formulario+'"].'+campo0+'.options.length++');
					eval('document.forms["'+formulario+'"].'+campo0+'.options['+((s+1)-dia)+'].text="'+fecD+'"');
					eval('document.forms["'+formulario+'"].'+campo0+'.options['+((s+1)-dia)+'].value="'+(s+1)+'"');
				}
				
				if(firstDay<6){firstDay++}
				else{firstDay=0;}
			}
		}
		
		else if(typ=='r'){
			eval('document.forms["'+formulario+'"].'+campo2+'.options.length=0');
			
			for(s=0;s<lastDay(nd);s++){
				
				var fecD=diaSemana[firstDay].substr(0,3)+' '+(s+1);
				
				if(s>=(dia-1)){
					eval('document.forms["'+formulario+'"].'+campo2+'.options.length++');
					eval('document.forms["'+formulario+'"].'+campo2+'.options['+((s+1)-dia)+'].text="'+fecD+'"');
					eval('document.forms["'+formulario+'"].'+campo2+'.options['+((s+1)-dia)+'].value="'+(s+1)+'"');
				}
				
				if(firstDay<6){firstDay++}
				else{firstDay=0;}
			}
		
		}
		
		else{			
			eval('document.forms["'+formulario+'"].'+campo0+'.options.length=0');
			eval('document.forms["'+formulario+'"].'+campo2+'.options.length=0');
			
			for(s=0;s<lastDay(nd);s++){
				
				var fecD=diaSemana[firstDay].substr(0,3)+' '+(s+1);
				
				if(s>=(dia-1)){
					eval('document.forms["'+formulario+'"].'+campo0+'.options.length++');
					eval('document.forms["'+formulario+'"].'+campo0+'.options['+((s+1)-dia)+'].text="'+fecD+'"');
					eval('document.forms["'+formulario+'"].'+campo0+'.options['+((s+1)-dia)+'].value="'+(s+1)+'"');
					eval('document.forms["'+formulario+'"].'+campo2+'.options.length++');
					eval('document.forms["'+formulario+'"].'+campo2+'.options['+((s+1)-dia)+'].text="'+fecD+'"');
					eval('document.forms["'+formulario+'"].'+campo2+'.options['+((s+1)-dia)+'].value="'+(s+1)+'"');
				}
				
				if(firstDay<6){firstDay++}
				else{firstDay=0;}
			}
			
			var actSel = eval('document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex');
			indSel = eval('document.forms["'+formulario+'"].'+campo0+'.options['+actSel+'].text').substr(4,6);
		}
	}
	
	else if(newMes!='changeD'){
		
		var actSel = eval('document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex');
		indSel = eval('document.forms["'+formulario+'"].'+campo0+'.options['+actSel+'].text').substr(4,6);
		if(typ=='r'){campoDef=campo3}
		else if(typ=='s'){campoDef=campo1}		
		
		var indMes = eval('document.forms["'+formulario+'"].'+campoDef+'.options.selectedIndex')
		newMes=eval('document.forms["'+formulario+'"].'+campoDef+'.options['+indMes+'].value')
		
		if(newMes<mes){newAnio=(anio+1);}
		else(newAnio=anio);
		
		fd=new Date(newAnio,newMes,1);
		
		if(typ=='s'){fieldChange0=campo0;fieldChange1=campo1}
		if(typ=='r'){fieldChange0=campo2;fieldChange1=campo3}
		
		var firstDay=firstDayMonth(fd);
		
		if(firstDay==0){firstDay=6;}
		else{firstDay=(firstDay-1)}
		eval('document.forms["'+formulario+'"].'+fieldChange0+'.options.length=0;');
		
	  	if(newMes==mes){
	  			  		
	  		for(s=0;s<lastDay(nd);s++){
				
				var fecD=diaSemana[firstDay].substr(0,3)+' '+(s+1);
				
				if(s>=(dia-1)){
					eval('document.forms["'+formulario+'"].'+fieldChange0+'.options.length++');
					eval('document.forms["'+formulario+'"].'+fieldChange0+'.options['+((s+1)-dia)+'].text="'+fecD+'"');
					eval('document.forms["'+formulario+'"].'+fieldChange0+'.options['+((s+1)-dia)+'].value="'+(s+1)+'"');
				}
				
				if(firstDay<6){firstDay++}
				else{firstDay=0;}
			}
			
	  	}  	
	  	
	  	else{
	  			
			for(s=0;s<lastDay(fd);s++){
				eval('document.forms["'+formulario+'"].'+fieldChange0+'.options.length++');
				contentField=diaSemana[firstDay].substr(0,3)+' '+(s+1);
				eval('document.forms["'+formulario+'"].'+fieldChange0+'.options['+s+'].text="'+contentField+'"');
				eval('document.forms["'+formulario+'"].'+fieldChange0+'.options['+s+'].value="'+(s+1)+'"');
				if(firstDay<6){firstDay++}
				else{firstDay=0;}
			}
		}
		
		if(campo3 != ""){
			if(eval('document.forms["'+formulario+'"].'+campo3+'.options.selectedIndex<document.forms["'+formulario+'"].'+campo1+'.options.selectedIndex')){
				eval('document.forms["'+formulario+'"].'+campo3+'.options.selectedIndex=document.forms["'+formulario+'"].'+campo1+'.options.selectedIndex')
				cargaFechas('r',formulario,eval('document.forms["'+formulario+'"].'+campo1+'.options.selectedIndex'),newAnio)
			}
		}
		
		
	}
	
	else if(newMes=='changeD'){
		
		if(campo3 != ""){
			if(eval('document.forms["'+formulario+'"].'+campo3+'.options.selectedIndex == document.forms["'+formulario+'"].'+campo1+'.options.selectedIndex') && eval('document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex > document.forms["'+formulario+'"].'+campo2+'.options.selectedIndex')){
				eval('document.forms["'+formulario+'"].'+campo2+'.options.selectedIndex = document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex')
			}
		}
		
		var actSel = eval('document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex');
		indSel = eval('document.forms["'+formulario+'"].'+campo0+'.options['+actSel+'].text').substr(4,6);
	}
	
	if(newAnio){		
		if(typ=='s'){eval('document.forms["'+formulario+'"].anioS.value='+newAnio+'')}
		if(typ=='r'){eval('document.forms["'+formulario+'"].anioR.value='+newAnio+'')}
	}
	
	var newIndSel = parseInt(indSel);
	
	if(startSession!=0){				
		for(s=0;s<eval('document.forms["'+formulario+'"].'+campo0+'.options.length');s++){
			if(eval('document.forms["'+formulario+'"].'+campo0+'.options['+s+'].text').substr(4,6) == indSel){
				eval('document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex='+s+'');
				newIndSel = s;
			}
		}
		if(campo3)
		if(eval('document.forms["'+formulario+'"].'+campo1+'.options.selectedIndex==document.forms["'+formulario+'"].'+campo3+'.options.selectedIndex')){
			
			if(campo2){				
				if(eval('document.forms["'+formulario+'"].'+campo0+'.options.selectedIndex>document.forms["'+formulario+'"].'+campo2+'.options.selectedIndex')){
					
					if (eval('document.forms["'+formulario+'"].'+campo2+'.options.length')>=newIndSel)
					{
							eval('document.forms["'+formulario+'"].'+campo2+'.options.selectedIndex='+newIndSel+'');
					}
				}
			}
		}
		
	}
	//alert('indSel = '+indSel);	
}


function actDay(){
	
}


function firstDayMonth(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  var fd=new Date(yy,mm,1);
  return fd.getDay();
}


function lastDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  for (var i=31; i>=28; i--) {
    var nd=new Date(yy,mm,i);
    if (mm == nd.getMonth()) {
      return i;  
    }
  }
}

function abrirCalendarV2(tpC,fn,cn,rn,ad,fv){
	formName=fn;
	fieldName=cn;
	fieldNameR=rn;
	tpCal=tpC;
	anioDep=ad;
	fieldVisible=fv;
	document.getElementById('calendarioIF').src=contextRoot+'jspV2/calendar/calendario.jsp';
	document.getElementById('calendarioIF').style.display='block';
	document.getElementById('calendarioIF').style.visibility="visible";
}

	function cierraCalendarV2(){
	    loadDatesV2(tpCal,formName,fieldName,fieldNameR,anioDep,fieldVisible);
		document.getElementById('calendarioIF').style.display="none";
}

    function loadDatesV2(typ,fn,cn,rn,ad,fv)
		{
			formName=fn;
			fieldName=cn;
			fieldNameR=rn;
			tpCal=typ;
			anioDep=ad;
			fieldVisible=fv;		
			var dateGo = eval('document.forms["'+formName+'"].'+fieldVisible+'.value'); 		
			eval('document.forms["'+formName+'"].'+cn+'.value='+dateGo.substr(0,2)); 		
			eval('document.forms["'+formName+'"].'+rn+'.value='+dateGo.substr(3,2)); 						
			eval('document.forms["'+formName+'"].'+anioDep+'.value='+dateGo.substr(6,dateGo.length));				
			if(tpCal=='r')
			{ 
				var dateBack = eval('document.forms["'+formName+'"].'+fieldVisible+'.value');							
				eval('document.forms["'+formName+'"].'+cn+'.value='+dateBack.substr(0,2)); 						
				eval('document.forms["'+formName+'"].'+rn+'.value='+dateBack.substr(3,2));				
    			eval('document.forms["'+formName+'"].'+anioDep+'.value='+dateGo.substr(6,dateBack.length));				
			}
		}

function abrirCalendario(tpC,fn,cn,rn){
	formName=fn;
	fieldName=cn;
	fieldNameR=rn;
	tpCal=tpC;
	document.getElementById('calendarioIF').src=contextRoot+"jsp/calendar/calendario.jsp";
	document.getElementById('calendarioIF').style.display="block";
}

function cierraCalendario(){
	document.getElementById('calendarioIF').style.display="none";
}

function cargaValores(ds,ms,dr,mr){
	if(ds)	fieldSalidaD=ds;
	if(ms)	fieldSalidaM=ms;
	if(dr)	fieldRegresoD=dr;
	if(mr)	fieldRegresoM=mr;
}

function compruebaEnvio(formu,dSalida,dRegreso){

	var dSal=eval('document.forms["'+formu+'"].'+dSalida+'.value');
	var defDayS=dSal;
	eval('document.forms["'+formu+'"].'+dSalida+'.value='+defDayS+'');
	
	if(dRegreso){
		var dReg=eval('document.forms["'+formu+'"].'+dRegreso+'.value');
		var defDayR=dReg;
		eval('document.forms["'+formu+'"].'+dRegreso+'.value='+defDayR+'');				
	}		
}
		
function deshab(frn,cmpD,cmpM,cmpH,chk){
	if((eval('document.forms["'+frn+'"].'+chk+'[0].checked==false'))){
		eval('document.forms["'+frn+'"].'+cmpD+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpD+'.style.backgroundColor="#e4e2e2"');
		eval('document.forms["'+frn+'"].'+cmpM+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpM+'.style.backgroundColor="#e4e2e2"');
		eval('document.forms["'+frn+'"].'+cmpH+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpH+'.style.backgroundColor="#e4e2e2"');	
	}
	
	else{
		eval('document.forms["'+frn+'"].'+cmpD+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpD+'.style.backgroundColor="white"');
		eval('document.forms["'+frn+'"].'+cmpM+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpM+'.style.backgroundColor="white"');
		eval('document.forms["'+frn+'"].'+cmpH+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpH+'.style.backgroundColor="white"');	
	}
}

function deshabV2(frn,cmpD,cmpH,chk){
	if((eval('document.forms["'+frn+'"].'+chk+'[0].checked==false'))){
		eval('document.forms["'+frn+'"].'+cmpD+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpD+'.style.backgroundColor="#e4e2e2"');
		eval('document.forms["'+frn+'"].'+cmpH+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpH+'.style.backgroundColor="#e4e2e2"');	
	}
	
	else{
		eval('document.forms["'+frn+'"].'+cmpD+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpD+'.style.backgroundColor="white"');
		eval('document.forms["'+frn+'"].'+cmpH+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpH+'.style.backgroundColor="white"');		
	}
}




function deshabParam(frn,cmpD,cmpM,cmpH,chk,param){
	if(param==false){
		eval('document.forms["'+frn+'"].'+cmpD+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpD+'.style.backgroundColor="#e4e2e2"');
		eval('document.forms["'+frn+'"].'+cmpM+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpM+'.style.backgroundColor="#e4e2e2"');
		eval('document.forms["'+frn+'"].'+cmpH+'.disabled=true');
		eval('document.forms["'+frn+'"].'+cmpH+'.style.backgroundColor="#e4e2e2"');	
	}
	
	if(param==true){
		eval('document.forms["'+frn+'"].'+cmpD+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpD+'.style.backgroundColor="white"');
		eval('document.forms["'+frn+'"].'+cmpM+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpM+'.style.backgroundColor="white"');
		eval('document.forms["'+frn+'"].'+cmpH+'.disabled=false');
		eval('document.forms["'+frn+'"].'+cmpH+'.style.backgroundColor="white"');	
	}
}
		
//####-FIn funciones para el control de Calendario-####//


//####-Funciones genericas (Utilidades)-####//

	function blinking(nameText){
	
	
	
	}
	
	
	//Funcion para seleccionar un valor de un combo
	//cuyo id se pasa como parametro

	function loadSelectedOption(nameOption,value){
	
		var combo = document.getElementById(nameOption);
			
		if(combo!=null){
		
			var length = combo.options.length;
			
			var valueTmp = '';
			
				for(var i=0;i<length;i++){
					
					valueTmp = combo[i].value;
					
					if(value==valueTmp){
						
						combo.selectedIndex=i;
						
					}
				}
		}
	
	}
	
	//Funcion que dice cual fecha es mayor
	// !!!!!! parametro de entrada (dd/mm/yyyy)
	
	function compareDates(date01,date02){		
		var auxfec1=date01.getTime();
		var auxfec2=date02.getTime();
		
		if (auxfec1<auxfec2){
			return 2;
		}
		else if(auxfec1==auxfec2){
			return 0;
		}		
		else{
			return 1;
		}	
	}
	

//####-Fin funciones genericas (Utilidades)-####//

//####- Función que activa le página de espera

function espera(vsrc){
	
	//Metemos el src del iframe
	document.getElementById('carga').src = vsrc;
			
	document.body.style.border=0;
	document.body.style.width='99%';
	document.body.style.height='85%';
	document.body.style.align='center';
	
	//Ocultamos el div del cuerpo
	document.getElementById('carga').style.display='block';
	//Mostramos el div de espera
	document.getElementById('splashScreen').style.display='none';	
}

function precargaFecha(formu,dSalida,dRegreso, newDia, newMes, newAnio, newDiaR, newMesR, newAnioR){

	for(j=0;j<eval('document.forms["'+formu+'"].'+fieldSalidaM+'.options.length');j++){
		if (eval('document.forms["'+formu+'"].'+fieldSalidaM+'.options['+j+'].value')==newMes){
			eval('document.forms["'+formu+'"].'+fieldSalidaM+'.options.selectedIndex='+j+'')
		}
	}
	
	for(j=0;j<eval('document.forms["'+formu+'"].'+fieldRegresoM+'.options.length');j++){
		if (eval('document.forms["'+formu+'"].'+fieldRegresoM+'.options['+j+'].value')==newMesR){
			eval('document.forms["'+formu+'"].'+fieldRegresoM+'.options.selectedIndex='+j+'')
		}
	}
	
//	alert(eval('document.forms["'+formu+'"].'+fieldSalidaM+'.options[document.forms["'+formu+'"].'+fieldSalidaM+'.options.selectedIndex].value'));
	preDate=new Date();			
	cargaFechas('s',formu,newMes,newAnio);		
	cargaFechas('r',formu,newMesR,newAnioR);		
	
	if(preDate.getMonth()!=newMes){	
		eval('document.forms["'+formu+'"].'+dSalida+'.options.selectedIndex='+(newDia-1)+'');	}
	
	else{
		eval('document.forms["'+formu+'"].'+dSalida+'.options.selectedIndex='+(newDia-preDate.getDate())+'');		
	}
	
	if(preDate.getMonth()!=newMesR){			
		eval('document.forms["'+formu+'"].'+dRegreso+'.options.selectedIndex='+(newDiaR-1)+'');		
	}
	
	else{
		eval('document.forms["'+formu+'"].'+dRegreso+'.options.selectedIndex='+(newDiaR-preDate.getDate())+'');		
	}
}

function openWindow(url,name,wid,hei,scroll)
{
	/*
	alert(url);
	alert(name);
	alert(wid);
	alert(hei);
	alert(scroll);
	*/
	window.open(url, name,'width='+wid+',height='+hei+',scrollbars='+scroll);
}


function ocultaElement(element){
	document.getElementById(element).style.display = 'none';
}

function muestraElement(element){
	document.getElementById(element).style.display = 'block';
}

function abreBuscadorCiudadesV2(nameForm,nameField,nameFieldValue,nameFieldIsIATA, typeOfSearch, site){
	
	formIf=nameForm;
	fieldIf=nameField;
	fieldValueIf=nameFieldValue;
	fieldValueIsIATA=nameFieldIsIATA;
	
	var posTop = obtenerPosicion(nameField)+20;
	var posLeft = obtenerPosicionX(nameField)+50;
	
	document.getElementById('buscadorCiudadesIF').style.display="block";
	document.getElementById('buscadorCiudadesIF').style.top = posTop;
	document.getElementById('buscadorCiudadesIF').style.left = posLeft;
	
	var ruta='';
	
	if(typeOfSearch=='flight'){
		document.getElementById('buscadorCiudadesIF').style.height='350px';
		document.getElementById('buscadorCiudadesIF').style.width='351px';
		//ruta=""+contextRoot+"jsp/generic/searchCities/"+site+"/ventanaModal_SearchCities.jsp";
		ruta=""+contextRoot+"jspV2/templates/"+site+"/flight/searchCities/ventanaModal_SearchCities.jsp";
		//ruta = "../general/buscadorCiudades.html"
	}
	else{
		document.getElementById('buscadorCiudadesIF').style.height='310px';
		document.getElementById('buscadorCiudadesIF').style.width='452px';	
		//ruta=""+contextRoot+"jsp/generic/searchCities/"+site+"/ventanaModal_SearchCities_hotel.jsp";
		ruta=""+contextRoot+"jspV2/templates/"+site+"/hotel/searchCities/ventanaModal_SearchCities_hotel.jsp";
		//ruta = "../general/buscadorCiudades.html"
	}
	
	document.getElementById('buscadorCiudadesIF').src=ruta;
}
function obtenerPosicionX(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }

  return (x);
}
function alerta(seleccionado,seleccionadoValue){
	eval(''+doc+'["'+formIf+'"].'+fieldIf+'.value=seleccionado');
	if(fieldValueIf!='')
		eval(''+doc+'["'+formIf+'"].'+fieldValueIf+'.value=seleccionadoValue');
	if(fieldValueIsIATA!='')
		eval(''+doc+'["'+formIf+'"].'+fieldValueIsIATA+'.value=true');
	document.getElementById('buscadorCiudadesIF').style.display="none";
}

function lanzaCiudad(ind0,ind1){
  parent.alerta(ind0,ind1);
}

function changeUrl(u){
	location.href=u;
}
