// JavaScript for Home.asp
function nameDefined(ckie,nme)
{
   var splitValues
   var i
   for (i=0;i<ckie.length;++i)
   {
      splitValues=ckie[i].split("=")
      if (splitValues[0]==nme) return true
   }
   return false
}
function delBlanks(strng)
{
   var result=""
   var i
   var chrn
   for (i=0;i<strng.length;++i) {
      chrn=strng.charAt(i)
      if (chrn!=" ") result += chrn
   }
   return result
}
function getCookieValue(ckie,nme)
{
   var splitValues
   var i
   for(i=0;i<ckie.length;++i) {
      splitValues=ckie[i].split("=")
      if(splitValues[0]==nme) return splitValues[1]
   }
   return ""
}
function setCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
function testCookie(cname, cvalue) {  //Tests to see if the cookie 
   var cookie=document.cookie           //with the name and value 
   var chkdCookie=delBlanks(cookie)  //are on the client computer
   var nvpair=chkdCookie.split(";")
   if(nameDefined(nvpair,cname))       //See if the name is in any pair
   {   
      tvalue=getCookieValue(nvpair,cname)  //Gets the value of the cookie
      if (tvalue == cvalue) return true
	   else return false
   }
   else return false
}
function testReturn() {
   if (testCookie("trfalready", "yes")) {
      document["TitleText"].src = "images/helloagain.gif";		//Show Hello Again
	  //document["TitleText"].width = "100%";
	  //document["TitleText"].height = "100%";
   }
   else{
      document["TitleText"].src = "images/hello.gif"		//Show Hello
	  //document["TitleText"].width = "100%";
	  //document["TitleText"].height = "100%";
	  setCookie("trfalready", "yes", 30);
   }
}

var reloadedH = false;
var loc=""+document.location;
loc = loc.indexOf("?reloaded=")!=-1?loc.substring(loc.indexOf("?reloaded=")+10,loc.length):"";
loc = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc;
reloadedH = loc!=""?(loc=="true"):reloadedH;

function reloadOnceOnly() {
    if (!reloadedH) 
        window.location.replace(window.location+"?reloaded=true");
		parent.bottomFrame.location.replace("menu.htm");
}

emsTweak();
