$(document).ready(function(){

	//globals ************************************************
	// - declare IE6, or not. (declared in /js/ie6.js)
	IE6 = (typeof IE6 == 'undefined') ? false : true;


	//#nav - keep hover class on sub menu expand ************************
	$('li:has("ul")', '#nav').each(function(){
		$(this).children('ul').hover(
			function () {
				$(this).parent('li').children('a').addClass('subnav-hover');
			},
			function () {
				$(this).parent('li').children('a').removeClass('subnav-hover');
			}
		);
	});


	//tabs ************************************************
	$('div.tabs').each(function(index) {

		var tabsContainer = $(this);

		//apply style to tab group - for js-enabled users only *****
		$(this).addClass('tabs-container');

		//make the tab nav - h2 titles make the nav li's *****
		var nav = "<ul class='tabs-nav'>";
		var title = null;
		$('.tab-item', $(this)).each(function(index) {
			title = $(this).children('h2').attr('title');
			$(this).attr('title', title); //set the title of the div so we can link it with the click event
			nav += "<li class='"+$(this).children('h2').attr('className')+"'><a href='#' rel='"+ title +"'><span>"+ title +"</span></a></li>\n";
		});
		nav += "</ul>";
		nav += "<div class='clear'></div>";
		$(this).prepend(nav); //add the nav list


		//remove any hr/br seperators outside the tab-item div elements, they only existed for js-disabled users *********
		$('.tab-item', $(this)).siblings('hr,br').remove();

		//remove the h2 elements
		$('.tab-item', $(this)).children('h2').remove();

		//click function for tabs-nav ***************
		$('ul.tabs-nav a', $(this)).live('click', function() {
			$('.tab-item', $(tabsContainer)).hide(); //hide all tab items
			$('div[title="'+ $(this).attr('rel') +'"]', $(tabsContainer)).show(); //show this tab item
			$('.tabs-nav a', $(tabsContainer)).removeClass('tabs-nav-selected'); //remove selected class from all tabs-nav
			$(this).addClass('tabs-nav-selected');
			return false;
		});

		$('li:eq(0) a', 'ul.tabs-nav').trigger('click');

	});


	//products-index-list ************************************************
	$('li', 'ul.products-index-list').each(function(index) {
		var link = $('a:eq(0)', this);
		$(this).css('cursor', 'pointer');
		$(this).attr('title', 'Click to view '+link.text());
		$(this).click(function() {
			window.location.href = link.attr('href');
		});
	});


	//show/hide any container. Use rel='show-hide' in a link, and use the title tag to specify the ID of the box to hide/show. ************************
	$('a[rel=show-hide]').each(function (event) {
		$($(this).attr("href")).hide(); //hide with js (not css), so non-js browsers will see the content
	}).click(function (event) {
		$($(this).attr("href")).slideToggle(400);
		return false;
	});

	//email nospam ************************
	$('a.email').nospam({replaceText: true, filterLevel: 'low'});

	//defaultValue ************************
	$('#nav-search-text').clearDefault();
	$('#google-search-form input:text').clearDefault();

	//external links ************************
	$('a[rel*=external]').click( function() { window.open(this.href); return false; });

	//external target on forms ************************
	$('form._blank').submit(function() { this.target = '_blank'; });

	//go to top of page ************************
    $('a[href=#top]').click(function() {$('html, body').animate({scrollTop:0}, 400); return false; });




});

/* Functions
-------------------------------------------------------------- */
//defaultValue for inputs
(function($){
	$.fn.clearDefault = function(){
		return this.each(function(){
			var default_value = $(this).val();
			$(this).focusin(function(){
				if ($(this).val() == default_value) { $(this).val(""); }
			}).focusout(function(){
				if ($.trim($(this).val()) == "") { $(this).val(default_value); }
			});
		});
	};
})(jQuery);

/* Plugins
-------------------------------------------------------------- */
// http://www.leftrightdesigns.com/library/jquery/nospam/ - nospam plugin
jQuery.fn.nospam=function(settings){settings=jQuery.extend({replaceText:false,filterLevel:'normal'},settings);return this.each(function(){e=null;if(settings.filterLevel=='low'){if($(this).is('a[rel]')){e=$(this).attr('rel').replace('//','@').replace(/\//g,'.');}else{e=$(this).text().replace('//','@').replace(/\//g,'.');}}else{if($(this).is('a[rel]')){e=$(this).attr('rel').split('').reverse().join('').replace('//','@').replace(/\//g,'.');}else{e=$(this).text().split('').reverse().join('').replace('//','@').replace(/\//g,'.');}} if(e){if($(this).is('a[rel]')){$(this).attr('href','mailto:'+e);if(settings.replaceText){$(this).text(e);}}else{$(this).text(e);}}});};

// http://malsup.com/jquery/block/ - jQuery blockUI plugin  Version 2.33 (29-MAR-2010)
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}(';(h($){7(/1\\.(0|1|2)\\.(0|1|2)/.1v($.R.1b)||/^1.1/.1v($.R.1b)){3e(\'d 3c 1I 3b.2.3 3g 3j!  3h 3k 32 v\'+$.R.1b);J}$.R.1W=$.R.16;a 1O=h(){};a 1P=r.39||0;a 2w=$.Q.1a&&(($.Q.31<8&&!1P)||1P<8);a 1Y=$.Q.1a&&/38 6.0/.1v(2k.3C)&&!1P;$.d=h(5){22(Z,5)};$.2X=h(5){1H(Z,5)};$.2B=h(1e,O,I,2S){a $m=$(\'<g E="2B"></g>\');7(1e)$m.1N(\'<1J>\'+1e+\'</1J>\');7(O)$m.1N(\'<2A>\'+O+\'</2A>\');7(I==1M)I=3A;$.d({O:$m,16:3u,P:2i,1q:19,I:I,Y:19,1B:2S,n:$.d.U.2Y})};$.R.3o=h(5){J w.2c({P:0}).1j(h(){7($.n(w,\'B\')==\'3q\')w.u.B=\'3r\';7($.Q.1a)w.u.3x=1;22(w,5)})};$.R.2c=h(5){J w.1j(h(){1H(w,5)})};$.d.31=2.33;$.d.U={O:\'<1J>3p 1X...</1J>\',1e:17,1L:G,1f:19,n:{1Q:0,28:0,V:\'30%\',C:\'40%\',12:\'35%\',3t:\'25\',2x:\'#27\',13:\'3z 3w #3l\',29:\'#2r\',1V:\'1X\'},1y:{V:\'30%\',C:\'40%\',12:\'35%\'},1A:{29:\'#27\',2b:0.6,1V:\'1X\'},2Y:{V:\'34\',C:\'1w\',12:\'\',36:\'1w\',13:\'K\',1Q:\'3i\',2b:0.6,1V:\'3y\',2x:\'#2r\',29:\'#27\',\'-3s-13-2d\':\'1w\',\'-3m-13-2d\':\'1w\',\'13-2d\':\'1w\'},2v:/^3B/i.1v(Z.3v.37||\'\')?\'3a:19\':\'3f:3d\',1C:19,2u:2i,2T:G,1q:G,2s:G,2E:G,2I:G,16:3n,P:3L,I:0,Y:G,2z:G,2q:G,1o:17,1B:17,2f:4};a T=17;a 11=[];h 22(c,5){a j=(c==Z);a k=5&&5.O!==1M?5.O:1M;5=$.1s({},$.d.U,5||{});5.1A=$.1s({},$.d.U.1A,5.1A||{});a n=$.1s({},$.d.U.n,5.n||{});a 1y=$.1s({},$.d.U.1y,5.1y||{});k=k===1M?5.O:k;7(j&&T)1H(Z,{P:0});7(k&&2G k!=\'42\'&&(k.14||k.1b)){a 15=k.1b?k[0]:k;a f={};$(c).f(\'d.2a\',f);f.c=15;f.1p=15.14;f.F=15.u.F;f.B=15.u.B;7(f.1p)f.1p.2R(15)}a z=5.2u;a 1r=($.Q.1a||5.1C)?$(\'<2l E="d" u="z-18:\'+(z++)+\';F:K;13:K;28:0;1Q:0;B:1l;V:1h%;1k:1h%;C:0;12:0" 43="\'+5.2v+\'"></2l>\'):$(\'<g E="d" u="F:K"></g>\');a W=$(\'<g E="d 45" u="z-18:\'+(z++)+\';F:K;13:K;28:0;1Q:0;V:1h%;1k:1h%;C:0;12:0"></g>\');a A,s;7(5.1f&&j){s=\'<g E="d 1x 2g q-X q-S q-2p-2m" u="z-18:\'+z+\';F:K;B:1T">\'+\'<g E="q-S-2t q-X-1Z 2y">\'+(5.1e||\'&2e;\')+\'</g>\'+\'<g E="q-S-1g q-X-1g"></g>\'+\'</g>\'}H 7(5.1f){s=\'<g E="d 1x 2h q-X q-S q-2p-2m" u="z-18:\'+z+\';F:K;B:1l">\'+\'<g E="q-S-2t q-X-1Z 2y">\'+(5.1e||\'&2e;\')+\'</g>\'+\'<g E="q-S-1g q-X-1g"></g>\'+\'</g>\'}H 7(j){s=\'<g E="d 1x 2g" u="z-18:\'+z+\';F:K;B:1T"></g>\'}H{s=\'<g E="d 1x 2h" u="z-18:\'+z+\';F:K;B:1l"></g>\'}A=$(s);7(k){7(5.1f){A.n(1y);A.41(\'q-S-1g\')}H A.n(n)}7(!5.2q||!($.Q.3Z&&/3W/.1v(2k.3X)))W.n(5.1A);W.n(\'B\',j?\'1T\':\'1l\');7($.Q.1a||5.1C)1r.n(\'2b\',0.0);a 2o=[1r,W,A],$2n=j?$(\'L\'):$(c);$.1j(2o,h(){w.3Y($2n)});7(5.1f&&5.1L&&$.R.1L){A.1L({44:\'.q-X-1Z\',4a:\'48\'})}a 2j=2w&&(!$.1z||$(\'47,46\',j?17:c).1t>0);7(1Y||2j){7(j&&5.2s&&$.1z)$(\'49,L\').n(\'1k\',\'1h%\');7((1Y||!$.1z)&&!j){a t=1n(c,\'2L\'),l=1n(c,\'2K\');a 24=t?\'(0 - \'+t+\')\':0;a 26=l?\'(0 - \'+l+\')\':0}$.1j([1r,W,A],h(i,o){a s=o[0].u;s.B=\'1l\';7(i<2){j?s.M(\'1k\',\'3U.3J(r.L.3K, r.L.1i) - (1I.1z?0:\'+5.2f+\') + "N"\'):s.M(\'1k\',\'w.14.1i + "N"\');j?s.M(\'V\',\'1I.1z && r.1d.2D || r.L.2D + "N"\'):s.M(\'V\',\'w.14.21 + "N"\');7(26)s.M(\'12\',26);7(24)s.M(\'C\',24)}H 7(5.1q){7(j)s.M(\'C\',\'(r.1d.2W || r.L.2W) / 2 - (w.1i / 2) + (3I = r.1d.1c ? r.1d.1c : r.L.1c) + "N"\');s.3D=0}H 7(!5.1q&&j){a C=(5.n&&5.n.C)?2M(5.n.C):0;a 2Z=\'((r.1d.1c ? r.1d.1c : r.L.1c) + \'+C+\') + "N"\';s.M(\'C\',2Z)}})}7(k){7(5.1f)A.3H(\'.q-S-1g\').1N(k);H A.1N(k);7(k.1b||k.3E)$(k).1E()}7(($.Q.1a||5.1C)&&5.Y)1r.1E();7(5.16){a 1U=5.1o?5.1o:1O;a 2U=(5.Y&&!k)?1U:1O;a 2V=k?1U:1O;7(5.Y)W.1W(5.16,2U);7(k)A.1W(5.16,2V)}H{7(5.Y)W.1E();7(k)A.1E();7(5.1o)5.1o()}1D(1,c,5);7(j){T=A[0];11=$(\':3F:3G:3V\',T);7(5.2z)1F(1K,20)}H 25(A[0],5.2T,5.1q);7(5.I){a 1m=1F(h(){j?$.2X(5):$(c).2c(5)},5.I);$(c).f(\'d.I\',1m)}};h 1H(c,5){a j=(c==Z);a $c=$(c);a f=$c.f(\'d.2a\');a 1m=$c.f(\'d.I\');7(1m){3M(1m);$c.2F(\'d.I\')}5=$.1s({},$.d.U,5||{});1D(0,c,5);a D;7(j)D=$(\'L\').2O().2N(\'.d\').3S(\'L > .d\');H D=$(\'.d\',c);7(j)T=11=17;7(5.P){D.P(5.P);1F(h(){23(D,f,5,c)},5.P)}H 23(D,f,5,c)};h 23(D,f,5,c){D.1j(h(i,o){7(w.14)w.14.2R(w)});7(f&&f.c){f.c.u.F=f.F;f.c.u.B=f.B;7(f.1p)f.1p.3T(f.c);$(c).2F(\'d.2a\')}7(2G 5.1B==\'h\')5.1B(c,5)};h 1D(b,c,5){a j=c==Z,$c=$(c);7(!b&&(j&&!T||!j&&!$c.f(\'d.2H\')))J;7(!j)$c.f(\'d.2H\',b);7(!5.2E||(b&&!5.Y))J;a 1S=\'3R 3Q 3N 3O\';b?$(r).1D(1S,5,1R):$(r).3P(1S,1R)};h 1R(e){7(e.2C&&e.2C==9){7(T&&e.f.2I){a D=11;a 2P=!e.2J&&e.1G==D[D.1t-1];a 1u=e.2J&&e.1G==D[0];7(2P||1u){1F(h(){1K(1u)},10);J 19}}}7($(e.1G).2Q(\'g.1x\').1t>0)J G;J $(e.1G).2Q().2O().2N(\'g.d\').1t==0};h 1K(1u){7(!11)J;a e=11[1u===G?11.1t-1:0];7(e)e.1K()};h 25(c,x,y){a p=c.14,s=c.u;a l=((p.21-c.21)/2)-1n(p,\'2K\');a t=((p.1i-c.1i)/2)-1n(p,\'2L\');7(x)s.12=l>0?(l+\'N\'):\'0\';7(y)s.C=t>0?(t+\'N\'):\'0\'};h 1n(c,p){J 2M($.n(c,p))||0}})(1I);',62,259,'|||||opts||if|||var||el|blockUI||data|div|function||full|msg|||css|||ui|document|||style||this||||lyr3|position|top|els|class|display|true|else|timeout|return|none|body|setExpression|px|message|fadeOut|browser|fn|widget|pageBlock|defaults|width|lyr2|dialog|showOverlay|window||pageBlockEls|left|border|parentNode|node|fadeIn|null|index|false|msie|jquery|scrollTop|documentElement|title|theme|content|100|offsetHeight|each|height|absolute|to|sz|onBlock|parent|centerY|lyr1|extend|length|back|test|10px|blockMsg|themedCSS|boxModel|overlayCSS|onUnblock|forceIframe|bind|show|setTimeout|target|remove|jQuery|h1|focus|draggable|undefined|append|noOp|mode|padding|handler|events|fixed|cb|cursor|_fadeIn|wait|ie6|titlebar||offsetWidth|install|reset|fixT|center|fixL|000|margin|backgroundColor|history|opacity|unblock|radius|nbsp|quirksmodeOffsetHack|blockPage|blockElement|1000|expr|navigator|iframe|all|par|layers|corner|applyPlatformOpacityRules|fff|allowBodyStretch|header|baseZ|iframeSrc|setExpr|color|blockTitle|focusInput|h2|growlUI|keyCode|clientWidth|bindEvents|removeData|typeof|isBlocked|constrainTabKey|shiftKey|borderLeftWidth|borderTopWidth|parseInt|filter|children|fwd|parents|removeChild|onClose|centerX|cb1|cb2|clientHeight|unblockUI|growlCSS|expression||version|using||350px||right|href|MSIE|documentMode|javascript|v1|requires|blank|alert|about|or|You|5px|later|are|aaa|moz|200|block|Please|static|relative|webkit|textAlign|700|location|solid|zoom|default|3px|3000|https|userAgent|marginTop|nodeType|input|enabled|find|blah|max|scrollHeight|400|clearTimeout|keydown|keypress|unbind|mouseup|mousedown|add|appendChild|Math|visible|Linux|platform|appendTo|mozilla||addClass|string|src|handle|blockOverlay|embed|object|li|html|cancel'.split('|'),0,{}))

// http://flesler.blogspot.com/2007/10/jqueryscrollto.html
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
