$(document).ready(function(){
						   
	// TOP NAVIGATION MENU 
	$("#top-menu > li.menu-item, #top-menu > li.menu-item > ul.sub-menu > li.menu-item").hover(
	function(){
		$(this).addClass("hovered");
		$(this).find("> .sub-menu").animate({height: 'toggle'}, 100);
	},
	function(){
		$(this).removeClass("hovered");
		$(this).find(".sub-menu").hide(0);
	});
	
	// DISSOLVED INPUT MENU
	var inputs = $('p.dissolve > input.disinput');
	inputs.val('');
	$(inputs).focus(function() {
		var vals = $(this).val();
		var fors = $(this).attr("id");
		var labels = $("p.dissolve > label.dislabel[for="+fors+"]");
		if (vals == "") {
			$(labels).animate({opacity: 0}, 200);
		}
	});
	$(inputs).blur(function() {
		var vals = $(this).val();
		var fors = $(this).attr('id');
		var labels = $("p.dissolve > label.dislabel[for="+fors+"]");
		if (vals == "") {
			$(labels).animate({opacity: 1}, 200);
		}
	});
	
	// TOP FEATURED TABS
	$("ul#featured-tabs").tabs("div#featured-panes > div.featured-pane", {effect: "fade",rotate: true}).slideshow({autoplay: true,interval: 4000,clickable: false});
	
	// IN PAGE TABS
	$("#browse-tab li, .tabbed-tabs li, #step2form-tabs li, .browse-pane ul li").hover(function(){$(this).addClass("hovered")},function(){$(this).removeClass("hovered")});
	$("ul#browse-tab").tabs("div#browse-panes > div.browse-pane");
	$("ul.tabbed-tabs").tabs("div.tabbed-panes > div.tabbed-pane");
	$("ul#step2form-tabs").tabs("div#step2form-panes > div.step2form-pane");
	
	// STICKY FOOTER
	var footHeight = $("#footer").height();
	var mainPadding = footHeight + 20 +"px";
	var footMargin = footHeight+"px";
	$("#main").css("padding-bottom", mainPadding);
	$("#footer").css("margin-top", "-"+footMargin);
	
	// EQUAL HEIGHTS
	function equalHeight(group) {
		var tallest = 0;
		group.each(function() {
			var thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}	
	equalHeight($(".product-small-desc"));
	equalHeight($(".tabbed-pane"));	
	equalHeight($(".post-status > div"));
	equalHeight($(".log-forms form"));
	
	// SCROLLABLES
	$("li.product-small").hover(function(){$(this).addClass("hovered")},function(){$(this).removeClass("hovered")});
	$(".scrolling .scrolling-wrap, #detail-thumb-wrap").each(function(){       
        var rowDiv = document.createElement("div");
        $(rowDiv).addClass("scrolling-row");
        for(i=0; i< $(this).find("> .scroll").length ; i+= 5)
        {       
                $(rowDiv).append( $(this).find("> .scroll").slice(i, i+5).clone() );           
                $(this).append(rowDiv);
                rowDiv = document.createElement("div");
                $(rowDiv).addClass("scrolling-row");
        }
        $(this).find("> .scroll").remove(); 
	});
	$(".scrolling").scrollable({speed: 1000,easing: 'linear',circular:true});
     
	$("#detail-thumb-center").scrollable({speed: 400,easing: 'linear'});
	
	// PRODUCT GALLERY
	$("#detail-thumb-wrap").tabs("#main-image > .main-image");
	$(".main-image").append('<div class="zooming">zoom</div>');
	$(".zooming").hide();
	$(".main-image").hover(function(){
		$(this).find(".zooming").fadeIn();
	},function(){
		$(this).find(".zooming").fadeOut();
	});
	
	// FANCYBOX
        if ($(".main-image > a").length){
            $(".main-image > a").fancybox({'titlePosition' : 'over'});
        }
	if ($("#atc_finish, #atw_finish").length){
            $("#atc_finish, #atw_finish").fancybox({'autoScale':false,'padding':0,'titleShow' : false});
	}
        $(".fancyclose").click(function(){$.fancybox.close();return false;});
	
	// COMMENTS
	$(".comment .children li:last-child").addClass("last");
	//$("#commentform p").addClass("clearfix");
	
});

