var d=document;

//var global
function _id(i)
{
 return document.getElementById(i);
}
function _p(o,l,t,r,b)
{
 if(l)o.style.left=l+"px";
 if(t)o.style.top=t+"px";
 if(r)o.style.right=r+"px";
 if(b)o.style.bottom=b+"px";
}
function winx()
{
 if(window.innerWidth)return window.innerWidth;
 else return document.body.clientWidth;
}
function winy()
{
 if(document.body.clientHeight) return document.body.clientHeight;
 else return window.innerHeight ;
 
}
function cenx()
{
 return winx()/2;
}
function ceny()
{
 return winy()/2;
}
function G4(a)
{
 var b=a.offsetLeft;
 var c=a.offsetParent;
 if(c)
 {
  b+=G4(c)
 }
 return b
}
function G5(a)
{
 var b=a.offsetTop;
 var c=a.offsetParent ;
 if(c)
 {
  b+=G5(c)
 }
 return b
}
function G44(a)
{
 var b=a.offsetWidth;
 return b+G4(a);
}
function G55(a)
{
 var b=a.offsetHeight;
 return b+G5(a);
}
function eventx(e)
{
 if(e.x)return e.x+document.documentElement.scrollLeft;
 return e.pageX;
}
function eventy(e)
{
 if(e.y)return e.y+document.documentElement.scrollTop;
 return e.pageY;
}
function f_ta(p,i)
{
 var _ta=d.createElement("table");
 var _tb= d.createElement("tbody");
 if(i)_ta.id=i;
 _ta.appendChild(_tb);
 if(p)p.appendChild(_ta);
 _ta.border="0";
 _ta.cellSpacing="0";
 _ta.cellPadding="0";
 _ta.align="center";
 _ta.valign="top";
 _ta.width="100%";
 return _tb;
}
function f_ta2(p,i)
{
 var _ta=d.createElement("table");
 var _tb=d.createElement("tbody");
 if(i)_ta.id=i;
 _ta.appendChild(_tb);
 if(p)p.appendChild(_ta);
 _ta.border="0";
 _ta.cellSpacing="0";
 _ta.cellPadding="0";
 _ta.align="center";
 _ta.valign="top";
 return _tb;
}
function f_tr(p,i)
{
 var _tr=d.createElement("tr");
 if(p)p.appendChild(_tr);
 if(i)_tr.id=i;
 return _tr;
}
function f_td(p,i)
{
 var _td=d.createElement("td");
 if(p)p.appendChild(_td);
 if(i)_td.id=i;
 return _td;
}
function f_di(p,i)
{
 var _di=d.createElement("div");
 if(p)p.appendChild(_di);
 if(i)_di.id=i;
 return _di;
}
function rc(o)
{
 o.parentNode.removeChild(o);
}
function canc(event)
{
 if(event.stopPropagation)event.stopPropagation();
 else event.cancelBubble=true;
}
function rfa(a,o)
{
 for(var i=0;i<a.length;i++)
 {
  if(a[i]==o)
  {
   return a.slice(0,i).concat(a.slice(i+1));
  }
 }
 return a;
}
//Func ajax
function req()
{
 var a=null;
 try
 {
  a=new ActiveXObject("Msxml2.XMLHTTP ")
 }
 catch(c)
 {
 }
 if(!a)try
 {
  a=new ActiveXObject("Microsoft.XMLHTTP")
 }
 catch(c)
 {
 }
 if(!a)
 {
  a=new XMLHttpRequest();
 }
 return a;
}
function err(o)
{
 try
 {
  var o=fc(o);
  var o=fc(o);
  if(o.nodeName=="failed")return value(o);
  else return 0;
 }
 catch(e)
 {
 }
 return 999;
}
function asynreq(u,h)
{
 var a=req();
 a.onreadystatechange=function()
 {
  h(a);
 }
 ;
 a.open("GET",u,true);
 a.send(null);
 return a;
}
function asynreq2(u,d,h)
{
 var a=req();
 a.onreadystatechange=function()
 {
  h(a);
 }
 ;
 a.open("POST",u,true);
 a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); a.send(d);
 return a;
}
function newiframe(u)
{
 var _div=f_di(d.body);
 hi2(_div);
 var _if=document.createElement("iframe");
 _if.src=u;
 return _if;
}
function uploadiframe(i)
{
 if(!i)i="";
 var _div=f_di(d.body);
 _div.style.width=0;
 _div.style.height=0;
 hi2(_div);
 _div.innerHTML="<iframe name='reserved_file_upload"+i+"' width=0 height=0 frameborder=0 marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no>";
}
//Func general
function str0(s)
{
 var s2="",s3="";
 for(var i=0;i<s.length;i++)
 {
  if(s.charAt(i)!=' ' && s.charAt(i)!='\r' && s.charAt(i)!='\n')
  {
   s2=s.substr (i,s.length);
   break;
  }
 }
 for(var i=s2.length-1;i>=0;i--)
 {
  if(s2.charAt(i)!=' ' && s.charAt(i)!='\r' && s.charAt(i)!='\n')
  {
   s3=s2.substr(0,i+1);
   break;
  }
 }
 return s3;
}
function strx(s)
{
 return str0(s).replace(/\"/g,"").replace(/\\/g,"").replace(/</g,"");
}
function stry(s)
{
 return str0(s).replace(/</g,"&lt;");
}
function NLZ(s)
{
 while(s.indexOf("0")==0){
    s=s.substr(1);
 }
 return s;
}
function clr(o)
{
 var nl= o.childNodes;
 while(nl.length>0)
 {
  o.removeChild(nl.item(0));
 }
}
function fc(o)
{
 try
 {
  var ret=o.firstChild;
  while(ret.nodeName=="#text" || ret.nodeName=="BR")
  {
   ret=ret.nextSibling;
   if(!ret)return null;
  }
  return ret;
 }
 catch(e)
 {
 }
 return null;
}
function nc(o)
{
 try
 {
  var ret=o.nextSibling;
  while(ret.nodeName=="#text" || ret.nodeName=="BR")
  {
   ret=ret.nextSibling;
   if(!ret)return null;
  }
  return ret;
 }
 catch(e)
 {
 }
 return null;
}
function lc(o)
{
 try
 {
  var items=item(o);
  return items[ items.length-1];
 }
 catch(e)
 {
 }
 return null;
}
function fc2(o)
{
 return o.firstChild;
}
function item(o)
{
 var a=new Array();
 try
 {
  for(var i=0;i<o.childNodes.length;i++)
  {
   var o1=o.childNodes.item(i);
   if(o1.nodeName=="#text")continue;
   a[ a.length]=o1;
  }
 }
 catch(e)
 {
 }
 return a;
 
}
function value(o)
{
 try
 {
  return fc2(o).nodeValue;
 }
 catch(e)
 {
  return "";
 }
}
function datestr(str)
{
 if(!str)return "";
 var d=new Date(parseInt(str+"000"));
 var n=new Date();
 var s="";
 if( d.getFullYear()!=n.getFullYear())s+=d.getFullYear()+"/";
 var _m=d.getMonth();
 var _d=d.getDate();
 if(_m!=n.getMonth() || _d!=n.getDate())
 {
  if(_m<9)_m="0"+(_m+1);
  else _m=_m+1;
  if(_d<10)_d="0"+_d;
  s+=_m+"/"+_d+" ";
 }
 var _h= d.getHours();
 var _i=d.getMinutes();
 if(_h<10)_h="0"+_h;
 if(_i<10)_i="0"+_i;
 s+=_h+":"+_i;
 if(d.getHours()>12)s+=" pm.";
 else s+=" am.";
 return s;
}
function get_search_arg(arg)
{
 var search= window.location.search;
 if(search.charAt(0)=="?")
 {
  search=search.substr(1);
 }
 var argpairs=search.split("&");
 for(var ii=0;ii<argpairs.length;ii++)
 {
  var x=argpairs[ii];
  var keyvalues=x.split("=");
  if(keyvalues[0]==arg)return keyvalues[1];
 }
 return "";
}
function mask50(o)
{
 o.style.opacity="0.5";
 o.style.filter="alpha(opacity=50)";
}
function mask40(o)
{
 o.style.opacity="0.4";
 o.style.filter="alpha(opacity=40)";
}
function mask100(o)
{
 o.style.opacity="0.0";
 o.style.filter="alpha(opacity=0)";
}
function mask()
{
 var _div=_id("bookmask");
 if(_div)
 {
  vi2(_div);
  return;
 }
 var _div=f_di(d.body,"bookmask");
 _div.style.position="absolute";
 _div.style.zIndex=500;
 _div.style.width=d.body.offsetWidth+"px";
 _div.style.height=d.body.offsetHeight+"px";
 _div.style.top="0px";
 _div.style.left=G4(d.body)+"px";
 _div.style.background="#fff";
 _div.style.textAlign="right";
 mask50(_div);
 ael2(window,"resize",function()
 {
  _div.style.width=d.body.offsetWidth+"px";
  _div.style.height=d.body.offsetHeight+"px";
  _div.style.left=G4(d.body)+"px";
 }
 );
}
function unmask()
{
 var _div=_id("bookmask");
 if(_div)
 {
  clr(_div);
  hi2(_div);
 }
}
function loading()
{
 var _div=_id("bookmask");
 if(_div)_div.innerHTML="<img src='img_lcn/loading.gif'>";
}
function loaded()
{
 var _div=_id("bookmask");
 if(_div)_div.innerHTML="";
}
function f_sdiv(l,t,w,h)
{
 var _div=f_di(d.body);
 _div.style.position="absolute";
 _div.style.zIndex=500;
 _div.style.left=l+"px";
 _div.style.top=t+"px";
 if(w)_div.style.width=w+"px";
 if(h)_div.style.height=h+"px";
 _div._callback=null;
 ael2(document,"click",function()
 {
  hi2(_div);
  try
  {
   _div._callback();
  }
  catch(e)
  {
  }
 }
 );
 return _div;
}
//Func misc
function vi2(o)
{
 if(!o)return;
 o.style.visibility="visible";
 o.style.display="";
}
function hi2(o)
{
 if(!o)return;
 o.style.visibility="hidden";
 o.style.display="none";
}
function vi(i)
{
 var o=document.getElementById(i);
 vi2(o);
}
function hi(i)
{
 var o=document.getElementById(i);
 hi2(o);
}
function click(o)
{
 try
 {
  o.click();
 }
 catch(e)
 {
  var e=document.createEvent("MouseEvents");
  e.initMouseEvent("click", true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
  o.dispatchEvent(e);
 }
}
function ael(i,s,h)
{
 var o=d.getElementById(i);
 if(o.attachEvent)
 {
  o.attachEvent("on"+s,h);
 }
 else 
 {
  o.addEventListener(s,h,true);
 }
}
function rel(i,s,h)
{
 var o=d.getElementById(i);
 if(o.detachEvent)
 {
  o.detachEvent ("on"+s,h);
 }
 else 
 {
  o.removeEventListener(s,h,true);
 }
}
function ael2(o,s,h)
{
 if(o.attachEvent)
 {
  o.attachEvent("on"+s,h);
 }
 else 
 {
  o.addEventListener(s,h,true);
 }
}
function rel2(o,s,h)
{
 if(o.detachEvent )
 {
  o.detachEvent("on"+s,h);
 }
 else 
 {
  o.removeEventListener(s,h,true);
 }
}
function go2(o,tag)
{
 tag=tag.toUpperCase();
 while(o.tagName!=tag && o.tagName.toUpperCase()!="BODY")
 {
  o=o.parentNode;
 }
 return o;
}
function border1(o,c,t,l,b,r)
{
 o.style.borderStyle="solid";
 o.style.borderColor=c;
 o.style.borderTopWidth=t;
 o.style.borderLeftWidth=l;
 o.style.borderBottomWidth=b;
 o.style.borderRightWidth=r;
}
function en64(input)
{
 keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 var output = "";
 var chr1, chr2, chr3;
 var enc1, enc2, enc3, enc4;
 var i = 0;
 do 
 {
  chr1 = input.charCodeAt(i++);
  chr2 = input.charCodeAt(i++);
  chr3 = input.charCodeAt(i++);
  enc1 = chr1 >> 2;
  enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  enc4 = chr3 & 63;
  if (isNaN(chr2)) 
  {
   enc3 = enc4 = 64;
  }
  else if (isNaN(chr3)) 
  {
   enc4 = 64;
  }
  output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
 }
 while (i < input.length);
 return output;
}
function de64(input)
{
 keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 var output = "";
 var chr1, chr2, chr3;
 var enc1, enc2, enc3, enc4;
 var i = 0;
 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 do 
 {
  enc1 = keyStr.indexOf(input.charAt(i++));
  enc2 = keyStr.indexOf(input.charAt(i++));
  enc3 = keyStr.indexOf(input.charAt(i++));
  enc4 = keyStr.indexOf(input.charAt(i++));
  chr1 = (enc1 << 2) | (enc2 >> 4);
  chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  chr3 = ((enc3 & 3) << 6) | enc4;
  output = output + String.fromCharCode(chr1);
  if (enc3 != 64) 
  {
   output = output + String.fromCharCode(chr2);
  }
  if (enc4 != 64) 
  {
   output = output + String.fromCharCode(chr3);
  }
 }
 while (i < input.length);
 return output;
}
function setCookie(name, value, date,path, domain, secure) 
{
 var curCookie = name + "=" + escape(value) +"; expires="+date+((path) ? "; path=" + path : "") +((domain) ? "; domain=" + domain : "") +((secure) ? "; secure" : "");
 document.cookie = curCookie;
}

function emailok(o)
{
 if( o.indexOf (".")==-1 || o.indexOf("@")==-1 || o.length<=6 || o.lastIndexOf("@")<1 || o.lastIndexOf("@")>o.length-5 || o.lastIndexOf(".")>o.length-3)
 {
  return false;
 }
 return true;
}

function confirmpost(id, s,s2)
{
   if( ! confirm(s))return;
   if(s2)try
   {
      _id(s2).value="yes";
   }
   catch(e)
   {
   }
   var _fo = d.getElementById(id);
   _fo.submit();
}

function confirmlink(link, s)
{
   if( ! confirm(s))return;
   window.location=link;
}

//Func function
function logout()
{
 //setCookie("a","","Thu, 01-Jan-1970 00:00:01 GMT","/","chanceseek.com");
 setCookie("p","","Thu, 01-Jan-1970 00:00:01 GMT","/","chanceseek.com");
 setCookie("s","","Thu, 01-Jan-1970 00:00:01 GMT","/","chanceseek.com");
 window.location="/signin?logout=logout";
}
