/*
	Copyright: 	Hybrid Forge 2010. All Rights Reserved.
	Author: 	Rod Miles (www.HybridForge.com)
	Date:		November 2010
	
	Info:		Customizations & Styling
=============================================================================*/
 
 
/*	jQuery Customizations
=============================================================================*/
jQuery.noConflict();	// required to use jQuery when Prototype is active
jQuery(document).ready(function($) {

	/*--------------------------------------------------------------
		Misc. EASING Functions
	--------------------------------------------------------------*/
		$.easing.custom = function (x, t, b, c, d) { 
			var s = 1.70158;  
			if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
			return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
		}	
		$.easing.easeInOutQuint = function (x, t, b, c, d) {
			if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
			return c/2*((t-=2)*t*t*t*t + 2) + b;
		}
	
	
	/*--------------------------------------------------------------
		MISC. Tweaks
	--------------------------------------------------------------*/
		// Product reviews inside Product Tabs when it's empty
		if ( $.trim($("#product_tabs_product_review_contents #customer-reviews").html()) == "") {
			$("#product_tabs_product_review_contents #customer-reviews").html( "No reviews yet. " + $("#product_addtocart_form .no-rating").html() );
		}
		
		// Hilite product cell if on sale and in grid-view
		$(".products-grid .special-price").parents("li.item").addClass("special");
		
		// Reviews page
		if ( $("body").hasClass("review-product-list") || $("body").hasClass("catalog-product-view") ) {
			if ( $.trim( $(".product-collateral.cms-content .cms-content-inner").text()) == "") { $(".product-collateral.cms-content").remove(); }
		}

	
	/*--------------------------------------------------------------
		MainMenu Tweaks
	--------------------------------------------------------------*/
		$("#nav li").filter(".level0").find("a:first").addClass("mm-top");
		if ( $("#nav li#mm01 li.active").length ) { $("#nav li#mm01 a.mmTop").addClass("active"); }
		else if ( $("#nav li#mm02 li.active").length ) { $("#nav li#mm02 a.mmTop").addClass("active"); }
		else if ( $("#nav li#mm03 li.active").length ) { $("#nav li#mm03 a.mmTop").addClass("active"); }
		else if ( $("#nav li#mm04 li.active").length ) { $("#nav li#mm04 a.mmTop").addClass("active"); }
		else if ( $("#nav li#mm05 li.active").length ) { $("#nav li#mm05 a.mmTop").addClass("active"); }


	/*--------------------------------------------------------------
		HF Featured / Scrollable 
	--------------------------------------------------------------*/
		// Pause/Play
		$(".pausePlay").click(function() {
			$(this).toggleClass("play");
			$(this).parents(".hf-featured").eq(0).find(".scrollable").cycle("toggle");
		});
		
		// HOME PAGE Featured
		// -------------------------------------------------
		if ( $("body").hasClass("cms-home") || $("body").hasClass("cms-new-home") ) {			
			
			// REMOVE TO BRING BACK NAV
			$("#featured-banners #bannerNavWrap").hide();
			
			// Featured BANNERS
			$('#featured-banners .scrollable').cycle({ 
				fx:			'fade', 
				speed: 		700,
				timeout:	5500,
				delay:		0,
				pause:		true,			
				pauseOnPagerHover: true,
				pagerEvent:	'click', 
				pager: 		'#bannerNav',
				prev:    	'#bannerPrev',
				next:    	'#bannerNext',
				sync:		true,
				cleartypeNoBg: 	true	// needed for IE
			});
			// Wrap Nav links 
			$("#bannerNav a").wrapInner("<span></span>");
			
			// Featured PRODUCTS
			/*
			$('#featured-products .scrollable').cycle({ 
				fx:			'scrollHorz', 
				easing:		'easeInOutQuint',
				speed: 		700,
				timeout:	4500,
				delay:		0,
				pause:		true,			
				pauseOnPagerHover: true,
				pagerEvent:	'click', 
				pager: 		'#scrollNav',
				prev:    	'#scrollPrev',
				next:    	'#scrollNext',
				sync:		true,
				cleartypeNoBg: 	true	// needed for IE
			});			
			// Wrap Nav links 
			$("#scrollNav a").wrapInner("<span></span>");
			// Pause it
			$('#featured-products .scrollable').cycle("pause");
			*/
		}
		
		// CATEGORY Page Featured
		// -------------------------------------------------
		/*
		if ( $("body").hasClass("catalog-category-view") ) {			
			$('#featuredincat-products .scrollable').cycle({ 
				fx:			'scrollHorz', 
				easing:		'easeInOutQuint',
				speed: 		1000,
				timeout:	4500,
				delay:		0,
				pause:		true,			
				pauseOnPagerHover: true,
				pagerEvent:	'click', 
				pager: 		'#scrollNav',
				prev:    	'#scrollPrev',
				next:    	'#scrollNext',
				sync:		true,
				cleartypeNoBg: 	true	// needed for IE
			});
			$('#featuredincat-products .scrollable').fadeIn();
			// Wrap Nav links 
			$("#scrollNav a").wrapInner("<span></span>");
			
		}
		*/


	/*--------------------------------------------------------------
		Specific Product Page Tweaks
	--------------------------------------------------------------*/
		var tempText = "";
		var newText = "";
	
		/* HINT MINT TWO PACK :: BUNDLE */
		// http://www.myfilosophy.com/hint-mint-tin-pack.html
		if ( $("body").hasClass("product-hint-mint-tin-pack") ) {
			// Remove the "HINT MINT" and othe text from the drop-down descriptions
			$(".bundle-option-select option").each(function() {
				tempText = $(this).text();
				newText = tempText.replace('Hint Mint ','');
				newText = newText.replace('+CA$0.00','');
				newText = newText.replace('Tin','');
				$(this).text(newText);
			});
			
			// Hide the "second" price box
			// Hide the "qty" labels
			$(".price-box:eq(1), .price-box:eq(2), .qty-holder").hide();
		}
		
		/* FlipFold Adult / Junior Combo Package */
		// http://www.myfilosophy.com/flip-fold-adult-and-junior-combo-package.html
		if ( $("body").hasClass("product-flip-fold-adult-and-junior-combo-package") ) {			
			// Remove the "+CA$0.00" and othe text from the drop-down descriptions
			$(".bundle-option-select option").each(function() {
				tempText = $(this).text();
				newText = tempText.replace('+CA$0.00','');
				newText = newText.replace('Shirt and Laundry Folder','-');
				$(this).text(newText);
			});
			
			// Remove text from the last area
			$("#product-options-wrapper dd.last").each(function() {
				$(this).find(".price-notice").hide();
				tempText = $(this).html();
				newText = tempText.replace('+CA$0.00','');
				newText = newText.replace('Shirt and Laundry Folder','');
				newText = newText.replace('Junior','Junior -');
				$(this).html(newText);
			});
			
			// Hide the "second" price box
			// Hide the "qty" labels
			$(".price-box:eq(1), .qty-holder").hide();
		}
		
		
});

