﻿// Updated 10-14-2013
// Site Wide JS (Non-consolidated)
/* The top var mmLocales includes the addition of en_CA and fr_CA - these additions are waiting on approval from Jenn Sickmann.  This JS is not ready to be published yet! */
var mmLocales=["en_US","en_NZ","en_AU","en_EU","en_GB","fi_FI","no_NO","uk_UA","ru_RU","bg_BG","da_DK","pl_PL","tr_TR","el_GR","pt_PT","en_EG","ro_RO","lt_LT","ru_KZ","sv_SE","en_ZA","en_AE","sl_SL","dk_SK","cs_CZ","de_CH","fr_CH","de_AT","de_DE","fr_BE","nl_BE","nl_NL","fr_FR","it_IT","es_ES","hu_HU","nl_NL","et_EE","ko_KR","ja_JP","en_IN", "en_PH","en_MY","vi_VN","th_TH","zh_TW","en_SG","sk_SK","en_ID","en_CA","fr_CA","es_CO","es_AR","es_UY","es_VE","es_BO","es_CL","es_CR","es_DO","es_EC","es_SV","es_GT","es_HN","es_MX","es_NI","es_PA","es_PY","es_PE","pt_BR","en_SA"];
//var mmLocales=["en_US","en_NZ","en_AU","en_EU","en_GB","fi_FI","no_NO","uk_UA","ru_RU","bg_BG","da_DK","pl_PL","tr_TR","el_GR","pt_PT","en_EG","ro_RO","lt_LT","ru_KZ","sv_SE","en_ZA","en_AE","sl_SL","dk_SK","cs_CZ","de_CH","fr_CH","de_AT","de_DE","fr_BE","nl_BE","nl_NL","fr_FR","it_IT","es_ES","hu_HU","nl_NL","et_EE","es_CO","ko_KR","ja_JP","en_IN", "en_PH","en_MY","vi_VN","th_TH","zh_TW","en_SG","sk_SK","en_ID"];
																																																																																						

$(document).ready(function(){
	$('#mmmlsnouterwrap').slideDown();
	
	//Start PSN Class Override for Industry Landing Pages
	//Transportation Industry Override
	 if(window.location.href.indexOf("5930183") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Metal Production Fabrication Industry Override
	if(window.location.href.indexOf("7577491") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Oil and Gas Industry Override
	if(window.location.href.indexOf("5930168") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Mining Industry Override
	if(window.location.href.indexOf("5930166") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Military MRO Industry Override
	if(window.location.href.indexOf("7571112") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Military LE Tactical Industry Override
	if(window.location.href.indexOf("7579196") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Manufacturing Industry Override
	if(window.location.href.indexOf("5930161") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
	//Food and Beverage Industry Override
	if(window.location.href.indexOf("7579194") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
		//Pharmaceutical Industry Override
	if(window.location.href.indexOf("5930173") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
	};
	//Construction Industry Override
	if(window.location.href.indexOf("5930137") > -1) {
       $("li#psn1").removeClass("selected");
	   $("li#psn2").addClass("selected");
    };
//End PSN Class Override for Industry Landing Pages
	//start PSN WTB Logic
		var $wtbButt = $('#wtbUrlBtn'),		//product details level button
		$psnButt,					//psn button
		$footerButt;					//footer button, add any others as you see fit. 
	if ($wtbButt.length !== 0){
		//get and cache the other buttons to update
		$psnButt = $('#psn5 a');								//ideally the link would be updated to have a more stable selector
		$footerButt = $('.fatFootLink a[href*="buy-safety-equipment"]');		//ideally the link would be updated to have a more stable selector
		
		//modify our buttons to match the WTB Button HREF
		$psnButt.attr('href', $wtbButt.attr('href'));
		$footerButt.attr('href', $wtbButt.attr('href'));
	}
	//end PSN WTB Logic
	
	
var useMM = "No";
	for(var i = 0;i <= mmLocales.length;i++){
		if(window.location.href.indexOf(mmLocales[i])>-1){
			useMM = "Yes";
		}
		
	}
	if(useMM=="Yes"){
		$('#psnwrap').PSNMegaMenu();	
	}
	if(useMM=="No"){
		$.dropdownJSON();
		$('#psnwrap').createNavInteraction({
			"enable":true
		});
	}
	
	
	
	
	
	// Start Enable PSN drop down menu
	
	// Start Contextual Nav
	$.fn.LSNify({
		'contextualNav':true
	});

	// Slides
	/*
	* Slides, A Slideshow Plugin for jQuery
	* Intructions: http://slidesjs.com
	* By: Nathan Searles, http://nathansearles.com
	* Version: 1.1.9
	* Updated: February 15th, 2013
	*
	* Licensed under the Apache License, Version 2.0 (the "License");
	* you may not use this file except in compliance with the License.
	* You may obtain a copy of the License at
	*
	* http://www.apache.org/licenses/LICENSE-2.0
	*
	* Unless required by applicable law or agreed to in writing, software
	* distributed under the License is distributed on an "AS IS" BASIS,
	* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	* See the License for the specific language governing permissions and
	* limitations under the License.
	*/
	(function(a){a.fn.slides=function(b){return b=a.extend({},a.fn.slides.option,b),this.each(function(){function w(g,h,i){if(!p&&o){p=!0,b.animationStart(n+1);switch(g){case"next":l=n,k=n+1,k=e===k?0:k,r=f*2,g=-f*2,n=k;break;case"prev":l=n,k=n-1,k=k===-1?e-1:k,r=0,g=0,n=k;break;case"pagination":k=parseInt(i,10),l=a("."+b.paginationClass+" li."+b.currentClass+" a",c).attr("href").match("[^#/]+$"),k>l?(r=f*2,g=-f*2):(r=0,g=0),n=k}h==="fade"?b.crossfade?d.children(":eq("+k+")",c).css({zIndex:10}).fadeIn(b.fadeSpeed,b.fadeEasing,function(){b.autoHeight?d.animate({height:d.children(":eq("+k+")",c).outerHeight()},b.autoHeightSpeed,function(){d.children(":eq("+l+")",c).css({display:"none",zIndex:0}),d.children(":eq("+k+")",c).css({zIndex:0}),b.animationComplete(k+1),p=!1}):(d.children(":eq("+l+")",c).css({display:"none",zIndex:0}),d.children(":eq("+k+")",c).css({zIndex:0}),b.animationComplete(k+1),p=!1)}):d.children(":eq("+l+")",c).fadeOut(b.fadeSpeed,b.fadeEasing,function(){b.autoHeight?d.animate({height:d.children(":eq("+k+")",c).outerHeight()},b.autoHeightSpeed,function(){d.children(":eq("+k+")",c).fadeIn(b.fadeSpeed,b.fadeEasing)}):d.children(":eq("+k+")",c).fadeIn(b.fadeSpeed,b.fadeEasing,function(){a.browser.msie&&a(this).get(0).style.removeAttribute("filter")}),b.animationComplete(k+1),p=!1}):(d.children(":eq("+k+")").css({left:r,display:"block"}),b.autoHeight?d.animate({left:g,height:d.children(":eq("+k+")").outerHeight()},b.slideSpeed,b.slideEasing,function(){d.css({left:-f}),d.children(":eq("+k+")").css({left:f,zIndex:5}),d.children(":eq("+l+")").css({left:f,display:"none",zIndex:0}),b.animationComplete(k+1),p=!1}):d.animate({left:g},b.slideSpeed,b.slideEasing,function(){d.css({left:-f}),d.children(":eq("+k+")").css({left:f,zIndex:5}),d.children(":eq("+l+")").css({left:f,display:"none",zIndex:0}),b.animationComplete(k+1),p=!1})),b.pagination&&(a("."+b.paginationClass+" li."+b.currentClass,c).removeClass(b.currentClass),a("."+b.paginationClass+" li:eq("+k+")",c).addClass(b.currentClass))}}function x(){clearInterval(c.data("interval"))}function y(){b.pause?(clearTimeout(c.data("pause")),clearInterval(c.data("interval")),u=setTimeout(function(){clearTimeout(c.data("pause")),v=setInterval(function(){w("next",i)},b.play),c.data("interval",v)},b.pause),c.data("pause",u)):x()}a("."+b.container,a(this)).children().wrapAll('<div class="slides_control"/>');var c=a(this),d=a(".slides_control",c),e=d.children().size(),f=d.children().outerWidth(),g=d.children().outerHeight(),h=b.start-1,i=b.effect.indexOf(",")<0?b.effect:b.effect.replace(" ","").split(",")[0],j=b.effect.indexOf(",")<0?i:b.effect.replace(" ","").split(",")[1],k=0,l=0,m=0,n=0,o,p,q,r,s,t,u,v;if(e<2)return a("."+b.container,a(this)).fadeIn(b.fadeSpeed,b.fadeEasing,function(){o=!0,b.slidesLoaded()}),a("."+b.next+", ."+b.prev).fadeOut(0),!1;if(e<2)return;h<0&&(h=0),h>e&&(h=e-1),b.start&&(n=h),b.randomize&&d.randomize(),a("."+b.container,c).css({overflow:"hidden",position:"relative"}),d.children().css({position:"absolute",top:0,left:d.children().outerWidth(),zIndex:0,display:"none"}),d.css({position:"relative",width:f*3,height:g,left:-f}),a("."+b.container,c).css({display:"block"}),b.autoHeight&&(d.children().css({height:"auto"}),d.animate({height:d.children(":eq("+h+")").outerHeight()},b.autoHeightSpeed));if(b.preload&&d.find("img:eq("+h+")").length){a("."+b.container,c).css({background:"url("+b.preloadImage+") no-repeat 50% 50%"});var z=d.find("img:eq("+h+")").attr("src")+"?"+(new Date).getTime();a("img",c).parent().attr("class")!="slides_control"?t=d.children(":eq(0)")[0].tagName.toLowerCase():t=d.find("img:eq("+h+")"),d.find("img:eq("+h+")").attr("src",z).load(function(){d.find(t+":eq("+h+")").fadeIn(b.fadeSpeed,b.fadeEasing,function(){a(this).css({zIndex:5}),a("."+b.container,c).css({background:""}),o=!0,b.slidesLoaded()})})}else d.children(":eq("+h+")").fadeIn(b.fadeSpeed,b.fadeEasing,function(){o=!0,b.slidesLoaded()});b.bigTarget&&(d.children().css({cursor:"pointer"}),d.children().click(function(){return w("next",i),!1})),b.hoverPause&&b.play&&(d.bind("mouseover",function(){x()}),d.bind("mouseleave",function(){y()})),b.generateNextPrev&&(a("."+b.container,c).after('<a href="#" class="'+b.prev+'">Prev</a>'),a("."+b.prev,c).after('<a href="#" class="'+b.next+'">Next</a>')),a("."+b.next,c).click(function(a){a.preventDefault(),b.play&&y(),w("next",i)}),a("."+b.prev,c).click(function(a){a.preventDefault(),b.play&&y(),w("prev",i)}),b.generatePagination?(b.prependPagination?c.prepend("<ul class="+b.paginationClass+"></ul>"):c.append("<ul class="+b.paginationClass+"></ul>"),d.children().each(function(){a("."+b.paginationClass,c).append('<li><a href="#'+m+'">'+(m+1)+"</a></li>"),m++})):a("."+b.paginationClass+" li a",c).each(function(){a(this).attr("href","#"+m),m++}),a("."+b.paginationClass+" li:eq("+h+")",c).addClass(b.currentClass),a("."+b.paginationClass+" li a",c).click(function(){return b.play&&y(),q=a(this).attr("href").match("[^#/]+$"),n!=q&&w("pagination",j,q),!1}),a("a.link",c).click(function(){return b.play&&y(),q=a(this).attr("href").match("[^#/]+$")-1,n!=q&&w("pagination",j,q),!1}),b.play&&(v=setInterval(function(){w("next",i)},b.play),c.data("interval",v))})},a.fn.slides.option={preload:!1,preloadImage:"/img/loading.gif",container:"slides_container",generateNextPrev:!1,next:"next",prev:"prev",pagination:!0,generatePagination:!0,prependPagination:!1,paginationClass:"pagination",currentClass:"current",fadeSpeed:350,fadeEasing:"",slideSpeed:350,slideEasing:"",start:1,effect:"slide",crossfade:!1,randomize:!1,play:0,pause:0,hoverPause:!1,autoHeight:!1,autoHeightSpeed:350,bigTarget:!1,animationStart:function(){},animationComplete:function(){},slidesLoaded:function(){}},a.fn.randomize=function(b){function c(){return Math.round(Math.random())-.5}return a(this).each(function(){var d=a(this),e=d.children(),f=e.length;if(f>1){e.hide();var g=[];for(i=0;i<f;i++)g[g.length]=i;g=g.sort(c),a.each(g,function(a,c){var f=e.eq(c),g=f.clone(!0);g.show().appendTo(d),b!==undefined&&b(f,g),f.remove()})}})}})(jQuery);


	// jQuery Easing
	/*
	 * jQuery Easing Compatibility v1 - http://gsgd.co.uk/sandbox/jquery.easing.php
	 *
	 * Adds compatibility for applications that use the pre 1.2 easing names
	 *
	 * Copyright (c) 2007 George Smith
	 * Licensed under the MIT License:
	 *   http://www.opensource.org/licenses/mit-license.php
	 */
	jQuery.extend( jQuery.easing,
	{
		easeIn: function (x, t, b, c, d) {
			return jQuery.easing.easeInQuad(x, t, b, c, d);
		},
		easeOut: function (x, t, b, c, d) {
			return jQuery.easing.easeOutQuad(x, t, b, c, d);
		},
		easeInOut: function (x, t, b, c, d) {
			return jQuery.easing.easeInOutQuad(x, t, b, c, d);
		},
		expoin: function(x, t, b, c, d) {
			return jQuery.easing.easeInExpo(x, t, b, c, d);
		},
		expoout: function(x, t, b, c, d) {
			return jQuery.easing.easeOutExpo(x, t, b, c, d);
		},
		expoinout: function(x, t, b, c, d) {
			return jQuery.easing.easeInOutExpo(x, t, b, c, d);
		},
		bouncein: function(x, t, b, c, d) {
			return jQuery.easing.easeInBounce(x, t, b, c, d);
		},
		bounceout: function(x, t, b, c, d) {
			return jQuery.easing.easeOutBounce(x, t, b, c, d);
		},
		bounceinout: function(x, t, b, c, d) {
			return jQuery.easing.easeInOutBounce(x, t, b, c, d);
		},
		elasin: function(x, t, b, c, d) {
			return jQuery.easing.easeInElastic(x, t, b, c, d);
		},
		elasout: function(x, t, b, c, d) {
			return jQuery.easing.easeOutElastic(x, t, b, c, d);
		},
		elasinout: function(x, t, b, c, d) {
			return jQuery.easing.easeInOutElastic(x, t, b, c, d);
		},
		backin: function(x, t, b, c, d) {
			return jQuery.easing.easeInBack(x, t, b, c, d);
		},
		backout: function(x, t, b, c, d) {
			return jQuery.easing.easeOutBack(x, t, b, c, d);
		},
		backinout: function(x, t, b, c, d) {
			return jQuery.easing.easeInOutBack(x, t, b, c, d);
		}
	});



	

	// MR5 Accordion jQuery implementation
	var str = $('#accordion span').text();
	$('#accordion span').text('[+]');
	$('#accordion div').hide();
	$('#accordion span').click(function() {
		$('#accordion div').slideToggle('normal');
		$(this).text($(this).text() == '[+]' ? '[-]' : '[+]');
	});
	var str = $('#accordian span').text();
	$('#accordian span').text('[+]');
	$('#accordian div').hide();
	$('#accordian span').click(function() {
		$('#accordian div').slideToggle('normal');
		$(this).text($(this).text() == '[+]' ? '[-]' : '[+]');
	});

	// Check to see if there is an LSN or not, and append the appropriate class to #ContentBdy
	if ($('#mmmlsnwrap').length > 0) {
		$('#ContentBdy').addClass('lsn');
	} else {
		$('#ContentBdy').addClass('nolsn');
	};
	/* End 5MR Accordion */

	/* Start jCarousel */
	if ($('.mr6 #mmmjCarousel li').length >= 7 || $('.mr7 #mmmjCarousel li').length >= 7 || $('.sr10 #mmmjCarousel li').length >= 5 || $('.sr11 #mmmjCarousel li').length >= 5 || $('.carousel #mmmjCarousel li').length >= 5) {
		$('#mmmjCarousel').jcarousel({
			animation: 'slow',
			scroll: 1,
			wrap: 'circular'
		});
	} else {
		$('#mmmjCarousel').jcarousel();
	}
	if ($('.mr6 #mmmjCarousel li').length >= 6 || $('.mr7 #mmmjCarousel li').length >= 6 || $('.sr10 #mmmjCarousel li').length >= 4 || $('.sr11 #mmmjCarousel li').length >= 4 || $('.carousel #mmmjCarousel li').length >= 4) {
	} else {
		$('ul#mmmjCarousel').addClass('centerCarousel');
	};
	/* End jCarousel */

	/* Start dynamically appending .alpha, .omega, and .vertDivider to appropriate divs */
	/* Works in IE7 and IE8, too! */
	/*try {
	$('.of1_AB:nth-child(3n),.of2_AB:nth-child(3n),.of3_AB:nth-child(3n),.sr5:nth-child(3n),.sr6:nth-child(3n),.sr7:nth-child(3n),.of1_C:nth-child(2n),.of2_C:nth-child(2n),.of3_C:nth-child(2n)').addClass('omega');
	$('.of1_AB:nth-child(3n-2),.of2_AB:nth-child(3n-2),.of3_AB:nth-child(3n-2),.sr5:nth-child(3n-2),.sr6:nth-child(3n-2),.sr7:nth-child(3n-2),.of1_C:nth-child(2n-1),.of2_C:nth-child(2n-1),.of3_C:nth-child(2n-1)').addClass('alpha');
	$('.of1_AB:nth-child(3n),.of2_AB:nth-child(3n),.of3_AB:nth-child(3n),.sr5:nth-child(3n),.sr6:nth-child(3n),.sr7:nth-child(3n),.of1_AB:nth-child(3n-1),.of2_AB:nth-child(3n-1),.of3_AB:nth-child(3n-1),.sr5:nth-child(3n-1),.sr6:nth-child(3n-1),.sr7:nth-child(3n-1),.of1_C:nth-child(2n),.of2_C:nth-child(2n),.of3_C:nth-child(2n)').addClass('vertDivider');*/
	/* End dynamically appending .alpha, .omega, and .vertDivider to appropriate divs */
	/*}
	catch (e)
	{*/
		// suppress
	/*}*/
	/* Start jQuery Accordion Specifications */
 /*try {*/
	/* Start jQuery Accordion Specifications */
	/*if(!('.accordion3m' == 'undefined')){
	if(window.location.hash) {*/
		// Assume a hash tag is present to indicate a specific panel in the accordion is being targeted and do nothing
		// If a hash tag is present in the link for another purpose, any accordion on the page will default to having the first panel active on page load
		/*$('html, body').animate({
			scrollTop: $("h3.ui-state-active").offset().top
		}, 1000);
	} else {
		$('.sr4 .accordion3m,.mr4 .accordion3m').accordion({
			active: false,
			collapsible: true
		});
	}
	}
 }
    catch (e)
	{
		// suppress
	}

	$('.sr4 .accordion3m div p:last-child,.mr4 .accordion3m div p:last-child').addClass('closeAccordion');
	$('.sr4 .accordion3m div p:last-child,.mr4 .accordion3m div p:last-child').click(function () {
		$('.accordion3m').accordion('activate', false);
	});*/

	/* Start Bottom Tabs Functions */
	$('#componentTabs').tabs();
	$('#componentTabs .ui-tabs-nav li:last-child').css('border-right-width', '1px');
	var ulWidth = $('#componentTabs ul.ui-tabs-nav').width();
	if ($('#componentTabs .ui-tabs-nav li').length == 1) {
		alert('You must have more than one tab to use this component.')
	} else if ($('#componentTabs .ui-tabs-nav li').length == 2) {
		var liWidth = Math.floor(ulWidth/2);
		$('#componentTabs .ui-tabs-nav li').css('width',liWidth-1);
		$('#componentTabs .ui-tabs-nav li:first-child').css('width',liWidth);
		$('.ie9 #componentTabs .ui-tabs-nav li:first-child').css('width',liWidth-2);
		$('.ie9 #componentTabs .ui-tabs-nav li:first-child').css('width',liWidth-2);
		$('.ie7 #componentTabs .ui-tabs-nav li,.ie8 #componentTabs .ui-tabs-nav li').css('width',liWidth-2);
		$('.ie7 #componentTabs .ui-tabs-nav li:first-child,.ie8 #componentTabs .ui-tabs-nav li:first-child').css('width',liWidth-1);
	} else if ($('#componentTabs .ui-tabs-nav li').length == 3) {
		var liWidth = Math.round(ulWidth/3);
		$('#componentTabs .ui-tabs-nav li').css('width',liWidth-1);
		$('.ie7 #componentTabs .ui-tabs-nav li').css('width',liWidth-2);
	} else if ($('#componentTabs .ui-tabs-nav li').length == 4) {
		var liWidth = Math.floor(ulWidth/4);
		$('#componentTabs .ui-tabs-nav li').css('width',liWidth-1);
		$('#componentTabs .ui-tabs-nav li:first-child').css('width',liWidth);
		$('.ie7 #componentTabs .ui-tabs-nav li:first-child, .ie8 #componentTabs .ui-tabs-nav li:first-child').css('width',liWidth-2);
	} else if ($('#componentTabs .ui-tabs-nav li').length == 5) {
		var liWidth = Math.floor(ulWidth/5);
		$('#componentTabs .ui-tabs-nav li').css('width',liWidth-1);
		$('#componentTabs .ui-tabs-nav li:first-child').css('width',liWidth);
		$('.ie7 #componentTabs .ui-tabs-nav li:last-child, .ie8 #componentTabs .ui-tabs-nav li:last-child').css('width',liWidth+1);
	}
	
	 /* Metrics Tagging */
  $("#BnrRht a").click(function(){dcsMultiTrack('WT.cg_n','Segments Pages:'+document.title,'WT.cg_s','ATSbannerRight click: '+this.innerHTML,'DCS.dcsuri',window.location.pathname+'ATSbannerRightClick','WT.dl','99')});

 $("#CatDet a").click(function(){dcsMultiTrack('WT.cg_n','Segments Pages:'+document.title,'WT.cg_s','Category click: '+this.innerHTML+this.title,'DCS.dcsuri',window.location.pathname+'CategoryClick','WT.dl','99')});
 
 $("#CatDProd a").click(function(){dcsMultiTrack('WT.cg_n','Segments Pages:'+document.title,'WT.cg_s','Product click: '+this.innerHTML,'DCS.dcsuri',window.location.pathname+'ProductClick','WT.dl','99')});
 
 $("#Qcklink a").click(function(){dcsMultiTrack('WT.cg_n','Segments Pages:'+document.title,'WT.cg_s','Quick Links click: '+this.innerHTML,'DCS.dcsuri',window.location.pathname+'QuickLinksClick','WT.dl','99')}); 

 $("#BnrHero a").click(function(){dcsMultiTrack('WT.cg_n','Segments Pages:'+document.title,'WT.cg_s','Hero banner click: '+this.innerHTML,'DCS.dcsuri',window.location.pathname+'HeroBannerClick','WT.dl','99')}); 
 
 $("#TabClks a").click(function(){dcsMultiTrack('WT.cg_n','Segments Pages:'+document.title,'WT.cg_s','Tab click: '+this.id,'DCS.dcsuri',window.location.pathname+'TabClick','WT.dl','99')});


	/* Auto Show "Other" text field after "Other" is selected from a select box */

	// Initially hide #toggleDiv and add some CSS for aesthetics
	$('.toggleMe,.partNumToggle').hide().css('clear','left');
	// Toggle the div when the checkbox is selected/deselected
	$(".toggleSwitch").change(function(){
	//set the select value
		var val = $(this).val();
		if (val == 'Other') {
			$(this).next('.toggleMe').show().effect("highlight", {}, 4000);
			$(this).nextAll('.partNumToggle').hide();
		} else if (val == 'Part Number Desired') {
			$(this).nextAll('.partNumToggle').show().effect("highlight", {}, 4000);
			$(this).next('.toggleMe,.partNumToggle').hide();
		} else {
			$(this).next('.toggleMe,.partNumToggle').hide();
			$(this).nextAll('.partNumToggle').hide();
		}
	});
	
	/* Start Two Column List Functions */

	var colLength = $('.columned li').length;
	var colHeight = $('.columned').height();
	var liHeight = $('.columned li').height();
	if ($('.columned li').length % 3 != 0) {
			var third = (Math.round(colHeight / 3)) + liHeight / 1.2;
	} else {
			var third = Math.round(colHeight / 2);
	}
	var firstrow = Math.ceil(colLength / 3);
	var secondrow = firstrow +1;
	var thirdrow = Math.ceil((colLength / 3)*2)+2;
	var parentWidth = $('.columned').parent().width();
	$('.columned li:nth-child(-n+' + firstrow + ')').addClass('column1');
	$('.columned li:nth-child(n+' + secondrow + ')').addClass('column2');
	$('.columned li:nth-child(n+' + thirdrow + ')').addClass('column3');
	$('.columned li:nth-child(' + secondrow + ')').css('margin-top', -third);
	$('.columned li:nth-child(' + thirdrow + ')').css('margin-top', -third);

/* End Two Column List Functions */
	
	
	/* Start NPI Rollover Script */
	var navWidths = new Array();
	var totalNavWidth = 0;
	var navMaxWidth = 0;
	var npiWidth = $("#npiNav").width();
	
	$("#npiNav .navItem").each(function(){
		navWidths.push($(this).width());
		totalNavWidth += $(this).outerWidth(true);
		if($(this).width() > navMaxWidth) navMaxWidth = $(this).width();
	});
	while(totalNavWidth > npiWidth){
		for(i=0; i<navWidths.length; i++){
			if(navWidths[i] == navMaxWidth){
				navWidths[i] -= 1;
				totalNavWidth -= 1;
				$("#npiNav .navItem:eq(" + i + ")").width(navWidths[i]).css({"line-height": "20px"});
			}
		}
		navMaxWidth -= 1;
	}
		
	$("#npiNav .navItem").on("click", function(){
		$(".npiSlide").fadeOut(250);
		$("#" + $(this).attr("rel")).fadeIn(250);
		$("#npiNav .navItem").removeClass("navActive");
		$(this).addClass("navActive");
	});
	
	$("#npiRollover .hotspot").on("mouseenter", function(e){
		x = e.pageX - $(this).parents("#npiRollover").offset().left;
		y = e.pageY - $(this).parents("#npiRollover").offset().top;
		$("#npiRollover .tooltips ." + $(this).attr("id")).css({"top": y+15, "left": x+15}).fadeIn(250);
	}).on("mousemove", function(e){
		x = e.pageX - $(this).parents("#npiRollover").offset().left;
		y = e.pageY - $(this).parents("#npiRollover").offset().top;
		$("#npiRollover .tooltips ." + $(this).attr("id")).css({"top": y+15, "left": x+15, "display": "block"});
	}).on("mouseleave", function(){
		$("#npiRollover .tooltips ." + $(this).attr("id")).stop().fadeOut(250);
	});
	/* Checks to see if page is using variant of NPI Rollover Component */
	if ($("#npiIntro").attr("rel") === "variant"){
	$("#npiIntro.npiSlide").css("display", "none");
	$("#npiSlide1").css("display","block");
	$("#npiNav > .navItem:first").addClass("navActive");
	}
	/* /End Variant of NPI Rollover Component check*/

/* End NPI Rollover Script */


	//Each class "BcVidLink" that is contained in the ID "BcVidLink"
	// "domEle" is equal to "this"
	$(".BcVidLink").each(function (index, domEle) {
		//bind the click function to the openVideo function  and use the value in the rel attribute found in the <a> with class "BcVidLink"
		$(this).bind('click', function () {
			openVideo($(this).attr('rel'));
		});
	});
	
	
// Cleaned up Single Player

	//Each class "BcVidLink" that is contained in the ID "BcVidLink"
	// "domEle" is equal to "this"
	$(".SingleBcVidLink").each(function (index, domEle) {
		//bind the click function to the openVidSingle function  and use the value in the rel attribute found in the <a> with class "BcVidLink"
		$(this).bind('click', function () {
			openVidSingle($(this).attr('playerID'),$(this).attr('playerKey'),$(this).attr('playerVidId'));
		});
	});



// Playlist Player

	//Each class "BcPlaylistLink" that is contained in the ID "BcPlaylistLink"
	// "domEle" is equal to "this"
	$(".BcPlaylistLink").each(function (index, domEle) {
		//bind the click function to the openVideo function  and use the value in the rel attribute found in the <a> with class "BcPlaylistLink"
		$(this).bind('click', function () {
			openVidPlaylist($(this).attr('bcPlaylistID'),$(this).attr('bcPlaylistKey'));
		});
	});

/* End Brightcove/Colorbox JavaScript */

/* Start OH Converstion Events */

$('#psn #psn4').click(function(){
	$('a').click(function() {
	 dcsMultiTrack('WT.cg_n','Conversion events','WT.cg_s','Resources click','DCS.dcsuri',document.location+'ResourcesClick','WT.ti','ResourcesClick','WT.si_cs','1');
	 });
});

$('#psn #psn6').click(function(){
	$('a').click(function() {
	 dcsMultiTrack('WT.cg_n','Conversion events','WT.cg_s','Where to Buy - header','DCS.dcsuri',document.location+'WhereToBuyHeaderClick','WT.ti','Where to Buy - header click','WT.si_cs','1');
	 });
});

/* End OH Converstion Events */

 /* WTB Metrics Tagging */
 var lsnXformer =
{
 init: function()
 {
 // get all links:   
 try {
  var all_teaser_links = jQuery("a");   
  if (all_teaser_links[0]) 
   {
   for (i = 0, ii = all_teaser_links.length; i < ii; i++)
    {
    jQuery(all_teaser_links[i]).bind("click", lsnXformer.lsnLinkTracker);
    }
   } 
  }
 catch (error) { }
    
 },


    lsnLinkTracker: function(event)
 {
       // construct the Event Tracking Parameters and execute DCSMultitrack
     if(this.href == "http://solutions.3m.com/wps/portal/3M/en_US/3M-PPE-Safety-Solutions/Personal-Protective-Equipment/safety-equipment-support/?WT.ac=PSN-Support"){
   dcsMultiTrack('WT.cg_n','Engagement Events','WT.cg_s','Where to Buy click - PSN - Support Menu','WT.dl','99','DCS.dcsuri',window.location.pathname+'WhereToBuyClick-PSN-SupportMenu');
   }
  else if(this.href == "http://solutions.3m.com/wps/portal/3M/en_US/3M-PPE-Safety-Solutions/Personal-Protective-Equipment/safety-equipment-support/buy-safety-equipment/?WT.ac=PSN-Secondary-WTB"){
   dcsMultiTrack('WT.cg_n','Engagement Events','WT.cg_s','Where to Buy click - PSN - Secondary Link','WT.dl','99','DCS.dcsuri',window.location.pathname+'WhereToBuyClick-PSN-SecondaryLink');
   }   
 }
}

lsnXformer.init();

}); /* end Doc.ready */

$(window).load(function(){
	// Dynamically set height of the components with vertical divider lines
	//$('#componentTabs').css('height',$(this).height());
	$('.vertDivWrapper').equalHeights();
	// #componentTabs jQuery Code
	$('#componentTabs .ui-tabs-nav').equalHeights();
	var compTabLinkHeight = $('#componentTabs .ui-tabs-nav').height();
	var compTabListPaddingLeft = $('#componentTabs .ui-tabs-nav li a').css("padding-left");
	var compTabListPaddingRight = $('#componentTabs .ui-tabs-nav li a').css("padding-right");
	var compTabListPadding = parseInt(compTabListPaddingLeft) + parseInt(compTabListPaddingRight);
	var compTabLinkWidth = $('#componentTabs .ui-tabs-nav li').width() - compTabListPadding;
	$('#componentTabs .ui-tabs-nav li a').css('height',compTabLinkHeight).css('width',compTabLinkWidth);
	// Let's see if this works!
	var compTabDivPaddingTop = $('#componentTabs div').css("padding-top");
	var compTabDivPaddingBottom = $('#componentTabs div').css("padding-bottom");
	var compTabDivPaddingPlus = parseInt(compTabDivPaddingTop) + parseInt(compTabDivPaddingBottom) + compTabLinkHeight;
	$('#componentTabs div').css('height',$('#componentTabs').height()-compTabDivPaddingPlus);
	//var getHeight = $('#componentTabs div').height();
	//var addHeight = getHeight + compTabLinkHeight + 50;
	//$('#componentTabs div').css('height',addHeight);
	// #topTabs
	// Dynamically set height and width of anchor tags based on list item height and width
	var topTabsULWidth = $('#topTabs .ui-tabs-nav').width();
	var topTabsCount = $('#topTabs .ui-tabs-nav li').length;
	var topTabsAdjustCount = Math.ceil(topTabsULWidth / (topTabsCount+0.5));
	var marginAdjust = parseInt($('#topTabs .ui-tabs-nav li').css('margin-right')) * topTabsCount;
	$('#topTabs .ui-tabs-nav li').css('width',topTabsAdjustCount)-marginAdjust;
	$('#topTabs .ui-tabs-nav ul').css('height',$(this).height());
	$('#topTabs .ui-tabs-nav').equalHeights();
	// Adjust <a> tag to fit within the <li> tag
	var topTabsTop = parseInt($('#topTabs .ui-tabs-nav li a').css('padding-top'));
	var topTabsBottom = parseInt($('#topTabs .ui-tabs-nav li a').css('padding-bottom'));
	var topTabsTopBottom = topTabsTop + topTabsBottom;
	var topTabsListHeight = $('#topTabs .ui-tabs-nav li').height() - topTabsTopBottom;
	var topTabsRight = parseInt($('#topTabs .ui-tabs-nav li a').css('padding-right'));
	var topTabsLeft = parseInt($('#topTabs .ui-tabs-nav li a').css('padding-left'));
	var topTabsRightLeft = topTabsRight + topTabsLeft;
	var topTabsListWidth = $('#topTabs .ui-tabs-nav li').width()-topTabsRightLeft;
	$('#topTabs .ui-tabs-nav li a').css('height',topTabsListHeight).css('width',topTabsListWidth);
});



/* Start Right Column Image Padding
$().ready(function(){
	if ($('.rc img').width() < 180) {
		//$('.rc img').css('margin-right','8px');
		//var rrrrr = $('.rc img').css('margin-right','8px');
		console.log('True');
	}​
});*/

/* End Right Column Image Padding */

/* Start Brightcove/Colorbox JavaScript */

var bcParam_width = 480;
var bcParam_height = 270;

function openVideo(vidID) {
	// use variable myPlayer to build the <object> Brightcove player.
	var myPlayer = '';
	myPlayer += '<object id="myExperience1443343911001" class="BrightcoveExperience">';
	myPlayer += '<param name="bgcolor" value="#FFFFFF" />';
	myPlayer += '<param name="width" value="' + bcParam_width + '" />';
	myPlayer += '<param name="height" value="' + bcParam_height + '" />';
	myPlayer += '<param name="playerID" value="1235504373001" />';
	myPlayer += '<param name="playerKey" value="AQ~~,AAABHqwijIE~,eE4mETXuXRWqMvjV8f5v-VS6K54F56fV" />';
	myPlayer += '<param name="isVid" value="true" />';
	myPlayer += '<param name="isUI" value="true" />';
	myPlayer += '<param name="dynamicStreaming" value="true" />';
	myPlayer += '<param name="@videoPlayer" value="' + vidID + '" />';
	myPlayer += '</object>';

	//Colorbox which calls 2 variables 'bcParam_width' and 'bcParam_height' to set the width and height of the colorbox video.
	$.colorbox({
		inline: true,
		href: myPlayer,
		title: true,
		current: "colorbox {current} of {total}",
		innerWidth: ((bcParam_width) + 5),
		innerHeight: ((bcParam_height) + 5),
		transition: 'none'
	});

	//Function provided by Brightcove
	brightcove.createExperiences();
}

// Alternate open video function (uses a different player ID and key)
function openVid(videoID){
	// use variable myPlayer to build the <object> Brightcove player.
	var myPlayer = '';
	myPlayer += '<object id="myExperience" class="BrightcoveExperience">';
	myPlayer += '<param name="bgcolor" value="#FFFFFF" />';
	myPlayer += '<param name="width" value="' + bcParam_width + '" />';
	myPlayer += '<param name="height" value="' + bcParam_height + '" />';
	myPlayer += '<param name="playerID" value="1252795092001" />';
	myPlayer += '<param name="playerKey" value="AQ~~,AAABIWNGTGE~,IU-09lzChCVW9Yhp7Q5jYk6hAREjx5TI" />';
	myPlayer += '<param name="isVid" value="true" />';
	myPlayer += '<param name="isUI" value="true" />';
	myPlayer += '<param name="dynamicStreaming" value="true" />';
	myPlayer += '<param name="@videoPlayer" value="' + videoID + '" />';
	myPlayer += '</object>';
	//Colorbox which calls 2 variables 'bcParam_width' and 'bcParam_height' to set the width and height of the colorbox video.
	$.colorbox({
		inline: true,
		href: myPlayer,
		title: true,
		current: "colorbox {current} of {total}",
		innerWidth: ((bcParam_width) + 5),
		innerHeight: ((bcParam_height) + 5),
		transition: 'none'
	});
	//Function provided by Brightcove
	brightcove.createExperiences();
}

// Cleaned up Single Player
var bc_width = 486;
var bc_height = 412;
//For the single player on the NPI page
function openVidSingle(playerID,playerKey, playerVidId){
	// use variable myPlayer to build the <object> Brightcove player.
	var myPlayer = '';
	myPlayer += '<object id="myExperience" class="BrightcoveExperience">';
	myPlayer += '<param name="bgcolor" value="#FFFFFF" />';
	myPlayer += '<param name="width" value="' + bc_width + '" />';
	myPlayer += '<param name="height" value="' + bc_height + '" />';
	myPlayer += '<param name="playerID" value="' + playerID + '" />';
	myPlayer += '<param name="playerKey" value="' + playerKey + '" />';
	myPlayer += '<param name="isVid" value="true" />';
	myPlayer += '<param name="isUI" value="true" />';
	myPlayer += '<param name="dynamicStreaming" value="true" />';
	myPlayer += '<param name="@videoPlayer" value="' + playerVidId + '" />';
	myPlayer += '<param name="autoStart" value="true" />';
	myPlayer += '</object>';
	//Colorbox which calls 2 variables 'bcParam_width' and 'bcParam_height' to set the width and height of the colorbox video.
	$.colorbox({
		inline: true,
		href: myPlayer,
		title: true,
		current: "colorbox {current} of {total}",
		innerWidth: ((bc_width) + 5),
		innerHeight: ((bc_height) + 5),
		transition: 'none'
	});
	//Function provided by Brightcove
	brightcove.createExperiences();
}

//For the playlist player on the NPI page
var bcParam_playlistWidth = 960;
var bcParam_playlistHeight = 445;

function openVidPlaylist(playlistID,playlistKey){
	// use variable myPlayer to build the <object> Brightcove player.
	var myPlayer = '';
	myPlayer += '<object id="myExperience" class="BrightcoveExperience">';
	myPlayer += '<param name="bgcolor" value="#FFFFFF" />';
	myPlayer += '<param name="width" value="' + bcParam_playlistWidth + '" />';
	myPlayer += '<param name="height" value="' + bcParam_playlistHeight + '" />';
	myPlayer += '<param name="playerID" value="' + playlistID + '" />';
	myPlayer += '<param name="playerKey" value="' + playlistKey + '" />';
	myPlayer += '<param name="isVid" value="true" />';
	myPlayer += '<param name="isUI" value="true" />';
	myPlayer += '<param name="dynamicStreaming" value="true" />';
	myPlayer += '</object>';		
	
	//Colorbox which calls 2 variables 'bcParam_width' and 'bcParam_height' to set the width and height of the colorbox video.
	$.colorbox({
		inline: true,
		href: myPlayer,
		title: true,
		current: "colorbox {current} of {total}",
		innerWidth: ((bcParam_playlistWidth) + 5),
		innerHeight: ((bcParam_playlistHeight) + 5),
		transition: 'none'
	});

	//Function provided by Brightcove
	brightcove.createExperiences();
}


/* Start Google+ JS */

// GOOGLE PLUS button for the PoW Product Catalog. Place this render call where appropriate
(function() {
	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();

/* End Google+ JS */



/* Start NPI Rollover - showNav() Script */
function showNav(){
	$(".npiSlide").fadeOut(250);
	$("#npiSlide1").fadeIn(250);
}
/* End NPI Rollover showNav() Script */
