pH8={};pH8.Version='2.0';pH8.CompatibleWithPrototype='1.6';if(Prototype.Version.indexOf(pH8.CompatibleWithPrototype)!==0&&console&&console.warn)
console.warn("This version of pH8 extensions is tested with Prototype "+pH8.CompatibleWithPrototype+" it may not work as expected with this version ("+Prototype.Version+")");pH8.SiteVersion=function(){var meta=Element.getElementsBySelector(document,"meta[name='site-version']");if(meta[0]){return meta[0].getAttribute('content');}else{return 0;}}();if(!window.console){window.console={log:function(message){}};}
pH8.Mixin={};Element.addMethods({getClassParameters:function(element,prefix){element=$(element);if(arguments.length<2){prefix='param';}
var regex=new RegExp(prefix+'-(\\w*)=(\\S*)','g');var params={};while((result=regex.exec(element.className))!=null){params[result[1]]=result[2];}
return params;},getClassParameter:function(element,param,prefix){if(arguments.length<3){prefix='param';}
var regex=new RegExp(prefix+'-'+param+'=(\\S*)');var parts=regex.exec(element.className);if(parts){return parts[1];}}});Object.extend(String.prototype,{isDigits:function(){return(this.match(/^\d+$/)!==null);},stripQuery:function(){return(this.split('?')[0]);}});Object.extend(Number.prototype,{isInteger:function(){return(Math.round(this)===this);}});;pH8.Dictionary=(function(){var _instance=null;var _list=null;return function(language){if(_instance!==null){return _instance;}
_instance=this;language=language||'';new Ajax.Request("/api/ajax.php?action=listDictionary&language="+language,{method:'get',onSuccess:function(transport){_list=transport.responseJSON;document.fire("dictionary:loaded");}});this.isLoaded=function(){return(null!==_list);};this.getText=function(key){if(_list[key]){return _list[key];}else{return key;}};};})();pH8.Mixin.needsDictionary={waitForDictionary:function(callback,language){var dictionary=new pH8.Dictionary(language);if(dictionary.isLoaded()){callback();}else{document.observe("dictionary:loaded",callback);}}};pH8.Storage=(function(){var _instance=null;return function(type){if(_instance!==null){return _instance;}
_instance=this;this.ttl=3600;this.set=function(name,value,ttl){ttl=ttl||this.ttl;var time=new Date();time.setTime(time.getTime()+ttl);document.cookie=name+'='+escape(Object.toJSON(value))+';expires='+time.toLocaleString();};this.get=function(name){var value=null;var cookie=document.cookie.match(name+'=([^;]+)');if(cookie){value=unescape(cookie[1].gsub('+','%20')).evalJSON(true);}
return value;};};})();;pH8.Mixin.needsTemplates={waitForTemplates:function(templates,callback){this._templatesLoadedCallback=callback;this._templateUrlsByName=new Hash(templates);this._templateNamesByUrl=new Hash();this.templates={};this._templateUrlsByName.each(function(pair){this._templateNamesByUrl.set(pair.value,pair.key);new Ajax.Request(pair.value,{method:'get',parameters:{'v':pH8.SiteVersion},onSuccess:this.checkTemplates.bind(this)});}.bind(this));},checkTemplates:function(response){var name=this._templateNamesByUrl.get(response.request.url.stripQuery());if(name){var check=true;this.templates[name]=response.responseText;this._templateNamesByUrl.each(function(pair){if(!this.templates[pair.value]){check=false;}}.bind(this));if(check&&this._templatesLoadedCallback){this._templatesLoadedCallback();}}}};pH8.Pages=(function(){var _instance=null;var _list=null;return function(language){if(_instance!==null){return _instance;}
_instance=this;new Ajax.Request("/api/ajax.php?action=listPages",{method:'get',onSuccess:function(transport){_list=transport.responseJSON;document.fire("pages:loaded");}});this.isLoaded=function(){return(null!==_list);};this.getList=function(){return _list;};this.getPage=function(key){if(_list[key]){return _list[key];}else{return key;}};};})();pH8.Mixin.needsPages={waitForPages:function(callback){var pages=new pH8.Pages();if(pages.isLoaded()){callback();}else{document.observe("pages:loaded",callback);}}};pH8.Form=Class.create({initialize:function(element,delegate,options){Object.extend(this,pH8.Mixin.needsDictionary);Object.extend(this,pH8.Mixin.needsTemplates);this.element=$(element);this.delegate=delegate;options=options||{};this.options={};this.data={};this.submitButton=options.submitButton||this.element.getInputs('submit')[0];this.activityIndicator=options.activityIndicator;this.options.disableButtonOnSubmit=options.disableButtonOnSubmit||true;this.options.disabledButtonClass=options.disabledButtonClass||'btn-disabled';this.options.disabledButtonText=options.disabledButtonText||'submitting...';this.dataUrl=options.dataUrl;this.fields=new Hash();this.labels=new Hash();this.externalData=new Hash();this.element.getElements().each(function(formElement){this.fields.set(formElement.name,formElement);if(formElement.id){if('radio'==formElement.type||'checkbox'==formElement.type){var label=formElement.up('fieldset').down('legend');}else{var label=this.element.down('label[for='+formElement.id+']');}
this.labels.set(formElement.name,label);}}.bind(this));if(this.dataUrl){this.element.observe('submit',this.submit.bindAsEventListener(this));}
if(options.successTemplateUrl){this.waitForTemplates({success:options.successTemplateUrl,dialog:options.dialogTemplateUrl},this.onTemplatesLoaded.bind(this));}
this.waitForDictionary(this.onDictionaryLoaded.bind(this));},onDictionaryLoaded:function(){this.dictionary=new pH8.Dictionary();this.dictionaryLoaded=true;if(this.templatesLoaded){this.onReady();}},onTemplatesLoaded:function(){this.templatesLoaded=true;if(this.dictionaryLoaded){this.onReady();}},onReady:function(){},displaySuccess:function(){if(this.delegate&&this.delegate.formDidSucceed){this.delegate.formDidSucceed(this);}else{this.element.up().update(this.templates.success.process({dictionary:this.dictionary}));}},displayErrorDialog:function(error){if(this.delegate&&this.delegate.formDisplayErrorDialog){this.delegate.formDisplayErrorDialog(this,error);}else{alert(error.message);}},submit:function(event){event.stop();if(this.delegate&&this.delegate.formCanSubmit&&this.delegate.formCanSubmit(this)){if(this.options.disableButtonOnSubmit){this.submitButton.disabled=true;this.submitButton.addClassName(this.options.disabledButtonClass);this.submitButton.store('originalValue',this.submitButton.getValue());this.submitButton.setValue(this.options.disabledButtonText);}
if(this.activityIndicator){this.activityIndicator.removeClassName('hidden');}
if(this.delegate&&this.delegate.formWillSubmit){this.delegate.formWillSubmit(this);}
this.data=$H(this.element.serialize(true)).merge(this.externalData).toObject();new Ajax.Request(this.dataUrl,{method:'post',parameters:this.data,onSuccess:this.parseJSONData.bind(this),onException:this.onSubmitError.bind(this),onFailure:this.onSubmitError.bind(this)});if(this.delegate&&this.delegate.formDidSubmit){this.delegate.formDidSubmit(this);}}},onSubmitError:function(response,data){if(this.options.disableButtonOnSubmit){this.submitButton.removeClassName(this.options.disabledButtonClass);this.submitButton.setValue(this.submitButton.retrieve('originalValue'));this.submitButton.disabled=false;}
if(this.activityIndicator){this.activityIndicator.addClassName('hidden');}
if(data){}else{}},parseJSONData:function(response){if(this.options.disableButtonOnSubmit){this.submitButton.removeClassName(this.options.disabledButtonClass);this.submitButton.setValue(this.submitButton.retrieve('originalValue'));this.submitButton.disabled=false;}
if(this.activityIndicator){this.activityIndicator.addClassName('hidden');}
var data=response.responseJSON;if(data){if('fail'==data.status){this.handleFormFail(data);}else if('ok'==data.status){this.displaySuccess();}}},handleFormFail:function(result){this.fields.each(function(pair){if(result.errors[pair.key]){label=this.labels.get(pair.key);if(label){label.addClassName('error');}}else{label=this.labels.get(pair.key);if(label){label.removeClassName('error');}}}.bind(this));if(this.delegate&&this.delegate.formDidFail){this.delegate.formDidFail(this);}},addData:function(data){this.externalData=this.externalData.merge(data);}});;pH8.Dialog=Class.create({initialize:function(options){this.options=Object.extend({duration:0.5,opacity:0.25,dialogId:'IQdialog',windowClass:'window',hasCloseButton:true},options||{});this.container=$(this.options.dialogId)||this.createNewDialog(this.options.dialogId);this.popup=this.container.down('.'+this.options.windowClass);this.overlay=this.container.down('.overlay');Event.observe(document.onresize?document:window,"resize",this.calculateOverlay.bindAsEventListener(this));},createNewDialog:function(id){var dialog=new Element('div',{'id':id});dialog.insert({'bottom':this.createOverlay()});dialog.insert(this.createPopup());$$('body')[0].insert({'bottom':dialog});return dialog;},createPopup:function(){var popup=new Element('div',{'class':this.options.windowClass}).hide();if(this.options.hasCloseButton){var closeButton=new Element('a',{'class':'closeButton','href':'#'}).update('<span>close</span>');closeButton.observe('click',this.hide.bindAsEventListener(this));popup.insert({'bottom':closeButton});}
var content=new Element('div',{'className':'content'});popup.insert({'bottom':content});popup.setStyle({top:document.viewport.getScrollOffsets().top+"px"});return popup;},createOverlay:function(){this.overlay=new Element('div',{'class':'overlay'}).hide();this.calculateOverlay();return this.overlay;},calculateOverlay:function(){var dimensions=document.viewport.getDimensions();var offsets=document.viewport.getScrollOffsets();this.middle={x:dimensions.width/2+offsets.left,y:dimensions.height/2+offsets.top};this.overlay.setStyle({position:'fixed',top:0,left:0,right:0,bottom:0,backgroundColor:'#000'});},insertContent:function(content){var contentElement=this.popup.down('.content');contentElement.update(content);contentElement.setStyle({'top':this.middle.y-contentElement.getHeight()/2,'left':this.middle.x-contentElement.getWidth()/2});},show:function(){this.container.show();this.container.down('.overlay').setStyle({'opacity':'0'}).show();this.container.down('.overlay').morph('opacity:0.8',{duration:0.2,position:'end'});this.popup.setStyle({'overflow':'hidden'});this.popup.appear({duration:0.5,position:'end'});},hide:function(e){if(e){e.stop();}
this.popup.morph('opacity:0',{duration:0.5,position:'first'});this.container.down('.overlay').morph('opacity:0',{duration:0.2,position:'end',afterFinish:function(){this.container.hide();}.bind(this)});}});pH8.Dialog.getInstance=function(options){if(pH8.Dialog._instance==null){pH8.Dialog._instance=new pH8.Dialog(options);}
return pH8.Dialog._instance;};;Accordion=Class.create({initialize:function(element,options){this.element=$(element);this.options={};this.options.openClass=options.openClass||'active';this.options.duration=options.duration||0.5;this.openElement=element.down('dd.'+this.options.openClass);this.isAnimating=false;this.element.observe('click',this.clickHandler.bindAsEventListener(this));},clickHandler:function(event){var me=event.findElement('a');if(me&&me.match('dt a')){event.stop();var dt=me.up('dt');if(dt){this.animateElement(dt.next('dd'));}}},animateElement:function(element){if(!this.isAnimating){var effects=new Array();var options={};if(!this.openElement||this.openElement!=element){options={sync:true,scaleFrom:0,scaleContent:false,scaleMode:'contents',transition:Effect.Transitions.sinoidal,scaleX:false,scaleY:true};effects.push(new Effect.Scale(element,100,options));}
if(this.openElement){options={sync:true,scaleContent:false,scaleMode:'contents',transition:Effect.Transitions.sinoidal,scaleX:false,scaleY:true};effects.push(new Effect.Scale(this.openElement,0,options));}
new Effect.Parallel(effects,{duration:this.options.duration,fps:35,queue:{position:'end',scope:'accordion'},beforeStart:function(){this.isAnimating=true;element.addClassName(this.options.openClass);element.previous('dt').addClassName(this.options.openClass);}.bind(this),afterFinish:function(){if(this.openElement){this.openElement.removeClassName(this.options.openClass);this.openElement.previous('dt').removeClassName(this.options.openClass);}
if(this.openElement==element){this.openElement=null;}else{this.openElement=element;}
this.isAnimating=false;}.bind(this)});}}});;var general_rules={'#onestat-placeholder':function(){var d=document;var sid=Element.getClassParameter(this,'sid');var CONTENTSECTION="";var CUSTOMDATA="";var osp_URL=d.URL;var osp_Title=d.title;var t=new Date();var p="http"+(d.URL.indexOf('https:')===0?'s':'')+"://stat.onestat.com/stat.aspx?tagver=2&sid="+sid;p+="&url="+escape(osp_URL);p+="&ti="+escape(osp_Title);p+="&section="+escape(CONTENTSECTION);p+="&custom="+escape(CUSTOMDATA);p+="&rf="+escape(document.referrer);p+="&tz="+escape(t.getTimezoneOffset());p+="&ch="+escape(t.getHours());p+="&js=1";p+="&ul="+escape(navigator.appName=="Netscape"?navigator.language:navigator.userLanguage);if(osp_URL!=d.URL){p+="&ol="+escape(d.URL);}
if(typeof(screen)=="object"){p+="&sr="+screen.width+"x"+screen.height;p+="&cd="+screen.colorDepth;p+="&jo="+(navigator.javaEnabled()?"Yes":"No");}
this.innerHTML='<img id="ONESTAT_TAG" width="1" height="1" src="'+p+'" >';},'#analytics-placeholder':function(){var params=this.getClassParameters();if(params.sid){var pageTracker=_gat._getTracker(params.sid);if(params.target){pageTracker._trackPageview(unescape(params.target));}else{pageTracker._trackPageview();}}},'.hilite-keywords':function(){var hiliter=new KeywordHiliter("ajax.php",this);hiliter.options.elementTag='ABBR';hiliter.fetchKeywords();},'.no-javascript':function(){this.hide();},'.show-no-javascript':function(){this.show();}};Event.addBehavior(general_rules);var hyperlink_rules={'a.void:click':function(e){return false;},'a.popup:click':function(e){var params=this.getClassParameters();var width=params.width||684;var height=params.height||350;var top=params.top||200;var left=params.left||'50%';window.open(this.href,'PopUp','width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=0,status=no,resizable=0,toolbar=0,titlebar=0,menubar=0,location=0');return false;},'a.external:click,a.new-window:click':function(e){if(!e.ctrlKey&&!e.altKey&&!e.shiftKey){window.open(this.href);return false;}},'a.status:mouseover':function(e){window.status=this.title;return true;},'a.status:mouseout':function(e){window.status='';return true;},'a.switch:click':function(e){var c=$(this.id.replace('-switch',''));var content=$(c.id+'-content');if(c){c.toggle();}
return false;},'a.tabswitch:click':function(e){var container=$(this.getAttribute('rel'));if(container){var other=$(container.getAttribute('rel'));if(other){container.addClassName('hide');other.removeClassName('hide');}}
return false;},'a.modal:click':function(e){var image=this.up().next().down('img');var dialog=new MUIL.Dialog.Image(image);return false;},'a.submit':function(e){var params=this.getClassParameters();var form=$(params.form);if(form){form.submit();}
return false;}};Event.addBehavior(hyperlink_rules);var form_rules={'form.overlabel':function(){this.addClassName('overlabel-apply');this.removeClassName('overlabel');},'form.overlabel-apply label:click':function(event){var field=this.getAttribute('for');if(field){field.focus();}},'form.overlabel-apply input:focus':function(event){var label=$(this.form).down('label[for='+this.id+']');if(label){label.setStyle({textIndent:'-10000px'});}},'form.overlabel-apply input:blur':function(event){if(''==this.getValue()){var label=$(this.form).down('label[for='+this.id+']');if(label){label.setStyle({textIndent:'0px'});}}},'form.auto-submit':function(e){this.submit();},'select.auto-submit:change':function(e){this.form.submit();},'input.auto-upper:blur':function(e){this.value=this.value.toUpperCase();},'input.auto-upper:change':function(e){this.value=this.value.toUpperCase();},'.default-value:blur':function(e){if(this.value==''){var params=this.getClassParameters();if(params.default_value!=''){this.value=params.default_value;this.addClassName('auto-clear');}}},'input.auto-blur:focus':function(e){this.className=this.className.replace('-off','-on');var fieldLabel=$(this.form).down('[for='+this.id+']');if(fieldLabel){fieldLabel.className=fieldLabel.className.replace('-off','-on');var image=fieldLabel.down('img');if(image){image.src=image.src.replace('_normal','_hover');}}
var fieldSet=this.up('fieldset');if(fieldSet&&fieldSet.up('fieldset')){var legend=fieldSet.down('legend');if(legend){legend.className=legend.className.replace('-off','-on');}}},'input.auto-blur:blur':function(e){this.className=this.className.replace('-on','-off');var fieldLabel=$(this.form).down('[for='+this.id+']');if(fieldLabel){fieldLabel.className=fieldLabel.className.replace('-on','-off');var image=fieldLabel.down('img');if(image){image.src=image.src.replace('_hover','_normal');}}
var fieldSet=this.up('fieldset');if(fieldSet&&fieldSet.up('fieldset')){var legend=fieldSet.down('legend');if(legend){legend.className=legend.className.replace('-on','-off');}}},'.auto-clear:focus':function(e){if(this.hasClassName('auto-clear')){this.value='';}
this.removeClassName('auto-clear');},'input.rollover:mouseover':function(el){if(!this.hasClassName('active')){this.className=this.className.replace('-normal','-hover');if(this.type=='image'){this.src=this.src.replace('_normal','_hover');}}},'input.rollover:mouseout':function(e){if(!this.hasClassName('active')){this.className=this.className.replace('-hover','-normal');if(this.type=='image'){this.src=this.src.replace('_hover','_normal');}}}};Event.addBehavior(form_rules);var rollover_rules={'img.rollover:mouseover':function(el){this.src=this.src.replace('_normal','_hover');return false;},'img.rollover:mouseout':function(el){this.src=this.src.replace('_hover','_normal');return false;}};Event.addBehavior(rollover_rules);var flash_rules={'#flash-video-1':function(e){var FO={data:"/flash/test_flash.swf",width:"200",height:"200",xi:"false",flashvars:{apiUrl:"/api"},version:"9.0.0",params:{menu:"false",allowfullscreen:"true"}};swfobject.embedSWF(FO.data,this.id,FO.width,FO.height,FO.version,FO.xi,FO.flashvars,FO.params,FO.attributes);},'#flash-video-2':function(e){var version="10.0.0";swfobject.registerObject(this.id,version);}};Event.addBehavior(flash_rules);