    function printcookies()

    {

      var cookieWindow = open();

      var myCookie = document.cookie.split("; ");
 
      alert(myCookie);

      if( myCookie.length > 0 )

      {

        for(var i=0;i < myCookie.length; i++)

        {

          cookieWindow.document.write("cookie[" + i + "]" + ": " + myCookie[i] + "<br>");

        }

      }

      else if( document.cookie == "")

      { 

        alert("No cookies");

      }

    }
	
	function findOptionIndex(thisselect, selectionvalue){
		
//		alert("option name: " + thisselect.id + "; option length: " + thisselect.length + "; option size: " + thisselect.size); 

		if(selectionvalue != ""){
			
			for( i=0; i<=thisselect.length; i++ ){
				if( thisselect.options[i].value == selectionvalue ) return i;
			}
		}

	return 0;
	
	}
	
	function setRadio( startday, classstart ){
		var valueString = startday + "-" + classstart;
		for(i=0;i<document.sheetform.classtime.length;i++)
			if(document.sheetform.classtime[i].value==valueString)
				document.sheetform.classtime[i].checked = true;
	}
	function setRadioOnline(onlinecookie){
		for(i=0;i<document.sheetform.online.length;i++)
			if(document.sheetform.online[i].value==onlinecookie)
				document.sheetform.online[i].checked = true;
	}
	
	function useCookies(){

		name = getCookies("studentname")
			
		if (name != ""){
			
			if( confirm("Are you " + name + "? \n(Click OK if yes, Cancel if no)")){
			
				document.sheetform.name.value = name;
				document.sheetform.instructor.selectedIndex = findOptionIndex(document.sheetform.instructor, getCookies("instructor"));
				document.sheetform.classcode.selectedIndex = findOptionIndex(document.sheetform.classcode, getCookies("classname"));
				
				var onlinecookie = getCookies("onlinego");
				setRadioOnline(onlinecookie);
				
				var sday = getCookies("startday");
				var sclass = getCookies("classstart");
//				alert("classstart: " + sclass);
				if(sday != "" && sclass != "" ){
					sday = parseInt(sday);
					sclass = parseInt(sclass);
					setStartDate( sday, sclass);	
					setRadio(sday, sclass);		
				}
				
			}
			else{

			    	document.cookie="studentname=" + escape(studentname) + ";expires=" + expired;
				
				document.sheetform.name.value = "";
				document.sheetform.instructor.selectedIndex = 0;
				document.sheetform.classcode.selectedIndex = 0;	

				for(i=0;i<document.sheetform.classtime.length;i++)
					document.sheetform.classtime[i].checked = false;
				for(i=0;i<document.sheetform.online.length;i++)
					document.sheetform.online[i].checked = false;

			}
			
		}
		
	}
	
	function getCookies(name){

//	printcookies();
		
        var position=document.cookie.indexOf(name);

        if ( position != -1)

        {

          var begin = position + name.length + 1;

          var end=document.cookie.indexOf(";", begin);
		  
//  alert("looking for \"" + name + "\"(of length " + name.length + ") in " + document.cookie + "; position: " + position + "; begin: " + begin + "; end: " + end);

          if(end == -1){ end=document.cookie.length;}

          return unescape(document.cookie.substring(begin, end));
		
        }		
		
//		alert("no cookies!");
		
		return "";
		
	}
	
    function deleteCookie(cookDel)

    {
   
        document.cookie = cookDel + "=;expires= Thu, 01-Jan-1970 00:00:01 GMT";
   
	}
	

