//################################################################################################################
//
//	Description:	Checks if a string contains only alpha numeric values

	function gValidString(sString) {

		var sRefString = "~`!@#$%^&*()_-+={[}]|:;'";
		sRefString = sRefString + "<,>.?/\\' '";
		sRefString = sRefString + '"';
		if(sString.length <= 0) return (false);
		for (Count=0; Count < sString.length; Count++) {
			TempChar= sString.substring (Count, Count+1);
			if (sRefString.indexOf (TempChar, 0)!=-1)  
				return (false);
		}
		return (true);
	}

//################################################################################################################
//
//	Description:	Checks to see if string is empty.  String as input, T/F as Result.
//	Inputs:			String
//	Results:		True if empty / null, False otherwise.
//	Comments:		None.
//

	function gIsEmpty(inStr) {
		if (inStr == null || inStr == "") {
			return true;
		}
		return false;
	}

//################################################################################################################
//
//	Description:	Checks if value only contains numbers

	function gNumOnly (InString) {
		var RefString = "0123456789";
		var OutString = "";
		for (Count = 0; Count < InString.length; Count++) {
			Temp = InString.substring (Count, Count+1);
			if (RefString.indexOf(Temp) != -1) {
				OutString += Temp
			}
		}
		return (OutString);
	}

//################################################################################################################

	function Verify_login()
	{
		if ((gValidString(document.login.username.value)) && (gValidString(document.login.password.value)))
		{
			return true;		
		}
		else
		{
			alert("Username and Password must contain only letters and numbers and must be no more than 10 characters in length.");
			return false;
		}
	}
	
	function Verify_register()
	{
		now = new Date();
	
		if (!(gValidString(document.register.username.value)) || !(gValidString(document.register.password.value)))
		{
			alert("Username and Password must contain only letters and numbers and must be no more than 10 characters in length.");
			return false;
		}
		else if (!(document.register.password.value == document.register.confirmation.value))
		{
			alert("Password does not match. Please try again.");
			return false;
		}
		else if (!(gNumOnly(document.register.zip.value)) || (document.register.zip.value.length < 5))
		{
			alert("Zip Code must be a 5 digit numeric value.");
			return false;
		}
		else if (gIsEmpty(document.register.day.value) || isNaN(parseInt(document.register.day.value))) 
		{
			alert("Please enter your birth day. It must be a number.");
			return false;
		}
		else if (gIsEmpty(document.register.year.value) || isNaN(parseInt(document.register.year.value))) 
		{
			alert("Please enter your birth year. It must be a number.");
			return false;
		}
		else if  ((document.register.year.value < 1890) || (document.register.year.value > now.getUTCFullYear()))
		{
			alert("Please enter a valid birth year. It must be a number.");
			return false;
		}
		else
		{
			return true;
		}
	}

	function Verify_teacher_register()
	{
		if (!(gValidString(document.register.username.value)) || !(gValidString(document.register.password.value)))
		{
			alert("Username and Password must contain only letters and numbers and must be no more than 10 characters in length.");
			return false;		
		}
		else if (!(document.register.password.value == document.register.confirmation.value))
		{
			alert("Password does not match. Please try again.");
			return false;
		}
		else if (gIsEmpty(document.register.fullname.value)) 
		{
			alert("Please enter your full name.");
			return false;
		}
		else if (gIsEmpty(document.register.grade.value)) 
		{
			alert("Please enter your grade level.");
			return false;
		}
		else if (gIsEmpty(document.register.schoolname.value)) 
		{
			alert("Please enter your school name.");
			return false;
		}
		else if (gIsEmpty(document.register.city.value)) 
		{
			alert("Please enter your city.");
			return false;
		}
		else if (!(gNumOnly(document.register.zip.value)) || (document.register.zip.value.length < 5))
		{
			alert("Zip Code must be a 5 digit numeric value.");
			return false;
		}
		else
		{
			return true;
		}
	}

//****************************************************************************************************************
//****************************************************************************************************************

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_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_findObj(n, d) { //v3.0
  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); return x;
}

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 onTop() {
  if (window.blur) window.focus();
}

function back(num) {
	history.back(num);
}


function popup(file2open)  {

	var spawn = null;
	var spawn = window.open(file2open, 'popup', 'height=250,width=375,scrollbars=no,resizable=no');
	if (spawn.blur) spawn.focus();
}

function popup2(file2open)  {

	var spawn = null;
	var spawn = window.open(file2open, 'popup', 'height=500,width=600,scrollbars=yes,resizable=yes');
	if (spawn.blur) spawn.focus();
}

function home_popup(file2open)  {

	var spawn = null;
	var spawn = window.open(file2open, 'popup', 'height=460,width=465,scrollbars=no,resizable=no');
	if (spawn.blur) spawn.focus();
}


function sponsor(file2open)  {

	var sponsorWin = null;
	var sponsorWin = window.open(file2open, 'popup', 'height=250,width=450,scrollbars=no,resizable=no');
	if (sponsorWin.blur) sponsorWin.focus();
}

function showPoll()
{
	var poll= null;
	var file2open = "poll.asp";
	poll = window.open(file2open,"results","width=462,height=501,scrollbars=no,resizable=no");
	if (poll.blur) poll.focus();
}

function visitSponsor(url) {
  var sponsorPage = window.open(url,'sponsor');
  //  var sponsorPage = window.open(url,'sponsor','scrollbars,resizable,width=640,height=340,left=40,top=40');
  if (sponsorPage != null) window.close();
  if (whoAmI == 'Netscape' && sponsorPage != null) sponsorPage.focus();
}

function openWin(file2open,h,w)  {

	var game = null;
	//var options = "'" + size + ",scrollbars=no,resizable=no'";
	var game = window.open(file2open, 'newWin', 'width=' + w + ',height=' + h + ',scrollbars=no,resizable=no');
}

function openSurvey(file2open,w,h)  {

	var spawn = null;
	//var options = "'" + size + ",scrollbars=no,resizable=no'";
	var spawn = window.open(file2open, 'newWin', 'width=' + w + ',height=' + h + ',scrollbars=yes,resizable=no');
	if (spawn.blur) spawn.focus();
}

function openWin_full(file2open,h,w)  {

	var newWin = null;
	//var options = "'" + size + ",scrollbars=yes,resizable=yes'";
	var newWin = window.open(file2open, 'newWin', 'width=' + w + ',height=' + h + ',scrollbars=yes,resizable=yes');
	newWin.focus();
}

function openWin3(file2open,h,w) {

	var newIn = null;
	var newWin = window.open(file2open, 'newWin', 'width=' + w + ',height=' + h + ',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes');
	newWin.focus();
}

function openWin4(file2open) {

	var newIn = null;
	var newWin = window.open(file2open, 'newWin', 'scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes');
	newWin.focus();
}

function bonepile() {

	var boneWin = null;
	var boneWin = window.open('bonepile.asp', 'bonepile', 'height=400,width=600,scrollbars=no,resizable=no');
}

function doWinFunk(h,w) {
	if (window.screen) {
		var aw = screen.availWidth;
		var ah = screen.availHeight;
		window.moveTo((aw - w) / 2, (ah - h)/2);
		window.resizeTo(w, h);
	}
}

function openWin2(file2open,h,w) {
	if (window.screen) {
  		newWin = window.open('login.asp','win1','width=' + w + ',height=' + h + ',scrollbars=no,resizable=no');
  	}
}

function openRoom(roomName) {
   var file2open= "gsa/" + roomName + ".htm";
   spawn = window.open( file2open, 'room', 'height=400, width=550, scrollbars=no,resizeable=no');
}<!-- START OF SDC Advanced Tracking Code -->
<!-- Copyright (c) 1996-2007 WebTrends Inc.  All rights reserved. -->
<!-- V8.0 -->
<!-- $DateTime: 2007/02/20 09:30:16 $ --> 


<SCRIPT TYPE="text/javascript">
<!-- 
var gService = true; 
var gTimeZone = 0; // Code section for Enable First-Party Cookie Tracking 
function dcsCookie(){
	if (typeof(dcsOther)=="function"){
		dcsOther();
	}
	else if (typeof(dcsPlugin)=="function"){
		dcsPlugin();
	}
	else if (typeof(dcsFPC)=="function"){
		dcsFPC(gTimeZone);
	}
}
function dcsGetCookie(name){
	var cookies=document.cookie.split("; ");
	var cmatch=[];
	var idx=0;
	var i=0;
	var namelen=name.length;
	var clen=cookies.length;
	for (i=0;i<clen;i++){
		var c=cookies[i];
		if ((c.substring(0,namelen+1))==(name+"=")){
			cmatch[idx++]=c;
		}
	}
	var cmatchCount=cmatch.length;
	if (cmatchCount>0){
		idx=0;
		if ((cmatchCount>1)&&(typeof(gFpc)!="undefined")&&(name==gFpc)){
			var dLatest=new Date(0);
			for (i=0;i<cmatchCount;i++){
				var lv=parseInt(dcsGetCrumb(cmatch[i],"lv"));
				var dLst=new Date(lv);
				if (dLst>dLatest){
					dLatest.setTime(dLst.getTime());
					idx=i;
				}
			}
		}
		return unescape(cmatch[idx].substring(namelen+1));
	}
	else{
		return null;
	}
}
function dcsGetCrumb(cval,crumb){
	var aCookie=cval.split(":");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsGetIdCrumb(cval,crumb){
	var id=cval.substring(0,cval.indexOf(":lv="));
	var aCrumb=id.split("=");
	for (var i=0;i<aCrumb.length;i++){
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsIsFpcSet(name,id,lv,ss){
	var c=dcsGetCookie(name);
	if (c){
		return ((id==dcsGetIdCrumb(c,"id"))&&(lv==dcsGetCrumb(c,"lv"))&&(ss=dcsGetCrumb(c,"ss")))?0:3;
	}
	return 2;
}
function dcsFPC(offset){
	if (typeof(offset)=="undefined"){
		return;
	}
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var name=gFpc;
	var dCur=new Date();
	var adj=(dCur.getTimezoneOffset()*60000)+(offset*3600000);
	dCur.setTime(dCur.getTime()+adj);
	var dExp=new Date(dCur.getTime()+315360000000);
	var dSes=new Date(dCur.getTime());
	 
WT.co_f=WT.vt_sid=WT.vt_f=WT.vt_f_a=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
	if (document.cookie.indexOf(name+"=")==-1){
		if ((typeof(gWtId)!="undefined")&&(gWtId!="")){
			WT.co_f=gWtId;
		}
		else if ((typeof(gTempWtId)!="undefined")&&(gTempWtId!="")){
			WT.co_f=gTempWtId;
			WT.vt_f="1";
		}
		else{
			WT.co_f="2";
			var cur=dCur.getTime().toString();
			for (var i=2;i<=(32-cur.length);i++){
				WT.co_f+=Math.floor(Math.random()*16.0).toString(16);
			}
			WT.co_f+=cur;
			WT.vt_f="1";
		}
		if (typeof(gWtAccountRollup)=="undefined"){
			WT.vt_f_a="1";
		}
		WT.vt_f_s=WT.vt_f_d="1";
		WT.vt_f_tlh=WT.vt_f_tlv="0";
	}
	else{
		var c=dcsGetCookie(name);
		var id=dcsGetIdCrumb(c,"id");
		var lv=parseInt(dcsGetCrumb(c,"lv"));
		var ss=parseInt(dcsGetCrumb(c,"ss"));
		if ((id==null)||(id=="null")||isNaN(lv)||isNaN(ss)){
			return;
		}
		WT.co_f=id;
		var dLst=new Date(lv);
		WT.vt_f_tlh=Math.floor((dLst.getTime()-adj)/1000);
		dSes.setTime(ss);
		if ((dCur.getTime()>(dLst.getTime()+1800000))||(dCur.getTime()>(dSes.getTime()+28800000))){
			WT.vt_f_tlv=Math.floor((dSes.getTime()-adj)/1000);
			dSes.setTime(dCur.getTime());
			WT.vt_f_s="1";
		}
		if ((dCur.getDay()!=dLst.getDay())||(dCur.getMonth()!=dLst.getMonth())||(dCur.getYear()!=dLst.getYear())){
			WT.vt_f_d="1";
		}
	}
	WT.co_f=escape(WT.co_f);
	WT.vt_sid=WT.co_f+"."+(dSes.getTime()-adj);
	var expiry="; expires="+dExp.toGMTString();
	var cur=dCur.getTime().toString();
	var ses=dSes.getTime().toString();
	document.cookie=name+"="+"id="+WT.co_f+":lv="+cur+":ss="+ses+expiry +"; path=/"+(((typeof(gFpcDom)!="undefined")&&(gFpcDom!=""))?(";domain="+gFpcDom):(""));
	var rc=dcsIsFpcSet(name,WT.co_f,cur,ses);
	if (rc!=0){
		WT.co_f=WT.vt_sid=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
		WT.vt_f=WT.vt_f_a=rc;
	}
}

// Code section for Use the new first-party cookie generated with this tag.
var gFpc="WT_FPC";
var gConvert=true;

function dcsAdv(){
	dcsFunc("dcsET");
	dcsFunc("dcsCookie");
	dcsFunc("dcsAdSearch");
	dcsFunc("dcsTP");
}

//-->
</SCRIPT>
<!-- END OF SDC Advanced Tracking Code -->
