name="MSPGP";
home=name+":  Math & Science Partnership of Greater Philadelphia";
teachers="Future Teachers"+" < "+name;
about="About "+name;
partners="Partners"+" < "+name;
contact="Contact "+name;

function email() {
  var a=email.arguments;
  if (a[1]) { window.location="mailto:"+a[0]+"@"+a[1]; } 
  else { window.location="mailto:"+a[0]+"@mspgp.org"; }
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i< a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.pics) d.pics=new Array(); 
    var i,j=d.pics.length,a=preloadImages.arguments;
	d.onoffhere=new Array(); 
	for(i=0; i< a.length; i++) {
	   d.onoffhere[0]=a[i]+"_on.gif";
	   d.onoffhere[1]=a[i]+"_off.gif";
	   d.onoffhere[2]=a[i]+"_here.gif";
       for (k=0; k<3;k++){ 
	   		d.pics[j]=new Image; 
			d.pics[j++].src=d.onoffhere[k];
	   }
	}}
}

/*
function preload_onImages() { //v3.0
  var d=document; if(d.images){ for(i=0; i< d.images.length; i++)
    if (!d.images[i].name){ d.pics=new Image; d.pics.src="images/"+d.images[i].name+"_on.gif";}}
}
*/

function findObj(n) { //v3.0
  var pics,i,x,d=document; 
  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=findObj(n,d.layers[i].document); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; 
   for(i=0;a&&i< a.length&&(x=findObj(a[i]));i++) {document.sr[j++]=x; x.oSrc=x.src; x.src="images/"+a[i]+"_on.gif";} 
}

function swapImagetch() { //v3.0
  var i,j=0,x,a=swapImagetch.arguments; document.sr=new Array; 
   for(i=0;a&&i< (a.length-1)&&(x=findObj(a[i]));i++) {
        document.sr[j++]=x; x.oSrc=x.src; x.src="images/"+a[i]+"_on.gif";} 
        x=findObj('tch_lr');document.sr[j++]=x; x.oSrc=x.src; x.src="images/tch_lr_"+a[i]+".gif";   
}

function swapImagej() { //v3.0
  var i,j=0,x,a=swapImagej.arguments; document.sr=new Array; 
   if ((x=findObj(a[0]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src="images/"+a[0]+"_on.jpg";} 
}

function swapImageb() { //v3.0
  var i,j=0,x,a=swapImageb.arguments; document.sr=new Array; 
   if ((x=findObj(a[0]+"_b"))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src="/images/"+a[0]+"_on.gif";} 
}

function swapImagea() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; 
   for(i=0;a&&i< a.length&&(x=findObj(a[i]));i++) {document.sr[j++]=x; x.oSrc=x.src; x.src="/images/arrow2.gif";} 
}

document.pics=new Array();

function winstat() {
  if(winstat.arguments[0]) {window.defaultStatus=winstat.arguments[0];} else {window.defaultStatus=pagename;}
return true; }


function setYou(f) {
   f.your_name.value=f.name.value;
   f.your_phone.value=f.phone.value;
   f.your_email.value=f.email.value;
   f.your_title.value=f.title.value;
}

function resetYou(f) {
		f.your_name.value="";
		f.your_phone.value="";
		f.your_email.value="";
		f.your_title.value="";
}

var global_form_elt;

function setfocus() {
	global_form_elt.focus();
}

function flag(fid,s) {
    document.getElementById(fid).className='ALLFORM'+s+'f';
    setTimeout('setfocus()',10);
}

function unflag(fid,s) {
    document.getElementById(fid).className='ALLFORM'+s;
}

function rflag(fid,s) {
    document.getElementById(fid).className='rating'+s+'f';
    setTimeout('setfocus()',10);
}

function runflag(fid,s) {
    document.getElementById(fid).className='rating'+s;
}

function isValidEmail(str) {
   return (str.indexOf("@") > 0) && (str.indexOf(".",str.indexOf("@"))>0) && (str.indexOf(" ")==-1)
          && (str.indexOf(".",str.length-1)==-1) ;
}

function ValidEmail(form_elt) {
   form_elt.value=form_elt.value.replace("INVALID EMAIL:","");
   form_elt.value=form_elt.value.replace(" ","");
   
   if (!isValidEmail(form_elt.value)) {
      alert (form_elt.value+" does not appear to be a valid email. Please double check the entry.");
      global_form_elt=form_elt;
      flag(form_elt.id,'');
   } else { unflag(form_elt.id,''); }
}

function isWholeNumber(str) {
   var ValidChars = "0123456789";
 
   for (i = 0; i < str.length; i++) { 
      if (ValidChars.indexOf(str.charAt(i)) == -1) {
         return false;
      }
   }
   
   if (str =="") { return false; }
   
   return true;
}

function WholeNumber(form_elt,val) {
  if(!isWholeNumber(form_elt.value)) {
      alert ("This entry needs to be a whole number. Please double check the entry.");
      global_form_elt=form_elt;
      flag(form_elt.id,'');
   } else if (val==0) {
      unflag(form_elt.id,'');
   } else if (form_elt.value>val) {
	  alert ("This entry is too large. If this is a legitimate entry, please email us.");
	  global_form_elt=form_elt;
	  flag(form_elt.id,'');
   } else {
	  unflag(form_elt.id,''); 
   }
}
  

function isPercentNumber(str) {
   var ValidChars = "0123456789.";
 
   for (i = 0; i < str.length; i++) { 
      if (ValidChars.indexOf(str.charAt(i)) == -1) {
         return false;
      }
   }
   
   if (str<0 || str>100) { return false; }
   
   return true;
}

function PercentNumber(form_elt,s) {
  var alpha="abcdefghijklmnopqrstuvwxyz";
  if (alpha.indexOf(s) == -1) { s=''; }
  var newform_elt_value=form_elt.value.replace("%","");
  if(newform_elt_value != form_elt.value) {form_elt.value=newform_elt_value; PercentNumber(form_elt); }
  if(!isPercentNumber(form_elt.value)) {
      alert ("This entry needs to be a decimal number between 0 and 100. Please double check the entry.");
      global_form_elt=form_elt;
      flag(form_elt.id,s);
   } else { unflag(form_elt.id,s); }
}
  

function isDecimalNumber(str) {
   var ValidChars = "0123456789.";
 
   for (i = 0; i < str.length; i++) { 
      if (ValidChars.indexOf(str.charAt(i)) == -1) {
         return false;
      }
   }
   
   return true;
}

function DecimalNumber(form_elt) {
  if(!isDecimalNumber(form_elt.value)) {
      alert ("This entry needs to be a decimal number. Please double check the entry.");
      global_form_elt=form_elt;
      flag(form_elt.id,'');
   } else { unflag(form_elt.id,''); }
}
  
function Digits(form_elt) {
  if(!isWholeNumber(form_elt.value)) {
      alert ("This entry should consist only of numbers. Please double check the entry.");
      global_form_elt=form_elt;
      flag(form_elt.id,'');
   } else { unflag(form_elt.id,''); }
}
  
function NotEmpty(form_elt,s) {
  if(form_elt.value=="") {
      alert ("This entry should not be left blank.");
      global_form_elt=form_elt;
      flag(form_elt.id,s);
   } else { unflag(form_elt.id,s); }
}
  
function NotNone(form_elt,s) {
  if(form_elt.value=="none") {
      alert ("Please make a selection.");
      global_form_elt=form_elt;
      flag(form_elt.id,s);
   } else { unflag(form_elt.id,s); }
}
    
function NotChoose(form_elt,s) {
  if(form_elt.value=="Choose your school") {
      alert ("Please make a selection.");
      global_form_elt=form_elt;
      flag(form_elt.id,s);
   } else { unflag(form_elt.id,s); }
}
    
function checkOther(form_elt1,form_elt0) {
    var ok=false;
    var alphanumeric="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var l=alphanumeric.length;
    var val=form_elt1.value;
    for(j=0; j<l; j++) {
        if (val.indexOf(alphanumeric.charAt(j)) > -1 ) { ok=true; break; }
    }
	if (ok) { 
		form_elt0.checked=true; 
		unflag(form_elt1.id,''); 
	} else {
	 	if (form_elt0.checked == true) {
	 		alert ("If you check this course box, then you must supply a name or list of names for the course you mean in this category.");
	 		global_form_elt=form_elt1;
	 		flag(form_elt1.id,'');
	 	} 
	}
}

function uncheckOther(form_elt0,form_elt1) {
	if (form_elt0.checked != true) { 
		form_elt1.value=''; 
		unflag(form_elt1.id,'');
	} 
}

function toggle2(form_elt,divid) {
   switch(document.getElementById(divid).style.display) {
	case 'none':
		document.getElementById(divid).style.display = 'block';
		document.getElementById(divid+'_open').style.display = 'none';
		document.getElementById(divid+'_close').style.display = 'inline';
		form_elt.value='open';
	break;
	case 'block':
		document.getElementById(divid).style.display = 'none';
		document.getElementById(divid+'_open').style.display = 'inline';
		document.getElementById(divid+'_close').style.display = 'none';
		form_elt.value='closed';
	break;
	}
}

function toggle_def(divid) {
   switch(document.getElementById(divid+'_def').style.display) {
	case 'block':
		document.getElementById(divid+'_show').style.display = 'block';
		document.getElementById(divid+'_def').style.display = 'none';
	break;
	case 'none':
		document.getElementById(divid+'_show').style.display = 'none';
		document.getElementById(divid+'_def').style.display = 'block';
	break;
	}
}

function isValidDate(str) {

   var ValidDateArray=new Array;
   ValidDateArray[0] = "01";
   ValidDateArray[1] = "0123456789";
   ValidDateArray[2] = "/";
   ValidDateArray[3] = "0123";
   ValidDateArray[4] = "0123456789";
   ValidDateArray[5] = "/";
   ValidDateArray[6] = "0";
   ValidDateArray[7] = "456";
   
 
   for (i = 0; i <= 7; i++) { 
      if (ValidDateArray[i].indexOf(str.charAt(i)) == -1) {
         return false;
      }
   }
   
   return true;
}


function ValidDate(form_elt) {
   if (!isValidDate(form_elt.value)) {
      alert (form_elt.value+" does not appear to be a valid date. Please enter dates in the form mm/dd/yy.");
      global_form_elt=form_elt;
      flag(form_elt.id,'');
   } else { unflag(form_elt.id,''); }
}

function Lower(form_elt,val1,val2) {
  if(!isWholeNumber(form_elt.value)) {
      alert ("This entry needs to be a whole number. Please double check the entry.");
      global_form_elt=form_elt;
      flag(form_elt.id,'');
   } else if ((val2==0) && (form_elt.value>=val1)) {
      unflag(form_elt.id,'');
   } else if (form_elt.value<val1) {
	  alert ("Be aware that this is lower than the original entry. Reducing it here will delete the last entry or entries of information submitted in later parts of the questionnaire.");
      unflag(form_elt.id,'');
   } else if (form_elt.value>val2) {
	  alert ("This entry is too large. If this is a legitimate value, please email us.");
	  global_form_elt=form_elt;
	  flag(form_elt.id,'');
   } else {
	  unflag(form_elt.id,''); 
   }
}
  

function allDel(id,form_elt) {
   del=confirm("Are you sure you want to delete this row of data? This cannot be undone.");
   if(del) { 
      document.getElementById(id).style.display = 'none';
	  form_elt.value="DELETED";
   }
}

function newDel(new_num,ms,form_elt) {
   del=confirm("Are you sure you want to delete all information about this teacher? This cannot be undone.");
   if(del) {       
      document.getElementById('new_'+ms+'_1_'+new_num).style.display = 'none';
      document.getElementById('new_'+ms+'_2_'+new_num).style.display = 'none';
      document.getElementById('new_'+ms+'_3_'+new_num).style.display = 'none';
      document.getElementById('new_'+ms+'_4_'+new_num).style.display = 'none';
	  form_elt.value="DELETED";
   }
}

function Saving() {
	if(submitted) {
		document.getElementById('submit1').style.display = 'none';
		document.getElementById('submit2').style.display = 'none';
		document.getElementById('saving1').style.display = 'inline';
		document.getElementById('saving2').style.display = 'inline';
	}
	
	return submitted;
}


function isValidRating(str) {
   var ValidNumbers0 = "0";
   var ValidNumbers1 = "1";
   var ValidNumbers4 = "01234";
   var ValidNumbers5 = "012345";   
   var ValidNumbers6 = "0123456";
   var ValidNumbers9 = "0123456789";
   return (((ValidNumbers0.indexOf(str.charAt(0))!= -1) && (ValidNumbers9.indexOf(str.charAt(1))!=-1) && (ValidNumbers9.indexOf(str.charAt(2))!=-1)) ||
   			((ValidNumbers1.indexOf(str.charAt(0))!= -1) && (ValidNumbers4.indexOf(str.charAt(1))!=-1) && (ValidNumbers9.indexOf(str.charAt(2))!=-1)) ||
			  ((ValidNumbers1.indexOf(str.charAt(0))!= -1) && (ValidNumbers5.indexOf(str.charAt(1))!=-1) && (ValidNumbers6.indexOf(str.charAt(2))!=-1)));
}

function ValidRating(form_elt) {
   form_elt.value=form_elt.value.replace(" ","");
   if (form_elt.value.length == 2) { form_elt.value="0"+form_elt.value; }
   if (form_elt.value.length == 1) { form_elt.value="00"+form_elt.value; }
   
   if (!isValidRating(form_elt.value)) {
      alert (form_elt.value+" does not appear to be a valid choice. Please double check the entry.");
      global_form_elt=form_elt;
      rflag(form_elt.id,'');
   } else { runflag(form_elt.id,''); }
}


function jumpNext(field,next) {
	if (field.value.length == 3) { field.form.elements[next].focus(); }
}

function scrollchange(scrollkind,oldcode,newcode) {
      document.getElementById('scrollbox_'+scrollkind+oldcode).className = 'scrollbox_'+scrollkind+newcode;
}

	   