function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  	if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
	obj.display=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

var d = document;
function showpic(pic) {
	if (d.images) {
		d.images['bigpic'].src = "themes/cie/images/hotels/"+pic;
		}
}

function OpenWin(u,n,w,h,s)
{
	var l = (screen.width)  ? (screen.width  - w)/2 : 0;
	var t = (screen.height) ? (screen.height - h)/2 : 0;
	var p = window.open(u,n,'width='+w+',height='+h+',scrollbars='+s+',left='+l+',top='+t+',resizable');
	p.focus();
}

function showWaiting() {
  MM_showHideLayers('menu_main','','hide');
  MM_showHideLayers('breadcrumbs','','hide');
  MM_showHideLayers('three_col_container','','hide');
  MM_showHideLayers('menu_main_long','','show');
  MM_showHideLayers('waiting','','show');
}

function checkCheckBox(f){
if (f.acceptErrata.checked == false )
{
alert('Please confirm that you have read and agree\n to the information shown.');
return false;
}else
return true;
}

function doSubmit(formName,nextPage) {

	var formObject = MM_findObj(formName);

	if (formObject != null)
	{
		if (formObject.nextPage != null)
			formObject.nextPage.value = nextPage;

		formObject.submit();

		return false;
	}

	return true;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function spin(obj)
{
  var spinner = document.getElementById(obj);
  var spinner_content = document.getElementById(obj+"_body" );
  if ( spinner_content.style.visibility == 'visible' )
  {
    //spinner.innerHTML = 'open';
    spinner_content.style.visibility = 'hidden';
	spinner_content.style.display = 'none';
    spinner_content.style.height = '0px';
    spinner_content.style.margin = '0px';
  }
  else
  {
    //spinner.innerHTML = 'close';
    spinner_content.style.visibility = 'visible';
	spinner_content.style.display = 'block';
    spinner_content.style.height = 'auto';
    //spinner_content.style.margin = '5px 0px 20px 20px';
  }
}
function hoteDetails() {
	//alert ("This is hoteDetails")
	//window.location = "#top";
	window.scrollTo(0,0);
	MM_showHideLayers('resAccesCol','','show');
	MM_showHideLayers('cols_two_and_three','','hide','popBook','','hide','booking_tabs','','hide','booking_details_div','','hide','hotel_details_div','','hide','searchresults','','hide','breadcrumbs','','hide','extra_details_div_left_col','','hide');
}
function qGetElementById(id)
{
	var elements = document.getElementsByName(id);

	for (var i = 0; i < elements.length; i++)
	{
		if (elements[i].name == elements[i].id)
		    return elements[i];
	}

	return MM_findObj(id);
}

function qDumpObject(object)
{
	var debugWindow = window.open('','debug','scrollbars,status,resizable,location,width=900,height=500');

	debugWindow.document.writeln("<html><head><title>Quatro Debug</title></head>");
	debugWindow.document.writeln("<body><pre>");

	debugWindow.document.writeln(object);

	for (var property in object)
		debugWindow.document.writeln(property + " = " + object[property]);

	debugWindow.document.writeln("</pre></body></html>");
	debugWindow.document.close();
	debugWindow.focus();
}

function validateform(form){
	var message = "";
	var moveOn = 1;
	var title = form.title.value;
	var fnm = form.fnm.value;
	var snm = form.lnm.value;
	var add1 = form.address1.value;
	var add2 = form.address2.value;
	var city = form.city.value;
	var cty = form.county.value;
	var eml = form.uemail.value;
	var confeml = form.confirmemail.value;

	if(title == "")
	{
		message += "Please select a title\n";
		moveOn = 0;
	}

	if(fnm == "")
	{
		message += "Please supply your Forename\n";
		moveOn = 0;
	}

	if(snm == "")
	{
		message += "Please supply your Surname\n";
		moveOn = 0;
	}

	if(add1 == "")
	{
		message += "Please supply first line of your address\n";
		moveOn = 0;
	}

	if(add2 == "")
	{
		message += "Please supply second line of your address\n";
		moveOn = 0;
	}

	if(city == "")
	{
		message += "Please your town/city\n";
		moveOn = 0;
	}

	if(cty == "")
	{
		message += "Please enter your county\n";
		moveOn = 0;
	}

	if(eml == "")
	{
		message += "Please supply an email address\n";
		moveOn = 0;
	}
	else
	{
		if(eml != confeml)
		{
			message += "Email Address and Confirmation Email Address are not the same\n";
			moveOn = 0;
		}
	}

	if(moveOn == 0)
	{
		var msgHead = "Please check the following:\n\n";
		msgHead = msgHead + message;
		alert (msgHead);
		return false;
	}
	else
		{
			var newwindow;
			newwindow = window.open('','NewsletterPopUp','width=400,height=150');
			form.submit()
			document.location.href = "viewPage.vm?viewName=generalConfirmation";
			return true;
		}

}

var selected = false;
function changeSelect(select){
	if (!selected){
		var changeSelect = document.getElementById('lowCost');
		changeSelect.style.color = "#B53A59";

		selected = true;
	}else{
		var changeSelect = document.getElementById('lowCost');
		changeSelect.style.color = "#5b5b5b";
		selected = false;
	}
}

var accomSelected = false;
function changeAccomSelect(){

	if (!accomSelected){
		var changeSelect = document.getElementById('checkBoxThisAccom');
		changeSelect.style.color = "#B53A59";
		accomSelected = true;
	}else{
		var changeSelect = document.getElementById('checkBoxThisAccom');
		changeSelect.style.color = "#5b5b5b";
		accomSelected = false;
	}
}

function checkValueBoxAccom(){

		var checkBoxAccom = document.getElementById('checkBoxThisAccomCheck')
		if (checkBoxAccom.checked == true){
			accomSelected = true;
    		var changeSelect = document.getElementById('checkBoxThisAccom');
    		changeSelect.style.color = "#B53A59";

		}
}

var firstTime = true;

function checkValueBox(){
	var checkBoxCheck = document.getElementById('lowCostCheckBox');
	if (checkBoxCheck && checkBoxCheck.checked == true){
		selected = true;
		var changeSelect = document.getElementById('lowCost');
		changeSelect.style.color = "#B53A59";
	}
}

function checkFirstTime(){
	if (firstTime){
		var checkBoxCheck = document.getElementById('lowCostCheckBox');

		if (checkBoxCheck) {
    		checkBoxCheck.checked = true;
    		selected = true;
    		var changeSelect = document.getElementById('lowCost');
    		changeSelect.style.color = "#B53A59";
		}
	}
}

function newCarousel(number) {
	new Effect.SlideDown('loader'+number, {duration:0.3});
	sentTimer = setTimeout("setCarousel("+number+")", 400);
}

function setCarousel(number) {
	document.getElementById('loader'+number).style.display = 'none';
	document.getElementById('villaImagesCaroselHidden'+number).style.display = 'block';
	document.getElementById("horizontal_carousel" + number).style.display = 'block';
	hCarousel = new UI.Carousel("horizontal_carousel" + number);
}


function toggleGalleryButton(number) {
	document.getElementById('viewGalleryButton'+number).style.display = 'none';
	document.getElementById('closeGalleryButton'+number).style.display = 'block';
}

function toggleGalleryButtonClose(number) {
	document.getElementById("horizontal_carousel" + number).style.display = 'none';
	document.getElementById("villaImagesCaroselHidden" + number).style.display = 'none';
	document.getElementById('viewGalleryButton'+number).style.display = 'block';
	document.getElementById('closeGalleryButton'+number).style.display = 'none';
}
