var preview = false;
var previewWW = false;

//jQuery Funktion: Warten bis DOM bereit ist
$(document).ready(function(){

    //window.location.hash = window.location.hash;
    if ($.browser.msie) {
        if (!badBrowser) {
            window.location.hash = window.location.hash;
        }
    }
    
    $("body").removeClass("nos");
    
    
    //////////////////////////////////LOADER//////////////////////////////////
	
    $('#progressBar').animate({
        width: '143px'
    }, {
        duration: 10000,
        easing: 'easeInOutQuad'
    });
    
    //////////////////////////Timestamp um Caching zu verhindern//////////////////////////
    
    $.wwGetTimestamp = function(){
        var timestamp = new Date();
        return timestamp.getTime();
    };
    
    
    //////////////////////////Nachladen der Scripte//////////////////////////
    
    $.wwLoadExtScript = function(){
    
        var stopLoading = false;
        $(window).unload(function(){
            stopLoading = true;
        });
        
        if (!stopLoading) {
            if (preview) {
                $.getScript("lib/werbewelt/random.js?cache=" + $.wwGetTimestamp(), function(){
                });
            }
            
            var targetScript = 'script-min';
            if (preview) {
                targetScript = 'script';
            }
            
            $.getScript("lib/werbewelt/" + targetScript + ".js?cache=" + $.wwGetTimestamp(), function(){
            
                $('#progressBar').stop().animate({
                    width: '153px'
                }, {
                    duration: 300,
                    easing: 'easeInOutQuad',
                    complete: function(){
                        $.wwInit();
                    }
                });
                
            });
        }
    };
    
    
    //////////////////////////Texte für HTTPS Loader//////////////////////////
    
    var tempHref = window.location.hash;
    var tempHash = window.location.hash;
    
    if (tempHref.indexOf("#") !== -1) {
        var pos = tempHref.indexOf("#") + 4;
        tempHash = tempHref.substring(pos);
    }
    
    if (tempHash === "WkbCheckoutLogin" || tempHash === "WkbCheckoutPasswort" || tempHash === "WkbCheckoutKundendaten" || tempHash === "WkbCheckoutVersenden" || tempHash === "WkbCheckoutBezahlen" || tempHash === "WkbCheckoutBestaetigung" || tempHash === "Footer" || tempHash === "FooMeinKonto" || tempHash === "FooMeinKontoLogin" || tempHash === "FooMeinKontoPasswort" || tempHash === "FooMeinKontoStart" || tempHash === "FooMeinKontoDaten" || tempHash === "FooMeinKontoFavorit" || tempHash === "FooMeinKontoBestell") {
    
        $("#progressText").html("Einen Moment bitte. <br />Eine sichere und verschl&uuml;sselte Verbindung wird hergestellt.");
        $.wwLoadExtScript();
    }
    else {
        $("#progressText").html('Der louis sayn Online Shop <br />wird geladen.');
        $.wwLoadExtScript();
    }
});
