var imgwidth = 121;
var	currMenu=-1;
var id = 0;
var mytimeout;

	function info(id) {
		clearTimeout(mytimeout);
		var c = getObj("left_nav_container");
		var o = getObj("menu"+id);
		var obj = getObj("item"+id);
		var os = getStyleObj(o);
	    if (document.getElementById || document.all) {
			//mac ie kludge
	    	if (navigator.appVersion.indexOf("MSIE") > -1 && navigator.appVersion.indexOf("Mac") > -1) {
		  		os.top = offsetTop(obj) - offsetTop(c); 
	    	} else {
				os.top = offsetTop(obj);
	    	}
			os.left = offsetLeft(obj) + imgwidth;
		}
		os.visibility = "visible";
		currMenu = id;
	}

	
	function clearme() {
		if (currMenu != -1) {
			clearTimeout(mytimeout);
			var o = getObj("menu"+currMenu);
			var os = getStyleObj(o);
			os.visibility = "hidden";
			currMenu=-1;
		}
	}

function clearmenus() {
	clearTimeout(mytimeout);
	mytimeout = setTimeout("clearme()", 500);
}


function offsetTop(o){
    var i = 0;
    while (o.offsetParent!=null) {
        i += o.offsetTop;
        o = o.offsetParent;
    }
    return i + o.offsetTop;
}
function offsetLeft(o){
    var i = 0;
    while (o.offsetParent!=null) {
        i += o.offsetLeft;
        o = o.offsetParent;
    }
    return i + o.offsetLeft;
}

function getObj(theId) {
    if (document.getElementById) {
        theObj = document.getElementById(theId); 
    } else if (document.all) { 
        theObj = document.all[theId];
    } else {
    	theObj = document.layers[theId];
    }
    return theObj;
}

function getStyleObj(o) {
    if (document.getElementById || document.all) { 
        return o.style;
    } else {
    	return o;
    }
}

function BrowserIsNotIE5() {
    var browser=navigator.appName;
    var version=navigator.appVersion;
    var isNotIE5 = true;
    if (browser.indexOf("Microsoft") >= 0 ) {
      if (version.indexOf("MSIE 5.0") != -1) {
        isNotIE5 = false;
      }
   }
   return isNotIE5;
}

function popUpDialogResizeable(name,url){
sealWin=window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=700,height=525');
if (BrowserIsNotIE5() && sealWin != null ) {
  sealWin.focus();
}
}

function Trim(s) {
   	          // Remove leading spaces and carriage returns
  	          while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || 
  	           (s.substring(0,1) == '\r')) {
   	           s = s.substring(1,s.length); }     
   	         // Remove trailing spaces and carriage returns
                  while ((s.substring(s.length-1,s.length) == ' ') || 
       (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')){
                   s = s.substring(0,s.length-1);
                }    
   	           return s;
                }
                
                function validEmail(str) {
                  //alert("validEmail :"+str);
		  var at="@"
		  var dot="."
		  var lat=str.indexOf(at)
		  var lstr=str.length
		  var ldot=str.indexOf(dot)
		  if (str.indexOf(at)==-1){
		    //alert("Invalid E-mail ID")
		    return false
		  }
		  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		     //alert("Invalid E-mail ID")
		     return false
		  }
		  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		     //alert("Invalid E-mail ID")
		     return false
		  }
		  if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		  }
		  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		  }
		  if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		  }		
		  if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		  }
 		  return true					
	       }
              
		function CheckFormSubmit(form) {
		        //alert("check form submit"+form.fromName.value);
			//if(document.docForm.body.value!='') 			       
			if(form.fromName.value=='') {
				alert("Please enter your name.");
				document.docForm.fromName.focus();
				return false;
			}
			if(Trim(form.fromEmail.value)=='') {
				alert("Please enter your email address.");
				document.docForm.fromEmail.focus();
				return false;
			}
			else if (!validEmail(Trim(document.docForm.fromEmail.value))) {
				alert("Your email address is invalid.");
				document.docForm.fromEmail.focus();
				document.docForm.fromEmail.select();
				return false;
			}
			
			if(Trim(document.docForm.toEmail.value)=='') {
				alert("Please enter the recipient\'s email address.");
				document.docForm.toEmail.focus();
				return false;
			}
			else if (!multiEmail(Trim(document.docForm.toEmail.value))) {
				//alert("The recipient's email address is invalid.");
				document.docForm.toEmail.focus();
				document.docForm.toEmail.select();
				return false;
			}
			//alert("to email :"+document.docForm.toEmail.value);			
			return true;
		}
		
		function multiEmail(email_field) {
                   var email = email_field.split(',');
                   for (var i = 0; i < email.length; i++) {
                       if (!validEmail(Trim(email[i]))) {
                           alert('one or more email addresses entered is invalid');
                           return false;
                       }
                   }
                   return true;
                }
