﻿//  Version 1.3
//  2006/10/09

resetModulNaviTimer = 5000;
hideCo2LayerTimer = 5000;

var i, e;
var browserAtributeLength, browserId, platform;
var imgCountTotal, lowImageSrc, highImageSrc, currentImg, currentState, currentAct, currentPerm, checkLoad;
var slideAmount;
var divNum, documentLeftScroll, documentTopScroll, mouseX, mouseY, loopDragging;
var speedHorizontal, speedVertical, currentBack, goup, godown, speed, currentObjNo;
var setDivPosition, setBackPosition, currentObjId, currentSpeed, currenDirection, currentDelay;
var diffWidth, diffHeight, lastWidth, lastHeight, currentDiv;
var popup_window, winUrl;
var ua = navigator.userAgent.toLowerCase();
var an = navigator.appName.toLowerCase();
var framesetPage = "index_narrowband.html";
var framesetPageHighend = "index_highend.html";
var currentStep = 0;
var windowWidth = 0;
var windowHeight = 0;
var browserVersion = 0;
var loaded = 0;
var divLeft = 0;
var divTop = 0;
var looping = -1;
var slideCount = -1;
var writeBrowser = "";
var tempAct = "";
var slideNumber = "";
var slideDescription = "";
var preLoadArray = new Array();
var preLoadCounter = new Array();
var highImages = new Array();
var lowImages = new Array();
var slideText = new Array();
var permanentActive = new Array();
var slideImages = new Array();
var allowedDomain = new Array();
allowedDomain[0] = "://www.bmw.";
allowedDomain[1] = "://bmw.";
allowedDomain[2] = "://origin.bmw.";
allowedDomain[3] = "://secure.bmw.";
allowedDomain[4] = "://wcms10.bmwgroup.com";
allowedDomain[5] = "://liintra.muc";
allowedDomain[6] = "://ltintra.muc";
allowedDomain[7] = "://www-at.bmw";
allowedDomain[8] = "://www-nl.bmw";
allowedDomain[9] = "://www-be.bmw";
allowedDomain[10] = "://www-lu.bmw";
allowedDomain[11] = "://www-pt.bmw";
allowedDomain[12] = "://www-ie.bmw";
allowedDomain[13] = "://www-jp.bmw";
allowedDomain[14] = "://www-fr.bmw";
allowedDomain[15] = "://www-cz.bmw";
allowedDomain[16] = "://www-sk.bmw";
allowedDomain[17] = "://www-se.bmw";
allowedDomain[18] = "://www-it.bmw";
var supportedOS = false;
var supportedVersion = false;
var currentLoop = false;
var dragAllowed = false;
var divIsMoving = false;
var flashversion = false;
var topFrame = null;
var contentFrame = null;
var bottomFrame = null;
var historyFrame = null;
var hiddenFrame = null;
var allowClose = true;
var modulNaviOverImage = true;
var idmodulsSpecial = "";
var minFlashVersion = 7;
var isMainnavigation = false;
var indexParameters = "";

var query = new Object();
var parameterArray = new Array();

var scrollerDefaultSize = 978;
var scrollerCheckElements = new Array();
var scrollerSize = scrollerDefaultSize;

var scrollerBgImage;
var scrollerSliderImage;
var scrollerImageUp;
var scrollerImageDown;

if (typeof browser != 'object') {
    browser = new Array();
    browser[0] = new Array('Opera', 'opera ', '6.5', '', '', '');
    browser[1] = new Array('Safari', 'safari/', '125', '', 'mac os x', '');
    browser[2] = new Array('Netscape', 'netscape/', '7.1', 'windows', 'mac os x', 'other');
    browser[3] = new Array('Firefox', 'firefox/', '1.0', 'windows', 'mac os x', 'other');
    browser[4] = new Array('Mozilla', 'rv:', '1.7', 'windows', 'mac os x', 'other');
    browser[5] = new Array('MSIE', 'msie ', '5.5', 'windows', '', '');
    browser[6] = new Array('Netscape4', 'mozilla/', '4.0', '', '', '');
}

function openQuestionnaire() {
    //Leere Funktion für eine spezielle bmw.at-Anpassung
    //Bitte nicht entfernen, da diese generell von dem Frameset innerhalb index_highend bei onunload aufgerufen wird!
    //Wird wieder entfernt
    //R. Aust, 28.11.05
}

function ssoCloseDialog() {
}

function checkClient() {
    var browserLength = browser.length;
    for (i = 0; i < browserLength; i++) {
        browserAtributeLength = browser[i].length;
        if (ua.indexOf(browser[i][1]) != -1) {
            browserId = browser[i][0];
            for (e = 3; e < browserAtributeLength; e++) {
                if (browser[i][e] != '' && (ua.indexOf(browser[i][e]) != -1 || browser[i][e] == 'other')) {
                    supportedOS = true;
                    platform = browser[i][e];
                    break;
                } else {
                    supportedOS = false;
                }
            }
            browserVersion = ua.split(browser[i][1]);
            browserVersion = parseFloat(browserVersion[1].slice(0, 3));
            if (browserVersion >= browser[i][2]) {
                supportedVersion = true;
            } else {
                supportedVersion = false;
            }
            break;
        } else {
            browserId = 'unknown';
        }
    }
    browserId = ((browserId == "MSIE") ? (((/\s+msie\s+7\.\d+/).test(navigator.appVersion.toLowerCase())) ? ("MSIE7") : (browserId)) : (browserId));
}

function checkBrowser(incompatibleBrowserUrl) {
    if (document.cookie && document.cookie.indexOf('bmwDisableBrowserCheck=true') != -1) {
        return true;
    }
    checkClient();
    if (supportedVersion == false || supportedOS == false) {
        parent.location.href = buildValidServerRelativeUrl(incompatibleBrowserUrl) + "?" + self.location.href.replace("?", "&");
        return false;
    } else {
        return true;
    }
}

function checkFrameset() {
    if (self.name != "frameContent") {
        if (typeof confCountryTopic != 'undefined' && confCountryTopic != null && typeof confLanguageTopic != 'undefined' && confLanguageTopic != null) {
            var basePath = self.location.href.substring(0, self.location.href.indexOf("/" + confCountryTopic + "/" + confLanguageTopic + "/"));
            var countryLanguagePath = basePath + "/" + confCountryTopic + "/" + confLanguageTopic + "/";
            self.location.href = countryLanguagePath + framesetPage + "?content=" + self.location.href.replace("?", "&");
        }
    }
}

function pageHandler() {
    splitSearchString();
    if (query.content) {
        if (query.content.indexOf("://") != -1) {
            var domainIsAllowed = false;
            for (i = 0; i < allowedDomain.length; i++) {
                if (query.content.indexOf(allowedDomain[i]) != -1) {
                    domainIsAllowed = true;
                    break;
                }
            }
            if (domainIsAllowed) {
                initContentURL = query.content;
                indexParameters = "";
                for (x in query) {
                    if (x == "content") continue;
                    if (indexParameters == "") {
                        indexParameters += "?";
                    } else {
                        indexParameters += "&";
                    }
                    indexParameters += x + "=" + query[x];
                }
            }
        }
        else {
            initContentURL = query.content;
            indexParameters = "";
            for (x in query) {
                if (x == "content") continue;
                if (indexParameters == "") {
                    indexParameters += "?";
                } else {
                    indexParameters += "&";
                }
                indexParameters += x + "=" + query[x];
            }
        }
    }
}

function setFrameVariables() {
    contentFrame = frames[0];
    bottomFrame = frames[1];
    historyFrame = frames[2];
    hiddenFrame = frames[3];
}

function getFrameset(version) {
    var frameSetSource = "";
    pageHandler();
    if (version == "flash" || version == "html") {
        if (version == "html") {
            initHistoryURL = initHiddenURL;
        }
        frameSetSource += '<frameset rows="*,29" frameborder="no" border="0" onload="setFrameVariables()" onunload="openQuestionnaire()">';
        frameSetSource += '<frame src="' + initContentURL + '" name="frameContent" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />';
        frameSetSource += '<frameset cols="*,1,1" frameborder="no" border="0">';
        frameSetSource += '  <frame src="' + initBottomURL + '" name="frameBottom"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
        frameSetSource += '  <frame src="' + initHistoryURL + '" name="frameHistory" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
        frameSetSource += '  <frame src="' + initHiddenURL + '" name="hiddenFrame"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
        frameSetSource += '</frameset>';
    } else if (version == "shortcut") {
        frameSetSource += '<frameset rows="99%,1%" frameborder="no" border="0">';
        frameSetSource += ' <frame src="' + initContentURL + '" name="frameContent" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />';
        frameSetSource += ' <frame src="' + initHiddenURL + '" name="hiddenFrame"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
    } else if (version == "popup") {
        frameSetSource += '<frameset rows="96,*" frameborder="no" border="0">';
        frameSetSource += ' <frame src="' + initTopURL + '" name="frameTop"  frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />';
        frameSetSource += ' <frame src="' + initContentURL + '" name="frameContent" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />';
    } else {
        frameSetSource = "Error: Function getFrameset called with illegal parameter (" + version + ")";
    }
    frameSetSource += '</frameset>';
    return frameSetSource;
}

function preload() {
    if (typeof slideImagesCollection != 'undefined') {
        slideAmount = slideImagesCollection.length;
    }
    for (i = 0; i < slideAmount; i++) {
        slideImages[i] = new Image();
        slideImages[i].src = slideImagesCollection[i];
    }
    loaded = 2;
    imgCountTotal = document.images.length;
    for (i = 0; i < imgCountTotal; i++) {
        if (typeof document.getElementsByTagName('img')[i].getAttribute('preload') == 'string') {
            lowImageSrc = document.getElementsByTagName('img')[i].src;
            if (document.getElementsByTagName('img')[i].getAttribute('preload').indexOf('/') != -1) {
                highImageSrc = document.getElementsByTagName('img')[i].getAttribute('preload');
            } else {
                var highImageUrl = lowImageSrc.split('/');
                var fileLevel = highImageUrl.length;
                var highImagePath = '';
                for (e = 0; e < fileLevel - 1; e++) {
                    highImagePath += highImageUrl[e] + '/';
                }
                highImageSrc = highImagePath + document.getElementsByTagName('img')[i].getAttribute('preload');
            }
            highImages[document.images[i].id] = new Image();
            highImages[document.images[i].id].src = highImageSrc;
            lowImages[document.images[i].id] = new Image();
            lowImages[document.images[i].id].src = lowImageSrc;
        }
        if (i < imgCountTotal - 1) {
            loaded = 3;
        }
        if (i == imgCountTotal - 1) {
            loaded = 1;
        }
    }
}

function switchImage(imgId, state, act, permanent, dropPerm) {
    currentImg = imgId;
    currentState = state;
    currentAct = act;
    currentPerm = permanent;
    if (typeof dropPerm == 'string' && dropPerm != 'all') {
        document.getElementsByTagName('img')[dropPerm].src = lowImages[dropPerm].src;
        delete permanentActive[dropPerm];
        if (dropPerm == tempAct) {
            tempAct = '';
        }
    } else if (dropPerm == 'all') {
        dropPermanentAll();
    }
    if (loaded == 1) {
        clearTimeout(checkLoad);
        if (tempAct != '' && imgId != tempAct && act == 1 && !permanentActive[tempAct]) {
            document.getElementsByTagName('img')[tempAct].src = lowImages[tempAct].src;
        }
        if ((tempAct == '' || imgId != tempAct) && !permanentActive[imgId]) {
            if (state == 1) {
                document.getElementsByTagName('img')[imgId].src = highImages[imgId].src;
            } else {
                document.getElementsByTagName('img')[imgId].src = lowImages[imgId].src;
            }
        }
        if (act == 1) {
            tempAct = imgId;
        }
        if (permanent == 1) {
            permanentActive[imgId] = imgId;
        }
    } else if (loaded == 2) {
        checkLoad = setTimeout('switchImage(currentImg,currentState,currentAct,currentPerm)', 50);
    } else if (loaded == 3) {
        preload();
        checkLoad = setTimeout('switchImage(currentImg,currentState,currentAct,currentPerm)', 50);
    }
}

function dropPermanentAll() {
    for (var dropImg in permanentActive) {
        document.getElementsByTagName('img')[dropImg].src = lowImages[dropImg].src;
        delete permanentActive[dropImg];
    }
    if (tempAct != '') {
        document.getElementsByTagName('img')[tempAct].src = lowImages[tempAct].src;
        tempAct = '';
    }
}

function setSlideshow(direction, delay) {
    currenDirection = direction;
    currentDelay = delay;
    if (direction == "forward") {
        slideCount++;
        if (slideCount > slideAmount - 1) {
            slideCount = 0;
        }
    } else if (direction == "backward") {
        slideCount--;
        if (slideCount < 0) {
            slideCount = slideAmount - 1;
        }
    } else {
        slideCount = 0;
    }
    if (delay) {
        looping = setTimeout("setSlideshow(currenDirection,currentDelay)", currentDelay);
    } else {
        clearTimeout(looping);
        looping = -1;
    }
    document.getElementById('slideshow').src = slideImages[slideCount].src;
}

function toggleSlideshow(direction, delay) {
    if (!direction) {
        direction = currenDirection;
    }
    if (!delay) {
        delay = currentDelay;
    }
    if (looping > -1) {
        clearTimeout(looping);
        looping = -1;
    } else {
        setSlideshow(direction, delay);
    }
}

function setClassName(tagId, nameOfClass) {
    if (typeof tagId != 'object') {
        tagId = document.getElementById(tagId);
    }
    if (tagId) {
        tagId.className = nameOfClass;
    }
}

function setColor(objId, color) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        objId.style.color = color;
    }
}

function addClassName(tagType, tagIndex, additionalClassName) {
    var oldClassName = (document.getElementsByTagName(tagType)[tagIndex].className) ? document.getElementsByTagName(tagType)[tagIndex].className : '';
    document.getElementsByTagName(tagType)[tagIndex].className = oldClassName + ' ' + additionalClassName;
}

function getAbsoluteLeft(obj) {
    if (typeof obj != 'object') {
        obj = document.getElementById(obj);
    }
    var x = 0;
    if (obj) {
        while (obj.offsetParent !== null) {
            x += obj.offsetLeft;
            obj = obj.offsetParent;
        }
        x += obj.offsetLeft;
    }
    return x;
}

function getAbsoluteTop(obj) {
    if (typeof obj != 'object') {
        obj = document.getElementById(obj);
    }
    var y = 0;
    if (obj) {
        while (obj.offsetParent !== null) {
            y += obj.offsetTop;
            obj = obj.offsetParent;
        }
        y += obj.offsetTop;
    }
    return y;
}

function getDivInformation(objId, attribute) {
    divInformation = new Array();
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        divInformation['offsetLeft'] = objId.offsetLeft;
        divInformation['offsetTop'] = objId.offsetTop;
        divInformation['styleLeft'] = parseInt(objId.style.left);
        divInformation['styleTop'] = parseInt(objId.style.top);
        divInformation['width'] = objId.offsetWidth;
        divInformation['height'] = objId.offsetHeight;
        divInformation['visibility'] = objId.style.visibility;
        divInformation['display'] = objId.style.display;
        divInformation['zIndex'] = objId.style.zIndex;
        return divInformation[attribute];
    }
}

function writeIntoLayer(objId, content) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        objId.innerHTML = content;
    }
}

lastPositions = new Array();
currentPositions = new Array();
currentPositions['navigation'] = [, ];

function moveObject(objId, left, top, speed, backLink) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        if (left) {
            divLeft = left;
        } else if ((typeof left == 'undefined' || typeof left == 'string') && (typeof backLink == 'undefined' || backLink == 0)) {
            divLeft = getDivInformation(objId, 'offsetLeft');
        }
        if (top) {
            divTop = top;
        } else if ((typeof top == 'undefined' || typeof top == 'string') && (typeof backLink == 'undefined' || backLink == 0)) {
            divTop = getDivInformation(objId, 'offsetTop');
        }
        if (!lastPositions[objId.id]) {
            lastPositions[objId.id] = [, ];
        }
        if (typeof backLink != 'undefined' && backLink == 1 && left == lastPositions[objId.id][0] && top == lastPositions[objId.id][1]) {
            currentBack = backLink;
            divLeft = currentPositions[objId.id][0];
            divTop = currentPositions[objId.id][1];
        }
        if (!divIsMoving) {
            currentPositions[objId.id] = [getDivInformation(objId, 'offsetLeft'), getDivInformation(objId, 'offsetTop')];
        }
        if (speed) {
            var horizontalRange = currentPositions[objId.id][0] - divLeft;
            var verticalRange = currentPositions[objId.id][1] - divTop;
            currentObjId = objId;
            currentSpeed = speed;
            currentStep++;
            if (left != '' || left == 0) {
                if (horizontalRange > 0) {
                    objId.style.left = (currentPositions[objId.id][0] - Math.round(currentStep * speed)) + 'px';
                    if (divLeft - getDivInformation(objId, 'offsetLeft') > 5) {
                        objId.style.left = divLeft + 'px';
                    }
                } else if (horizontalRange < 0) {
                    objId.style.left = (currentPositions[objId.id][0] + Math.round(currentStep * speed)) + 'px';
                    if (divLeft - getDivInformation(objId, 'offsetLeft') < 5) {
                        objId.style.left = divLeft + 'px';
                    }
                }
            }
            if (top != '' || top == 0) {
                if (verticalRange > 0) {
                    objId.style.top = (currentPositions[objId.id][1] - Math.round(currentStep * speed)) + 'px';
                    if (divTop - getDivInformation(objId, 'offsetTop') > 5) {
                        objId.style.top = divTop + 'px';
                    }
                } else if (verticalRange < 0) {
                    objId.style.top = (currentPositions[objId.id][1] + Math.round(currentStep * speed)) + 'px';
                    if (divTop - getDivInformation(objId, 'offsetTop') < 5) {
                        objId.style.top = divTop + 'px';
                    }
                }
            }
            if (getDivInformation(objId, 'offsetLeft') == left && getDivInformation(objId, 'offsetTop') == top) {
                divIsMoving = false;
                currentStep = 0;
                currentBack = 0;
                divLeft = 0;
                divTop = 0;
                lastPositions[objId.id] = [left, top];
                clearTimeout(setDivPosition);
            } else {
                divIsMoving = true;
                setDivPosition = setTimeout('moveObject(currentObjId,divLeft,divTop,currentSpeed)', 10);
            }
        } else {
            if (divLeft != '' || divLeft == 0) {
                objId.style.left = divLeft + 'px';
            }
            if (divTop != '' || divTop == 0) {
                objId.style.top = divTop + 'px';
            }
            currentBack = 0;
            divLeft = 0;
            divTop = 0;
            lastPositions[objId.id] = [left, top];
        }
    }
}

function mousePosition(currentevent) {
    if (window.event) {
        currentevent = window.event;
    }
    mouseX = currentevent.clientX;
    mouseY = currentevent.clientY;
}

function getWindowInformation(value) {
    windowInformation = new Array();
    windowInformation['winWidth'] = document.body.clientWidth;
    if (document.body.clientHeight == 0) {
        windowInformation['winHeight'] = window.innerHeight;
    } else {
        windowInformation['winHeight'] = document.body.clientHeight;
    }
    windowInformation['docWidth'] = document.body.scrollWidth;
    windowInformation['docHeight'] = document.body.scrollHeight;
    windowInformation['scrollLeft'] = document.body.scrollLeft;
    windowInformation['scrollTop'] = document.body.scrollTop;
    return windowInformation[value];
}

function getCurrentStyle(nodeObject, propertyName) {
    var propertyValue;
    if (document.documentElement && document.defaultView) {
        propertyValue = document.defaultView.getComputedStyle(nodeObject, "").getPropertyValue(propertyName);
    }
    else if (document.documentElement && document.documentElement.currentStyle) {
        var regX = /([a-z]*)\-([a-z])([a-z]*)/;
        while (regX.test(propertyName)) {
            regX.exec(propertyName);
            propertyName = RegExp.$1 + RegExp.$2.toUpperCase() + RegExp.$3;
        }
        propertyValue = nodeObject.currentStyle[propertyName];
    }
    return propertyValue;
}

var currentState, currentDisplayState;

function setVisibility(objId, visibility, display, initialSet) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        if (typeof visibility == 'undefined' && typeof display == 'undefined') {
            currentState = getDivInformation(objId, 'visibility');
            currentDisplayState = getDivInformation(objId, 'display');
            if (currentState == '') {
                if (initialSet) {
                    currentState = 'visible';
                } else {
                    currentState = 'hidden';
                }
            }
            if (currentDisplayState == '') {
                if (initialSet) {
                    currentDisplayState = initialSet;
                } else {
                    currentDisplayState = 'none';
                }
            }
            if (currentState == 'hidden') {
                objId.style.visibility = 'visible';
            } else if (currentState == 'visible') {
                objId.style.visibility = 'hidden';
            }
            if (currentDisplayState == 'none') {
                objId.style.display = 'block';
                objId.style.visibility = 'visible';
            } else if (currentDisplayState == 'block' || currentDisplayState == 'inline') {
                objId.style.display = 'none';
            }
        } else if (visibility == 1) {
            objId.style.visibility = 'visible';
        } else if (visibility == 0) {
            objId.style.visibility = 'hidden';
        }
        if (display) {
            objId.style.display = display;
        }
    }
}

function setZIndex(obj, n) {
    if (typeof obj != 'object') {
        obj = document.getElementById(obj);
    }
    if (obj) {
        obj.style.zIndex = n;
    }
}

function resizeLayer(objId, newWidth, newHeight) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        currentDiv = objId;
        lastWidth = getDivInformation(objId, 'width');
        lastHeight = getDivInformation(objId, 'height');
        if (newWidth) {
            if (typeof newWidth == 'string') {
                objId.style.width = newWidth;
            } else {
                objId.style.width = newWidth + 'px';
            }
        }
        if (newHeight) {
            if (typeof newHeight == 'string') {
                objId.style.height = newHeight;
            } else {
                objId.style.height = newHeight + 'px';
            }
        }
    }
}

function clipLayer(objId, top, right, bottom, left) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        currentDiv = objId;
        lastWidth = getDivInformation(objId, 'width');
        lastHeight = getDivInformation(objId, 'height');
        objId.style.clip = "rect(" + top + "px " + right + "px " + bottom + "px " + left + "px)";
    }
}

function getClipping(objId) {
    if (typeof objId != 'object') {
        objId = document.getElementById(objId);
    }
    if (objId) {
        return objId.style.clip;
    }
}

function restoreLayer() {
    if (typeof currentDiv == 'object') {
        if (typeof currentDiv.style.width != 'undefined') {
            currentDiv.style.width = lastWidth + 'px';
        }
        if (typeof currentDiv.style.height != 'undefined') {
            currentDiv.style.height = lastHeight + 'px';
        }
        if (typeof currentDiv.style.clip != 'undefined') {
            currentDiv.style.clip = "rect(" + 0 + "px " + lastWidth + "px " + lastHeight + "px " + 0 + "px)";
        }
    }
}

function centerPopup(popup_url, popup_name, popup_with, popup_height, reopen, myScrollbar, myLeftPos, myTopPos) {
    if (!myLeftPos) { myLeftPos = 5; }
    if (!myTopPos) { myTopPos = 15; }
    if (!myScrollbar) { myScrollbar = 0; }
    var popup_left = (window.screen.width / 2) - (popup_with / 2 + myLeftPos);
    var popup_top = (window.screen.height / 2) - (popup_height / 2 + myTopPos);
    if ((typeof popup_window != 'object') || (typeof popup_window == 'object' && popup_window.closed)) {
        if (document.all) {
            var xyPos = 'left=' + popup_left + ',top=' + popup_top;
        } else {
            var xyPos = 'screenX=' + popup_left + ',screenY=' + popup_top;
        }
        popup_window = window.open(popup_url, popup_name, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popup_with + ",height=" + popup_height + ",copyhistory=no," + xyPos + "");
        popup_window.opener = self;
        popup_window.focus();
        winUrl = popup_url;
        windowWidth = popup_with;
        windowHeight = popup_height;
    } else {
        if ((winUrl != popup_url) || reopen) {
            popup_window.location.href = popup_url;
        }
        if ((windowWidth + windowHeight > 0) && (popup_with != windowWidth || popup_height != windowHeight || myLeftPos != diffWidth || myTopPos != diffHeight)) {
            var newWidth = popup_with - windowWidth;
            var newHeight = popup_height - windowHeight;
            popup_window.resizeBy(newWidth, newHeight);
            popup_window.moveTo(popup_left, popup_top);
        }
        popup_window.focus();
        winUrl = popup_url;
        windowWidth = popup_with;
        windowHeight = popup_height;
    }
    diffWidth = myLeftPos;
    diffHeight = myTopPos;
}

function openPopupLink(url, popupString) {
    var params = popupString.split(",");
    if (params.length == 3) {
        centerPopup(url, params[0], params[1], params[2], false, false);
    } else {
        centerPopup(url, "searchwin", 800, 600, false, false);
    }
}

function openPopupParams(popup_url, popup_name, popup_params) {
    if ((typeof popup_window != 'object') || (typeof popup_window == 'object' && popup_window.closed)) {
        if (popup_params) {
            popup_window = window.open(popup_url, popup_name, popup_params);
        } else {
            popup_window = window.open(popup_url, popup_name);
        }
        popup_window.opener = self;
        popup_window.focus();
        winUrl = popup_url;
    } else {
        if (winUrl != popup_url) {
            popup_window.location.href = popup_url;
        }
        popup_window.focus();
        winUrl = popup_url;
    }
}

function splitSearchString() {
    if (self.location.search.indexOf("=") == -1) return;
    parameterArray = self.location.search.substring(1).split("&");
    for (i = 0; i < parameterArray.length; i++) {
        pair = parameterArray[i].split("=");
        query[unescape(pair[0])] = (pair[1] ? unescape(pair[1]) : "");
    }
}

function getCookieValue(name) {
    var arg = name + "=";
    var alen = arg.length;
    var i = 0;
    while (i < document.cookie.length) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            var endstr = document.cookie.indexOf(";", j);
            if (endstr == -1) {
                endstr = document.cookie.length;
            }
            return unescape(document.cookie.substring(j, endstr));
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) {
            break;
        }
    }
    return false;
}

function isCookiesEnabled() {
    document.cookie = "bmwCookieEnabled=true";
    if (document.cookie.indexOf("bmwCookieEnabled=true") != -1) {
        var expire = new Date();
        document.cookie = "bmwCookieEnabled=;expires=" + expire.toGMTString();
        return true;
    } else {
        return false;
    }
}

function onLoadFunctions() {
}
function onUnloadFunctions() {
}


function checkWindowSize() {
    if (getWindowInformation('winWidth') < scrollerSize) {
        if (document.getElementById('mainNavi')) {
            resizeLayer('mainNavi', 1024);
        }
        for (i = 0; i < scrollerCheckElements.length; i++) {
            if (document.getElementById(scrollerCheckElements[i])) {
                resizeLayer(scrollerCheckElements[i], 1024);
            }
        }
    } else {
        if (document.getElementById('mainNavi')) {
            resizeLayer('mainNavi', '100%');
        }
        for (i = 0; i < scrollerCheckElements.length; i++) {
            if (document.getElementById(scrollerCheckElements[i])) {
                resizeLayer(scrollerCheckElements[i], '100%');
            }
        }
    }
}

function changeToHiEndVersion() {
    var currentHighlightNew;
    if (currentMatch) {
        currentHighlight = currentMatch;
        pos1 = 0;
        pos2a = currentHighlight.lastIndexOf('.');
        currentHighlightNew = currentHighlight.slice(pos1, pos2a);
        pos2b = currentHighlightNew.lastIndexOf('/');
        htmlName = currentHighlight.slice(currentHighlight.lastIndexOf('/') + 1, pos2a);
        currentHighlightNew = currentHighlightNew.slice(pos1, pos2b) + "/_highend/xml/" + htmlName;
        xmlMetaNew = currentHighlightNew;
    } else {
        currentHighlight = self.location.href;
        pos1 = currentHighlight.indexOf("/" + confCountryTopic + "/" + confLanguageTopic);
        pos2a = currentHighlight.lastIndexOf('.');
        currentHighlightNew = currentHighlight.slice(pos1, pos2a);
        pos2b = currentHighlightNew.lastIndexOf('/');
        htmlName = currentHighlight.slice(currentHighlight.lastIndexOf('/') + 1, pos2a);
        currentHighlightNew = currentHighlightNew.slice(0, pos2b) + "/_highend/xml/" + htmlName;
        xmlMetaNew = currentHighlightNew;
    }
    // SAFARI BUG
    if (document.getElementsByTagName("meta") && !document.getElementsByTagName('meta')['target-url-swf']) {
        var name;
        var metatags = document.getElementsByTagName("meta");
        for (var i = 0; i < metatags.length; i++) {
            name = metatags.item(i).getAttribute("name");
            if (name && name == 'target-url-swf' && metatags.item(i).getAttribute("content")) {
                xmlMeta = metatags.item(i).getAttribute("content"); break;
            }
        }
        if (xmlMeta.indexOf('../') != -1) {
            pos1 = xmlMeta.lastIndexOf('../') + 2;
            pos2 = xmlMeta.lastIndexOf('.')
            xmlMetaNew = buildValidServerRelativeUrl(xmlMeta.slice(pos1, pos2));
        }
    }

    // all Browsers
    if (document.getElementsByTagName('meta')['target-url-swf']) {
        xmlMeta = document.getElementsByTagName('meta')['target-url-swf'].content;
        if (xmlMeta.indexOf('../') != -1) {
            pos1 = xmlMeta.lastIndexOf('../') + 2;
            pos2 = xmlMeta.lastIndexOf('.')
            xmlMetaNew = buildValidServerRelativeUrl(xmlMeta.slice(pos1, pos2));
        }
    }


    if (xmlMetaNew != currentHighlightNew) {
        currentHighlightNew = (currentHighlightNew.indexOf('/bmw_edit/') != -1) ? currentHighlightNew.replace("/bmw_edit/", "/") : currentHighlightNew;
        currentHighlightNew = (currentHighlightNew.indexOf('/bmw_qa/') != -1) ? currentHighlightNew.replace("/bmw_qa/", "/") : currentHighlightNew;
        currentHighlightNew = (currentHighlightNew.indexOf('/bmw_prod/') != -1) ? currentHighlightNew.replace("/bmw_prod/", "/") : currentHighlightNew;
        xmlMeta = "../.." + currentHighlightNew + ".xml";
    }


    if (typeof confCountryTopic != 'undefined' && confCountryTopic != null && typeof confLanguageTopic != 'undefined' && confLanguageTopic != null) {
        var basePath = self.location.href.substring(0, self.location.href.indexOf("/" + confCountryTopic + "/" + confLanguageTopic + "/"));

        var countryLanguagePath = basePath + "/" + confCountryTopic + "/" + confLanguageTopic + "/";
        var highendUrl = countryLanguagePath + framesetPageHighend + '?prm_content=' + xmlMeta;
        parent.location.href = highendUrl;
    }
}

function myAlert(alertText) {
    if (top.location.search.indexOf("debug") != -1) {
        alert(alertText);
    }
}

function closeChooseBandLayer() {
    if (parent.frameContent.document.getElementById('changeToHighend')) {
        oldDiv = parent.frameContent.document.getElementById('changeToHighend');
        parent.frameContent.document.getElementsByTagName("body")[0].removeChild(oldDiv);
        parent.frameBottom.document.getElementById('changeVersionLink').className = "menu";
        if ((parent.frameContent.useCurtain) && (parent.frameContent.useCurtain == "true")) {
            setVisibility(parent.frameContent.document.getElementById('iFrameContainer'), 1);
            if (typeof parent.frameContent.leftPos != 'undefined') {
                moveObject(parent.frameContent.document.getElementById('iFrameContainer'), parent.frameContent.leftPos);
            }
            else {
                moveObject(parent.frameContent.document.getElementById('iFrameContainer'), 0);
            }
            setVisibility(parent.frameContent.document.getElementById('curtain'), null, 'none');
        }
    }
}

function buildLinkList() {
    var links = new Array(document.getElementsByTagName('a').length);
    for (var i = 0; i < document.getElementsByTagName('a').length; i++) {
        links[i] = document.getElementsByTagName('a')[i].href;
    }
    return links;
}

function highlightBottomNavigation() {
    if (self.name == "frameContent") {
        if (parent.frames[1] && parent.frameBottom.bottomNavigationLoaded == true) {
            parent.frameBottom.highlightBottomNavigation(self.location.href);
        } else {
            setTimeout('highlightBottomNavigation()', 300);
        }
    }
}

function resetBottomNavigation() {
    if (self.name == "frameContent") {
        parent.frameBottom.resetBottomNavigation(self.location.href);
    }
}

function evaluateHighlighting(contentUrl, linkList) {
    var navLinkFull = "";
    var navLinkPath = "";
    var navLinkFile = "";
    var navLinkQuery = "";
    var navLinkPathParts = new Array();
    var contentLinkFull = "";
    var contentLinkPath = "";
    var contentLinkFile = "";
    var contentLinkQuery = "";
    var contentLinkPathParts = new Array();
    var evaluatedLinks = new Array();

    if (contentUrl.indexOf('?') != -1) {
        contentLinkFull = contentUrl.substring(0, contentUrl.lastIndexOf('?'));
        contentLinkQuery = contentUrl.substring(contentUrl.lastIndexOf('?'), contentUrl.length);
        if (contentLinkQuery.indexOf("&") != -1) {
            contentLinkQuery = contentLinkQuery.substring(0, contentLinkQuery.indexOf("&"));
        }
    } else {
        contentLinkFull = contentUrl;
    }
    if (contentLinkFull.charAt(contentLinkFull.length - 1) == '/') {
        contentLinkFull = contentLinkFull.substring(0, contentLinkFull.length - 1);
    }
    if (contentLinkFull.lastIndexOf('/') < contentLinkFull.lastIndexOf('.')) {
        contentLinkFile = contentLinkFull.substring(contentLinkFull.lastIndexOf('/') + 1, contentLinkFull.length);
        contentLinkPath = contentLinkFull.substring(0, contentLinkFull.lastIndexOf('/'));
    } else {
        contentLinkPath = contentLinkFull;
        contentLinkFile = "";
    }
    contentLinkPathParts = contentLinkPath.split('/');

    for (i = 0; i < linkList.length; i++) {
        navLinkFull = linkList[i];
        if (navLinkFull.indexOf('javascript:') != -1 || navLinkFull == '') {
            evaluatedLinks.push(999);
            continue;
        }
        if (navLinkFull.indexOf('?') != -1) {
            navLinkQuery = navLinkFull.substring(navLinkFull.lastIndexOf('?'), navLinkFull.length);
            if (navLinkQuery.indexOf("&") != -1) {
                navLinkQuery = navLinkQuery.substring(0, navLinkQuery.indexOf("&"));
            }
            navLinkFull = navLinkFull.substring(0, navLinkFull.lastIndexOf('?'));
        } else {
            navLinkQuery = "";
        }
        if (navLinkFull.charAt(navLinkFull.length - 1) == '/') {
            navLinkFull = navLinkFull.substring(0, navLinkFull.length - 1);
        }
        if (navLinkFull.lastIndexOf('/') < navLinkFull.lastIndexOf('.')) {
            navLinkFile = navLinkFull.substring(navLinkFull.lastIndexOf('/') + 1, navLinkFull.length);
            navLinkPath = navLinkFull.substring(0, navLinkFull.lastIndexOf('/'));
        } else {
            navLinkPath = navLinkFull;
            navLinkFile = "";
        }
        navLinkPathParts = navLinkPath.split('/');

        var contentIndex = 0;
        var navIndex = 0;
        var bestmatchFound = false;
        var charMatch = null;

        while (navLinkPathParts[navIndex] == contentLinkPathParts[contentIndex]) {
            navIndex++;
            contentIndex++;
            if (contentIndex == contentLinkPathParts.length && navIndex == navLinkPathParts.length) {
                if (navLinkFile == contentLinkFile) {
                    if (navLinkQuery == contentLinkQuery) {
                        evaluatedLinks.push(-2);
                        bestmatchFound = true;
                    } else {
                        evaluatedLinks.push(-1);
                    }
                } else {
                    charMatch = stringCompare(navLinkFile, contentLinkFile);
                    evaluatedLinks.push(0.99 - (charMatch / 100));
                }
                break;

            } else if (contentIndex == contentLinkPathParts.length) {
                evaluatedLinks.push(999);
                break;

            } else if (navIndex == navLinkPathParts.length) {
                if (confCountryTopic != null
              && confLanguageTopic != null
              && navLinkPathParts.length >= 2
              && navLinkPathParts[navLinkPathParts.length - 1] == confLanguageTopic
              && navLinkPathParts[navLinkPathParts.length - 2] == confCountryTopic) {
                    evaluatedLinks.push(999);
                } else if (confCountryTopic != null && navLinkPath.indexOf("/" + confCountryTopic + "/") == -1) {
                    evaluatedLinks.push(999);
                } else {
                    evaluatedLinks.push(contentLinkPathParts.length - contentIndex);
                }
                break;

            } else if (navLinkPathParts[navIndex] != contentLinkPathParts[contentIndex]) {
                evaluatedLinks.push(999);
                break;
            }
        }
        if (bestmatchFound) {
            break;
        }
    }
    return evaluatedLinks;
}


function stringCompare(comparator1, comparator2) {
    var shorter = null;
    var longer = null;
    if (comparator1.length > comparator2.length) {
        longer = comparator1.toLowerCase();
        shorter = comparator2.toLowerCase();
    } else {
        longer = comparator2.toLowerCase();
        shorter = comparator1.toLowerCase();
    }
    var matchCount = 0;
    for (var x = 0; x < shorter.length; x++) {
        if (shorter.charAt(x) == longer.charAt(x)) {
            matchCount++;
        } else {
            break;
        }
    }
    return matchCount;
}

function buildValidServerRelativeUrl(simpleServerRelativeUrl) {
    if (simpleServerRelativeUrl == '') {
        return '';
    }
    if (simpleServerRelativeUrl.charAt(0) != '/') {
        return simpleServerRelativeUrl;
    }
    var validServerRelativeUrl = '';
    var simpleSeverrelativeUrlNoParams = '';

    if (simpleServerRelativeUrl.indexOf('?') != -1) {
        simpleSeverrelativeUrlNoParams = simpleServerRelativeUrl.substring(0, simpleServerRelativeUrl.indexOf('?'));
    } else {
        simpleSeverrelativeUrlNoParams = simpleServerRelativeUrl;
    }
    if (self.location.href.indexOf('/bmw_edit/') != -1 && simpleSeverrelativeUrlNoParams.indexOf('/bmw_edit/') == -1) {
        validServerRelativeUrl = '/bmw_edit' + simpleServerRelativeUrl;
    } else if (self.location.href.indexOf('/bmw_qa/') != -1 && simpleSeverrelativeUrlNoParams.indexOf('/bmw_qa/') == -1) {
        validServerRelativeUrl = '/bmw_qa' + simpleServerRelativeUrl;
    } else if (self.location.href.indexOf('/bmw_prod/') != -1 && simpleSeverrelativeUrlNoParams.indexOf('/bmw_prod/') == -1) {
        validServerRelativeUrl = '/bmw_prod' + simpleServerRelativeUrl;
    } else {
        validServerRelativeUrl = simpleServerRelativeUrl;
    }
    return validServerRelativeUrl;
}

function getFullPath(basePath, relativePath) {
    var fullPath = basePath.substring(0, (basePath.lastIndexOf("/") + 1));
    var regXHostPath = /((^(https{0,1}\:\/\/[^\/]*\/))|(^(file\:\/\/[^\:]*\:\/))|(^([a-z]+\:\\))|(^([a-z]+\:\/))|(^(\\\\))|(^(\/\/)))/i;
    if (regXHostPath.test(relativePath)) {
        fullPath = relativePath;
    } else {
        var regXGoingUp = /(\.\.\/)/g, goingUpArr = [], i;
        if (regXGoingUp.test(relativePath)) {
            goingUpArr = relativePath.match(regXGoingUp);
        }
        for (i = 0; i < goingUpArr.length; ++i) {
            fullPath = fullPath.substring(0, (fullPath.lastIndexOf("/", (fullPath.length - 2)) + 1));
        }
        fullPath += relativePath.replace(regXGoingUp, "");
    }
    return fullPath;
}

function setModuleHeader(hasLink) {
    var headerHTML = "";
    if (hasLink) {
        headerHTML = '<a href="javascript:moveMenu();" style="position:relative;display:block;margin-top:1px;">' + moduleHeader + '</a>';
    } else {
        headerHTML = '<span style="position:relative;display:block;margin-top:1px;">' + moduleHeader + '</span>';
    }
    if (typeof document.getElementsByTagName('div')['moduleHeaderContainer'] == 'object') {
        writeIntoLayer('moduleHeaderContainer', headerHTML);
        setVisibility('moduleHeaderContainer', 1);
    } else {
        moveObject(document.getElementsByTagName('div')['naviClipArea'], null, 0);
    }
}

function closeMainNavigation() {
    if (window.frames && allowClose == true && (document.getElementById('mainNavi') || isMainnavigation)) {
        if (parent.frames['frameContent'] && parent.frames['frameContent'].window.frames['mainNavigationIFrame'] && parent.frames['frameContent'].window.frames['mainNavigationIFrame'].menuOpen != false) {
            parent.frames['frameContent'].window.frames['mainNavigationIFrame'].closeMenu('close');
        } else if (parent.frames['mainNavigationIFrame'] && parent.frames['mainNavigationIFrame'] && parent.frames['mainNavigationIFrame'].menuOpen != false) {
            parent.frames['mainNavigationIFrame'].closeMenu('close');
        }
    }
}


if (window.frames) {
    if (self.location.href.indexOf('https://') == -1) {
        document.onclick = closeMainNavigation;
    }
}


function download(fileUrl) {
    var downloadUrl = downloadJSP + '?file=' + buildValidServerRelativeUrl(fileUrl);
    self.location.href = downloadUrl;
}


function writeFramesetTitle(titleText) {
}

function preloader(ticketId) {
    preLoadCounter[ticketId] = 0;
    preload[ticketId] = new Array();
    for (j = 0; j < preLoadArray[ticketId].length; j++) {
        preload[ticketId][j] = new Image();
        preload[ticketId][j].onabort = function() { loadUpdate(ticketId, j); }
        preload[ticketId][j].onerror = function() { loadUpdate(ticketId, j); }
        preload[ticketId][j].onload = function() { loadUpdate(ticketId, j); }
        preload[ticketId][j].src = preLoadArray[ticketId][j];
    }
}

function loadUpdate(ticketId, imageId) {
    preLoadCounter[ticketId]++;
    if (preLoadCounter[ticketId] == preLoadArray[ticketId].length) {
        preLoadReady(ticketId);
    }
}

function preLoadReady(ticketId) {
}

function showCo2() {
    setVisibility('co2HeaderOn', 1);
    setVisibility('co2HeaderOff', 0);
    setVisibility('co2body', 1);
}

function hideCo2() {
    setVisibility('co2HeaderOn', 0);
    setVisibility('co2HeaderOff', 1);
    setVisibility('co2body', 0);
}

function stopPlayingMp3() { }


function setElementClass(elementTagName, currentClass, newClass) {
    for (var i = 0; i < document.getElementsByTagName(elementTagName).length; i++) {
        if (document.getElementsByTagName(elementTagName)[i].className == currentClass) {
            document.getElementsByTagName(elementTagName)[i].className = newClass;
        }
    }
}

function dialogClosed() { }



var loadingBoxGif = buildValidServerRelativeUrl("/client/img/standard_elements/loading_box.gif");
var lensGif = buildValidServerRelativeUrl("/client/img/standard_elements/lens.gif");
var lensMouseOverGif = buildValidServerRelativeUrl("/client/img/standard_elements/lens-h.gif");

var transGif = buildValidServerRelativeUrl("/client/img/palette/1x1_trans.gif");
var p999999Gif = buildValidServerRelativeUrl("/client/img/palette/1x1_999999.gif");
var p003399Gif = buildValidServerRelativeUrl("/client/img/palette/1x1_003399.gif");
var pff0000Gif = buildValidServerRelativeUrl("/client/img/palette/1x1_ff0000.gif");
var pafafafGif = buildValidServerRelativeUrl("/client/img/palette/1x1_afafaf.gif");


var backgroundGif = buildValidServerRelativeUrl("/client/img/modul_navigation/scroller_background.gif");
var scrollerUpGif = buildValidServerRelativeUrl("/client/img/modul_navigation/scroller_up.gif");
var scrollerDownGif = buildValidServerRelativeUrl("/client/img/modul_navigation/scroller_down.gif");
var dropperGif = buildValidServerRelativeUrl("/client/img/modul_navigation/dropper.gif");

var pulldownGif = buildValidServerRelativeUrl("/client/img/forms/pulldown.gif");
var pulldownErrorGif = buildValidServerRelativeUrl("/client/img/forms/pulldown_error.gif");

var downloadJSP = buildValidServerRelativeUrl("/client/shared/jsp/download.jsp");




if (typeof window.attachEvent != "undefined") { // msie and opera only;
    window.attachEvent("onload", function() {
        var submitNode = document.getElementsByTagName("a")["defaultAnchorButton"];
        if (submitNode && (typeof submitNode.attachEvent != "undefined")) {
            submitNode.attachEvent("onfocus", function() { submitNode.style.color = "#ffffff"; submitNode.style.backgroundColor = "#003399"; });
            submitNode.attachEvent("onblur", function() { submitNode.style.color = "#ffffff"; submitNode.style.backgroundColor = "#4c4c4c"; });
        }
    });
}

formImages = new Array(
      buildValidServerRelativeUrl('/client/img/palette/1x1_003399.gif'),
      buildValidServerRelativeUrl('/client/img/palette/1x1_ff0000.gif'),
      buildValidServerRelativeUrl('/client/img/palette/1x1_trans.gif'),
      buildValidServerRelativeUrl('/client/img/forms/pulldown.gif'),
      buildValidServerRelativeUrl('/client/img/forms/pulldown_error.gif'),
      buildValidServerRelativeUrl('/client/img/forms/checkbox.gif'),
      buildValidServerRelativeUrl('/client/img/forms/checkbox-h.gif'),
      buildValidServerRelativeUrl('/client/img/forms/checkbox_error.gif'),
      buildValidServerRelativeUrl('/client/img/forms/checkbox_error-h.gif'),
      buildValidServerRelativeUrl('/client/img/forms/checkbox_disabled.gif'),
      buildValidServerRelativeUrl('/client/img/forms/checkbox_disabled-h.gif')
  );
formImageSources = new Array();
for (i = 0; i < formImages.length; i++) {
    formImageSources[i] = new Image();
    formImageSources[i].src = formImages[i];
}

var p003399Gif = formImageSources[0].src;
var pff0000Gif = formImageSources[1].src;
var transGif = formImageSources[2].src;
var pulldownGif = formImageSources[3].src;
var pulldownErrorGif = formImageSources[4].src;

var checkboxGif = formImageSources[5].src;
var checkboxGifHigh = formImageSources[6].src;
var checkboxErrorGif = formImageSources[7].src;
var checkboxErrorGifHigh = formImageSources[8].src;
var checkboxDisabledGif = formImageSources[9].src;
var checkboxDisabledGifHigh = formImageSources[10].src;

var activInfo = "";
var superOffsetLeft = 0;
var superOffsetTop = 0;

function showInfoText(objName) {
    setZIndex(objName + "InfoText", 560);
    setZIndex("infoCloseButton", 561);
    if (activInfo != "") {
        if (typeof (hideInfo) == "function") {
            hideInfo();
        }
    }
    activInfo = objName;
    moveObject("infoCloseButton", getAbsoluteLeft("infoButton" + objName) + superOffsetLeft, getAbsoluteTop("infoButton" + objName) + superOffsetTop);
    setVisibility(objName + "InfoText", null, "block");
    setVisibility("infoCloseButton", 1);
}

function hideInfo() {
    setVisibility(activInfo + "InfoText", null, "none");
    setVisibility("infoCloseButton", 0);
    activInfo = "";
}

function switchHelpText(divName) {
    if (typeof (hideInfo) == "function") {
        hideInfo();
    }
    if (getDivInformation(divName, 'display') == "block") {
        setVisibility(divName, null, "none");
        switchImage('helpButtonImg', 0, 0, 0, 'helpButtonImg');
    } else {
        setVisibility(divName, null, "block");
        switchImage('helpButtonImg', 1, 1, 1, 'helpButtonImg');
    }
}



function FormElement(id, name, elementLabel, elementValue, editor, defaultText) {
    this.id = id;
    this.name = name;
    this.elementLabel = elementLabel;
    this.elementValue = elementValue;
    this.editor = editor;
    this.defaultText = defaultText;
    this.options = new Array();
    this.attributes = new Array();
    this.hintText = null;
    this.hasError = false;
    this.hasInfo = false;
    this.isReadonly = false;
    this.isDisplayedAsText = false;
    this.isHidden = false;
    this.mandatory = false;
    this.multiValued = false;
    this.changeValueEvent = null;
}
FormElement.prototype.addOption = function(name, value) {
    this.options.push(name);
    this.options.push(value);
};
FormElement.prototype.hasOptions = function() {
    return this.options.length > 0;
};
FormElement.prototype.getOptionCount = function() {
    if (this.options.length <= 0) return 0;
    return this.options.length / 2;
};
FormElement.prototype.getSelectedOptionIndex = function() {
    if (this.options.length <= 0) return 0;
    if (this.elementValue == "") return 0;
    for (i = 0; i < this.options.length; i = i + 2) {
        if (this.options[i + 1] == this.elementValue) {
            return i / 2;
        }
    }
};
FormElement.prototype.setAttribute = function(name, value) {
    for (i = 0; i < this.attributes.length; i = i + 2) {
        if (this.attributes[i] == name) {
            this.attributes[i + 1] = value;
            return;
        }
    }
    this.attributes.push(name);
    this.attributes.push(value);
};
FormElement.prototype.getAttribute = function(name) {
    for (i = 0; i < this.attributes.length; i = i + 2) {
        if (this.attributes[i] == name) {
            return this.attributes[i + 1];
        }
    }
    return null;
};
FormElement.prototype.hasAttribute = function(name) {
    for (i = 0; i < this.attributes.length; i = i + 2) {
        if (this.attributes[i] == name) {
            return true;
        }
    }
    return false;
};
FormElement.prototype.hasChangeValueEvent = function() {
    return this.changeValueEvent != null && this.changeValueEvent != "";
};
FormElement.prototype.toString = function() {
    return this.name + "=" + this.elementValue;
};





selectBoxes = new Array();
directOrder = new Array();
function selectBoxNotify(formField) {
    alert('test2');
}
function setOption(text, value, formField, notify, index) {

    formFieldValue = value;
    activeText = text;
    setVisibility('selectBoxContent' + formField, 0, 'none');
    writeIntoLayer('selectedValue' + formField, "&nbsp; " + text);
    if (document.forms.length > 0) {
        document.forms[0][formField].value = formFieldValue;
    }
    if (notify) {
        selectBoxNotify(formField, formFieldValue, index);
    }
    if (formField == 'drdHuidigeWagen_Merk') {
        setTimeout('__doPostBack(\'ctl00$c$DropDownList1\',\'\')', 0)
    }
}
function writeSelectBox(formField, keyValueArray, zIndex, elementWidth, visibleEntries, selectedValue, notify, error, readonly, direction, sublayerwidth) {
    var formValue = "";
    entryFound = false;
    var bgcolorBorder = "#003399";
    var bgcolorBorder1 = "#FF6600";
    var borderGif = p003399Gif;
    var pulldownImage = pulldownGif;
    if (error == true) {
        bgcolorBorder = "#ff0000";
        pulldownImage = pulldownErrorGif;
        borderGif = pff0000Gif;
    }
    for (i = 0; i < keyValueArray.length; i++) {
        if (keyValueArray[i + 1] == selectedValue) {
            selectText = keyValueArray[i];
            formValue = keyValueArray[i + 1];
            entryFound = true;
            break;
        }
        i++;
    }
    if (!entryFound) {
        selectText = keyValueArray[0];
        formValue = keyValueArray[1];
    }
    selectBoxes.push(formField);
    directOrder[formField] = false;
    tdWidth = elementWidth - 20;
    if (visibleEntries > (keyValueArray.length / 2)) {
        visibleEntries = (keyValueArray.length / 2);
    }
    deep = (visibleEntries * 16) + 14;
    selectBox = '';
    if (readonly == true) {
        selectBox += '<input type="text" class="defaultReadonly" readonly="readonly" value="' + selectText + '">';
        selectBox += '<input type="hidden" name="' + formField + '" value="' + formValue + '">';
    } else {
        selectBox += '<div style="position:relative;z-index:' + zIndex + ';" class="selectBox">';
        selectBox += '<table width="' + elementWidth + '" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff">';
        selectBox += '<colgroup><col width="1"><col width="' + tdWidth + '"><col width="18"><col width="1"></colgroup>';
        selectBox += '<tr><td colspan="4" bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="' + elementWidth + '" height="1"></td></tr>';
        selectBox += '<tr>';
        selectBox += '<td bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="1" height="16"></td>';
        selectBox += '<td valign="middle" onClick="setVisibility(\'selectBoxContent' + formField + '\');" onMouseover="directOrder[\'' + formField + '\']=true;" onMouseout="directOrder[\'' + formField + '\']=false;" style="cursor:pointer;"><span id="selectedValue' + formField + '">&nbsp; ' + selectText + '</span></td>';
        selectBox += '<td><a href="javascript:setVisibility(\'selectBoxContent' + formField + '\');" onMouseover="directOrder[\'' + formField + '\']=true;" onMouseout="directOrder[\'' + formField + '\']=false;"><img src="' + pulldownImage + '" width="18" height="16" border="0"></a></td>';
        selectBox += '<td  bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="1" height="16"></td>';
        selectBox += '</tr>';
        selectBox += '<tr><td colspan="4" bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="' + elementWidth + '" height="1"></td></tr>';
        selectBox += '</table>';
        if (sublayerwidth) {
            if (direction == "above") {
                selectBox += '<div id="selectBoxContent' + formField + '" class="selectBoxContent" style="width:' + sublayerwidth + '; top:' + -(deep + 1) + 'px;" >';
            } else {
                selectBox += '<div id="selectBoxContent' + formField + '" class="selectBoxContent" style="width:' + sublayerwidth + '; border-top:1px solid ' + bgcolorBorder + '; top:17px;">';
            }
            selectBox += '<table width="' + sublayerwidth + '" cellspacing="0" cellpadding="0" border="0">';
        } else {
            if (direction == "above") {
                selectBox += '<div id="selectBoxContent' + formField + '" class="selectBoxContent" style="top:' + -(deep + 1) + 'px;" >';
            } else {
                selectBox += '<div id="selectBoxContent' + formField + '" class="selectBoxContent">';
            }
            selectBox += '<table width="' + elementWidth + '" cellspacing="0" cellpadding="0" border="0">';
        }
        if (direction == "above") {
            if (sublayerwidth) {
                selectBox += '<tr><td colspan="3" bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="' + sublayerwidth + '" height="1"></td></tr>';
            } else {
                selectBox += '<tr><td colspan="3" bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="' + elementWidth + '" height="1"></td></tr>';
            }
        }
        selectBox += '<tr>';
        selectBox += '<td width="1" bgcolor="' + bgcolorBorder + '"><img src="' + transGif + '" width="1" height="1"></td>';
        selectBox += '<td width="' + (tdWidth - 2) + '" valign="top">';
        if (sublayerwidth) {
            selectBox += '<div style="width:' + (sublayerwidth - 2) + 'px; height:' + deep + 'px; background-color:#ffffff; overflow:auto;">';
        }
        else {
            selectBox += '<div style="width:' + (elementWidth - 2) + 'px; height:' + deep + 'px; background-color:#ffffff; overflow:auto;">';
        }
        selectBox += '<span id="vSpace" style="padding-bottom:7px;"></span>';
        for (i = 0; i < keyValueArray.length; i++) {
            keyValueArray[i + 1] = keyValueArray[i + 1].replace(/'/g, "\\\'");
            var tempValue = keyValueArray[i].replace(/'/g, "\\\'");
            selectBox += '<a href="javascript:setOption(\'' + tempValue + '\',\'' + keyValueArray[i + 1] + '\',\'' + formField + '\',' + notify + ',' + zIndex + ');" class="selectboxEntry">&nbsp; ' + keyValueArray[i] + '</a>';
            i++;
        }
        selectBox += '</div>';
        selectBox += '</td>';
        selectBox += '<td width="1" bgcolor="' + bgcolorBorder + '"><img src="' + transGif + '" width="1" height="1"></td>';
        selectBox += '</tr>';
        if (sublayerwidth) {
            selectBox += '<tr><td colspan="3" bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="' + sublayerwidth + '" height="1"></td></tr>';
        }
        else {
            selectBox += '<tr><td colspan="3" bgcolor="' + bgcolorBorder + '"><img src="' + borderGif + '" width="' + elementWidth + '" height="1"></td></tr>';
        }
        selectBox += '</table>';
        selectBox += '</div>';
        selectBox += '</div>';
        selectBox += '<div style="width:2px;height:2px;overflow:hidden;"></div>';
        selectBox += '<input type="hidden" name="' + formField + '" value="' + formValue + '">';
    }
    return selectBox;
}
function checkSelectBoxStatus() {
    for (j = 0; j < selectBoxes.length; j++) {
        if (!directOrder[selectBoxes[j]]) {
            setVisibility('selectBoxContent' + selectBoxes[j], 0, 'none');
        }
    }
}
var scriptedCheckbox = "";
function writeCheckbox(formField, description, boxInputValue, boxInputName, boxIndex, zIndex, elementWidth, notify, error, className, mandatory, readonly) {
    var currentGifDefault;
    var currentGifSwitch;
    var currentTextStyle = "padding-left:23px;";
    var mandatoryStyle;
    if (boxInputValue != "true") {
        currentGifDefault = checkboxGif;
        currentGifSwitch = checkboxGifHigh;
        if (error) {
            currentGifDefault = checkboxErrorGif;
            currentGifSwitch = checkboxErrorGifHigh;
            currentTextStyle = "padding-left:23px;color:#ff0000;";
        }
        if (readonly) {
            currentGifDefault = checkboxDisabledGif;
            currentGifSwitch = checkboxDisabledGifHigh;
            currentTextStyle = "padding-left:23px;color:#333333;";
            checkReadOnly.push(formField);
        } else {
            for (i = 0; i < checkReadOnly.length; i++) {
                if (checkReadOnly[i] == formField) {
                    checkReadOnly.slice(i, 1);
                }
            }
        }
    } else {
        currentGifDefault = checkboxGifHigh;
        currentGifSwitch = checkboxGif;
        if (error) {
            currentGifDefault = checkboxErrorGifHigh;
            currentGifSwitch = checkboxErrorGif;
            currentTextStyle = "padding-left:23px;color:#ff0000;";
        }
        if (readonly) {
            currentGifDefault = checkboxDisabledGifHigh;
            currentGifSwitch = checkboxDisabledGif;
            currentTextStyle = "padding-left:23px;color:#333333;";
            checkReadOnly.push(formField);
        } else {
            for (i = 0; i < checkReadOnly.length; i++) {
                if (checkReadOnly[i] == formField) {
                    checkReadOnly.slice(i, 1);
                }
            }
        }
    }
    if (mandatory) {
        mandatoryStyle = "display:none;";
    } else {
        mandatoryStyle = "display:none;";
    }
    description = description.replace(/\n/g, '<br><br>');
    checkClient();
    if (browserId == 'Safari') {
        var descriptionWidth = elementWidth - 19;
        scriptedCheckbox = '<span id="vSpace" class="formOffset2"></span><br>'
                     + '<div class="' + className + '" style="position:relative; display: inline; width:' + elementWidth + 'px; height:auto; z-index:' + zIndex + ';">'
                     + '<div style="position:absolute; display:inline; top:13px; left:0; width:23px;"><img src="' + currentGifDefault + '" vspace="1" style="cursor:pointer;" id="checkboxImage' + boxIndex + '" preload="' + currentGifSwitch + '" onClick="setCheckbox(this,\'' + formField + '\',\'' + boxInputName + '\');"></div>'
                     + '<div style="display:inline;float:left;"><div style="' + currentTextStyle + ';display: block;width:' + descriptionWidth + 'px;">'
                     + description
                     + '<span id="mandatory_' + formField + '" style="' + mandatoryStyle + '">*</span></div></div>'
                     + '<input type="hidden" name="' + boxInputName + '" value="' + boxInputValue + '">'
                     + '</div>';
    } else {
        var descriptionWidth = elementWidth - 19;
        scriptedCheckbox = '<span id="vSpace" class="formOffset2"></span><br>'
                     + '<div class="' + className + '" style="position:relative; display: inline; width:' + elementWidth + 'px; height:auto; z-index:' + zIndex + ';">'
                     + '<div style="display:inline;"><div style="' + currentTextStyle + ';display: block;width:' + descriptionWidth + 'px;">'
                     + description
                     + '<span id="mandatory_' + formField + '" style="' + mandatoryStyle + '">*</span></div></div>'
                     + '<div style="position:absolute; top:0; left:0; width:23px;"><img src="' + currentGifDefault + '" vspace="1" style="cursor:pointer;" id="checkboxImage' + boxIndex + '" preload="' + currentGifSwitch + '" onClick="setCheckbox(this,\'' + formField + '\',\'' + boxInputName + '\');"></div>'
                     + '<input type="hidden" name="' + boxInputName + '" value="' + boxInputValue + '">'
                     + '</div>';
    }
    return scriptedCheckbox;
}
var allowSend = true;
function handleSubmit(cValue) {
    if (allowSend == true) {
        allowSend = false;
        if (cValue) {
            document.forms[0].elements['action'].value = cValue;
        }
        document.forms[0].submit();
    }
    return false;
}
function writeButton(formId, formName, className, currentValue, label) {
    var scriptedButton = '<a href="#" onclick="return handleSubmit(\'' + currentValue + '\')" id="defaultAnchorButton">' + label + '</a>';
    return scriptedButton;
}




var formElements = new Array();
var checkReadOnly = new Array();
function setCheckbox(imageObject, formElement, inputElement) {
    var setReadonly = false;
    for (i = 0; i < checkReadOnly.length; i++) {
        if (checkReadOnly[i] == formElement) {
            setReadonly = true;
            break;
        } else {
            setReadonly = false;
        }
    }
    if (setReadonly == false) {
        var boxImgsrc;
        if (formElements[formElement][2] != "true") {
            formElements[formElement][2] = "true";
            if (document.images[imageObject.id].src.indexOf('-h') != -1) {
                boxImgsrc = document.images[imageObject.id].src;
            } else {
                boxImgsrc = document.images[imageObject.id].src.split('.gif');
                boxImgsrc = boxImgsrc[0] + '-h.gif'
            }
            document.images[imageObject.id].src = boxImgsrc;
            document.forms[0][inputElement].value = formElements[formElement][1];
        } else {
            formElements[formElement][2] = "false";
            if (document.images[imageObject.id].src.indexOf('-h') != -1) {
                boxImgsrc = document.images[imageObject.id].src.split('-h');
                boxImgsrc = boxImgsrc[0] + '.gif'
            } else {
                boxImgsrc = document.images[imageObject.id].src;
            }
            document.images[imageObject.id].src = boxImgsrc;
            document.forms[0][inputElement].value = formElements[formElement][0];
        }
        handleBehaviours(inputElement, imageObject.id);
    }
}
function selectBoxNotify(formField, formFieldValue, currentIndex) {
    if (typeof dependingSelects != 'undefined') {
        if (dependingSelects[formField] && formFieldValue != "" && typeof optionGroups[dependingSelects[formField]][formFieldValue] != 'undefined') {
            divContent = writeSelectBox(dependingSelects[formField], optionGroups[dependingSelects[formField]][formFieldValue], currentIndex - 1, 289, 4);
            writeIntoLayer(document.getElementsByTagName("div")[dependingSelects[formField]], divContent);
            if (typeof dependingSelects != 'undefined' && dependingSelects[formField]) {
                for (i = 0; i < dependingSelects[formField].length; i++) {
                    setVisibility('element_' + dependingSelects[formField][i], null, 'block');
                }
            }
        } else if (dependingSelects[formField]) {
            for (i = 0; i < dependingSelects[formField].length; i++) {
                setVisibility('element_' + dependingSelects[formField][i], null, 'none');
                document.forms[0][dependingSelects[formField][i]].value = '';
            }
        }
        notifyValue(formField, formFieldValue);
    }
}
function submitForm(actionName) {
    document.forms[0].elements['action'].value = actionName;
    document.forms[0].submit();
    return false;
}
function renderDropSelect(elem) {
    var checkNotify = false;
    if ((typeof dependingSelects != 'undefined' && dependingSelects[elem.name]) || (typeof behaveDependOn != 'undefined' && behaveDependOn[elem.name])) {
        checkNotify = true;
    }
    if (elem.defaultText != "") {
        elem.options.unshift("");
        elem.options.unshift(elem.defaultText);
    }
    var selectHeight = elem.getOptionCount();
    if (selectHeight > 10) selectHeight = 10;
    if (selectHeight < 1) selectHeight = 1;
    var selectWidth;
    var selectedValue = elem.elementValue;
    if (elem.elementValue == "") {
        selectedValue = elem.defaultText;
    }
    if (elem.getAttribute('class').indexOf('default') != -1) {
        selectWidth = 220;
    } else {
        selectWidth = 220;
    }
    document.write(writeSelectBox(elem.name, elem.options, elem.getAttribute('zIndex'), selectWidth, selectHeight, selectedValue, checkNotify, elem.hasError, elem.isReadonly));
}
var checkboxCounter = 0;
function renderCheckbox(elem) {
    formElements[elem.name] = new Array("false", "true", elem.elementValue);
    checkboxCounter++;
    var checkNotify = "false";
    if (typeof behaviours != 'undefined' && behaveDependOn[elem.name]) {
        checkNotify = "true";
    }
    var boxWidth;
    if (elem.getAttribute('class').indexOf('default') != -1) {
        boxWidth = 289;
    } else {
        boxWidth = 289;
    }
    var isChecked = 'false';
    for (i = 0; i < elem.options.length; i++) {
        if (elem.options[1] == elem.elementValue) {
            isChecked = 'false';
        } else if (elem.options[3] == elem.elementValue) {
            isChecked = 'true';
        }
    }
    document.write(writeCheckbox(elem.name, elem.elementLabel, isChecked, elem.name, checkboxCounter, elem.getAttribute('zIndex'), boxWidth, checkNotify, elem.hasError, elem.getAttribute('class'), elem.mandatory, elem.isReadonly));
}
function renderButton(elem) {
    document.write(writeButton(elem.id, elem.name, elem.getAttribute('class'), elem.elementValue, elem.defaultText));
}
function handleSections(elemName) {
    var sectionDependant, sectionHandler;
    if (typeof behaviours != 'undefined' && sectionsBehaveDependOn[elemName]) {
        for (i = 0; i < sectionsBehaveDependOn[elemName].length; i++) {
            if (sectionBehaviours[sectionsBehaveDependOn[elemName][i]]) {
                for (e = 0; e < sectionBehaviours[sectionsBehaveDependOn[elemName][i]].length; e++) {
                    if (sectionBehaviours[sectionsBehaveDependOn[elemName][i]][e][2] == 0) {
                        setVisibility("section_" + sectionsBehaveDependOn[elemName][i], null, 'none');
                    } else {
                        setVisibility("section_" + sectionsBehaveDependOn[elemName][i], null, 'block');
                    }
                }
            }
        }
    }
}
var a = 0, u = 0;
var breakDisplay = "";
var breakVisibility = "";
var breakMandatory = "";
function handleBehaviours(elemName, token) {
    if (typeof behaviours != 'undefined') {
        handleSections(elemName);
        if (behaveDependOn[elemName]) {
            for (a = 0; a < behaveDependOn[elemName].length; a++) {
                parentElement = behaveDependOn[elemName][a];
                if (behaviours[parentElement][0].length > 0) {
                    handleDisplay(parentElement, behaviours[parentElement][0], token);
                }
                if (behaviours[parentElement][1].length > 0) {
                    handleVisibility(parentElement, behaviours[parentElement][1]);
                }
                if (behaviours[parentElement][2].length > 0) {
                    handleMandatory(parentElement, behaviours[parentElement][2])
                }
            }
        }
    }
}
function isBehaviourActive(behaviourDef) {
    if (behaviourDef[1] == null) return false;
    if (behaviourDef.length > 3 && behaviourDef[3] == 'notequal') {
        // behaviour matches notequal
        return document.forms[0].elements[behaviourDef[0]].value != behaviourDef[1];
    } else {
        // behaviour matches equal (default)
        return document.forms[0].elements[behaviourDef[0]].value == behaviourDef[1];
    }
}
function handleDisplay(parentElement, displayArray, token) {
    for (i = displayArray.length - 1; i >= 0; i--) {
        if (typeof document.forms[0].elements[displayArray[i][0]] != 'undefined' && typeof document.forms[0].elements[parentElement] == 'object') {
            if (isBehaviourActive(displayArray[i]) && (breakDisplay != parentElement)) {
                displayMode = displayArray[i][2];
                switchDisplayMode(displayMode, parentElement, displayArray[i][0], token);
                breakDisplay = parentElement;
            } else if (breakDisplay != parentElement && displayArray[i][1] == null) {
                displayMode = displayArray[i][2];
                switchDisplayMode(displayMode, parentElement, displayArray[i][0], token);
            }
        }
    }
    breakDisplay = "";
}
function switchDisplayMode(displayMode, parentElement, displayArrayElement, token) {
    switch (displayMode) {
        case 0:
            handleDisplayTextBehaviour(parentElement, displayArrayElement);
            break;
        case 1:
            handleDisplayReadonlyBehaviour(parentElement, displayArrayElement, token);
            break;
        case 2:
            handleDisplayEditBehaviour(parentElement, displayArrayElement, token);
            break;
    }
}
function handleDisplayTextBehaviour(parentElement, controlElement) {
    writeIntoLayer(parentElement, document.forms[0].elements[displayArray[i][0]].value);
}
function handleDisplayReadonlyBehaviour(parentElement, controlElement, imageId) {
    if (document.forms[0].elements[parentElement].type == "hidden" && (typeof document.getElementsByTagName("div")[parentElement] != 'undefined')) {
        var checkElem;
        for (checkElem in formElements) {
            if (parentElement == checkElem) {
                checkReadOnly.push(parentElement);
                if (formElements[parentElement][2] == "false") {
                    document.images[imageId].src = checkboxDisabledGif;
                } else {
                    document.images[imageId].src = checkboxDisabledGifHigh;
                }
            }
        }
    }
    if (typeof document.forms[0].elements[parentElement] == 'object') {
        if (document.forms[0].elements[parentElement].type == 'hidden') {
        } else {
            document.forms[0].elements[parentElement].readonly = true;
            setClassName(document.forms[0].elements[parentElement], 'disabled input100');
        }
    }
}
function handleDisplayEditBehaviour(parentElement, controlElement, imageId) {
    var checkElem;
    for (checkElem in formElements) {
        if (parentElement == checkElem) {
            if (formElements[parentElement][2] == "false") {
                document.images[imageId].src = checkboxGif;
            } else {
                document.images[imageId].src = checkboxGifHigh;
            }
        }
    }
    document.forms[0].elements[parentElement].readonly = false;
    setClassName(document.forms[0].elements[parentElement], 'input100');
}
function handleVisibility(parentElement, displayArray) {
    for (i = displayArray.length - 1; i >= 0; i--) {
        if (typeof document.forms[0].elements[displayArray[i][0]] != 'undefined' && typeof document.forms[0].elements[parentElement] == 'object') {
            if (isBehaviourActive(displayArray[i]) && (breakVisibility != parentElement)) {
                visibilityMode = displayArray[i][2];
                switchVisibilityMode(visibilityMode, parentElement, displayArray[i][0]);
                breakVisibility = parentElement;
            } else if (breakVisibility != parentElement && displayArray[i][1] == null) {
                visibilityMode = displayArray[i][2];
                switchVisibilityMode(visibilityMode, parentElement, displayArray[i][0]);
            }
        }
    }
    breakVisibility = "";
}
function switchVisibilityMode(visibilityMode, parentElement, displayArrayElement) {
    switch (visibilityMode) {
        case 0:
            setVisibility("element_" + parentElement, null, 'none');
            break;
        case 1:
            setVisibility("element_" + parentElement, null, 'block');
            break;
    }
}
function handleMandatory(parentElement, displayArray) {
    for (i = displayArray.length - 1; i >= 0; i--) {
        if (typeof document.forms[0].elements[displayArray[i][0]] != 'undefined' && typeof document.forms[0].elements[parentElement] == 'object') {
            if (isBehaviourActive(displayArray[i]) && (breakMandatory != parentElement)) {
                mandatoryMode = displayArray[i][2];
                switchMandatoryMode(mandatoryMode, parentElement, displayArray[i][0]);
                breakMandatory = parentElement;
            } else if (breakMandatory != parentElement && displayArray[i][1] == null) {
                mandatoryMode = displayArray[i][2];
                switchMandatoryMode(mandatoryMode, parentElement, displayArray[i][0]);
            }
        }
    }
    breakMandatory = "";
}
function switchMandatoryMode(mandatoryMode, parentElement, displayArrayElement) {
    switch (mandatoryMode) {
        case 0:
            setVisibility("mandatory_" + parentElement, null, "none");
            break;
        case 1:
            setVisibility("mandatory_" + parentElement, null, "inline");
            break;
    }
}
function notifyValue(elemName, curValue) {
    handleBehaviours(elemName);
}
function checkEmptySelects() {
    if (typeof dependingSelects != 'undefined') {
        if (typeof document.forms[0] != 'undefined') {
            var currentDependant;
            for (currentDependant in dependingSelects) {
                for (i = 0; i < dependingSelects[currentDependant].length; i++) {
                    //if(document.forms[0][currentDependant] && document.forms[0][currentDependant].value == eval('fe_'+currentDependant).options[0]){
                    if (document.forms[0][currentDependant] && document.forms[0][currentDependant].value == window["fe_" + currentDependant].options[0]) {
                        setVisibility('element_' + dependingSelects[currentDependant][i], null, 'none');
                    } /*
          alert("dependingSelects[\"" + currentDependant + "\"] : " + dependingSelects[currentDependant] + "\ndependingSelects[\"" + currentDependant + "\"][" + i + "] : " + dependingSelects[currentDependant][i]);
          alert('fe_'+dependingSelects[currentDependant][i]);
          alert(eval('fe_'+dependingSelects[currentDependant][i]));*/
                    //if((typeof eval('fe_'+dependingSelects[currentDependant][i]) != 'undefined') && (typeof eval('fe_'+dependingSelects[currentDependant][i]).options[2] != 'string')){
                    if ((typeof window["fe_" + dependingSelects[currentDependant][i]] != "undefined") && (typeof window["fe_" + dependingSelects[currentDependant][i]].options[2] != "string")) {
                        setVisibility('element_' + dependingSelects[currentDependant][i], null, 'none');
                    }
                }
            }
        } else {
            window.setTimeout('dependingSelects()', 500);
        }
    }
}