/* Author: 

*/

var addthis_config = {
    services_compact : "facebook,twitter,linkedin,blogger,email,print,more"
}

$(document).ready(function() {
    $(".third-width").each(function() {
        $(this).load(function() {
            $(this).parent().find(".design-image-rotate").height($(this).height());
        });
    });

    $("#main").slides({
        container: "home-images",
        crossfade: true,
        effect: "fade",
        generatePagination: false,
        play: 3000,
        preload: true,
        preloadImage: "/themes/broadbase/img/loading.gif"
    });

    $("html").not(".ie6").find(".row").each(function() {
        $(this).slides({
            container: "design-image-rotate",
            crossfade: true,
            effect: "fade",
            generatePagination: false,
            play: 3000,
            preload: false,
            preloadImage: "/themes/broadbase/img/loading.gif"
        });
    });

    /* Some IE6 stuff */
    $(".design-image-rotate").each(function() {
        $(this).find("img").hide();
        $(this).find("img:first").show();
    });

    $("#introduction-text").delay(3000).fadeIn(350).delay(5650).fadeOut(350);
    
    var title;

    $("nav").not("#menu-top-subpage").hover(
        function() {
            $("#menu").show();
            title = $("#menu-top span").html();
            $("#menu-top span").html("menu");
        },
        function() {
            $("#menu").hide();
            $("#menu-top span").html(title);
        }
    );

    $("#menu-top").hover(
        function() {
            $(".children").hide();
            $("#menu-top-subpage").show();
        }
    );

    $("#menu>li").each(function() {
        $(this).hover(function() {
            $(this).addClass("hover");
        },
        function() {
            $(this).removeClass("hover");
        });
    });

    $("#menu>li .children>li").not(".menu-divider").each(function() {
        $(this).hover(function() {
            $(this).addClass("hover");
        },
        function() {
            $(this).removeClass("hover");
        });
    });

    $("#menu-item-4").hover(
        function() {
            $(this).children(".children").show();
            $("#menu-top-subpage").hide(1, function() {
            });
        },
        function() {
            $(this).children(".children").show();
        }
    );

    $("#menu>li").not("#menu-item-4").hover(
        function() {
            $("#menu-item-4 .children").hide();
            $("#menu-top-subpage").show();
        }
    );

    $("#menu-item-16").hover(
        function() {
            $(this).children(".children").show();
            $("#menu-top-subpage").hide();
        },
        function() {
            $(this).children(".children").show();
        }
    );

    $("#menu>li").not("#menu-item-16").hover(
        function() {
            $("#menu-item-16 .children").hide();
            $("#menu-top-subpage").show();
        }
    );

    /* Append "read more" better */

    $(".post-content").each(function() {
        $readmore = $(this).find(".read-more");

        if($readmore.length) {
            $(this).children("p:last").append(" " + $readmore.html());
            $readmore.remove();
        }
    });

});





















