function priceToPercent(id, price, price_norm)
{
	var price_value = price.replace(",", ".");
	if (price_norm > 0)
		document.getElementById("product_"+id+"_percent").value = 100 - Math.ceil(price_value / price_norm * 100);
}

function percentToPrice(id, percent, price_norm)
{
	if (price_norm > 0)
		document.getElementById("product_"+id+"_price").value = Math.round(price_norm * (100 - percent)) / 100;
}

function deleteProduct(my_id)
{
	if (!confirm("Möchten Sie das Produkt wirklich aus dem Warenkorb entfernen?")) return; 
	document.location.href = "?remove_from_cart="+my_id;
}

function showDiv(show, class_name)
{
	var my_objects = document.getElementsByClassName(class_name);
	for (i = 0; i < my_objects.length; i++)
		my_objects[i].style.display = "none";

	document.getElementById(class_name+"_"+show).style.display = "block";
}

function showDiv2(show, id_name)
{
	if (show == true)
		document.getElementById(id_name).style.display = "none";
	else
		document.getElementById(id_name).style.display = "block";
}

var slideshowImages = new Array();
var slideDuration = 8000;
var slideEffectDuration = 1.5;

function nextSlideshow(images, index)
{			
	var transition = Effect.Transitions.linear;

	var switchImage = function() {
		$("slideImage").src = images[index]["path"];
	};

	var switchText = function() {
		$("slideText").innerHTML = images[index]["text"];	
	}

	var setTimeoutCall = function() {	
		window.setTimeout(function () { nextSlideshow(images, index+1); }, slideDuration);
	};

	if (!index) { // initialize on first call
		index = 0;
		switchImage();
		switchText();
		setTimeoutCall();
		$("slideWelcomeBg").setOpacity(0.7);
		return;
	} else if(index >= images.length)
		index = 0;	

	$("slideBuffer").style.backgroundImage = "url(" + $("slideImage").src + ")";

	new Effect.Opacity('slideImage', {
		transition: transition,
		from: 1.0,
		to: 0,
		duration: slideEffectDuration,
		afterFinish: function() {
			switchImage();

			window.setTimeout(function () { switchText(); }, (slideEffectDuration * 1000) / 2);

			new Effect.Opacity('slideImage', {
				transition: Effect.Transitions.linear,
				from: 0,
				to: 1.0,
				duration: slideEffectDuration,
				afterFinish: setTimeoutCall
			});

		}
	});	
}
	
window.IEPNGFix = {};
IEPNGFix.blankImg = '/_templates/images/blank.gif';