var $GLOBALS = {};
window.undefined = window.undefined ? window.undefined : window.undefined;
window.opera = window.opera ? window.opera : undefined;
if(/MSIE/.test(navigator.appVersion) && !(/Macintosh/.test(navigator.appVersion))&&!opera&&!(/Konqueror/.test(navigator.appVersion))){
    if(/MSIE 6/.test(navigator.appVersion))$GLOBALS.IE6=true;
    if(/MSIE 7/.test(navigator.appVersion))$GLOBALS.IE7=true;
    if(/MSIE 8/.test(navigator.appVersion))$GLOBALS.IE7=true;
}
window.oe = function (Fehler,Datei,Zeile)
{
//	alert('Es ist der JS- Fehler: '+Fehler+', in der Datei: '+Datei+', in der Zeile: '+Zeile+'Aufgetreten.');
};
window.o2 = function ()
{
	return true;
};
window.onerror=window.oe;
window.hideLinkFocus = function(Parent)
{
    var a=$T('a', Parent);
    for(var i=0;i<a.length;i++){
        if(document.IE){
            a[i].onmousedown=function(){this.onfocus=function(){this.blur();};};
            a[i].onmouseout=function(){this.onfocus=function(){};};
            a[i].onmouseup=a[i].onmouseout;
        }
        else {
            a[i].onmousedown=function(){return false;};
        }
    }
};
window.getElementsByClassName = document.getElementsByClassName ? function (className, scope) {
        return Array.prototype.slice.call((scope || document).getElementsByClassName(className));
    } : document.evaluate ? function (className, scope) {
        scope = scope || document;
        var re = [], xpathResult, ele,
            scopeDocument    = !scope.ownerDocument ? scope : scope.ownerDocument,
            searchClassNames = getElementsByClassName.quirksCheck(className.trim(), scope).split(" "),
            searchClassName  = searchClassNames[0],
            searchClassNameLength = searchClassNames.length;

        if (scopeDocument.compatMode === "BackCompat") {
            xpathResult = scopeDocument.evaluate(".//*[contains(concat(' ', translate(@class, 'ABCDEFGHIJKLMNOPQRSTUVWYXZ', 'abcdefghijklmnopqrstuvwyxz'), ' '), ' " + searchClassName + " ')]", scope, null, 0, null);
        } else {
            xpathResult = scopeDocument.evaluate(".//*[contains(concat(' ', @class, ' '), ' " + searchClassName + " ')]", scope, null, 0, null);
        }

        if (searchClassNameLength > 1) {
            var eleClassNames, classNameLength, i;
            while ((ele = xpathResult.iterateNext())) {
                classNameLength = 1;
                eleClassNames = getElementsByClassName.quirksCheck(ele.className, scope).split(" ");
                check: for (i = 1; searchClassName = searchClassNames[i]; i++) {
                    if (eleClassNames.indexOf(searchClassName) > -1) {
                        classNameLength++;
                        if (classNameLength === searchClassNameLength) {
                            re.push(ele);
                            break check;
                        }
                    }
                }
            }
        } else {
            while ((ele = xpathResult.iterateNext())) {
                re.push(ele);
            }
        }

        return re;
    } : function (className, scope) {
        scope = scope || document;
        var re = [], ele, eleClassNames, i = 0,
            elements = scope.getElementsByTagName("*"),
            searchClassNames = getElementsByClassName.quirksCheck(className.trim(), scope).split(" "),
            searchClassName  = searchClassNames[0],
            searchClassNameLength = searchClassNames.length;

        if (searchClassNameLength > 1) {
            var classNameLength, j;
            for (; ele = elements[i]; i++) {
                eleClassNames = getElementsByClassName.quirksCheck(ele.className, scope).split(" ");
                classNameLength = 0;
                check: for (j = 0; searchClassName = searchClassNames[j]; j++) {
                    if (eleClassNames.indexOf(searchClassName) > -1) {
                        classNameLength++;
                        if (classNameLength === searchClassNameLength) {
                            re.push(ele);
                            break check;
                        }
                    }
                }
            }
        } else {
            for (; ele = elements[i]; i++) {
                eleClassNames = getElementsByClassName.quirksCheck(ele.className, scope).split(" ");
                if (eleClassNames.indexOf(searchClassName) > -1) {
                    re.push(ele);
                }
            }
        }

        return re;
    };
getElementsByClassName.quirksCheck = function (className, scope) {
    return (!scope.ownerDocument ? scope : scope.ownerDocument).compatMode === "BackCompat" ? className.toLowerCase() : className;
};

if (typeof Array.prototype.indexOf === "undefined") {
    Array.prototype.indexOf = function (val) {
        for (var i = 0, len = this.length, ele; i < len ; i++) {
            ele = this[i];
            if (ele === val) {
                return i;
            }
        }
        return -1;
    };
}
if (typeof String.prototype.trim === "undefined") {
    String.prototype.trim = function () {
        var str = this.replace(/^\s\s*/, ''), ws = /\s/, i = str.length;
        while (ws.test(str.charAt(--i))) {}
        return str.slice(0, i + 1);
    };
}

window.$Obj = function(Obj, Parent)
{
    return (Parent || document).getElementById(Obj);
}
window.$T = function (tag_name, Parent)
{
	return tag_name != '*'  ? $Arr((Parent || document).getElementsByTagName(tag_name)) : (document.IE && (navigator.versionNr < 6) ? $Arr((Parent || document).all) : $Arr((Parent || document).getElementsByTagName('*')));
};
window.$Arr = function(array){
	var nArray = [];
	for (var i=0;i<array.length;i++) nArray.push(array[i]);
	return nArray;
};
window.init = function(){
    hideLinkFocus();
    if($GLOBALS.IE6)$T('body')[0].style.behavior = 'url(../js/hover.htc)';
    hoverInput($Obj('email'));
    hoverInput($Obj('password'));
    hoverTopNavi($Obj('top_navi'));
};
window.hoverInput = function(Obj){
    if(Obj){
        Obj.onfocus = function(){
            this.style.backgroundPosition = '0px -22px';
        }
        Obj.onblur = function(){
           this.style.backgroundPosition = this.value ? '0px -22px' : '0px 0px';
        }
    }
}
window.nodChilds = function(Nod){
    var chNodes = [];
    for(var i=0,l=Nod.childNodes.length;i<l;i++){
       if(Nod.childNodes[i].tagName){
          chNodes[chNodes.length] = Nod.childNodes[i];
       }
    }
    return chNodes;
}
window.hoverTopNavi = function(Navi){
    Childs = nodChilds(Navi)[0];
    Childs = nodChilds(Childs);
    for(var i=0,l=Childs.length;i<l;i++){
        Childs[i].onmouseover = function(){
            if(nodChilds(this).length>1){
                nodChilds(this)[1].style.display = 'block';
            }
        };
        Childs[i].onmouseout = function(){
            if(nodChilds(this).length>1){
                nodChilds(this)[1].style.display = 'none';
            }
        };
    }
}
window.onload = init;
