 
<!--
Date.fromDDMMYYYY = function (s) {return (/^(\d\d?)\D(\d\d?)\D(\d{4})$/).test(s) ? new Date(RegExp.$3, RegExp.$2 - 1, RegExp.$1) : new Date (s)}



function getStartDate(id){
	var start = Date.fromDDMMYYYY (document.getElementById(id).value);
	 
	 mYear = start.getYear();
	 mMonth = start.getMonth();
	 mDay  = start.getDate();
	 return mYear+','+mMonth+','+mDay;
}

function sendReg()
{  //var sendToEmail = decodeEmail(encodedEmail);
     if(document.form1.clientName.value==''){alert('Please add your name');return false;}
	//check for an address value
	if(document.form1.telAreaCode.value==''){alert('Please add your Country Code');return false;}
	if(document.form1.Telephone.value==''){alert('Please add your Telephone Number');return false;}
	if(document.form1.email.value==''){alert('Please add your email');return false;} 
	if(document.form1.Mobnumber.value==''){alert('Please add your Mobile Number');return false;}
	
	var re = /^\w+([\.]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
 	if(!(re.test(document.form1.email.value))){alert('Please enter a valid email');return false;}
    //check for notes
	if(document.form1.query.value==''){alert('Please enter a Message');return false;}
  
    document.form1.submit();
  //alert( decodeEmail(encodedEmail));
}
var submitcount=0;
  

 function fn_formCheck() {
	 var submitcount
				 if (submitcount == 0)
				  {
				  submitcount++;
				  return true;
				  }
			   else 
				  {document.form[0].submit();
				  alert("This form has already been submitted.  Thanks!");
				  return false;
				  }
           
		   return false;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



<!-- Begin
function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The email address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}



function validationBooking()
{  //var sendToEmail = decodeEmail(encodedEmail);
    var err = new Array(); 
 //alert(document.getElementById('Title').selectedIndex);
   
   if(document.getElementById('Title').selectedIndex=='0'){err.push('Please select title');}
    if(document.getElementById('Number of people').selectedIndex=='0'){err.push('Please select Number of people in group');}
	//check for an address value
	if(document.getElementById('FirstName of Leader').value==''){err.push('Please add First Name of Leader');}
	if(document.getElementById('SurnName of Leader').value==''){err.push('Please add Surnname of Leader');}
	if(document.getElementById('Address1').value==''){err.push('Please add your Address');}
	if(document.getElementById('email').value==''){err.push('Please add your email');} 
	if(document.getElementById('Home Tel').value==''){err.push('Please add your telephone Number');}
	//alert(getCheckedValue(document.forms['formmail'].elements['Payment Method']));
	if(getCheckedValue(document.forms['formmail'].elements['Payment Method'])==''){err.push('Please select your Payment Method');}
	var re = /^\w+([\.]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
 	if(!(emailCheck(document.getElementById('email').value))){err.push('Please enter a valid email');}
	if(document.getElementById('Declaration').checked!=true){err.push('Please tick the Declaration box');}
	
	
    //check for notes
	//if(document.form1.query.value==''){err.push('Please enter a Message');return false;}
  //alert(err.length);
  if (err.length > 0) {
		alert(err.join('\n'));
		return false;
	}
   fn_formCheck()
  //alert( decodeEmail(encodedEmail));
}

function emailcheck(email,ref)
{  //var sendToEmail = decodeEmail(encodedEmail);
    var err = new Array(); 
 //alert(document.getElementById('Title').selectedIndex);
   var email = email;
  
	if(email==''){err.push('Please add your email');} 
	
	//if(document.getElementById('Declaration').checked!=true){err.push('Please tick the Declaration box');}
	
	var re = /^\w+([\.]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
 	if(!(re.test(email))){err.push('Please enter a valid email');}
    //check for notes
	//if(document.form1.query.value==''){err.push('Please enter a Message');return false;}
  
  if (err.length > 0) {
		alert(err.join('\n'));
		return false;
	}
	window.location.href='../processing/cancelCheck.asp?email='+email+'&ref='+ref;
   //fn_formCheck()
  //alert( decodeEmail(encodedEmail));
}
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;
   
   }
function setPeopleBooking(hr){
	var peoNu = document.getElementById('peopleHideNum').value;
	//alert(peoNu);
		if (peoNu!=''){
			if(IsNumeric(document.getElementById('peopleHideNum').value)){
				hr+='&people='+peoNu;
			window.location.href=hr;
			}else{
				alert('Please input a numeric for people');
				}
		}else{
		 	alert('Please input a numeric for people');
		}
		
		return false;
	}
function validationReserving()
{  //var sendToEmail = decodeEmail(encodedEmail);
    var err = new Array(); 
 //alert(document.getElementById('Title').selectedIndex);
   
   if(document.getElementById('Title').selectedIndex=='0'){err.push('Please select title');}
    if(document.getElementById('Number of people').selectedIndex=='0'){err.push('Please select Number of people in group');}
	//check for an address value
	if(document.getElementById('FirstName of Leader').value==''){err.push('Please add First Name of Leader');}
	if(document.getElementById('SurnName of Leader').value==''){err.push('Please add Surnname of Leader');}
	//if(document.getElementById('Address').value==''){err.push('Please add your Address');}
	if(document.getElementById('email').value==''){err.push('Please add your email');} 
	if(document.getElementById('Home Tel').value==''){err.push('Please add your telephone Number');}
	//if(document.getElementById('Declaration').checked!=true){err.push('Please tick the Declaration box');}
	
	var re = /^\w+([\.]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
 	if(!(re.test(document.getElementById('email').value))){err.push('Please enter a valid email');}
    //check for notes
	//if(document.form1.query.value==''){err.push('Please enter a Message');return false;}
  
  if (err.length > 0) {
		alert(err.join('\n'));
		return false;
	}
   fn_formCheck()
  //alert( decodeEmail(encodedEmail));
}



function fn_quickFormReset(){
	
	

	//currdate = new Date (document.form1.newStartPeriod.value);
	//var start = Date.fromDDMMYYYY (document.rightMenuQuickSearch.startDate.value);
	//var end = Date.fromDDMMYYYY (document.rightMenuQuickSearch.endDate.value);
	
	//endDate = new Date(document.form1.newEndPeriod.value);
	//alert(start);
	document.rightMenuQuickSearch.select.selectedIndex='0';
	document.rightMenuQuickSearch.intSingleBeds.selectedIndex='0';
		document.rightMenuQuickSearch.intSleepsPeople.selectedIndex='0';
		document.rightMenuQuickSearch.intPropertyThemeID.selectedIndex='0';
	document.rightMenuQuickSearch.startDate.value='';
	document.rightMenuQuickSearch.endDate.value='';
}

function fn_saleFormReset(){
	
	

	
	document.propSearch.intAreaID.selectedIndex='0';
	document.propSearch.intBeds.selectedIndex='0';
		document.propSearch.intLocationID.selectedIndex='0';
		document.propSearch.intPropertyTypeID.selectedIndex='0';
	document.propSearch.intMaxPrice.value='0';
	document.propSearch.intMinPrice.value='0';
	
		propSearch.intOffer.checked =false;
		propSearch.intResale.checked=false;
	propSearch.intCompleted.checked =false;
		propSearch.intSoon.checked=false;
	
}
function checkEnter(e){ //e is event object passed from function invocation literal character code will be stored in this variable
var characterCode

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
document.forms[0].submit() //submit the form
return false
}
else{
return true
}

}
function gotoDetails(id){
	// alert(id);
	if(id==''){
		window.document.rightMenuNameSearch.submit();}
	else{	
	window.location.href='cyprusVillaRental.asp?'+id;
	}
	
	}
	
	function gotoDetailsE(id){
	// alert(id);
	var characterCode,e
	e=='event';

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
if(id==''){
		window.document.rightMenuNameSearch.submit();}
	else{	
	window.location.href='cyprusVillaRental.asp?PropertyID='+id;
	}return false
}
else{
return false;
}

	
	
	}
	
	
	
	function formSubmit(){
	
	now=new Date();
	
	var y =now.getUTCFullYear()+2; 
	
	var maxDate = Date.fromDDMMYYYY ('01/01/'+y);

	//currdate = new Date (document.form1.newStartPeriod.value);
	var start = Date.fromDDMMYYYY (document.form1.startDate1.value);
	var end = Date.fromDDMMYYYY (document.form1.endDate1.value);
	
	//endDate = new Date(document.form1.newEndPeriod.value);
	//alert(start);
	
	if (start >=end){
			
			alert('The end date must later than start date');
			return false;
			}
		else if (start>=maxDate)	{
			alert('Please input start date before 01/01/'+y );
			return false;
			}
		else if (end>=maxDate)	{
			alert('Please input end date before 01/01/'+y );
			return false;
			}
		else if ((end-start)/86400000>365)	{
			alert('Max stay is 365 days' );
			return false;
			}
			
		else{	
			 document.form1.submit();
		}
	
}
	
	function fn_quickFormSubmit(){
	now=new Date();
	
	var y =now.getUTCFullYear()+2; 
	
	var maxDate = Date.fromDDMMYYYY ('01/01/'+y);
	//currdate = new Date (document.form1.newStartPeriod.value);
	var start = Date.fromDDMMYYYY (document.rightMenuQuickSearch.startDate.value);
	var end = Date.fromDDMMYYYY (document.rightMenuQuickSearch.endDate.value);
	
	//endDate = new Date(document.form1.newEndPeriod.value);
	
	
	
	//alert();
	if (start!=''&&end!=''){
		if (start >=end){
			
			alert('The end date must later than start date');
			return false;
			}
		else if (start>=maxDate)	{
			alert('Please input start date before 01/01/'+y );
			return false;
			}
		else if (end>=maxDate)	{
			alert('Please input end date before 01/01/'+y );
			return false;
			}
		else if ((end-start)/86400000>365)	{
			alert('Max stay is 365 days' );
			return false;
			}
			
		else{	
			 document.rightMenuQuickSearch.submit();
		}
	}else if(start=='' || end==''){
		
		alert('please input all date field');
		return false;
		}
	
	  //alert(document.getElementById('select').value);
}
function fn_aFormSubmit(){
	
	now=new Date();
	
	
	var y =now.getUTCFullYear()+2; 
	
	var maxDate = Date.fromDDMMYYYY ('01/01/'+y);

	//currdate = new Date (document.form1.newStartPeriod.value);
	var start = Date.fromDDMMYYYY (document.aform1.startDateB.value);
	var end = Date.fromDDMMYYYY (document.aform1.endDateB.value);
	var peoNu = document.getElementById('people').value;
	//alert(peoNu);
		if (peoNu!=''){
			if(IsNumeric(document.getElementById('people').value)){
					if(start=='NaN'||end=='NaN'){
		
		alert('please input all date field');
		
		
		  return false;
		}
		
	if (start!=''&&end!=''){
		if (start >=end){
			
			alert('The end date must later than start date');
			return false;
			}
		else if (start>=maxDate)	{
			alert('Please input start date before 01/01/'+y );
			return false;
			}
		else if (end>=maxDate)	{
			alert('Please input end date before 01/01/'+y );
			return false;
			}
			else if ((end-start)/86400000>365)	{
			alert('Max stay is 365 days' );
			return false;
			}
			
		else{	
			 document.aform1.submit();
		}
	}
			}else{
				alert('Please input a numeric for people');
				return false;
				}
		}else{
		 	alert('Please input a numeric for people');
			return false;
		}
		
		
	//endDate = new Date(document.form1.newEndPeriod.value);
	//alert(start); 

	
   
}
function fnQuotationSubmit(act){
	
	document.form1.bookAction.value=act;
	var bAmount = document.getElementById("bookingPrice");
		document.form1.totalAmount.value=parseFloat(bAmount.innerHTML);
    
	document.form1.submit();
	
	
	}
	
	
	function getElementNameSelect2(amount,val,id){

var eCost = document.getElementById("cost");
var bP    = document.getElementById("bookingPrice");
var toHtml = document.getElementById(id);
var bP1   = document.getElementById("bookingPrice1");
var bP2   = document.getElementById("bookingPrice2");


	tmpCost = parseFloat(parseFloat(eCost.innerHTML)-parseFloat(toHtml.innerHTML) + val*parseFloat(amount));
	tmpBp1 = (parseFloat(parseFloat(bP1.innerHTML) - parseFloat(toHtml.innerHTML)*0.3+ val*parseFloat(amount)*0.3)).toFixed(2);
	tmpCost = tmpCost.toFixed(2); 
	tmpAc = parseFloat(parseFloat(val)*parseFloat(amount)).toFixed(2);
	
    eCost.innerHTML = tmpCost;

    bP1.innerHTML =tmpBp1;
bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) - parseFloat(toHtml.innerHTML)*0.7+ val*parseFloat(amount)*0.7)).toFixed(2);

if ((parseFloat(parseFloat(bP.innerHTML)-parseFloat(toHtml.innerHTML) + val*parseFloat(amount))).toFixed(2)!='NaN'){
bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) -parseFloat(toHtml.innerHTML)+ val*parseFloat(amount))).toFixed(2);
}



toHtml.innerHTML = tmpAc;
document.getElementById('1I').value=tmpAc;
//alert(document.getElementById('1I').value);
}
	
		function getElementNameSelect(amount,val,id){

var eCost = document.getElementById("cost");
var bP    = document.getElementById("bookingPrice");
var toHtml = document.getElementById(id);


	tmpCost = parseFloat(parseFloat(eCost.innerHTML)-parseFloat(toHtml.innerHTML) + val*parseFloat(amount));
	
	tmpCost = tmpCost.toFixed(2); 
	tmpAc = parseFloat(parseFloat(val)*parseFloat(amount)).toFixed(2);
	
    eCost.innerHTML = tmpCost;


if ((parseFloat(parseFloat(bP.innerHTML)-parseFloat(toHtml.innerHTML) + val*parseFloat(amount))).toFixed(2)!='NaN'){
bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) -parseFloat(toHtml.innerHTML)+ val*parseFloat(amount))).toFixed(2);}



toHtml.innerHTML = tmpAc;
document.getElementById('1I').value=tmpAc;
//alert(document.getElementById('1I').value);
}
	
	function getElementName2(amount,val,id){
//var ele = document.getElementById("amount");
//var ec = document.getElementsByName("amount");

var eCost = document.getElementById("cost");
var bP    = document.getElementById("bookingPrice");
var bP1   = document.getElementById("bookingPrice1");
var bP2   = document.getElementById("bookingPrice2");
var toHtml = document.getElementById(id);
//ele.innerHTML = amount;
//alert(amount);
if(val==true){
	tmpCost = parseFloat(parseFloat(eCost.innerHTML) + parseFloat(amount));
	tmpCost = tmpCost.toFixed(2); 
eCost.innerHTML = tmpCost;
if ((parseFloat(parseFloat(bP.innerHTML) + parseFloat(amount))).toFixed(2)!='NaN'){
bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) + parseFloat(amount))).toFixed(2);}
bP1.innerHTML = (parseFloat(parseFloat(bP1.innerHTML) + parseFloat(amount)*0.3)).toFixed(2);
bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) + parseFloat(amount)*0.7)).toFixed(2);
setVisibility(toHtml,"visible");


}else{
	//alert(parseFloat(amount));
eCost.innerHTML = (parseFloat(parseFloat(eCost.innerHTML) - parseFloat(amount))).toFixed(2);
if ((parseFloat(parseFloat(bP.innerHTML) + parseFloat(amount))).toFixed(2)!='NaN'){

bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) - parseFloat(amount))).toFixed(2);}
bP1.innerHTML =(parseFloat(parseFloat(bP1.innerHTML) - parseFloat(amount)*0.3)).toFixed(2);
bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) - parseFloat(amount)*0.7)).toFixed(2);
setVisibility(toHtml, "hidden");
}
//alert("" + ec.length);
//alert(ele.innerHTML);
}


function getLCDiscount(lcDiscount,minPrice,amount,val,id){
//var ele = document.getElementById("amount");
//var ec = document.getElementsByName("amount");
var ele = document.getElementById("hiddenActive");

var eCost = document.getElementById("cost");
var bP    = document.getElementById("bookingPrice");
var toHtml = document.getElementById(id);

if(val==true){				tmpCost = parseFloat(parseFloat(eCost.innerHTML) - parseFloat(lcDiscount));
								tmpCost = tmpCost.toFixed(2); 
							eCost.innerHTML = tmpCost;
							if ((parseFloat(parseFloat(bP.innerHTML) - parseFloat(lcDiscount))).toFixed(2)!='NaN'){
							bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) - parseFloat(lcDiscount))).toFixed(2);}
							setVisibility(toHtml,"visible");
	                         ele.value = 'Active';
							  

}else{
	     eCost.innerHTML = (parseFloat(parseFloat(eCost.innerHTML) + parseFloat(lcDiscount))).toFixed(2);
			if ((parseFloat(parseFloat(bP.innerHTML) + parseFloat(lcDiscount))).toFixed(2)!='NaN'){
				
			bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) + parseFloat(lcDiscount))).toFixed(2);}
		
	setVisibility(toHtml, "hidden");
ele.value = 'hidden';
}
//alert("" + ec.length);
//alert(ele.innerHTML);
}
	
function getLCDiscount2(lcDiscount,minPrice,amount,val,id){
//var ele = document.getElementById("amount");
//var ec = document.getElementsByName("amount");

var eCost = document.getElementById("cost");
var bP    = document.getElementById("bookingPrice");
var bP1   = document.getElementById("bookingPrice1");
var bP2   = document.getElementById("bookingPrice2");
var ele = document.getElementById("hiddenActive");
var toHtml = document.getElementById(id);
if(val==true){			
tmpCost = parseFloat(parseFloat(eCost.innerHTML) - parseFloat(lcDiscount));
								tmpCost = tmpCost.toFixed(2); 
							eCost.innerHTML = tmpCost;
							if ((parseFloat(parseFloat(bP1.innerHTML) - parseFloat(lcDiscount))).toFixed(2)!='NaN'){
							//bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) - parseFloat(lcDiscount))).toFixed(2);
							//alert(bP1.innerHTML );
							bP1.innerHTML = (parseFloat(parseFloat(bP1.innerHTML) - parseFloat(lcDiscount)*0.3)).toFixed(2);
                            bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) - parseFloat(lcDiscount)*0.7)).toFixed(2);}
							 setVisibility(toHtml,"visible");
							 ele.value = 'Active';
	

}else{
	     eCost.innerHTML = (parseFloat(parseFloat(eCost.innerHTML) + parseFloat(lcDiscount))).toFixed(2);
			if ((parseFloat(parseFloat(bP1.innerHTML) + parseFloat(lcDiscount))).toFixed(2)!='NaN'){
				
			//bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) + parseFloat(lcDiscount))).toFixed(2);
			bP1.innerHTML =(parseFloat(parseFloat(bP1.innerHTML) + parseFloat(lcDiscount)*0.3)).toFixed(2);
            bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) + parseFloat(lcDiscount)*0.7)).toFixed(2);
			
}
		setVisibility(toHtml, "hidden");
		 ele.value = 'hidden';
	
}
//alert("" + ec.length);
//alert(ele.innerHTML);
}
	
	function getElementName(amount,val,id){
//var ele = document.getElementById("amount");
//var ec = document.getElementsByName("amount");

var eCost = document.getElementById("cost");
var bP    = document.getElementById("bookingPrice");
//var bP1   = document.getElementById("bookingPrice1");
//var bP2   = document.getElementById("bookingPrice2");
var toHtml = document.getElementById(id);
//ele.innerHTML = amount;
//alert(amount);
if(val==true){
	tmpCost = parseFloat(parseFloat(eCost.innerHTML) + parseFloat(amount));
	tmpCost = tmpCost.toFixed(2); 
eCost.innerHTML = tmpCost;
if ((parseFloat(parseFloat(bP.innerHTML) + parseFloat(amount))).toFixed(2)!='NaN'){
bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) + parseFloat(amount))).toFixed(2);}
//bP1.innerHTML = parseFloat(parseFloat(bP1.innerHTML) + parseFloat(amount));
//bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) + parseFloat(amount))).toFixed(2);
setVisibility(toHtml,"visible");


}else{
	//alert(parseFloat(amount));
eCost.innerHTML = (parseFloat(parseFloat(eCost.innerHTML) - parseFloat(amount))).toFixed(2);
if ((parseFloat(parseFloat(bP.innerHTML) + parseFloat(amount))).toFixed(2)!='NaN'){

bP.innerHTML = (parseFloat(parseFloat(bP.innerHTML) - parseFloat(amount))).toFixed(2);}
//bP1.innerHTML =parseFloat(parseFloat(bP1.innerHTML) - parseFloat(amount));
//bP2.innerHTML = (parseFloat(parseFloat(bP2.innerHTML) - parseFloat(amount))).toFixed(2);
setVisibility(toHtml, "hidden");
}
//alert("" + ec.length);
//alert(ele.innerHTML);
}



function addAcAmount(){
var ac = document.getElementById("acAmount");

var eCost = document.getElementById("cost");
var bAmount = document.getElementById("bookingPrice");
var amount = ac.innerHTML;
//ele.innerHTML = amount;


eCost.innerHTML = parseFloat(eCost.innerHTML) + parseFloat(amount);
bAmount.innerHTML = parseFloat(bAmount.innerHTML) + parseFloat(amount);



//alert("" + ec.length);
//alert(ac.innerHTML);
}

function validateForm(obj){
	if(document.form1.clientName.value==''){document.form1.clientName.focus();document.form1.clientName.select();document.form1.clientNameError.value='add your name';return false}else{document.form1.clientNameError.value=''}
	if(document.form1.telephone.value==''){document.form1.telephone.focus();document.form1.telephone.select();document.form1.telephoneError.value='add your phone number';return false}else{document.form1.telephoneError.value=''}	
}
function openMap(obj){ 
  window.open(obj,'Map','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=780,height=400');
}


function fn_goToPage(pageNo){
	document.searchForm.Page.value = pageNo;
	document.searchForm.isFirstSearch.value = 'no';
	document.searchForm.submit();
}
function fn_goToPage1(pageNo){


	document.searchForm.intPage.value = pageNo;
	
	document.searchForm.submit();
}

function getElementById_s(id){
var obj = null;
if(document.getElementById){
/* Prefer the widely supported W3C DOM method, if
available:-
*/
obj = document.getElementById(id);
}else if(document.all){
/* Branch to use document.all on document.all only
browsers. Requires that IDs are unique to the page
and do not coincide with NAME attributes on other
elements:-
*/
obj = document.all[id];
}
/* If no appropriate element retrieval mechanism exists on
this browser this function always returns null:-
*/
return obj;
}
  function fn_changeSmallButton(imageID){
  
    var imageCat = ["bathroom","bedroom","diningRoom","exterior","garden","lounge","kitchen","parking"]
	
	
	for (i = 0 ;i<= 7;i++){
           for (j =1 ;j<=10 ;j++){
			  if (document.getElementById(imageCat[i]+j)){
		     	document.getElementById(imageCat[i]+j).src='../images/generic/smallButtonGray.gif'; 
                     }    
				//alert(imageCat[i]+j);
				}
			
		}
	
    
	document.getElementById(imageID).src='../images/generic/smallButtonGreen.gif';
	
 
  }  
function bedsSearch(imageID,no){
	
  var imageCat = ["bed","beds","bedlet","bedslet"]
	//alert(imageID);
	
	for (i = 0 ;i<= 3;i++){
           for (j =1 ;j<=4 ;j++){
			  if (getElementById_s(j+imageCat[i])){
		     	getElementById_s(j+imageCat[i]).src='../images/Frog88_bed_green.jpg'; 
                     }    
				//alert(imageCat[i]+j);
				}
			
		}
	
    
	getElementById_s(imageID).src='../images/Frog88_bed_pink.jpg';
	document.saleSearchForm.beds.value=no;
	document.letSearchForm.beds.value="";
	//document.saleSearchForm.submit();
	
	}
function lbedsSearch(imageID,no){
	
var imageCat = ["bed","beds","bedlet","bedslet"]
	
	
	for (i = 0 ;i<= 3;i++){
           for (j =1 ;j<=4 ;j++){
			  if (document.getElementById(j+imageCat[i])){
		     	document.getElementById(j+imageCat[i]).src='../images/Frog88_bed_green.jpg'; 
                     }    
				//alert(imageCat[i]+j);
				}
			
		}
	
    
	document.getElementById(imageID).src='../images/Frog88_bed_pink.jpg';
	document.letSearchForm.beds.value=no;
	document.saleSearchForm.beds.value="";
	//alert(document.letSearchForm.beds.value);
	//document.saleSearchForm.submit();
	
	}


function objCalendar(date, tableId, dateId, monthId){
	var me = this;
	var calendar = document.getElementById(tableId);
	var day = document.getElementById(dateId);
	var month = document.getElementById(monthId);

	calendar.isCalendar = true;

	me.date = new Date();
	me.date.setMonth(month.value);
	me.date.setDate(day.value);

	me.onClick = null;
	me.minDate = null;
	me.locked = false;

	initTable();

	function createCell(className, text, onClick){
		var cell = createElement("td");
		cell.className = className;
		cell.innerHTML = text;
		cell.isCalendar = true;

		if (isSet(onClick)){
			addEvent(cell, "click", function(){
				if (me.locked){
					return;
				}
				var date = new Date( fixMozYear(me.date.getYear()), me.date.getMonth(), text);
				if (isSet(me.minDate)){
					if (me.minDate > date){
						return;
					}
				}
				me.date = date;
				onClick(text);
			});
		}
		return cell;
	}

	function createDivCell(className, text){
		var div = createElement("div");
		div.className = className;
		div.style.textAlign="center";
		div.style.width="100%";
		div.style.height="100%";
		div.innerHTML = text;

		var cell = createElement("td");
		cell.isCalendar = true;
		appendChild(cell, div);

		return cell;
	
	}

	function incDate(date, num){
		return new Date( fixMozYear(date.getYear()), date.getMonth(), date.getDate() + num);
	}

	function initDates(table, date, onClick){
		//first off clear any date rows in the table
		while (table.rows.length > 0){
			table.deleteRow(0);
		}

		//create date object to base dates on, starting from the first off the month passed in
		var thisMonth = new Date( fixMozYear(date.getYear()) , date.getMonth(), 1);

		var cells = new Array();
		cells[0] = createCell("title_click", "&lt;");
		cells[1] = createDivCell("title", months[me.date.getMonth()] + "&nbsp;" + fixMozYear(me.date.getYear()));
		cells[2] = createCell("title_click", "&gt;");
		var monthTitle = cells[1];

		addEvent(cells[0], "click", function(){changeMonth(-1, cells[1])});
		addEvent(cells[2], "click", function(){changeMonth(1, cells[1])});

		addRow(calendar,cells);

		// loop to add rows
		for (var row=1; row < 8; row++){
			// init cells array
			cells = new Array();
			// loop to add each cell
			for (var column=0; column < 7; column++){
				// add column headers
				if (row == 1){	
					cells[column] = createCell("title", days[column]);
				} else {
					// keep adding blank cells till the first day is reached in the days array
					var className = (date.getDate() == thisMonth.getDate() ? "selected" : "data");
					if (isSet(me.minDate)){
						if (me.minDate > thisMonth){
							className = "not_selectable";
						}
					}

					if (thisMonth.getDate() == 1 && thisMonth.getMonth() == date.getMonth()){
						if (thisMonth.getDay() == column){
							cells[column] = createCell(className, thisMonth.getDate(), onClick);			
							thisMonth = incDate(thisMonth, 1);
						} else {
							cells[column] = createCell("no_data", "");		
						}
					// keep adding nunbered cells till end of month
					} else {
						if (thisMonth.getMonth() == date.getMonth()){
							cells[column] = createCell(className, thisMonth.getDate(), onClick);
							thisMonth = incDate(thisMonth, 1);
						} else {
							cells[column] = createCell("no_data", "");									
						}
					}
				}
			}

			if (row > 3 && cells[0].innerHTML == "") {
				// the row is empty - don't bother appending
				continue;
			}

			addRow(calendar,cells);
		}

		monthTitle.colSpan = 5;
		monthTitle.style.textAlign = "center";

//		document.write ( document.body.innerHTML );
	}

	function initTable(){
		initDates(calendar, me.date, function(day){
			date = new Date( fixMozYear(me.date.getYear()), me.date.getMonth(), day);

			if (isSet(me.onClick)){
				me.onClick(date, true);
			}
			initTable();
		});		
	}

	me.setDate = function(date){
		me.date = date;
		initTable();
	}

	function changeMonth(inc, label){
		
		//check if trying to set before today
		if (me.date.getMonth() == today.getMonth() && inc < 0){
			return;
		}

		//check if trying to after a year from now
		var yearDiff = me.date.getYear() - today.getYear();
		var month = yearDiff == 0 ? me.date.getMonth() : (me.date.getMonth() + (yearDiff*12));
		if (month - today.getMonth() == 11 && inc > 0){
			return;
		}

		//check if trying to set before min date
		if (me.date.getMonth() == me.minDate.getMonth() && inc < 0){
			return;
		}

		me.date.setMonth(me.date.getMonth() + inc);
		initTable();

		if (isSet(me.onClick)){
			me.onClick(me.date, false);
		}
	}
}

//** freetext or area id logic **/
// triggered by clicking either the freetext field or the area dropdown
// sets the appropriate radio button to checked
function setAreaType(obj) {
	if (obj.name == "Area") {
		document.getElementById("specific").value = "";
	}else{
		document.getElementById("areaDropDown").value = "";
	}
}

/** number of rooms to show logic  **/
// triggered by changing the number of rooms
// will show the normal how many people dropdown for 1 room or individual room dropdowns where its more than 1
function showRooms(obj) {
	var numRooms = obj.value;

	var               roomCopy = document.getElementById('tooManyRooms');
	var              partyCopy = document.getElementById('bigParty');
	var  selfCateringPartyCopy = document.getElementById('selfCateringParty');

	var howManyPeople = document.getElementById('howManyPeople');

	var numberOfPeople = document.getElementById('numberOfPeople');

	if (numRooms == 1) {

		setDisplay(roomCopy,      'none');
		setDisplay(howManyPeople, 'block');

		for (var i = 1; i < 4; i++) {
			setDisplay(document.getElementById('room' + i), 'none');
		}

		if (isSet(numberOfPeople.options) && numberOfPeople.options.length == 20) {
			if (numberOfPeople.selectedIndex == 19) {
				setDisplay(selfCateringPartyCopy, 'block');
			} else {
				setDisplay(selfCateringPartyCopy, 'none');
			}
		} else {
			setDisplay(selfCateringPartyCopy, 'none');

			if (((numberOfPeople.value)*1) > 2) {
				setDisplay(partyCopy, 'block');
			} else {
				setDisplay(partyCopy, 'none');
			}
		}

	} else if(numRooms == '4+') {
		setDisplay(roomCopy,      'block');
		setDisplay(partyCopy,     'none');
		setDisplay(howManyPeople, 'none');
		for (var i=1; i<4; i++) {
			setDisplay(document.getElementById('room' + i), 'none');
		}
	} else {
		setDisplay(roomCopy,      'none');
		setDisplay(partyCopy,     'none');
		setDisplay(howManyPeople, 'none');
		for (var i=1; i<4; i++) {
			setDisplay(document.getElementById('room' + i), (i <= numRooms ? 'block' : 'none'));
		}
	}
}

/** date dropdown logic **/
// triggered by changing a month dropdown
// 1) ensures the check out month isn't before the check in
// 2) fixes any day issues where the number of days is now less than whats shown
function validateMonth() {
	var checkIn = document.getElementById("checkInMonth");
	var checkOut = document.getElementById("checkOutMonth");

	if ((checkOut.value*1) < (checkIn.value*1)) {
		checkOut.value = checkIn.value;
	}

	showCorrectDays(document.getElementById("checkInDate"), daysInMonth(checkIn.value));
	showCorrectDays(document.getElementById("checkOutDate"), daysInMonth(checkOut.value));

	validateDate();
}

// triggered by changing a date dropdown (also called by validateMonth)
// 1) tests the check in date against the current date to ensure its not in the past
// 2) ensures the check out date isn't before the check in when they are on the same month
// 3) rejigs the calendar to display the correct month and highlighted date
// 4) sets the min date for the check out calendar
function validateDate() {
	var checkIn = document.getElementById("checkInDate");
	var checkOut = document.getElementById("checkOutDate");

	var checkInMonth = document.getElementById("checkInMonth");
	var checkOutMonth = document.getElementById("checkOutMonth");

	var date = new Date();
	date.setDate(checkIn.value);
	date.setMonth(checkInMonth.value);
	if (date < today) {
		date = today;
		checkIn.value = date.getDate();
		checkInMonth.value = date.getMonth();
	}

	if ((checkInMonth.value*1) == (checkOutMonth.value*1)) {
		if ((checkOut.value*1) <= (checkIn.value*1)) {

			date.setDate(date.getDate() +1);

			showCorrectDays(checkOut, daysInMonth(date.getMonth()));

			checkOutMonth.value = (date.getYear() > today.getYear() ? (date.getMonth()+12) : date.getMonth());
			checkOut.value = date.getDate();

			date.setDate( date.getDate() -1 );
		}
	}

	checkOutCalendar.minDate = date;

	redoCalendar(checkInCalendar, checkIn.value, checkInMonth.value);
	redoCalendar(checkOutCalendar, checkOut.value, checkOutMonth.value);
}


// util function to return number of days in a month
function daysInMonth(month) {
	var date = new Date();

	date.setDate(1);
	date.setMonth(month);
	var month = date.getMonth();
	var day = date.getDate();

	if (month < date.getMonth()) {
		while (month < date.getMonth()) {
			date.setDate(day--);
		}
	}else{
		date.setMonth(month+1);
		date.setDate(0);
	}
	return date.getDate();
}

// util function to limit the number of options in the date dropdown
function showCorrectDays(obj, numDays) {

	var indx = obj.options.selectedIndex;
	while (obj.options.length > 0) {
		removeElement(obj.options[0]);
	}

	for (var i=1; i<=numDays; i++) {
		var option = createElement("option");
		option.value = i;
		option.innerHTML = i;
		appendChild(obj, option)
	}

	obj.options.selectedIndex = (indx < obj.options.length ? indx : 0);
}

/** calendar logic **/
// util function to redraw a calendar
function redoCalendar(calendar, day, month) {
	var date = new Date();
	date.setDate(day);
	date.setMonth(month);
	calendar.setDate(date);
}

// triggered by clicking a date on the check in calendar
// 1) updates the check in date dropdown with new value
// 2) hides the calendar again
// 4) changes the check out date if its before the check in
function setCheckInDate(date, hide) {
	var checkIn = document.getElementById("checkInDate");
	var checkOut = document.getElementById("checkOutDate");
	var checkInMonth = document.getElementById("checkInMonth");
	checkIn.value = date.getDate();

	var yearDiff = date.getYear() - today.getYear();
	var month = yearDiff == 0 ? date.getMonth() : (date.getMonth() + (yearDiff*12)) ;

	checkInMonth.value = month;

	checkOutCalendar.minDate = date;
	validateMonth();

	if (checkOutCalendar.date < checkInCalendar.date) {
		checkOutCalendar.setDate( date );
	}else{
		checkOutCalendar.setDate(checkOutCalendar.date);
	}


	if (hide) {
		showHide("checkInPicker");
		switchVisibility("checkOutDate", "checkOutMonth");
		setVisibility(document.getElementById("numberOfRooms"),  "visible");
		setVisibility(document.getElementById("numberOfPeople"), "visible");
	} else {
		//ie fix to ensure the check out date stays hidden after showing the correct number of days
		setVisibility(checkOut, "hidden");
	}

}

// triggered by clicking a date on the check out calendar
// 1) updates the check out date dropdown with new value
// 2) hides the calendar again
function setCheckOutDate(date, hide) {
	var checkOut = document.getElementById("checkOutDate");
	var checkOutMonth = document.getElementById("checkOutMonth");
	checkOut.value = date.getDate();

	var yearDiff = date.getYear() - today.getYear();
	var month = yearDiff == 0 ? date.getMonth() : (date.getMonth() + (yearDiff*12)) ;
	checkOutMonth.value = month;
	validateMonth();

	if (hide) {
		showHide("checkOutPicker");
		setVisibility(document.getElementById("numberOfRooms"),  "visible");
		setVisibility(document.getElementById("numberOfPeople"), "visible");
	}
}

// triggered by page load
// 1) initializes the calendar displays
function initCalendars() {
	var startDate = new Date();

	var checkInAttachPoint  = document.getElementById("checkInPicker");
	var checkInTable = document.createElement("table");

	checkInTable.id  = "checkInCalendar";
	checkInTable.className = "dynamicCalendar";

	checkInAttachPoint.appendChild(checkInTable);

	var checkOutAttachPoint = document.getElementById("checkOutPicker");
	var checkOutTable = document.createElement("table");

	checkOutTable.id  = "checkOutCalendar";
	checkOutTable.className = "dynamicCalendar"

	checkOutAttachPoint.appendChild(checkOutTable);

	checkInCalendar = new objCalendar(startDate, "checkInCalendar", "checkInDate", "checkInMonth");
	checkInCalendar.onClick = setCheckInDate;
	checkInCalendar.minDate = today;

	checkOutCalendar = new objCalendar(startDate, "checkOutCalendar", "checkOutDate", "checkOutMonth");
	checkOutCalendar.onClick = setCheckOutDate;

	validateDate();

	var numberOfRooms = document.getElementById("numberOfRooms");
	if (isSet(numberOfRooms)) {
		showRooms(numberOfRooms);
	}

	addEvent(document, "click", function(e) {
		var src = ((ie) ? e.srcElement : e.target);

		if (src.isCalendar) {
			return;
		}

		if (src.id != "checkInIcon") {
			setDisplay(document.getElementById("checkInPicker"), "none");
		}

		if (src.id != "checkOutIcon") {
			setDisplay(document.getElementById("checkOutPicker"), "none");
		}

		if (src.id != "checkInIcon" && src.id != "checkOutIcon") {
			setVisibility(document.getElementById("checkOutDate"), "visible");
			setVisibility(document.getElementById("checkOutMonth"), "visible");
			setVisibility(document.getElementById("numberOfRooms"), "visible");
			setVisibility(document.getElementById("numberOfPeople"), "visible");
			var list = document.getElementById('room');
			if (isSet(list)) {
				list.style.visibility = 'visible';
			}
		}
	});
}

function showCalendar(calendarId, hideMany) {
	var   picker = document.getElementById(calendarId);

	var visibility = "";

	if (picker.style.display == "none" || picker.style.display == "") {
		picker.style.display = "block";
		visibility = "hidden";
	} else {
		picker.style.display = "none";
		visibility = "visible";
	}

	if (isSet(hideMany)) {
		setVisibility(document.getElementById("numberOfRooms"),  visibility);
		setVisibility(document.getElementById("numberOfPeople"), visibility);
		var list = document.getElementById('room');
		if (isSet(list)) {
			list.style.visibility = visibility;
		}
	}

	if (picker.id == "checkInPicker") {
		setVisibility(document.getElementById("checkOutDate"),  visibility);
		setVisibility(document.getElementById("checkOutMonth"), visibility);
	}
}

function validate() {
	var err = new Array();

	// area
	if (isSet(document.getElementById("areaDropDown"))) {
		if (document.getElementById("areaDropDown").value == "" && document.getElementById("specific").value == "") {
			err.push("Please specify an area to search");
		}
	}

	// business name
	if (isSet(document.getElementById("businessName"))) {
		if (document.getElementById("businessName").value == "") {
			err.push("Please specify an name to search on");
		}
	}

	// location
	if (isSet(document.getElementById("coordinates"))) {
		if (document.getElementById("coordinates").value == "") {
			err.push("Please specify an location to search");
		}
	}

	// provider type
	var providerTypeIsSet = false;

	if (!isSet(document.getElementById("providerType")) && !isSet(document.getElementById("providerTypes"))) {
		// no providerType on page ...
		providerTypeIsSet = true;
	}

	if (isSet(document.getElementById("providerTypes"))) {
		// advanced search
		var  list = document.getElementById("providerTypes");
		if (list.hasChildNodes()) {
			var elements = list.childNodes;
			for (var i = 0; i < elements.length; i++) {
				var li = elements[i];
				if (li.nodeName == "LI") {
					var input = li.firstChild;
					if (input.checked) {
						providerTypeIsSet = true;
						break;
					}
				}
			}
		}
	} else if (isSet(document.getElementById("providerType"))) {
		// basic search
		if (document.getElementById("providerType").value != "") {
			providerTypeIsSet = true;
		}
	}

	if (!providerTypeIsSet) {
		err.push("Please specify a type of accommodation to search for");
	}

	// number of rooms
	if (isSet(document.getElementById("numberOfRooms"))
		&& document.getElementById("numberOfRooms").value == "4+") {
		err.push("Please change the number of rooms you require to continue your search.");
	}

	if (isSet(document.getElementById("numberOfPeople"))
		&& document.getElementById("numberOfPeople").value == "20+") {
		err.push("Please change your party size requirements to continue your search.");
	}

	// map coordinates
	if (isSet(document.getElementById('x_coord')) && document.getElementById('x_coord').value == "") {
		err.push("Please enter a location by using the map.");
	}


	if (err.length > 0) {
		alert(err.join('\n'));
		return false;
	}

	return true;
}

function setSortOrder(obj) {
	var      formElement = document.getElementById("resortForm");
	var    resortElement = document.createElement("input");
	var sortOrderElement = document.createElement("input");

	resortElement.setAttribute("name", "resort");
	resortElement.setAttribute("type", "hidden");
	sortOrderElement.setAttribute("name", "sortOrder");
	sortOrderElement.setAttribute("value", obj.value);
	sortOrderElement.setAttribute("type", "hidden");

	formElement.appendChild(resortElement);
	formElement.appendChild(sortOrderElement);
	formElement.submit();
}

function checkValidProviderTypes(element) {
	var debug = new Array();
	var    id = element.className;
	var  list = document.getElementById("providerTypes");
	if (list.hasChildNodes()) {
		var elements = list.childNodes;
		for (var i = 0; i < elements.length; i++) {
			var li = elements[i];
			if (li.nodeName == "LI") {
				var input = li.firstChild;
				if (input.className != id) {
					input.checked = false;
				}
			}
		}
	}

	checkForSelfCateringProviderType(element);

	if (debug.length > 0) {
		alert(debug.join('\n'));
	}
}

function checkValidFacilities(parentElementID) {
	var debug = new Array();
	var limit = 3;
	var count = 0;
	var  list = document.getElementById(parentElementID);
	if (list.hasChildNodes()) {
		var elements = list.childNodes;
		for (var i = 0; i < elements.length; i++) {
			var li = elements[i];
			if (li.nodeName == "LI") {
				var input = li.firstChild;
				if (count >= limit) {
					input.checked = false;
				}

				if (input.checked == true) {
					count++;
				}
			}
		}
	}

	if (debug.length > 0) {
		alert(debug.join('\n'));
	}
}

function showQuickSearchForm() {
	return showHide("quicksearchForm");
}

function checkForSelfCateringProviderType(element) {
	var debug = new Array();
	var rooms = document.getElementById("numberOfRooms");
	var party = document.getElementById("numberOfPeople");

	var  initValue = 5;
	var limitValue = 20;

	if (element.className == '2') {
		// self catering
		rooms.value = 1;
		showRooms(rooms);
		rooms.disabled = true;
		for (i = (party.options.length + 1); i <= limitValue; i++) {
			var child = document.createElement('OPTION');
			child.value = child.innerHTML = i;
			if (i == limitValue) {
				// last element
				child.value = child.innerHTML = i +'+';
			}

			party.appendChild(child);
		}

	} else {
		// serviced
		rooms.disabled = false;
		if (party.options.length > initValue) {
			while(party.options.length > initValue) {
				removeElement(party.options[initValue]);
			}
		}
	}

	setDisplay(document.getElementById('tooManyRooms'),      'none');
	setDisplay(document.getElementById('bigParty'),          'none');
	setDisplay(document.getElementById('selfCateringParty'), 'none');

	if (debug.length > 0) {
		alert(debug.join('\n'));
	}

	return true;
}

function checkProviderType() {
	var list = document.getElementById("providerType");

	if (!isSet(list)) {
		return false;
	}

	var   index = list.options.selectedIndex;
	var element = list.options[index];

	return checkForSelfCateringProviderType(element);
}

function setVisibility(element, visibility) {
	if (isSet(element)) {
		element.style.visibility = visibility;
	}
}

function setDisplay(element, display) {
	if (isSet(element)) {
		element.style.display = display;
	}
}

/** global variables **/
var checkInCalendar, checkOutCalendar;
var today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
today.setMilliseconds(0);


var ie=(document.all&&document.getElementById)?1:0;
var ns=(!document.all&&document.getElementById)?1:0;
var days = new Array();
days[0] = "Sun";
days[1] = "Mon";
days[2] = "Tue";
days[3] = "Wed";
days[4] = "Thu";
days[5] = "Fri";
days[6] = "Sat";

var months = new Array();
months[0] = "Jan";
months[1] = "Feb";
months[2] = "Mar";
months[3] = "Apr";
months[4] = "May";
months[5] = "Jun";
months[6] = "Jul";
months[7] = "Aug";
months[8] = "Sep";
months[9] = "Oct";
months[10] = "Nov";
months[11] = "Dec";


function showHide() {
	var ids = showHide.arguments;
	for (var i = 0; i < ids.length; i++) {
		var elem = document.getElementById(ids[i]);
		if (isSet(elem)) {
			if (elem.style.display == "block") {
				elem.style.display = "none";
			} else {
				elem.style.display = "block";
			}
		}
	}
	return(false);
}

function switchVisibility() {
	var ids = switchVisibility.arguments;
	for (var i=0; i<ids.length; i++) {
		var elem = document.getElementById(ids[i]);
		if (elem) {
			if (elem.style.visibility == "hidden") {
				elem.style.visibility = "visible";
			} else {
				elem.style.visibility = "hidden";
			}
		}
	}

	return(false);
}

function setMainImage(img) {
	var mainImage = document.getElementById("mainImage");
	mainImage.src = "http://shared.visitscotland.com/images/thumbnails/" + img;
}

function openWin(url, windowName, x, y) {
	var features = '';

	if (windowName == null) {
		windowName = 'window';
	}

	if (x != null && y != null) {
		features += 'width='+ x +',height='+ y +',status=no';
	}

	window.open(url, windowName, features).focus();
	return false;
}

function openHelpWin(url) {
	var features = 'width=770,height=600,status=no,scrollbars=yes';
	window.open(url, 'Help', features).focus();
	return false;
}

function isSet(val) {
	val+="";
	if (val=="undefined"||val=="null") {
		return(0);
	}
	return(1);
}

function addEvent(obj,event,func) {
	if (ie) {
		return(obj.attachEvent("on"+event,func));
	} else if (ns) {
		obj.addEventListener(event,func,1);
		return true;
	} else {
		return(-1);
	}
}

function createElement(type) {
	return document.createElement(type);
}

function removeElement(obj) {
	if (ie) {
		obj.removeNode(true);
	} else if (ns) {
		obj.parentNode.removeChild(obj);
	}
}

function appendChild(obj,child) {
	obj.appendChild(child);
};

function addRow(table,cells) {
	row=table.insertRow(table.rows.length);

	for (var i=0;i<cells.length;i++) {
		appendChild(row,cells[i]);
	}
}

function fixMozYear(year) {
	return year < 1900 ? year + 1900 : year;
}

function setClass(id, className) {
	document.getElementById(id).className = className;
}



// ************************
// layer utility routines *
// ************************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
}
//-->
var xOffset = 30;
var yOffset = -5;

function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
	// hide any currently-visible popups
	hideCurrentPopup();
	// stop event from bubbling up any farther
	eventObj.cancelBubble = true;
	// move popup div to current cursor position 
	// (add scrollTop to account for scrolling for IE)
	var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0);
	var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
	moveObject(targetObjectId, newXCoordinate, newYCoordinate);
	// and make it visible
	if( changeObjectVisibility(targetObjectId, 'visible') ) {
	    // if we successfully showed the popup
	    // store its Id on a globally-accessible object
	    window.currentlyVisiblePopup = targetObjectId;
	    return true;
	} else {
	    // we couldn't show the popup, boo hoo!
	    return false;
	}
    } else {
	// there was no event object, so we won't be able to position anything, so give up
	return false;
    }
} // showPopup

function hideCurrentPopup() {
    // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
    if(window.currentlyVisiblePopup) {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
    }
} // hideCurrentPopup



// ***********************
// hacks and workarounds *
// ***********************

// initialize hacks whenever the page loads
window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
document.onclick = hideCurrentPopup;

function initializeHacks() {
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function resizeBlankDiv() {
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix () {
    location.reload(false);
}




function showTip(msg)
{
	if (Tipshow)
	{
		Tipmsg = msg;
		eventy = NN4 ? e.y : IE4 ? event.y : 0;
		showTimeOut = setTimeout('delayTip()', 600);
		Tipshow = false;
	}
}
function delayTip()
{
	var obj = 'TipBox';

	if (typeof(showTimeOut) != 'undefined') {clearTimeout(showTimeOut); Tipshow = true;}
	if (typeof(hideTimeOut) != 'undefined') clearTimeout(hideTimeOut);

	if (NN4)
	{
		if (document.layers[obj].visibility != 'visible')
		{
			with (document[obj].document)
			{
				open();
				write('<layer id=TipBox bgColor=#ffffee style="width: 600px; border: 1px solid #e5e3e3" onMouseover="keepTip()" onMousewheel="keepTip()" onMouseout="hideTip()">' + Tipmsg + '</layer>');
				close();
			}
			var objp = document.layers.TipBox;
			objp.moveTo(100, eventy + 6);
		}
		document.layers[obj].visibility = 'visible';
	}
	else if(IE4)
	{
		if (document.all[obj].style.visibility != 'visible')
		{
			document.all[obj].innerHTML = Tipmsg;
			var objp = document.all.TipBox.style;
			var yy = document.body.scrollTop + eventy + 6;
			objp.pixelLeft = 100;
			objp.pixelTop = yy;
		}
		document.all[obj].style.visibility = 'visible';
	}
}
function keepTip()
{
	var obj = 'TipBox';

	if (typeof(showTimeOut) != 'undefined') {clearTimeout(showTimeOut); Tipshow = true;}
	if (typeof(hideTimeOut) != 'undefined') clearTimeout(hideTimeOut);

	if (NN4)
		document.layers[obj].visibility = 'visible';
	else if(IE4)
		document.all[obj].style.visibility = 'visible';
}
function hideTip()
{
	hideTimeOut = setTimeout('delayHide()', 100);
}
function delayHide()
{
	var obj = 'TipBox';

	if (typeof(showTimeOut) != 'undefined') {clearTimeout(showTimeOut); Tipshow = true;}
	if (typeof(hideTimeOut) != 'undefined') clearTimeout(hideTimeOut);

  	if (NN4)
	{
		if (document.layers[obj] != null)
			document.layers[obj].visibility = 'hidden';
	}
	else if(IE4)
		document.all[obj].style.visibility = 'hidden';
}
function showDetail(info_hash)
{
	var url = info_hash == '' ? 'viewgraph.php' : 'detail.php?info_hash=' + info_hash;
	window.open(url, 'detailview', 'scrollbars=yes, width=560, height=300');
}

var showPopStep = 10;
var popOpacity = 80;
var sPop = '';
var tFadeOut = null;

function showPopupText(popText)
{
	if (!IE4) return;

	var o = event.srcElement;
	var MouseX = event.x;
	var MouseY = event.y;

	if (popText != sPop)
	{
		sPop = popText;
		clearTimeout(tFadeOut);

		if (sPop == null || sPop == '')
		{
			document.all.popLayer.innerHTML = '';
			document.all.popLayer.style.filter = "Alpha()";
			document.all.popLayer.filters.Alpha.opacity = 0;	
		}
		else
		{
			document.all.popLayer.innerHTML = sPop;
			document.all.popLayer.style.filter = "Alpha(Opacity=0)";
			var popWidth = document.all.popLayer.clientWidth;
			var popHeight = document.all.popLayer.clientHeight;
			document.all.popLayer.style.left = MouseX + popWidth > document.body.clientWidth - 5 ? document.body.clientWidth - popWidth - 5 : MouseX;
			document.all.popLayer.style.top = MouseY + document.body.scrollTop;
			fadeOut();
		}
	}
}
function fadeOut()
{
	if (popLayer.filters.Alpha.opacity < popOpacity)
	{
		popLayer.filters.Alpha.opacity += showPopStep;
		tFadeOut = setTimeout('fadeOut()', 30);
	}
}
function fn_changeClass(id, class1, class2){
//get the id of the element you wish to change

	identity=document.getElementById(id);
	//check what the current class is and swap it for the alternate class
	if(identity.className==class1){
		className=class2;
	}else{
		className=class1;
	}

	identity.className=className;
}

function getFormatDate(start,end){
	var mstart = Date.fromDDMMYYYY (document.getElementById(start).value);
	var mend = Date.fromDDMMYYYY (document.getElementById(end).value);
	if (document.getElementById(end).value==''){
	document.getElementById(end).value=document.getElementById(start).value;
	}else if(mend < mstart){
		document.getElementById(end).value=document.getElementById(start).value;
		
		}
	}
	function setWaiverAmount(currentPeople,oPeople,waiver,amount){
		var val = currentPeople-oPeople;
		var confirmPay       = document.getElementById("Total Rental Cost in  GBP");
		var confirmPayHidden       = document.getElementById("confirmPayHidden");
		var waiverHtml       =                         document.getElementById("cost1"); 
		var bookingPriceHtml       =                         document.getElementById("bookingPrice"); 
		confirmPay.value = (parseFloat(amount)+parseFloat(waiver*val)).toFixed(2);
		confirmPayHidden.value = (parseFloat(amount)+parseFloat(waiver*val)).toFixed(2);
		//alert(currentPeople);
		waiverHtml.innerHTML = ( (parseInt(currentPeople)+1)*waiver).toFixed(2);
		bookingPriceHtml.innerHTML = (parseFloat(amount)+parseFloat(waiver*val)).toFixed(2);
		}
		
	function setWaiverAmount84(currentPeople,oPeople,waiver,amount){
		var val = currentPeople-oPeople;
		var confirmPay       = document.getElementById("Total Rental Cost in  GBP");
		var confirmPayHidden       = document.getElementById("confirmPayHidden");
		var waiverHtml       =                         document.getElementById("cost1"); 
		var bookingPriceHtml       =                   document.getElementById("bookingPrice2"); 
		
		//alert(currentPeople);
		waiverHtml.innerHTML = ( (parseInt(currentPeople)+1)*waiver).toFixed(2);
		bookingPriceHtml.innerHTML = (parseFloat(amount)+parseFloat(waiver*val)).toFixed(2);
		}	
	
	function getPeople(val){
		
		var group       = document.getElementById("group");
		var tmpPage ;
		tmpPage='';
		//alert(val);
		if (val>0){
	     for (i=0; i<val;i++){
		tmpPage = '<div style=width:100%;><div  style=float:left;>                Guest Name*</div><div style=float:left; margin:0 0 0 2px;>  <input name=Name'+i+' type=text id=Name'+i+' size=19>  Age*</div> <select name=age'+i+'><option value=0 selected=selected>35-60</option><option value=17>less than 1</option><option value=16>1</option><option value=15>2</option><option value=14>3</option><option value=13>4</option><option value=12>5</option><option value=11>6-10</option><option value=10>11-15</option><option value=9>16-18</option><option value=8>19-21</option><option value=7>22-25</option><option value=6>26-34</option><option value=5>61-80</option><option value=99>over 80</option></select></div><br>'+tmpPage;}
		
		group.innerHTML = tmpPage;
		group.className='showGroup';
		}
		else{
			group.innerHTML = '';
		group.className='hideGroup';
			}
		
		}
		
		function toUp(tci,ch)
{
  var result="";
  if(tci.value.indexOf(ch)==-1)
    /* Looking for the CHARACTER if it exits then dont do anything */
    tci.value = tci.value;
  else
  {
    /* Character Exists */
    var str = tci.value.split('');
    for(i=0; i<=str.length-1; i++)
	{
	  if(str[i]==ch)
        /* here update the Character within the LOOP */
        str[i]  = str[i].toUpperCase();
      /* save the output to the resule variable which was set to a blank string in the begining */
      result+=str[i];
    }
    /* and Finaly set the value of your textBox equall to the result variable */	
    tci.value = result;
  }
}
		function getReservation(val)
		
		{
			if(val!=''){
				//var reLetter = /^[a-z]$/;
				//val = toUp(val,1);
				window.location.href='processing/getReservationProcessing.asp?ref='+val;
				}
			return false	;
			
			}
			
function writeExtraChecked(myID){
	// window.location.reload(false );
	// history.go(0);
	 return false;
	//alert(myID);
	}