//use browser sniffing to determine if IE or Opera (ugly, but required)
var isOpera, isIE = false;

if(typeof(window.opera) != 'undefined')
{
	// no alert, never : ) even for opera users
	//alert('isOpera');
	isOpera = true;
}

if(!isOpera && (navigator.userAgent.toLowerCase().search(/msie/) != -1))
{
	isIE = true;
}

var atsynonym  = '.23.';  // für das @
var dotsynonym = '!_&_!'; // für Punkt

function decodeString(myEncStr) {
	var tmp;
	tmp = myEncStr.replace( eval("/" + atsynonym + "/"), '@');
	tmp = tmp.replace( eval("/" + dotsynonym + "/g"), '.');
	return(tmp);
}

function openLink(myEncStr) {
  var decStr	= decodeString(myEncStr);
  location.href = "mailto:" + decStr;
}

function printLink(myEncStr) {
  var decStr = decodeString(myEncStr);
  document.write( decStr );
}

function showFBKlassik(){
	document.getElementById('showKlassik').style.display = 'block';
	document.getElementById('showMini').style.display = 'none';	
}

function showFBMini(){
	document.getElementById('showMini').style.display = 'block';
	document.getElementById('showKlassik').style.display = 'none';	
}

var automaticSwitch = null;

function startFading()
{
	automaticSwitch = window.setTimeout("fadeImages(4)",3000);
}

var currentPicID = 2;
var oldID = 1;
var currentCategory = 'Babygirl';
var counter = 0;

function fadeImages(speed)
{
	window.clearTimeout(automaticSwitch);

	if(counter+speed >100)
	{
		counter = 100;
	}
	else
	{
		counter = counter+speed;
	}
	//IE opacity
	if(isIE)
	{
		document.getElementById("beispiel"+currentCategory+currentPicID).style.filter = "Alpha(opacity="+counter+")";
		document.getElementById("beispiel"+currentCategory+oldID).style.filter = "Alpha(opacity="+(100 - counter)+")";
	}
	else
	{
	//FF opacity
		document.getElementById("beispiel"+currentCategory+currentPicID).style.opacity = (1/100 * counter);
		document.getElementById("beispiel"+currentCategory+oldID).style.opacity = (1/100 * (100 - counter));	
	}
	if(counter <100){ 
		window.setTimeout("fadeImages("+speed+")", 1);
	}else{
		counter=0; 
		document.getElementById("beispiel"+currentCategory+currentPicID).style.zIndex = 1;
		document.getElementById("beispiel"+currentCategory+oldID).style.zIndex = 0;
		
		if(currentPicID == 4)
		{
			currentPicID = 1
			oldID = 4;
		}
		else
		{
			oldID = currentPicID;
			currentPicID++;
		}
		startFading();
	}
}

function changeCategory(which)
{
	document.getElementById("beispiel"+currentCategory+currentPicID).style.opacity = 0;
	document.getElementById("beispiel"+currentCategory+oldID).style.opacity = 0;
	document.getElementById("beispiel"+currentCategory+currentPicID).style.zIndex = 0;
	document.getElementById("beispiel"+currentCategory+oldID).style.zIndex = 0;
	
	if(which == 'Babygirl')
	{
		currentCategory = which;
	}
	else if(which == 'Reise')
	{
		currentCategory = which;
	}
	else if(which == 'Hochzeit')
	{
		currentCategory = which;
	}
	
	currentPicID = 2;
	oldID = 1;
	counter = 0;
	document.getElementById("beispiel"+currentCategory+oldID).style.opacity = 1;
	document.getElementById("beispiel"+currentCategory+oldID).style.zIndex = 1;
	
	//startFading();
}