var autoHook=true;var defaultOptions={animate:true,showText:true,width:120,boxImage:"/images/bramus/percentImage.png",barImage:"/images/bramus/percentImage_back1.png",height:12};if(!JS_BRAMUS){var JS_BRAMUS=new Object}JS_BRAMUS.jsProgressBar=Class.create();JS_BRAMUS.jsProgressBar.prototype={el:null,id:null,percentage:null,options:null,initialPos:null,pxPerPercent:null,backIndex:null,running:null,queue:false,initialize:function(a,b,c){this.options=Object.clone(defaultOptions);Object.extend(this.options,c||{});this.el=a;this.id=a.id;this.percentage=0;this.backIndex=0;this.running=false;this.queue=Array();this.imgWidth=this.options.width*2;this.initialPos=this.options.width*-1;this.pxPerPercent=this.options.width/100;if(this.options.barImage.constructor!=Array){this.options.barImage=Array(this.options.barImage)}this.el.update('<img id="'+this.id+'_percentImage" src="'+this.options.boxImage+'" alt="0%" style="width: '+this.options.width+"px; height: "+this.options.height+"px; background-position: "+this.initialPos+"px 50%; background-image: url("+this.options.barImage[this.backIndex]+'); padding: 0; margin: 0;"/>'+(this.options.showText==true?'  <span id="'+this.id+'_percentText">0%</span>':""));this.setPercentage(b)},setPercentage:function(a){this.queue.push(a);if(this.running==false){this.processQueue()}},processQueue:function(){if(this.queue.length>0){this.running=true;this.processQueueEntry(this.queue[0])}else{return}},processQueueEntry:function(a){var b=this.percentage;if(a.toString().substring(0,1)=="+"||a.toString().substring(0,1)=="-"){a=b+parseInt(a)}if(a<0)a=0;if(a>100)a=100;if(this.options.animate==false){this.queue.splice(0,1);this._setBgPosition(a);this.running=false;this.processQueue();return}if(a!=b){if(b<a){newPercentage=b+1}else{newPercentage=b-1}}else{newPercentage=b}this._setBgPosition(newPercentage);if(b!=newPercentage){setTimeout(function(){this.processQueueEntry(a)}.bind(this),10)}else{this.queue.splice(0,1);this.running=false;this.processQueue();return}},getPercentage:function(a){return this.percentage},_setBgPosition:function(a){$(this.id+"_percentImage").style.backgroundPosition=""+(this.initialPos+a*this.pxPerPercent)+"px 50%";var b=Math.floor((a-1)/(100/this.options.barImage.length));if(b!=this.backIndex&&this.options.barImage[b]!=undefined){$(this.id+"_percentImage").style.backgroundImage="url("+this.options.barImage[b]+")"}this.backIndex=b;$(this.id+"_percentImage").alt=""+a+"%";$(this.id+"_percentImage").title=""+a+"%";if(this.options.showText==true){$(this.id+"_percentText").update(""+a+"%")}this.percentage=a}};JS_BRAMUS.jsProgressBarHandler=Class.create();JS_BRAMUS.jsProgressBarHandler.prototype={pbArray:new Array,initialize:function(){$$("span.progressBar").each(function(a){this.pbArray[a.id]=new JS_BRAMUS.jsProgressBar(a,parseInt(a.innerHTML.replace("%","")))}.bind(this))},setPercentage:function(a,b){this.pbArray[a].setPercentage(b)},getPercentage:function(a){return this.pbArray[a].getPercentage()}};if(autoHook==true){function initProgressBarHandler(){myJsProgressBarHandler=new JS_BRAMUS.jsProgressBarHandler}Event.observe(window,"load",initProgressBarHandler,false)}
