function $(id) {
	return document.getElementById(id)
}

function subCtryCty(){
	theElem = window.document.getElementById("selectCountry");
	if (theElem.value=="<?=$theSeparator?>"){
		return false;
	}
	else{
		return true;
	}
}

function GetXmlHttpObject()
{ 
	objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
} 

function getContent(url, contentid) {
	if($('loading')) {
		$('loading').style.display = 'block';
	}
	contentID = contentid; 
	xmlHttp=GetXmlHttpObject();
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=update;		
	xmlHttp.send(null);	
	
}

function update() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{	
		if($('loading')) {
			$('loading').style.display = 'none';
		}
		$(contentID).innerHTML = xmlHttp.responseText;
	} 
}

var tab_active = 'tabCity';
function tab_munu() {
	var tab_menu  = $('tab_box');
	var tab	= tab_menu.getElementsByTagName('li');
	for (var i = 0; i < tab.length; i++) {
		if(tab[i].className.indexOf('tab')!= -1) {
		/*
			tab[i].onmouseover = function() {
				this.className='tab_active';
				this.childNodes.item(1).className = 'bg_right_active';
			}
			tab[i].onmouseout = function() {
				if(this.id != tab_active) {
					this.className='tab';
					this.childNodes.item(1).className = 'bg_right';
				}
			}
			*/
			tab[i].onclick = function() {
				tab_active = this.id;
				setActive();
			}
		}
		
	}  					
}	
					
function setActive() {

	var tab_menu  = $('tab_box');
	var tab	= tab_menu.getElementsByTagName('li');
	for (var i = 0; i < tab.length; i++) {
 		tab[i].className='tab';
 		tab[i].childNodes.item(1).className = 'bg_right';
		$(tab[i].id.replace('tab','box')).className='hide';
	}	
	$(tab_active).className='tab_active';
	$(tab_active).childNodes.item(1).className = 'bg_right_active';
	$(tab_active.replace('tab','box')).className='show';
	if($(tab_active.replace('tab','box')).innerHTML.replace(" ", "").length < 100) {
		getContent('/commun/getContent?box='+tab_active.replace('tab','box'), tab_active.replace('tab','box'));
	} 
}

function buildOcc() {
	document.writeln('<option value="2|0">Double/Twin(2 people)</option>');
	document.writeln('<option value="1|0">Single(1 people)</option>');
	document.writeln('<option value="2|1">Double/Twin + kid</option>');
	document.writeln('<option value="3|0">Triple(3 people)</option>');
}

function checkDateInstant(checkInD,checkInM,checkInY){
	var minDate = new Date();
	var thedate = new Date();
	thedate.setFullYear(checkInY,checkInM-1,checkInD);
	minDate.setDate(minDate.getDate()+1);
	if (thedate<minDate){
		alert("You must book at least 1 days in advance\n\nPlease change your dates");
		return true;
	}
	else{
		return false;
	}
}

function submitInstant(){
	var checkin  = document.f2.checkInDate.value;
	var checkinArray = checkin.split("/");
	if (checkDateInstant(checkinArray[1],checkinArray[0],checkinArray[2])){
		return false;
	}
	else {
		document.f2.submit();
		return true;
	}
}
