$(document).ready(function(){
            $("a.group").fancybox({'hideOnContentClick': false });                              //start Fancybox for product image preview
            
//function calls for product page menu            
            $('.menu_overview').click(function()                                                
            {
                $('.features, .soundclips, .videoclips, .manual, .warranty').hide();
                $('.overview').show();
              });
            $('.menu_features').click(function()
            {
                $('.overview, .soundclips, .videoclips, .manual, .warranty').hide();
                $('.features').show();
              });
            $('.menu_soundclips').click(function()
            {
                $('.overview, .features, .videoclips, .manual, .warranty').hide();
                $('.soundclips').show();
              });
            $('.menu_videoclips').click(function()
            {
                $('.overview, .features, .soundclips, .manual, .warranty').hide();
                $('.videoclips').show();
              });
            $('.menu_manual').click(function()
            {
                $('.overview, .features, .soundclips, .videoclips, .warranty').hide();
                $('.manual').show();
              });
            $('.menu_warranty').click(function()
            {
                $('.overview, .features, .soundclips, .manual, .videoclips').hide();
                $('.warranty').show();
              });
            
//Functions for Footer

			$(".carousel li").hover(function() {
                        $(this).find("a").prev("table").animate({opacity: "show"}, "fast");
                        }, function() {
                        $(this).find("a").prev("table").animate({opacity: "hide"}, "fast");
            });



//Functions for dealer pages            
            $(".usacanada").click(function()
            {
                $('#usacanada').toggle();
              });
            $(".europe").click(function()
            {
                $('#europe, #europe_left, #europe_right').toggle();
              });
            $(".others").click(function()
            {
                $('#others, #others_left, #others_right').toggle();
              });
            $("a.close").click(function()
            {
                $('#usa_left, #usa_right, #europe_left, #europe_right, #others_left, #others_right, #canada_left, #canada_right').hide();
              });
            $(".subtitle_canada").click(function()
            {
                $('#usa_left, #usa_right').hide();
                $('#canada_left, #canada_right').toggle();
              });
            $(".subtitle_usa").click(function()
            {
                $('#canada_left, #canada_right').hide();
                $('#usa_left, #usa_right').toggle();
              });

            $(".triggerbutton").click(function () {
                $("input.hide").trigger('click');
            });

//Carousel Footer//
function scrollcarousel (direction){
            var marginleftstring = $(".carousel ul").css("margin-left");
            var marginleft = parseInt(marginleftstring,10);
            var lastitem = $(".carousel ul li:last").position();                  
            var firstitem = $(".carousel ul li:first").position();
            var itemwidth = lastitem.left+5 - firstitem.left;                       /*add 5px because we add a margin-left of -5px*/
            if(direction == "left"){
                        if(marginleft <= -5, marginleft != -itemwidth){marginleft -= 104;}
                        else{marginleft = -itemwidth;}
            }
            else{
                        if(marginleft < -5){marginleft += 104;}
                        else if(marginleft == -5){marginleft = -5;}
                        else{marginleft = -5;}
            }
            
                $("div.carousel ul").css("margin-left", marginleft+"px");
            
}
            $(".arrowright").click(function(){
                        scrollcarousel("left");
            });
            
            $(".arrowleft").click(function(){
                        scrollcarousel("right");
            });

        });