startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("menu");
		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", "");
				}
			}
		}
	 }
}

function include(file){
  var script  = document.createElement('script');
  script.src  = file;
  script.type = 'text/javascript';
  script.defer = false;

  document.getElementsByTagName('head').item(0).appendChild(script);
}
include("/includes/js/jquery.js");

function newsletter(){
	$('#newsletter_name').bind("click",function(){
		if($(this).val() == "name"){
			$(this).val("");
		}
	}).bind("blur",function(){
		if($(this).val() == ""){
			$(this).val("name");
		}
	});
	
	$('#newsletter_email').bind("click",function(){
		if($(this).val() == "email"){
			$(this).val("");
		}
	}).bind("blur",function(){
		if($(this).val() == ""){
			$(this).val("email");
		}
	});
	
	$('#newsletter_company_name').bind("click",function(){
		if($(this).val() == "company name"){
			$(this).val("");
		}
	}).bind("blur",function(){
		if($(this).val() == ""){
			$(this).val("company name");
		}
	});
	
	$('#newsletter_button').bind("click",function(){
        var hasError = false;
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
        var email = $('#newsletter_email').val();
        var name = $('#newsletter_name').val();
        
        if(!email || !name || name == "name" || email == "email"){
        	alert("Please enter your name and email address");
        	return false;
        }
        
        if(!emailReg.test(email)){
        	alert("Please enter a valid email address");
        	return false;
        }
        
		return true;
	});
}

window.onload=function(){
	startList();
	newsletter();
}
