document.write('<style type="text/css">#pgTxt, #subTxt {opacity: 0; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0);} #defImg {position:absolute; width:640px; height:400px; top:0px; visibility:hidden}</style>');

var slideshowImages = new Array();
var morphCount="1";


ruleIndex=new Object();
function addCssRule(clsName,clsRule) {
    modCSS = document.styleSheets[0];
    ruleIndex[clsName]=modCSS.cssRules? modCSS.cssRules.length : modCSS.rules.length
    modCSS.addRule? modCSS.addRule(clsName,clsRule) : modCSS.insertRule(clsName+"{"+clsRule+"}", modCSS.cssRules.length);
}
function removeCssRule(clsName) {
    modCSS = document.styleSheets[0];
    ruleIndex[clsName] ? modCSS.deleteRule ? modCSS.deleteRule(ruleIndex[clsName]) : modCSS.removeRule(ruleIndex[clsName]) : "";
}


function zufall() {
	return Math.random()-Math.random()
}
// email decrypting
function UnCryptMailto(s, shift) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(shift));
	}
	return r;
}
function genAddr(s, shift)	{
//	location.href=UnCryptMailto(s, shift);
	document.write(UnCryptMailto(s, shift));
}
var fadeline=new Object();
function generateFadeOut(nbr) {
	for (i=0; i<=nbr; i++) {
		fadeline[i]=document.createElement("div");
		fadeline[i].className="fadeline2";
		fadeline[i].id="fadeline"+i;
		document.getElementById("bg").appendChild(fadeline[i]);
		fade = getSquareDelta(i, 0, 100, nbr);
		setOpacity((fade),"fadeline"+i);
	}
}

function setOpacity(opacity, theID) {
    var object = document.getElementById(theID).style;
    // Firefox Bugfix
    if (navigator.userAgent.indexOf("Firefox") != -1) {
        if (opacity == 100) { opacity = 99.9999; }
    }
    object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
    object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla
    opacity=0 ? object.display="none" : object.display="block";
}
function getSquareDelta(t, b, c, d)
{
    if ((t/=d/2) < 1) return c/2*t*t*t + b;
    return c/2*((t-=2)*t*t + 2) + b;
}
html=document.getElementsByTagName("html")[0];

function initPage() {
	initSlideshow();
	generateFadeOut(30);
}


var fadeTimer  = new Array();


var lastMorphObj;
var slideshowParent;
var defMorphSteps=40;
var initMorphSteps=40;
var morphStepDelta=20;
var morphInterval=5000;
var displayText = function(){};


initSlideshow = function() {
	slideshowParent=document.createElement("div");
	slideshowParent.id="gallCont";
	document.getElementById("rightcol").insertBefore(slideshowParent,document.getElementById("rightcol").firstChild);
	(slideshowImages.length==0 && document.getElementById("defImg")) ? slideshowImages.push(document.getElementById("defImg").src) : "";
	if (document.getElementById("pgTxt")) {
		displayText = function () {
			fadeElement("pgTxt", 0, 100, -100,initMorphSteps);
			fadeElement("subTxt", 0, 99, -99,initMorphSteps);
		}
	}
	slideshowImages.length>=1 ? execSlideshow() : displayText();
};
var afterMorph = function() {
		if (slideshowImages.length>1) {
			if (typeof(lastMorphObj)!='undefined') {
				slideshowParent.removeChild(lastMorphObj);
			}
			lastMorphObj=slideshowImg;
		}
	};

execSlideshow = function(morphNext) {
	var slideshowFinishText=document.getElementById("sFText");
	morphCount=morphCount+1;
	morphSteps=defMorphSteps;
	if (!morphNext) {
		morphSteps=initMorphSteps;
		morphNext=0;
		displayText();
	}
	if(morphNext==slideshowImages.length) {
		morphNext=0;
	}
	imgToLoad=slideshowImages[morphNext];
	slideshowImg = new Image();
	slideshowImg.id = 'slideshowImg'+morphCount;
	slideshowImg.style.display='none';
	slideshowParent.appendChild(slideshowImg);
	slideshowImg.onload=function(){
		if (morphNext==slideshowImages.length-1 && slideshowFinishText) {
			slideshowFinishText.style.display="none";
			slideshowFinishText.id="slideshowFinishText";
			fadeElement('slideshowFinishText', 0, 99, -99,morphSteps);
		}
		fadeElement('slideshowImg'+morphCount, 0, 99, -99,morphSteps, afterMorph);
		var setTimeout=window.setTimeout(function() {
			execSlideshow(morphNext+1)
		}, morphInterval);
		slideshowImg.onload=function(){};
	}
	slideshowImg.src = imgToLoad;
};


function fadeElement(theID, fadeCurrent, fadeStart, fadeChange,fadeSteps, execWhenDone) {
    // Test if we're done, or if we continue
    clearInterval(fadeTimer[theID]);
    if (fadeCurrent == (fadeSteps + 1)) {
        if (typeof(execWhenDone) == 'function') {
            execWhenDone();
        } else if (execWhenDone != '') {
            eval(execWhenDone);
        } else {
        	execWhenDone="";
        }
    } else {
        // Calculate this step's difference, and fade it!
        moveFade = getSquareDelta(fadeCurrent, fadeStart, fadeChange, fadeSteps);
        if (moveFade < 0) {
            setOpacity(moveFade, theID);
        } else {
            setOpacity(100 - (Math.abs(moveFade)), theID);
        }
        fadeCurrent++;
//        clearInterval(fadeTimer[theID]);
        fadeTimer[theID] = setInterval(function() {
        	fadeElement(theID,fadeCurrent,fadeStart,fadeChange,fadeSteps,execWhenDone);
        }, morphStepDelta);
    }
}


if (window.addEventListener){
	window.addEventListener("load", initPage, true);
} else if (window.attachEvent){
	var r = window.attachEvent("onload", initPage, true);
}
