
$(document).ready(function(){var id=$.cookie('id');if(id!=null){$('#id').val(id);$('#pwd').focus().bind('keypress',doKey);};var re=$.cookie('re');if(re==1){$('#re').attr('checked','checked');}
var ip=window.location.href.indexOf("?e=");if(ip!=-1){var mn=parseInt(window.location.href.charAt(ip+3));var msg=null;switch(mn){case 1:msg='Invalid Member ID or password';break;case 2:case 3:msg='Session ended. Please log in.';break;default:break;}
if(msg)msgDialog(msg);}
$("#pwd").focus(function(e){$(this).bind('keypress',doKey);},function(e){$(this).unbind('keypress');});$(".dlc").click(function(){$(this).closest('.dlg').hide('fast');});$("#lgo").click(function(){doLogin();});$("#frg").click(function(){showForgot();});$("#reps").click(function(){showSupport();});$("#fgs").click(function(){var m=$('#fem').val();if(!checkEmail(m))return;var url='p/forgot.php?em='+escape(m);$.get(url,function(res){$('#fgr').text(m);$('.fs0').hide();$('.fs1').show();});});$("#fgp").click(function(){var m=$('#fph').val();if(m.length<10){msgDialog('Please enter your full telephone number including area code.');return;}
if(m.length>25){msgDialog('Phone number too long.');return;}
$.post('p/psreq.php',{pn:m},function(res){var msg='A support call to <b>'+m+'</b> has been requested. Bizpad Support will call you within one business day.';msgDialog(msg);$('#rps').hide();});});$("#tvid").click(function(){$(this).html("<iframe src='http://members.xiosoftvideo.com/videoiframe.asp?filehigh=67116663671XEROBV&a=640&b=504&playmode=1&bkgcolor=FFFFFF&c=671&plname=1&ssl=0' frameborder='0' style='margin:0; padding:0; overflow:hidden;' width='640' height='504' scrolling='no'></iframe>");});});function doKey(evt){if(evt.which==13){doLogin();return false;}
return true;}
function showForgot(){$('.fs0').show();$('.fs1').hide();$('#fem').val('');$('#d1').hide();var w=350;$('#forgt').css('left',(($(document).width()-w)/2)+'px').css('top','100px').css('width',w).show('fast').css('z-index',9000);}
function showSupport(){$('#forgt').hide();$('#fph').val('');var w=350;$('#rps').css('left',(($(document).width()-w)/2)+'px').css('top','100px').css('width',w).show('fast').css('z-index',9005);}
function doLogin(){var id=$('#id').val();if(id==''){msgDialog('Please enter your Member ID');return;}
var pwd=$('#pwd').val().toLowerCase();if(pwd==''){msgDialog('Please enter your password');return;}
var re=($('#re').attr('checked')?1:0);$.cookie('re',re,{expires:730});if(re){$.cookie('id',id,{expires:730});}else{$.cookie('id',null);}
$.cookie('i',id);$.cookie('p',SHA1(pwd));document.login.submit();}
function checkEmail(m){if(m==''){msgDialog('Please enter your email address');return false;}
var pt=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;if(!pt.test(m)){msgDialog('Please enter a valid email address');return false;}
return true;}
function msgDialog(msg){var w=210;$('#d1m').html(msg);$('#d1').css('left',(($(document).width()-w)/2)+'px').css('top','95px').css('width',w).show('fast').css('z-index',9999);}
String.prototype.trim=function(){return this.replace(/^\s*/,"").replace(/\s*$/,"");}
