// JavaScript Document
function compileForm() { 
	var frm = document.bookingForm;
	if (frm.hotel.value != "00000") { 
		frm.arrive.value = frm.checkinmonth.value + "/" + frm.checkinday.value + "/" + frm.checkinyear.value;
		frm.depart.value = frm.checkoutmonth.value + "/" + frm.checkoutday.value + "/" + frm.checkoutyear.value;
		frm.action = "https://reservations.synxis.com/LBE/rez.aspx";
		frm.method = "get";
		return true;
	} else {
		/*frm.arriveDate.value = frm.checkinday.value;frm.arriveMonth.value = frm.checkinmonth.value;frm.arriveYear.value = frm.checkinyear.value;
		frm.departDate.value = frm.checkoutday.value;frm.departMonth.value = frm.checkoutmonth.value;frm.departYear.value = frm.checkoutyear.value;
		frm.action = "https://indecorp.ibe.netbooker.com/web/DisplayRoomRateSelection.do?pageIndex=1&conversionFactor=&roomsSortOrder=RateType";
		frm.action = "https://indecorp.ibe.netbooker.com/web/DisplaySinglePropertySearch.do;jsessionid=E3F40C2242C60D759642C204D05E0C5C";
		frm.method = "post";*/
		alert("Use the link provided under the booking form to book / amend booking for The Sarova Stanley.");
		return false;
	}
}

function toggleLayer(div)
{
	var x;
	if(!(x=document[div])&&document.all){x=document.all[div];}
	if(!x && document.getElementById){x=document.getElementById(div);}
	if(!x){return;}	
	if(x.style.display=="none"){x.style.display="block"}
	else{x.style.display="none"}
}

function showLayer(div)
{
	var x;
	if(!(x=document[div])&&document.all){x=document.all[div];}
	if(!x && document.getElementById){x=document.getElementById(div);}
	if(!x){return;}	
	if(x.style.display=="none"){x.style.display="block"}
}

function hideLayer(div)
{
	var x;
	if(!(x=document[div])&&document.all){x=document.all[div];}
	if(!x && document.getElementById){x=document.getElementById(div);}
	if(!x){return;}	
	if(x.style.display=="block"){x.style.display="none"}
}

function agyLayer(div)
{
	var p = document.getElementById(div);
	var dv = new Array('toc','adv','cwo','stay','gar','ginfo', 'eat');
	// -----------------------------------
	for (c = 0; c <= dv.length; c++) {
		if (dv[c] == div) {
			var x = document.getElementById(dv[c]);
			if(x.style.display=="block"){LC = 1;x.style.display="none";}else{LC = 0;x.style.display="block";}
			//alert(dv[c]);
		} else {
			hideLayer(dv[c]);
			//alert(dv[c]);
		}
	}
	// -----------------------------------
}

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_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
  if (obj) 
  if (obj.disabled == true) {
    obj.value = '';
  	obj.disabled = false;
  } else {
  	obj.disabled = true;
  }
}

function disABLE(objName) {
  var obj = MM_findObj(objName); 
  if (obj) 
  if (obj.disabled == false) {
  	obj.disabled = true;
  }
}

function enABLE(objName) {
  var obj = MM_findObj(objName); 
  if (obj) 
  if (obj.disabled == true) {
  	obj.disabled = false;
  }
}

function uncheck()
{
	var cbox = document.getElementById('alldonors');
	//var cchk = cbox.checked.value;
	if (cbox.checked == true) {
		cbox.checked = false;
	}
}

function check(element)
{
	var cbox = document.getElementById(element);
	//var cchk = cbox.checked.value;
	if (cbox.checked == false) {
		cbox.checked = true;
	}
}

function updateValue(newValue) {
	var ts = document.getElementById('TST');
	ts.value = newValue; 
	//HideDropdown();
}

function switchCSS(id, newstyle) {
	var ts = document.getElementById(id);
	ts.className = newstyle;
}

function changeTab(id) {
	// ----------------------------------
	var ts = document.getElementById(id);
	switchCSS(id, 'tbsel');
	// ----------------------------------
	// Change the other guys
	// ----------------------------------
	for (i=1;i<=4;i++) {
		if (i != id) {
			var m = document.getElementById(i);
			m.className = 'tbdef';
			if (i==4) {
				m.className = 'tbdefE';
			}
		}
	}
	
	// ----------------------------------
	// Change the display message
	// ----------------------------------
	var header = "Not Chosen";
	var frm = document.getElementById('shd');
	switch (id) {
		case "1":
		header = "Find information on gapyear organisations.";
		shd.location.href="gapyear.php";
		break;
		
		case '2':
		header = "Overland companies in operation.";
		shd.location.href="overland.php";
		break;
		
		case '3':
		header = "Showing the various accommodation options.";
		shd.location.href="accom.php";
		break;
		
		case '4':
		header = "Listing all restaurants and dining spots in the country.";
		shd.location.href="rests.php";
		break;
		
		default:
		header = "General Information.";
		frm.location.href="gapyear.php";
		break;
	}
	
	// -------------------------------------
	var ds = document.getElementById('dsp');
	dsp.innerHTML = header;
	// -------------------------------------

}

function isEmail(value) {
	if (value.indexOf('@') == -1) {
		return false;
	} else {
		return true;
	}
}

function isDigit(value) {
	if (isNaN(value)) {
		return false;
	} else {
		return true;
	}
}

function isEmpty(value) {
	if (value == 'undefined' || value == '') {
		return false;
	} else {
		return true;
	}
}

function showFilter() {
	var ft = document.getElementById().value;
	// ---------------------------------------
	switch (ft) {
		case 'unit':
		
		break;
		// --------
		case 'purpose':
		
		break;
		// --------
		case 'age':
		
		break;
		// --------		
	}
}
