var ord = Math.random() * 10000000000000000;

function processerrormsg(tempstr){
  var startstr='<font face="verdana">&nbsp;&nbsp;<img src="/img/tbull.gif" width=12 height=13 border="0">&nbsp;<b>',
      emailstr='please contact <font color="#0000ee">&#098;&#105;&#108;&#108;&#105;&#110;&#103;&#064;&#115;&#116;&#111;&#099;&#107;&#099;&#111;&#110;&#115;&#117;&#108;&#116;&#097;&#110;&#116;&#046;&#099;&#111;&#109;</font>';     
  if (tempstr.indexOf("expsession")>=0) document.write(startstr+'Your login session has expired, please re login below.</b></font>');
  else if (tempstr.indexOf("loginerror")>=0) document.write(startstr+'There was a temporary system error, please re login below.</b></font>');
  else if (tempstr.indexOf("thankyou")>=0) document.write(startstr+'Thank you for your purchase! you can login below.</b></font>');  
  else if (tempstr.indexOf("invalidpass")>=0) document.write(startstr+'Incorrect password entered. please try again or <a href="http://www.stockconsultant.com/password2.html">Lookup Password</a>.</b><br><br>If error continues '+emailstr+'</font>');
  else if (tempstr.indexOf("loginexpired")>=0) document.write(startstr+'Subscription has expired, please <a href="http://www.stockconsultant.com/signup2.html"> Sign up</a>.</b></font>');
  else if (tempstr.indexOf("logininactive")>=0) document.write(startstr+'Unable to login, subscription not activated, last sign up attempt was not completed.</b><br><br>If error continues '+emailstr+'</font>');
  else if (tempstr.indexOf("logincancelled")>=0) document.write(startstr+'Unable to login, subscription has been cancelled.</b></font>');
  else if (tempstr.indexOf("emailnotvalid")>=0) document.write(startstr+'Unable to login, email address not valid or expired, please try again.</b><br><br>If error continues '+emailstr+'</font>');
  else if (tempstr.indexOf("emailchanged")>=0) document.write(startstr+'Unable to login, email address has been changed, please try again.</b><br><br>If error continues '+emailstr+'</font>');
  else if (tempstr.indexOf("checkmembership")>=0) document.write(startstr+'Incorrect email address entered, or subscription has expired/cancelled.</b></font>');
}
 
  var emailstr="",setemailstr=0,rn=Math.round(Math.random(1)*100000),
  prews='resizable=1,toolbar=0,location=0,menubar=1,status=1,scrollbars=1,left=30,top=30,screenX=30,screenY=30,',
  ws='resizable=1,toolbar=1,location=1,menubar=1,status=1,scrollbars=1,';
  if (screen.width>810){
    prews+='width=550,height=750'; ws+='width=860,height=760';
  }
  else{
    prews+='width=550,height=550'; ws+='width=790,height=550';
  }
  function wo(url,win,wsize){
    window.open(url,win,wsize).focus();
  }
  function prescreen(){
    wo('http://www.stockconsultant.com/consultnow/prescreened_2.cgi?'+rn,'prescreen',prews);
  }
 function checkifpres(tmpstr){
   if ((typeof(tmpstr)!='string')||(typeof(tmpstr)=='undefined')) 
     return(0); 
   else if ((tmpstr==null)||(tmpstr=='null')) 
     return(0); 
   else if (tmpstr=='undefined') return(0); 
   return(1);
 }
 function callforum(){ 
   var d=getCookie('loginck8753'),u="",ts,ld;
   if ((checkifpres(d))&&(d.length>3)&&(d.indexOf("~")>=0)) { 
     ld=d.split("~"); 
     if (ld.length==3) { ts=ld[1].split("@");
       if (ts.length==2) u="?userz="+escape(ts[0]+ld[2].substr(0,1)+ld[2].substr(ld[2].length-1,1));
     }
   }
   wo("http://www.stockconsultant.com/forums/netboard.cgi"+u,'parentWin',ws+',left=20,top=20,screenX=20,screenY=20');
 }
 function openwin(name){
   wo(name,'parentWin',ws+',left=20,top=20,screenX=20,screenY=20');
 }
 function setCookieHome(name, value){
    var c = new Date(); 
    c.setTime(c.getTime() + 15.552E9); /* 6 month cookie */
    document.cookie=name + "=" + escape(value) + "; expires=" + c.toGMTString() + "; path=/;";
  }
  function getCookie(name){
    var re = new RegExp(name + "=([^;]+)"), value = re.exec(document.cookie);
    return (value != null) ? unescape(value[1]) : null;
  }
  function getuserdata(){ var dataz=getCookie('loginck8753');
    if ((checkifpres(dataz))&&(dataz.length>2)&&(dataz.indexOf("~")>=0)){ 
      var logdata=dataz.split("~");
      if (logdata[0]=="1") { document.login.scheck.checked=true; document.login[0].value=logdata[1]; document.login[1].value=logdata[2]; } else document.login[0].value=logdata[1];
    } 
}
function setuserinfo(){
  document.login[0].value=document.login[0].value.toLowerCase().replace(/ /g,"");
  document.login[1].value=document.login[1].value.replace(/ /g,"");
  var temp=document.login[0].value,illegalChars= /[\*\(\)\<\>\,\;\:\\\"\[\]]/, myAtSymbolAt = temp.indexOf('@'), myLastDotAt = temp.lastIndexOf('.'), mySpaceAt = temp.indexOf(' '), myLength = temp.length;
  if (temp.match(illegalChars)) { window.alert("Illegal characters used in email address, Please enter a valid email address."); document.login[0].focus(); return false; }
  else if (myAtSymbolAt < 1 ) 
    { window.alert("Please enter a valid email address, at least one @ must be present and not before position 2."); document.login[0].focus(); return false; }
  else if (myLastDotAt < myAtSymbolAt) 
     { window.alert("Please enter a valid email address, at least one . (dot) afer the @ is required.");  document.login[0].focus();  return false; }
  else if (myLength - myLastDotAt <= 2) 
     { window.alert("Please enter a valid email address, at least two characters [com, uk, fr, ...] must occur after the last . (dot)");  document.login[0].focus(); return false; }
  if (document.login.scheck.checked) setCookieHome('loginck8753',"1"+"~"+document.login[0].value+"~"+document.login[1].value); 
  else setCookieHome('loginck8753',"0"+"~"+document.login[0].value+"~"+document.login[1].value); 
  return true;
}
