jQuery(function ($) {
	// $.ajaxSetup forces the browser NOT to cache AJAX calls.
	$.ajaxSetup ({  
		cache: false  
	});
	
/*##################  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); 
        }
	});	

/*##################  IMG 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});
	});

/*##################   TABS   ################################ */
	$("#singleMainContent .related .tabs").tabs("div.panes > div", { event:'mouseover' });

/*##################   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"         
         
    });
	
/*##################  ADJACENT PRODUCTS   ################################ */
	$('.adjacentProd').hover(function(){
		var $showME = $(this).find('.adjacentImg');
		$showME.stop().fadeIn("slow");
	}, function(){
		var $showME = $(this).find('.adjacentImg');
		$showME.fadeOut("slow");
	});
	
/*##################   AJAX SHOPPING CART  ################################ */
/*
  var name = $("input#name").val(); 
  var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
  //alert (dataString);return false;
	$.ajax({
		type: "POST",
		url: "bin/process.php",
		data: dataString,
		success: function() {
			$('#singleMainContent .product_btns').after("<div id='message' class='success'></div>");
			$('#message').html("<p>You just added this item to your shopping bag!</p>")
			.append("<p>We will be in touch soon.</p>")
			.hide()
			.fadeIn(1500, function() {
				$('#message').append("<img id='checkmark' src='images/check.png' />");
			});
		}
	});
  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('.featured .hover_block  .subcatnavi a, .featured .hover_block  .mainCatTitle, .theCats .hover_link', {
hover: true
});