/*-------------------------------------------------------------------------
Elemente die ersetzt werden ausblenden um ein kurzes Aufflackern zu vermeiden
-------------------------------------------------------------------------*/
function hideElement(elementObj){
		elementObj.style.visibility = "hidden";
}
function showElement(elementObj){
		elementObj.style.visibility = "visible";
}
/*-------------------------------------------------------------------------
Wird ausgeführt, wenn die letzte Zeile HTML geladen ist
-------------------------------------------------------------------------*/
function HTMLloaded(){
	if(document.getElementsByTagName){
		//hideElement(document.getElementsByTagName('h1')[0]);
	}
	if(document.getElementById){
		correctCopyHeight();
		correctFooterPosition();
	}
}

window.onresize = HTMLloaded;

function correctFooterPosition(){	
	var agent = navigator.userAgent.toLowerCase();
	if(agent.indexOf('mac') != -1 && agent.indexOf('msie') != -1){
		var screenHeight = document.getElementsByTagName('body')[0].offsetHeight;
		document.getElementById('menuUnten').style.top = (screenHeight-50)+"px";
	}
}

function correctCopyHeight(){
	var marginTop = 215;
	var marginBottom = 56;
	var screenHeight = document.getElementsByTagName('body')[0].offsetHeight;
	if(window.innerHeight){
		screenHeight = window.innerHeight;
	}
	var newHeight = screenHeight-marginTop-marginBottom;
	document.getElementById('content').style.height = newHeight+"px";
}


/*-------------------------------------------------------------------------
Flashcheck
wird sofort ausgeführt
Setzt Variable showFlash true wenn Flash Version 6 vorhanden
-------------------------------------------------------------------------*/
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if (plugin){
	plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 6;
}else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)){
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
	document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
	document.write('<\/SCRIPT\> \n');
}
if (plugin){
	showFlash = true;
}else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
	showFlash = false;
}

/*-------------------------------------------------------------------------
wird im onLoad des Body ausgeführt und startet Funktionen
-------------------------------------------------------------------------*/
function doOnload(){
	if(document.getElementById){
		initWMRollover();
		newsTicker = new listNewsTickerClass('ticker','newsTicker',3000,true);
		var tmpH1 = document.getElementsByTagName('h1')[0];
		if(tmpH1){
			showElement(tmpH1);
		}
		if(window.location.search == "?debug"){
			var head = document.getElementById("headline");
			if(head){
				head.style.top = "51px";
				head.style.left = "242px";
			}
			header = new replaceContentClass('header','', 'h1','/pics/tmp.gif','503','55');	
		}else{
			if(showFlash){
				header = new replaceContentClass('header','', 'h1','/flash/head1.swf','398','20');
			}else{
				header = new replaceContentClass('header','', 'h1','/pics/head_lust_auf_laster.gif','192','20');		
			}			
		}
	}
	if(window.pageOnload){
		pageOnload();
	}
}
/*-------------------------------------------------------------------------
replaceContentClass 0.1
Aufruf (z.B. im onLoad des Bodys):
header = new replaceContentClass('header','headline', '','/flash/head1.swf','398','20');
header = new replaceContentClass('header','headline', '','/pics/head_lust_auf_laster.gif','192','20');		

-------------------------------------------------------------------------*/
replaceContentClass = function(objName,containerID,containerTAG,fullPathToReplaceFile,width,height){
	if(document.getElementById && document.getElementsByTagName){
		//if(document.innerHTML){
			this.objName = objName;
			this.containerID = containerID;
			this.containerTAG = containerTAG;
			this.fullPathToReplaceFile = fullPathToReplaceFile;	
			this.width = width;
			this.height = height;
			if(this.containerTAG != ''){
				this.useContainerTAG = true;
				this.containerObj = document.getElementsByTagName(this.containerTAG)[0];
			}
			if(this.containerID != ''){
				this.useContainerID = true;
				this.containerObj = document.getElementById(this.containerID);
			}
			if(!this.useContainerID && !this.useContainerTAG){
				alert('geben Sie entweder containerID ODER containerTAG an! Einer der Beiden Parameter MUSS angegeben werden!');
				return;
			}		
			if(this.useContainerID && this.useContainerTAG){
				alert('Diese Version unterstützt nur entweder containerID ODER containerTAG! Löschen Sie einen der beiden Parameter!');
				return;
			}
			if(this.containerObj){
				this.recognizeFiletypeToReplace();		
			}
		//}
	}
}
replaceContentClass.prototype.recognizeFiletypeToReplace = function(){
	this.filetypeToReplace = this.fullPathToReplaceFile.substr(this.fullPathToReplaceFile.length-3,3);
	switch(this.filetypeToReplace){
		case "swf":
			this.replaceContentWithFlash();
			break;
		case "gif":
			this.replaceContentWithImage();
			break;
		case "jpeg":
			this.replaceContentWithImage();
			break;
		case "jpg":
			this.replaceContentWithImage();
			break;
		default:
			alert("Filetype: "+this.filetypeToReplace+" not recognized!");
			break;
	}
}
replaceContentClass.prototype.replaceContentWithFlash = function(){
	this.newContent = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+this.width+'" height="'+this.height+'">';
	this.newContent += '	<param name="movie" value="'+this.fullPathToReplaceFile+'" />';
	this.newContent += '	<param name="quality" value="high" />';
	this.newContent += '	<param name="FlashVars" value="txt='+this.containerObj.innerHTML+'" />';
	this.newContent += '	<embed src="'+this.fullPathToReplaceFile+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+this.width+'" height="'+this.height+'" FlashVars="txt='+this.containerObj.innerHTML+'"></embed>';
	this.newContent += '</object>';
	this.containerObj.innerHTML = this.newContent;
}
replaceContentClass.prototype.replaceContentWithImage = function(){
	this.newContent = '<img src="'+this.fullPathToReplaceFile+'" width="'+this.width+'" height="'+this.height+'" alt="'+this.containerObj.innerHTML+'" />';
	this.containerObj.innerHTML = this.newContent;
}


/*-------------------------------------------------------------------------
listNewsTickerClass 1.1
12.02.04 Dirk Ginader für Bartenbach & Co. Werbeagentur GmbH & Co. KG
31.03.04 Bugfix (frage nach explitizem Filter vor anwendung
Aufruf (z.B. im onLoad des Bodys):
meinTicker = new listNewsTickerClass('nameDesDivs','meinTicker',3000,true);
-------------------------------------------------------------------------*/
listNewsTickerClass = function(tickerDivID,objName,interval,pauseOnOver){
	if(document.getElementById){
		this.tickerDivID = document.getElementById(tickerDivID);
		this.objName = objName;
		this.interval = interval;
		this.tickerItems = this.tickerDivID.getElementsByTagName("li");
		this.allowTick = true;
		this.tickCount=0;
		this.hideAllItems();
		if(pauseOnOver){
			this.attachPauseOnOver();
		}
		this.tick();
	}
}
listNewsTickerClass.prototype.attachPauseOnOver = function(){
	this.tickerDivID.obj = this;
	this.tickerDivID.onmouseover=function() {
		this.obj.MouseOver();
    }
	this.tickerDivID.onmouseout=function() {
		this.obj.MouseOut();        
	}
}
listNewsTickerClass.prototype.MouseOver = function(){
	this.allowTick = false;
}
listNewsTickerClass.prototype.MouseOut = function(){
	this.allowTick = true;
}
listNewsTickerClass.prototype.tick = function(){
		this.showTransitions = false;
		if(this.allowTick){
			if(document.all){				
				if(this.tickerDivID.filters){
					if(this.tickerDivID.filters.revealTrans){
						if(!navigator.userAgent.toLowerCase().indexOf('msie 5.0') != -1){
							this.tickerDivID.filters.revealTrans.Apply();
							this.showTransitions = true;
						}
					}
				
				}
			}
			this.showOnlyItem(this.tickCount);
			if(document.all && this.showTransitions){
				if(this.tickerDivID.filters && this.tickerDivID.filters.revealTrans){
					this.tickerDivID.filters.revealTrans.Play();
				}
			}
			this.tickCount++;
			if(this.tickCount>=this.tickerItems.length){
				this.tickCount=0;
			}
		}
		window.setTimeout(""+this.objName+".tick()",this.interval);
}
listNewsTickerClass.prototype.showOnlyItem = function(tickerItem){
	this.hideAllItems();
	this.showItem(this.tickerItems[tickerItem]);
}
listNewsTickerClass.prototype.showItem = function(tickerItem){
	tickerItem.style.display = "list-item";
}
listNewsTickerClass.prototype.hideItem = function(tickerItem){
	tickerItem.style.display = "none";
}
listNewsTickerClass.prototype.hideAllItems = function(){
	for(var i=0;i<this.tickerItems.length;i++){
		this.hideItem(this.tickerItems[i]);
	}
}
// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
picSwapClass = function(objName,containerID,swapPx,swapFrames){
	if(document.getElementById){
		this.objName = objName;
		this.containerID = containerID;
		this.swapPx = swapPx;
		this.swapFrames = swapFrames;
		this.containerObj = document.getElementById(this.containerID);
		this.activeMenuID = null;
		this.showTransitions = false;
		if(this.containerObj){
			if(document.all){
				if(this.containerObj.filters){
					if(this.containerObj.filters.revealTrans){
						if(!navigator.userAgent.toLowerCase().indexOf('msie 5.0') != -1){
							this.showTransitions = true;
						}
					}			
				}
			}
		}
	}
}
picSwapClass.prototype.mouseOver = function(me){
	if(this.mouseOutTimeout){
		window.clearTimeout(this.mouseOutTimeout);
	}
	if(this.containerObj){
		var tmpActiveMenu = me.id.substr(me.id.length-1,1)*1;
		var tmpSwap = (this.swapFrames-tmpActiveMenu) * this.swapPx;
		var tmpSwap = (tmpActiveMenu-1) * this.swapPx;
		if(this.showTransitions){
			this.containerObj.filters.revealTrans.Apply();
		}
		this.containerObj.style.backgroundPosition = "-"+tmpSwap+"px 0px";
		if(this.showTransitions){
			this.containerObj.filters.revealTrans.Play();
		}
	}
	return true;
}

picSwapClass.prototype.mouseOut = function(me){
	this.mouseOutTimeout = window.setTimeout(this.objName+".doMouseOut()",100);
}
picSwapClass.prototype.doMouseOut = function(){
	this.mouseOutTimeout = false;
	if(this.containerObj){
		if(this.activeMenu){
			this.mouseOver(this.activeMenu);
		}else{
			if(this.showTransitions){
				this.containerObj.filters.revealTrans.Apply();
			}
			this.containerObj.style.backgroundPosition ="0px 0px";
			if(this.showTransitions){
				this.containerObj.filters.revealTrans.Play();
			}
		}
	}
	return true;
}
// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
initWMRollover = function(){
	WMRollover = new picSwapClass("WMRollover","images",251,4);
}
