sfHover = function() { 
	var sfEls = document.getElementById("nav").getElementsByTagName("li"); 
	for (var i=0; i<sfEls.length; i++) { 
		sfEls[i].onmouseover=function() { 
			this.className+=" sfhover"; 
		} 

		sfEls[i].onmouseout=function() { 
			this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); 
		} 
	} 
} 

if (window.attachEvent) window.attachEvent("onload", sfHover);

function CheckEmailForm(){

mystr = document.emailArticle.mailTo.value;
varArr = new Array();
varArr = mystr.split(";");

for (j=0; j<=varArr.length-1; j++){
     
     if(!ValidEmail(varArr[j]))
     {strMsg = "The Colleague email address you typed is invalid.";            
     alert(strMsg);
     document.emailArticle.mailTo.focus();
     return false;
     }
}

if (!ValidEmail(document.emailArticle.mailFrom.value))
   {strMsg = "The email address you typed as yours is invalid.";            
    alert(strMsg);
    document.emailArticle.mailFrom.focus();
    return false;
   }

addRefPage();
}

function ValidEmail(email) {

var invalidChars = " /:,;";
var invalidChar;

if (email == "") {
   return false;
}

for (i=0; i<invalidChars.length; i++) {
     invalidChar = invalidChars.charAt(i)
     if (email.indexOf(invalidChar,0) != -1) {
         return false;
     }
     }
     atPos = email.indexOf("@",1)
     if (atPos == -1) {
        return false;
     }
     if (email.indexOf("@",atPos+1) != -1) {
        return false;
     }
     periodPos = email.indexOf(".",atPos)
     if (periodPos == -1) {
        return false;
     }
     if (periodPos+3 > email.length) {
        return false;
     }       

     return true;
}

function addRefPage() {
     var loc = "" + location
     if (loc.indexOf("&refPage") == -1) 
     return  
     var ref = loc.substring( loc.indexOf("&refPage=") + 9, loc.length );
     document.emailArticle.refPage.value = ref;
     return true;}


function checkSearch() 
{ 
  if (document.SearchForm.text.value == "")
  {
    window.alert("Please enter a text value to be searched for.");
    return false;
  }

  document.SearchForm.text.value = trim(document.SearchForm.text.value.toLowerCase());
  return true;
 
}

function trim(psText) 
{
	psText = psText.replace(/^[\s]+/g,"");
	psText = psText.replace(/[\s]+$/g,"");
	return psText;
}


function AddCommas(num){
// Check to see if the number needs any commas
num = num + '';
if (num.length > 3) {
// Figure out how many commas need to go in
var count;
var numcommas;

count = 0;
numcommas = 0;
while (count < num.length) {
count = count + 3;
if (count < num.length) {
numcommas = numcommas + 1;
}
}

// Put the commas in.
var NewNumber;
var TempNumber;

count = 0;
TempNumber = num;
NewNumber = '';
for(count = 0; count < numcommas; count++) {
NewNumber = ',' + TempNumber.substring(TempNumber.length - 3,TempNumber.length) + NewNumber;
TempNumber = TempNumber.substring(0, TempNumber.length - 3);
}
NewNumber = TempNumber + NewNumber;
document.write(NewNumber);
} else {
// Number is less then 3 and doesnt need any commas.
// Just print the number.
document.write(num);
}
}

function urlMenu(that) {
	theURL = that.options[that.selectedIndex].value; 
	if (theURL) {
		window.location = theURL;
	}
}

function CheckForm(ThisForm)
{
var x;
var count;
var vertnum;
var temp;
        
	if (ThisForm.mailFrom.value == "")
	{
		alert("Email address is required.");
		ThisForm.mailFrom.focus();
		return false;
	}
	else if (!ValidEmail(ThisForm.mailFrom.value)) 
	{
		strMsg = "The Email address you typed is invalid.";		
		alert(strMsg);
		ThisForm.mailFrom.focus();
      return false;
	}

	if (ThisForm.mail_FirstName.value == "")
	{
		alert("Your first name is required.");
		ThisForm.mail_FirstName.focus();
		return false;
	}

	if (ThisForm.mail_LastName.value == "")
	{
		alert("Your last name is required.");
		ThisForm.mail_LastName.focus();
		return false;
	}


	if (ThisForm.mail_Company.value == "")
	{
		alert("Your Company is required.");
		ThisForm.mail_Company.focus();
		return false;
	}
	
	if (ThisForm.mail_Country.value == "")
	{
		alert("Your Country is required.");
		ThisForm.mail_Country.focus();
		return false;
	}

	if (ThisForm.mail_Event.value == "")
	{
		alert("Event is required.");
		ThisForm.mail_Event.focus();
		return false;
	}

	
	if (ThisForm.mail_Description.value == "")
	{
		alert("Description is required.");
		ThisForm.mail_Description.focus();
		return false;
   }
   
   if ((ThisForm.mail_StartDate.value == "")||(ThisForm.mail_StartDate.value == "mm/dd/yyyy"))
	{
		alert("Start Date is required.");
		ThisForm.mail_StartDate.focus();
		return false;
   }
   else if (!CheckDate(ThisForm.mail_StartDate.value)) 
	{
		strMsg = "The start date is invalid. (format should be MM/DD/YYYY)";		
      alert(strMsg);
		ThisForm.mail_StartDate.focus();
      return false;
	}

   if ((ThisForm.mail_EndDate.value == "")||(ThisForm.mail_EndDate.value == "mm/dd/yyyy"))
	{
		alert("End Date is required.");
		ThisForm.mail_EndDate.focus();
		return false;
	}
   else if (!CheckDate(ThisForm.mail_EndDate.value)) 
	{
		strMsg = "The end date is invalid. (format should be MM/DD/YYYY)";	
		alert(strMsg);
		ThisForm.mail_EndDate.focus();
      return false;
	}
	
	ToDay = new Date();
	month1 = ToDay.getMonth()+1;
	day1   = ToDay.getDate();
	if (month1 < 10) month1 = '0'+month1;
        if (day1 <10) day1 = '0'+day1;
	var TodayDate = month1 + '/' + day1 + '/' + ToDay.getFullYear();
	if ( !CheckDiffDate(TodayDate,ThisForm.mail_StartDate.value) )
	{
		strMsg = "You entered a start date which is earlier than today's date";	
		alert(strMsg);
		ThisForm.mail_StartDate.focus();
      return false;
	}
	

	if (!CheckDiffDate(ThisForm.mail_StartDate.value,ThisForm.mail_EndDate.value) )
	{
		strMsg = "You entered an end date which is earlier than the start date";	
		alert(strMsg);
		ThisForm.mail_EndDate.focus();
      return false;
	}
}

function CheckDate(sDate) 
{
	var flag;
	var dYear = (new Date());
	var splitString = sDate.split("/");
	var MM = splitString[0];
	var DD = splitString[1];
	var YY = splitString[2];

	dYear = dYear.getYear();
	flag = 1;
   if ((typeof(MM) == 'undefined') || (typeof(DD) == 'undefined') || (typeof(YY) == 'undefined')) {return false;} 

	if (MM.length !== 2) {return false;}
	if (DD.length !== 2) {return false;}
	if (YY.length !== 4) {return false;}
	if ( isNaN(MM) || isNaN(DD) || isNaN(YY) ) {return false;}
	if ( MM.charAt(0) == '0' ) { MM = MM.substring(1,2); }
	if ( DD.charAt(0) == '0' ) { DD = DD.substring(1,2); }
	
	var IntMM = parseInt(MM);
	var IntDD = parseInt(DD);
	if (IntDD > 0)
	{
		if (IntDD < 29) 
			{flag = 0;}
		else if ( ( IntMM==1 || IntMM==3 || IntMM==5 || IntMM==7 || IntMM==8 || IntMM==10 || IntMM==12 ) && IntDD<32 ) 
			{flag = 0;}
		else if ( ( IntMM==4 || IntMM==6 || IntMM==9 || IntMM==11 ) && IntDD<31 ) 
			{flag = 0;}
		else if ( IntMM==2 && parseInt(YY / 4) == parseFloat(YY / 4) && IntDD==29 ) {flag = 0;}
	}
	if (flag == 1) {return false;}
	return true;   
}


function CheckDiffDate(sDate,eDate) 
{
	var splitString = sDate.split("/");
	var Start = splitString[2] + splitString[0] + splitString[1];
	splitString = eDate.split("/");
	var End = splitString[2] + splitString[0] + splitString[1];
	
	if ( Start>End ) {return false;}
	return true;
}


function ValidEmail(emailin) {
	var invalidChars = " /:,;";
	var invalidChar;
	if (emailin == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		invalidChar = invalidChars.charAt(i)
		if (emailin.indexOf(invalidChar,0) != -1) {
			return false;
		}
	}
	atPos = emailin.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (emailin.indexOf("@",atPos+1) != -1) {
		return false;
	}
	periodPos = emailin.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > emailin.length)	{
		return false;
	}
	return true;					
}

