// JavaScript Document
var bMakeLB=false;
var bHiddeBanners=false;
var bannersActives=false;
var contacto=false;
var bugFixing;
var age=false;
function ponerPublicidad(){
	var cPublicidad=document.getElementsByTagName('img');
	for(var i=0;i<cPublicidad.length;){
		var oRemplace=cPublicidad[i];
		if(oRemplace.className=='publicidad'){
			var oNewRemplace=document.createElement('div');
			oNewRemplace.id=oRemplace.id+'div';
			var oPublicidad = new SWFObject("/lib/fir/imagerotator.swf",oRemplace.id+"Publicidad",oRemplace.offsetWidth,oRemplace.offsetHeight,"7");
			oPublicidad.addVariable("file","/banners.php?area="+oRemplace.id);
			oPublicidad.addVariable("transition","slowfade");
			oPublicidad.addVariable("overstretch","true");
			oPublicidad.addVariable("shuffle","true");
			oPublicidad.addVariable("backcolor","#000000");
			oPublicidad.addVariable("linkfromdisplay","true");
			oPublicidad.addVariable("linktarget","_blank");
			oRemplace.parentNode.replaceChild(oNewRemplace,oRemplace);
			oPublicidad.write(oNewRemplace.id);
			}else{
			i++;
		}
	}
	bannersActives=true;
}
function hiddeBanners(){
	var oRight=document.getElementById('right');
	var oLeft=document.getElementById('left');
	oRight.style.display='none';
	oLeft.style.width='100%';
}
var ooDebug;
window.onload=function () {
	//urchinTracker();
	if(!bMakeLB)
		activeCalendar();
	formRules();
	showTBody();
	if(bHiddeBanners)
		hiddeBanners();
	else if(!bannersActives)
		ponerPublicidad();
	if(document.getElementById('intro_left')){
		var oRotador = new SWFObject("/lib/fir/imagerotator.swf","oRotadorSWF","630","205","7");
		oRotador.addVariable("file","/playlist.xml");
		oRotador.addVariable("transition","slowfade");
		oRotador.addVariable("overstretch","true");
		oRotador.addVariable("shuffle","false");
		oRotador.addVariable("backcolor","#A4B7C6");
		oRotador.write("intro_left");
	}
	if(contacto)
		activeteSpry();
	bugFixing==setTimeout('fnBugFixing()',5000);
};
function fnBugFixing(){
	var show = document.getElementsByTagName('div');
	for(var i=0;i<show.length;i++){
		if(show[i].className=='columna_izquierda' || show[i].className=='columna_derecha'){
			for(var j=0;j<show[i].childNodes.length;j++){
				var CurrShow=show[i].childNodes[j];
				if(CurrShow.nodeType==1){
					CurrShow.style.display='block';
					CurrShow.style.visibility='visible';
				}
			}
		}
	}
	jQuery('.columna_derecha .reservaCompleta').hide();
	jQuery('.columna_derecha .reservaSimple').show();
	/*
	if(bMakeLB){
		var objBody = document.getElementsByTagName("body").item(0);
		var ofScript=document.createElement('script');
		ofScript.setAttribute('type','text/javascript');
		ofScript.setAttribute('src','js/prototype.js');
		objBody.appendChild(ofScript);
		ofScript=document.createElement('script');
		ofScript.setAttribute('type','text/javascript');
		ofScript.setAttribute('src','js/scriptaculous.js?load=effects');
		objBody.appendChild(ofScript);
		ofScript=document.createElement('script');
		ofScript.setAttribute('type','text/javascript');
		ofScript.setAttribute('src','js/lightbox.js');
		objBody.appendChild(ofScript);
		ofScript=document.createElement('script');
		ofScript.setAttribute('type','text/javascript');
		ofScript.setAttribute('src','js/sobreEscribirLB.js');
		objBody.appendChild(ofScript);
	}*/
	clearTimeout(bugFixing);
}
function activeCalendar(){
	popUpCal.init();
	var OldYears=0;
	if(age)
		OldYears=100;
	jQuery('input.calendarFocus').calendar({yearRange:(nowDate.getFullYear()-OldYears)+':'+(nowDate.getFullYear()+5)});
	if(currLang=='esp'){
		jQuery('input.calendarFocus').calendar({yearRange:(nowDate.getFullYear()-OldYears)+':'+(nowDate.getFullYear()+5),clearText: 'Limpiar', closeText: 'Cerrar', prevText: '&lt;Ant', nextText: 'Sig&gt;', currentText: 'Hoy', dayNames: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'], monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']});
	}
}
function activeteSpry(){
	Spry.Widget.Form.destroyAll();
	var cImputs = document.getElementsByTagName('input');
	for(var iImput=0; iImput<cImputs.length; iImput++){
		var parentId=cImputs[iImput].parentNode.id;
		if(parentId!=undefined && parentId!=''){
			switch(cImputs[iImput].type){
				case 'text':
					var sprytextfield1 = new Spry.Widget.ValidationTextField(parentId, ((cImputs[iImput].id=='email')?'email':'none'), {validateOn:["blur"]});
					break
				case 'checkbox':
					var sprycheckbox1 = new Spry.Widget.ValidationCheckbox(parentId);
					break;
			}
		}
	}
	var sprytextarea1 = new Spry.Widget.ValidationTextarea("spryMensaje", {validateOn:["blur"],isRequired:true});
}
var nowDate=new Date();
function formRules(){
	var frmSearch=document.getElementById('intro_right');
	if(frmSearch){
		frmSearch.onsubmit=function(){
			var aIndate=document.getElementById('checkin').value.split('/');
			var dIndate=new Date(aIndate[2],aIndate[1]-1,aIndate[0]-1);
			if(dIndate<=nowDate){
				if(currLang=='esp')
					alert('Para ofrecerle un mejor servicio, necesitamos que reserve con 2 días de anticipación.');
				else if(currLang=='eng')
					alert('In order to offer a better service to you, we needed that it reserves with 2 days of anticipation.');
				document.getElementById('checkin').select();
				document.getElementById('checkin').focus();
				return false;
			}
			var iCateory=document.getElementById('pro_category').selectedIndex;
			var iDestinos=document.getElementById('destinos').selectedIndex;
			if(iCateory<1 && iDestinos<1){
				if(currLang=='esp')
					alert('Seleccione por lo menos una ciudad o categoría.');
				else if(currLang=='eng')
					alert('Choice at least one city or category.');
				return false;
			}
		}
	}
}
function showTBody(){
	var cLinks=document.getElementsByTagName('a');
	var hideAll=false;
	for(var i=0;i<cLinks.length;i++){
		if(cLinks[i].className=='showDetails'){
			cLinks[i].onclick=function(){
				var allTBodys=document.getElementsByTagName('tbody');
				var oBody=this.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('tbody')[0];
				for(var j=0;j<allTBodys.length;j++)
					allTBodys[j].style.display='none';
				try{
					oBody.style.display='table-row-group';
				}catch(e){
					oBody.style.display='block';
				}
				return false;
			}
			hideAll=true;
		}
	}
	if(hideAll){
		var allTBodys=document.getElementsByTagName('tbody');
		for(var j=0;j<allTBodys.length;j++)
			allTBodys[j].style.display='none';
	}
}
function addCommas(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
// Google \\
_uacct = "UA-2668826-1";
_uacct = "UA-2473163-1";
google_ad_client = "pub-4090659741763654";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "E1771E";
google_color_bg = "FFFFCC";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
google_ui_features = "rc:6";
/*var pageTracker = _gat._getTracker("UA-2668826-1");
pageTracker._trackPageview();*/
var pageTracker = _gat._getTracker("UA-2473163-1");
pageTracker._trackPageview();
