var MyIndo=Class.create();MyIndo.DefaultOptions={base_url:'/',index_page:'index.php',image_url:'/images/',slash:'/'};MyIndo.prototype={initialize:function(options){this.options=Object.extend(Object.extend({},MyIndo.DefaultOptions),options||{});this.language=new Array();this.base_url=this.options.base_url;this.index_page=this.options.index_page;this.images_url=this.options.image_url;this.slash=this.options.slash},site_url:function(url){if(url==null){return this.base_url};if(url.blank()){return this.slash_item(this.base_url)+this.index_page};var result=this.slash_item(this.base_url)+this.slash_item(this.index_page)+url;return result},get_base_url:function(url){if(url==null){return this.base_url};if(url.blank()){return this.slash_item(this.base_url)};var result=this.slash_item(this.base_url)+url;return result},set_img_url:function(url){if(url==null){if(typeof image_url=='undefined'){this.image_url=this.options.image_url}else{this.image_url=this.slash_item(image_url)}}else{this.image_url=this.slash_item(url)}},img_url:function(url){if((url==null)||url.blank()){return this.image_url};var result=this.slash_item(this.image_url)+url;return result},slash_item:function(item){if((item==null)||item.blank()){return''}if(item.endsWith(this.slash)){return item}var result=item+this.slash;return result},KeyUpEnter:function(element,method){this.keyup_element=$(element);this.onKeyUpEnterListener=this.onKeyUpEnter.bindAsEventListener(this,method);Event.observe(this.keyup_element,'keyup',this.onKeyUpEnterListener)},onKeyUpEnter:function(event,method){var key=event.which||event.keyCode;if(key==13){eval(method);return false}},KeyUpEnterAsTab:function(form){this.keyup_form=$(form);this.onKeyUpEnterAsTabListener=this.onKeyUpEnterAsTab.bindAsEventListener(this,form);for(var f,i=(f=this.keyup_form).length;i>0;){i--;f[i].observe('keyup',this.onKeyUpEnterAsTabListener)}},onKeyUpEnterAsTab:function(event,form){var key=event.which||event.keyCode;var el,l;var e=event.target;var k=key==13;if(k){if(!/textarea|select/i.test(e.type)&&!event.preventDefault()){for(l=k=(el=$(form).getElements()).length;el[--k]!=e;);while(!(e=el[k=++k*(k<l)]).type||e.disabled);e.focus()}return false}},setLang:function(key,value){this.language[key]=value},getLang:function(key){if(this.language[key]==undefined)return'';return this.language[key]},href:function(url){location.href=url},insert:function(element,url){var randomID=Math.floor(Math.random()*10e12);url=this.site_url(this.slash_item(url)+randomID);new Ajax.Updater({success:element,failure:'notice'},url,{parameters:{kirim:'kirim'},insertion:Insertion.Bottom})},ajax_show:function(){$('overlay').show();$('waiting').show()},ajax_hide:function(){$('overlay').hide();$('waiting').hide()},ajax_on404:function(transport){this.ajax_hide();alert('404/Not Found')},ajax_on403:function(transport){this.ajax_hide();alert('403/Forbidden')},ajax_onLoading:function(){this.ajax_show()},ajax_onFailure:function(transport){this.ajax_hide();alert('Failure')},ajax_onSuccess:function(transport){this.ajax_hide()},ajax_onComplete:function(transport){this.ajax_hide()},AutoFormat:function(element,regex,flags){this.onKeyUpAutoFormatListener=this.onKeyUpAutoFormat.bindAsEventListener(this,element,regex,flags);Event.observe(element,'keyup',this.onKeyUpAutoFormatListener)},onKeyUpAutoFormat:function(event,element,regex,flags){this.onKeyUpFormat(element,regex,flags)},onKeyUpFormat:function(element,regex,flags){if(regex==undefined)return;f=$F(element);e=$(element);if(f.empty())return;if(flags==null){var myreg=new RegExp(regex)}else{var myreg=new RegExp(regex,flags)}f=e.value;while(!f.match(myreg)){e.value=f.substring(0,f.length-1);f=e.value;if(f.empty()){break}}},AutoFormatUserName:function(element){this.AutoFormat(element,"^[a-zA-Z0-9]([A-Za-z0-9_])*$")},FormatUserName:function(element){this.onKeyUpFormat(element,"^[a-zA-Z]([A-Za-z0-9_])*$")},AutoFormatNumber:function(element){this.AutoFormat(element,"^[0-9]+$")},FormatNumber:function(element){this.onKeyUpFormat(element,"^[0-9]+$")},FormatTelp:function(element){this.onKeyUpFormat(element,"^(([0-9]+)|([0-9]+-?[0-9]*))$")},TestPasswd:function(elpasswd,elverdict,elbar){var passwd=$F(elpasswd);var intScore=0;var strVerdict="weak";if(passwd.length<5){intScore=(intScore+3)}else if(passwd.length>4&&passwd.length<8){intScore=(intScore+6)}else if(passwd.length>7&&passwd.length<16){intScore=(intScore+12)}else if(passwd.length>15){intScore=(intScore+18)};if(passwd.match(/[a-z]/)){intScore=(intScore+1)};if(passwd.match(/[A-Z]/)){intScore=(intScore+5)};if(passwd.match(/\d+/)){intScore=(intScore+5)};if(passwd.match(/(.*[0-9].*[0-9].*[0-9])/)){intScore=(intScore+5)};if(passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){intScore=(intScore+5)};if(passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){intScore=(intScore+5)};if(passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){intScore=(intScore+2)};if(passwd.match(/([a-zA-Z])/)&&passwd.match(/([0-9])/)){intScore=(intScore+2)};if(passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){intScore=(intScore+2)};if(intScore<16){strVerdict="very weak";$(elbar).className='elbar_veryweek'}else if(intScore>15&&intScore<25){strVerdict="weak";$(elbar).className='elbar_week'}else if(intScore>24&&intScore<35){strVerdict="medium";$(elbar).className='elbar_medium'}else if(intScore>34&&intScore<45){strVerdict="strong";$(elbar).className='elbar_strong'}else{strVerdict="stronger";$(elbar).className='elbar_stronger'};$(elverdict).update(strVerdict)},TestMatch:function(el,elmatch,eldict){if($F(el).blank()){$(eldict).update('');return true}if($F(el)==$F(elmatch)){$(eldict).update('Password Match')}else{$(eldict).update('Password Not Match')}},getRandomNum:function(lbound,ubound){return(Math.floor(Math.random()*(ubound-lbound))+lbound)},getRandomChar:function(number,lower,upper,other,extra){var numberChars="0123456789";var lowerChars="abcdefghijklmnopqrstuvwxyz";var upperChars="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var otherChars="`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";var charSet=extra;if(number==true)charSet+=numberChars;if(lower==true)charSet+=lowerChars;if(upper==true)charSet+=upperChars;if(other==true)charSet+=otherChars;return charSet.charAt(this.getRandomNum(0,charSet.length))},getPassword:function(pass_options){default_pass_options={length:8,extraChars:'',firstNumber:true,firstLower:true,firstUpper:true,firstOther:false,latterNumber:true,latterLower:true,latterUpper:true,latterOther:false};this.pass_options=Object.extend(Object.extend({},default_pass_options),pass_options||{});var rc="";if(this.pass_options.length>0)rc=rc+this.getRandomChar(this.pass_options.firstNumber,this.pass_options.firstLower,this.pass_options.firstUpper,this.pass_options.firstOther,this.pass_options.extraChars);for(var idx=1;idx<this.pass_options.length;++idx){rc=rc+this.getRandomChar(this.pass_options.latterNumber,this.pass_options.latterLower,this.pass_options.latterUpper,this.pass_options.latterOther,this.pass_options.extraChars)}return rc},genPassword:function(elm,pass_options){$(elm).value=this.getPassword(pass_options)}};
