//jquery tabs
  jQuery(function() {
                jQuery('#tabcontainer-1 > ul, #tabcontainer-2 > ul').tabs({ fx: { opacity: 'toggle' } });
            });
 
	// Text Resizer
	$(document).ready(function() {
		$('.resizer area').click(function() {
			var textSize = $(this).attr('class');
			$('#wm_content td.col_2,#Description,#Specs,#ShipInfo,#WestAdvisor,#Reviews').removeClass('small medium large').addClass(textSize);
			return false;
		});
	});
	
// Vanilla js - light boxes
function tb_path(lbx)
    {
    function showlightbox() {
		tb_show('','/wcsstore/MadisonsStorefrontAssetStore/LightBox/'+lbx, 300);
		}
    return showlightbox;
    }
var Feedback = tb_path('Feedback.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=330&amp;width=370&amp;modal=true');
var FeedbackConfirm = tb_path('FeedbackConfirm.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=70&amp;width=360&amp;modal=true');
var SizeChart = tb_path('SizeChart.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=450&amp;width=810&amp;modal=false');
var ShoppingCartShipCharges = tb_path('SC_ShipTax.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=450&amp;width=810&amp;modal=false');
var SC_LowPrice = tb_path('SC_LowPrice.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=320&amp;width=810&amp;modal=false');
var SC_NoHassle = tb_path('SC_NoHassle.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=450&amp;width=810&amp;modal=false');
var SC_FreeShip = tb_path('SC_FreeShip.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=450&amp;width=810&amp;modal=false');
var SC_NoShiptoStore = tb_path('SC_NoShiptoStore.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=320&amp;width=810&amp;modal=false');
var SC_FAQ = tb_path('SC_FAQ.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=150&amp;width=520&amp;modal=false');
var ShoppingCartPlusPlan = tb_path('ShoppingCartPlusPlan.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=220&amp;width=420&amp;modal=false');
var ShoppingCartPlusPlanPDF = tb_path('PLUSTerms.pdf#toolbar=0&amp;navpanes=0&amp;?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=450&amp;width=820&amp;modal=true');
var ShoppingCartPlusPlanPDF_FL = tb_path('PLUSTerms_FL.pdf#toolbar=0&amp;navpanes=0&amp;?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=450&amp;width=820&amp;modal=true');
var RequestCatalog = tb_path('RequestCatalog.htm?placeValuesBeforeTB_=savedValues&amp;TB_iframe=true&amp;height=194&amp;width=347&amp;modal=false');

//// Endeca Navigation ////////////////////////////////////////////
jQuery(document).ready(function(){
//Store Image paths
var toggleMinus = '/wcsstore/MadisonsStorefrontAssetStore/images/wm/nav_minus.gif';
var togglePlus = '/wcsstore/MadisonsStorefrontAssetStore/images/wm/nav_plus.gif';
var jQuerysubHead = jQuery('.children').parent();
var jQueryshow = jQuery('.show').parent();
//Add the Plus image to every child by default
jQuerysubHead.prepend('<img src="' + togglePlus + '" alt="" /> ');
//By Default put the Menu in collapsed state
//jQuery('.children').parent().children('ul').slideUp('fast');
///////////////////////////////////////////////////////////////////////////////
//Expand All 
jQuery('.expand').click(function() {
		jQuerysubHead.children('ul').slideDown('fast');
		jQuery('img', jQuerysubHead).attr('src', toggleMinus);
		});
//Contract All 
jQuery('.contract').click(function() {
		jQuerysubHead.attr('src', toggleMinus).children('ul').slideUp('fast');
		jQuery('img', jQuerysubHead).attr('src', togglePlus);
});
//////////////////////////////////////////////////////////////////////////////////
//Expand 

jQuery('img', jQuerysubHead).addClass('clickable').click(function() {
var toggleSrc = jQuery(this).attr('src');
if ( toggleSrc == toggleMinus ) {
jQuery(this).attr('src', togglePlus).parent().children('ul').slideUp('fast');
} else{
jQuery(this).attr('src', toggleMinus).parent().children('ul').slideDown('fast');
};
});
jQuery('img', jQueryshow).attr('src', toggleMinus);
});


// WA Product Advice Toggle Box 
	jQuery(document).ready(function(){
		jQuery('#wa_toggler').toggle(
					function(){
						jQuery('#wa_box').fadeIn('slow');
						jQuery('#wa_togimg').attr('src','/wcsstore/MadisonsStorefrontAssetStore/images/wm/wa_minus.png');
					},function(){ 
						jQuery('#wa_box').fadeOut('fast');
						jQuery('#wa_togimg').attr('src','/wcsstore/MadisonsStorefrontAssetStore/images/wm/wa_plus.png');
					});
	});

// Tooltips  
jQuery(document).ready(function() {
// Price Match Info Tooltip
 jQuery("#P_PriceMatchInfoBox").html("<div><img src='http://content.westmarine.com/wm-img/lightbox/lb_closeX.gif' alt='close X' id='P_PriceMatchclose'/><b>We Won&acute;t Be Beat &mdash; Low Price Guarantee<\/b><br //>Our Low Price Guarantee assures that you are always getting a competitive price. If you find a nationally recognized retailer who has a lower advertised price on an identical, in&ndash;stock item within 10 days of purchase of that identical item from West Marine, just let us know. You can shop with confidence at West Marine.<br //><a href=\"/webapp/wcs/stores/servlet/CustomerServiceView?langId=-1&storeId=11151&catalogId=10001&page=Low-Price-Guarantee\" target=\"_self\">Click for Complete Details<\/a> </div>");
 jQuery('.P_PriceMatch').click(function() {
  jQuery('#P_PriceMatchInfoBox').fadeIn('slow');
  jQuery('#P_WestAdvantageInfoBox,#P_FreeShippingInfoBox').hide();
 });
 jQuery('#P_PriceMatchclose').click(function() {
  jQuery('#P_PriceMatchInfoBox').hide();
 });
 
// West Advantage Info Tooltip
jQuery('#P_WestAdvantageInfoBox,#WestAdvantageRegInfoBox').html("<div><img src='/wcsstore/MadisonsStorefrontAssetStore/images/wm/lb_closeX.gif' alt='close X' id='WestAdvantageclose'/><b>The West Advantage Program<\/b><br //>West Advantage Members can earn 4% back on boating supply purchases, in addition to hundreds of dollars in savings opportunities though exclusive product and service offerings. Members also enjoy special discounts on travel, magazine subscriptions, outfitting and more.<br //><a href=\"http://www.westmarine.com/webapp/wcs/stores/servlet/WestAdvantageView?langId=-1&storeId=11151&catalogId=10001&page=West-Advantage-Program\" target=\"_self\">Join today!<\/a> </div>");
jQuery('.P_WestAdvantage,.WestAdvantageTt a').click(function() {
jQuery('#P_WestAdvantageInfoBox,#WestAdvantageRegInfoBox').fadeIn('slow');
jQuery('#P_PriceMatchInfoBox,#P_FreeShippingInfoBox').hide();
});
jQuery('#P_WestAdvantageclose,#WestAdvantageclose').click(function() {
jQuery('#P_WestAdvantageInfoBox,#WestAdvantageRegInfoBox').hide();
});

// My Account Change Member Number Slide Box
jQuery('span.gedit-accNum').click(function() {
jQuery('#gdiv-accNum').slideDown("slow");
});
jQuery('span.sedit-accNum').click(function() {
jQuery('#sdiv-accNum').slideDown("slow");
});
jQuery('span.close-accNum').click(function() {
jQuery('#sdiv-accNum, #gdiv-accNum').slideUp("slow");
});

// Free Shipping Info Tooltip
jQuery('#P_FreeShippingInfoBox').html("<div class=\"P_FreeShippingLeave\"><img src='http://content.westmarine.com/wm-img/lightbox/lb_closeX.gif' alt='close X' id='P_FreeShippingclose'/><b>Free Ground Shipping - Ship to Store<\/b><br //>When selecting your shipping options, simply click the &quot;Buy Online - Ship to Store&quot; button and choose your preferred West Marine store location. Shipping takes 8-10 days and is FREE!<br //><a href=\"/webapp/wcs/stores/servlet/CustomerServiceView?langId=-1&storeId=11151&catalogId=10001&nav=LeftNav&page=Shipping-Methods\" target=\"_self\">See details<\/a> </div>");
jQuery('.P_FreeShipping').click(function() {
jQuery('#P_FreeShippingInfoBox').fadeIn('slow');
jQuery('#P_PriceMatchInfoBox,#P_WestAdvantageInfoBox').hide();
});
jQuery('#P_FreeShippingclose').click(function() {
jQuery('#P_FreeShippingInfoBox').hide();
});

// Shopping Cart shipping/handling Info Tooltip
 jQuery("#P_ShopCartInfoBox").html("<div><img src='http://content.westmarine.com/wm-img/lightbox/lb_closeX.gif' alt='close X' id='P_ShopCartclose'/><p><b>Purchase as much as you want  and ship for one flat rate fee!<\/b><\/p> </div>");
 jQuery('.P_ShopCart a').click(function() {
  jQuery('#P_ShopCartInfoBox').fadeIn('slow');
 });
 jQuery('#P_ShopCartclose').click(function() {
  jQuery('#P_ShopCartInfoBox').hide();
 });
});

// WA Tables 
 jQuery(document).ready(function(){
 jQuery("table.waTable tr:even").addClass("tr-alt");
 });
// This for IE6 only 
if ( jQuery.browser.msie && /6.0/.test(navigator.userAgent) ) {
jQuery(document).ready(function() {
jQuery('.row .Cell').hover(function() {
jQuery(this).addClass('cellhover');
}, function() {
jQuery(this).removeClass('cellhover');
});

jQuery('.wm_topcap td').hover(function() {
jQuery(this).addClass('wm_topcaphover');
}, function() {
jQuery(this).removeClass('wm_topcaphover');
});

jQuery('.catcolumncontain .catblockcontain').hover(function() {
jQuery(this).addClass('catblockhover');
}, function() {
jQuery(this).removeClass('catblockhover');
});

jQuery('.rnavtopsellerscontain .rnavtopsellerblock').hover(function() {
jQuery(this).addClass('rnavtopsellerhover');
}, function() {
jQuery(this).removeClass('rnavtopsellerhover');
});

//bgiframe
if (jQuery.browser.version == 6) { 
jQuery('#hmenucontain ul.sub_menu').bgiframe(); 
jQuery('#hmenucontain ul.sub_menu2').bgiframe(); 
}
});
}

// Compare Button on search results pages
function ShowCompareButton (cell, box) { 
	var compare = (box.checked) ? "block" : "none"; 
	document.getElementById(cell).style.display = compare;
}
function CompareProducts(link) { 
	var checkedBoxes = $("input:checkbox.modtype:checked");
	var rValues = '';
	for (var i = 0; i < checkedBoxes.length; i++) {
		if (rValues.length > 0) {
			rValues += ',';
		}
		rValues += checkedBoxes[i].value;
	}
	link.href += '&A=' + rValues;
	if (checkedBoxes.length < 2) {
		var msg = "Please select a minimum of 2 items to compare."
		alert(msg);
      return false;
	}
	if (checkedBoxes.length > 4) {
		var msg = "Please select a maximum of 4 items to compare.";
		alert(msg);
		return false;
	}
	return true;
}
// Store Finder SL_SrchBox
var SL_Request={GetInvalidChars:function(a,d){var e=new Array();for(var c=0;c<a.length;c++){var b=a.charAt(c);if(d.indexOf(b)>=0){e[e.length]=b}}return e},ProcessInput:function(){var b=document.getElementById("SL_SrchBox").value.replace(/ /g,"+");var c=SL_Request.GetInvalidChars("!@$%^&*()=[]\\'/{}|\":<>?",b);if((b.length>=2)&&(b!="Enter+a+ZIP+code+or+City+and+State")){if((c.length==0)){var a="/webapp/wcs/stores/servlet/AjaxStoreLocatorDisplayView?langId=-1&storeId=11151&catalogId=10001";window.location.href=a+"#FindStore="+b;return true}else{document.getElementById("ErrorMessageText").innerHTML="Your search contains prohibitied character(s). Please remove [ "+c.join().replace(/,/g," ")+" ] and try again.";document.getElementById("MessageArea").style.display="block";dojo.query("body.hasLeftNav").forEach(function(d){if(dojo.hasClass(d,"hasLeftNav")){document.getElementById("ErrorMessageText").style.margin="0 0 0 205px"}});return false}}else{return false}},GetInvalidChars2:function(e,a){var d=new Array();for(var b=0;b<e.length;b++){var c=e.charAt(b);if(a.indexOf(c)>=0){d[d.length]=c}}return d},ftrProcessInput:function(){var a=document.getElementById("ftrSL_SrchBox").value.replace(/ /g,"+");var c=SL_Request.GetInvalidChars2("!@$%^&*()=[]\\'/{}|\":<>?",a);if((a.length>=2)&&(a!="Enter+a+ZIP+code+or+City+and+State")){if((c.length==0)){var b="http://www.westmarine.com/webapp/wcs/stores/servlet/AjaxStoreLocatorDisplayView?langId=-1&storeId=11151&catalogId=10001";window.location.href=b+"#FindStore="+a;if(hasFindStore){location.reload(true)}return true}else{document.getElementById("ErrorMessageText").innerHTML="Your search contains prohibitied character(s). Please remove [ "+c.join().replace(/,/g," ")+" ] and try again.";document.getElementById("MessageArea").style.display="block";dojo.query("body.hasLeftNav").forEach(function(d){if(dojo.hasClass(d,"hasLeftNav")){document.getElementById("ErrorMessageText").style.margin="0 0 0 205px"}});return false}}else{return false}}};
//power reviews update
function updateReviewsClone(){$("#mainTabContainer #Reviews").html("");$("#ReviewsCell").clone().appendTo("#mainTabContainer #Reviews");}$(document).ready(function(){$('#mainTabContainer #Reviews').click(function(){setTimeout('updateReviewsClone()',1500);});});

