﻿

        function hideFilterHover() {
                $("#filterHover").addClass("displayNone");
            }
         

        $().ready(function() {
            
                       
        
             $("#filterContainer").hover(
                function () {
                    $("#filterHover").removeClass("displayNone");
                    $("#filterContainer").addClass("inactive");
                  }, 
                  function () {
                    $("#filterHover").addClass("displayNone");
                    $("#filterHover .show").removeClass("show");
                    $("#filterContainer .active").removeClass("active");
                    $("#filterContainer").removeClass("inactive");
                  });
                  
                  
            $(".filterProduct").hover( 
                function () {
                    $("#filterHover .show").removeClass("show");
                    $("#filterContainer .active").removeClass("active");
                    $("#filterHover .product").addClass("show");
                    $(".filterProduct").addClass("active");
                  });
                  
            $(".filterFlavor").hover( 
                function () {
                    $("#filterHover .show").removeClass("show");
                    $("#filterContainer .active").removeClass("active");
                    $("#filterHover .flavor").addClass("show");
                    $(".filterFlavor").addClass("active");
                  });
                  
            $(".filterLifeStage").hover( 
                function () {
                    $("#filterHover .show").removeClass("show");
                    $("#filterContainer .active").removeClass("active");
                    $("#filterHover .lifeStage").addClass("show");
                    $(".filterLifeStage").addClass("active");
                  });
            
            $('#imageNav div').hover(
                function() {
                    if ($(this).is('.thisPage')) { 
                        //do nothing }
                    } else {
                        $(this).children('.text').css('display','block');
                    }                    
                }, function() {
                    if ($(this).is('.thisPage')) { 
                        //do nothing }
                    } else {
                        $(this).children('.text').css('display','none');
                    }
             });
             
             $('.thisPage a').click(function() { return false; });
             
             $(function() {
                $("#nutritionPopPanel").dialog({
                    autoOpen: false,
                    height: 320,
                    width: 500,
                    position: ['center','center'],
                    closeText: 'x',
                    modal: true,
                    open: function() { 
                        $(this).parent().prependTo('#nutritionPop_ui-dialog');
                    }
                });                
             
            });
            
            $('#originalPateNav').hover(
                function() {
                    $('#PateRollover .cuisineRollover').fadeIn();
                }, function() {
                    $('#PateRollover .cuisineRollover').fadeOut(0);
            });
            
            $('#cesarBistroNav').hover(
                function() {
                    $('#BistroRollover .cuisineRollover').fadeIn();
                }, function() {
                    $('#BistroRollover .cuisineRollover').fadeOut(0);
            });
            
            $('#gfisNav').hover(
                function() {
                    $('#GFISRollover .cuisineRollover').fadeIn();
                }, function() {
                    $('#GFISRollover .cuisineRollover').fadeOut(0);
            });
            
            $('#cesarTreatsNav').hover(
                function() {
                    $('#TreatsRollover .cuisineRollover').fadeIn();
                }, function() {
                    $('#TreatsRollover .cuisineRollover').fadeOut(0);
            });
            
            $('#sunriseBreakfastNav').hover(
                function() {
                    $('#SunriseRollover .cuisineRollover').fadeIn();
                }, function() {
                    $('#SunriseRollover .cuisineRollover').fadeOut(0);
            });
            
         });
         
         
         
         function popUpNutrition () {
            
            var content = $("#nutrition-info").html();
            $('#nutritionPop #topContent .selected').toggleClass('selected');
            
            if(!$('#nutritionPopPanel').dialog('isOpen')){
                centerPopup('.ui-dialog');
                $("#nutritionPopPanel").dialog('open');
                $("#nutritionPopPanel").bind('clickoutside',function(){
                    $("#nutritionPopPanel").dialog('close');
                });
            }
            
            $('#nutritionPop #topContent div.nutrition').toggleClass('selected');
            
            $(".ui-dialog").css("border-color",$("a.stbar.chicklet").css("color"));
            $("#nutritionPop #popUpFooter a").css("color",$("a.stbar.chicklet").css("color"));
            $("#feeding-guide-container span.value").css("color",$("a.stbar.chicklet").css("color"));
            $("#nutritionPop #topContent a").css("color","#838383");
            $("#nutritionPop #topContent .selected a").css("color",$("a.stbar.chicklet").css("color"));
            $(".ui-dialog-titlebar a").css("color",$("a.stbar.chicklet").css("color"));
            
            $("#popUpContent").html(content);            
            
        } 
        
        function popUpIngredients () {
            
            var content = $("#ingredients").html();
            $('#nutritionPop #topContent .selected').toggleClass('selected');
            
            if(!$('#nutritionPopPanel').dialog('isOpen')){ 
                centerPopup('.ui-dialog');               
                $("#nutritionPopPanel").dialog('open');
                $("#nutritionPopPanel").bind('clickoutside',function(){
                    $("#nutritionPopPanel").dialog('close');
                });
            }
            
            $('#nutritionPop #topContent div.ingredients').toggleClass('selected');
            
            $(".ui-dialog").css("border-color",$("a.stbar.chicklet").css("color"));
            $("#nutritionPop #popUpFooter a").css("color",$("a.stbar.chicklet").css("color"));
            $("#feeding-guide-container span.value").css("color",$("a.stbar.chicklet").css("color"));
            $("#nutritionPop #topContent a").css("color","#838383");
            $("#nutritionPop #topContent .selected a").css("color",$("a.stbar.chicklet").css("color"));
            
            $("#popUpContent").html(content);            
            
        }
        
        function popUpFeedingGuide () {
            
            var content = $("#feeding-guide").html();
            $('#nutritionPop #topContent .selected').toggleClass('selected');
            
            
            if(!$('#nutritionPopPanel').dialog('isOpen')){ 
                centerPopup('.ui-dialog');            
                $("#nutritionPopPanel").dialog('open');
                $("#nutritionPopPanel").bind('clickoutside',function(){
                    $("#nutritionPopPanel").dialog('close');
                });
            }
            
            $('#nutritionPop #topContent div.feeding').toggleClass('selected');
            
            $(".ui-dialog").css("border-color",$("a.stbar.chicklet").css("color"));
            $("#nutritionPop #popUpFooter a").css("color",$("a.stbar.chicklet").css("color"));
            $("#feeding-guide-container span.value").css("color",$("a.stbar.chicklet").css("color"));
            $("#nutritionPop #topContent a").css("color","#838383");
            $("#nutritionPop #topContent .selected a").css("color",$("a.stbar.chicklet").css("color"));

            
            $("#popUpContent").html(content);            
            
        }
        
        function printNutritionPopup () {
            
            // Creates a popup window and populates it with the correct nutrition info 
            // and automagically brings up the print dialog.  Once the window is either 
            // printed or printing is cancelled, the window closes automatically.
            
            var content = '<html><head><link rel="Stylesheet" type="text/css" href="/cuisine-and-treats/bistro/css/print-out.css" />\r\n';
            
            var title = $('img.subHeading').attr('alt');
            
            content = content + '<title>' + title + '</title></head><body>';            
            content = content + '<h1>'+ title + ' nutrition & feeding info</h1>';
            content = content + '<div style="width:460px;">';
            content = content + '<h2>nutrition info</h2>';
            content = content + $("#nutrition-info").html();
            content = content + '<h2>ingredients</h2>';
            content = content + $("#ingredients").html();
            content = content + '<h2>feeding guide</h2>';
            content = content + $("#feeding-guide").html();
            content = content + '</div>';
            content = content + "<script type=\"text/javascript\">setTimeout(\"window.print()\",500)<\/script>";
            content = content + "<script type=\"text/javascript\">setTimeout(\"window.close()\",500)<\/script>";
            content = content + '</body></html>';
            
            var nutritionWindow = window.open("","nutrition","width=520,height=600,scrollbars=no");
            
            nutritionWindow.document.writeln(content);
            
            nutritionWindow.document.close();
        }
