
function setCookie(name,value,expires,path,domain,secure){var today=new Date();today.setTime(today.getTime());if(expires){expires=expires*1000*60*60*24;}
var expires_date=new Date(today.getTime()+(expires));document.cookie=name+'='+escape(value)+
((expires)?';expires='+expires_date.toGMTString():'')+
((path)?';path='+path:'')+
((domain)?';domain='+domain:'')+
((secure)?';secure':'');}
function randomString(string_length){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";var randomstring='';for(var i=0;i<string_length;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1);}
return randomstring;}
function doForgot(form){var utils=new bb_Utils();var oParams=utils.GetFormValuesAsArray(form);var pwd=randomString(6);oParams['pwd_en']=hex_hmac_sha1(form['salt'].value,pwd);oParams['pwd_1']=pwd;$.post("/post_forgot.php",oParams,function(msg,status)
{window.location=msg;});return false;}
function doLogin(form)
{form['pass'].value=hex_hmac_sha1(form['salt'].value,form['pass_field'].value);var utils=new bb_Utils();utils.Fake(form['pass_field']);return true;}
function doRegister(form){var utils=new bb_Utils();var oParams=utils.GetFormValuesAsArray(form);oParams['post_pass_confirm']=hex_hmac_sha1(form['salt'].value,form['input_password_confirm'].value);oParams['post_pass']=hex_hmac_sha1(form['salt'].value,form['input_password'].value);utils.Fake(form['input_password']);utils.Fake(form['input_password_confirm']);$.post("/post_register.php",oParams,handle_post_register);return false;}
function handle_post_register(sMessage,sStatus)
{var msg=sMessage;if(sStatus=="success")
{if(msg=="OK")
{window.location="/registration/success/";return;}
else
{var err_msg=msg.substring(7);msg=err_msg;}}
else
{msg="Registration failed";}
$("span.register_result").html(msg);}
function BindInputChangeEvent(className)
{$("input").bind("keypress",function(e){$(className).html("");});}
function bb_toggle_updown(obj,c)
{if(obj)
{var imgsrc=obj.attr("src");var imglocation="/images/";var newimgsrc=imglocation+"btn_expand_"+c+".gif";if(imgsrc==(imglocation+"btn_expand_"+c+".gif"))
newimgsrc=imglocation+"btn_collapse_"+c+".gif";obj.attr("src",newimgsrc);}
else
alert('Exception:: Image toggle failed');}
function bb_toggle_sidebox(boxid,c)
{animatedcollapse.toggle(boxid,"fade=1");var element=$("#sbimg"+boxid);bb_toggle_updown(element,c);}
function bb_Utils(){this.GetFormValuesAsArray=function(oForm)
{var oParams={};for(var i=0;i<oForm.elements.length;i++)
{var oField=oForm.elements[i];switch(oField.type)
{case"button":case"reset":break;case"submit":case"text":case"hidden":case"password":oParams[oField.name]=oField.value;break;case"radio":case"checkbox":if(oField.checked)
oParams[oField.name]=oField.value;break;default:oParams[oField.name]=oField.value;}}
return oParams;},this.FillInput=function(form,fillwith)
{var fake='';for(var i=0;i<form.value.length;i++){fake=fake+fillwith;}
form.value=fake;},this.Fake=function(form)
{this.FillInput(form,'-');},this.gup=function(name)
{name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null)
return"";else
return results[1];}}
function bb_isnumeric(value)
{if(isNaN(value))
return false;else
{return(value-0)==value&&value.length>0;}}
function bb_ltrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");}
function bb_rtrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");}
function bb_trim(str,chars){return bb_ltrim(bb_rtrim(str,chars),chars);}
function bb_IsDefined(v)
{return v!=null&&v.length>0;}
function bb_GetDBSafeDate(dte,offsetmonth)
{var day=dte.getDate();day=bb_LeadingZeros(day,2,"0");if(!offsetmonth)
offsetmonth=0;var month=dte.getMonth()+offsetmonth;month=bb_LeadingZeros(month,2,"0");var year=dte.getFullYear().toString();return year+"-"+month+"-"+day;}
function bb_LeadingZeros(num,totalChars,padWith){num=num+"";padWith=(padWith)?padWith:"0";if(num.length<totalChars)
{while(num.length<totalChars){num=padWith+num;}}
if(num.length>totalChars){num=num.substring((num.length-totalChars),totalChars);}
return num;}
var animatedcollapse={divholders:{},divgroups:{},lastactiveingroup:{},show:function(divids){if(typeof divids=="object"){for(var i=0;i<divids.length;i++)
this.showhide(divids[i],"show")}
else
this.showhide(divids,"show")},hide:function(divids){if(typeof divids=="object"){for(var i=0;i<divids.length;i++)
this.showhide(divids[i],"hide")}
else
this.showhide(divids,"hide")},toggle:function(divid){this.showhide(divid,"toggle")},addDiv:function(divid,attrstring){this.divholders[divid]=({id:divid,$divref:null,attrs:attrstring})
this.divholders[divid].getAttr=function(name){var attr=new RegExp(name+"=([^,]+)","i")
return(attr.test(this.attrs)&&parseInt(RegExp.$1)!=0)?RegExp.$1:null}},showhide:function(divid,action){var $divref=this.divholders[divid].$divref
if(this.divholders[divid]&&$divref.length==1){var targetgroup=this.divgroups[$divref.attr('groupname')]
if($divref.attr('groupname')&&targetgroup.count>1&&(action=="show"||action=="toggle"&&$divref.css('display')=='none')){if(targetgroup.lastactivedivid&&targetgroup.lastactivedivid!=divid)
this.slideengine(targetgroup.lastactivedivid,'hide')
this.slideengine(divid,'show')
targetgroup.lastactivedivid=divid}
else{this.slideengine(divid,action)}}},slideengine:function(divid,action){var $divref=this.divholders[divid].$divref
if(this.divholders[divid]&&$divref.length==1){var animateSetting={height:action}
if($divref.attr('fade'))
animateSetting.opacity=action
$divref.animate(animateSetting,$divref.attr('speed')?parseInt($divref.attr('speed')):500)
return false}},generatemap:function(){var map={}
for(var i=0;i<arguments.length;i++){if(arguments[i][1]!=null){map[arguments[i][0]]=arguments[i][1]}}
return map},init:function(){var ac=this
jQuery(document).ready(function($){var persistopenids=ac.getCookie('acopendivids')
var groupswithpersist=ac.getCookie('acgroupswithpersist')
if(persistopenids!=null)
persistopenids=(persistopenids=='nada')?[]:persistopenids.split(',')
groupswithpersist=(groupswithpersist==null||groupswithpersist=='nada')?[]:groupswithpersist.split(',')
jQuery.each(ac.divholders,function(){this.$divref=$('#'+this.id)
if((this.getAttr('persist')||jQuery.inArray(this.getAttr('group'),groupswithpersist)!=-1)&&persistopenids!=null){var cssdisplay=(jQuery.inArray(this.id,persistopenids)!=-1)?'block':'none'}
else{var cssdisplay=this.getAttr('hide')?'none':null}
this.$divref.css(ac.generatemap(['height',this.getAttr('height')],['display',cssdisplay]))
this.$divref.attr(ac.generatemap(['groupname',this.getAttr('group')],['fade',this.getAttr('fade')],['speed',this.getAttr('speed')]))
if(this.getAttr('group')){var targetgroup=ac.divgroups[this.getAttr('group')]||(ac.divgroups[this.getAttr('group')]={})
targetgroup.count=(targetgroup.count||0)+1
if(!targetgroup.lastactivedivid&&this.$divref.css('display')!='none'||cssdisplay=="block")
targetgroup.lastactivedivid=this.id
this.$divref.css({display:'none'})}})
jQuery.each(ac.divgroups,function(){if(this.lastactivedivid)
ac.divholders[this.lastactivedivid].$divref.show()})
$(window).bind('unload',function(){ac.uninit()})})},uninit:function(){var opendivids='',groupswithpersist=''
jQuery.each(this.divholders,function(){if(this.$divref.css('display')!='none'){opendivids+=this.id+','}
if(this.getAttr('group')&&this.getAttr('persist'))
groupswithpersist+=this.getAttr('group')+','})
opendivids=(opendivids=='')?'nada':opendivids.replace(/,$/,'')
groupswithpersist=(groupswithpersist=='')?'nada':groupswithpersist.replace(/,$/,'')
this.setCookie('acopendivids',opendivids)
this.setCookie('acgroupswithpersist',groupswithpersist)},getCookie:function(Name){var re=new RegExp(Name+"=[^;]*","i");if(document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return null},setCookie:function(name,value,days){if(typeof days!="undefined"){var expireDate=new Date()
expireDate.setDate(expireDate.getDate()+days)
document.cookie=name+"="+value+"; path=/; expires="+expireDate.toGMTString()}
else
document.cookie=name+"="+value+"; path=/"}}