function javtrim(s){
return s.replace(/^\s*(.*?)\s*$/,"$1")
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var subMnus="";
									
function showMenu(idx,li){
	var subleftoffset=((document.body.offsetWidth-954)/2)+8;
	if(document.body.offsetWidth<954)
		subleftoffset=18;
	var sublefts=new Array(4);
	sublefts[0]=subleftoffset;
	sublefts[1]=sublefts[0]+145;
	sublefts[2]=sublefts[1]+220;
	sublefts[3]=sublefts[2]+195;
	try{
		hideAllMenu();
		var dv=document.getElementById("sub"+idx);
		dv.style.left=sublefts[li];
		dv.style.top=159;
		dv.style.visibility="visible";
		if(idx==6)
			hideRightNav();
	}
	catch(e){}
}

function hideAllMenu(){
	try{
		var ar=subMnus.split(',');
		for(i=0;i<ar.length;i++){
			var dv=document.getElementById("sub"+ar[i]);
			dv.style.visibility="hidden";
		}
		showRightNav();	
	}
	catch(e){}
}

// This function checks to see if a selection was made in a checkbox group
function cbxSelectionMade(cbx){
	var isGood=false;
	if(cbx.checked){
		isGood=true;
	}
	for(i=0;i<cbx.length && !isGood;i++){
		if(cbx[i].checked){
			isGood=true;
		}
	}
	return isGood;
}


function writeHomeSwf(divName){	
	var str='<object id="homeswf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="621" height="265">';
	str+='<param name="movie" value="images/slideshow/banner.swf">';
	str+='<param name="quality" value="high">';
	str+='<param name="wmode" value="opaque">';
	str+='<param name="menu" value="false">';
	str+='<embed name="homeswf" src="images/slideshow/banner.swf" quality="high" wmode="opaque" menu="false" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="621" height="265"></embed>';
	str+='</object>';
	document.getElementById(divName).innerHTML=str;
}

// This function checks to see if all needed fields are valid for blog emailer
function validateBlogEmail(thisForm){	
	if(thisForm.from.value==""){
		alert("You must provide a name to identify who sent this link!");
		thisForm.from.focus();
		return false;
	}	
	if(thisForm.email.value==""||!isValidEmail(thisForm.email.value)){
		alert("You must provide a valid email address to send this link to!");
		thisForm.email.focus();
		return false;
	}
	
	return true;
}

// This function checks to see if all needed fields are valid for blog comment
function validateBlogComment(thisForm){	
	if(thisForm.cText.value==""){
		alert("You must provide a comment for submission!");
		thisForm.cText.focus();
		return false;
	}
	
	return true;
}

// This function is for validating BlogTitle submissions
function validateBlogTitle(thisForm){
	if(thisForm.bTitle.value==""){
		alert("You must provide a title for the blog!");
		thisForm.bTitle.focus()
		return false
	}
	if(thisForm.bText.value==''){
		alert("You must provide the first post for the blog!");
		return false
	}
	
	return true;
}

function calMinMax(thisDiv,thisBtn){	
	var dv=document.getElementById(thisDiv);
	dv.className=(dv.className=="calShrunk"?"calExpanded":"calShrunk");
	var bt=document.getElementById(thisBtn);
	bt.innerHTML=(dv.className=="calShrunk"?"<strong>+</strong>":"<strong>-</strong>");
}

function popVideo(){
	window.open("videos/playVid.html","","width=320,height=280");
	return false;
}


/*********************************************************************************/
/*              These functions are for brochure building                        */
/*********************************************************************************/
function validateBrochure(thisForm){
	if(!cbxSelectionMade(thisForm.mnuids)){
		alert("You must choose at least one item to include in the brochure!");
		return false;
	}
	
	return true;
}

function markPDF(){
	var i=0;
	var f=document.pdfForm;
	for(i=0;i<f.mnuids.length;i++){
		f.mnuids[i].checked=true;
	}
}

function unmarkPDF(){
	var i=0;
	var f=document.pdfForm;
	for(i=0;i<f.mnuids.length;i++){
		f.mnuids[i].checked=false;
	}
}
function writeSWF(dvSwf,imglist)
{
	var str='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="705" height="275" id="mainImg" align="middle">';
	str+='<param name="allowScriptAccess" value="sameDomain" />';
	str+='<param name="menu" value="false" />';
	str+='<param name="FlashVars" value="imglist='+imglist+'" />';
	str+='<param name="wmode" value="opaque" />';
	str+='<param name="allowFullScreen" value="false" />';
	str+='<param name="movie" value="mainImg.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
	str+='<embed src="mainImg.swf" quality="high" bgcolor="#ffffff" width="705" height="275" flashVars="imglist='+imglist+'" name="mainImg" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" menu="false" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str+='	</object>';
	document.getElementById(dvSwf).innerHTML=str;
}

function validateLink(thisForm){
	if(thisForm.URL.value==""){
		alert("You must select a link.");
		thisForm.URL.focus();
		return false;
	}
	
	return true;
}

function validateSubscribe(thisForm){
	
	if(thisForm.email.value==""){
		alert("You need to enter in an email.");
		thisForm.email.focus();
		return false;
	}
	var emailexp = /.*\@.*\..*/;
	if (!emailexp.test(thisForm.email.value)) {
		alert("You need to enter in a valid email.");
		thisForm.email.focus();
		return false;
	} 
	
	return true;
}

function validateFeedback(thisForm){
	
	if(thisForm.fullName.value==""){
		alert("You need to enter in your full name.");
		thisForm.fullName.focus();
		return false;
	}
	if(thisForm.email.value==""){
		alert("You need to enter in your email.");
		thisForm.email.focus();
		return false;
	}
	var emailexp = /.*\@.*\..*/;
	if (!emailexp.test(thisForm.email.value)) {
		alert("You need to enter in a valid email.");
		thisForm.email.focus();
		return false;
	} 
	
	if(thisForm.comments.value==""){
		alert("You need to enter in some comments or concerns.");
		thisForm.comments.focus();
		return false;
	}
	
	
	
	return true;
}

function validateEmail(thisForm){
	if(thisForm.fullName.value==""){
		alert("You need to enter in your full name.");
		thisForm.fullName.focus();
		return false;
	}
	if(thisForm.email.value==""){
		alert("You need to enter in your email address.");
		thisForm.email.focus();
		return false;
	}
	if(thisForm.comments.value==""){
		alert("You need to enter in your comments.");
		thisForm.comments.focus();
		return false;
	}
	return true;
}
function hideRightNav()
{
	document.getElementById('infoParents').style.display='none';
	document.getElementById('infoStudents').style.display='none';
	document.getElementById('proForms').style.display='none';
	document.getElementById('hrForms').style.display='none';
	document.getElementById('sendLink').style.display='none';
}

function showRightNav()
{
	document.getElementById('infoParents').style.display='inline';
	document.getElementById('infoStudents').style.display='inline';
	document.getElementById('proForms').style.display='inline';
	document.getElementById('hrForms').style.display='inline';
	document.getElementById('sendLink').style.display='inline';
}