var aArrayOfPhotos = new Array();

window.onload = do_onload;

function do_onload()
{
	if (document.getElementById) 
	{
		if (document.all)
		{
			navRoot = document.getElementById("menulist");
			if (navRoot != null)
			{
				for (i=0; i< navRoot.childNodes.length; i++) 
				{
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") 
					{
						node.onmouseover=function() 
						{
							this.className+=" over";
						}
						node.onmouseout=function() 
						{
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}
		}
		
		/* Associate logo's onclick event with home page */
		var centralsign = document.getElementById('centralsign');
		if (centralsign != null)
		{
			centralsign.onclick = function() 
			{
				window.location='home.php';
				return false;
			}
		}
		
		// Add extra property table functionality
		var propertytable = document.getElementById("propertytable");
		if (propertytable != null)
		{
			var links = propertytable.getElementsByTagName("a");
			for (aIndex = 0; aIndex < links.length; aIndex++)
			{
				if (links[aIndex].className == "button") links[aIndex].innerHTML = '<input class="button" type="button" value="Details"></input>';
			}

			var propertytablerows = propertytable.getElementsByTagName("tr");
			for (aIndex = 1; aIndex < propertytablerows.length; aIndex++)
			{
				var wheretoclickspan = document.getElementById("propertyclicksspan");	
				wheretoclickspan.innerHTML = "relevant row of";
				propertytablerows[aIndex].getElementsByTagName("td")[0].getElementsByTagName("a")[0].style.textDecoration = "none";		
				propertytablerows[aIndex].getElementsByTagName("td")[0].getElementsByTagName("a")[0].style.color = "#474747";		
				propertytablerows[aIndex].onclick = function() {window.location = this.getElementsByTagName("td")[0].getElementsByTagName("a")[0].href; return false;}
				propertytablerows[aIndex].onmouseover = function() {this.className = 'propertyhover';}
				propertytablerows[aIndex].onmouseout = function() {this.className = '';}
			}
		}

		// Add extra quick links functionality
		var quicklinksdiv = document.getElementById("quicklinks");
		if (quicklinksdiv != null)
		{	
			var quicklinks = quicklinksdiv.getElementsByTagName("a");
			for (aIndex = 0; aIndex < quicklinks.length; aIndex++)
			{
				quicklinks[aIndex].onmouseover = function() 
				{
					this.getElementsByTagName("img")[0].src = this.getElementsByTagName("img")[0].src.replace('.gif','%20hover.gif');;
				}
				quicklinks[aIndex].onmouseout = function() 
				{
					this.getElementsByTagName("img")[0].src = this.getElementsByTagName("img")[0].src.replace('%20hover.gif', '.gif');
				}
			}
		}
			
		// Add extra property thumbnail images functionality
		var thumbnailslist = document.getElementById("thumbnails");
		if (thumbnailslist != null)
		{	
			var picturelinks = thumbnailslist.getElementsByTagName("a");
			for (aIndex = 0; aIndex < picturelinks.length; aIndex++)
			{
				aHashPosition = picturelinks[aIndex].href.indexOf("#");
				aLengthOfLink = picturelinks[aIndex].href.length;
				aLinkTarget = picturelinks[aIndex].href.substring(aHashPosition + 1,aLengthOfLink);
				aArrayOfPhotos[aIndex] = aLinkTarget;
				
				aImageToHide = document.getElementById(aLinkTarget);
				if (aImageToHide != null) 
				{
					picturelinks[aIndex].onclick = JSFnThumbnailClick;
					if (aIndex > 0) aImageToHide.style.display = 'none';
				}
			}
			
			// Hide any back to top links as they are no longer necessary
			var allLinks = document.getElementsByTagName("a")
			for (aIndex = 0; aIndex < allLinks.length; aIndex++)
			{
				if (allLinks[aIndex].href.indexOf("#header") != -1) allLinks[aIndex].style.display = 'none';
			}
		}
		
		// Rollover images in rightcolumn
		navRoot = document.getElementById("rightcolumn");
		if (navRoot != null)
		{
			for (i=0; i< navRoot.childNodes.length; i++) 
			{
				node = navRoot.childNodes[i];
				if (node.nodeName=="A") 
				{
					for (a=0; a< node.childNodes.length; a++) 
					{
						childnode = node.childNodes[a];
						if (childnode.className == "rollover") 
						{
							childnode.onmouseover = function() 
							{
								this.src = this.src.replace(".gif", "%20hover.gif");
							}
							
							childnode.onmouseout = function() 
							{
								this.src = this.src.replace("%20hover.gif", ".gif");
							}
						}
					}
				}
			}
		}	
	}
}

function JSFnThumbnailClick()
{
	// Hide all other images
	var aImageToHide = '';
	for (aIndex = 0; aIndex < aArrayOfPhotos.length; aIndex++)
	{
		aImageToHide = document.getElementById(aArrayOfPhotos[aIndex]);
		if (aImageToHide != null) aImageToHide.style.display = 'none';
	}
	
	// Show the relevant image
	var aHashPosition = this.href.indexOf("#");
	var aLengthOfLink = this.href.length;
	var aLinkTarget = this.href.substring(aHashPosition + 1,aLengthOfLink);
	var aImageToShow = document.getElementById(aLinkTarget);
	if (aImageToShow != null) aImageToShow.style.display = 'block';
	
	// Override the link
	return false;
}

function JSFnShowSubMenu()
{
	var subitems = this.getElementsByTagName("li");
	for (aIndex = 0; aIndex < subitems.length; aIndex++)
	{
		subitems[aIndex].style.display = 'block';
	}
}

function JSFnHideSubMenu()
{
	var subitems = this.getElementsByTagName("li");
	for (aIndex = 0; aIndex < subitems.length; aIndex++)
	{
		subitems[aIndex].style.display = 'none';
	}
}