/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function aegOnErr(Fehler,Datei,Zeile){
    alert('Es ist der JS- Fehler: '+Fehler+', in der Datei: '+Datei+', in der Zeile: '+Zeile+' Aufgetreten.');
}

function aegNoErr(){
    return true;
}

//window.onerror = aegOnErr; //Debugging: Strictly on = aegOnErr || Strictly off = aegNoErr || off = komment this Line out

$_GLOBALS = {};
$_GLOBALS.wait = false;
$_GLOBALS.mySelect = {};
$_GLOBALS.mySelect2 = {};
$_GLOBALS.tmr = null;
$_GLOBALS.tmr2 = null;

function ieSelectFix(id,nr){
   nr = !nr ? '' : nr;
   if($_GLOBALS['mySelect' + nr] = document.getElementById(id)){
        $_GLOBALS['mySelect' + nr].options[0].text = 'Bitte Wählen';
        if(navigator.appVersion.indexOf('MSIE')>-1){
            $_GLOBALS['mySelect' + nr].parentNode.style.position = 'absolute';
            $_GLOBALS['mySelect' + nr].parentNode.style.marginTop = '15px';
            $_GLOBALS['mySelect' + nr].onchange = function(){
                this.style.width='98px';
            }
            $_GLOBALS['mySelect' + nr].onmousedown = function(){
                clearTimeout($_GLOBALS['tmr' + nr]);
                if(this.style.width!='auto'){
                    this.style.width='auto';
                }
                else{
                    $_GLOBALS['mySelect' + nr] = this;
                    $_GLOBALS['tmr' + nr] = setTimeout(function(){
                        $_GLOBALS['mySelect' + nr].blur();
                        $_GLOBALS['mySelect' + nr].focus();
                    },
                    200);
                }
            }
            $_GLOBALS['mySelect' + nr].onblur = $_GLOBALS['mySelect' + nr].onchange;
        }
    }
}

function showProgressBar(){
    $('progress-bg').style.zIndex = '999999';
    $('progress-bg').style.display = 'block';
    $('progress-loader').style.zIndex = '9999999';
    $('progress-loader').style.display = 'block';
    window.scrollTo(0,0);
    $$('body')[0].style.height='100%';
    $$('body')[0].style.overflow = 'hidden';
}

function waitonclick(){
    $$('.waitonclick').each(function(a){
        a.onclick = function(){
            showProgressBar();
        }
    });
    $$('.waitonclick-submit').each(function(b){
        b.onclick = function(){
            showProgressBar();
            this.form.submit();
        }
    });
}

function ps_init(){
    ieSelectFix('titel');
    ieSelectFix('prefix');
    ieSelectFix('billing:prefix');
    ieSelectFix('shipping:prefix', 2);
    waitonclick();
}

function ps_after_init(){
}

Event.observe(document,'dom:loaded', ps_init);
Event.observe(window,'load', ps_after_init);
