﻿$(function() {         

    /* hauptnavigation */
    $('#hauptmenu ul li a').filter(':last').addClass("lastchild");
    $('#hauptmenu ul li a').filter(':first').addClass("firstchild"); 
    $( "#hauptmenu ul li a" ).each(
        function( intIndex ){
            if($(this).hasClass("firstchild")) {
                $( this ).css( {backgroundPosition: "0 0"} );
            } else {
                $( this ).css( {backgroundPosition: "100% 0"} );
            }
        
            
            /* active-state vorerst deaktiviert
              if($(this).hasClass("navi-activechild")) {
                if($(this).hasClass("firstchild")) {
                    $(this).stop().animate({backgroundPosition:"(0 -51px)"}, {queue: false, duration:0});
                } else {
                    $(this).stop().animate({backgroundPosition:"(right -51px)"}, {queue: false, duration:0});//only .lastchild
                }
                $(this).parent().stop().animate({backgroundPosition:"(right -51px)"}, {queue: false, duration:0});
        
            } else {
            */
                $( this ).mouseover(function(){
                    if($(this).hasClass("firstchild")) {
                        $(this).stop().animate({backgroundPosition:"(0 -51px)"}, {queue: false, duration:0}); //height of li element
                    } else {
                        $(this).stop().animate({backgroundPosition:"(right -51px)"}, {queue: false, duration:0});//only .lastchild
                    }
                    $(this).parent().stop().animate({backgroundPosition:"(right -51px)"}, {queue: false, duration:0});
                })
                $( this ).mouseout(function(){
                    if($(this).hasClass("firstchild")) {
                        $(this).stop().animate({backgroundPosition:"(0 0)"}, {queue: false, duration:0});
                    } else {
                        $(this).stop().animate({backgroundPosition:"(right 0)"}, {queue: false, duration:0});
                    }
                    $(this).parent().stop().animate({backgroundPosition:"(right 0)"}, {queue: false, duration:0});
                })
        //    } 
              
        }
    );



    /* subnavigation */
    if ( $("#subnavigation").length > 0 ) {
        $('#subnavigation ul li a').filter(':first').addClass("firstchild");
        $('#subnavigation ul li a').filter(':last').addClass("lastchild");
        $( "#subnavigation ul li a" ).each(
            function( intIndex ){
                if($(this).hasClass("firstchild")) {
                    $( this ).css( {backgroundPosition: "0 0"} );
                } else {
                    $( this ).css( {backgroundPosition: "0 bottom"} );
                }
            
                if($(this).hasClass("navi-activechild")) {
                    if($(this).hasClass("firstchild")) {
                        $(this).stop().animate({backgroundPosition:"(100% 0)"}, {queue: false, duration:0});
                    } else {
                        $(this).stop().animate({backgroundPosition:"(right bottom)"}, {queue: false, duration:0});//only .lastchild
                    }
                    $(this).parent().stop().animate({backgroundPosition:"(right bottom)"}, {queue: false, duration:0});
            
                } else {
                
                    $( this ).mouseover(function(){
                        if($(this).hasClass("firstchild")) {
                            $(this).stop().animate({backgroundPosition:"(100% 0)"}, {queue: false, duration:0}); //height of li element
                        } else {
                            $(this).stop().animate({backgroundPosition:"(100% bottom)"}, {queue: false, duration:0});//only .lastchild
                        }
                        $(this).parent().stop().animate({backgroundPosition:"(100% bottom)"}, {queue: false, duration:0});
                    })
                    $( this ).mouseout(function(){
                        if($(this).hasClass("firstchild")) {
                            $(this).stop().animate({backgroundPosition:"(0 0)"}, {queue: false, duration:0});
                        } else {
                            $(this).stop().animate({backgroundPosition:"(0 bottom)"}, {queue: false, duration:0});
                        }
                        $(this).parent().stop().animate({backgroundPosition:"(0 bottom)"}, {queue: false, duration:0});
                    })
                }
                  
            }
        );
    }



    //letztes listenelement bekommt keine border-bottom auf ueberzeugungen
    $("#textcontentfull .article:last").css({'border-bottom' : 'none'});
    //letzter Grund bekommt kein kein bg-image auf gruende
    $("#gruende .ul_zweispaltig ul li:last").css({'background' : 'transparent'});
    
    //Kontakt
    $("#kontakt .container:last").css({'background' : 'transparent'});
    
    
    
    /* textarea kontakt*/
/*    $('textarea').autoResize({
        // On resize:
        onResize : function() {
            $(this).css({opacity:0.8});
        },
        // After resize:
        animateCallback : function() {
            $(this).css({opacity:1});
        },
        animateDuration : 200,
        extraSpace : 0
    });
*/    
    
    /* rounded corners */
    settingsRoundedTop = {
      tl: { radius: 5 },
      tr: { radius: 5 },
      bl: { radius: 0 },
      br: { radius: 0 },
      antiAlias: true,
      autoPad: true,
      validTags: ["div", "h2"]
    }
    
    settingsRounded = {
      tl: { radius: 5 },
      tr: { radius: 5 },
      bl: { radius: 5 },
      br: { radius: 5 },
      antiAlias: true,
      autoPad: true,
      validTags: ["div", "a"]
    }
    $('.rounded').corner(settingsRoundedTop);
    $('table.sitemap td.ebene1 a').corner(settingsRounded);

    /* dropshadows */
    /* DIFF */
    $(window).load(function(){
        $("#content #unterstuetzer h1").dropShadow({left: 0, top: 2, opacity: 0.3, blur: 2, color: "#000"});
        $("#rightcolumn .rightbox h2").dropShadow({left: 0, top: 2, opacity: 0.3, blur: 2, color: "#000"});
        $("#unterstuetzer .container_left h2").dropShadow({left: 0, top: 2, opacity: 0.3, blur: 2, color: "#000"});
        $("img.dropshadow").dropShadow({left: 1, top: 1, opacity: 0.3, blur: 2, color: "#000"});
    });
    
    
});
