function refreshTotals(num,anticipated,total,section){
	anticipated = parseFloat(anticipated);
	total = parseFloat(total);

	if (section == "HT"){
		//num = num + 1;
		
		checked = document.form1.elements[num].checked;
		
		anticipatedHotels = parseFloat(document.form1.anticipatedHotels.value);
		totalHotels = parseFloat(document.form1.totalHotels.value);	
		
		anticipatedImport = parseFloat(document.form1.anticipatedImport.value);
		totalImport = parseFloat(document.form1.totalImport.value);
		
		if (checked == true){
			anticipatedHotels = anticipatedHotels + anticipated;
			totalHotels = totalHotels + total;
			
			anticipatedImport = anticipatedImport + anticipated;
			totalImport = totalImport + total;			
		
		}
		else{
			anticipatedHotels = anticipatedHotels - anticipated;
			totalHotels = totalHotels - total;			
			
			anticipatedImport = anticipatedImport - anticipated;
			totalImport = totalImport - total;						
		}

		anticipatedHotels = anticipatedHotels * 100;
		totalHotels = totalHotels * 100;
		
		anticipatedImport = anticipatedImport * 100;
		totalImport = totalImport * 100;
		
		with(Math){
			anticipatedHotels = round(anticipatedHotels);
			totalHotels = round(totalHotels);
			
			anticipatedImport = round(anticipatedImport);
			totalImport = round(totalImport);			
		}
		anticipatedHotels = anticipatedHotels/100;
		totalHotels = totalHotels/100;
		
		anticipatedImport = anticipatedImport/100;
		totalImport = totalImport/100;		

		document.form1.anticipatedHotels.value = anticipatedHotels;
		document.form1.totalHotels.value = totalHotels;	
		document.form1.anticipatedHotelsField.value = anticipatedHotels.toFixed(2) + " €";
		document.form1.totalHotelsField.value = totalHotels.toFixed(2) + " €";		
		
		document.form1.anticipatedImport.value = anticipatedImport;
		document.form1.totalImport.value = totalImport;	
		document.form1.anticipatedImportField.value = anticipatedImport.toFixed(2) + " €";
		document.form1.totalImportField.value = totalImport.toFixed(2) + " €";				
	}
	else{
		if (section == "TR"){
			if (document.form1.totalHotels){
				num = num + 4;
			}
			
			checked = document.form1.elements[num].checked;
			
			anticipatedTransfers = parseFloat(document.form1.anticipatedTransfers.value);
			totalTransfers = parseFloat(document.form1.totalTransfers.value);	
			
			anticipatedImport = parseFloat(document.form1.anticipatedImport.value);
			totalImport = parseFloat(document.form1.totalImport.value);
			
			if (checked == true){
				anticipatedTransfers = anticipatedTransfers + anticipated;
				totalTransfers = totalTransfers + total;
				
				anticipatedImport = anticipatedImport + anticipated;
				totalImport = totalImport + total;			
			
			}
			else{
				anticipatedTransfers = anticipatedTransfers - anticipated;
				totalTransfers = totalTransfers - total;			
				
				anticipatedImport = anticipatedImport - anticipated;
				totalImport = totalImport - total;						
			}
	
			anticipatedTransfers = anticipatedTransfers * 100;
			totalTransfers = totalTransfers * 100;
			
			anticipatedImport = anticipatedImport * 100;
			totalImport = totalImport * 100;
			
			with(Math){
				anticipatedTransfers = round(anticipatedTransfers);
				totalTransfers = round(totalTransfers);
				
				anticipatedImport = round(anticipatedImport);
				totalImport = round(totalImport);			
			}
			anticipatedTransfers = anticipatedTransfers/100;
			totalTransfers = totalTransfers/100;
			
			anticipatedImport = anticipatedImport/100;
			totalImport = totalImport/100;		
	
			document.form1.anticipatedTransfers.value = anticipatedTransfers;
			document.form1.totalTransfers.value = totalTransfers;	
			document.form1.anticipatedTransfersField.value = anticipatedTransfers.toFixed(2) + " €";
			document.form1.totalTransfersField.value = totalTransfers.toFixed(2) + " €";		
			
			document.form1.anticipatedImport.value = anticipatedImport;
			document.form1.totalImport.value = totalImport;	
			document.form1.anticipatedImportField.value = anticipatedImport.toFixed(2) + " €";
			document.form1.totalImportField.value = totalImport.toFixed(2) + " €";				
		}
		else{
			if (section == "CR"){
				if ((document.form1.totalHotels) && (document.form1.totalTransfers)){
					num = num + 8;
				}
				else{
					if ((document.form1.totalHotels) || (document.form1.totalTransfers)){
						num = num + 4;
					}
				}
		
		
				checked = document.form1.elements[num].checked;
				
				anticipatedCars = parseFloat(document.form1.anticipatedCars.value);
				totalCars = parseFloat(document.form1.totalCars.value);	
				
				anticipatedImport = parseFloat(document.form1.anticipatedImport.value);
				totalImport = parseFloat(document.form1.totalImport.value);
				
				if (checked == true){
					anticipatedCars = anticipatedCars + anticipated;
					totalCars = totalCars + total;
					
					anticipatedImport = anticipatedImport + anticipated;
					totalImport = totalImport + total;			
				
				}
				else{
					anticipatedCars = anticipatedCars - anticipated;
					totalCars = totalCars - total;			
					
					anticipatedImport = anticipatedImport - anticipated;
					totalImport = totalImport - total;						
				}
		
				anticipatedCars = anticipatedCars * 100;
				totalCars = totalCars * 100;
				
				anticipatedImport = anticipatedImport * 100;
				totalImport = totalImport * 100;
				
				with(Math){
					anticipatedCars = round(anticipatedCars);
					totalCars = round(totalCars);
					
					anticipatedImport = round(anticipatedImport);
					totalImport = round(totalImport);			
				}
				anticipatedCars = anticipatedCars/100;
				totalCars = totalCars/100;
				
				anticipatedImport = anticipatedImport/100;
				totalImport = totalImport/100;		
		
				document.form1.anticipatedCars.value = anticipatedCars;
				document.form1.totalCars.value = totalCars;	
				document.form1.anticipatedCarsField.value = anticipatedCars.toFixed(2) + " €";
				document.form1.totalCarsField.value = totalCars.toFixed(2) + " €";		
				
				document.form1.anticipatedImport.value = anticipatedImport;
				document.form1.totalImport.value = totalImport;	
				document.form1.anticipatedImportField.value = anticipatedImport.toFixed(2) + " €";
				document.form1.totalImportField.value = totalImport.toFixed(2) + " €";				
			}
		}
	}
}

function mOvr(src,clrOver) {
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
src.bgColor = clrOver;
}
}
function mOut(src,clrIn) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
src.bgColor = clrIn;
}
}
function mClk(src) {
if(event.srcElement.tagName=='TD'){
src.children.tags('A')[0].click();
}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
	function MM_showHideLayers() { //v6.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	    obj.visibility=v; }
	}



function mailAntiSpam()
{
	var usuario = "info";
	var dominio = "mca-hotels.com";


	document.write("<a href=\"mailto:" + usuario + "@" + dominio + "\" class=\"link2\">" + usuario + "@" + dominio + "</a>")

}


function MM_openBrWindowCenter(theURL,winName,w,h) { //v2.0
   var availHeight = screen.availHeight;
   var availWidth = screen.availWidth;

   var x = 0, y = 0; 
   if (document.all) {
        x = window.screenTop; 
        y = window.screenLeft;
   }
   else if (document.layers) {  
        x = window.screenX;
        y = window.screenY;
   }
   
   
   availWidth = (availWidth-w)/2;
   availHeight = (availHeight - h)/2;

   var arguments = 'resizable=no,toolbar=0,location=0,directories=0,addressbar=0,scrollbars=no,status=0,menubar=0,top='+availHeight+',left='+availWidth+',width=' + w + ',height=' + h;
   var newWindow = window.open(theURL,winName,arguments);



}

function confirmDelete(txt,string){
	if (string != ""){
		var txt = txt + '? \n - ' + string;
	}
	else{
		var txt = txt + '?';
	}
	var agree=confirm(txt);
	if (agree){
		return true;
	}
	else{
		return false;
	}
}

function confirmDeleteRomm(txt,identifier,identifier1){

	var txt = txt + '?';

	var agree=confirm(txt);
	if (agree){
		document.location = "inforeservaDeleteRoom.php?identifier=" + identifier + "&identifier1= " + identifier1;
	}
	else{
		return false;
	}
}





function getDevolutionDate(interval){

	
	deliveryDate = document.form1.firstinput.value;
	devolutionDate = document.form1.secondinput.value;
	deliveryDate = deliveryDate.split("/");

	deliveryDateDay = deliveryDate[0];
	deliveryDateMonth = deliveryDate[1];
	deliveryDateYear = deliveryDate[2];

	if ((deliveryDateDay == undefined) || (deliveryDateMonth == undefined) || (deliveryDateYear == undefined)){
		document.form1.firstinput.value = "";
	}
	else{
		

		var gDeliveryDate = new Date(deliveryDateYear,deliveryDateMonth-1,deliveryDateDay);
		dia = gDeliveryDate.getDate();
		mes = gDeliveryDate.getMonth();
		any = gDeliveryDate.getYear();
		
		shownewdate = "true";
		
		dia = parseInt(dia);
		interval = parseInt(interval);
		interval++;
		var day2 = dia+interval;
			
		var devolutionDateNew = new Date(any,mes,day2);

		dia = devolutionDateNew.getDate();
		mes = devolutionDateNew.getMonth()+1;
		any = devolutionDateNew.getFullYear();
//alert(navigator.appName);
		if (navigator.appName=="Netscape"){
			any = any+'';
			var anyN1 = any.substring(0,1);
			anyN1 = parseInt(anyN1);
			anyN1 = anyN1 + 19;
			var anyN2 = any.substring(1,3);

			any = anyN1 + anyN2 + '';
		}
					

		if (dia<10) dia = "0" + dia;
		if (mes<10) mes = "0" + mes;
					
		devolutionDateNew = dia + '/' + mes + '/' + any;
		devolutionDateNew2 = any + "" + mes + "" + dia;

		if ((devolutionDate != undefined) && (devolutionDate != "")){
			deliveryDateTmp = deliveryDateYear + deliveryDateMonth + deliveryDateDay;
			deliveryDateTmp = parseInt(deliveryDateTmp);
			
			devolutionDate = devolutionDate.split("/");
		
			devolutionDateDay = devolutionDate[0];
			devolutionDateMonth = devolutionDate[1];
			devolutionDateYear = devolutionDate[2];			
			
			devolutionDateTmp = devolutionDateYear + devolutionDateMonth + devolutionDateDay;

			devolutionDateTmp = parseInt(devolutionDateTmp);
			devolutionDateNew2 = parseInt(devolutionDateNew2);
			if (devolutionDateTmp < devolutionDateNew2){
				shownewdate = "true";
			}
			else{
				shownewdate = "false";
			}
		}

		if (shownewdate == "true"){
			document.form1.secondinput.value = devolutionDateNew;
		}

	}

}
	
	


function validateTime(field,msg){
	var temp = "document.form1." + field + ".value";
	var time = eval(temp);
	
	time = time.split(":");
	
	hours = parseInt(time[0]);
	minutes = parseInt(time[1]);


	if ((hours != undefined) && (minutes != undefined) && ((hours>0) || (hours==0)) && (hours<25) && ((minutes>0) || (minutes==0)) && (minutes<60)){		
		if (field == "deliveryTime"){
			document.form1.devolutionTime.value=document.form1.deliveryTime.value;
		}
		return true;
	}
	else{
		alert(msg);
		var temp2 = "document.form1." + field + ".value=''";
		eval(temp2);

		return false;
	}
}

function transferDates(arrivalDate,exitDate,nameHotel,addressHotel){
	document.form1.nameHotel.value = "";
	document.form1.addressHotel.value = "";
	document.form1.idHotelTransfer.value = "";

	if (document.form1.firstinputArrival) document.form1.firstinputArrival.value = arrivalDate;
	if (document.form1.secondinputExit) document.form1.secondinputExit.value = exitDate;
	document.form1.nameHotel.value = nameHotel;
	document.form1.addressHotel.value = addressHotel;
}

function updateHotelInfo(numReservations){
	
		if (numReservations > 0) {
			document.form1.idReservation[numReservations].checked = true;
		}
	
		var infoHotel = document.form1.idHotelTransfer.value;

		if (infoHotel != ""){
			infoHotel = infoHotel.split("#");
			
			var id = infoHotel[0];
			var name = infoHotel[1];
			var address = infoHotel[2];
		
			document.form1.nameHotel.value = name;
			document.form1.addressHotel.value = address;
		}
		else{
			document.form1.nameHotel.value = "";
			document.form1.addressHotel.value = "";
		}
}
function paytransfer(){
	MM_validateForm('iagree','','checked');

	if (document.MM_returnValue){
		if ((document.tpvvirtual.pressedButton.value) == "pay"){
			MM_showHideLayers('LayerC','','show','Layer2','','hide');
			MM_openBrWindow4('','tpvvirtual','scrollbars=yes',770,500);
			setTimeout('', 2000) 
		}
		else{
			
			document.tpvvirtual.target = '';
		}
		return true;
	}
	else{
		return false;
	}

}
function MM_openBrWindow4(theURL,winName,features,w,h) { //v2.0

   var availHeight = screen.availHeight;
   var availWidth = screen.availWidth;

   var x = 0, y = 0; 
   if (document.all) {
        x = window.screenTop; 
        y = window.screenLeft;
   }
   else if (document.layers) {  
        x = window.screenX;
        y = window.screenY;
   }
   

   availWidth = (availWidth - w)/2;
   availHeight = (availHeight - h)/2;


   var arguments = features + ',top='+availHeight+',left='+availWidth+',width=' + w + ',height=' + h;;
   var newWindow = window.open(theURL,winName,arguments);
   newWindow.focus();

}
function MM_openBrWindow5(theURL,winName,features,w,h) { //v2.0

   var availHeight = screen.availHeight;
   var availWidth = screen.availWidth;

   var x = 0, y = 0; 
   if (document.all) {
        x = window.screenTop; 
        y = window.screenLeft;
   }
   else if (document.layers) {  
        x = window.screenX;
        y = window.screenY;
   }
   

   availWidth = (availWidth - w)/2;
   availHeight = (availHeight - h)/2;


   var arguments = features + ',top='+availHeight+',left='+availWidth+',width=' + w + ',height=' + h;;
   var newWindow = window.open(theURL,winName,arguments);
   newWindow.focus();

}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_prefix(){
	prefixvalue = document.form1.country.value;
	
	if (prefixvalue != ""){
	
		prefixvalue = prefixvalue.split("#");

		prefixvalue = prefixvalue[1];

		if (prefixvalue != ""){
			prefixvalue = "+" + prefixvalue;
		}
		
		document.form1.prefix.value = prefixvalue;
	}
	else{
		document.form1.prefix.value = "";
	}

}












function puntuaComentariOK(idComentari,graciasE)
{
	capa="caixa_puntacio" + idComentari;
	var c = document.getElementById(capa);
	c.innerHTML=""+ graciasE.toString() + "";
	document.getElementById("framePuntaComentari").src="http://www.mca-hotels.com/puntuaComment.php?idComentari=" + idComentari + "&val=1";

}

function puntuaComentariKO(idComentari,graciasE)
{

	capa="caixa_puntacio" + idComentari;
	var c = document.getElementById(capa);
	c.innerHTML=""+ graciasE.toString() + "";
	document.getElementById("framePuntaComentari").src="http://www.mca-hotels.com/puntuaComment.php?idComentari=" + idComentari + "&val=-1";
}


function puntuaComentariGuiaOK(idComentari,graciasE)
{
	capa="caixa_puntacio" + idComentari;
	var c = document.getElementById(capa);
	c.innerHTML=""+ graciasE.toString() + "";
	document.getElementById("framePuntaComentariGuia").src="http://www.mca-hotels.com/puntuaCommentGuide.php?idComentari=" + idComentari + "&val=1";

}

function puntuaComentariGuiaKO(idComentari,graciasE)
{

	capa="caixa_puntacio" + idComentari;
	var c = document.getElementById(capa);
	c.innerHTML=""+ graciasE.toString() + "";
	document.getElementById("framePuntaComentariGuia").src="http://www.mca-hotels.com/puntuaCommentGuide.php?idComentari=" + idComentari + "&val=-1";
}

function showDiv (div) {

	if (document.getElementById){
		var c = document.getElementById(div);
		
        if (c.style.display != "block"){
			
			c.style.visibility = 'hidden'; // Needed to measure
			c.style.display = "block";     // Needed to measure
			c.style.visibility = 'visible';

		} else {
			c.style.display="none";
		}
	}

}

function hideDiv (div) {
	if (document.getElementById){
		var c=document.getElementById(div);
		c.style.display="none";
	}
}

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 desplega(capa){
	
	capa1=document.getElementById('capa_home1');
	capa2=document.getElementById('capa_home2');
		
	capa1_2=document.getElementById('div_capa_home1');
	capa2_2=document.getElementById('div_capa_home2');
	
	capa1_3=document.getElementById('div2_capa_home1');
	capa2_3=document.getElementById('div2_capa_home2');
	
	capa1.style.visibility="hidden";
	capa1.style.display="none";
	capa1_2.style.background="none";
	capa1_3.style.background="#f9d1a0";
	
	capa2.style.visibility="hidden";
	capa2.style.display="none";
	capa2_2.style.background="none";
	capa2_3.style.background="#f9d1a0";
	
	valor=document.getElementById(capa);
	valor2=document.getElementById('div_'+capa);
	valor3=document.getElementById('div2_'+capa);
	
	valor.style.visibility="visible";
	valor.style.display="inline";
	valor2.style.background="#FFFFFF";
	valor3.style.background="#FFFFFF";
		
}

function amagacapes(){
	capa2=document.getElementById('capa_home2');
	capa2.style.visibility="hidden";
	capa2.style.display="none";
}


function saveinfo(strLanguageHC,strUrlHC,strBrandIdHC){

	citySearchv=document.getElementById('citySearch').value;
	hotelCheckin=document.hotelscombined.hotelCheckin.value;
	hotelCheckout=document.hotelscombined.hotelCheckout.value;

	
	window.actualitzakw.location.href='savekeyw.php?strLanguageHCf=' + strLanguageHC + '&strUrlHCf=' + strUrlHC + '&strBrandIdHCf=' + strBrandIdHC + '&citySearch=' + citySearchv + '&hotelCheckin=' + hotelCheckin + '&hotelCheckout=' + hotelCheckout;
}
function saveinfoAT(strLanguageHC,strUrlHC,strBrandIdHC){

	citySearchv=document.getElementById('volltext').value;

	window.actualitzakw.location.href='savekeyw.php?strLanguageHCf=' + strLanguageHC + '&strUrlHCf=atreveo&strBrandIdHCf=&citySearch=' + citySearchv;
}


//-->

