//<![CDATA[
// ============================================================================
// Copyright 2011 by venussystems
// www.venussystems.de
// René Venus
// 05.04.2011
// ============================================================================
window.onDomReady = initReady;
function initReady(fn) {
	if(document.addEventListener) {
		document.addEventListener("DOMContentLoaded", fn, false);
	} else {
		document.onreadystatechange = function(){readyState(fn)}
	}
}
function readyState(func) {
	if(document.readyState == "interactive" || document.readyState == "complete") {
		func();
	}
}
window.onDomReady(onReady);
function onReady() {
	if(document.getElementById('Ticker')) TickerStart();
	vfStart();
}
// =============================================================================

function vfStart() {
	// All blur
	vsLinks = document.getElementsByTagName('a');
	for(i = 0; i < vsLinks.length; i++){
		vsLinks[i].onfocus = vfLinkBlur;
	}
}
function vfLinkBlur(evt) {
	this.blur();
}


function FullSize(Picture, PicHeight, PicWidth, ObjId) {
	var ScrollPosY = getScrollPosition();
	var PicHgW = PicWidth + 8;
	var PicHgH = PicHeight + 38;
	var ImgMarginX	= parseInt(-PicHgW / 2);
	var ImgMarginY	= parseInt(-PicHgH / 2);
	var ShMarginX	= parseInt(-PicHgW / 2 + 10);
	var ShMarginY	= parseInt(-PicHgH / 2 + 10);
	SetOpacity('SCRD', 0);
	SetOpacity('IMGhg', 0);
	SetOpacity('IMGShadow', 0);
	document.getElementById('SCRD').style.top		=  ScrollPosY + 'px';
	document.getElementById('SCRD').style.height	=  getScreenHeight() + 'px';
	document.getElementById('SCRD').style.display	= 'block';
	document.getElementById('IMGhg').style.display	= 'block';
	document.getElementById('IMGhg').style.width	= PicHgW + 'px';
	document.getElementById('IMGhg').style.height	= PicHgH + 'px';
	document.getElementById('IMGhg').style.margin	= ImgMarginY + 'px 0 0 ' +  ImgMarginX + 'px';
	document.getElementById('IMGShadow').style.display	= 'block';
	document.getElementById('IMGShadow').style.width	= PicHgW + 'px';
	document.getElementById('IMGShadow').style.height	= PicHgH + 'px';
	document.getElementById('IMGShadow').style.margin 	= ShMarginY + 'px 0 0 ' +  ShMarginX + 'px';
	document.getElementById('SCRIMG').src = Picture;
	document.getElementById('ImgText').innerHTML = ucfirst(document.getElementById(ObjId).alt);
	FadeInPic(0, 0);
}

function FadeInPic(BlendCountIMG, BlendCountIMGHG) {
	BlendCountIMG += 10;
	BlendCountIMGHG += 3;
	if(BlendCountIMG < 110) {
		SetOpacity('IMGhg', BlendCountIMG);
		SetOpacity('IMGShadow', BlendCountIMGHG);
		SetOpacity('SCRD', BlendCountIMGHG);
		var Blend = window.setTimeout("FadeInPic(" + BlendCountIMG +", " + BlendCountIMGHG + ")", 20)
	}
}
function PictureOff() {
	BlendAct = 2;
	FadeOutPic(100, 30);
}
function FadeOutPic(BlendCountIMG, BlendCountIMGHG) {
	BlendCountIMG -= 10;
	BlendCountIMGHG -= 3;
	if(BlendCountIMG > 1) {
		SetOpacity('IMGhg', BlendCountIMG);
		SetOpacity('IMGShadow', BlendCountIMGHG);
		SetOpacity('SCRD', BlendCountIMGHG);
		var Blend = window.setTimeout("FadeOutPic(" + BlendCountIMG +", " + BlendCountIMGHG + ")", 20)
	} else {
		document.getElementById("SCRD").style.display = "none";
		document.getElementById("IMGShadow").style.display = "none";
		document.getElementById("IMGhg").style.display = "none";
		document.getElementById("SCRIMG").src = "vsImages/vsBlank.gif";
	}
}


function ucfirst(str) {
    var firstLetter = str.substr(0, 1); 
    return firstLetter.toUpperCase() + str.substr(1); 
} 
// Transparenz ================================================================
function SetOpacity(Obj, Opacity) {
	var Objekt = document.getElementById(Obj);
	Opacity = (Opacity == 100)?99.999:Opacity;
	if(document.all) {
		Objekt.style.filter = "alpha(opacity:" + Opacity + ")";
	} else {
		Objekt.style.KHTMLOpacity = Opacity / 100;
		Objekt.style.MozOpacity = Opacity / 100;
		Objekt.style.Opacity = Opacity / 100;
	}
}
// Bildschirmhöhe und Breite --------------------------------------------------
function getScreenHeight() {
	var ScreenH = 0;
	if (self.innerHeight) {
		ScreenH = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		ScreenH = document.documentElement.clientHeight;
	} else if (document.body) {
		ScreenH = document.body.clientHeight;
	}
	return ScreenH;
}
function getScreenWidth() {
	var ScreenW = 0;
	if (self.innerWidth) {
		ScreenW = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		ScreenW = document.documentElement.clientWidth;
	} else if (document.body) {
		ScreenW = document.body.clientWidth;
	}
	return ScreenW;
}
// Bildschirmposition ScrollTop -----------------------------------------------
function getScrollPosition() {
	var ScrollPosY = 0;
	if (typeof window.pageYOffset != 'undefined') {
		ScrollPosY = window.pageYOffset;
	} else if (typeof document.compatMode != 'undefined' &&
		document.compatMode != 'BackCompat') {
		ScrollPosY = document.documentElement.scrollTop;
	} else if (typeof document.body != 'undefined') {
		ScrollPosY = document.body.scrollTop;
	}
	return ScrollPosY;
}
// Absolute Position eines Elements -------------------------------------------
function getAbsoluteX(Obj) {
	var Element = document.getElementById(Obj);
	var x = 0;
	if (Element && typeof Element.offsetParent != "undefined") {
		while (Element && typeof Element.offsetLeft == "number") {
			x += Element.offsetLeft;
			Element = Element.offsetParent;
		}
	}
	return x;
}
function getAbsoluteY(Obj){
	var Element = document.getElementById(Obj);
	var y = 0;
	if (Element && typeof Element.offsetParent != "undefined") {
		while (Element && typeof Element.offsetTop == "number") {
			y += Element.offsetTop;
			Element = Element.offsetParent;
		}
	}
	return y;
}
// ============================================================================

var TWidth	= new Array(3);
var TLeft	= new Array(3);
var TObj	= new Array(3);
var TLast;

function TickerStart() {	
	var startpos = 0;
	for(i = 0; i < 3; i++) {
		var x = 'T' + parseInt(i  + 1);
		TObj[i] = document.getElementById(x);
		TWidth[i] = TObj[i].offsetWidth;
		TLeft[i] = startpos;
		startpos += TWidth[i];
	}
	TickerScroll();
}
 
function TickerScroll() {
	var p = 0;
	for(i = 0; i < 3; i++) {
		TLeft[i] -= 1;
		if(p < TLeft[i]) {
			p = TLeft[i];
			TLast = i;
		}
	}
	for(i = 0; i < 3; i++) {
		if(TLeft[i] < -Math.abs(TWidth[i])) {
			TLeft[i] = TLeft[TLast] + TWidth[TLast];
		}
		TObj[i].style.left = TLeft[i] + 'px';
	}
	window.setTimeout("TickerScroll()", 35)
}
//]]>
