var counthiddendivs;

var browser;
var opacityvalue = 0;

var iteratorHid;
	
//czasy
var speedHid = 0.01;
var intervalHid = 2;
var pauseHid = 2500;
			
//tablica divow do przewijania
var slidersHid = new Array();

function resetHid() {
	
	//ustawienie iteratora
	iteratorHid = 0;
	
}

function show(current) {

	opacityvalue = opacityvalue + speedHid;
	
	if(browser == 'Microsoft Internet Explorer') {
		temp = (opacityvalue * 100);
		slidersHid[1].getElementsByTagName('div')[current].style.filter = "alpha(opacity = " + temp + ")";
	} else {
		slidersHid[1].getElementsByTagName('div')[current].style.opacity = opacityvalue;
	}
	
	if(opacityvalue <= 1) {
		shower(current, 'show');
	} else {
		//przerwa, kiedy produkt jest wyswietlany byz zmiany wartosci opacity
		setTimeout('shower(' + current + ', "hide")', pauseHid);
	}
	
}

function hide(current) {
	
	opacityvalue = opacityvalue - speedHid;
	// ukrywanie jest zalezne od przegladarki
	if(browser == 'Microsoft Internet Explorer') {
		temp = (opacityvalue * 100);
		slidersHid[1].getElementsByTagName('div')[current].style.filter = "alpha(opacity = " + temp + ")";
	} else {
		slidersHid[1].getElementsByTagName('div')[current].style.opacity = opacityvalue;
	}
	
	if(opacityvalue > 0) {
		shower(current, 'hide');
	} else {
		slidersHid[1].getElementsByTagName('div')[iteratorHid].style.display = 'none';
		iteratorHid++;
		mainHid();
	}
}

function shower(current, action) {
	
	if(action == 'show') {
		setTimeout('show(' + current + ')', intervalHid);
	} else {
		setTimeout('hide(' + current + ')', intervalHid);
	}
	
}

function mainHid() {

	var temp = ((iteratorHid < counthiddendivs) ? iteratorHid : (iteratorHid - 1));
	
	if(iteratorHid == counthiddendivs) {
		resetHid();
	}
	
	slidersHid[1].getElementsByTagName('div')[iteratorHid].style.display = 'block';
	
	shower(iteratorHid, 'show');
	
}
