// Opera & NS4 resize-Topnavigation Fix START
var ResizeTimer;
var origW=window.innerWidth;
var origH=window.innerHeight;
// Opera / NS4.x resize-Topnavigaton Fix Check 
function checkResize() {
	clearTimeout( ResizeTimer );
	if ( !OP && !NS ) return true;
	if ( OP && !(window.innerWidth==origW && window.innerHeight==origH)) location.reload();
	else if ( NS && !(window.outerWidth==origW && window.outerHeight==origH)) location.reload();
	ResizeTimer = window.setTimeout("checkResize()", 500);
	return true;
}
// Opera & NS4 (on Mac) resize-Topnavigation Fix END	

function preLoad (imgfile) {
	Cache = new Image();
	eval ("Cache.src = \"" + sUriPrefix + imgfile+"\"");																		 
}
			
// hides corrupted HTML-Page when using Netscape-Resize-Patch
function grayOutPageOnNetscapeReload(){ 
	var grayOutAllLayer = new Layer(innerWidth);
	with(grayOutAllLayer){
		left = 0;
		top = 0;
		clip.height = innerHeight;
		clip.width = innerWidth;
		bgColor = "#CCE6FF";
		zIndex = 1000;
		document.open();
		document.write("Reloading, please wait...");
		document.close();
		visibility = "show";
	}
}

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0, IE4 = 0, MAC = 0, NT4=0, IE6 = 0, WIN = 0;
var sUriPrefix;
function DHTML_init() {
	if (window.opera) OP = 1;
	if(document.getElementById) {
		DHTML = 1;
		DOM = 1;
	}
	if(document.all && !OP) {
		DHTML = 1;
		MS = 1;
	}
	if(document.layers && !OP) {
		DHTML = 1;
		NS = 1;
	}
	if (MS && !DOM) IE4 = 1;
	// check for Mac.
	if (navigator.userAgent.toLowerCase().indexOf("mac")>-1) MAC = 1;
	// has to be extended so msie7+ are recognized too!
	if (navigator.userAgent.toLowerCase().indexOf("msie 6")>-1) IE6 = 1;
	if (navigator.userAgent.toLowerCase().indexOf("windows nt;")>-1) NT4 = 1;
	if (navigator.userAgent.toLowerCase().indexOf("windows")>-1) WIN = 1;
}

function swapImage(imgName, imgSource, layerId){//Bildwechsel
    var imageObject;
		if (NS) {
			if (layerId)
        imageObject = getImageObjectForNS4( imgName, getLayerById(layerId).document );
			else 
				imageObject = getImageObjectForNS4( imgName );
      imageObject.src = imgSource;
		} else if (document.images[imgName]) { 
			document.images[imgName].src = imgSource;
		} else if (DOM){
			document.getElementById(imgName).src = imgSource;
		}
	return true;
}

function getImageObjectForNS4(id, d){
	if (!NS) return null;
	var searchResult = null;
	if (!d) d = document;
	if (d.images[''+id+'']) searchResult = d.images[''+id+''];
	for (var i=0; !searchResult && i < d.layers.length; i++){			 
		searchResult = getImageObjectForNS4( id, d.layers[i].document );
	}
	return searchResult;
}

// initialise the window status bar and bugfix scrollbar for MAC+IE
function initPage(windowStatus){
	if ( OP || NS ){	// Opera / NS4 Resize Patch
		clearTimeout( ResizeTimer );
		if (NS){
			origW=window.outerWidth;
			origH=window.outerHeight;
		}
		ResizeTimer = window.setTimeout("checkResize()",500);
	}
	if (MAC && MS) { window.resizeBy(0,1); window.resizeBy(0,-1); } // garanties the scrollbar on mac+IE
	
	window.status = windowStatus;
	window.defaultStatus = windowStatus;
	
	// remove the rectangle around links for IE+Win
	if (MS&&WIN) { document.onmousedown = ExplorerFix; };
	
	return true;
}

// remove the rectangle around links for IE+Win only onClick-event, TAB function remains
function ExplorerFix() {
	for (a in document.links) document.links[a].onfocus = document.links[a].blur; 
	}

// service function to get Layer-object in NS4 no matter how much surrounding layers
function getLayerObjectForNS4(id, d){
	if (!NS) return null;
	var searchResult = null;
	if (!d) d = document;
	if (d.layers[''+id+'']) searchResult = d.layers[''+id+''];
	for (var i=0; !searchResult && i < d.layers.length; i++){			 
		searchResult = getLayerObjectForNS4( id, d.layers[i].document );
	}
	return searchResult;
}
// almost like the getElem-function of DHTML.js, but can only get layer-objects
// and has advanced capabilities for NS4 using getLayerObjectForNS4()
function getLayerById(id, d){
	if (id == '' && !id ) return null;
	var layerObject = null;
	if (NS) layerObject = getLayerObjectForNS4( id, d );
	else if (MS) layerObject = document.all[''+id+''];
	else if (DOM) layerObject = document.getElementById(id);	
	return layerObject;
}
// START: eMBLayer - Object
function eMBLayer ( id ){
	// data member
	this.object = getLayerById( id ); // can be used if direct access on the layer-object is required
	this.id = id; // the id of the layer as a string
	
	// member functions 
	this.isObject = isObject; // returns true if layer was found, else false, object.isObject()
	this.getParentLayer = getParentLayer; // returns the parent layer as an eMBLayer object, object.getParentLayer()
	this.convertLayerToEmbLayer = convertLayerToEmbLayer; /* converts an usual layer object to an eMBLayer object, 
																													 targetEmbLayerObject.convertLayerToEmbLayer( sourceLayerObject )*/
	 
	this.getId = getId; // writes the id of the calling object into the "id"-property
	this.show = show; // object.show()
	this.hide = hide; // object.hide()
	
	this.setBgColor = setBgColor; // sets the background color of the caling eMBLayer, object.setBgColor("#ffffff")
	
	this.setX = setX; // set x Position of the layer, object.setX( int-Value )
	this.setY = setY; // set y Position of the layer, object.setY( int-Value )
	
	this.getX = getX; // retrieves x Position of the layer, relative to parent element, object.getX()
	this.getY = getY; // retrieves y Position of the layer, relative to parent element, object.getY()
	this.getAbsoluteY = getAbsoluteY; // retrieves y Position of the layer, relative to browser window, object.setAbsoluteX()
	
	this.getWidth = getWidth; // retrieves the width of the layer, object.getWidth()
	this.getHeight = getHeight; // retrieves the height of the layer, object.getHeight()
	
	this.setSize = setSize; // sets the size for the layer, object.setSize( int-Value width, int-Value height )
}
// member functions implementations, do NOT use as standalone function!
// if needed, can be used as follows: 
// (new eMBLayer(IdOfTheLayerYouWantToUseTheFunctionWith)).theFunctionYouWantToUse();
function convertLayerToEmbLayer( layerObject ){
	this.object = layerObject;
	this.id = this.getId();
	return this;
}

function isObject(){
	return ( (this.object==null)?false:true );
}
// returns the parent-eMBLayer of the layer with the given id as an object
function getParentLayer( ){
	if (!this.isObject()) return null;
	var parentLayerObject = null;
	if (NS) parentLayerObject = new eMBLayer( this.object.parentLayer.name );
	else if (MS){
		var parentObject = this.object.parentElement;
		while (parentObject && parentObject.parentElement && parentObject.tagName.toLowerCase() != "div")
			parentObject = parentObject.parentElement;
		if (parentObject && parentObject.tagName.toLowerCase() != "div") parentObject = null;
	} else if (DOM){
		var parentObject = this.object.parentNode ;
		while (parentObject && parentObject.parentNode && !((parentObject.nodeType==1 || OP) && parentObject.tagName.toLowerCase()=="div") )
			parentObject = parentObject.parentNode ;
		if ( !( parentObject && (parentObject.nodeType==1 || OP) && parentObject.tagName.toLowerCase()=="div") ) parentObject = null;
	}
	return (new eMBLayer(null)).convertLayerToEmbLayer( parentObject );
}
function getId(){
	if ( !this.isObject() ) return null;
	if (MS || DOM) return this.object.id;
	else if (NS) return this.object.name;
}
function show(){
	if ( !this.isObject() ) return true;
	if (NS) this.object.visibility = "show";
	else if (MS || DOM) this.object.style.visibility = "visible";
}
function hide(){
	if ( !this.isObject() ) return true;
	if (NS) this.object.visibility = "hide";
	else if (MS || DOM) this.object.style.visibility = "hidden";
}
function setBgColor( newColor ){
	if ( !this.isObject() ) return true;
	if (NS) this.object.bgColor = newColor;
	else this.object.style.backgroundColor = newColor;
}
function setX( newXPosition ){
	if ( !this.isObject() ) return true;
	if (NS) this.object.left = newXPosition;
	else if (MS || DOM) this.object.style.left=newXPosition+"px";
}
function setY( newYPosition ){
	if ( !this.isObject() ) return true;
	if (NS) this.object.top = newYPosition;
	else if (MS || DOM) this.object.style.top = newYPosition+"px";
}
function getX(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (MS || DOM) w = this.object.offsetLeft;
	else if (NS) w = this.object.left;
	return w;
}
function getY(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (MS || DOM) w = this.object.offsetTop;
	else if (NS) w = this.object.top;
	return w;
}
function getAbsoluteY(){
	var absTop = 0;
	if ( !this.isObject() ) return -1;
	var layerObject = this;
	if (NS) return this.object.pageY;
	while( layerObject.isObject() ){
		absTop = absTop + layerObject.getY();
		layerObject = layerObject.getParentLayer();
	}
	return absTop;
}
function getWidth(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (DOM && !OP) this.object.style.width = "auto"; // needed but can reset a layers size in strict HTML4.01
	if (IE4 || OP) w = this.object.style.pixelWidth;
	else if (MS || (DOM && !OP)) w = this.object.offsetWidth; // IE5+ & NS6
	else if (NS) w = this.object.clip.width;
	return w;
}
function getHeight(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (DOM && !OP) this.object.style.height = "auto";
	if (MS || (DOM && !OP)) w = this.object.offsetHeight;
	else if (NS) w = this.object.clip.height;
	else if (OP) w = this.object.style.pixelHeight;
	return w;
}
// setting width and height for layers
// used on initalization and when positioning highlight layers
// on Mozilla 0.9x+ don't use getWidth or getHeight (on the same layer) after this function, this
// would shrink layer size to its contents size
function setSize( newWidth, newHeight ){
	if ( !this.isObject() ) return true;
	if (!NS){
		with (this.object.style) {
			if (MS || OP){
				pixelWidth = newWidth;
				pixelHeight = newHeight;
			}	else if (DOM && !OP){		
				width = newWidth+"px";
				height = newHeight+"px";
			}
		}
	} else if (NS){
		this.object.resizeTo(newWidth, newHeight);
		with(this.object.clip){
			top = 0;
			left = 0;
			width = newWidth;
			height = newHeight;
		}
	}
}
// END: eMBLayer - Object
/*
function openChild(source, name, attributes){
	if(!NS)
		var infoWin = window.open(source, name, attributes);
	else if(NS)
		if(window
}*/
var popUps = new Array();
function openChild(source, name, attributes) {
	if (!popUps[name] || popUps[name].closed==true) {
		window.open(source,name,attributes);
	} else {
		popUps[name].close();
		popUps[name] = window.open(source,name,attributes);
	}
}
function writetolayer(lay,txt) {
			if(MAC && MS) document.all[lay].innerHTML = '';
			if (MS || OP) document.all[lay].innerHTML = txt;
			if (NS) {
				document[lay].document.write(txt);
				document[lay].document.close();
			}
			if (DOM && !MS) {
				over = document.getElementById([lay]);
				range = document.createRange();
				range.setStartBefore(over);
				domfrag = range.createContextualFragment(txt);
				while (over.hasChildNodes()) over.removeChild(over.lastChild);
				over.appendChild(domfrag);
			}
		}

DHTML_init(); // this library is automaticly initialized during loading	