
<!--
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_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];}
}

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;
}

var newWin = null;

function newWindow(content, width, height, scroll, tool, menu, loc, dir, status, resize){
//	if (newWin != null)
//		newWin.close()

	newWin = window.open(content , 'newWin', 'width=' + width + ',height=' + height + ',scrollbars=' + scroll + ',toolbar=' + tool + ',menubar=' + menu + ',location=' + loc + 'directories=' + dir + ',status=' + status + ',resizable=' + resize)

	newWin.focus()

}


function scholarClick(id){
	//alert("Scholar clicked "+id.value);
	scholarID = id.value
	scholarChecked = id.checked
	//alert("scholar clicked, " +scholarID+" is checked="+scholarChecked);		
	
	if (scholarChecked){	
		addScholarToCookie(scholarID)
		//alert("Added " +scholarID+" to cookie "+document.cookie);
	
		return
	}
	else{
		deleteScholarFromCookie(scholarID)
		return
	}
}

function addScholarToCookie(id){
	var allcookies = document.cookie;
	var cookieval = "MailMe=";
	var pos = allcookies.indexOf("MailMe=");

	if ( pos != -1 ) {
   	   	var start = pos + 7;
		var end = allcookies.indexOf(";", start);
		if ( -1 == end ) {
			end = allcookies.length;
		}	

		var list = allcookies.substring(start, end);

		var items = list.split(",");
		// add id
	//	cookieval += id;  - reversed order

		// put back all other values, as long as they are not id
		for ( k = 0; k < items.length; k++ ){
			if ( items[k] == id ) continue;
			cookieval = cookieval+items[k]+",";
		}
		// add id
		cookieval += id;  
	}
	else {
	   cookieval = cookieval + id;
	} 
	//alert("Cookie is now "+cookieval);
	document.cookie = cookieval;
}

function setChecks() {
	//if (someForm == null) return true;
	//if (someForm.scholars == null ) return true;
	//if (someForm.scholars.length == null ) return true;	
	
	//alert("Checking "+ document.scholarForm.scholars.length +" checkboxes");
	
	if ( document.scholarForm.scholars == null ) return true;	

	for ( j = 0; j < document.scholarForm.scholars.length; j++ ){
		//alert("Checking "+someForm.scholars[j].value+" number "+j);
		document.scholarForm.scholars[j].checked = isChecked(document.scholarForm.scholars[j].value);
      	 }
      

}

function isChecked(id) {
	
	scholarCookie = document.cookie.split("; ")	;
		
//	alert("Is "+id+" checked ? ");
	for(i=0;i < scholarCookie.length; i++){
		if(scholarCookie[i].split("=")[0] == "MailMe"){
			//alert("yes");
			partTwo = scholarCookie[i].split("=")[1];
			if ( null == partTwo ) break;
			idList = partTwo.split(",");
			if ( null == idList ) break;
			for ( n = 0 ; n < idList.length; n ++) {
				if ( idList[n] == id) return true;		
			}
			// no more cookies will apply		
			break; 
		}
	}
//	alert("no");
	return false;
}

function deleteScholarFromCookie(id){
	//set the cookie expiration to some time in the past
	
	var allcookies = document.cookie;
	var cookieval = "MailMe=";
	var pos = allcookies.indexOf("MailMe=");

	if ( pos != -1 ) {
   	   	var start = pos + "MailMe=".length;
		var end = allcookies.indexOf(";", start);
		if ( -1 == end ) {
			end = allcookies.length;
		}	
		var list = allcookies.substring(start, end);
		var items = list.split(",");
				
		// put back all other values, as long as they are not id
		for ( k = 0; k < items.length; k++ ){
			if ( items[k] == id ){
				//alert("Skipping iten "+items[k]+" as it is deleted");
				 continue;
}
			if ( cookieval == "MailMe=" ) {
				//alert("Adding first item to list "+items[k]);
				cookieval += items[k];
			}
			else {
				//alert("Adding item to list "+items[k]);
				cookieval += ","+items[k];
			}
		}
	
	}
	document.cookie = cookieval;
	//alert("cookie list after delete= "+document.cookie)
}

function printScholarList(myForm){
	//alert(myForm.scholarList.name +" = " +myForm.scholarList.value)
	scholarList = "";

	if (document.cookie == null || document.cookie == ""){
		alert("Please select at least one scholar.")
		return;
	}
	else{

		scholarCookie = document.cookie.split("; ")
	 		for(i = 0; i < scholarCookie.length; i++){
			var theCookie = scholarCookie[i].split("=") ;
			if(theCookie[0] == "MailMe"){
				scholarList = theCookie[1];
			}
		}

		if(scholarList == null || scholarList == ""){
			alert("Please select at least one scholar.")
			return false;
		}
		else{

			newWindow('', 600, 550, 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes');	

			//alert("about to mail "+scholarList);
			myForm.scholarList.value = scholarList
			deleteAllScholarsFromCookie();

		setChecks();
			return true;
		}
	}
}

function emailScholarList(myForm){
	//alert(myForm.scholarList.name +" = " +myForm.scholarList.value)
	scholarList = "";
	if (document.cookie == null || document.cookie == ""){
		alert("Please select at least one scholar.")
		return;
	}
	else{
		
		scholarCookie = document.cookie.split("; ")
		for(i = 0; i < scholarCookie.length; i++){
			var theCookie = scholarCookie[i].split("=") ;
			if(theCookie[0] == "MailMe"){
				scholarList = theCookie[1];
			}
		}

		if(scholarList == null || scholarList == ""){
			alert("Please select at least one scholar.")
			return false;
		}
		else{

		//alert("about to mail "+scholarList);
			myForm.scholarList.value = scholarList
			deleteAllScholarsFromCookie();
			setChecks();
			return true;
		}
	}
}

function deleteAllScholarsFromCookie(){

	document.cookie = "MailMe=";
	
}


// pops up the intro 
function intro(content){
//	alert(skipIntro());
	if ( !skipIntro() ) {
		newWindow(content, 450, 400, 'no' , 'no', 'no', 'no', 'no', 'no', 'yes');
	setSkipIntro();
	//alert(skipIntro());
	}

}

function closeWin() {

	if (newWin != null)
		newWin.close();
	
}

// checks to see if the cookie is set
function skipIntro() {
	var allcookies = document.cookie;
	if ( allcookies == "" ) {
	//alert("No Cookies");
	return false;
	}
	
	var start = allcookies.indexOf('skip=');
	if ( start == -1 ) { 
	//alert("No start");
	return false;
	}
	
	var end = allcookies.indexOf( ';', start);
	if ( end == -1 ) {	
	//alert("No end");
	end = allcookies.length;
	//alert("set end to "+end);	
	}
	
	var cookieval = allcookies.substring(start, end).split("=")[1];
	//alert("skip is: '"+cookieval+"'");
	if ( cookieval == "true" ){
	//alert("Skip is true");
	 return true;
	}
	//alert("skip is false");
	return false;
	 
	
 }

function setSkipIntro() {

	    document.cookie = "skip=true";

}

function navigate(sForm, sAction, sKey) {

	var oField = document.forms[sForm].CommandCtl;
	oField.value = sAction;
	
	if (sKey != null){
		document.forms[sForm].CommandKeyCtl.value = sKey
	}
	
	document.forms[sForm].target= "_self";
	document.forms[sForm].submit();
	
	return false;
}
//-->

