jQuery.noConflict();
jQuery(document).ready(function() {	

jQuery(".extra a").each(function() {
	(!jQuery(this).attr('href')) ? jQuery(".extra").hide() : jQuery(this).show();
});




// HOME SLIDESHOW
jQuery(".slidetabs").tabs(".slideshow > .slides", {
	effect: 'fade',
	fadeOutSpeed: 300,
	fadeInSpeed: 600,
	initialIndex: 0,
	rotate: true
	}).slideshow({autoplay: true, clickable: false, interval: 8500});
	
jQuery('.hidden').hide();
jQuery('.readmore-home').click(function() {
	jQuery('.hidden').toggle('fast', function() {});
	jQuery('.readmore-home').toggleClass("hidetext");
});
	
	
jQuery('ul.sf-menu').superfish();
jQuery('h1.hide, h2.hide, .hide').hide();

//CAREERS ACCORDEN
jQuery(".careers").tabs(".careers div.pane", {tabs: 'h3', effect: 'slide', initialIndex: null});

// LOCATIONS MAP
jQuery(".map-aus a").each(function() { if(this.href == window.location.href.split("#")[0]) { jQuery(this).parent().addClass("active"); } });

jQuery(".map-aus").hover(
function () {jQuery(".map-aus .active").addClass('over');}, 
function () {jQuery(".map-aus .active").removeClass('over'); });

// Menu Active - Top Menu
jQuery(".topmenu li a").each(function() { if(this.href == window.location.href.split("#")[0]) { jQuery(this).parent().addClass("active"); } });
// Menu Active - Equipment Sub Menu
jQuery("ul.submenu li a").each(function() { if(this.href == window.location.href.split("#")[0]) { jQuery(this).parent().addClass("active"); } });

// Hide last borders
jQuery(".BlogRecentPost ul li:last, .BlogTagList ul li:last, .BlogPostArchive ul li:last, .footer ul li:last-child a, .home-latest-news .blog-post:last, ul.submenu li:last a").css({ borderBottom: 'none' });
jQuery(".photogallery a").append('<span class="blacky"></span>');
jQuery("#compare tr td:nth-child(2)").addClass("odd");
jQuery("#compare tr th:nth-child(2)").addClass("odd");

jQuery(".faqs").tabs(".faqs div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});
jQuery('.faqs h2').hover(
	function(){jQuery(this).addClass("over");}, function(){ jQuery(this).removeClass("over"); });
	
jQuery("table.wwr-table tr:odd").css("background-color", "#282626"); 


jQuery('.t-col .inner').hover( 
	function(){ jQuery(this).animate({opacity: 0.9}, 'normal' );}, 
	function(){ jQuery(this).animate({opacity: 1}, 'normal' ); });
jQuery('.t-cl .inner, .promos .promo-box').click(function(){
	window.location=jQuery(this).find('a').attr('href');
	return false;
}); 

jQuery('.promos .promo-box').hover( 
	function(){ jQuery(this).addClass('pover');}, 
	function(){ jQuery(this).removeClass('pover');
});


jQuery('body.cvc ul.submenu li:last').hide(); 


/* 
var pathArray = window.location.pathname.split( '/' );
var sL = pathArray[2];
var buynowinterest = document.getElementById('buynow');
buynowinterest.CAT_Custom_213151.value = sL; 
*/


// Wrap div around object - Idea to add div around image on blog posts to hide image - constrain hieght.
//$('.inner').wrap('<div class="new" />');

/* jQuery('.parallax').scrollingParallax();
jQuery.scrollingParallax('/images/layout/bg-body-front.png',{
    bgHeight: '1200px',
	bgWidth: '2000px',
	staticSpeed: 0.5,
	loopIt: true
	
});
jQuery.scrollingParallax('/images/layout/bg-body-middle.png',{
    bgHeight: '1200px',
	bgWidth: '2000px',
	staticSpeed: 0.1,
	loopIt: true
	
});

jQuery.scrollingParallax('/images/layout/bg-body-back.png',{
    bgHeight: '1200px',
	bgWidth: '2000px',
	staticSpeed: 0.05,
	loopIt: true
});*/


/*** LOAD OVERLAY IF URL CONTAINS #WELCOME STRING ***/
if ( document.location.href.indexOf('#welcome') > -1 ) {
		jQuery(".duncan-video").hide();
		var clone = jQuery("#video").clone(true);
				 jQuery("#video").remove();
				 jQuery(".duncan-video").html(clone);
		jQuery("button.close").click(function() {
			window.location = "http://www.cardiotech.com.au/guy-leech-series-fitness-equipment"
		});
		
    // select the overlay element - and "make it an overlay"
		jQuery("#overlay").overlay({
		// custom top position
		top: 0,
		// some mask tweaks suitable for facebox-looking dialogs
		mask: {
			// you might also consider a "transparent" color for the mask
			color: '#000',
			// load mask a little faster
			loadSpeed: 200,
			// very transparent
			opacity: 0.5
		},
	// disable this for modal dialog-type of overlays
	closeOnClick: false,
	// load it immediately after the construction
	load: true,
	onClose: function() {
				jQuery(".duncan-video").show();
				 //remove and re-add video
				 var clone = jQuery("#video").clone(true);
				 jQuery("#video").remove();
				 jQuery(".duncan-video").html(clone);
 	}

});            
}


if ( document.location.href.indexOf('index.php?') > -1 ) {
	window.location = "http://www.cardiotech.com.au/" }

/*jQuery("a[rel=#op]").overlay({  
	mask: 'black',
	effect: 'apple',
});*/

/* ECOMM POP FOR TERMS */
jQuery(function() {
	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	jQuery("a[rel=#op]").overlay({

		mask: 'black',
		effect: 'apple',

		onBeforeLoad: function() {

			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");

			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
		}

	});
});

/* COMBATZONE SPECS POP UP */
jQuery(function() {
	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	jQuery("a[rel=#czs]").overlay({
		mask: '#000',
		effect: 'apple',
	});
});


/*jQuery(".quantity input").change(function() {  
	 alert("Changed!");
		
	updateShipping();
});*/





// CHANGE BODY CLASS DEPENDENT ON PRODUCT IN CART 
if ( document.location.href.indexOf('lifeback') > -1 ) {
		jQuery("body").addClass("lifeback");	
	} else if ( document.location.href.indexOf('combatzone-buy') > -1 ) {
		jQuery("body").addClass("cz");	
}

//jQuery("#Anniversary1").DatePicker('setDate', new Date());

jQuery('#Anniversary1').datePicker().val(new Date().asString()).trigger('change');

function updateShipping() {
	jQuery('.custom-p .productitemcell, .product-type').hide();
	jQuery('.custom-p .productitemcell').each(function(index) {
		var tt = jQuery(this).text();
		jQuery('.product-type').append(tt);
	});
			
	if (jQuery('td.productname .productitemcell a:contains("LifeBack Vibration Machine")').length > 0 && jQuery('td.productname .productitemcell a:contains("CombatZone")').length > 0 ) {
		//alert("2 products");
	} else if (jQuery('td.productname .productitemcell a:contains("LifeBack Vibration Machine")').length > 0) {
		jQuery("body").addClass("lifeback");
	} else if (jQuery('td.productname .productitemcell a:contains("CombatZone")').length > 0) {
		jQuery("body").addClass("cz");
	}
		
	var hrefLoc = jQuery("a#catshopbuy").attr("href");
		
	if (jQuery("body").hasClass("lifeback") || jQuery("body").hasClass("cz") ) {
		jQuery('select.shippingDropDown option:contains("Australia Wide $90.00")').hide();
	}
	if (jQuery("body").hasClass("lifeback") || jQuery("body").hasClass("cz") ) {
		jQuery('select.shippingDropDown option:contains("Australia Wide $90.00")').hide();
	};
	
	jQuery("select.shippingDropDown:contains('free $0.00')").val('79970');
	
	var freeShipping = jQuery("select.shippingDropDown:contains('free $0.00')").val('79970');
	if ( freeShipping ) {
		jQuery("#ShippingOptions").hide();
		jQuery("tr.shipping td.shippingtotal:contains('$0.00')").html('Free');
		jQuery("tr.shipping td #shippingSpan:contains('Choose Shipping Option')").html('Free Shipping!');
	}
	
}; // end updateShipping function

if ( document.location.href.indexOf('OrderRetrievev2.aspx') > -1 ) {
	updateShipping();
	
	//$('select').val('Two'); // also selects "Two"
}

jQuery("td.remove a").click(function(){  updateShipping(); });


jQuery('input.cartInputText').live('change', function(){
	updateShipping();
});
/*
jQuery('input.cartInputText').bind('DOMAttrModified textInput input change keypress paste focus', function() {
	jQuery('.custom-p .productitemcell').hide();
		jQuery('.custom-p .productitemcell').each(function(index) {
			var tt = jQuery(this).text();
			jQuery('.product-type').append(tt);
		});
    
});
*/
});





jQuery("#selectsearch").change(function() {
  var action = jQuery(this).val() == "people" ? "user" : "content";
  jQuery("#search-form").attr("action", "/search/" + action);
});
