
var g_Validation;function init(){var sendOnEnter=function(evt){return submitEnter(this,evt,sendForgottenPasswordEmail);}
Event.observe("submit","click",sendForgottenPasswordEmail);Event.observe("submit","keypress",sendOnEnter);Event.observe("email","keypress",sendOnEnter);g_Validation=new Validation('forgotPasswordForm',{immediate:true});$("email").focus();}
function sendForgottenPasswordEmail(){if(!g_Validation.validate()){return;}
$("message").update('<img src="'+gCommonUrls.smallPreloader+'" alt="">');disableObject($("submit"),true);userManager.sendForgottenPasswordEmail($("email").value,{callback:function(){$("message").className="";$("message").update(gForgotPasswordStrings.mailSent);},errorHandler:function(){$("message").className="";$("message").update(gForgotPasswordStrings.mailSent);}});}
var g_Birthdate='';function showError(str,errorField)
{if(!gErrorDivs||!$(gErrorDivs.msg)||!$(gErrorDivs.ui))
{alert(str);return;}
if(str)
{$(gErrorDivs.msg).innerHTML=str;var index=str.indexOf("<br")==-1?str.length:str.indexOf("<br");$(gErrorDivs.msg).title=str.substr(0,index);$(gErrorDivs.ui).show();if(errorField){errorField.focus();}}
else
{$(gErrorDivs.msg).title="";$(gErrorDivs.ui).hide();}}
function validatePhoneNumber(phone)
{if(isPhoneNumberValid(phone)){return null;}
if(phone.length<7){return gSessionStrings.call_seven_digit_number_required;}
return gSessionStrings.call_invalid_number;}
function isPhoneNumberValid(phone)
{var len=phone.length;var re=/^\+?\d+([\+\-\.\s]?\d+)*$/;return((phone.match(re)!=null)&&len>=7&&len<=25);}
function setBirthdateValidation(birthdateId)
{var birthdate=$(birthdateId);if(!birthdate)
return;Event.observe(birthdate,'keydown',saveBirthdate)
Event.observe(birthdate,'keyup',checkBirthDate)
g_Birthdate=birthdate.value}
function saveBirthdate(evt)
{var birthdate=Event.element(evt);if(isNumberEvt(evt)||isSlashEvt(evt))
g_Birthdate=birthdate.value}
function checkBirthDate(evt)
{if(evt.ctrlKey||evt.keyCode==13||evt.keyCode==37||evt.keyCode==39)
return true;$('sdateMonth').className="validationNormal"
$('sdateDay').className="validationNormal"
$('sdateYear').className="validationNormal"
var birthdate=Event.element(evt);if(!isDelete(evt)&&!isNumberEvt(evt)&&!isSlashEvt(evt))
{birthdate.value=g_Birthdate
return false}
var currVal=birthdate.value;var mm=currVal.substr(0,2);if(mm.length<2)
{g_Birthdate=birthdate.value
return true}
var iValue=parseFloat(mm);if(!isInt(iValue)||iValue<1||iValue>12)
{$('sdateMonth').className="validationError"
if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}
if(currVal.length>=3)
{if(currVal.substr(2,1)!='/')
{$('sdateMonth').className="validationError"
if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}}
$('sdateMonth').className="validationOK"
var dd=currVal.substr(3,2);if(dd.length<2)
{g_Birthdate=birthdate.value
return true}
iValue=parseFloat(dd);if(!isInt(iValue)||dd<1||dd>31)
{$('sdateDay').className="validationError"
if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}
if(currVal.length>=6)
{if(currVal.substr(5,1)!='/')
{$('sdateDay').className="validationError"
if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}}
$('sdateDay').className="validationOK"
var yyyy=currVal.substr(6);if(yyyy.length<4)
{g_Birthdate=birthdate.value
return true}
if(yyyy.length>4)
{$('sdateYear').className="validationError"
if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}
var now=new Date();var thisyear=now.getFullYear();iValue=parseFloat(yyyy);if(!isInt(iValue)||yyyy<(thisyear-100)||yyyy>thisyear)
{$('sdateYear').className="validationError"
if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}
if(!dateCheck(mm,dd,yyyy))
{if(evt.keyCode==8||evt.keyCode==46)
return true;else
{birthdate.value=g_Birthdate
return false}}
$('sdateYear').className="validationOK"
g_Birthdate=birthdate.value
return true;}
function dateCheck(mm,dd,yyyy)
{var year=parseFloat(yyyy);var month=parseFloat(mm);var day=parseFloat(dd);if(month!='')
{if(month==4||month==6||month==9||month==11)
{if(day>30){showError(gErrorStrings.validation_month)
return false;}}
if(month==2)
{if(parseFloat(year)%4!=0&&day=="29")
{showError(gErrorStrings.validation_feb28)
return false;}
else if(day==30||day==31)
{showError(gErrorStrings.validation_feb29)
return false;}}
return checkAge(year,month,day);}
return false;}
function checkAge(year,month,day)
{month=month-1;var min_age=18;var theirDate=new Date((year+min_age),month,day);var today=new Date;if((today.getTime()-theirDate.getTime())<0){showError(gErrorStrings.age18);return false;}
return true;}
function isNumberEvt(evt){return((evt.keyCode>47&&evt.keyCode<58)||(evt.keyCode>95&&evt.keyCode<106))}
function isDelete(evt){return(evt.keyCode==46||evt.keyCode==8)}
function isSlashEvt(evt){return(evt.keyCode==191||evt.keyCode==111)}
function validateSSN(ssn){if((ssn.length==11)||(ssn.length==9)){var segments=ssn.split("-")
if((segments.length==3)){if((segments[0].length==3)&&(segments[1].length==2)&&(segments[2].length==4)){for(var i=0;i<3;i++){if(isNaN(segments[i]))
return false;}
return true;}}
else{if((segments.length==1)&&(!isNaN(ssn)))
return true;}}
return false;}
var Validator=Class.create();Validator.prototype={initialize:function(className,error,test,options){if(typeof test=='function'){this.options=$H(options);this._test=test;}else{this.options=$H(test);this._test=function(){return true};}
this.error=error||'Validation failed.';this.className=className;},test:function(v,elm){return(this._test(v,elm)&&this.options.all(function(p){return Validator.methods[p.key]?Validator.methods[p.key](v,elm,p.value):true;}));}}
Validator.methods={pattern:function(v,elm,opt){return Validation.get('IsEmpty').test(v)||opt.test(v)},minLength:function(v,elm,opt){return v.length>=opt},maxLength:function(v,elm,opt){return v.length<=opt},min:function(v,elm,opt){return v>=parseFloat(opt)},max:function(v,elm,opt){return v<=parseFloat(opt)},notOneOf:function(v,elm,opt){return $A(opt).all(function(value){return v!=value;})},oneOf:function(v,elm,opt){return $A(opt).any(function(value){return v==value;})},is:function(v,elm,opt){return v==opt},isNot:function(v,elm,opt){return v!=opt},equalToField:function(v,elm,opt){return v==$F(opt)},notEqualToField:function(v,elm,opt){return v!=$F(opt)},include:function(v,elm,opt){return $A(opt).all(function(value){return Validation.get(value).test(v,elm);})}}
var Validation=Class.create();Validation.prototype={initialize:function(form,options){this.options=Object.extend({onSubmit:true,stopOnFirst:false,immediate:false,focusOnError:true,useTitles:false,onFormValidate:function(result,form){},onElementValidate:function(result,elm){}},options||{});this.form=$(form);if(this.options.onSubmit)Event.observe(this.form,'submit',this.onSubmit.bind(this),false);if(this.options.immediate){var useTitles=this.options.useTitles;var callback=this.options.onElementValidate;Form.getElements(this.form).each(function(input){Event.observe(input,'blur',function(ev){Validation.validate(Event.element(ev),{useTitle:useTitles,onElementValidate:callback});});if(input.type.toLowerCase()=="hidden"){Event.observe(input,'s2Event:blur',function(ev){Validation.validate(Event.element(ev),{useTitle:useTitles,onElementValidate:callback});});}});}},onSubmit:function(ev){if(!this.validate())Event.stop(ev);},validate:function(){var result=false;var useTitles=this.options.useTitles;var callback=this.options.onElementValidate;if(this.options.stopOnFirst){result=Form.getElements(this.form).all(function(elm){return Validation.validate(elm,{useTitle:useTitles,onElementValidate:callback});});}else{result=Form.getElements(this.form).collect(function(elm){return Validation.validate(elm,{useTitle:useTitles,onElementValidate:callback});}).all();}
if(!result&&this.options.focusOnError){var input=Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first();if(input.type!="hidden"){input.focus()}}
this.options.onFormValidate(result,this.form);return result;},reset:function(){Form.getElements(this.form).each(Validation.reset);}}
Object.extend(Validation,{validate:function(elm,options){options=Object.extend({useTitle:false,onElementValidate:function(result,elm){}},options||{});elm=$(elm);var cn=elm.classNames();return result=cn.all(function(value){var test=Validation.test(value,elm,options.useTitle);options.onElementValidate(test,elm);return test;});},test:function(name,elm,useTitle){var v=Validation.get(name);var prop='__advice'+name.camelize();try{if(Validation.isVisible(elm)&&!v.test($F(elm),elm)){if(!elm[prop]){var advice=Validation.getAdvice(name,elm);if(advice==null){var errorMsg=useTitle?((elm&&elm.title)?elm.title:v.error):v.error;advice='<div class="validation-advice" id="advice-'+name+'-'+Validation.getElmID(elm)+'" style="display:none">'+errorMsg+'</div>'
switch(elm.type.toLowerCase()){case'checkbox':case'radio':var p=elm.parentNode;if(p){new Insertion.Bottom(p,advice);}else{new Insertion.After(elm,advice);}
break;default:new Insertion.After(elm,advice);}
advice=Validation.getAdvice(name,elm);}
if(typeof Effect=='undefined'){advice.style.display='block';}else{new Effect.Appear(advice,{duration:1});}}
elm[prop]=true;elm.removeClassName('validation-passed');elm.addClassName('validation-failed');return false;}else{var advice=Validation.getAdvice(name,elm);if(advice!=null)advice.hide();elm[prop]='';elm.removeClassName('validation-failed');elm.addClassName('validation-passed');return true;}}catch(e){throw(e)}},isVisible:function(elm){while(elm.tagName!='BODY'){if(!$(elm).visible())return false;elm=elm.parentNode;}
return true;},getAdvice:function(name,elm){return $('advice-'+name+'-'+Validation.getElmID(elm))||$('advice-'+Validation.getElmID(elm));},getElmID:function(elm){return elm.id?elm.id:elm.name;},reset:function(elm){elm=$(elm);var cn=elm.classNames();cn.each(function(value){var prop='__advice'+value.camelize();if(elm[prop]){var advice=Validation.getAdvice(value,elm);advice.hide();elm[prop]='';}
elm.removeClassName('validation-failed');elm.removeClassName('validation-passed');});},add:function(className,error,test,options){var nv={};nv[className]=new Validator(className,error,test,options);Object.extend(Validation.methods,nv);},addAllThese:function(validators){var nv={};$A(validators).each(function(value){nv[value[0]]=new Validator(value[0],value[1],value[2],(value.length>3?value[3]:{}));});Object.extend(Validation.methods,nv);},get:function(name){return Validation.methods[name]?Validation.methods[name]:Validation.methods['_LikeNoIDIEverSaw_'];},methods:{'_LikeNoIDIEverSaw_':new Validator('_LikeNoIDIEverSaw_','',{})}});Validation.add('IsEmpty','',function(v){return((/^\s*$/.test(v)));});Validation.addAllThese([['required',gCommonErrors.required,function(v){return!Validation.get('IsEmpty').test(v);}],['validate-number',gCommonErrors.number,function(v){return Validation.get('IsEmpty').test(v)||(!isNaN(v)&&!/^\s+$/.test(v));}],['validate-digits',gCommonErrors.digits,function(v){return Validation.get('IsEmpty').test(v)||!/[^\d]/.test(v);}],['validate-alpha',gCommonErrors.alpha,function(v){return Validation.get('IsEmpty').test(v)||/^[a-zA-Z]+$/.test(v)}],['validate-alpha-more',gCommonErrors.alpha_more,function(v){return Validation.get('IsEmpty').test(v)||/^([a-zA-Z\s\-']+)$/.test(v)}],['validate-alphanum',gCommonErrors.alphanum,function(v){return Validation.get('IsEmpty').test(v)||!/\W/.test(v)}],['validate-ALPHANUM',gCommonErrors.alphanum,function(v){return Validation.get('IsEmpty').test(v)||/\w/.test(v)}],['validate-date',gCommonErrors.date,function(v){var test=new Date(v);return Validation.get('IsEmpty').test(v)||!isNaN(test);}],['validate-email',gCommonErrors.email,function(v){return Validation.get('IsEmpty').test(v)||/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(v)}],['validate-url',gCommonErrors.url,function(v){return Validation.get('IsEmpty').test(v)||/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)}],['validate-zip-length',gCommonErrors.ziplength,function(v){return v.length>4;}],['validate-zipcode',gCommonErrors.zipcode,function(v){return Validation.get('IsEmpty').test(v)||/^[a-zA-Z0-9\- ]+$/.test(v);}],['validate-date-au',gCommonErrors.date_au,function(v){if(Validation.get('IsEmpty').test(v))return true;var regex=/^(\d{2})\/(\d{2})\/(\d{4})$/;if(!regex.test(v))return false;var d=new Date(v.replace(regex,'$2/$1/$3'));return(parseInt(RegExp.$2,10)==(1+d.getMonth()))&&(parseInt(RegExp.$1,10)==d.getDate())&&(parseInt(RegExp.$3,10)==d.getFullYear());}],['validate-currency-dollar',gCommonErrors.currency_dollar,function(v){return Validation.get('IsEmpty').test(v)||/^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)}],['validate-currency',gCommonErrors.currency,function(v){return Validation.get('IsEmpty').test(v)||/^([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)}],['validate-selection',gCommonErrors.selection,function(v,elm){return!Validation.get('IsEmpty').test(v);}],['validate-one-required',gCommonErrors.one_required,function(v,elm){var p=elm.parentNode;var options=p.getElementsByTagName('INPUT');return $A(options).any(function(elm){return $F(elm);});}],['security-code-length',gCommonErrors.code_length,function(v){return Validation.get('IsEmpty').test(v)||v.length==3||v.length==4;}]]);Validation.add('validation-credit-card',gCommonErrors.credit_card,function(v){return validatePaymentCreditCard(v);});Validation.add('validation-exp-date',gCommonErrors.exp_date,function(v){return verifyExpirationDate();});Validation.add('validation-full-name',gCommonErrors.fullname,function(v){return Validation.get('IsEmpty').test(v)||/^([a-zA-Z]+)\s([\sa-zA-Z]+)$/.test(v)});Validation.add('validation-address',gCommonErrors.address,function(v){return Validation.get('IsEmpty').test(v)||/^[^<>"'&]+$/.test(v)});Validation.add('validation-password',gCommonErrors.password,function(v){return Validation.get('IsEmpty').test(v)||!/\s/.test(v)});Validation.add("validate-identical",gCommonErrors.identical,function(v){return Validation.get('IsEmpty').test(v)||v==$F("password");});Validation.add('validation-phone-number',gCommonErrors.phone_number,function(v){return Validation.get('IsEmpty').test(v)||isPhoneNumberValid(v);});if(dwr==null)var dwr={};if(dwr.engine==null)dwr.engine={};if(DWREngine==null)var DWREngine=dwr.engine;if(dwr==null)var dwr={};if(dwr.engine==null)dwr.engine={};if(DWREngine==null)var DWREngine=dwr.engine;if(userManager==null)var userManager={};userManager._path=''+JAWR.jawr_dwr_path+'';userManager.addSupportPackageToLoggedinSupporter=function(p0,callback){dwr.engine._execute(userManager._path,'userManager','addSupportPackageToLoggedinSupporter',p0,callback);}
userManager.removeSupportPackageFromLoggedinSupporter=function(p0,callback){dwr.engine._execute(userManager._path,'userManager','removeSupportPackageFromLoggedinSupporter',p0,callback);}
userManager.isSupporterHasRequiredExperties=function(p0,callback){dwr.engine._execute(userManager._path,'userManager','isSupporterHasRequiredExperties',p0,callback);}
userManager.getPackagesToBeRemove=function(p0,p1,callback){dwr.engine._execute(userManager._path,'userManager','getPackagesToBeRemove',p0,p1,callback);}
userManager.sendForgottenPasswordEmail=function(p0,callback){dwr.engine._execute(userManager._path,'userManager','sendForgottenPasswordEmail',p0,callback);}