// JavaScript Document

function doVirtualTour(url, lang){
	var arLang = {'es':'ESP','fr':'FRA','en':'ING'};
	window.open(url+"?lang="+arLang[lang],'VT','width=700,height=400');
	
}

function loadPopup(elDiv, elDivBg,txt){
  //loads popup only if it is disabled

	$("#"+elDiv).html(txt);

    $("#"+elDivBg).css({
    	"opacity": "0.7"
  	});
  	$("#"+elDivBg).fadeIn("fast");
  	$("#"+elDiv).fadeIn("fast");

}

//centering popup
function centerPopup(elDiv, elDivBg){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#"+elDiv).height();
  var popupWidth = $("#"+elDiv).width();
  //centering
  $("#"+elDiv).css({
    	"position": "absolute",
    	"top": windowHeight/2-popupHeight/2,
    	"left": windowWidth/2-popupWidth/2
    });

  //only need force for IE6
  $("#"+elDivBg).css({
  	"height": windowHeight
  	});

}

function disablePopup(elDiv, elDivBg){
	$("#"+elDivBg).fadeOut("fast");
	$("#"+elDiv).fadeOut("fast");
}

function doCal(lang,tar,w,h,scl){

	popUp('/cal.php?lang='+lang+'&d='+tar,w,h,scl);
}

function doMapInteractive(file){
//	obj = document.mapInteractive;
//	obj.mapDistrict.value = district;
//	obj.submit();

		document.location.href= file;

}

// set airport code

function fncSetAirCode(tar,val){
	opener.document.getElementById(tar).value=val;
	window.close();
}

function setIdBg(id,bgColor){
	document.getElementById[id].style.bgColor=bgColor;
}


// functions for special

function setFormDate(d,month,day,year){
	var form = document.searchForm;
		dObj = eval('form.'+d+'Day');

		yObj  = eval('form.'+d+'Year')

		for(x=0;x<dObj.length;x++){
			if(dObj.options[x].value == day){

				dObj.selectedIndex=x;
			}
		}

		for(x=0;x<yObj.length;x++){
			if(yObj.options[x].value == year+"-"+month){

				yObj.selectedIndex=x;
			}
		}

}
function doSubmit(form, doWaiting){

	if(doWaiting == null){doWaiting = true; }

	var objForm = eval('document.'+form);
	if(validateForm(form)){
		if(objForm.btnBook) {
			objForm.btnBook.disabled 	= true;
			objForm.btnBook.style.color = '#CCCCCC';

		}
		Display('msgStartPayment');
		objForm.submit();

	if(doWaiting){
//		Display('waiting');
		loadPayment();
		document.location.hash='top';
	}


	}
}

/*
 			function showLayer(tar){

			document.getElementById(tar).style.display='block';

			}

			function hideLayer(tar){

			document.getElementById(tar).style.display='none';

			}
*/
			function toggleLayerCheckbox(el,tar){
				if(document.getElementById(el).checked==true){
					document.getElementById(tar).style.display='block';
				}else{
					document.getElementById(tar).style.display='none';
					document.getElementById(el).checked=false;
				}
			}
function toggleLayerRadio(el,tar){

		if(el.value=="Y"){
			document.getElementById(tar).style.display='block';
		}else{
			document.getElementById(tar).style.display='none';
		}
	}

var displayWin;
function popUp(url,width,height,sroll){

	var query="";
	var flag=0;
	if(sroll=="yes"){query=",resizable=yes,scrollbars=yes,outerHeight="+height+",outerWidth="+width;}

	offsetX = (screen.width - width)/2;
	if(offsetX<0){ offsetX = 10; }

	offsetY = (screen.height - height)/2;
	if(offsetY<0){ offsetY = 10; }

	if(displayWin != null){
		displayWin.close();
		displayWin = window.open(url,"win","status=no,width="+width+",height="+height+",top="+offsetY+",left="+offsetX+query);
	}else{
		displayWin = window.open(url,"win2","status=no,width="+width+",height="+height+",top="+offsetY+",left="+offsetX+query);

	}

}


function showLayer(tar){
	document.getElementById('aptSearch').style.display='none';
	document.getElementById('hotelSearch').style.display='none';
	document.getElementById(tar).style.display='block';
	if(tar=='hotelSearch'){
		document.searchForm.elements['accommType'][1].checked=true;
	}
	if(tar=='aptSearch'){
		document.searchForm.elements['accommType'][0].checked=true;
	}
}

function noDisplay(el){

				var me = document.getElementById(el);

				if(me)me.style.display='none';

				}

function Display(el){

		var me = document.getElementById(el);

		if(me)me.style.display='block';

		}

function ShowHide(el) {

		var object = document.getElementById(el);

		state = object.style.display;

			if (state != 'block')Display(el);

			else noDisplay(el);

			return false;

		}
function dinsDIV(Ele,On,QUI){

				var newImageElement = document.createElement(Ele);

				newImageElement.setAttribute('id',QUI);

				if(On==0)document.body.appendChild(newImageElement);

				else document.getElementById(On).appendChild(newImageElement);

				}

function doFilter(elVar, elValue){

			document.filterForm.submit();
		}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

   }

/*check the form to addLink*/

function checkFormLink(){

	if(document.linkForm.url.value == "" ||!checkURL(document.form1.url.value)){
		 alert("Please enter a correct domain URL");
		 document.linkForm.link_data_url.focus(); 
		 return false;
	 }
	 else if(document.linkForm.link_data_target.value == "" ||!checkURL(document.form1.link_data_target.value)){
		 
		 alert("Please enter a correct target URL");
		 document.linkForm.link_data_target.focus(); 
		 return false;
	 }
	 else if(document.linkForm.email.value == "" || !checkMail(document.form1.link_data_email.value)){
		 
		 alert("Please enter a correct Email");
		 document.linkForm.link_data_email.focus(); 
		 return false;
	 }

}

