var wait=4500;
var loop=null;
var slides=$$('div.csc-textpic-text');
var c=Math.floor(Math.random()*(slides.length));
var scrolling=0;
if(slides.length>1){
	var scr_up=document.createElement('a');
	scr_up.href='javascript:;';
	scr_up.onclick=function(){
		if(!scrolling){
			clearInterval(loop);
			scrollUp();
		}
	};
	scr_up.id='arr_up';
	$('navigation_content').appendChild(scr_up);
	var scr_down=document.createElement('a');
	scr_down.href='javascript:;';
	scr_down.onclick=function(){
		if(!scrolling){
			clearInterval(loop);
			scrollDown();
		}
	};
	scr_down.id='arr_down';
	$('navigation_content').appendChild(scr_down);
	for(var d=0;d<slides.length;d++){
		if(c!=d){
			slides[d].hide();
			$('navigation_content').appendChild(slides[d]);
		} else {
			updateLink(slides[d]);
		}
		slides[d].style.cursor='pointer';
	}
	loop=setInterval('scrollDown()',wait);
}

function scrollDown(){
	scrolling=1;
	Effect.SlideUp(slides[c],{duration:1, afterFinish:function(){scrolling=0;}});
	c++;if(c==slides.length)c=0;
	$('navigation_content').appendChild(slides[c]);
	Effect.BlindDown(slides[c],{duration:1, afterFinish:function(){updateLink(slides[c]);}});
}

function scrollUp(){
	scrolling=1;
	$('navigation_content').appendChild(slides[c]);
	Effect.BlindUp(slides[c],{duration:1, afterFinish:function(){scrolling=0;}});
	c--;if(c<0)c=slides.length-1;
	Effect.SlideDown(slides[c],{duration:1, afterFinish:function(){updateLink(slides[c]);}});
}

function updateLink(slide){
	var link = slide.getElementsByTagName("a")[0];
	if (link && !link.onclick) {
		slide.onclick=function(){
			location.href = link.href;
		}
	}
}

