var copyright = "Copyright (c) 2010 TEC-IT Datenverarbeitung GmbH";

var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
 
function GetScrollPosX() {
    if (self.pageYOffset)
        return self.pageXOffset;
    if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollLeft;
    if (document.body)
        return document.body.scrollLeft;
    return 0;
};

function GetScrollPosY() {
    if (self.pageYOffset)
        return self.pageYOffset;
    if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
    if (document.body)
        return document.body.scrollTop;
    return 0;
};

function SetScrollPos(x, y) {
    window.scrollTo(x, y);
};

// display help panel
function ShowHelp(event, divId) {
    var element = document.getElementById(divId);
    var width = element.offsetWidth + 10;
    var cX = 0; var cY = 0; var rX = 0; var rY = 0; var innerWidth = 0;

    // for all browsers supporting "documentElement.clientWidth"
    if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth != 'undefined'
      && document.documentElement.clientWidth != 0)
        innerWidth = document.documentElement.clientWidth;
    else
        innerWidth = document.body.clientWidth;

    if ((event.clientX + width) > innerWidth)
        cX = innerWidth - width;
    else
        cX = event.clientX;

    if (cX < 0)
        cX = 0;

    cY = event.clientY;

    rX = GetScrollPosX();
    rY = GetScrollPosY();

    cX += rX + 10;
    cY += rY + 10;

    element.style.left = cX + 'px';
    element.style.top = cY + 'px';
    element.style.visibility = 'visible';
};

// hide help panel
function HideHelp(divId) {
    document.getElementById(divId).style.visibility = 'hidden';
};

function GetElement(id) {
    return document.getElementById(id);
};

function GetRow(id) {
    return GetElement("TR_" + id);
};

function GetDiv(id) {
    return GetElement("DIV_" + id);
};

// set display style
function DispStyle(id, display) {
    var item = GetElement(id);
    if (!item || item.id == '') item = GetRow(id);
    if (!item || item.id == '') item = GetDiv(id);
    if (item) item.style.display = display;
};

// hide item
function Hide(id) {
    DispStyle(id, 'none');
};

// hide item
function Show(id) {
    if (isIE6)
        style = '';
    else if (String(id).substring(0, 3) == 'TR_' || GetRow(id))
        style = 'table-row';
    else
        style = 'block';
    DispStyle(id, style);
};

// return field
function Field(name) {
    return document.getElementsByName('FORM_F_' + name)[0];
}

/* return true if field value contains given characters */
/* name is not id, it is name!!*/
function FldContains(name, chars) {
    var field = Field(name);
    if (field) {
        if (field.type == "select-one")
            field = field[field.selectedIndex].value;
        else if (field.type == "text")
            field = field.value;
    }
    if (field && field.indexOf(chars) != -1)
        return true;
    return false;
}

// expand block
function expand(id, display) {
    var item = GetElement(id);
    var image = GetElement(id + '_img');

    if (item.style.display == 'block' || display == 'none') {
        item.style.display = 'none';
        image.src = 'images/dashplus.gif';
    } else {
        item.style.display = 'block';
        image.src = 'images/dashminus.gif';
    }
};

// change cursor on mouse over 
function cursor(id) {
    GetElement(id + '_h2').style.cursor = 'hand';
    GetElement(id + '_img').style.cursor = 'hand';
};

// change text of label on event
function updateLabel(id, text) {
    var row = GetRow(id);

    // if there is a text to display, show it
    if (text != '') {
        if (row)
            row.style.display = "table-row";
        else
            DispStyle(id, 'block');

        GetElement(id).innerHTML = text;
    }
    else {
        // hide table row
        if (row)
            row.style.display = "none";
        // hide label by default 
        else
            Hide(id);
    }
};

// enables the element with the corresponding id
function Enable(id) {
    GetElement(id).disabled = false;
};

// disables the element with the corresponding id
function Disable(id) {
    GetElement(id).disabled = true;
};

// adds actual scroll position and moves to new link
function AddScrollPos(link) {
    if (!link || !link.href)
        return true;

    if (link.href.indexOf('?') == -1) link.href = link.href + '?';

    // add scroll positions
    link.href = link.href + '&scrollposx=' + GetScrollPosX() + '&scrollposy=' + GetScrollPosY();

    return true;
};

/* CUSTOM EVENT HANDLER */
// used in order form

function Event() {
    this.eventHandlers = new Array();
};

Event.prototype.addHandler = function(eventHandler) {
    this.eventHandlers.push(eventHandler);
};

Event.prototype.raise = function(obj, id, value) {
    for (var i = 0; i < this.eventHandlers.length; i++) {
        this.eventHandlers[i](obj, id, value);
    }
};

var _xmlHttp = null; var _bt = null; var _pn = null; var _pnPX = 0; var _pnPY = 0; var _pnW = 252; var _pnHtml = null; var count = 0; var _myTimer = null; function EncUri(a) { if (typeof encodeURIComponent == 'function') { return encodeURIComponent(a) } else { return escape(a) } } function ShowBookmark(a, b, c) { if (_xmlHttp == null) _xmlHttp = GetXmlHttpObject(); if (_xmlHttp == null || !document.getElementById) return false; _pn = document.getElementById(a + '_Panel'); _bt = document.getElementById(a + '_Link'); if (_pnHtml == null || _pnHtml.indexOf('<!-- OK -->') == -1) { b = b + "?url=" + EncUri(location.href); b = b + "&title=" + EncUri(document.title); b = b + "&language=" + c; _xmlHttp.onreadystatechange = StateChanged; _xmlHttp.open("GET", b, true); _xmlHttp.send(null) } DisplayPanel(_pnHtml); SetHideTimer(false); return true } function StateChanged() { if (_xmlHttp.readyState == 4) { var a = _xmlHttp.responseText; if (a.indexOf('<!-- OK -->') == -1) a = '<h3>Sorry, service not available...</h3>'; DisplayPanel(a) } } function GetXmlHttpObject() { var a = null; try { a = new XMLHttpRequest() } catch (e) { try { a = new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { a = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { } } } return a } function DisplayPanel(a) { if (_pn && _pn.style) { if (a != null) { _pnHtml = a; _pn.innerHTML = a } PositionPanel(); _pn.style.width = '250px'; _pn.style.visibility = 'visible' } } function PositionPanel() { var a = PageWidth(); _pnPX = FindPosX(_bt); _pnPY = FindPosY(_pn); if (a != null && _pnPX > 0) { if ((_pnPX + _pnW) > a) _pnPX = a - _pnW; _pn.style.left = _pnPX + 'px' } } function FindPosX(a) { var b = 0; if (a.offsetParent) while (1) { b += a.offsetLeft; if (!a.offsetParent) break; a = a.offsetParent } else if (a.x) b += a.x; return b } function FindPosY(a) { var b = 0; if (a.offsetParent) while (1) { b += a.offsetTop; if (!a.offsetParent) break; a = a.offsetParent } else if (a.y) b += a.y; return b } function PageWidth() { if (window.innerWidth != null) return window.innerWidth; else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; else if (document.body != null) return document.body.clientWidth; else return null } function PanelMouseOut(a) { SetHideTimer(true) } function PanelMouseOver(a) { SetHideTimer(false) } function SetHideTimer(a) { if (a == true) { if (_myTimer != null) clearTimeout(_myTimer); _myTimer = setTimeout("HideBookmark()", 6600) } else { clearTimeout(_myTimer); _myTimer = null } } function HideBookmark() { _mouseOver = false; _pn.style.visibility = 'hidden'; SetHideTimer(false) } function AddFavorite() { url = location.href; title = document.title; message = 'In order to bookmark this site you need to do so manually through your browser.'; try { if (window.sidebar) alert('Press Ctrl-D to bookmark this page in your favorites.'); else if (window.external && document.all) window.external.AddFavorite(url, title); else if (window.opera && window.print) alert('Press Ctrl-T to bookmark this page in your favorites.'); else alert(message) } catch (err) { alert(message) } return false }


