//////////////////////////////////////////
//									   //
//									  //
//	created by Jeffery Vincent		 //
// COPYRIGHT 2007 BIGSTRING CORP	//
/////////////////////////////////////


function newCookie(user,value,days) {
 var days = 90;   // days to expire cookie
 if (days) {
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = "; expires="+date.toGMTString(); 
   }
   else var expires = "";
   document.cookie = user+"="+value+expires+"; path=/"; 
}

function readCookie(user) {
   var userSG = user + "=";
   var nuller = '';
   var username= "";
   var checkbx ="<span class=\"trotxt\">Remember Me </span><input name=\"checker\" type=\"checkbox\" id=\"checker\">";
   var uncheck ="<span class=\"trotxt\"><a href=\"\" onclick=\"delMem(this)\">This is not me..</a></span><br /><span class=\"trotxt\">Remember Me </span><input name=\"checker\" type=\"checkbox\" id=\"checker\" checked=\"checked\">";
   
  if (document.cookie.indexOf(userSG) == -1){ //If user has not se cookies
      document.getElementById('checkbox').innerHTML= checkbx;
  }else{
	  document.getElementById('checkbox').innerHTML= uncheck;
  }

  var ca = document.cookie.split(';');
  
  for(var i=0; i<ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
	
  if (c.indexOf(userSG) == 0) return c.substring(userSG.length,c.length); 
   }
  return username; //sets to null if no cookie
}
	
function eraseCookie(user) {
   newCookie(user,"",1); 
}

function toMem(a) {
   newCookie('User', document.login_frm.user.value);     
   newCookie('Password', document.login_frm.pass.value); 
}

function delMem(a) {
   eraseCookie('User');   
   eraseCookie('Password');

   document.login_frm.user.value = '';   
   document.login_frm.pass.value = ''; 
}


function delCookiesPete(){
	eraseCookie('bigstring_login_cookie');	
	//window.reload
}


function remCookie() {
	document.login_frm.user.value = readCookie("User");
	document.login_frm.pass.value = readCookie("Password");
}
//function makehash(pw) {
	//pass=pw.toUpperCase();
	//hash=0;
	//for (i=0;i<8;i++) {
	//letter=pass.substring(i,i+1);
	//c=alpha.indexOf(letter,0)+1;
	//hash=hash*mult+c;
//}
//return(hash);
//}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  remCookie();
});
