
$(document).ready(function(){
       
    //$("body").addClass(tz);

    
    /* Hintergrundbild an Fenstergr��e anpassen und horizontal zentrieren */

    var imgElm = ".backgroundImg";
    var ctnElm = "#wechsler .inside";
    var iW = 1500;
    var iH = 1000;
    var iR = iW / iH;
    
    /*
    if ($(".anim_container .repos").length > 0){
        reposL = parseInt($(".anim_container .repos").css('left').replace(/px/,""));
        reposT = parseInt($(".anim_container .repos").css('top').replace(/px/,""));
        resizW = parseInt($(".anim_container .repos").find("img").attr('width'));
        resizH = parseInt($(".anim_container .repos").find("img").attr('height'));
    }
    */
    imgResize();
    $(window).resize(function(){imgResize();});
    
    
    
    function imgResize(){
        
        bH = $(window).height();
         
        // Scrollbar im Fenster gegebenenfalls entfernen 
        /*
        if(($("#container").height() + 80 + 50) < bH ){
            $("body").css({"overflow" : "hidden"});
        
        } else {
            $("body").css({"overflow" : "auto"});
        }
        */
        
        bW = $(window).width();
        
        bR = bW / bH;

        $(ctnElm).attr({style: "width: " + bW + "px; height:" + bH + "px"});
        
        if(bR < iR) $(imgElm).attr({width: bH*iR, height: bH, style: "left: -"+((bH*iR)-bW)/2+"px"});
        else  $(imgElm).attr({width: bW, height: bW/iR, style: "left: 0px"});
        /*
        iSize = $(imgElm).width() / iW;
        
        /// Fixe Elemente Repositionieren
        if($(".anim_container .repos").length > 0){
        $(".anim_container .repos").css({
            'left' : reposL * iSize + "px",
            'top' : reposT * iSize + "px"
        });
        
        /// Fixe Elemente Resizen
        
        $(".anim_container .repos img").attr({
            width : resizW * iSize,
            height : resizH * iSize
        });
        }
         */
    }

    
    
    
    
    $.tools.dateinput.localize("de",  {
       months:        'Januar,Februar,M&auml;rz,April,Mai,Juni,Juli,August,' +
                       	'September,Oktober,November,Dezember',
       shortMonths:   'jan,f&eacute;v,mar,avr,mai,jun,jul,ao&ucirc;,sep,oct,nov,d&eacute;c',
       days:          'Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag',
       shortDays:     'mo,di,mi,do,fr,sa,so'
    });
    
    
    
    //var name = $("#ctrl_4").attr('name');
    //var ivalue = $("#ctrl_4").attr('value');
    //var iclass = $("#ctrl_4").attr('class') + " date";

    //var html = '<input type="date" name="'+name+'" value="'+ivalue+'" class="'+iclass+'"  />';

    //$("#ctrl_4").after(html).remove(); 

    
    // jQuery Tools

/*
    $("#ctrl_4").dateinput({
        
        selectors: true,
        lang: 'de',
        firstDay: 1,
        speed: 'fast',
        disabled: true,
        format: 'dd.mm.yyyy',
        value: -365*20, 
        min: -365*50, 
        max: -365*18,
        offset:[0,0]
        
    });
    */
    /* ischiller  �ffnen */
    
    $(".opener").overlay({
        mask: {
    		loadSpeed: 200,
    		opacity: 1
       },
       fixed: false,
       left: 0

    });
    
    $(".slidetabs").tabs("#overlay .tab_images > .image_container", {
            effect: 'fade',
            rotate: true,
            fadeOutSpeed: 300
    }).slideshow({
            interval: 15000
    });

    //$(".opener").mouseup(function(){$(".slidetabs").data("slideshow").play()});
    
    
    
    //http://flowplayer.org/tools/download/combine/1.2.5/jquery.tools.min.js?download=true&t=jquery&t=tabs&t=tabs.slideshow&t=tooltip&t=overlay&t=dateinput
    
    $(".slidetabs a[title]").tooltip({
        offset: [0,0]
    });
    
    /*
    var anim = new Array();
    
    anim[0] = new Object();
    anim[0]['class'] =      ".playschiller";
    anim[0]['startTop'] =   10;
    anim[0]['width'] =      236;
    anim[0]['height'] =     64;
    anim[0]['endTop'] =     30;
    anim[0]['duration'] =   10000;
    anim[0]['delay'] =      15000;
    anim[0]['direction'] =  "toleft";

    window.setTimeout(function callFunc(){move(anim[0]);}, 1000);
    bat = window.setInterval(function callFunc(){move(anim[0]);}, anim[0]['delay']);


    anim[1] = new Object();
    anim[1]['class'] =      ".logo_mittag";
    anim[1]['startTop'] =   80;
    anim[1]['width'] =      488;
    anim[1]['height'] =     156;
    anim[1]['endTop'] =     30;
    anim[1]['duration'] =   8000;
    anim[1]['delay'] =      15000;
    anim[1]['direction'] =  "toright";

    window.setTimeout(function callFunc(){move(anim[1]);}, 1000);
    werbeflieger = window.setInterval(function callFunc(){move(anim[1]);}, anim[1]['delay']);
    
    
    anim[2] = new Object();
    anim[2]['class'] =      ".logo_morgen";
    anim[2]['startTop'] =   90;
    anim[2]['width'] =      255;
    anim[2]['height'] =     288;
    anim[2]['endTop'] =     10;
    anim[2]['duration'] =   40000;
    anim[2]['delay'] =      55000;
    anim[2]['direction'] =  "toright";

    move(anim[2]);
    werbeflieger = window.setInterval(function callFunc(){move(anim[2]);}, anim[2]['delay']);
 
 
    anim[3] = new Object();
    anim[3]['class'] =      ".fledermaeuse";
    anim[3]['startTop'] =   500;
    anim[3]['width'] =      87;
    anim[3]['height'] =     68;
    anim[3]['endTop'] =     -30;
    anim[3]['duration'] =   2000;
    anim[3]['delay'] =      8000;
    anim[3]['direction'] =  "toright";


    window.setTimeout(function callFunc(){move(anim[3]);}, 1000);
    fledermaeuse = window.setInterval(function callFunc(){move(anim[3]);}, anim[3]['delay']);
 

    anim[4] = new Object();
    anim[4]['class'] =      ".moewe";
    anim[4]['startTop'] =   400;
    anim[4]['width'] =      87;
    anim[4]['height'] =     68;
    anim[4]['endTop'] =     60;
    anim[4]['duration'] =   4000;
    anim[4]['delay'] =      8000;
    anim[4]['direction'] =  "toright";


    window.setTimeout(function callFunc(){move(anim[4]);}, 1000);
    fledermaeuse = window.setInterval(function callFunc(){move(anim[4]);}, anim[4]['delay']);
 

    function move(elm){
        
        duration = elm['duration'] * iSize;
        $(elm['class']).show();
        
        
        // Resize
        $(elm['class'] + " img").width(elm['width'] * iSize + "px");
        $(elm['class'] + " img").height(elm['height'] * iSize + "px");
            
          

        if(elm['repos']){
            elm['startTop'] = elm['startTop'] * iSize;
            elm['endTop'] = elm['endTop'] * iSize;
        }
        if(elm['direction'] == "toleft"){
            
            $(elm['class']).css({
                'right' : -elm['width'],
                'top' : elm['startTop'] * iSize + "px"
            });
            
            $(elm['class']).animate({
                right: bW+"px",
                top: elm['endTop'] * iSize + "px"
            }, duration, "linear", function(){$(this).hide()});
        }
        
        if(elm['direction'] == "toright"){
            
            $(elm['class']).css({
                'left' : -elm['width'],
                'top' : elm['startTop'] * iSize + "px"
            });
            
            $(elm['class']).animate({
                left: bW+"px",
                top: elm['endTop'] * iSize + "px"
            }, duration, "linear", function(){$(this).hide()});
        }  
    }
    
    */
    
    
});
