// Login Function
function the_loginator() { 
	theRadioValue = 0;
	for (i=0, n=document.Login.elements.length; i<n; i++) {
	    if (document.Login.elements[i].checked) {
		   theRadioValue = document.Login.elements[i].value;
		   break;
	    }
	}

	switch (theRadioValue){
	   case "PeopleSoft" :
		  //document.Login.action = "https://student.studentadmin.uconn.edu/servlets/iclientservlet/SAPR/?cmd=login&languageCd=ENG";
		  document.Login.action = "https://student.studentadmin.uconn.edu/servlets/iclientservlet/SAPR/?cmd=login&languageCd=ENG";
		  document.Login.user.name = 'userid';
		  document.Login.pass.name = 'pwd'
		  document.Login.one.name = 'Submit'
		  document.Login.one.value = 'Sign In'
		  document.Login.two.name = 'timezoneOffset'
		  document.Login.two.value = '0'
		  pop('popups/peoplesoft.php',500,500,'PeopleSoft');
		  return true;
		 break;
	   case "HuskyMail" :
		  document.Login.action = "https://huskymail.uconn.edu/login.msc";
		  document.Login.pass.name = 'password'
		  return true;
		  break;
	   case "WebCT" :
		  document.Login.action = "https://webct.uconn.edu/webct/ticket/ticketLogin";
		  document.Login.user.name = 'WebCT_ID';
		  document.Login.pass.name = 'Password'
		  document.Login.one.name = 'request_uri'
		  document.Login.one.value = '/webct/homearea/homearea?'
		  document.Login.two.name = 'action'
		  document.Login.two.value = 'webform_user'
		  document.Login.three.name = 'goto_button'
		  document.Login.three.value = 'Log in'
		  
			// Begin New Husky Hack
			var userID = document.Login.user.value;
			var len = userID.length;
			var ttvm = 5;	// Times To View Message - Must be a single digit
			var expiration = "Sun, 15-Aug-2005 00:00:00 GMT"; 	// Begin the cycle again after this date
			var views = 0;
			var popThis = false;
			
			if(document.cookie){
				var cooky = document.cookie;
				var cookyLen = cooky.length;
				var cookies = cooky.split("; ");
				for(x=0;x<cookies.length;x++){
					pieces = cookies[x].split("=");
					if(pieces[0] == 'views'){
						views = pieces[1];
						if(isNaN(views)){
							views = 0;
						}
						break;
					}
				}
			}
			
			if(userID && (len >= 5) && (userID.substring((len-5),(len-3)) == '04')){		
				if(views < ttvm){	// Do if cookie exists and value is less than ttvm
					views++;
					document.cookie = "views=" + views + ";expires=" + expiration + ";path=/;domain=.students.uconn.edu";
					popThis = true;
				}else{	// Do if they have viewed it enough times
					// Don't show the pop-up
					popThis = false;
				}				
			}
			
			if(popThis){
				//	Do Popup code...
				//alert("You have seen this message " + views + " time(s).");
				pop('popups/fye.php',300,300,'Phone');
			}
			// End New Husky Hack
			
		  return true;
		  break;
	   case "Reslife" :
		  document.Login.action = "https://webcentral.reslife.uconn.edu/default.cfm";
		  document.Login.user.name = 'username';
		  document.Login.pass.name = 'password'
		  document.Login.one.name = 'logOnAs'
		  document.Login.one.value = 'student'
		  return true;
		 break;
	   default : 
			alert('You have made an invalid selection');
			return false;
		  break;
	} 
} 

