// V�LKwerbung JavaScript Document

//function open window not used jet
function openNewWindow(URLtoOpen, windowName, windowFeatures)
{ newWindow=window.open (URLtoOpen, windowName, windowFeatures);}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}



var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		munich_o = newImage("../bilder/scrollDn-o.gif");
		nav1_o = newImage("../bilder/scrollUp.gif");
		menu1_o = newImage("../bilder/ulSquare.gif");
		
		preloadFlag = true;
	}
}


function expandCollapse() {
	for (var i=0; i<expandCollapse.arguments.length; i++) {
		var element = document.getElementById(expandCollapse.arguments[i]);
		element.style.display = (element.style.display == "none") ? "block" : "none";
	}
}

// Change display from 4 menu over  page
function display (obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.display = "block";
    }
}

function gone (obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.display = "none";
    }
}

function active (obj0, obj1, obj2) {
	var a = new Array("submenu1", "submenu2", "submenu3", "submenu4");
	for (i=0;i<a.length;i++) {
	var n = a[i];
	//alert("n= vor if "+ n);
	if (!document.getElementById(n)) {
		i++;
		n = a[i];
		//alert("i= "+ i);
		//alert("n= in if "+ n);
		}
	//alert("n= nach if "+ n);
	document.getElementById(n).style.display = "none";
	}
	//alert("reached display obj arguments.length=" + arguments.length);
	//alert("obj1 now " + obj1);
	//alert("obj[j] i now" + obj[j]);
		for (j=0;j<arguments.length;j++) {
		var theObj = arguments[j];
		//alert(" theObj is " + theObj) ;
		theObj = getObject(arguments[j]);
		
    	if (theObj) {
			//alert("make obj[j] visible " + obj[j]) ;
       	 	theObj.display = "block";
		}
    }
}



function over (arg)
{
	document.getElementById(arg).style.visibility = "visible";
	document.getElementById("contact").style.visibility = "hidden";
}

function out ()
{
	document.getElementById("contactOver").style.visibility = "hidden";
	document.getElementById("contact").style.visibility = "visible";
	document.square0.style.display = "inline";	
	document.square00.style.display = "none";
	document.square1.style.display = "inline";	
	document.square11.style.display = "none";
	document.square2.style.display = "inline";	
	document.square22.style.display = "none";
	document.square3.style.display = "inline";	
	document.square33.style.display = "none";
	document.square4.style.display = "inline";	
	document.square44.style.display = "none";
	document.getElementById("mainSub0").style.display = "none";
	document.getElementById("mainSub1").style.display = "none";
	document.getElementById("mainSub2").style.display = "none";
	document.getElementById("mainSub3").style.display = "none";
	document.getElementById("mainSub4").style.display = "none";
	document.getElementById("viewOver").style.display = "block";
	document.getElementById("overallview").style.display = "none";
}

// Change display from 2 mainSubs in ausSagen (text.html)
function display1b ()
{
	document.getElementById("mainSub1").style.display = "block";
	document.getElementById("mainSub2").style.display = "none";
	document.getElementById("mainSub3").style.display = "none";
}

function display2b ()
{
	document.getElementById("mainSub1").style.display = "none";
	document.getElementById("mainSub2").style.display = "block";
	document.getElementById("mainSub3").style.display = "none";
}

function display3b ()
{
	document.getElementById("mainSub1").style.display = "none";
	document.getElementById("mainSub2").style.display = "none";
	document.getElementById("mainSub3").style.display = "block";

}

// for flickerfree dropdown, since IE can only :hover on an <a> element; other elements not!
// So for IE we have to use onmouseover/onmouseout events
// start IE check with <body onLoad="init('droplist')">
// if there are more 'droplists', name them differently, else it won't work for those!

var g_bH = false;

  function init(p_strId) {
    g_bH = false;
    var l_E = document.getElementById(p_strId);
    if(l_E && document.defaultView) {
if(document.defaultView.getComputedStyle(l_E, 'hover')) {
  g_bH = true;
}
    }
    l_E = null;
  }

  
  //	Browsercheck (needed)
	function lib_bwcheck() {
		this.ver=navigator.appVersion;
		this.agent=navigator.userAgent;
		this.dom=document.getElementById?1:0;
		this.opera5=this.agent.indexOf("Opera 5")>-1;
		this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
		this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
		this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
		this.ie=this.ie4||this.ie5||this.ie6;
		this.mac=this.agent.indexOf("Mac")>-1;
		this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
		this.ns4=(document.layers && !this.dom)?1:0;
		this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
		return this;
	}
	
//	replace image
	var bw = new lib_bwcheck();
	
	function set_image(name, url) {
		var img = document.images[name];
		if(img){
		  img.src = url;
		}
	}
	


/* ***********************************************************
Example 4-3 (DHTMLAPI.js)
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 1-56592-494-0
http://www.oreilly.com
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************ */
// DHTMLapi.js custom API for cross-platform
// object positioning by Danny Goodman (http://www.dannyg.com).
// Release 2.0. Supports NN4, IE, and W3C DOMs.
// safari fix by Barbara Voelk 10/05 
// Global variables
var isCSS, isW3C, isIE4, isNN4, isNN6, isIE6CSS, isSafari, isFireFox;
// Initialize upon load to let all browsers establish content objects
function getNNVersionNumber () {
	if (navigator.appName == "Netscape") {
		var appVer = parseFloat(navigator.appVersion);
		if (appVer < 5) {
			return appVer;
		} else {
			if (typeof navigator.vendorSub != "undefinex") {
				return parseFloat(navigator.vendorSub);
			}
		}
	}
	return 0;
}

function initLibrary() {
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
		isNN6 = getNNVersionNumber() >= 6;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
		isSafari = (navigator.userAgent.indexOf("Safari") != -1);
		isFireFox = (navigator.userAgent.indexOf("Firefox") != -1);
    }
}

	
// Set event handler to initialize API
window.onload = initLibrary;

// Seek nested NN4 layer from string name
function seekLayer(doc, name) {
    var theObj;
    for (var i = 0; i < doc.layers.length; i++) {
        if (doc.layers[i].name == name) {
            theObj = doc.layers[i];
            break;
        }
        // dive into nested layers if necessary
        if (doc.layers[i].document.layers.length > 0) {
            theObj = seekLayer(document.layers[i].document, name);
        }
    }
    return theObj;
}

// Convert object name string or object reference
// into a valid element object reference
function getRawObject(obj) {
    var theObj;
    if (typeof obj == "string") {
        if (isW3C) {
            theObj = document.getElementById(obj);
        } else if (isIE4) {
            theObj = document.all(obj);
        } else if (isNN4) {
            theObj = seekLayer(document, obj);
        }
    } else {
        // pass through object reference
        theObj = obj;
    }
    return theObj;
}

// Convert object name string or object reference
// into a valid style (or NN4 layer) reference
function getObject(obj) {
    var theObj = getRawObject(obj);
    if (theObj && isCSS) {
        theObj = theObj.style;
    }
    return theObj;
}

// Position an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = x + units;
            theObj.top = y + units;
        } else if (isNN4) {
            theObj.moveTo(x,y)
        }
    }
}

// Move an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = getObjectLeft(obj) + deltaX + units;
            theObj.top = getObjectTop(obj) + deltaY + units;
        } else if (isNN4) {
            theObj.moveBy(deltaX, deltaY);
        }
    }
}

// Set the z-order of an object
function setZIndex(obj, zOrder) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.zIndex = zOrder;
    }
}

// Set the background color of an object
function setBGColor(obj, color) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isNN4) {
            theObj.bgColor = color;
        } else if (isCSS) {
            theObj.backgroundColor = color;
        }
    }
}

// Set the visibility of an object to visible
function show(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "visible";
    }
}

// Set the visibility of an object to hidden
function hide(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "hidden";
    }
}

// Retrieve the x coordinate of a positionable object
function getObjectLeft(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.left;
    } else if (elem.style) {
        result = elem.style.left;
    } else if (isNN4) {
        result = elem.left;
    }
    return parseInt(result);
}

// Retrieve the y coordinate of a positionable object
function getObjectTop(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("top");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.top;
    } else if (elem.style) {
        result = elem.style.top;
    } else if (isNN4) {
        result = elem.top;
    }
    return parseInt(result);
}

// Retrieve the rendered width of an element
function getObjectWidth(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetWidth) {
        result = elem.offsetWidth;
    } else if (elem.clip && elem.clip.width) {
        result = elem.clip.width;
    } else if (elem.style && elem.style.pixelWidth) {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}

// Retrieve the rendered height of an element
function getObjectHeight(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetHeight) {
        result = elem.offsetHeight;
    } else if (elem.clip && elem.clip.height) {
        result = elem.clip.height;
    } else if (elem.style && elem.style.pixelHeight) {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}

// Return the available content width space in browser window
function getInsideWindowWidth() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6CSS) {
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;
}

// Return the available content height space in browser window
function getInsideWindowHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
}

// start script for scroll buttons
var scrollEngaged = false;
var scrollInterval;
var scrollBars = new Array();

function getElementStyle(elemID, IEStyleAttr, CSSStyleAttr) {
    var elem = document.getElementById(elemID);
    if (elem.currentStyle) {
        return elem.currentStyle[IEStyleAttr];
    } else if (window.getComputedStyle) {
        var compStyle = window.getComputedStyle(elem, "");
        return compStyle.getPropertyValue(CSSStyleAttr);
    }
    return "";
}

function scrollBar(ownerID, ownerContentID, upID, dnID) {
    this.ownerID = ownerID;
    this.ownerContentID = ownerContentID;
    this.index = scrollBars.length;
	//alert("scrollBars.length is" + scrollBars.length);
    this.upButton = document.getElementById(upID);
    this.dnButton = document.getElementById(dnID);
    this.upButton.index = this.index;
    this.dnButton.index = this.index;
    this.ownerHeight = parseInt(getElementStyle(this.ownerID, "height", "height"));
	//alert("this.ownerHeight" + this.ownerHeight);
    this.contentElem = document.getElementById(ownerContentID);
    this.contentFontSize = parseInt(getElementStyle(this.ownerContentID, 
        "fontSize", "font-size"));
    this.contentScrollHeight = (this.contentElem.scrollHeight) ? 
        this.contentElem.scrollHeight : this.contentElem.offsetHeight;
    this.initScroll = initScroll;
}


function initScroll() {
    this.upButton.onmousedown = handleScrollClick;
    this.upButton.onmouseup = handleScrollStop;
    this.upButton.oncontextmenu = blockEvent;

    this.dnButton.onmousedown = handleScrollClick;
    this.dnButton.onmouseup = handleScrollStop;
    this.dnButton.oncontextmenu = blockEvent;
    
    var isIEMac = (navigator.appName.indexOf("Explorer") != -1 && navigator.userAgent.indexOf("Mac") != -1);
    if (!isIEMac) {
        document.getElementById("innerWrapper0").style.overflow = "hidden";
        //alert("is not isIEMac");
    }
}

function handleScrollStop() {
    scrollEngaged = false;
}

function blockEvent(evt) {
    evt = (evt) ? evt : event;
    evt.cancelBubble = true;
    return false;
}

function handleScrollClick(evt) {
    var fontSize;
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var index = target.index;
    fontSize = scrollBars[index].contentFontSize;
    fontSize = (target.className == "lineup") ? fontSize : -fontSize;
    scrollEngaged = true;
    scrollBy(index, parseInt(fontSize));
    scrollInterval = setInterval("scrollBy(" + index + ", " + parseInt(fontSize) + ")", 30);
    evt.cancelBubble = true;
    return false;
}

function scrollBy(index, px) {
    var scroller = scrollBars[index];
    var elem = document.getElementById(scroller.ownerContentID);
    var top = parseInt(elem.style.top);
    var scrollHeight = parseInt(scroller.contentScrollHeight);
    var height = scroller.ownerHeight;

    if (scrollEngaged && top + px >= -scrollHeight + height && top + px <= 0) {
        shiftBy(elem, 0, px);
    } else {
    	//alert("called function scrollBy, else loop clearInterval");
        clearInterval(scrollInterval);
    }
}


function initScroller() {
    scrollBars[0] = new scrollBar("outerWrapper0", "innerWrapper0", "lineup0", 
        "linedown0");
    scrollBars[0].initScroll();
}