function imgOn(imgName)
{
	document[imgName].src = "gui/"+ imgName + "_over.gif";
}

function imgOff(imgName)
{
	document[imgName].src = "gui/"+ imgName + ".gif"; 
}

//only for maintenance menu "save" and "delete" buttons
function imgOnM(img, ID, bEdit)
{
	var sPrefix = "";
	if (bEdit)
	{
		sPrefix = "../";
	}
	document.getElementById(img + ID).src = sPrefix + "gui/" + img + "_i.gif";
}


function imgOffM(img, ID, bEdit)
{
	var sPrefix = "";
	if (bEdit)
	{
		sPrefix = "../";
	}
	document.getElementById(img + ID).src = sPrefix + "gui/" + img + "_o.gif";
}


function debug(name, value)
{
	alert(name + " : " + value);
	return false;
}

function NotAvailable()
{
}

// Cross-browser function to add a function to the onload event.
function AddOnload(myfunc)
{

	if(window.addEventListener)	// FireFox
	{
		window.addEventListener('load', myfunc, false);
	}
	else if(window.attachEvent)	// IE
	{
		window.attachEvent('onload', myfunc);
	}
	else if (window.onload)
	{
		var func = window.onload; 
		window.onload = function()
		{
			func();
			myfunc();
		}
	}
	else
	{
		window.onload = myfunc();
	}
}


// The hover function:
//  If there is a child sub-menu, show it on mouseover, hide it on mouseout!
var sfHover = function()
{
	var menu = document.getElementById("nav");
	if (!menu)
	{
		return;
	}
	var listItems = menu.getElementsByTagName("LI");
	for (var i = 0; i < listItems.length; i++)
	{
		listItems[i].onmouseover = function()
		{
			if (this.getElementsByTagName("UL").length > 0)
			{
				// Show the sub-menu
				this.getElementsByTagName("UL").item(0).style.display = "block";
			}
		}
		listItems[i].onmouseout = function()
		{
			if (this.getElementsByTagName("UL").length > 0)
			{
				// Hide the sub-menu
				this.getElementsByTagName("UL").item(0).style.display = "none";
			}
		}
	}
}

AddOnload(sfHover); // Activate the menus when the page loads...


function activeNav(sActivePageID)
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

	switch(sPage)
	{
		case "index.shtml":
			var sActivePageID = "NavHome";
			break;
		case "about.shtml":
			var sActivePageID = "NavAbout";
			break;
		case "showcase.shtml":
			var sActivePageID = "NavShowcase";
			break;
		case "carports.shtml":
			var sActivePageID = "NavCarports";
			break;
		case "verandahs.shtml":
			var sActivePageID = "NavVerandahs";
			break;
		case "testimonials.shtml":
			var sActivePageID = "NavTestimonials";
			break;
		case "contact.shtml":
			var sActivePageID = "NavContact";
			break;			
		case "":
			var sActivePageID = "NavHome";
			break;
		default:
			var sActivePageID = "";
			break;
	}
	
	if((sActivePageID != "") && (document.getElementById(sActivePageID))) document.getElementById(sActivePageID).style.color = "#B70400";
}

function validateContactForm()
{
	if (!validatePresence(document.getElementById("cClient_Name"), "Please enter your name.")) return false;
	if (!validateEmail(document.getElementById("cClient_Email"), "Please enter a valid email address.", false)) return false;
	if (!validatePresence(document.getElementById("cClient_Enquiry"), "Please enter your enquiry.")) return false;
}
