function sub_menu(which){ //nav functionality for each time an event happens (page load or mouseover) // which is equivalent to the top menu 'a' tag id
	$("#nav #sub_menu div").css("display", "none");//make sure every sub menu is hidden
	$("#top_menu ul li a").removeClass("over");//make sure every top menu link (a tag) has no "over" class
	$("#sub_"+which).css("display", "block");//show the submenu of the 'which' link
	$("#"+which).addClass("over");//add the 'over' class to the top menu links (text turns blue)
}
$(document).ready(function() {//first thing after DOM load
	var menu = ($("#banner").text().toLowerCase()).replace(/\s+/g,'_');//to see what page it is it looks at the text in #banner and replaces spaces with '_'
	if (menu.charAt(0) == "_"){	sub_menu("menu"+menu.substring(0, menu.length-1));}//IE returns no underscore before the text so...
	else {sub_menu("menu_"+menu.substring(0, menu.length-1));}//FF returns an underscore before the text so...
	$("#top_menu ul li a").mouseover(function(){sub_menu($(this).id());}); //add a mouseover event to each top menu link (send id to sub_menu())
	$("#section_side a").click(function(){$("#section_side div").toggle(400);return false;});//add onclick event to 'get in touch..' link (show/hide the div below it)
	$("#section_side form").submit(function(){return checkContactForm();});//add event to the side contact form. Run validation function
	if (jQuery.browser.msie ){$("object").each(function() {this.outerHTML = this.outerHTML;});}//if the browser is ie redwrite the object tags to circumvent click to activate
});
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkContactForm() { 
	var msg = "Please complete the following fields:\n";
	if ($("#name").val() == ""){msg=msg + "Name\n"; }
	if ($("#company").val() == ""){msg=msg + "Company\n"}
	if ($("#position").val() == ""){msg=msg + "Position\n"}
	if ($("#email").val() == ""){msg=msg + "Email\n"}
	if ($("#telephone").val() == ""){msg=msg + "Telephone\n"}
	if ($("#details").val() == ""){msg=msg + "Project Details\n"}
	if (msg.length > 40){alert(msg);return false;}
	else {return true;}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
