jQuery(function ($) {
	// $.ajaxSetup forces the browser NOT to cache AJAX calls.
	$.ajaxSetup ({  
		cache: false  
	});
	
/* jQuery Tools - Overlay */
	$("#header a[rel], #footnotes a[rel], #singleMainContent .shipping_info a, #singleMainContent .add_to_wishlist_inactive a, #floatswrap .order_table a[rel], #singleMainContent .supplinfo a").each(function(i) {
			
		$(this).overlay({
			effect: 'apple'
		});			
	});
	
	// load external content
	$("#singleMainContent .suppl_InfoLoad a").overlay({
		effect: 'apple',
		
		onBeforeLoad: function() { 
			
			// let the user know that something is about to load 
			var ajax_load = "<img class='loadingImg' src='http://"+ document.URL.split("/")[2] + "/wp-content/themes/TheFurnitureStore/images/ajax-loader.gif' alt='loading...' />";
            // grab wrapper element inside content 
            var wrap = this.getContent().find("div.supplInfoWrap"); 
			// get the page specified in the trigger and a specific element from inside it 
			//var toLoad = $(this.getTrigger()).attr('href')+' .page_post';
			var toLoad = $(this.getTrigger()).attr('href')+' .container .whereAmI + div';
            // load it! 
			wrap.html(ajax_load).load(toLoad); 
        }
	});	
	
/* Category - Image Hover */
	$('#floatswrap .theCats .contentWrap').hover(function(){
		var $go = $(this).find('.teaser');
		$go.stop().animate({'opacity':'0.8'},{queue:false,duration:500});
	}, function(){
		var $go = $(this).find('.teaser');
		$go.stop().animate({'opacity':'0'},{queue:false,duration:500});
	});

/* Multiple Product Pages - Image Hover */
	$('#floatswrap .contentWrap').hover(function(){
		var $go = $(this).find('.hover_link');
		$go.stop().animate({opacity:'0'},{queue:false,duration:500});
	}, function(){
		var $go = $(this).find('.hover_link');
		$go.stop().animate({opacity:'1'},{queue:false,duration:500});
	});

/* Single Product Page - jQuery Tools - Tabs*/
	$("#singleMainContent .related .tabs").tabs("div.panes > div", { event:'mouseover' });
	
	$("#singleMainContent .thumbTabs").tabs("div.mediaPanes > .theProdMedia", { event:'mouseover' });
	$("#singleMainContent .innerProdMedia .inner_thumbTabs").tabs("div.inner_mediaPanes > .theInner_ProdMedia", { event:'mouseover' });
	
/*return false when no effect is used!*/
	$("#singleMainContent .no_effect").click(function(){
		return false;
	});

/* jQuery Tools - ToolTip */
	$("#header li.wishlist a[title], #trackingform img[title], .wishList_table a[title]").tooltip({ 
 
        // use div.tooltip as our tooltip 
        tip: '.tooltip', 
 
        // use fade effect instead of the default 
        effect: 'fade', 
 
        // make fadeOutSpeed similar to browser's default 
        fadeOutSpeed: 2000, 
 
        // the time before tooltip is shown 
        predelay: 100, 
 
        // tweak the position 
        position: "bottom center"         
         
    });
	
/* Single Product Page - Adjacent Products */
	$('.adjacentProd').hover(function(){
		var $showME = $(this).find('.adjacentImg');
		$showME.stop(false,true).fadeIn("slow");
	}, function(){
		var $showME = $(this).find('.adjacentImg');
		$showME.stop(false,true).fadeOut("slow");
	});
	
/* wp_list_categories - add class  */
	$('.widget_categories .children .current-cat-parent').parents("li").addClass("current-cat-ancestor");
	
/* Single Product Page - Main Product Image Tabs Add current class  */
	$("#singleMainContent .thumbTabs li:first-child .thumbTab, #singleMainContent .inner_thumbTabs li:first-child .thumbTab").addClass('current');
	$("#singleMainContent .thumbTabs .thumbTab, #singleMainContent .inner_thumbTabs .thumbTab").mouseover(function() {
		$(this).addClass('current').parent().siblings().children().removeClass('current');
	});
	
/*Comment Trackbacks*/
	$("ol.trackback").hide();
		$("a.show_trackbacks").click(function(){
			$("ol.trackback").slideToggle('fast');
			return false;
		});
	
});	

$(window).load(function(){

/* EQUAL HEIGHTS (fire this when everything has loaded for correct height calculation) */
	$.fn.equalHeights = function() {
		var maxheight = 0;
		$(this).children().each(function(){
			maxheight = ($(this).height() > maxheight) ? $(this).height() : maxheight;
		});
		$(this).children().css('height', maxheight);
	}
	$('#floatswrap .eqcol').equalHeights();

});

/* FONT REPLACEMENT */
Cufon.replace('.widget-title, #singleMainContent .prod-title, .entry-title, .comments_title, .respond_title, .trackback_title', {
hover: true
});