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]").each(function(i) {
			
		$(this).overlay({
			effect: 'apple'
		});			
	});
	
	// load external content
	$("#singleMainContent .sizing_info 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/TheClothesShop/images/ajax-loader.gif' alt='loading...' />";
            // grab wrapper element inside content 
            var wrap = this.getContent().find("div.sizeChartWrap"); 
			// get the page specified in the trigger and a specific element from inside it 
			var toLoad = $(this.getTrigger()).attr('href')+' .page_post';
            // load it! 
			wrap.html(ajax_load).load(toLoad); 
        }
	});	

/* Multiple Product Pages - Image Hover */
	$('.contentWrap').hover(function(){
		var $goleft = $(this).find('.hover_link');
		$goleft.stop().animate({left:-$goleft.outerWidth()},{queue:false,duration:500});
	}, function(){
		var $goleft = $(this).find('.hover_link');
		$goleft.stop().animate({left:'0'},{queue:false,duration:500});
	});

/* Single Product Page - Related Tabs */
	$("#singleMainContent .related .tabs").tabs("div.panes > div", { event:'mouseover' });
/* Single Product Page - when videos are embedded (image/video tab) */
	$("#singleMainContent .imgtabs").tabs("div.mediaPanes > .theProdMedia");
/* Single Product Page - when videos are embedded and multible images are used (inner tabs) */
	$("#singleMainContent .innerProdMedia .innerTabs").tabs("div.inner_mediaPanes > .theInner_ProdMedia", { event:'mouseover' });
/* Single Product Page - when multible images are used (with lightbox effect or no effect) */
	$("#singleMainContent .tabs_alt").tabs("div.mediaPanes_alt > .theProdMedia_alt", { 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");
	});
	
/* Single Product Page - Main Product Image Tabs Add current class  */
	$("#singleMainContent .tabs li:first-child .thumbTab").addClass('current');
	$("#singleMainContent .tabs .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;
		});
		
/*DROP DOWN NAVI*/
	function mainmenu(){
		if(!$.browser.msie){// IE  - 2nd level Fix
		$(" #header .MainCatsNav ul ul ").css({opacity:"0.95"});
		}
		$("#header .MainCatsNav ul a").removeAttr('title');
		$(" #header .MainCatsNav ul ul ").css({display: "none"}); // Opera Fix
		
		$(" #header .MainCatsNav ul li").hover(function(){
			$(this).find('ul:first:hidden').slideDown("slow");
		},function(){
			$(this).find('ul:first').slideUp();
		});
	}
	
	mainmenu();
});	

		


$(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('.featured .hover_block  .subcatnavi a, .featured .hover_block  .mainCatTitle, .theCats .hover_link, .theCats .static_link', {
hover: true
});