var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

function validForm(){
	//alert(document.contactus.elements.length);
	for(i=0; i<document.contactus.elements.length; i++)
	{
		if(trim(document.contactus.elements[i].value) == "" && document.contactus.elements[i].className == "required"){
			alert(document.contactus.elements[i].alt + " is a required field.")
			document.contactus.elements[i].focus(); 
			return false
		}
		if((document.contactus.elements[i].name == "email" && document.contactus.elements[i].className == "required") && !isEmailValid(trim(document.contactus.elements[i].value))){
			alert("Please enter a valid E-mail address.");
			document.contactus.elements[i].focus(); 
			return false
		}
	}
	return true;
}

function isEmailValid(val){
		var atPos = val.indexOf('@',0);
		// must contain an @
		if (atPos == -1) { return false; }
 		// must not start with @
		if (atPos == 0) { return false;	}
		// must contain only one @
		if (val.indexOf('@', atPos + 1) > - 1) { return false; }
		// must contain a period in the domain name
		if (val.indexOf('.', atPos) == -1) { return false; }
		// period must not immediately follow @ in email address
		if (val.indexOf('@.',0) != -1) { return false; }
		// period must not immediately precede @ in email address
		if (val.indexOf('.@',0) != -1){ return false; }
		// must not have 2 periods one after another
		if (val.indexOf('..',0) != -1) { return false; }
		// must have a valid primary domain in the email address
		var suffix = val.substring(val.lastIndexOf('.')+1);
		if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {return false;}
		return true;
	}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function stopRKey(evt) {
   var evt = (evt) ? evt : ((event) ? event : null);
   var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

document.onkeypress = stopRKey;