function init() {
	makeShadow();
	displayImageInfo();
	displayRandFeature();
}

function makeShadow(){
	if ((browser.isIE55 || browser.isIE6up) && browser.isWin32)
		document.getElementById("shadow").innerHTML = '<div style="height:50px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'Images/header/shadow.png\', sizingMethod=\'scale\')"></div>';
	else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast))
		document.getElementById("shadow").innerHTML = '<img src="Images/header/shadow.png" width="750" height="50" border="0" alt="">';
}

function displayImageInfo(){
	var info; var infoheight; var imgheight;
	if (document.getElementById("image-float")) {
		var imgnodes = document.getElementById("image-float");
		var nodelength = imgnodes.childNodes.length;
		for (var i = 0; i < nodelength; i++) {
			if (document.getElementById("desc"+i)) {
				info = document.getElementById("desc"+i)
				infoheight = info.clientHeight;
				imgheight = document.getElementById("img"+i).clientHeight;
				info.style.top = (imgheight - infoheight + 1) + "px";
				document.getElementById("link"+i).style.top = (infoheight - 16) + "px";
				info.style.visibility = "visible";
			}
		}
	}
}

function displayBlurb() {
	var blurbtext = document.getElementById("blurb");
	if (blurbtext.style.display == "none")
		blurbtext.style.display = "block";
	else
		blurbtext.style.display = "none";
}

function displayRandFeature() {
	// Only for homepage
	if (document.getElementById("p1")) {
		for (i = 1; i <= 5; i++) {
			if (document.getElementById("p"+ i +"-title").innerHTML.toLowerCase() == "<span></span><br>") {
				var total = i - 1;
				break;
			}
		}
		var rand = Math.floor(Math.random()*total) + 1;
		document.getElementById("empty").style.display = "none";
		document.getElementById("p"+ rand).style.display = "block";
	}
}

// used on confirmation of booking
function checkTerms() {
	if (document.terms.checkterms.checked)
		location.href = "proceed.asp";
	else
		alert("Please tick the box to show that you agree with the terms and conditions.");
}

function checkCompTerms() {
	if (document.compfrm.terms.checked)
		document.compfrm.submit();
	else
		alert("Please tick the box to show that you agree with the terms and conditions.");
}

function submitPayment() {
	document.getElementById("paylink").innerHTML = "<a><strong>processing...</strong>&nbsp;&nbsp;</a>"
	document.paymentfrm.submit();
}

function displayInterests() {
	var interests = document.getElementById("interests");
	if (interests.style.display == "none")
		interests.style.display = "block";
	else
		interests.style.display = "none";
}

function displayUpsell(pid, tid) {
	var tournodes = document.getElementById(pid);
	tournodes = tournodes.getElementsByTagName("div");
	for (var i = 0; i < tournodes.length; i++)
		if (tournodes[i].className == "upsell") tournodes[i].style.display = "none";
	document.getElementById(tid).style.display = "block";
}

// Dinner Booking
function openBooking(pos) {
	var output = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
	output += "<tr><td style=\"width:100px\">Date/Time:</td><td><input type=\"text\" name=\"time"+ pos +"\" size=\"30\" maxlength=\"30\" style=\"margin-right:20px;\"></td></tr>";
	output += "<tr><td>People:</td><td><input type=\"text\" name=\"people"+ pos +"\" size=\"30\" maxlength=\"30\" style=\"margin-right:20px;\"></td></tr>";
	output += "<tr><td>Special Requests:</td><td><input type=\"text\" name=\"request"+ pos +"\" size=\"30\" maxlength=\"200\"></td></tr>";
	output += "</table>";
	document.getElementById("frm"+pos).innerHTML = output;
	document.getElementById("frm"+pos).style.display = "block";
}

function submitBooking() {
	var count = 7;
	for (var i = 1; i <= count; i++) {
		if (document.getElementById("frm"+ i).style.display == "block") {
			var formarray = document.commentsfrm.formarr.value;
			if (formarray.length > 0)
				document.commentsfrm.formarr.value = formarray +","+ i;
			else
				document.commentsfrm.formarr.value = i;
		}
	}
	document.commentsfrm.submit();
}

function changePasswordType() {
	document.getElementById("passfake").style.display = "none";
	document.getElementById("password").style.display = "inline";
	document.loginfrm.user_password.focus();
}

var win=null;
function openWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}else if((pos!="center" && pos!="random") || pos==null){
		LeftPosition=0;TopPosition=20
 	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	if(win.focus) win.focus();
}

function loadImage(cID,pID) {
	property_id = 666;
	pricing = false;
	document.getElementById("photo").innerHTML = 'Loading ...';
	loadXMLDoc("includes/content.asp?cID=" + cID + "&pID=" + pID);
}

function processImage() {
	var output = '';
	var items = xml.responseXML.getElementsByTagName("results");
	var pdiv = document.getElementById("photo");
	var iWidth = items[0].childNodes[5].firstChild.nodeValue;
	var iHeight = items[0].childNodes[6].firstChild.nodeValue;
	var pID = items[0].childNodes[7].firstChild.nodeValue;
	if(iWidth > iHeight){
		output += '<img src="' + items[0].childNodes[3].firstChild.nodeValue + '\" width=' + iWidth + ' height=' + iHeight + ' border=0 alt=\"' + items[0].childNodes[2].firstChild.nodeValue + '\">';
		output += '<div style="height:36px;padding-top:2px;">' + items[0].childNodes[4].firstChild.nodeValue + '</div>';
		//output += '<div style="float:left;"><img src="Images/icons/arrow_grey_left.gif" width=7 height=7 border=0><a href="" class="arrow">back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="" class="arrow-left">next</a><img src="Images/icons/arrow_grey.gif" width=7 height=7 border=0></div>';
		output += '<div style="float:right;"><a href="default.asp?pID=' + pID + '&cID=' + items[0].childNodes[0].firstChild.nodeValue + '" class="arrow-left">email this image to a friend</a><img src="Images/icons/arrow_grey.gif" width=7 height=7></div>';
	} else {
		output += '<div style="float:left;width:171px;"><div style="padding:140px 10px 10px 0px;">';
		output += '<div style="height:100px;">' + items[0].childNodes[4].firstChild.nodeValue + '</div>';
		output += '<div style="height:37px;"><a href="default.asp?pID=' + pID + '&cID=' + items[0].childNodes[0].firstChild.nodeValue + '" class="arrow-left">email this image to a friend</a><img src="Images/icons/arrow_grey.gif" width="7" height="7" alt=""></div>';
		//output += '<div><img src="Images/icons/arrow_grey_left.gif" width="7" height="7" alt=""><a href="' + iPrev + '" class="arrow">back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="' + iNext + '" class="arrow-left">next</a><img src="Images/icons/arrow_grey.gif" width="7" height="7" alt=""></div>';
		output += '</div></div>';
		output += '<div style="float:right;"><img src="' + items[0].childNodes[3].firstChild.nodeValue + '\" width=' + iWidth + ' height=' + iHeight + ' border=0 alt=\"' + items[0].childNodes[2].firstChild.nodeValue + '\"></div>';
	}
	pdiv.innerHTML = output;
}

var isOn = 'info_1';
	
function show(divID) {
	hide(isOn);
	document.getElementById(divID).style.visibility = 'visible';
	isOn = divID;
}

function hide(divID) {
	document.getElementById(divID).style.visibility = 'hidden';
}

function subForm(pg){
	document.cSearch.pg.value = pg;
	document.cSearch.submit();
}

function closeWin(url){
	window.parent.opener.location = url;
	window.parent.opener.focus();
	window.close();
}

function wordCounter(total, s) {
	var str = s.split(" ");
	var count = total - str.length;
	if (str.length >= total || count == 0) {
		document.compfrm.comp_entry.value = s.substring(0, s.length - 1);
		document.getElementById("wTotal").innerHTML = count;
	} else
		document.getElementById("wTotal").innerHTML = count;
}