var IE = (document.all) ? true : false; 

var indMozz;
var actItm;

if(IE){indMozz=0}
else{indMozz=1}

var meses = new Array ('enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre')
var dias = new Array('lunes','martes','miércoles','jueves','viernes','sábado','domingo')
var actDate = new Date();

var actDayTxt = dias[actDate.getDay()-1];
var actDayNum = actDate.getDate();
var actMonth = meses[actDate.getMonth()];
var actYear = actDate.getFullYear();

var fechaTxt = actDayTxt+" "+actDayNum+" de "+actMonth+" de "+actYear;

var formIf="";
var fieldIf="";
var fieldValueIf="";
var fieldValueIsIATA="";
var doc="document.forms";

var actCln=false;

var fieldName="";
var fieldNameR="";
var tpCal;
var anioDep="";

var auxDate="";


document.write('<iframe src="'+contextRoot+'jspV2/templates/mrses/flight/searchCities/ventanaModal_SearchCities.jsp" id=\"buscadorCiudadesIF\" frameborder=\"no\" scrolling=\"no\">');
document.write('</iframe>');

document.write('<iframe src="'+contextRoot+'jspV2/calendar/calendario.jsp" id="calendarioIF" frameborder="no" scrolling="no">');
document.write('</iframe>');

/*document.write('<iframe src="/viajes/jspV2/minors/register/capaRegistro.jsp" id="registroIF" frameborder="no" scrolling="no">');
document.write('</iframe>');*/

document.write('<iframe id="fondoPopForm" frameborder="no" scrolling="no" style="position:absolute;top:0px;left:0px;display:none;float:left">');
document.write('</iframe>');

function closeOut(itm,e){
	
	var posY = obtenerPosicion(itm);
	var posX = obtenerPosicionX(itm);
	var h = document.getElementById(itm).offsetHeight;
	var y = document.getElementById(itm).offsetWidth;
	var evy = obtenerPosicionEvent(e);
	var evx = obtenerPosicionEventX(e);
	
	if(evy<posY || evy>posY+h || evx<posX || evx>posX+y){
		ocultaElement('calendarioIF')
	}
}

function abreBuscadorCiudades(nameForm,nameField,nameFieldValue,nameFieldIsIATA, typeOfSearch, site){
	if(actW)
	ocultaElement(actW);
	
	var bh;
	var bw;

	actW  = ('buscadorCiudadesIF')
	
	formIf=nameForm;
	fieldIf=nameField;
	fieldValueIf=nameFieldValue;
	fieldValueIsIATA=nameFieldIsIATA;
	
	var posTop = obtenerPosicion(nameField)+20+'px';
	var posLeft = obtenerPosicionX(nameField)+'px';
	
	document.getElementById('buscadorCiudadesIF').style.display="block";
	/*document.getElementById('buscadorCiudadesIF').style.top = posTop;
	document.getElementById('buscadorCiudadesIF').style.left = posLeft;*/
	
	var ruta='';
	
	if(typeOfSearch=='flight'){
		bh = '350px';
		bw = '351px';
		/*document.getElementById('buscadorCiudadesIF').style.height='368px';
		document.getElementById('buscadorCiudadesIF').style.width='351px';*/
		ruta=""+contextRoot+"jspV2/templates/"+site+"/flight/searchCities/ventanaModal_SearchCities.jsp";
	}
	else{
		bh = '370px';
		bw = '430px';
		/*document.getElementById('buscadorCiudadesIF').style.height='368px';
		document.getElementById('buscadorCiudadesIF').style.width='452px';	*/
		ruta=""+contextRoot+"jspV2/templates/"+site+"/hotel/searchCities/ventanaModal_SearchCities_hotel.jsp";
	}
	
	 var ww = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    ww = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    ww = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    ww = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  
	bwt = parseInt(bw);
	plt = parseInt(posLeft);
	var potT = bwt+plt;
	if(potT>ww){
	posLeft = parseInt(ww-bwt-50)+'px';}
	
	document.getElementById('buscadorCiudadesIF').style.top = posTop;
	document.getElementById('buscadorCiudadesIF').style.left = posLeft;
	document.getElementById('buscadorCiudadesIF').style.height=bh;
	document.getElementById('buscadorCiudadesIF').style.width=bw;
	document.getElementById('buscadorCiudadesIF').src=ruta;
}

function overMenu(itm){
	alert(itm.childNodes[0].styleClass);
}

function muestraMenu(ident){
	document.getElementById('subvuelos').style.display  = 'block';
	var ampli = 0;
	if(IE){ampli = 161}
	else{ampli = 0}
	var leftPos = parseInt(obtenerPosicion(ident));
	document.getElementById('subvuelos').style.left = leftPos+ampli+"px";
	//document.getElementById(ident.id).className='pestActiva';
}

function ocultaMenu(ident,e){
	var posTopMenu = 0;
	var may = 0;
	if(IE){
		posTopMenu = event.clientY;
		may = 134;
	}
	
	else{
		posTopMenu = e.pageY;
	}
	
	if(posTopMenu<120){
		ocultaElement(ident);
	}
}

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 obtenerPosicionEvent(ev) {	
	var evento = ev || window.event;
	return(evento.clientY+document.documentElement.scrollTop);
}

function obtenerPosicionEventX(ev) {
	var evento = ev || window.event;
	return(evento.clientX+document.documentElement.scrollLeft);
}

function ocultaElement(element){
	if (typeof element == "string")
	document.getElementById(element).style.display = 'none';
	
	else
	element.style.display = 'none'
}

function muestraElement(element){
	
	//selFactura es el div para mostrar Particular y Empresa en el "deseo recibir factura"
	if(element == "selFactura"){
		if(document.getElementsByName("billingType")[0].checked == true)
			muestraElement('formParticular');		
		else 
			muestraElement('formEmpesa');
	}

	if (typeof element == "string")
	{
		document.getElementById(element).style.display = 'block';
	}
	else
	{		
		element.style.display = 'block'
	}
}

function popVac(itm,ev){
	if(actItm){actItm.style.display = 'none';}
	var newElement = itm.parentNode.parentNode.parentNode.parentNode.childNodes[1+(2*indMozz)];	
	newElement.style.display='block';
	var posTop = obtenerPosicionEvent(ev);
	newElement.style.top = posTop+10+'px';
	actItm = newElement;
	moveIfBlank(newElement);
}

function moveIfBlank(itm){
	var posXIf = obtenerPosicionX(itm);
	var posYIf = obtenerPosicion(itm);
	document.getElementById('fondoPopForm').style.width = itm.offsetWidth;
	document.getElementById('fondoPopForm').style.height= itm.offsetHeight;
	document.getElementById('fondoPopForm').style.top = posYIf;
	document.getElementById('fondoPopForm').style.left = posXIf;
	document.getElementById('fondoPopForm').style.display = 'block';
	
}

function cerrarPop(itm){
	/*alert(itm.parentNode.parentNode.parentNode.className);
	for(j=0;j<100;j++){
		
	}*/
	itm.parentNode.parentNode.parentNode.style.display = 'none';
}

function changeStyle(itm,newStyle){
	if (document.getElementById(itm))
		document.getElementById(itm).className=newStyle;
}

function cambiaEnlacesFichaStanding(itm){
	var capArr = new Array('contentDat','contentMap','contentOpin','contentPhoto','contentVideo')
	var listArr = new Array('masInfo','verMap','verOpi','verFot','verVid');	
	for(a=0;a<listArr.length;a++){
		if(listArr[a]){
			if(document.getElementById(listArr[a])){
				if(listArr[a]==itm){changeStyle(listArr[a],'listNegroSep');muestraElement(capArr[a])}
				else{changeStyle(listArr[a],'listRojoSep'),ocultaElement(capArr[a])}
			}
		}
	}
}

function cambiaEnlacesFicha(itm){
	var capArr = new Array('contentDat','contentMap','contentOpin','contentPhoto','contentVideo')
	var listArr = new Array('masInfo','verMap','verOpi','verFot','verVid');	
	for(a=0;a<listArr.length;a++){
		if(document.getElementById(listArr[a])){	
			if(listArr[a]==itm){changeStyle(listArr[a],'rojo');muestraElement(capArr[a])}
			else{changeStyle(listArr[a],'');ocultaElement(capArr[a])}
		}
	}
}

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);
}

// FUNCIONES SOBRE CAPAS (MAS INFO, DESGLOSES, ETC...)

var actW;
var cajaDestino='';
var raizForm = '';


function cierraDesglose(itm)
{
	itm.parentNode.parentNode.parentNode.style.display='none';
}

function muestraDom(itm,cl,pr,ref){
	var iniRoot = itm;
	var iniRootM = itm;
	
	for(j=0;j<pr;j++){
		iniRoot = iniRoot.parentNode;
		iniRootM = iniRoot;
	}
	if(ref){
		iniRootM = itm;
		for(c=0;c<ref;c++){
			iniRootM = iniRootM.parentNode
		}
	}
	if(actW)
	ocultaElement(actW);
	var iniRootW = iniRootM.offsetWidth;
	var posY = obtenerPosicion(itm);
	var posBody;
	
	if(IE){posBody = parseInt(document.body.offsetLeft);}
	else{posBody = (-(document.body.scrollWidth-window.innerWidth)/2)}
	for(j=0;j<iniRoot.childNodes.length;j++){
		if(iniRoot.childNodes[j].className==cl){
			//muestraElement(iniRoot.childNodes[j].id);
			iniRoot.childNodes[j].style.display='block';
			posX = iniRootW - iniRoot.childNodes[j].offsetWidth+posBody;
			iniRoot.childNodes[j].style.top = posY+'px';
			iniRoot.childNodes[j].style.left = posX+'px';
			actW = iniRoot.childNodes[j];
		}
	}
}

function cerrarVentanaDom(){
	actW.style.display = 'none'
}

function abrirCalendario(fn,cn,itm,dd,dm,dy,rt,cnR){
	if(actW)
	ocultaElement(actW);
	
	actW  = ('calendarioIF')
	
	raizForm=fn;
	cajaDestino=cn;
	fieldName=dd;
	fieldNameR=dm;
	tpCal=rt;
	anioDep=dy;	
	if(cnR!=null)
	{
	auxDate=cnR;
	}
	
	var posBody = parseInt(document.body.offsetLeft);
	
	var posY = obtenerPosicion(itm)+itm.offsetHeight+'px';	
	var posX = obtenerPosicionX(itm)+document.body.offsetLeft;
	
	if(IE){posX = obtenerPosicionX(itm)+document.body.offsetLeft;}
	else{posX = obtenerPosicionX(itm)+'px'}
	
	document.getElementById('calendarioIF').src=contextRoot+'jspV2/calendar/calendario.jsp';
	document.getElementById('calendarioIF').style.display="block";
	
	document.getElementById('calendarioIF').style.top = posY;
	document.getElementById('calendarioIF').style.left = posX;
	
	
	if(tpCal=='s'){actCln=true}
	else{actCln=false}
}

function removeStyles(itm){
	document.all.itm.getStyle();
	
}

//TICKER
var TICKER_PAUSED = false;
var TICKER_SPEED = 1;
var TICKER_RIGHTTOLEFT = false;
var TICKER_STYLE = "float:left;font-family:Arial; font-size:12px; color:#444444";

function ticker_start() {
	var ticker_content = document.getElementById("ticker2").innerHTML;
	
	var tickerSupported = false;
	TICKER_WIDTH = document.getElementById("ticker2").style.width;
	var img = "<img src=/media/images/es/general/pt.gif width="+TICKER_WIDTH+" height=0 border=1>";

	// Firefox
	if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
		document.getElementById("ticker2").innerHTML = "<TABLE  cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'>&nbsp;</SPAN>"+img+"</TD></TR></TABLE>";
		tickerSupported = true;
	}
	// IE
	if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1) {
		document.getElementById("ticker2").innerHTML = "<DIV nowrap='nowrap' style='width:100%;float:left;padding-top:0px;'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'></SPAN>"+img+"</DIV>";
		tickerSupported = true;
	}
	if(!tickerSupported) document.getElementById("ticker2").outerHTML = ""; else {
		document.getElementById("ticker2").scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById("ticker2").scrollWidth - document.getElementById("ticker2").offsetWidth : 0;
		document.getElementById("TICKER_BODY").innerHTML = ticker_content;
		document.getElementById("ticker2").style.display="block";
		TICKER_tick();
	}
}

function TICKER_tick() {
	if(!TICKER_PAUSED) document.getElementById("ticker2").scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
	if(TICKER_RIGHTTOLEFT && document.getElementById("ticker2").scrollLeft <= 0) document.getElementById("ticker2").scrollLeft = document.getElementById("ticker2").scrollWidth - document.getElementById("ticker2").offsetWidth;
	if(!TICKER_RIGHTTOLEFT && document.getElementById("ticker2").scrollLeft >= document.getElementById("ticker2").scrollWidth - document.getElementById("ticker2").offsetWidth) document.getElementById("ticker2").scrollLeft = 0;
	window.setTimeout("TICKER_tick()", 30);
}











function deshabV2(frn,cmpD,cmpH,chk){
if(chk != null)
{
	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"');		
	}
}
else
{
		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"');	
}	
}

function deshabParamV2(frn,cmpD,cmpH,param){
	if(param==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"');	
	}
	
	if(param==true){
		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 cargaFechasV2(typ,formulario,newMes,newAnio,campoDate,day)
{
	var mesAnio = new Array("ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE");
	var actualD = new Date();
	dia=actualD.getDate();
	mes=actualD.getMonth();
	anio=actualD.getYear();
	if(!IE){anio=(anio+1900)}
	
	var date0 = "dd/mm/yyyy";
    date0 = date0.replace(/yyyy/i, newAnio);
	date0 = date0.replace(/mm/i, get2Digits(newMes));

    //date0 = date0.replace(/MON/, mesAnio[eval(mes-1)].substring(0,3).toUpperCase());
    //date0 = date0.replace(/Mon/i, mesAnio[eval(mes-1)].substring(0,3)); 
 
    
    if(day!=null)
    {
    	if(day!="")
    	{
    		dia=day;
    	}
    }
    date0 = date0.replace(/dd/i, get2Digits(dia));
    /*
    date0 = date0.replace(/DAY/, getDayName(eval(newMes-1),eval(mes-1),dia).toUpperCase());
    date0 = date0.replace(/day/i, getDayName(eval(newMes-1),eval(mes-1),dia));  
	*/
    
	var fech = null;
	var aux = null;  
	if(campoDate!=null)
	 {
		  aux = campoDate;
	 }
	 else
	 {
	   if(typ=="s")
	   {
			aux="departureDate";
	   }
	   if(typ=="r")
	   {
			aux="destinationDate";
	   }
	 }
	 
	 fech = eval('parent.document.forms["'+formulario+'"].'+aux);
     fech.value=date0;
     
}

function cargaFechasTrainV2(typ,formulario,newMes,newAnio,campoDate,day)
{
	var mesAnio = new Array("ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE");
	var actualD = new Date();
	dia=actualD.getDate();
	mes=actualD.getMonth();
	anio=actualD.getYear();
	if(!IE){anio=(anio+1900)}
	
	var date0 = "dd/mm/yyyy";
    date0 = date0.replace(/yyyy/i, newAnio);
	date0 = date0.replace(/mm/i, get2Digits(newMes));

    //date0 = date0.replace(/MON/, mesAnio[eval(mes-1)].substring(0,3).toUpperCase());
    //date0 = date0.replace(/Mon/i, mesAnio[eval(mes-1)].substring(0,3)); 
 
    
    if(day!=null)
    {
    	if(day!="")
    	{
    		dia=day;
    	}
    }
    date0 = date0.replace(/dd/i, get2Digits(dia));
    /*
    date0 = date0.replace(/DAY/, getDayName(eval(newMes-1),eval(mes-1),dia).toUpperCase());
    date0 = date0.replace(/day/i, getDayName(eval(newMes-1),eval(mes-1),dia));  
	*/
    
	var fech = null;
	var aux = null;  
	if(campoDate!=null)
	 {
		  aux = campoDate;
	 }
	 else
	 {
	   if(typ=="s")
	   {
			aux="departureDateTrain";
	   }
	   if(typ=="r")
	   {
			aux="destinationDateTrain";
	   }
	 }
	 
	 fech = eval('parent.document.forms["'+formulario+'"].'+aux);
     fech.value=date0;
     
}


// Funcion para incrementar en dos dias la fecha por defecto en Hoteles y Vuelos+Hotel
// ubicacion: /media/js/V2/general.js


function cargaFechasV2Hotel(typ,formulario,newMes,newAnio,campoDate,day)
{
	
	var mesAnio = new Array("ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE");
	var aFinMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); 
	var actualD = new Date();
	dia=actualD.getDate();
	mes=actualD.getMonth();
	anio=actualD.getYear();
	
	dia += 2;
	
	if (dia > aFinMes[mes]){
		ndias =	dia - aFinMes[mes];	
		dia = ndias;
			
		if ((mes+1)>11){
			
			if(!IE) {
				newAnio = (anio+1900)+1;
			}else{
				newAnio = anio+1;
			}
			newMes = 1;
		}else{
			newMes = mes + 2;
		}
	}else{

	}

	
	if(!IE){anio=(anio+1900)}
	
	var date0 = "dd/mm/yyyy";
    date0 = date0.replace(/yyyy/i, newAnio);
	date0 = date0.replace(/mm/i, get2Digits(newMes));
    //date0 = date0.replace(/MON/, mesAnio[eval(mes-1)].substring(0,3).toUpperCase());
    //date0 = date0.replace(/Mon/i, mesAnio[eval(mes-1)].substring(0,3)); 
    if(day!=null)
    {
    	if(day!="")
    	{
    		dia=day;
    	}
    }
    date0 = date0.replace(/dd/i, get2Digits(dia));
    /*
    date0 = date0.replace(/DAY/, getDayName(eval(newMes-1),eval(mes-1),dia).toUpperCase());
    date0 = date0.replace(/day/i, getDayName(eval(newMes-1),eval(mes-1),dia));  
	*/
    
	var fech = null;
	var aux = null;  
	if(campoDate!=null)
	 {
		  aux = campoDate;
	 }
	 else
	 {
	   if(typ=="s")
	   {
			aux="departureDate";
	   }
	   if(typ=="r")
	   {
			aux="destinationDate";
	   }
	 }
	 
	 fech = eval('parent.document.forms["'+formulario+'"].'+aux);
     fech.value=date0;
}


function get2Digits(n) {
  return ((n<10)?"0":"")+n;
}

function getDayName(y,m,d) {
  var wd=new Date(y,m,d);
  return dias[wd.getDay()].substring(0,3);
}


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 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;
		}	
	}	
	
	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 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 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 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));
var newMonthS = dateGo.substr(3,2)-1;

eval('document.forms["'+formName+'"].'+rn+'.value='+newMonthS);
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));
var newMonthR = dateBack.substr(3,2)-1;
eval('document.forms["'+formName+'"].'+rn+'.value='+newMonthR);
eval('document.forms["'+formName+'"].'+anioDep+'.value='+dateGo.substr(6,dateBack.length));
}
}

function cargaValores(ds,ms,dr,mr){
	if(ds)	fieldSalidaD=ds;
	if(ms)	fieldSalidaM=ms;
	if(dr)	fieldRegresoD=dr;
	if(mr)	fieldRegresoM=mr;
}


//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;
			}
		}
	}
}


function pestanasMulti(itm){
	ocultaElement('calendarioIF');
	ocultaElement('buscadorCiudadesIF');
	var pest = new Array('multiVuelos','multiHoteles','multiHotelesVH','multiVac');
	
	for(r=0;r<pest.length;r++){
		if(pest[r]==itm){muestraElement(pest[r])}
		else{ocultaElement(pest[r])}
	}	
}

function mapOfice(itm,newTxt,newStyle,typ,elmpos){
	
	var itm0;
	if (typeof itm == "string"){itm0 = document.getElementById(itm)}
	else{itm0 = itm.parentNode;}
	var oldTxt = itm0.childNodes[0].innerHTML;
	
	var inn0 = "<a onclick=\"muestraElement('"+elmpos+"');mapOfice(this,'"+oldTxt+"','listNegroSep','inn1','"+elmpos+"')\">"+newTxt+"</a>";	
	var inn1 = "<a onclick=\"ocultaElement('"+elmpos+"');mapOfice(this,'"+oldTxt+"','listRojoSep','inn0','"+elmpos+"')\">"+newTxt+"</a>";
	
	//changeTextStyle(itm0,newStyle);
	changeInner(itm0,eval(typ))
}

function changeTextStyle(itm,newStyle){
	itm.className = newStyle;
}

function changeInner(itm,inn){
	itm.innerHTML = inn;
}

function modifFondo(itm,niv,newStyle,et){

	var padre = itm;
	var padreL;
	var newid = newStyle;
	
	padreL = document.getElementById(newStyle).parentNode;
	for(v=0;v<padreL.childNodes.length;v++){
		if(padreL.childNodes[v].tagName == et){
			padreL.childNodes[v].id = 'idB';
		}
	}

	
	for(c=0;c<niv;c++){
		padre = padre.parentNode
	}
	
	for(v=0;v<padre.childNodes.length;v++){
		if(padre.childNodes[v].tagName == et){
			padre.childNodes[v].id = newStyle;
		}
	}
	
}

function clickC(itm,cmp){
	if(itm.checked == true){document.getElementById(cmp).style.display = 'block';}
	else{document.getElementById(cmp).style.display = 'none';}
}


function abrirRegistro(itm){
	var posBody = parseInt(document.body.offsetLeft);
	
	var posY = obtenerPosicion(itm)+itm.offsetHeight+'px';
	var posX = obtenerPosicionX(itm)+document.body.offsetLeft;
	
	if(IE){posX = obtenerPosicionX(itm)+document.body.offsetLeft+12;}
	else{posX = obtenerPosicionX(itm)+20+'px'}
	
	//document.getElementById('registroIF').src='../general/capaRegistro.html';
	//document.getElementById('registroIF').src=contextRoot+'jspV2/minors/register/capaRegistro.jsp';
	document.getElementById('registroIF2').style.display="block";
	document.getElementById('registroIF2').style.top = posY;
	document.getElementById('registroIF2').style.left = posX;
}

function abrirRegistro2(itm){
	
	var posBody = parseInt(document.body.offsetLeft);
	
	var posY = obtenerPosicion(itm)+itm.offsetHeight+'px';
	var posX = obtenerPosicionX(itm)+document.body.offsetLeft;
	
	if(IE){posX = obtenerPosicionX(itm)+document.body.offsetLeft+12;}
	else{posX = obtenerPosicionX(itm)+20+'px'}
	
	document.getElementById('registroIF2').style.display="block";
	document.getElementById('registroIF2').style.top = posY;
	document.getElementById('registroIF2').style.left = posX;
}

function abrirRegistro2(itm){
	var posBody = parseInt(document.body.offsetLeft);
	
	var posY = obtenerPosicion(itm)+itm.offsetHeight+'px';
	var posX = obtenerPosicionX(itm)+document.body.offsetLeft;
	
	if(IE){posX = obtenerPosicionX(itm)+document.body.offsetLeft+12;}
	else{posX = obtenerPosicionX(itm)+20+'px'}
	
	//document.getElementById('registroIF').src='../general/capaRegistro.html';
	//document.getElementById('registroIF').src=contextRoot+'jspV2/minors/register/capaRegistro.jsp';
	document.getElementById('registroIF2').style.display="block";
	document.getElementById('registroIF2').style.top = posY;
	document.getElementById('registroIF2').style.left = posX;
}


var actP='';

function muestraThisMenu(itm2){
	var ind0 = 0;
	if(IE){ind0=2}
	else{ind0 = 3}
	createMenu2();
	if(itm2.childNodes[ind0]){
		itm2.childNodes[ind0].style.display = 'block';
		itm2.className = 'pestActiva';
	}
}

function ocultaThisMenu(itm2){
	var ind0 = 0;
	if(IE){ind0=2}
	else{ind0 = 3}
	if(itm2.childNodes[ind0]){
		itm2.childNodes[ind0].style.display = 'none';
		if(itm2!=actP)itm2.className = 'pestInactiva';
	}
}

function createMenu2(){
	var ind0 = 0;
	if(IE){ind0=0}
	else{ind0 = 1}
	var itm;
	var rootMenu = document.getElementById('menu');
	if (rootMenu){
		for(s=0;s<rootMenu.childNodes[ind0].childNodes.length;s++){
			if(rootMenu.childNodes[ind0].childNodes[s+(ind0*s)+ind0]){
				itm = rootMenu.childNodes[ind0].childNodes[s+(ind0*s)+ind0].childNodes[2+ind0];
				if(itm){
					if(itm.parentNode.className=='pestActiva'){actP = itm.parentNode}
					itm.style.display='none';
					itm.style.position='absolute';
					itm.className = 'menuUl';
					itm.style.top='39px';
					itm.style.border='3px solid #ffffff';
					itm.style.left=(9*s)-((1.86*s))+'em';
					itm.style.width='12em';			
					
					for(a=0;a<itm.childNodes.length;a++){
						if(itm.childNodes[a].tagName == 'LI'){
							itm.childNodes[a].style.width = '12em';
							itm.childNodes[a].style.color = '#ffffff';
							itm.childNodes[a].childNodes[0].style.color = '#ffffff';
							itm.childNodes[a].childNodes[0].style.width = '12em';
						}
					}
				}
			}
		}
	}
}

function onBlurDepartureCalendar(form, departureField) {
  var departureDateValue = eval("document.forms."+form+"."+departureField+".value");
  if (departureDateValue != 'dd/mm/yyyy') {
	if (!(isDate(departureDateValue))) {			
	  alertNotValidDate();						
	  eval("document.forms."+form+"."+departureField+".value='dd/mm/yyyy'");
	  eval("document.forms."+form+"."+departureField+".select()");	  
	  eval("document.forms."+form+"."+departureField+".focus()");
	}
    else {
	  actClnFec = departureDateValue;
    }			
  }
}		

function onBlurDestinationCalendar(form, destinationField) {
    var destinationDateValue = eval("document.forms."+form+"."+destinationField+".value");
	if (destinationDateValue != 'dd/mm/yyyy') {
		if (!(isDate(destinationDateValue))) {			
			alertNotValidDate();			
		    eval("document.forms."+form+"."+destinationField+".value='dd/mm/yyyy'");
	  		eval("document.forms."+form+"."+destinationField+".select()");	  
	  		eval("document.forms."+form+"."+destinationField+".focus()");			
		}
	}
}


function onBlurDepartureCalendarOrderedByTime(form, departureField) {
    var departureDateValue = document.getElementById(departureField).value;
	if (departureDateValue != 'dd/mm/yyyy') {
		if (!(isDate(departureDateValue))) {			
			alertNotValidDate();			
		    document.getElementById(departureField).value='dd/mm/yyyy';
	  		document.getElementById(departureField).select();	  
	  		document.getElementById(departureField).focus();			
		}
	}
    else {
	  actClnFec = departureDateValue;
    }			
  }


function onBlurDestinationCalendarOrderedByTime(form, destinationField) {
    var destinationDateValue = document.getElementById(destinationField).value;
	if (destinationDateValue != 'dd/mm/yyyy') {
		if (!(isDate(destinationDateValue))) {			
			alertNotValidDate();			
		    document.getElementById(destinationField).value='dd/mm/yyyy';
	  		document.getElementById(destinationField).select();	  
	  		document.getElementById(destinationField).focus();			
		}
	}
}


function alertNotValidDate() {
	alert('Lo sentimos la fecha introducida es incorrecta. Por favor verifica que has introducido el siguiente formato dd/mm/yyyy');
}


function changeUrl(u){
	location.href=u;
}


	var IE = (document.all) ? true : false;
	function imprimir()
	{
	 if(IE){
	  var content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">'+
	  '<html>'+
	  '<head>'+
	  '<title>Marsans.com</title>'+
	  '<link rel="STYLESHEET" type="text/css" href="https://www.marsans.es/media/css/print.css"></head><body>'+
	  document.getElementById('cuerpo').innerHTML+
	  '</body></html>';
	  win = window.open();
	  self.focus();
	  win.document.open();
	  win.moveTo(-1000,-1000);
	  win.resizeTo(1,1);
	  win.document.write(content);
	  win.moveTo(-1000,-1000)
	  win.document.close();
	  win.moveTo(-1000,-1000)
	  win.print();
	  win.moveTo(-1000,-1000)
	  win.close();
	  }
	 else {window.print();}
	}
	
function muestraFoto(elem,image){
	ocultaElement('contentImageHotel');
	document.getElementById('contentImageHotel').innerHTML = '';
	var sup = obtenerPosicion(elem);
	var lat = obtenerPosicionX(elem)+80;
	document.getElementById('contentImageHotel').style.top = sup+'px';
	document.getElementById('contentImageHotel').style.left = lat+'px';
	var contentCap = '<a href="javascript:ocultaElement(\'contentImageHotel\');" style="float:left;color:#fff">cerrar x</a><br><img src='+image+'>';
	document.getElementById('contentImageHotel').innerHTML += contentCap;
	muestraElement('contentImageHotel')
}

function repintaTable(itm){
	var thisLI = itm.parentNode;
	var thisTR = thisLI.parentNode.parentNode.parentNode.parentNode;
	var thisTable = document.getElementById('tableContentPrice2')
	var liElements = thisTable.getElementsByTagName('LI');
	var tdElements = thisTable.getElementsByTagName('TD');

        for(a=0;a<liElements.length;a++){
		liElements[a].style.backgroundColor = '#f7f7f7';
		if(liElements[a] == thisLI){liElements[a-1].style.backgroundColor = '#ffffcd';}
	}
	
	for(r=0;r<tdElements.length;r++){
		tdElements[r].style.backgroundColor = '#f7f7f7';
	}

        thisLI.style.backgroundColor = '#ffffcd';

        for(h=0;h<thisTR.childNodes.length;h++){
		if(thisTR.childNodes[h].className == 'titTdB')
		thisTR.childNodes[h].style.backgroundColor = '#ffffcd';
	}
}

