// Utility functions
// Admin password changed 7/06


function contactX(strDomain, strName) // obscures email address (spam preventer)
{
	var strAddress, nCharNum, strDiddleDivider;
	strAddress = strDomain;
	if (strAddress == "123456")
	{
		strAddress = "cdr.state.tx.us";
	}	
	nCharNum = 32 + 32;
	strDiddleDivider = "";
	document.location.href = "mail"+strDiddleDivider+"to:"+strName+String.fromCharCode(nCharNum)+strAddress;
}

function setMsg(mssg) // status bar message
{
	window.setTimeout('window.status=\"' + mssg + '\"', 1);
	return true;
}

function signIn() // main OSCAR sign in routine
{
	var strPassword = document.loginText.password.value;
	switch (strUsername)
	{
		case "" :
			window.alert("You must select a School or WIA region!");
			break;
		case "Administrator" :
//			if (strPassword == 72114)
			if (strPassword == 72203)
			{
				document.cookie = "oscar = ok; PATH = /";
				document.cookie = "admin = ok";
				document.location.replace("oscar.asp");
			}
			else
			{		
				window.alert("Invalid Password. Please check your password and try again.");
			}
			break;
		case "Out-of-State" :
			if (strPassword == 54321)
			{
				document.cookie = "oscar = ok; PATH = /";
				document.cookie = "admin = ";
				document.location.replace("setcount.asp?username="+strUsername);
			}
			else
			{
				window.alert("Invalid Password. Please check your password and try again.");
			}
			break;
		default :
			if (((strPassword >= 71601) && (strPassword <= 72959)) || ((strPassword >= 75500) && (strPassword <= 75599)))
			{
				document.cookie = "oscar = ok; PATH = /";
				document.cookie = "admin = ";
				document.location.replace("setcount.asp?username="+strUsername);
			}
			else
			{
				window.alert("Invalid Password. Please check your password and try again.");
			}
	}
}

function altsignIn() // other user OSCAR sign in routine
{
	var strUsername = document.loginText.username2.value;
	var strPassword = document.loginText.password2.value;
	if (strUsername == "IOSCAR")
	{
		if (strPassword == "ARKANSAS")
		{
			document.cookie = "oscar = ok; PATH = /";
			document.location.replace("setcount.asp?username=iOSCAR");
		}
		else
		{
			window.alert("Invalid password. Please check your password and try again.");
		}	
	}
	else
	{
		window.alert("Invalid user name. Please check your user name and try again.");
	}
}

function adminsignIn() // administrative OSCAR sign in routine
{
	var strUsername = document.loginText.username2.value;
	var strPassword = document.loginText.password2.value;
	if (strUsername == "ARKANSAS")
	{
		if (strPassword == "OSCARADMIN")
		{
			document.cookie = "oscar = ok; PATH = /";
			document.cookie = "admin = ok";
			document.location.replace("admin2.asp");
		}
		else
		{
			window.alert("Invalid password. Please check your password and try again.");
		}	
	}
	else
	{
		if (strUsername == "ADMINISTRATOR")
		{
//			if (strPassword == 72114)
			if (strPassword == 72203)
			{
				document.cookie = "oscar = ok; PATH = /";
				document.cookie = "admin = ok";
				document.location.replace("admin2.asp");
			}
			else
			{
				window.alert("Invalid password. Please check your password and try again.");
			}	
		}
		else
		{
			window.alert("Invalid user name. Please check your user name and try again.");
		}
	}	
}



// COOKIE functions
//<!-- This script and many more are available free online at -->
//<!-- The JavaScript Source!! http://javascript.internet.com -->

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function getCookieVal (offset) 
{  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) 
{  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) 
	{    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return "";
}

function SetCookie (name, value) 
{  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) 
{  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

    
