function addToShoppingCartPopup(nummer)
{
	width=300;
	height=100;	
	var popup =window.open('index.php?nummer='+nummer+'&cmd=addToShoppingCartPopup.php', 'addToShoppingCartPopup', 'width='+width+',height='+height+',status=no,scrollbars=no,resizable=yes');
	popup.focus();
}

function openGalleryPopup(galleryName)
{
	width=screen.availWidth;
	height=screen.availHeight;
	
	var popup=window.open('/~galerien/?galleryName='+galleryName, 'popup', 'width='+width+',height='+height+',status=no,scrollbars=yes,resizable=yes,left=0,top=0');
	popup.focus();
}

function openImagePopup(img)
{
	width=632;
	height=421;
		
	var popup=window.open('index.php?cmd=imgPopup.php&img='+img, 'popup', 'width='+width+',height='+height+',status=no,scrollbars=no,resizable=no,top=0');
	popup.focus();
}


// Fade-Funktionen

var fadePicBuffer=new Image();
var currentFadePic=1;

function switchFadePic(direction)
{	
	currentFadePic=currentFadePic+direction;
	if(currentFadePic==0) currentFadePic=fadePicArray.length-1;
	if(currentFadePic>fadePicArray.length-1) currentFadePic=1;

	fadePicBuffer.src=fadePicArray[currentFadePic];

	fadePicBuffer.onload=function()
	{
		document.getElementById("fadePicContainer").style.backgroundImage="url("+fadePicBuffer.src+")"; 
		fadeOut("fadePic", 1);
	}
}

// Parameter festlegen
var fadeInTimer=new Array();
var fadeOutTimer=new Array();
var opacitiyProgress=new Array();
var opacitiyAvailable=true;
var opacity=0;
var opacityFull=1;
var fadeEnd=0;
var opacityZero=0;
var fadeInStep=0.05;
var fadeOutStep=0.05;
var stepTime=20;


function fadeIn(id, opacity)
{
	if(!opacitiyAvailable) return;
	
	clearTimeout(fadeOutTimer[id]);
	
	opacity=opacity+fadeInStep;
	opacitiyProgress[id]=opacity;
	
	setOpacitiy(id, opacity);
	
	if(opacity+fadeInStep<opacityFull) fadeInTimer[id]=setTimeout("fadeIn('"+id+"', "+opacitiyProgress[id]+")", stepTime);
	else 
	{
		setOpacitiy(id, opacityFull);
		opacitiyProgress[id]=opacityFull;

		fadePicBuffer.src=document.getElementById('fadePic').src;
	}
}

function fadeOut(id, opacity)
{	
	if(!opacitiyAvailable) return;
	
	clearTimeout(fadeInTimer[id]);
	
	opacity=opacity-fadeOutStep;
	opacitiyProgress[id]=opacity;
	
	setOpacitiy(id, opacity);
	
	if(opacity-fadeOutStep>fadeEnd) fadeOutTimer[id]=setTimeout("fadeOut('"+id+"', "+opacitiyProgress[id]+")", stepTime);
	else
	{
		setOpacitiy(id, fadeEnd);
		opacitiyProgress[id]=fadeEnd;

		document.getElementById('fadePic').src=fadePicBuffer.src;
	}
}

function getFadeOpacity(id)
{	
	if(!opacitiyAvailable) return;

	// überprüfen ob Tranparenz unterstützt wird
	if(document.getElementById(id).style.filter=="undefined" && document.getElementById(id).style.opacity=="undefined")
	{
		opacitiyAvailable=false;
		return;
	}
	else
	{		
		if(opacitiyProgress[id]) return opacitiyProgress[id];
		else return 0;
	}	
}

function setOpacitiy(id, opacity)
{
	if(document.all) document.getElementById(id).style.filter="Alpha(opacity="+opacity*100+")";
	else document.getElementById(id).style.opacity=opacity;
}