﻿$(document).ready(function(){
    $(document).pngFix(); 
    //main nav
    jQuery.preloadImages = function()
    {
      for(var i = 0; i<arguments.length; i++)
      {
        jQuery("<img>").attr("src", arguments[i]);
      }
    }
    $.preloadImages('images/nav_text_contact.png', 'images/nav_text_press.png', 'images/nav_text_menu.png',
        'images/nav_text_locations.png', 'images/nav_text_franchising.png', 'images/nav_text_ssp.png',
        'images/nav_text_drivein.png', 'images/nav_horiz_contact_on.png', 'images/nav_horiz_franchising_on.png',
        'images/nav_horiz_home_on.png', 'images/nav_horiz_locations_on.png', 'images/nav_horiz_menu_on.png',
        'images/nav_horiz_press_on.png', 'images/nav_horiz_ssp_on.png', 'images/ostrich_menu_easteregg.png');

    jQuery.bindNavLink = function(navEl, imgUrl, linkUrl)
    {
        navEl.bind("mouseover",function(){
            $(".mirror").css("background","url("+imgUrl+")");
        });
        navEl.bind("mouseout",function(){
            $(".mirror").css("background","none");
        });
        navEl.bind("click",function(){
            window.location=linkUrl;
        });
    }
    $.bindNavLink($('.nav_horn'),'images/nav_text_contact.png','contactus.aspx');
    $.bindNavLink($('.drivein'),'images/nav_text_drivein.png','default.aspx');
    $.bindNavLink($('.locations'),'images/nav_text_locations.png','locations.aspx');
    $.bindNavLink($('.nav_radio'),'images/nav_text_menu.png','menu.aspx');
    $.bindNavLink($('.franchising'),'images/nav_text_franchising.png','franchising.aspx');
    $.bindNavLink($('.press'),'images/nav_text_press.png','pressreleases.aspx');
    $.bindNavLink($('.ssp'),'images/nav_text_ssp.png','http://www.simplesimonspizza.com');
    $.bindNavLink($('.logo'),'','default.aspx');

    if(!$.browser.msie){
        //known bug in jquery (http://dev.jquery.com/ticket/3145) fade causes trans pngs in IE to show an ugly black background. other browsers are fine.
        $(".pulse").effect("pulsate", { times: 1000 }, 4000);
    }
    //end main nav
});

$(document).ready(function(){
    //menu page
    $(".menuItems a.tooltip").tooltip({ 
        bodyHandler: function() { 
            return $($(this).attr("rel")).html(); 
        },
        track: true, 
        delay: 0, 
        showURL: false, 
        opacity: 1, 
        fixPNG: true, 
        extraClass: "htmltooltipShow", 
        top: -150, 
        left: 10 
    });

    if($('.menuItem').length > 0){
        $(".menuItem").ahover({moveSpeed: 100, hoverEffect: function() {
            $(this)
                .css({opacity: 0.99})
                .animate({opacity: 0.5}, 750)
                .animate({opacity: 0.99}, 750)
                .dequeue();
            $(this).queue(arguments.callee);
        }});
    }
    //end menu page
//    if($('.locationListContainer').length > 0){
//         $(".locationListContainer").lavaLamp({
//	        // fx: "easeOutCirc",
//	         speed: 1000
//         });
//	        $(".locationListItem").ahover({moveSpeed: 100, hoverEffect: function() {
//	            $(this)
//	                .css({opacity: 0.99})
//	                .animate({opacity: 0.5}, 750)
//	                .animate({opacity: 0.99}, 750)
//	                .dequeue();
//	            $(this).queue(arguments.callee);
//	        }});
//     }
    
    if($('#mycarousel').length > 0){
        jQuery('#mycarousel').jcarousel({
            visible:1,
            scroll:1
        });
    }
    // $('.franchiseeContents img').each(function(){
        // this.src = this.src.replace("/franchisee","");
    // });

});
