<!-- Hide script from old browsers
// Make sure file is not hosted in a different frameset
if ( top.location.href != window.location.href )
  { top.location.href=window.location.href }

    function openWindow(url, w, h) {
        var windowprops = "width=" + w + ",height=" + h +",,left=10,top=10,scrollbars=no,status=yes,toolbar=no,location=no,directories=no,resizable=yes";
          popup = window.open(url,'newWin',windowprops);
          popup.focus();
           } 
        
	function openPicture(pic,w,h) {
     
     	var wpro = w + 20;
     	var hpro = h + 50;
		var windowprops = "left=160,top=50,scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,width=" + wpro + ",height=" + hpro;
          
		picture = window.open('','newPicture',windowprops);
		picture.close();
        picture = window.open('','newPicture',windowprops);  
        picture.focus();
        
		picture.document.write("<html><head><title>Picture<\/title><link href='common\/cstyle.css' type=text\/css rel=stylesheet><\/head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'bgcolor='#000000'>")
		picture.document.writeln("<table width='100%' border='0' cellpadding='5'><tr><td align='center' valign='middle'>")
		picture.document.writeln("<img src=" + pic + " width=" + w + " height=" + h + "></td></tr></table>")
		picture.document.write("<center><a href='#' OnClick='window.close();' class='messageLink'>Close</a></center>")
		picture.document.write("<\/body><\/html>")
	}                
 
function showdate()
{
	
		// Determine the current date and display it
   	var today = new Date();
   	var day = today.getDay();
   	var date = today.getDate();
   	var month = today.getMonth();
   	var year = today.getFullYear();
   	
   		//January,February,March,April,May,June,July,August,September,October,November,December
   	if (month == 0) {month='Jan'};
   	if (month == 1) {month='Feb'};
   	if (month == 2) {month='Mar'};
   	if (month == 3) {month='Apr'};
   	if (month == 4) {month='May'};
   	if (month == 5) {month='Jun'};
   	if (month == 6) {month='Jul'};
   	if (month == 7) {month='Aug'};
   	if (month == 8) {month='Sept'};
   	if (month == 9) {month='Oct'};
   	if (month == 10) {month='Nov'};
   	if (month == 11) {month='Dec'};
   
   	if (day == 0) {day='Sunday'};
   	if (day == 1) {day='Monday'};
   	if (day == 2) {day='Tuesday'};
   	if (day == 3) {day='Wednesday'};
   	if (day == 4) {day='Thursday'};
   	if (day == 5) {day='Friday'};
   	if (day == 6) {day='Saturday'};
   
   if ( document.all ) {
		document.write ('<span class="small">&nbsp;&nbsp;' + day + ', ' + month +  ' ' + date + ', ' + year + '</span>');
	} else {
		document.write ('<span class="smallNC">&nbsp;&nbsp;' + day + ', ' + month +  ' ' + date + ', ' + year +  '</span>');
	}
   
   
}

function switchClass(obj,strClassName) {
		obj.className	= strClassName;
	}
	
function gotoURL(strUrl) {
		location = strUrl;
	}

function copyrightYear(startYear)
	{
		d = new Date();
		
		if (startYear != d.getFullYear())
			{
			return startYear + " - " + d.getFullYear();
			}
		else
			{
			return startYear;
			}
	}
	
	// Show current date in format "Nov 15, 2003".		
function nsDate()
{
		// Get today's date.
	var sDate = new Date();
	var sToday = "";
	
		// Array with months.
	var aMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
		// Get current month.
	var iMonth = sDate.getMonth();
		
		// Get current hour,minute,second.
	var iHours   = sDate.getHours();
	var iMinutes = sDate.getMinutes();
	var iSeconds = sDate.getSeconds();
			
	sToday = "";
		// Get today's date string.
	sToday += aMonths[iMonth] + " ";
	sToday += sDate.getDate() + ", ";
	sToday += sDate.getFullYear() + " ";

		// Display the date on the screen.
	document.write("<b>"+sToday+"</b>");	
}

	// Get the current date in format "Nov 15, 2003  12:53:23 pm".
function today()
{
	var ie4=document.all;
    var ns4=document.layers;
    var ns6=document.getElementById&&!document.all;
    	
		// Get today's date.
	var sDate = new Date();
	var sToday = "";
	
		// Array with months.
	var aMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
		// Get current month.
	var iMonth = sDate.getMonth();
		
		// Get current hour,minute,second.
	var iHours   = sDate.getHours();
	var iMinutes = sDate.getMinutes();
	var iSeconds = sDate.getSeconds();
	
		// If iHour > 12.
	if(iHours>12)
		iHours = iHours - 12;
	
	if(iMinutes < 10)
		iMinutes = "0" + iMinutes;
		
	if(iSeconds < 10)
		iSeconds = "0" + iSeconds;
	
	sToday = "";
		// Get today's date string.
	sToday += aMonths[iMonth] + " ";
	sToday += sDate.getDate() + ", ";
	sToday += sDate.getFullYear() + " ";
	
	sToday += iHours + ":";
	sToday += iMinutes + ":" ;
	sToday += iSeconds; 

	
		// Set am or pm
	if(sDate.getHours() < 12)
		sToday += " am ";
	else
		sToday += " pm ";
	
		// Display the date on the screen.
	
		// Write the clock to the layer:
	if (ns4) 
	{
		return;
	} 
	else 
		if (ie4) 
		{
			document.getElementById("LiveClock").innerHTML = "<b>"+sToday+"</b>";
		}	 
		else 
			if (ns6)
			{
				document.getElementById("LiveClock").innerHTML = "<b>"+sToday+"</b>";
            }            
	
		setTimeout("today()",1000);
		//window.setInterval(today(),100);
}

function validateEmail(email)
{
	if ((email.length < 3) || (email.length > 50) || 
			(email.charAt(0) == '@') || (email.charAt(email.length-1) == '@') || 
			(email.charAt(0) == '.') || (email.charAt(email.length-1) == '.') || 
			(email.indexOf('.') == -1) || (email.indexOf('@') == -1) ||
			(email.indexOf('@') != email.lastIndexOf('@')) || 
			(email.indexOf(' ') > 0) || (email.indexOf('?') > 0) || (email.indexOf('..') > 0)
			)
	{
		return false;
	}
	else
	{
		return true;
	}
} 	

/*
* cllear text element if its value is equal to textToClear
*/
function ClearText(elem, textToClear)
{
	if (elem.value == textToClear)
	{
		elem.value = '';
	}
} 

/*
* get weekday name depending on result from getDay() JS function
* @param int dayinteger - result from getDay()
*/
function getDayName(dayinteger) {
	
	// put weekday in standart 0-6
	if (dayinteger < 0) {
		dayinteger = dayinteger + 7;
	}
	if (dayinteger > 6) {
		dayinteger = dayinteger - 7;
	}
	
	switch (dayinteger) {
		case 0:
			return "Sunday";
			break;
		case 1:
			return "Monday";
			break;
		case 2:
			return "Tuesday";
			break;
		case 3:
			return "Wednesday";
			break;
		case 4:
			return "Thursday";
			break;
		case 5:
			return "Friday";
			break;
		case 6:
			return "Saturday";
			break;
		default:
			return "Unknown";
			break;
	}	
}

/*
* get current weekday
*
*/
function changeSearchStartDate(from) {
	var day = document.getElementById('SearchDay' + from);
	var month = document.getElementById('SearchMonth' + from);
	var year = document.getElementById('SearchYear' + from);
	
	/*
	if (day.value != '' && month.value != '' && year.value != '') {
		// calculate week day
		//var startDate = new Date(year.value, month.value, day.value);
		var startDate = new Date(year.value, month.value-1, day.value);
		
		weekday = startDate.getDay();
		
		var Flexibility1 = document.getElementById("Flexibility1" + from);
		Flexibility1.innerHTML = "+/- 1 day"+"("+getDayName(weekday-1)+"/"+getDayName(weekday+1)+")";
		
		var Flexibility2 = document.getElementById("Flexibility2" + from);
		Flexibility2.innerHTML = "+/- 2 day"+"("+getDayName(weekday-2)+"/"+getDayName(weekday+2)+")";
		
		var Flexibility3 = document.getElementById("Flexibility3" + from);
		Flexibility3.innerHTML = "+/- 3 day"+"("+getDayName(weekday-3)+"/"+getDayName(weekday+3)+")";
		
		var Flexibility4 = document.getElementById("Flexibility4" + from);
		Flexibility4.innerHTML = "+/- 4 day"+"("+getDayName(weekday-4)+"/"+getDayName(weekday+4)+")";
		
	} else {
		var Flexibility1 = document.getElementById("Flexibility1" + from);
		Flexibility1.innerHTML = "+/- 1 day";
		
		var Flexibility2 = document.getElementById("Flexibility2" + from);
		Flexibility2.innerHTML = "+/- 2 day";
		
		var Flexibility3 = document.getElementById("Flexibility3" + from);
		Flexibility3.innerHTML = "+/- 3 day";
		
		var Flexibility4 = document.getElementById("Flexibility4" + from);
		Flexibility4.innerHTML = "+/- 4 day";
	}
	*/
}

// *******************************************************************************************
// AJAX
// *******************************************************************************************
function GetXMLHttpRequest() {
	var req;

    if(window.XMLHttpRequest && !(window.ActiveXObject))
    {
    	try 
    	{
			req = new XMLHttpRequest();
        } 
        catch(e)
        {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } 
    else if(window.ActiveXObject)
    {
    	try 
    	{
        	req = new ActiveXObject("Msxml2.XMLHTTP");
    	} 
    	catch(e) 
    	{
       		try 
       		{
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) 
        	{
          		req = false;
        	}
		}
    }

  	return req;	
}

// get object
var xmlhttp = GetXMLHttpRequest();

function loadXMLDoc(sURL,execFunction)
{
	xmlhttp.open("GET",sURL,true);
	
	xmlhttp.onreadystatechange = eval(execFunction);
	
	xmlhttp.send(null);	
}

function alertResult() {
	// if xmlhttp shows "loaded"	
	if (xmlhttp.readyState == 4) {
	// loading finished
		if (xmlhttp.status==200) {
			// ...some code here...
			alert(xmlhttp.responseText);
		} else {
			alert("Problem retrieving XML data");
		}
	} else if (xmlhttp.readyState == 1) {
		// loading
		//alert('readystate:' + xmlhttp.readyState);
	} else {
		//alert('readystate:' + xmlhttp.readyState);
	}
}

function getCalendar() {
	// if xmlhttp shows "loaded"	
	var calendarDiv = document.getElementById('PropertyCalendar');
	
	if (xmlhttp.readyState == 4) {
		// loading finished
		if (xmlhttp.status==200) {			
			// ...some code here...			
			if (calendarDiv) {
				calendarDiv.innerHTML = xmlhttp.responseText;
			}
		} else {
			alert("Problem retrieving XML data");
		}
	} else if (xmlhttp.readyState == 1) {
		// loading
		calendarDiv.innerHTML = "<b>Loading. Please wait ...</b>";
	} else {
		//alert('readystate:' + xmlhttp.readyState);
	}
}

function getBedrooms() {
	// if xmlhttp shows "loaded"	
	var bedroomsDiv = document.getElementById('PropertyBedrooms');
	
	if (xmlhttp.readyState == 4) {
		// loading finished
		if (xmlhttp.status==200) {			
			// ...some code here...			
			if (bedroomsDiv) {
				bedroomsDiv.innerHTML = xmlhttp.responseText;
			}
		} else {
			alert("Problem retrieving XML data");
		}
	} else if (xmlhttp.readyState == 1) {
		// loading
		bedroomsDiv.innerHTML = "<b>Loading. Please wait ...</b>";
	} else {
		//alert('readystate:' + xmlhttp.readyState);
	}
}

function getBathrooms() {
	// if xmlhttp shows "loaded"	
	var bathroomsDiv = document.getElementById('PropertyBathrooms');
	
	if (xmlhttp.readyState == 4) {
		// loading finished
		if (xmlhttp.status==200) {			
			// ...some code here...			
			if (bathroomsDiv) {
				bathroomsDiv.innerHTML = xmlhttp.responseText;
			}
		} else {
			alert("Problem retrieving XML data");
		}
	} else if (xmlhttp.readyState == 1) {
		// loading
		bathroomsDiv.innerHTML = "<b>Loading. Please wait ...</b>";
	} else {
		//alert('readystate:' + xmlhttp.readyState);
	}
}


function getShowerrooms() {
	// if xmlhttp shows "loaded"	
	var showerroomsDiv = document.getElementById('PropertyShowerrooms');
	
	if (xmlhttp.readyState == 4) {
		// loading finished
		if (xmlhttp.status==200) {			
			// ...some code here...			
			if (showerroomsDiv) {
				showerroomsDiv.innerHTML = xmlhttp.responseText;
			}
		} else {
			alert("Problem retrieving XML data");
		}
	} else if (xmlhttp.readyState == 1) {
		// loading
		showerroomsDiv.innerHTML = "<b>Loading. Please wait ...</b>";
	} else {
		//alert('readystate:' + xmlhttp.readyState);
	}
}

// *******************************************************************************************
// AJAX
// *******************************************************************************************	

// change current currency for a week in property calendar
// @param rowID - the row id of the week 
// @param currency - currency select element
// 
function changeCurrency(rowID, currency) {
	var StandardPriceCurr = document.getElementById('StandardPriceCurr' + rowID);
	var DiscountedPriceCurr = document.getElementById('DiscountedPriceCurr' + rowID);
	if (StandardPriceCurr) {
		if (currency.value == "GBP") {
			StandardPriceCurr.innerHTML = "&pound;";
			DiscountedPriceCurr.innerHTML = "&pound;";
		} else {
			StandardPriceCurr.innerHTML = "&euro;";
			DiscountedPriceCurr.innerHTML = "&euro;";
		}
	}
}

// change current currency for a week in property calendar
// @param rowID - the row id of the week 
// @param available - available checkbox element
// 
function changeWeekStatus(rowID, available) {
	var WeekRow = document.getElementById('WeekRow' + rowID);
	var StandardPrice = document.getElementById('StandardPrice' + rowID);
	var DiscountedPrice = document.getElementById('DiscountedPrice' + rowID);
	var Currency = document.getElementById('Currency' + rowID);
	
	if (available.checked) {
		// week becomes available
		StandardPrice.disabled = false;
		DiscountedPrice.disabled = false;
		Currency.disabled = false;
		
		if (WeekRow.className == "tableDataLight") {
			// put available light class
			WeekRow.className = "tableDataLightAv";
		} else {
			WeekRow.className = "tableDataDarkAv";
		}
	} else {
		// week is no more available
		StandardPrice.disabled = true;
		DiscountedPrice.disabled = true;
		Currency.disabled = true;
		
		if (WeekRow.className == "tableDataLightAv") {
			// put available light class
			WeekRow.className = "tableDataLight";
		} else {
			WeekRow.className = "tableDataDark";
		}
	}
	
}

function showClock(cmd) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="259" height="164" id="watch" align="middle">'
	+'<param name="allowScriptAccess" value="sameDomain" />'
	+'<param name="movie" value="images/watch.swf?stop=' + cmd + '" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="images/watch.swf?stop=' + cmd + '" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="259" height="164" name="watch" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	+'</object>');
}

// End hiding script from old browsers -->
