function getRollableDivs() {

	var divs = document.getElementById('sliders').getElementsByTagName('div');
	div_ok = new Array(); 
	var y = 1;
	for(var x=0; x < divs.length; x++){

		if(navigator.appName == 'Netscape') var ga = divs[x].getAttribute("class");
		else var ga = divs[x].className;

		if(ga == 'active-produkt-slider') {
			div_ok[y] = divs[x];
			div_ok[y].onclick = function () { ShowDiv(this); }
			y = y + 1;
		}
	}
	if(div_ok[1]) ShowDiv(div_ok[1]);
}
function HideAllDivs(){
	for(var x=1; x <= div_ok.length; x++){
		if(div_ok[x]) setStyle(div_ok[x], "" );
	}
}
function ShowDiv(xdiv){
	HideAllDivs();
	//var obj = document.getElementById(xdiv);
	setStyle( xdiv , "height: 280px;" );
}

function setStyle( object, styleText ) {
	if( object.style.setAttribute ) { object.style.setAttribute("cssText", styleText ); }
	else { object.setAttribute("style", styleText ); }
}

window.onload = function (){
	getRollableDivs();
	
	var slideDuration = 3000; //how long will be displayed a single slide (in miliseconds)
	var transitionTime = 400; //speed of transitions between slides (in miliseconds)
	var transitionTimeP = transitionTime * 0.001;
	var notHoveringFeatured = true;

	if(($('promo')) && ($('promo').childNodes)){
		//Variable defaults
		var slideCount = $('promo').childNodes.length;
		var slideCurrent = 0;
		var slideLastCurrent = slideCount - 1;
		//var liHeight = $('promo').childNodes[0].offsetHeight;
		
		for(var i = 1; i < slideCount; i++){
			Element.setOpacity($('promo').childNodes[i], 0);
		}
	
		//Animation
		function switchIt() {
			slideLastCurrent = slideCurrent;
			slideCurrent = (slideCurrent + 1)%slideCount;
			
			var slideLC = $('promo').childNodes[slideLastCurrent];
			new Effect.Opacity( slideLC, { duration: transitionTimeP, from: 1.0, to: 0, afterFinish: function () {
				$(slideLC).setStyle({
  					top: '290px'
				});
				//Element.setTop( slideLC, 290 );
			}} );
			
			var slideC = $('promo').childNodes[slideCurrent];
			$(slideC).setStyle({
  				top: '0'
			});             	
			//Element.setTop( slideC, 0 );
			new Effect.Opacity( slideC, { duration: transitionTimeP, from: 0, to: 1.0 } );
	
		} // /switchIt()
		
		//pressing navigation buttons
		if($('promo').nextSibling) $('promo').nextSibling.onclick = switchIt;
	
		//transitions stop when hovering these objects:
		$('promo').observe('mouseover', function() {notHoveringFeatured = false});
		$('promo').observe('mouseout', function() {notHoveringFeatured = true});
	
		//Repeated execution of switchIt() function
		function doRepeat ()
		{
		  if (slideCount > 1 && notHoveringFeatured === true) switchIt();
		}
		setInterval ( doRepeat, (slideDuration-transitionTime) );
	}
};

