				
		function inicioJS(){			
			yearESel = parseInt();yearSSel = parseInt();			
			dia = parseInt(fecha.substr(6),10);                   
			mes = parseInt(fecha.substr(4,2),10);
			year = parseInt(fecha.substr(0,4),10);								
			escriuMes("mesE",nMeses,mes, year);
			escriuMes("mesS",nMeses,mes, year);
			mes--;
			dia_checkin = dia + diasAdelante;
			dia_checkout = dia + diasAdelante + diasEstancia;
			fecha_checkin = new Date(year, mes, dia_checkin);
			fecha_checkout = new Date(year, mes, dia_checkout);
			dia_checkin = fecha_checkin.getDate();
			mes_checkin = fecha_checkin.getMonth();
			year_checkin = fecha_checkin.getFullYear();
			dia_checkout = fecha_checkout.getDate();
			mes_checkout = fecha_checkout.getMonth();
			year_checkout = fecha_checkout.getFullYear();			
			if(diaESel==0){ diaESel=dia_checkin; }
			if(diaSSel==0){ diaSSel=dia_checkout; }
			if(mesESel==0){ mesESel=mes_checkin; }
			if(mesSSel==0){ mesSSel=mes_checkout; }
			if(isNaN(yearESel)){ yearESel=year_checkin; }
			if(isNaN(yearSSel)){ yearSSel=year_checkout; }			
			var i = 0;
			i= yearESel-year;
			if(i>0) {
				if(mesESel>mes+1) { mesESel = (12*i) + (mesESel - (mes + 1));
				} else { 
					mesESel=(12*i) - ((mes+1)-mesESel); 
				}
			} else {
				mesESel = mesESel - (mes + 1); 
			}               
			//$("mesE").selectedIndex = mesESel+1;
			selecMes("mesE","diaE");
			//Fechas por defecto hemos tenido que comentar esta linea
			//$("diaE").selectedIndex = diaESel - 1;
			i= yearSSel-year;
			if(i>0) { 
				if(mesSSel>mes+1) { mesSSel = (12*i) + (mesSSel - (mes + 1));
				} else { 
					mesSSel= (12*i) - ((mes+1) - mesSSel); 
				}
			} else { 
				mesSSel = mesSSel - (mes + 1); 
			}                     
			//$("mesS").selectedIndex = mesSSel+1;
			selecMes("mesS","diaS");
			//Fechas por defecto hemos tenido que comentar esta linea
			//$("diaS").selectedIndex = diaSSel - 1;
			thisDate = 1;
			todaysDate = dia;
			todaysMonth = mes+1;
			todaysYear = year;
			monthNum = todaysMonth;
			yearNum = todaysYear;
			quinDate = '';
			theID='';
			if(navigator.userAgent.indexOf('Opera')!=-1){ OP= 1;} else { OP= 0;}
			if(OP==1)theID='calendivop';
			if(theID=='') theID='calendiv';			
			if($('h_avtot')){
				altini=$('h_avtot').offsetHeight; onCos='h_avtot';
			} else onCos=0;			
		}
		
		function createCalendar() {
			var gastat='0';
			var ultim=$("mes"+quinDate).options[parseInt(nMeses)-1].value;
			var writeCalendar = '';	
			writeCalendar += '<a href="javascript:void(\'\');" onClick="noViss(theID)" id="tancar">X</a>'
			writeCalendar += '<div id="controller">'
			if(!((todaysMonth == monthNum) && (todaysYear == yearNum))) writeCalendar+= '<a class="calControl" id="backa" href="javascript:changeMonth(\'prev\')">&nbsp;<&nbsp;</a>'
			writeCalendar += '<span class="monthShow">';
			writeCalendar += arrMes[monthNum] + '&nbsp;&nbsp;';
			writeCalendar += yearNum;
			writeCalendar += '</span>';
			if(ultim==(yearNum+''+monthNum)|| ultim==(yearNum+'0'+monthNum)) writeCalendar=writeCalendar;
			else writeCalendar += '<a class="calControl" href="javascript:changeMonth(\'next\')">&nbsp;>&nbsp;</a>'
			writeCalendar += '</div>'																	   
			writeCalendar += '<div id="blocDies"><span class="calDay">'+d01+'</span><span class="calDay">'+d02+'</span><span class="calDay">'+d03+'</span><span class="calDay">'+d04+'</span><span class="calDay">'+d05+'</span><span class="calDay">'+d06+'</span><span class="calDay">'+d07+'</span></div>';
			if(firstDay-1==0)firstDay=8;
			diaclick= $("dia"+quinDate).value;
            mesclick= parseInt(String($("mes"+quinDate).value.substr(4,2)));
			for (var i = 1; i <= 42; i++) {
				if ((thisDate <= numbDays) && (i >= (firstDay-1))) {
					if ((thisDate == todaysDate) && (todaysMonth == monthNum) && (todaysYear == yearNum)){gastat='1'; writeCalendar += '<a id="avui" class="calDateToday" href="javascript:setDate(' + thisDate + ',' + monthNum + ',' + yearNum + ')">' + thisDate + '</a>';}
					else if((gastat==0)&&(todaysMonth == monthNum) && (todaysYear == yearNum)) {writeCalendar += '<a class="calDateb" href="javascript:void(\'\')">' + thisDate + '</a>';}
					else if((thisDate == diaclick)&&( mesclick== monthNum)){writeCalendar += '<a class="calDateSelected" href="javascript:setDate(' + thisDate + ',' + monthNum + ',' + yearNum + ')">' + thisDate + '</a>';}
					else writeCalendar += '<a class="calDate" href="javascript:setDate(' + thisDate + ',' + monthNum + ',' + yearNum + ')">' + thisDate + '</a>';
					thisDate++;
				}
				else writeCalendar += '<span class="calEmpty">&nbsp;</span>';
			}
			object=$(theID);
			object.innerHTML= writeCalendar;
			thisDate = 1;
		}
		
		
		
		function foraNnins(){
			noDiss('xiquets');
			for(i=1;$('rumi'+i)!==null;i++){
				for(x=1;$('anysde'+x)!==null;x++){
					var removeObject = $('anysde'+x);
					removeObject.parentNode.removeChild(removeObject);
				}
				var remObject = $('rumi'+i); 
				remObject.parentNode.removeChild(remObject);
			}
			$('selxnnins').parentNode.removeChild($('selxnnins'));
			$('capsal').parentNode.removeChild($('capsal'));
			$('adxiq').parentNode.removeChild($('adxiq'));
			$('xiquets').parentNode.removeChild($('xiquets'));
			if($('h_avtot')){
				$('h_avtot').style.height=altini+'px';
			}
			Diss('destino');Diss('avguest');Diss('go_search');
			Diss('go_search_results');
			Diss('guest');
			Diss('date_in');
			Diss('date_out');
			Diss('campo_free');
			Diss('fechas');
		}
			
		function GroupEdades(){
			$('frsv01').edad.value = "";
			var e = $('xiquets').getElementsByTagName('select');
			if(e.length!=zagals*habitacul){ 
				window.status="Error nins - contact to Hotelopia"; 
				return;
			}
			for(f=0;f<e.length;f++){ $('frsv01').edad.value += e[f].options[e[f].selectedIndex].text+'#';}
		}
		
		function dinsNnis(posevt){
			noDiss('destino');
			noDiss('avguest');
			noDiss('go_search');
			habitacul=parseInt($('frsv01').nhab.options[$('frsv01').nhab.selectedIndex].text);
			zagals=parseInt($('frsv01').nnins.options[$('frsv01').nnins.selectedIndex].text);
			partAb='';partB='';
			dinsDIV('div','csshead','xiquets');
			noDiss('go_search_results');
			noDiss('guest');
			noDiss('date_in');
			noDiss('date_out');
			noDiss('campo_free');
			noDiss('fechas');
			dinsDIV('div','xiquets','capsal');
			dinsDIV('div','xiquets','adxiq');
			$('adxiq').className  = 'borddd';
			$('adxiq').innerHTML= adxiqtxt+'.';
			$('capsal').innerHTML='<a href="javascript:foraNnins();" class="tancar">X</a>  '+tanctxt;
			$('xiquets').innerHTML+='<img src="'+pathh+'home/images/home/arrow_blue.gif" alt="Hotelopia" />';
			for(e=0;e<=16;e++){partB+='<option>'+e+'</option>'}
			for(i=1;i<=habitacul;i++){
				dinsDIV('div','xiquets','rumi'+i);
				orjeto=$('rumi'+i);
				orjeto.className  = 'oneroom';
				partA='<span class="roomy"> '+roomytxt+''+i+'-</span>';
				for(f=1;f<=zagals;f++){
					partAb+='<div id="anysde'+f+'" class="ageof"> '+ageoftxt+''+f+':&nbsp;&nbsp;<select id="agenins'+f+'" name="agenins'+f+'" size="1">'+partB+'</select>&nbsp;&nbsp;'+ageoftxt2+'.</div>';
				}
				orjeto.innerHTML=partA+partAb;
				partAb='';
			}
			$('xiquets').innerHTML+="<div id=\"selxnnins\" class=\"borddd\"><span>"+txt1+"</span><a id=\"selxics\" onClick=\"GroupEdades();document.getElementById('frsv01').submit()\" class=\"buttonon\" HREF=\"#\">"+txt2+"</a></div>";
			Diss('xiquets');
			if($('h_avtot')){
				$('h_avtot').style.height=$('xiquets').offsetHeight+50+'px';
			}
		}
	
		function selecMes(id,idDies){
			//alert('selecMes() '+id+' '+idDies+' ');
			var listMes = $(id);
			var listDia = $(idDies);
			var diaAnt = parseInt(listDia.selectedIndex);
			if(diaAnt==-1){ diaAnt=0; }
			var mesSelec = listMes.options[listMes.selectedIndex].value.substr(4,2);
			var yearSelec = listMes.options[listMes.selectedIndex].value.substr(0,4);
			var numDiesSelec = donamDies(mesSelec,yearSelec);
            var SoE = "diaS";
            var mesIndex = listMes.selectedIndex;
            ChangeMes(mesIndex);
            escriuDies(SoE,numDiesSelec);
            escriuDies(idDies, numDiesSelec);
			if(listDia.length > diaAnt) { 
				listDia.selectedIndex = diaAnt;
			} else { 
				listDia.selectedIndex=(diaAnt - (diaAnt - listDia.length)) - 1; 
			}
		}
        function ChangeMes(mesIndex){
            var messel = document.getElementById("mesS");
            if(mesIndex.length > 2)
            {
                messel.value = mesIndex;
            }
            else
            {
                messel.selectedIndex = mesIndex;
            }

        }

        function escriuMes(id, nMesos, mes, year) {
			//Fechas por defecto
			/*funcionalidad normal*/
			/*var contador = 1;
			var cero = "";
			while(contador<=nMesos) {
				if(mes>12) { mes = 1; year ++; }
				if(mes<10) { cero = "0"; }
				$(id).options[contador-1] = new Option(arrMes[mes]+" "+String(year).substr(2,2), (year+cero+mes));
				contador ++; mes ++; cero = "";
			}*/
			/*funcionalidad sin fechas por defecto TEMPORAL*/
			var contador = 1;
			var cero = "";
			$(id).options[0] = new Option(document.getElementById('textMes').value, "");
			while(contador<=nMesos) {
				if(mes>12) { mes = 1; year ++; }
				if(mes<10) { cero = "0"; }
				$(id).options[contador] = new Option(arrMes[mes]+" "+String(year).substr(2,2), (year+cero+mes));
				contador ++; mes ++; cero = "";
			}
		} 
						  
		function escriuDies(id, nDies) {
		    //Fechas por defecto
			/*funcionalidad normal*/
			//alert('escriuDies() '+id+' '+nDies);
			/*for(i=0;i<$(id).length;i++) { $(id).options[i] = null;}
			for(i=0;i<nDies; i++ ) { $(id).options[i] = new Option(i+1, i+1);}*/

			/*funcionalidad sin fechas por defecto TEMPORAL*/
			$(id).options[0] = new Option(document.getElementById('textdia').value, "");
			for(i=1;i<=$(id).length;i++) { $(id).options[i] = null;}
			for(i=1;i<=nDies; i++ ) { $(id).options[i] = new Option(i, i);}
		}
		
		function donamBi(year) { 
			if ( ((year % 4)==0) && (((year % 100)!=0) || ((year % 400)==0))) { return true; } return false; 
		}
		
		function donamDies(mes, year) {
			if (mes == 2) { if(donamBi(year)) { return 29; } return 28;  }
			if (mes == 4 || mes == 6 ||  mes == 9 ||  mes == 11) return 30;
			return 31;
		}
		
		
		function validaTot() {
			var seleME = $("mesE");
			var seleMS = $("mesS");
			var seleDE = $("diaE");
			var seleDS = $("diaS");
			if (seleME.selectedIndex >= seleMS.selectedIndex) {
				seleMS.selectedIndex = seleME.selectedIndex;
				selecMes("mesS", "diaS");
				if (seleDE.selectedIndex > seleDS.selectedIndex) {
					seleDS.selectedIndex = seleDE.selectedIndex; 
				}
			}		
		}
			
		function timeControl(time_now,date_now){			
			var dia_e = $("diaE").value;
			if (dia_e.length == 1) dia_e = '0'+ $("diaE").value;
			var select_date = $("mesE").value+dia_e;
			var time = time_now.replace(':','').split(':')[0];
			if ((date_now == select_date) && (parseInt(time)>=1700)){                    
				errorear(22804);
			} else {
				if(validaFechas())check_frsv01($('frsv01'));
			}
		}				
				
		function validaFechas(){
			var dE = ($('diaE').value<10)?('0'+$('diaE').value):$('diaE').value;
			var dS = ($('diaS').value<10)?('0'+$('diaS').value):$('diaS').value;
			var fE = parseInt($('mesE').value +''+ dE);
			var fS = parseInt($('mesS').value +''+ dS);
			var hoy = parseInt(fecha);
			if(fE < hoy) { errorear(20202);return false; }
			if(fE >= fS){ errorear(20201);return false; }
			return true;
		}
		
		function validaToten() {
			var seleME = $("mesE");
			var seleMS = $("mesS");
			var seleDE = $("diaE");
			var seleDS = $("diaS");
			if (seleDE.selectedIndex >= seleDS.selectedIndex && seleMS.selectedIndex == seleME.selectedIndex ){
				if (seleDE.selectedIndex + 3 >= seleDS.length){
					seleMS.selectedIndex = seleME.selectedIndex+1;
					seleDS.selectedIndex = (seleDE.selectedIndex + 3) - seleDS.length;
					selecMes("mesS", "diaS");quinSera('S');
				}else{
					seleDS.selectedIndex = seleDE.selectedIndex +3;
					seleMS.selectedIndex = seleME.selectedIndex;
					selecMes("mesS", "diaS");quinSera('S');
				}
			}
			if (seleME.selectedIndex >= seleMS.selectedIndex) {
				   seleMS.selectedIndex = seleME.selectedIndex;
				   selecMes("mesS", "diaS");quinSera('S');
			}
		 }
					 
		function setDate(diia,mesa,yearVal) {
			var numDiesSelec = donamDies(mesa,yearVal);			
			escriuDies("dia"+quinDate,numDiesSelec);
			nouVal= ''+mesa+'';
            if(nouVal.length==1)mesa='0'+mesa;
				$("dia"+quinDate).value = diia;
				$("mes"+quinDate).value = String(yearVal)+String(mesa);
				quinSera(quinDate);
                var SoE = "diaS";
                var mesIndex = $("mes"+quinDate).value;
                if(quinDate=='E')
                {
                   ChangeMes(mesIndex);
                   escriuDies(SoE,numDiesSelec);
                }
                //validaTot();
			}
			
					
		function changeMonth(direction) {			
			//alert('changeMonth() '+direction);
			if (direction == "prev") monthNum--;
			else if (direction == "next")monthNum++;
			else{//Fechas por defecto
			    if ($("mes"+quinDate).value == ''){
                    $("mes"+quinDate).selectedIndex = 1;
                }
			}
			if (monthNum == 0) {
				monthNum = 12;
				yearNum--;
			}else if (monthNum == 13) {
				monthNum = 1;
				yearNum++
			}
			Nouany=$("mes"+quinDate).value.substring(0,4);
			Noumes=($("mes"+quinDate).value.substring(4,5)==0)? ($("mes"+quinDate).value.substring(5,6)):($("mes"+quinDate).value.substring(4,6));
			pato=($(theID).style.visibility!='visible')?1:2;
			if(OP!=1){
				firstDate =(pato==1)?  new Date(String(Noumes)+"/1/"+String(Nouany)):new Date(String(monthNum)+"/1/"+String(yearNum));}
			else {
				firstDate =(pato==1)?  new Date("1/"+String(Noumes)+"/"+String(Nouany)):new Date("1/"+String(monthNum)+"/"+String(yearNum));}
			monthNum=(pato==1)?Noumes:monthNum;
			yearNum=(pato==1)?Nouany:yearNum;
			numbDays = donamDies(monthNum,yearNum);
			firstDay = firstDate.getDay() + 1;
            createCalendar();
			return;
		}
		
		function quinSera(bip){						
			//alert('quinSera() '+bip);
			if(!$('calE'))noViss(theID);
			else if(bip!=-1){theID='cal'+bip;changeMonth('return')};
		}
									  
		function dosCalend(){
			quinDate='E';
			quinSera(quinDate);
			quinDate='S';
			quinSera(quinDate);
		}
		
		function favourites(){
			IE = navigator.appName.match(/(Microsoft Internet Explorer)/gi);
			NS = navigator.appName.match(/(Netscape)/gi);
			OP = navigator.appName.match(/(Opera)/gi);
			if(IE && document.uniqueID) window.external.AddFavorite(label1,'HOTELOPIA '+keytit);
			if(OP || IE && !document.uniqueID) alert('Your browser requires that you\nPress Ctrl + T to Bookmark this page.');
			if(NS) alert('Your browser requires that you\nPress Ctrl + D to Bookmark this page.');
		}
		
		function errorear(hotelopiaAlert) {				
				switch(hotelopiaAlert){
					case 20301: alert(al01); break;
					case 20302: alert(al02); break;			
					case 20303: alert(al03); break;
					case 20304: alert(al04); break;
					case 20305: alert(al05); break;
					case 20306: alert(al06); break;
					case 20307: alert(al07); break;
					case 20308: alert(al08); break;
					case 20309: alert(al09); break;
					case 20310: alert(al10); break;
					case 20311: alert(al11); break;
					case 20312: alert(al12); break;
					case 20313: alert(al13); break;
					case 20314: alert(al14); break;
					case 20315: alert(al15); break;
					case 20316: alert(al16); break;
					case 20317: alert(al17); break;
					case 20318: alert(al18); break;
					case 20319: alert(al19); break;
					case 20320: alert(al20); break;
					case 20321: conf00=al21; return conf00; break;					
					case 20601: alert(al22); break;					
					case 20101: alert(al23); break;					
					case 20102: alert(al24); break;					
					case 21301: alert(al25); break;
					case 21302: alert(al26); break;
					case 21303: alert(al27); break;
					case 21304: alert(al28); break;
					case 21305: alert(al29); break;
					case 21306: alert(al30); break;
					case 21307: alert(al31); break;					
					case 20201: alert(al32); break;					
					case 20202: alert(al33); break;					
					case 22801: alert(al34); break;					
					case 22802: alert(al35); break;
                    case 22803: alert(al36); break;
                    case 22804: alert(al37); break;
                    case 22805: alert(al38); break;
					default: alert("Error please contact to Call Center. Cod. Reference=erGenB"); break;
				}
			}
			
			function getSelValue(selectId){ var objSel = document.getElementById(selectId); return objSel.options[objSel.selectedIndex].value; }

			function changeConf(p_curr, p_lang, p_form){
				var moned = getSelValue(p_curr);
				var idiom = getSelValue(p_lang);
				var formul = document.getElementById(p_form);
				var dominio = null;
				if(moned=="EUR"){ moned = getcodWebEUR(idiom); }
                if(moned=='hmx'){idiom ='MEX';}
                document.getElementById("lanG").value = idiom;
				document.getElementById("codWeb").value = moned;
				formul.submit();
			}
			
			function getcodWebEUR(p_param) 
			{  
				var codEUR = "hie";
				switch(p_param)
				{
					case "ALE": codEUR="hde"; break;
					case "FRA": codEUR="hfr"; break;
					case "ITA": codEUR="hit"; break;
					case "CAS": codEUR="hes"; break;
					case "HOL": codEUR="hnl"; break;
					case "DAN": codEUR="hdk"; break;
					case "POR": codEUR="hpt"; break;
				}
				return codEUR;
			}
			
			function clearRadioDest(form) {
				return true;
			}
			
			function check_frsv01() {
				var codigo = "";
				var txt = $('freetext');
				var txtvis = $(freeNid).value;	
				var layerLength = $('content_free').childNodes;
				for(i=0; i<layerLength.length;i++){
					if(layerLength[i].tagName!=='DIV' && layerLength[i].tagName!=='div' ) break;
					if(format(layerLength[i].innerHTML)==format(txtvis)){
						txt.value=layerLength[i].attributes.getNamedItem('name').nodeValue;
						break;}
					}
				var txthid = txt.value.split(',')[0];
				if(txt.value!=""){
					var name_free = txt.value.split(',');
					document.getElementById('goto').value='HFT-'+name_free[2];
					codigo = txt.value;
					}    	
				if(!cargarDestino(codigo)) {
					errorear(20101);
					return;
				}
				if(parseInt($('frsv01').nnins.options[$('frsv01').nnins.selectedIndex].text,10)>0) {
					dinsNnis();
					return;
				}
				$('frsv01').submit();
			}
			
			function cargarDestino(destinoCompacto){
				$('frsv01').codagrdest.value="";
				$('frsv01').coddest.value="";
				$('frsv01').codagrzon.value="";
				$('frsv01').codzon.value="";
				arrayDestino = destinoCompacto.split(',');
				if(arrayDestino.length < 2){ return false; }
				$('frsv01').nomdest.value =arrayDestino[0]; 
				if(arrayDestino[1]!=""){ 
					$('frsv01').codagrdest.value = arrayDestino[1];
				return true;
				}
				if(arrayDestino.length >= 3)
				{
					if(arrayDestino[2]!="")
					{
						$('frsv01').coddest.value = arrayDestino[2];
						if(arrayDestino.length >= 4 && arrayDestino[3]!=""){ $('frsv01').codagrzon.value = arrayDestino[3]; }
						if(arrayDestino.length == 5 && arrayDestino[4]!=""){ $('frsv01').codzon.value =  arrayDestino[4]; }
						return true;
					}
				}
				return false;
			}