$(function() {
    $.preloadCssImages("images/sub_nav_bg.png");

    // If no JS CSS menu will still work
    $("#main_nav").removeClass("cssonly");

    // Find subnav menus and slide them down
    $("#main_nav li a").hover(function(){
    $(this).parent().find(".subnav").slideDown(400);
    $(this).parent().hover(function() {
        $(".sub_active").hide();
        }, function() {
            // On hovering out slide subnav menus back up
            $(this).parent().find(".subnav").slideUp(400);
            $(".sub_active").show();
        })
    });
    $(".sub_active").show();

    $("#flowpanes").scrollable({ circular: true, mousewheel: true }).navigator();
    $(".prod_list_scroll").scrollable({circular: true, mousewheel: true});
    $(".prod_cate_scroll").scrollable({circular: true, mousewheel: true}).autoscroll({autoplay: false});

    $(".prod_cate_noscroll").scrollable({size:3}).mousewheel();

    $("div.scrollable").scrollable();

    $(".gall_items img").click(function() {
        var gall_id = $(this).attr("alt");
        var url = $(this).attr("src").replace("150x150_", "");
        // get handle to element that wraps the image and make it semitransparent
        var wrap = $("#image_wrap"+gall_id).fadeTo("medium", 0.5);
        // the large image from flickr
        var img = new Image();
        // call this function after it's loaded
        img.onload = function() {
            // make wrapper fully visible
            wrap.fadeTo("fast", 1);
            // change the image
            wrap.find("img").attr("src", url);
        };
        // begin loading the image from flickr
        img.src = url;
    // when page loads simulate a "click" on the first image
    }).filter(":first").click();

    var options = {
        zoomWidth: 400,
        zoomHeight: 400,
        zoomType:'reverse'
    }
    $(".prod_zoom_img").jqzoom(options);

    $("img[rel]").overlay();

    // select all desired input fields and attach tooltips to them
    $("#blog_form :input").tooltip({
	// place tooltip on the right edge
	position: "center right",
	// a little tweaking of the position
	offset: [-2, 10],
	// use the built-in fadeIn/fadeOut effect
	effect: "fade",
	// custom opacity setting
	opacity: 0.7,
	// use this single tooltip element
	tip: '.tooltip'
    });

   $("#prodcate").change(function() {
      var id=$(this).val();
      var dataString = 'value='+ id;
      $.ajax ({
         type: "GET",
         url: "xmas_select.php",
         data: dataString,
         cache: false,
         success: function(html) {
            $("#proditem").html(html);
         }
      });
   });

    $("#blog_form, #form").validate();

});
Cufon.replace('.menu_item, h1, h2, #foot_nav');

