// JavaScript Document

addOnload(roundCorners);

function roundCorners() {
	if(!NiftyCheck()) return;
	Rounded("div#header","#FFFFFF","#647791");
	Rounded("div#letMeHelp","#FFFFFF","#6d7784");
	Rounded("div#footer","#FFFFFF","#647791");
	Rounded("div.infoBlock","#FFFFFF","#6d7784");
	Rounded("div.infoBlock1","#FFFFFF","#AFC3DD");
	Rounded("div.rounded","#FFFFFF","#AFC3DD");
}

addOnload(cottageOn);

function cottageOn() {
	allDivs = document.getElementsByTagName("div");
	for (i=0; i<allDivs.length; i++) {
		if ((allDivs[i].className == "cottage") && (allDivs[i].title.indexOf("_") != 0)) {
					allDivs[i].onmouseover = function() { this.className = "cottage_on"; }
					allDivs[i].onmouseout = function() { this.className = "cottage"; }
					allDivs[i].onclick = function() { window.location.href = ("suffolk-holiday-cottages/" + this.title); }
		}
		if ((allDivs[i].className == "cottage") && (allDivs[i].title.indexOf("_") == 0)) {
					allDivs[i].onmouseover = function() { this.className = "cottage_on"; }
					allDivs[i].onmouseout = function() { this.className = "cottage"; }
					allDivs[i].onclick = function() { window.location.href = ("holiday-cottages/" + this.title.substr(1)); }
		}
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return false;
}

addOnload(checkLogin);

function checkLogin() {
	if (getCookie('loggedin')) document.getElementById('userlogin').innerHTML = '<a href="/logout.php" style=\"padding-top:1em; padding-bottom: 1em\"><img src="/images/power_off.png" align="absmiddle" alt="log out" border=0 /> LOG OUT</a>';
}

Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) if (this[i] == value) return true;
	return false;
};