// JavaScript Document

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
					if (document.getElementById("grid-state")) {
						document.getElementById("grid-state").style.visibility="hidden";
					}

					if (document.getElementById("GRE_USA_StateMap")) {
						document.getElementById("GRE_USA_StateMap").style.visibility="hidden";
					}					
					
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
					if (document.getElementById("grid-state")) {
						document.getElementById("grid-state").style.visibility="visible";
					}

					if (document.getElementById("GRE_USA_StateMap")) {
						document.getElementById("GRE_USA_StateMap").style.visibility="visible";
					}					

				}
			}
		}
	}
}
window.onload=startList;





function isValidEmail(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)

    // there is an @
    if (str.indexOf(at)==-1){
       return false
    }

    // @ in the middle
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       return false
    }

    // . in the middle
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        alert("Invalid E-mail ID")
        return false
    }

     // only one @
     if (str.indexOf(at,(lat+1))!=-1){
        return false
     }

     // . not next to @
     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false
     }

     // non-empty name after @ and before .
     if (str.indexOf(dot,(lat+2))==-1){
        return false
     }

     // no spaces
     if (str.indexOf(" ")!=-1){
        return false
     }

     return true
}


function checkForm () {
  if (document.tinyForm.emailAddress.value.length == 0)  {
      alert("Please enter your email address");
      return false;
  } else if (!isValidEmail(document.tinyForm.emailAddress.value)) {
      alert("This email address is not valid");
      return false;
  }

}
