
var hideAllBranches = function(){
    jQuery(".branch").hide();
    jQuery(".branch").children().hide();
}

jQuery(document).ready(function(){
    
    // start homepage slideshow
    jQuery(".frp_slideshow").cycle({fx: 'fade',slideExpr: 'img'});
    
    jQuery("#branchNavigation a").hover(
        function(){
            jQuery("#slideshowWrapper").hide();
            jQuery(this).children(".enter_link").fadeIn("slow");  // animate nav button
            var branch = jQuery(this).parent().attr("id").replace("Nav", "");
            hideAllBranches();
            jQuery("#"+branch).show(); // show selected branch
            jQuery("#"+branch).children().fadeIn("slow"); // animate branch items
            jQuery("#closeBranch").show();  // show close button
            
        },
        function(){
            jQuery(this).children(".enter_link").hide();
        }
    );
        
    jQuery("#closeBranch").click(function(){
        hideAllBranches();           //hide all branches
        jQuery(this).hide();                // hide close button
        jQuery("#slideshowWrapper").show();  // show slideshow
    });
    
});
