function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('MainImage').src = whichpic.href;
  document.location.href = "#top"
  return false;
 } else {
  return true;
 }
}


function clearEmail() {
 if (document.EmailToFriend.FriendEmail.value == '<%=strFriendEmail%>') {
	document.EmailToFriend.FriendEmail.value = '';
 }
}



function showSubjects(iShow){
	if (iShow==1){
		document.getElementById("subjButton").src='/images/subjOn.gif';
		DoShow('SubjectPicker');
	}else{
		document.getElementById("subjButton").src='/images/subjOff.gif';
		DoHide('SubjectPicker');
	}
}
function lightHome(iShow){
	if (iShow==1){
		document.getElementById("nav1").src='/images/nav/nav1_on.gif';
	}else{
		document.getElementById("nav1").src='/images/nav/nav1_off.gif';
	}
}
function showGrades(iShow){
	if (iShow==1){
		document.getElementById("gradeButton").src='/images/gradeOn.gif';
		DoShow('GradePicker');
	}else{
		document.getElementById("gradeButton").src='/images/gradeOff.gif';
		DoHide('GradePicker');
	}
}
function showThisDiv(iShow,divID){
	if (iShow==1){
		DoShow(divID);
	}else{
		DoHide(divID);
	}
}


function passWindow(){

	newWindow=window.open("/lostpassword.asp", "PassWindow", "toolbar=no,status=no,location=no,menubar=no,left=15,top=220,width=550,height=165,scrollbars=yes,resizable=yes");
	newWindow.focus();
}

function passWindowP(){

	newWindow=window.open("/lostpasswordp.asp", "PassWindow", "toolbar=no,status=no,location=no,menubar=no,left=15,top=220,width=550,height=165,scrollbars=yes,resizable=yes");
	newWindow.focus();
}



function doEmailFriend(){

 if (document.EmailToFriend.FriendEmail.value == '<%=strFriendEmail%>'||document.EmailToFriend.FriendEmail.value == ''||!isEmail(document.EmailToFriend.FriendEmail.value)) {
	alert('Please enter a valid e-mail address!');
	 }
	else
	{
	newWindow=window.open("/blank.asp", "EmailWindow", "toolbar=no,status=no,location=no,menubar=no,left=15,top=220,width=500,height=325,scrollbars=yes,resizable=yes");
     
	setTimeout("document.EmailToFriend.submit()",100);
	newWindow.focus();
	}
}


function isEmail(strEmail)
{


if(strEmail.length > 4)
 {
 strEmail = strEmail.toLowerCase();
 
  var at = strEmail.indexOf("@"); 
  if((at > 1) && (at==strEmail.lastIndexOf("@")))
     {
     if ((strEmail.indexOf("@") > 1))
	  {
	   var dot = strEmail.lastIndexOf(".");
	   if ((dot>4) && ((dot-at)>2) && ((strEmail.length-dot)>2))
		   {
		    return true; // valid!
		   }
	  }  
    }
 }
 return false;
}




function goTo(page){
//	document.location.href = page;
//	return;
}





function DoShow(div){
    obj = document.getElementById(div).style;
    obj.display='block';
}


function DoHide(div){
    obj = document.getElementById(div).style;
    obj.display='none';
}


	function switchPage(thisURL){
		if (!isBlank(thisURL)){
			location.href=thisURL;
		}
	}
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}



function submitContactForm(){

    var errMessage = '';

// required field:

      if (isBlank(document.MyContact.YourName.value)){
        errMessage = errMessage + 'Name is required\n';
    }
      if (isBlank(document.MyContact.Email.value)){
        errMessage = errMessage + 'Email is required\n';
    }
  	if (!isEmail(document.MyContact.Email.value)){
		errMessage = errMessage + 'Email Address is not valid.\n';
	}  

      if (isBlank(document.MyContact.Subject.value)){
        errMessage = errMessage + 'Subject is required.\n';
    }
      if (isBlank(document.MyContact.Comments.value)){
        errMessage = errMessage + 'Message is required.\n';
    }

    //print out errors or submit        
    if (errMessage!=""){
        alert(errMessage);
    }
    else {
    	DoHide('SubmitButton');
    	DoShow('SubmitButtonProgress');
    	document.MyContact.submit();
    }
}



function setDatesUsed(){
	document.forms.SearchForm.DatesUsed.value='true';
}



	function DoList(sDivShow,iShow){
		//alert(sDivShow);
		var doc = document.getElementsByTagName('div');
		var sDiv = '';
		var sDivLeft15 = Left(sDivShow,15);
		for (var i = 0; i < doc.length; i++){
		   sDiv = doc[i].id;
	   		sThisDiv = sDiv;
			sThisDivLeft15 = Left(sThisDiv,15);
			if (sThisDivLeft15==sDivLeft15){
				//alert(sThisDivLeft15);
				if (iShow==1){
					document.getElementById(sDiv).style.background = '#ffffff';//'url(\'/images/calBlue.gif\') repeat-x';
				}else{
					document.getElementById(sDiv).style.background = 'none';//'url(\'/images/calBlue.gif\') repeat-x';
				}
	   		}
		}
	}
	function DoDate(sDivShow,iShow){
		//alert(sDivShow);
		var doc = document.getElementsByTagName('div');
		var sDiv = '';
		var sDivLeft14 = Left(sDivShow,14);
		for (var i = 0; i < doc.length; i++){
		   sDiv = doc[i].id;
	   		sThisDiv = sDiv;
			sThisDivLeft14 = Left(sThisDiv,14);
			if (sThisDivLeft14==sDivLeft14){
				//alert(sThisDivLeft14);
				if (iShow==1){
					document.getElementById(sDiv).style.background = '#ffffff';//'url(\'/images/calBlue.gif\') repeat-x';
				}else{
					document.getElementById(sDiv).style.background = 'none';//'url(\'/images/calBlue.gif\') repeat-x';
				}
				if (iShow==1){
					document.getElementById(sDiv).style.color='#000000';
					document.getElementById(sDiv).style.background='url(\'/images/calBlue.gif\') repeat-x';
				}else{
					document.getElementById(sDiv).style.color='#ffffff';
					document.getElementById(sDiv).style.background='url(\'/images/calGreen.gif\') repeat-x';
				}
	   		}
		}
	}

        function Left(str, n)
        {
                if (n <= 0)     // Invalid bound, return blank string
                        return "";
                else if (n > String(str).length)   // Invalid bound, return
                        return str;                // entire string
                else // Valid bound, return appropriate substring
                        return String(str).substring(0,n);
        }
        
        function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                   return "";
                else if (n > String(str).length)   // Invalid bound, return
                   return str;                     // entire string
                else { // Valid bound, return appropriate substring
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }


// -->