function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
  window.focus();
}
//-----------------------------------------------------------------------------------------------------------------------------

function DoOnLoad(){
	window.focus();
	if(typeof(roomChanged)!="undefined")roomChanged()
	if(typeof(WriteTimeout)!="undefined")WriteTimeout()
}
//-----------------------------------------------------------------------------------------------------------------------------

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

//-----------------------------------------------------------------------------------------------------------------------------

function openWindowApointment (url,wdth,hght) {
	window.open(url,'flag','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+wdth+',height='+hght+',top=100,left='+((screen.availWidth - 500) /2));
}
//-----------------------------------------------------------------------------------------------------------------------------

function removeProduct(ptoken, spui) {
	document.forms['remove'].PTOKEN.value=ptoken;
	document.forms['remove'].SPUI.value=spui;
	document.forms['remove'].REMOVE.value='remove';
	document.forms['remove'].submit();
}

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 changeLanguage(lang) {
	var frm=document.getElementById("f_search");
	if(frm) {
		document.forms["f_search"].language.value=lang;
		document.forms["f_search"].submit();		
	} else {
		document.forms["ft_search"].language.value=lang;
		document.forms["ft_search"].submit();
	}
}

	function gotoPage(pnum) {
		xCountry = document.getElementById ("countryCode").value;
		xProvince = document.getElementById ("destinationCode").value;
		xZone = document.getElementById("zoneCode").value; 
		ifrom = document.getElementById("hs_arrival").value; 
		ito = document.getElementById("hs_departure").value; 
		name = document.getElementById("name").value; 
		var x=document.getElementsByName("catCode[]");
		htype = document.getElementById("hType").value; 
		var f=document.forms.ft_search;
		var rms=f.rooms.value;
		var cat="";
		for(n=0;n<x.length;n++) {
			if(x[n].checked==true)
				cat=(cat+"&catCode[]="+x[n].value);			
		} 

		var data="?pg="+pnum+"&page="+pnum+"&countryCode="+xCountry+"&destinationCode="+xProvince+"&zoneCode="+xZone+"&i_from="+ifrom+"&i_to="+ito+"&name="+name+"&rooms="+rms+"&htype="+htype+cat;
		
		var el,ad =0;
		var room="";
		for(var i=0;i<rms;i++){
			el=eval('f.child'+i+'.value')*1;
			ad=eval('f.adult'+i+'.value')*1;
			data+=("&adult"+i+"="+ad+"&child"+i+"="+el);

			if(el>0){
				for(c=0;c<el;c++){
					ag=eval('f.age'+i+'_'+c+'.value');
					data+=("&age"+i+"_"+c+"="+ag);
				}
			}
		}
		searchAvail("hotels/ajax.php",data);
	}


	function gotoMap() {
		xCountry = document.getElementById ("countryCode").value;
		xProvince = document.getElementById ("destinationCode").value;
		xZone = document.getElementById("zoneCode").value; 
		ifrom = document.getElementById("hs_arrival").value; 
		ito = document.getElementById("hs_departure").value; 
		name = document.getElementById("name").value; 
		var x=document.getElementsByName("catCode[]");
		htype = document.getElementById("hType").value; 
		var f=document.forms.ft_search;
		var rms=f.rooms.value;
		var cat="";
		for(n=0;n<x.length;n++) {
			if(x[n].checked==true)
				cat=(cat+"&catCode[]="+x[n].value);			
		} 

		var data="?pg=1&page=1&countryCode="+xCountry+"&destinationCode="+xProvince+"&zoneCode="+xZone+"&i_from="+ifrom+"&i_to="+ito+"&name="+name+"&rooms="+rms+"&htype="+htype+cat;
		
		var el,ad =0;
		var room="";
		for(var i=0;i<rms;i++){
			el=eval('f.child'+i+'.value')*1;
			ad=eval('f.adult'+i+'.value')*1;
			data+=("&adult"+i+"="+ad+"&child"+i+"="+el);

			if(el>0){
				for(c=0;c<el;c++){
					ag=eval('f.age'+i+'_'+c+'.value');
					data+=("&age"+i+"_"+c+"="+ag);
				}
			}
		}
		searchAvail("hotels/mapa.php",data);
	}



	function bookEntrada(tCode,mCode,num) {
		var adlts=document.getElementById("ADULTS").value;
		var chldr=document.getElementById("CHILDREN").value;
		var desde=document.getElementById("cfrm_date_"+num).value;
		var days=document.getElementById("days_"+num).value;		
		var y_in=desde.substring(0,4);
		var m_in=desde.substring(4,6);
		var d_in=desde.substring(6);
		var nm=(num.indexOf("_")==-1?'0':num.substring(num.indexOf("_")+1));
		var data="?pg=0&tCode="+tCode+"&mCode="+mCode+"&day="+d_in+"&month="+m_in+"&year="+y_in+"&days="+days+"&num="+nm+"&service=T&ADD=Y&ADULTS="+adlts+"&CHILDREN="+chldr+"&checkInDate="+desde;
				
		searchAvail("bookings/affstep1-h.php",data,"content");
	}


	function loadEvtResults(page) {
		xCountry = document.getElementById ("countryCode").value;
		xProvince = document.getElementById ("destinationCode").value;
		ifrom = document.getElementById("hs_arrival").value; 
		ito = document.getElementById("hs_departure").value; 
		var f=document.forms.ft_search;
		var data="?pg=0&page="+page+"&countryCode="+xCountry+"&destinationCode="+xProvince+"&i_from="+ifrom+"&i_to="+ito;
		
		var el,ad =0;
		var room="";
			el=eval('f.child0.value')*1;
			ad=eval('f.adult0.value')*1;
			data+=("&adult0="+ad+"&child0="+el);

			if(el>0){
				for(c=0;c<el;c++){
					ag=eval('f.age0_'+c+'.value');
					data+=("&age0_"+c+"="+ag);
				}
			}
		searchAvail("entradas/ajax.php",data);
	}	



	function loadCarResults(page) {
		countCode = document.getElementById ("countryCode").value;
		destCode = document.getElementById ("destinationCode").value;
		countDropCode = document.getElementById ("countryDropCode").value;
		destDropCode = document.getElementById ("destinationDropCode").value;
		locatCode = document.getElementById ("locationCode").value;
		locDropCode = document.getElementById ("locationDropCode").value;
		groupCode = document.getElementById ("groupCode").value;


		ifrom = document.getElementById("hs_arrival").value; 
		ito = document.getElementById("hs_departure").value; 
		picHour = document.getElementById("picHour").value; 
		picMinute = document.getElementById("picMinute").value; 
		dropHour = document.getElementById("dropHour").value; 
		dropMinute = document.getElementById("dropMinute").value; 

		var data="?page="+page+"&countryCode="+countCode+"&destinationCode="+destCode+"&i_from="+ifrom+"&i_to="+ito+"&countryDropCode="+countDropCode+"&destinationDropCode="+destDropCode+"&picHour="+picHour+"&picMinute="+picMinute+"&locationCode="+locatCode+"&locationDropCode="+locDropCode+"&dropHour="+dropHour+"&dropMinute="+dropMinute+"&groupCode="+groupCode;
		searchAvail("coches/ajax.php",data);
	}


	function bookCar(cNum) {
		var carCode=document.getElementById("carCode").value;
		var destCode = document.getElementById ("destinationCode").value;
		var destDropCode = document.getElementById ("destinationDropCode").value;
		var data="?pg=0&service=C&ADD=Y&carCode="+carCode+"&cNum="+cNum+"&destinationCode="+destCode+"&destinationDropCode="+destDropCode;
				
		searchAvail("bookings/affstep1-h.php",data);
	}




function loadEvDetails(data) {
		searchAvail("entradas/details.php",data);
	}



	function loadResults(page) {
		destName = document.getElementById("destName").value;
		ifrom = document.getElementById("hs_arrival").value; 
		ito = document.getElementById("hs_departure").value; 
		afId = document.getElementById("afId").value; 
		name = document.getElementById("name").value; 
		htype = document.getElementById("hType").value; 
		ito = document.getElementById("hs_departure").value; 

		var f=document.forms.ft_search;
		var rms=f.rooms.value;
		var x=document.getElementsByName("catCode[]");
		var cat="";
		for(n=0;n<x.length;n++) {
			if(x[n].checked==true)
				cat=(cat+"&catCode[]="+x[n].value);			
		} 


		var data="?pg=1&page="+page+"&destName="+destName+"&i_from="+ifrom+"&i_to="+ito+"&rooms="+rms+"&afId="+afId+"&name="+name+"&htype="+htype+cat;
		
		var el,ad =0;
		var room="";
		for(var i=0;i<rms;i++){
			el=eval('f.child'+i+'.value')*1;
			ad=eval('f.adult'+i+'.value')*1;
			data+=("&adult"+i+"="+ad+"&child"+i+"="+el);

			if(el>0){
				for(c=0;c<el;c++){
					ag=eval('f.age'+i+'_'+c+'.value');
					data+=("&age"+i+"_"+c+"="+ag);
				}
			}
		}
		searchAvail("hotels/destSearch.php",data);
		 document.getElementById("busq").style.display='none';
	}


	function loadHotels(page) {
		xCountry = document.getElementById ("countryCode").value;
		xProvince = document.getElementById ("destinationCode").value;
		xZone = document.getElementById("zoneCode").value; 
		ifrom = document.getElementById("hs_arrival").value; 
		ito = document.getElementById("hs_departure").value; 

		var f=document.forms.ft_search;
		var rms=f.rooms.value;

		var data="?page="+page+"&countryCode="+xCountry+"&destinationCode="+xProvince+"&zoneCode="+xZone+"&i_from="+ifrom+"&i_to="+ito+"&rooms="+rms;
		
		var el,ad =0;
		for(var i=0;i<rms;i++){
			el=eval('f.child'+i+'.value')*1;
			ad=eval('f.adult'+i+'.value')*1;
			data+=("&adult"+i+"="+ad+"&child"+i+"="+el);

			if(el>0){
				for(c=0;c<el;c++){
					ag=eval('f.age'+i+'_'+c+'.value');
					data+=("&age"+i+"_"+c+"="+ag);
				}
			}
		}
		document.location.href="hoteles.php"+data;
	}


	function loadSteps() {
		var cCode = document.getElementById("countryCode").value;
		var dCode = document.getElementById("destinationCode").value;
		var estCode = document.getElementById("estCode").value; 
		var ifrom = document.getElementById("checkInDate").value; 
		var ito = document.getElementById("checkOutDate").value; 
		var nights = document.getElementById("nights").value; 
		var hnum = document.getElementById("hNum").value; 
		var rnum = document.getElementById("rNum").value; 
		var serv = document.getElementById("service").value; 
		var action = document.getElementById("action").value; 
		var data="?estCode="+estCode+"&countryCode="+cCode+"&destinationCode="+dCode+"&rNum="+rnum+"&checkInDate="+ifrom+"&checkOutDate="+ito+"&nights="+nights+"&hNum="+hnum+"&service="+serv;
		searchAvail(action,data,"content");
	}


	function confirmSteps() {
		var service = document.getElementById("service").value;
		var mfname = document.getElementById("FirstName").value;
		var mlname = document.getElementById("LastName").value;
		var email = document.getElementById("e_Mail").value;
		var phone = document.getElementById("phone").value;
		var addres = document.getElementById("Address").value;
		var city = document.getElementById("City").value;
		var zip = document.getElementById("Zip").value;
		var state = document.getElementById("State").value;
		var cCode = document.getElementById("countryCode").value;
		var notes = document.getElementById("notes").value;
		var ptype = document.getElementById("ptype").value;
		var desde = document.getElementById("DESDE").value;
		var pax = document.getElementById("PAX").value;
		var rcount = document.getElementById("RCOUNT").value;
		var afId = document.getElementById("afId").value;
		var names="";
//		if(service=="H") {
//			for(var t=0;t<pax;t++) {
//					var fname = document.getElementById((t+"FName")).value;
//					var lname = document.getElementById((t+"LName")).value;
//					names=(names+"&"+t+"FName="+fname+"&"+t+"LName="+lname);
//			}
//		}
		var page="bookings/bankredirect.php";
		if(ptype=="transfer")
			page="bookings/transfer.php";
		if(ptype=="parts")
			page="bookings/partredirect.php";
		var data="?pg=1&countryCode="+cCode+"&FirstName="+mfname+"&LastName="+mlname+"&e_Mail="+email+"&phone="+phone+"&Address="+addres+"&City="+city+"&Zip="+zip+"&State="+state+"&notes="+notes+"&PTYPE="+ptype+"&DESDE="+desde+"&PAX="+pax+"&RCOUNT="+rcount+names+"&service="+service+"&afId="+afId;
		searchAvail(page,data, "content");
	}

	function loadDetails(data) {
		searchAvail("hotels/details.php",data,"content");
	}
	
	function backToResults() {
		var data = document.getElementById("ResQuery").value;
		var service = document.getElementById("service").value;
		
		if(service=='H')
			searchAvail("hotels/ajax.php",data);
		else if(service=='T')
			searchAvail("entradas/ajax.php",data);
		else if(service=='C')
			searchAvail("coches/ajax.php",data);
	}
