addLoadEvent(function(){addElementClass(document.body,'js');});function hideFocus(element){var elements=document.getElementsByTagName(element);for(var i in elements){elements[i].hideFocus=true;};};if(document.all)
addLoadEvent(function(){hideFocus("input");hideFocus("a");});function toggleShowHide(id){toggleElementClass('help_popup_visible',id);}
function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;}
function getPageScroll(){var yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;}else if(document.body){yScroll=document.body.scrollTop;}
arrayPageScroll=new Array('',yScroll)
return arrayPageScroll;}
function setUpOverlay(){var overlay=DIV({'id':'overlay'});setOpacity(overlay,0.6);overlay.style.height=getPageSize()[1]+"px";appendChildNodes(document.body,overlay);};addLoadEvent(setUpOverlay);function HelpPopUp(toggle,type){this.toggle=toggle;this.target=$(this.toggle.href.split("#")[1]);this.type=type;this.hidden=true;if(this.target&&this.target.innerHTML.length){removeElementClass(this.toggle,'hidden');this.buildHTML();this.attach();}else{addElementClass(this.toggle,'hidden');};};HelpPopUp.setup=function(container){if(container==null){container=$('content');}
var toggles=getElementsByTagAndClassName("a","helptoggle",$('content'));for(var i=0;i<toggles.length;i++){var toggle=toggles[i],type="overlay";if(hasElementClass(toggle,"questionnaire")){type="questionnaire";}else if(hasElementClass(toggle,"tip")){type="tip";};new HelpPopUp(toggle,type);};};HelpPopUp.prototype={attach:function(){this.toggle.onclick=bind(this.togglePopUp,this);if(this.type=="tip"){var listItem=$('tip_'+this.target.id.replace("hint",""));listItem.onmouseover=bind(function(){removeElementClass(this.toggle,'helptoggle_inactive');},this);listItem.onmouseout=bind(function(){addElementClass(this.toggle,'helptoggle_inactive');},this);};},show:function(event){if(this.type=="overlay"||this.type=="tip"){$('overlay').style.display="block";$('overlay').onclick=bind(this.hide,this);this.popUp.style.top=(getPageScroll()[1]+200)+"px";this.popUp.style.display="block";}else{this.popUp.style.display="block";this.questionImage.style.display="none";this.updateScrollButtonsDisabledState();if(this.upButton.disabled&&this.downButton.disabled){this.upButton.style.display="none";this.downButton.style.display="none";};};this.hidden=false;return false;},hide:function(event){if(this.type=="overlay"||this.type=="tip"){$('overlay').style.display="none";$('overlay').onclick=null;}else{this.questionImage.style.display="block";};this.popUp.style.display="none";this.hidden=true;return false;},togglePopUp:function(){this.hidden?this.show():this.hide();return false;},scrollUp:function(){this.startScrolling(5,this.upButton,bind(this.canScrollUp,this));return false;},scrollDown:function(){this.startScrolling(-5,this.downButton,bind(this.canScrollDown,this));return false;},startScrolling:function(howMuch,button,condition){var scrollCall=bind(function(){this.doScroll(howMuch,button,condition);},this);this.interval=window.setInterval(scrollCall,50);scrollCall();button.onmouseup=bind(this.clearInterval,this);},doScroll:function(howMuch,button,condition){if(condition()){this.scrollTop+=howMuch;this.updateScroll();};this.updateScrollButtonsDisabledState();if(button.disabled){this.clearInterval();};},clearInterval:function(){window.clearInterval(this.interval);},updateScroll:function(){this.contentDiv.style.clip="rect("+this.scrollTop+"px, 268px, "+this.scrollBottom()+"px, 0)";this.contentDiv.style.top=this.scrollTop+"px";},scrollBottom:function(){return this.height-this.scrollTop;},canScrollUp:function(){return this.scrollTop<0;},canScrollDown:function(){return this.scrollBottom()<elementDimensions(this.contentDiv).h;},updateScrollButtonsDisabledState:function(){this.updateScrollButtonDisabledState(this.upButton,this.canScrollUp());this.updateScrollButtonDisabledState(this.downButton,this.canScrollDown());},updateScrollButtonDisabledState:function(button,canScroll){if(canScroll){if(button.disabled){removeElementClass(button,"disabled");button.disabled=false;};}else{if(!button.disabled){addElementClass(button,"disabled");button.disabled=true;};};},buildHTML:function(){var bottomCurve=DIV({'class':'bottom'});var topCurve=DIV({'class':'top'});var closeLink=A({'href':'#','class':'close'},"close");closeLink.onclick=bind(this.hide,this);this.contentDiv=DIV({'class':'content'});this.contentDiv.innerHTML=this.target.innerHTML;this.popUp=DIV({'class':this.type+'_pop_up'},topCurve,this.contentDiv,bottomCurve);this.popUp.style.display="none";if(this.type=="overlay"||this.type=="tip"){this.popUp.style.top=(getPageScroll()[1]+200)+"px";this.popUp.style.left=((getPageSize()[0]-500)/2)+"px";this.contentDiv.insertBefore(closeLink,this.contentDiv.childNodes[0]);appendChildNodes(document.body,this.popUp);}else{this.popUp.insertBefore(closeLink,this.contentDiv);this.questionImage=getElementsByTagAndClassName("img","questionimage")[0];var parent=this.questionImage.parentNode;this.height=elementDimensions(parent).h;this.popUp.style.height=this.height+"px";this.upButton=A({'class':'up'},translations.up);this.upButton.onmousedown=bind(this.scrollUp,this);this.upButton.disabled=false;this.downButton=A({'class':'down'},translations.down);this.downButton.onmousedown=bind(this.scrollDown,this);this.downButton.disabled=false;var scrollDiv=DIV({'class':'scroll'},this.upButton,this.downButton);this.popUp.insertBefore(scrollDiv,this.contentDiv);this.scrollTop=0;this.updateScroll();parent.insertBefore(this.popUp,this.questionImage);};}};addLoadEvent(HelpPopUp.setup);function update_preview(source_element_id,target_element_id){var source_element=document.getElementById(source_element_id);if(source_element){var value=source_element.value;if(value.length!=0)
document.getElementById(target_element_id).innerHTML=value;}}
function updateCheckboxStatusClass(checkboxId,label){var checkbox=$(checkboxId);setTimeout(function(){if(checkbox.checked){addElementClass(label,'checked');}else{removeElementClass(label,'checked');}},10);}
function updateAvatarChooser(buttonId){button=$(buttonId);if(!button)return;button.checked=true;updateAvatarChooserHighlight(button);}
function updateAvatarChooserHighlight(button){if(!button)return;setTimeout(function(){if(button.checked){var labels=getElementsByTagAndClassName('label',null,'avatar_list');for(var i=0;i<labels.length;i++){if(labels[i].htmlFor==button.id){addElementClass(labels[i],'selected');}else{removeElementClass(labels[i],'selected');}}}},10)}
function breakOutOfFrames(){if(top.location!=location){top.location.href=document.location.href;}}
addLoadEvent(breakOutOfFrames);ROLLUP_ANIM_RATE=20;ROLLUP_ANIM_STEP=10;function initRollUp(elem){elem.originalHeight=elementDimensions(elem).h+20;elem.style.height='0px';elem.style.overflow='hidden';elem.shown=false;}
function toggleRollUp(elem){if(elem.shown){elem.shown=false;elem.animationStep=-ROLLUP_ANIM_STEP;animateRollUp(elem);return false;}else{elem.shown=true;elem.animationStep=+ROLLUP_ANIM_STEP;animateRollUp(elem);return true;}}
function showRollUp(elem){elem.shown=true;elem.style.height=elem.originalHeight+'px';}
function animateRollUp(elem){var newHeight=elementDimensions(elem).h+elem.animationStep;if(elem.animationStep<0&&newHeight<=0){elem.style.height='0px';}else if(elem.animationStep>0&&newHeight>=elem.originalHeight){elem.style.height=elem.originalHeight+'px';}else{elem.style.height=newHeight+'px';setTimeout(function(){animateRollUp(elem)},ROLLUP_ANIM_RATE);}}
addLoadEvent(function(){forEach(getElementsByTagAndClassName(null,'announcement'),addAnnouncementRollup);});function addAnnouncementRollup(announcement){var announcementDetail=getElementsByTagAndClassName(null,'announcement_detail',announcement)[0];if(announcementDetail==null)return;initRollUp(announcementDetail);var readMoreLink=A({'href':'#','onclick':function(){var isShowing=toggleRollUp(announcementDetail);this.innerHTML=(isShowing?'Hide':'Read more...');return false;}},'Read more...');var announcementIntro=getElementsByTagAndClassName('p','announcement_intro',announcement)[0];announcementIntro.appendChild(document.createTextNode(' '));announcementIntro.appendChild(readMoreLink);}
var planetWidth=75;var maximumWidth=planetWidth*5;var breakdownMinWidth=30;var animationStepSize=.05;var tickLength=20;var breakdownWidthAdjustment=-3;var breakdownCategories=['food','travel','home','stuff'];var planetsHtml,footprintFigureNumHtml,emissionsBarNumHtml,hectaresNumHtml,futureFootprintFigureNumHtml,nonfootprintableNoticeHtml;var wiEmissionsReductionNumHtml,wiReduceEmissionsMessageHtml,wiCompletedMessageHtml;var breakdownSegmentsHtml={};var breakdownNumsHtml={};var breakdownLabelsHtml={};var currentFootprint;var displayedFootprint;var isAnimating=false;var animationProgress=0;var targetFootprint;var nonfootprintableNoticeIsAnimating=false;var nonfootprintableAnimationStartTime;var nonfootprintableNoticeDuration=15000;var breakdownIsShown=false;var wiCarbonChallengeTarget=0;function initFootprint(){planetsHtml=$('planets');footprintFigureNumHtml=$('footprint_figure_num');futureFootprintFigureNumHtml=$('future_footprint_figure_num');futureCarbonFigureNumHtml=$('future_carbon_figure_num');emissionsBarNumHtml=$('emissions_bar_num');hectaresNumHtml=$('hectares_num');nonfootprintableNoticeHtml=$('non_footprintable_notice');wiEmissionsReductionNumHtml=$('wi_emissions_reduction_num');wiReduceEmissionsMessageHtml=$('wi_reduce_emissions_message')
wiCompletedMessageHtml=$('wi_completed_message')
if($('breakdown_bar')){breakdownIsShown=true;for(i=0;i<breakdownCategories.length;i++){var cat=breakdownCategories[i];breakdownSegmentsHtml[cat]=$('breakdown_'+cat);breakdownNumsHtml[cat]=$('breakdown_num_'+cat);breakdownLabelsHtml[cat]=$('breakdown_label_'+cat);}}}
function setFootprint(fp){currentFootprint=fp;displayFootprint(fp);}
function displayFootprint(fp){var width=planetWidth*fp.planets;width=Math.min(width,maximumWidth);planetsHtml.style.width=width+'px';replaceChildNodes(footprintFigureNumHtml,fp.planets.toFixed(2));replaceChildNodes(emissionsBarNumHtml,fp.emissions.toFixed(2));if(hectaresNumHtml){replaceChildNodes(hectaresNumHtml,fp.global_hectares.toFixed(2));}
if(futureFootprintFigureNumHtml&&fp.future_planets){replaceChildNodes(futureFootprintFigureNumHtml,fp.future_planets.toFixed(2));}
if(futureCarbonFigureNumHtml&&fp.future_carbon){replaceChildNodes(futureCarbonFigureNumHtml,fp.future_carbon.toFixed(2));}
if(breakdownIsShown){var remainingWidth=width;var remainingProportion=100;var segmentUpdates=[];for(cat in fp.breakdown){segmentUpdates.push({category:cat,proportion:fp.breakdown[cat]});}
segmentUpdates.sort(function(a,b){return a.proportion-b.proportion;});for(var i=0;i<segmentUpdates.length;i++){var seg=segmentUpdates[i];var idealSegmentWidth=remainingWidth*(seg.proportion/remainingProportion);var actualSegmentWidth=Math.max(breakdownMinWidth,idealSegmentWidth)
breakdownSegmentsHtml[seg.category].style.width=(actualSegmentWidth+breakdownWidthAdjustment)+'px';replaceChildNodes(breakdownNumsHtml[seg.category],(seg.proportion).toFixed(0));remainingWidth-=actualSegmentWidth;remainingProportion-=seg.proportion;}}
if(wiEmissionsReductionNumHtml){var reduction=fp.emissions-wiCarbonChallengeTarget;if(reduction>0){wiReduceEmissionsMessageHtml.className='';wiCompletedMessageHtml.className='hidden';}else{wiReduceEmissionsMessageHtml.className='hidden';wiCompletedMessageHtml.className='';}
replaceChildNodes(wiEmissionsReductionNumHtml,Math.max(0.01,reduction).toFixed(2));}
displayedFootprint=fp;}
function animateFootprint(fp){currentFootprint=displayedFootprint;targetFootprint=fp;animationProgress=0;if(!isAnimating){isAnimating=true;animateFootprintStep();}}
function animateFootprintStep(){animationProgress+=animationStepSize;if(animationProgress>=1){displayFootprint(targetFootprint);isAnimating=false;}else{var fp={breakdown:{}};for(cat in currentFootprint.breakdown){fp.breakdown[cat]=animationProgress*targetFootprint.breakdown[cat]+(1-animationProgress)*currentFootprint.breakdown[cat];}
fp.planets=animationProgress*targetFootprint.planets+(1-animationProgress)*currentFootprint.planets;fp.future_planets=animationProgress*targetFootprint.future_planets+(1-animationProgress)*currentFootprint.future_planets;fp.emissions=animationProgress*targetFootprint.emissions+(1-animationProgress)*currentFootprint.emissions;fp.global_hectares=animationProgress*targetFootprint.global_hectares+(1-animationProgress)*currentFootprint.global_hectares;displayFootprint(fp);setTimeout(animateFootprintStep,tickLength)}}
function showNonfootprintable(){nonfootprintableAnimationStartTime=new Date().getTime();if(!nonfootprintableNoticeIsAnimating){nonfootprintableNoticeIsAnimating=true;animateNonfootprintableStep();}}
function hideNonfootprintable(){nonfootprintableNoticeIsAnimating=false;}
function animateNonfootprintableStep(){var t=(new Date().getTime())-nonfootprintableAnimationStartTime;if(!nonfootprintableNoticeIsAnimating||t>=nonfootprintableNoticeDuration){nonfootprintableNoticeHtml.style.visibility='hidden';nonfootprintableNoticeIsAnimating=false;}else{if(t<250){setOpacity(nonfootprintableNoticeHtml,t/250);}else if(t<nonfootprintableNoticeDuration-2000){setOpacity(nonfootprintableNoticeHtml,1);}else{setOpacity(nonfootprintableNoticeHtml,(nonfootprintableNoticeDuration-t)/2000);}
nonfootprintableNoticeHtml.style.visibility='visible';setTimeout(animateNonfootprintableStep,tickLength)}}
var activeExpandable=null;var inactiveWrapperClass="dropdown_menu";var activeWrapperClass="dropdown_menu_active";var applyDropdownMenu=function(expandableId,targetId){var expandable=$(expandableId);var target=$(targetId);if(target!=null){expandable.targetElement=target;addElementClass(target,'scripted');addElementClass(expandable,'scripted');hideElement(expandable);addToCallStack(target,'onclick',bind(showOrHideExpandable,expandable));}}
var showExpandable=function(expandable){showElement(expandable);addElementClass(expandable.targetElement,"activetarget");activeExpandable=expandable;expandable.parentNode.className=activeWrapperClass;}
var hideExpandable=function(expandable){hideElement(expandable);removeElementClass(expandable.targetElement,"activetarget");activeExpandable=null;expandable.parentNode.className=inactiveWrapperClass;}
var handleBodyClick=function(){if(activeExpandable!=null){hideExpandable(activeExpandable,activeExpandable.targetElement);}}
var stopEventPropagation=function(theEvent){if(theEvent&&theEvent.stopPropagation){theEvent.stopPropagation();}else{event.cancelBubble=true;}}
var showOrHideExpandable=function(clickEvent){if(activeExpandable==this){hideExpandable(this);}else{if(activeExpandable!=null){hideExpandable(activeExpandable);}
showExpandable(this);}
stopEventPropagation(clickEvent);}
addToCallStack(document,'onclick',handleBodyClick);var frameActions=[];var frameIsScheduled=false;function scheduleFrameAction(f){frameActions.push(f);if(!frameIsScheduled){frameIsScheduled=true;setTimeout(doFrame,50);}}
function doFrame(){frameIsScheduled=false;var currentFrameActions=[];while(frameActions.length){currentFrameActions.push(frameActions.shift());}
for(var i=0;i<currentFrameActions.length;i++){currentFrameActions[i]();}}
var tipsAccepted=0;function showEncouragementMessage(container){if(getElementsByTagAndClassName('div','encouragement_message',container).length>0){return;}else{container.appendChild(DIV({'class':'encouragement_message'},P(null,translations.well_done_more_eco_tips),IMG({'src':'/images/lang/'+languageCode+'/buttons/continue.gif','width':130,'height':39,'class':'button','onclick':function(){removeElement(this.parentNode);}})));}}
function makePledge(url,tipHtmlId,responseIsPositive){xhr=getXMLHttpRequest();if(!xhr){var f=FORM({'action':url,'method':'POST'});document.body.appendChild(f);f.submit();}else{var sourceListUl=$(tipHtmlId).parentNode;xhr.open("POST",url+'&source_list_id='+sourceListUl.id+'&source_list_class='+sourceListUl.className.match(/\btiplist-\S+/)[0]);xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");fadeOutPledge(tipHtmlId);if(responseIsPositive){tipsAccepted++;if(tipsAccepted%10==0){showEncouragementMessage(sourceListUl.parentNode);}}
response=sendXMLHttpRequest(xhr);response.addCallback(function(xhr){var updates=eval('('+xhr.responseText+')');var newPledge=updates.new_pledge;var destinationList=$('tiplist-pledges'+newPledge.status);if(destinationList){$('block-pledges'+newPledge.status).style.display='block';var destinationListParams=destinationList.className.match(/\btiplist-(grouped|ungrouped)-section(\d*)-size(\d*)-page(\d*)-pagesize(\d*)\b/);if(destinationListParams[1]=='grouped'){var lis=childElements(destinationList,"LI");for(var i=0;i<lis.length;i++){var pledgeSection=lis[i].className.match(/\bsection(\d+)\b/)[1];if(pledgeSection>=newPledge.section)break;}
attachPledge(newPledge.html,destinationList,lis[i]);if(destinationListParams[3]){var size=destinationListParams[3];lis=childElements(destinationList,"LI");if(lis.length>size){var sectionCounts=[];for(var i=0;i<lis.length;i++){var pledgeSection=lis[i].className.match(/\bsection(\d+)\b/)[1];if(sectionCounts[pledgeSection]==null){sectionCounts[pledgeSection]=1}else{sectionCounts[pledgeSection]++}}
var maxid=0;var maxcount=0;for(var id in sectionCounts){if(sectionCounts[id]>=maxcount&&id>maxid){maxid=id;maxcount=sectionCounts[id];}}
var toRemove=getElementsByTagAndClassName('LI','section'+maxid,destinationList);fadeOutPledge(toRemove[toRemove.length-1]);}}}else{attachPledge(newPledge.html,destinationList,destinationList.firstChild);if(destinationListParams[3]){var size=destinationListParams[3];var lis=childElements(destinationList,"LI");if(lis.length>size){fadeOutPledge(lis[size]);}}}}
var sourceList=$(updates.source_list_id);var lis=childElements(sourceList,"LI");for(var i=lis.length-1;i>=0;i--){if(hasElementClass(lis[i],'fading-out')){lis.splice(i,1);}}
for(var i=0;i<updates.source_list.length;i++){if(lis[i]==null||updates.source_list[i].id!=lis[i].id){attachPledge(updates.source_list[i].html,sourceList,lis[i]);break;}}
if(updates.source_list.length==0){var completedMessage=getElementsByTagAndClassName(null,'all_recommendations_completed_message',sourceList.parentNode);if(completedMessage.length){completedMessage[0].style.display='block';}}
var previousFootprint=targetFootprint||currentFootprint;if(previousFootprint.planets.toFixed(2)==updates.footprint.planets.toFixed(2)&&previousFootprint.future_planets.toFixed(2)==updates.footprint.future_planets.toFixed(2)){if(!updates.footprint.suppress_model_warning){showNonfootprintable();}else{hideNonfootprintable();}}else{hideNonfootprintable();animateFootprint(updates.footprint);}});}}
var TIP_HEIGHT=38;var TIP_PADDING=3;function fadeOutPledge(id){var elem=$(id);elem.id=null;addElementClass(elem,'fading-out');var fadeProgress=0;elem.style.overflow='hidden';var fadeOutPledgeStep=function(){if(fadeProgress<1){setOpacity(elem,1-fadeProgress);elem.style.height=((1-fadeProgress)*TIP_HEIGHT)+'px';elem.style.paddingTop=((1-fadeProgress)*TIP_PADDING)+'px';elem.style.paddingBottom=((1-fadeProgress)*TIP_PADDING)+'px';fadeProgress+=.05;scheduleFrameAction(fadeOutPledgeStep);}else{var ul=elem.parentNode;removeElement(elem);resetAlternatingClasses(ul);}}
fadeOutPledgeStep();}
function fadeInPledge(id){var elem=$(id);var fadeProgress=0;elem.style.overflow='hidden';elem.style.height='0';elem.style.paddingTop='0';elem.style.paddingBottom='0';setOpacity(elem,0);elem.style.display='block';var fadeInPledgeStep=function(){if(fadeProgress<1){setOpacity(elem,fadeProgress);elem.style.height=(fadeProgress*TIP_HEIGHT)+'px';elem.style.paddingTop=(fadeProgress*TIP_PADDING)+'px';elem.style.paddingBottom=(fadeProgress*TIP_PADDING)+'px';fadeProgress+=.05;scheduleFrameAction(fadeInPledgeStep);}else{setOpacity(elem,1);elem.style.height=TIP_HEIGHT+'px';elem.style.paddingTop=TIP_PADDING+'px';elem.style.paddingBottom=TIP_PADDING+'px';resetAlternatingClasses(elem.parentNode);elem.style.overflow='visible';}}
fadeInPledgeStep();}
function resetAlternatingClasses(ul){var lis=childElements(ul,'LI');for(var i=0;i<lis.length;i++){addElementClass(lis[i],"s"+(i%2));removeElementClass(lis[i],"s"+(1-(i%2)));}}
function childElements(parent,tagName){var children=[];for(i=0;i<parent.childNodes.length;i++){if(parent.childNodes[i].tagName==tagName){children.push(parent.childNodes[i]);}}
return children;}
function attachPledge(html,list,before){var temp=DIV();temp.innerHTML=html;var newTip=childElements(temp,"LI")[0];if(before){list.insertBefore(newTip,before);}else{list.appendChild(newTip);}
applyDropdownMenu(getElementsByTagAndClassName('ul','dropdown_menu_list',newTip)[0],getElementsByTagAndClassName('a','dropdown_menu_trigger',newTip)[0]);HelpPopUp.setup(newTip);fadeInPledge(newTip);}
var avatarScrollerCanvas;var avatarScrollerCurrentColumn=0;var avatarScrollerCurrentLeft=0;var avatarScrollerColumnCount;var avatarScrollerLeft;var avatarScrollerRight;var avatarScrollerAnimating=false;var AVATAR_COLUMN_WIDTH=175;var AVATAR_SCROLLER_START_SPEED=1;var AVATAR_SCROLLER_ACCEL=0.7;var avatarScrollerSpeed=AVATAR_SCROLLER_START_SPEED;function initAvatarScroller(){avatarScrollerCanvas=$('avatar_canvas');if(!avatarScrollerCanvas)return;avatarScrollerLeft=$('avatar_scroller_left');avatarScrollerRight=$('avatar_scroller_right');avatarScrollerColumnCount=getElementsByTagAndClassName('div','avatar_column',avatarScrollerCanvas).length;avatarScrollerCanvas.style.width=(avatarScrollerColumnCount*AVATAR_COLUMN_WIDTH)+'px';avatarScrollerLeft.onclick=function(){if(avatarScrollerCurrentColumn>0){avatarScrollerCurrentColumn--;avatarScrollerSetArrowVisibility();if(!avatarScrollerAnimating)avatarScrollerAnim();}}
avatarScrollerRight.onclick=function(){if(avatarScrollerCurrentColumn<(avatarScrollerColumnCount-1)){avatarScrollerCurrentColumn++;avatarScrollerSetArrowVisibility();if(!avatarScrollerAnimating)avatarScrollerAnim();}}
avatarScrollerCanvas.style.left='0px';avatarScrollerLeft.style.visibility='hidden';avatarScrollerSetArrowVisibility();}
function avatarScrollerSetArrowVisibility(){avatarScrollerLeft.style.visibility=(avatarScrollerCurrentColumn==0?'hidden':'visible');avatarScrollerRight.style.visibility=(avatarScrollerCurrentColumn>=(avatarScrollerColumnCount-1)?'hidden':'visible');}
function avatarScrollerAnim(){avatarScrollerAnimating=true;var target=-(avatarScrollerCurrentColumn*AVATAR_COLUMN_WIDTH);avatarScrollerSpeed+=AVATAR_SCROLLER_ACCEL;if(avatarScrollerCurrentLeft<target){avatarScrollerCurrentLeft+=avatarScrollerSpeed;if(avatarScrollerCurrentLeft>=target){avatarScrollerCurrentLeft=target;avatarScrollerCanvas.style.left=avatarScrollerCurrentLeft+'px';avatarScrollerSpeed=AVATAR_SCROLLER_START_SPEED;avatarScrollerAnimating=false;}else{avatarScrollerCanvas.style.left=avatarScrollerCurrentLeft+'px';setTimeout(avatarScrollerAnim,20);}}else{avatarScrollerCurrentLeft-=avatarScrollerSpeed;if(avatarScrollerCurrentLeft<=target){avatarScrollerCurrentLeft=target;avatarScrollerCanvas.style.left=avatarScrollerCurrentLeft+'px';avatarScrollerSpeed=AVATAR_SCROLLER_START_SPEED;avatarScrollerAnimating=false;}else{avatarScrollerCanvas.style.left=avatarScrollerCurrentLeft+'px';setTimeout(avatarScrollerAnim,20);}}}
function togglePostcode(visible){if(visible)
$('postcodeContainer').style.display='block';else $('postcodeContainer').style.display='none';};addLoadEvent(initAvatarScroller);
