/* Copyright 2008 Engrade. All rights reserved. */   var timeout=false;var req=false;function ajax(url,todo){req=false;if(window.XMLHttpRequest){try{req=new XMLHttpRequest();}catch(e){req=false;}}else if(window.ActiveXObject){try{req=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){req=false;}}}if(req){timeout=setTimeout('alert("Sorry, the request did not go through, please try again.");document.location.href=document.location.href;',10000);req.onreadystatechange=eval(todo);req.open("GET", url, true);req.send("");}else{alert('Your browser is too old to use this feature, go to www.mozilla.com to download Firefox.');}}function gid(i){return document.getElementById(i);}var mtimeout;function montre(i){if(mtimeout)clearTimeout(mtimeout);var d=gid(i);for(var j=1;j<=10;j++){if(gid('smenu'+j))gid('smenu'+j).style.display='none';}if(d)d.style.display='block';mtimeout=setTimeout("montre()",2000);}function showhide(i){for(var j=1;j<=99;j++){if(gid('showhide'+j)){if(j==i)gid('showhide'+j).style.display='block';else gid('showhide'+j).style.display='none';}}}function showhideclass(i,classon,classoff){for(var j=1;j<=99;j++){if(gid('showhideclass'+j)){if(j==i)gid('showhideclass'+j).className=classon;else gid('showhideclass'+j).className=classoff;}}}var submitted=false;function formsubmit(m){gid('submitb').disabled=true;gid('submitb').value=m;if(submitted===false){submitted=true;return true;}else return false;}var poptimeout, html;var poped=false;function popbox(top,html,title){var p=gid('popbox');var w=gid('wrapper');var min=10;var max=100;var op;var left=Math.floor((screen.width - 700)/ 2);if(poped){op=max;poped=false;p.style.visibility='hidden';p.style.display='none';document.body.style.background='rgb(255,255,255)';}else{op=min;poped=true;p.style.visibility='visible';p.style.display='block';p.style.top=top+'px';document.body.style.background='rgb(213,213,213)';}w.style.filter='alpha(opacity='+op+')';w.style.opacity=op/100;p.style.left='-700px';p.rows[1].cells[0].innerHTML=html;p.rows[0].cells[0].innerHTML=title;poptimeout=setInterval('slide('+left+')',10);}function slide(fl){var p=gid('popbox');var l=parseInt(p.style.left);if(l>=fl)clearInterval(poptimeout);else{var m=100;if(fl-l<100)m=fl-l;p.style.left=(l+m)+'px';}}function refresh(to){var x=setTimeout('location.reload(true)',to);}function confmsg(p,url){var c=confirm(p);if(c)document.location.href=url;}function showhelp(loc,id,width,height){if(gid(loc)){gid(loc).style.border='1px solid rgb(170,170,255)';gid(loc).innerHTML='<iframe src="/help-frame/'+id+'" frameborder="0" border="0" width="'+width+'" height="'+height+'"></iframe><br/><a href="javascript:hidehelp(\''+loc+'\');void(0)" style="font-size:10px;display:block;padding:0 0 10px 10px">(CLOSE)</a>';}}function hidehelp(loc){if(gid(loc))gid(loc).innerHTML='';}function on(obj,bg){obj.style.background=bg;}function xgtron(obj){obj.style.background="url('/i/xg-highlight.png')center center repeat-x rgb(245,255,245)";}function xgtroff(obj){obj.style.background='none';}function go(u){document.location.href=u;}function pwdstrength(){var g=gid('pwdstrength');var p=gid('pwd1').value;if((g)&&(p.length)){var s=0;var ma=' Add uppercase letters.';var mb=' Add lowercase letters.';var mc=' Add numbers.';if(p.match(/[a-z]/)){s++;mb='';}if(p.match(/[A-Z]/)){s++;ma='';}if(p.match(/[0-9]/)){s++;mc='';}if(p.match(/[^a-zA-Z0-9]/))s++;var msg=ma+mb+mc;if(p.length<5)g.innerHTML='<span style="color:rgb(213,0,0)">Weak password</span>. Needs to be longer.';else if(s==2)g.innerHTML='<span style="color:rgb(213,128,0)">Medium-strength password</span>.'+msg;else if(s==3)g.innerHTML='<b style="color:rgb(0,170,0)">Strong password</b>.';else g.innerHTML='<span style="color:rgb(213,0,0)">Weak password</span>.'+msg;}else g.innerHTML='';}function pwdmatch(){var g=gid('pwdmatch');var a=gid('pwd1').value;var b=gid('pwd2').value;if((g)&&(b.length)){if((b.length<a.length)&&(a.indexOf(b)==0))g.innerHTML='<span style="color:rgb(213,128,0)">Matching...</span>';else if(a==b)g.innerHTML='<b style="color:rgb(0,170,0)">Passwords match.</b>';else g.innerHTML='<span style="color:rgb(213,0,0)">Passwords do not match.</span>';}else g.innerHTML='';}function emailcheck(){var g=gid('emailcheck');var a=gid('email').value;if((g)&&(a.length)){if(a.match(/engrade\.com/))g.innerHTML='<span style="color:rgb(213,0,0)">Not a valid email address.</span>';else if(a.match(/[\w\d\_\.\-]+\@[\w\d\_\-]+\.[\w\d\_\.\-]+/))g.innerHTML='<b style="color:rgb(0,170,0)">Valid email address.</b>';else g.innerHTML='<span style="color:rgb(213,0,0)">Not a valid email address.</span>';}else g.innerHTML='';}function usrcheck(){var p=gid('usr').value;var g=gid('usrcheck');if(p.length){if(p.length<3)g.innerHTML='<b style="color:rgb(213,0,0)">Your username must be greater than 3 characters.</b>';else if(p.length>30)g.innerHTML='<b style="color:rgb(213,0,0)">Your username must less than 30 characters.</b>';else if(p.match(/[^a-zA-Z0-9]/))g.innerHTML='<b style="color:rgb(213,0,0)">Your username can only contain numbers and letters.</b>';else{ajax('/usercheck.php/'+p,'usrcheck2');g.innerHTML='<b style="color:rgb(0,170,0)">Valid username.</b>';}}else g.innerHTML='';}function usrcheck2(){clearTimeout(timeout);timeout=false;if(req.readyState==4){var g=gid('usrcheck');if(req.responseText.match(/taken/))g.innerHTML='<b style="color:rgb(213,128,0)">Sorry, that username has already been taken.</b>';}}