// for IE
var d = document.all;

// for Gekko
var g = document.getElementById;

// for the first two functions below
var lastText;

// hides the detail on the call to action panel
function hideDetail()
{
	if(d)
	{
		for (i=1; i<=6; i++)
		{
			document.all['t'+i].style.display="none";
		}
	}
		else if(g)
	{
		for (i=1; i<=6; i++)
		{
			document.getElementById('t'+i).style.display="none";
		}
	}
}

var textNo;

var imageName = new Array("","location","open","prices","facilities","nearby","gallery");

// generic showing of the same lumps of text function
// messy: probably no need to have it split into document.all and getElementById
function showDetail(textNo)
{
	if(d)
	{
		// if there's anything to hide
		if(lastText)
		{
			// if the user has clicked on the button twice
			if(lastText.charAt(1) == textNo)
			{
				hideDetail();
				document.getElementById(textNo).src = "/UPLOAD/home_files/img/action_" + imageName[textNo] + "_off.gif";
				lastText = "";
			}
			// if it's just the last detail which needs to be hidden
			else
			{
				lastImg = lastText.charAt(1);
				document.all[lastText].style.display="none";
				document.getElementById(lastImg).src = "/UPLOAD/home_files/img/action_" + imageName[lastImg] + "_off.gif";
				// displaying the new detail
				document.all['t'+textNo].style.display = "block";
				document.getElementById(textNo).src = "/UPLOAD/home_files/img/action_" + imageName[textNo] + "_on.gif";
				// setting up the new lastText variable
				lastText = 't' + textNo;
			}
		}

		// or if it's the first time the event has fired
		else
		{
			// displaying the new detail
			document.all['t'+textNo].style.display = "block";
			document.getElementById(textNo).src = "/UPLOAD/home_files/img/action_" + imageName[textNo] + "_on.gif";
			// setting up the new lastText variable
			lastText = 't' + textNo;
		}
	}

	else if(g)
	{
		if(lastText)
		{
			if(lastText.charAt(1) == textNo)
			{
				hideDetail();
				document.getElementById(textNo).src = "/UPLOAD/home_files/img/action_" + imageName[textNo] + "_off.gif";
			}

			else
			{
				lastImg = lastText.charAt(1);
				document.getElementById(lastText).style.display="none";
				document.getElementById(lastImg).src = "/UPLOAD/home_files/img/action_" + imageName[lastImg] + "_off.gif";
				document.getElementById('t'+textNo).style.display = "block";
				document.getElementById(textNo).src = "/UPLOAD/home_files/img/action_" + imageName[textNo] + "_on.gif";
				lastText = 't' + textNo;
			}
		}

		else
		{
			document.getElementById('t'+textNo).style.display = "block";
			document.getElementById(textNo).src = "/UPLOAD/home_files/img/action_" + imageName[textNo] + "_on.gif";
			lastText = 't' + textNo;
		}
	}
}

// writes the print link to the page
function printButton()
{
	if (window.print)
	{
		document.write('<p><a href="javascript:window.print();"><img src="/UPLOAD/home_files/img/icon_print.gif" width="17" height="18" alt="Print this page" /></a> <a href="javascript:window.print();">Print this page</a></p>');
	}
}

// Generic popup
function windowOpenSized(windowname, width, height)
{
	var thiswin = open('',windowname,'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes');
	if (thiswin.focus) thiswin.focus();
}

// Ric's popup script for ActivEdition
if (document.addEventListener) window.addEventListener("load",setLinks,false); else	if (document.attachEvent) window.attachEvent("onload",setLinks,false); else onload = setLinks;
		function setLinks() {
	for (var i=0;i<document.links.length;i++) {
		if (document.links[i].target.indexOf("popup_")>-1) document.links[i].onclick = new Function("open('"+document.links[i].href+"','','width="+parseInt(document.links[i].target.substr(7,document.links[i].target.indexOf("h")-7),10)+",height="+parseInt(document.links[i].target.substr(document.links[i].target.indexOf("h")+1),10)+",status=1,toolbars=0,menubar=0,resizable=1,scrollbars=yes,location=0');return false");
	}
}