var slideshowProductImageID = 001
var slideshowHomeImageID = 00

function mShow(element){
	
	$(element).addClassName("hover");
}

function mHide(element){

	$(element).removeClassName("hover");
}

function switchProductImage(){
	var _imgArr = new Array("product_01.jpg", "product_02.jpg");
	++slideshowProductImageID;
	var _currentImgNr = (slideshowProductImageID%_imgArr.length);
	var _imgName = _imgArr[_currentImgNr];
	var newImgUrl = "url(fileadmin/user_upload/images/slideshow/spenden-und-shoppen/"+_imgName+")";
	$('productslideshow').style.backgroundImage = newImgUrl;
	new Effect.Opacity('product_transition', {
		duration:0.3,
		from:1.0,
		to:0.0,
		afterFinish: function () {
			$('product_transition').style.backgroundImage = newImgUrl;
			new Effect.Opacity('product_transition', {	
				duration:0.3,
				from:0.0,
				to:1.0
			});
		}
	});
}

function switchBackgroundImage(){
	var imgArr = new Array('00.jpg','01.jpg','02.jpg','03_edited.jpg','04.jpg','05.jpg','06.jpg','07.jpg','08_edited.jpg','09.jpg','10.jpg','11.jpg','12.jpg','13_edited.jpg','14.jpg','15.jpg','16.jpg','17.jpg','18.jpg','19.jpg','20.jpg','21.jpg','22.jpg','23.jpg','24.jpg','25.jpg','26.jpg','27.jpg','28.jpg','29.jpg','30.jpg','31.jpg','32.jpg','33.jpg','34.jpg');
	++slideshowHomeImageID;
	var currentImgNr = (slideshowHomeImageID%imgArr.length);
	var imgName = imgArr[currentImgNr];
	var newImgUrl = "url(fileadmin/user_upload/images/slideshow/winter_2011/"+imgName+")";
	$('slideshow').style.backgroundImage = newImgUrl;
	new Effect.Opacity('ch_transition', {
		duration:1.5,
		from:1.0,
		to:0.0,
		afterFinish: function () {
			$('ch_transition').style.backgroundImage = newImgUrl;
			new Effect.Opacity('ch_transition', {	
				duration:0.5,
				from:0.0,
				to:1.0
			});
		}
	});
}

Event.observe(window, 'load', function() {
	
	if($('productslideshow') != null){

		//init slideshow
		switchProductImage();
		new PeriodicalExecuter(switchProductImage, 12);
	}

	if($('slideshow') != null){

		//init slideshow
		switchBackgroundImage();
		new PeriodicalExecuter(switchBackgroundImage, 4);
	}
});
