var testimonials=new Array(), current=Math.random(), delay=15, dwell=20, step=25, sliderStart=-195;

function slide_init() {
	if(!document.getElementById || !document.createElement) return;
	css=document.createElement("link");
	css.setAttribute("href","/css/slide.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	document.getElementsByTagName("head")[0].appendChild(css);
	testimonials=document.getElementById("testimonials").getElementsByTagName("div");
	current=Math.floor((testimonials.length)*Math.random());
	previous=((current-1<0)?testimonials.length-1:current-1);
	sliderX=sliderStart;
	slide();
}

function slide(){
	sliderX=sliderX+step;
	testimonials[current].style.right=sliderX+"px";
	
	if(sliderX>=0){
		testimonials[current].style.right=0;
		testimonials[current].style.zIndex=0;
		testimonials[previous].style.display="none";
		previous=current;
		current=((testimonials[current+1])?current+1:0);
		testimonials[current].style.right=sliderStart+"px";
		testimonials[current].style.zIndex=1;
		testimonials[current].style.display="block";
		sliderX=sliderStart;
		setTimeout(slide,delay*1000);
	}else{
		setTimeout(slide,dwell);
	}
}
