// JavaScript Document

function KBSlider(wrap_id,block_width)
{setTimeout("kb_slider.init('"+wrap_id+"',"+block_width+");",0);}
KBSlider.prototype={init:function(wrap_id,block_width){this._ready=false;
this._sliding=false;
this._clicked=false;
this.slide_auto_delay=6000;
this.slide_width=block_width;
this.slide_distance=50;
this.slide_dec=0.6;
this.current_slide=0;
this.wrapper=document.getElementById(wrap_id);

if(!this.wrapper){alert("Couldn't find elemnt with id "+wrap_id);return false;}
this.num_current=document.getElementById('slide_current');
this.num_total=document.getElementById('slide_total');
this.slide_elements=this.wrapper.getElementsByTagName("DIV");
this.slides=[];var c=0;for(var i=0;i<this.slide_elements.length;i++){if(this.slide_elements[i].className.match(/slide/)){if(c>0){this.slide_elements[i].style.display='none';}
this.slide_elements[i].id='s'+c;this.slides.push(this.slide_elements[i]);c++;}}
if(this.num_total){this.num_total.innerHTML=this.slides.length;}
this._ready=true;var slide_controls=document.getElementById('slide_controls');

if(slide_controls)slide_controls.style.display='';setTimeout("kb_slider.slide(1,true);",this.slide_auto_delay);},ready:function(){return this._ready;},slide:function(direction,automatic)
{if(typeof automatic=="undefined"){this._clicked=true;}
if(!this.ready())return false;if(this._sliding)return false;
if(this._clicked&&automatic)return false;this._sliding=true;var old_slide=this.current_slide;var new_slide=direction<0?this.prevSlide():this.nextSlide();this.slides[new_slide].style.left=(this.slide_width*direction)+"px";this.slides[new_slide].style.display='';this.slides[new_slide].zIndex=10;this.slides[old_slide].zIndex=1;this.current_slide=new_slide;if(this.num_current)this.num_current.innerHTML=this.current_slide+1;this.slideMove(new_slide,old_slide,direction,0);},slideMove:function(new_slide,old_slide,direction,current){if((current/this.slide_width)>this.slide_dec){var divisor=(1-(current/this.slide_width))/(1-this.slide_dec);divisor=Math.round(((.9*divisor)+.1)*100)/100;var distance=Math.round(this.slide_distance*divisor);}else{var distance=this.slide_distance;}
current+=distance;if(current>this.slide_width)current=this.slide_width;this.slides[new_slide].style.left=((direction*this.slide_width)-(direction*current))+"px";this.slides[old_slide].style.left=(0-(direction*current))+"px";if(current<this.slide_width){setTimeout("kb_slider.slideMove("+new_slide+","+old_slide+","+direction+","+current+");",50);}else{this._sliding=false;if(!this._clicked){setTimeout("kb_slider.slide(1,true);",this.slide_auto_delay);}}},nextSlide:function(){return this.current_slide+1>=this.slides.length?0:this.current_slide+1;},prevSlide:function(){return this.current_slide==0?this.slides.length-1:this.current_slide-1;}}
function kbTrackLink(tracking_link)
{if(typeof(pageTracker)!='undefined'){pageTracker._trackPageview(tracking_link);}}
