 
<!--
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 formSubmit(){
	
	

	//currdate = new Date (document.form1.newStartPeriod.value);
	var start = Date.fromDDMMYYYY (document.form1.startDate1.value);
	var end = Date.fromDDMMYYYY (document.form1.endDate.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{	
	     document.form1.submit();
	}
}

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));
}
function fn_quickFormSubmit(){
	
	

	//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);
	if (start!=''&&end!=''){
		if (start >=end){
			
			alert('The end date must later than start date');
			return false;
			}
		else{	
			 document.rightMenuQuickSearch.submit();
		}
	}else if(start==''||end==''){
		
		alert('please input all date field');
		}
}
function fn_aFormSubmit(){
	
	

	//currdate = new Date (document.form1.newStartPeriod.value);
	var start = Date.fromDDMMYYYY (document.form1.startDateB.value);
	var end = Date.fromDDMMYYYY (document.form1.endDateB.value);
	
	//endDate = new Date(document.form1.newEndPeriod.value);
	//alert(start);
	if (start!=''&&end!=''){
		if (start >=end){
			
			alert('The end date must later than start date');
			return false;
			}
		else{	
			 document.form1.submit();
		}
	}
	
	if(start=='NaN'||end=='NaN'){
		
		alert('please input all date field');
		  return false;
		}
		 return false;
}
function fnQuotationSubmit(act){
	
	document.form1.bookAction.value=act;
	document.form1.submit();
	
	
	}
	
	
	function getElementName(amount,val){
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")

//ele.innerHTML = amount;

if(val==true){
eCost.innerHTML = parseFloat(eCost.innerHTML) + parseFloat(amount);
bP.innerHTML = parseFloat(bP.innerHTML) + parseFloat(amount);
bP1.innerHTML = parseFloat(bP1.innerHTML) + parseFloat(amount);
bP2.innerHTML = parseFloat(bP2.innerHTML) + parseFloat(amount);


}else{
eCost.innerHTML = parseFloat(eCost.innerHTML) - parseFloat(amount);
bP.innerHTML = parseFloat(bP.innerHTML) - parseFloat(amount);
bP1.innerHTML = parseFloat(bP1.innerHTML) - parseFloat(amount);
bP2.innerHTML = parseFloat(bP2.innerHTML) - parseFloat(amount);

}
//alert("" + ec.length);
//alert(ele.innerHTML);
}
function addAcAmount(){
var ac = document.getElementById("acAmount");

var eCost = document.getElementById("cost");
var amount = ac.innerHTML;
//ele.innerHTML = amount;


eCost.innerHTML = parseFloat(eCost.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.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;
}
function checkPrices(propSearch){

	maxPrice=document.getElementById('intMaxPrice').value;
	minPrice =document.getElementById('intMinPrice').value;
	if (maxPrice == ""){
		maxPrice =0;
	}
	if (minPrice ==""){
		minPrice =0;
	}
	if (isNaN(minPrice) ){
		alert('Please ensure that the Minimum Price is a number');return false;
	
	}
	else if(isNaN(maxPrice)) {
		alert('Please ensure that the Maxmum Price is a number');return false;
	}
	else if (parseInt(maxPrice) < parseInt(minPrice) && maxPrice > 0){
		alert('Please ensure that the Maxmum Price is greater than the Minimum Price');return false;
	}
	else{
		document.getElementById('intMinPrice').value =maxPrice;
		document.getElementById('intMinPrice').value =minPrice;
		document.propSearch.submit();
	}
}
//-->


