

;(function(){var $$;$$=jQuery.fn.flash=function(htmlOptions,pluginOptions,replace,update){var block=replace||$$.replace;pluginOptions=$$.copy($$.pluginOptions,pluginOptions);if(!$$.hasFlash(pluginOptions.version)){if(pluginOptions.expressInstall&&$$.hasFlash(6,0,65)){var expressInstallOptions={flashvars:{MMredirectURL:location,MMplayerType:'PlugIn',MMdoctitle:jQuery('title').text()}};}else if(pluginOptions.update){block=update||$$.update;}else{return this;}}htmlOptions=$$.copy($$.htmlOptions,expressInstallOptions,htmlOptions);return this.each(function(){block.call(this,$$.copy(htmlOptions));});};$$.copy=function(){var options={},flashvars={};for(var i=0;i<arguments.length;i++){var arg=arguments[i];if(arg==undefined)continue;jQuery.extend(options,arg);if(arg.flashvars==undefined)continue;jQuery.extend(flashvars,arg.flashvars);}options.flashvars=flashvars;return options;};$$.hasFlash=function(){if(/hasFlash\=true/.test(location))return true;if(/hasFlash\=false/.test(location))return false;var pv=$$.hasFlash.playerVersion().match(/\d+/g);var rv=String([arguments[0],arguments[1],arguments[2]]).match(/\d+/g)||String($$.pluginOptions.version).match(/\d+/g);for(var i=0;i<3;i++){pv[i]=parseInt(pv[i]||0);rv[i]=parseInt(rv[i]||0);if(pv[i]<rv[i])return false;if(pv[i]>rv[i])return true;}return true;};$$.hasFlash.playerVersion=function(){try{try{var axo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');try{axo.AllowScriptAccess='always';}catch(e){return'6,0,0';}}catch(e){}return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g,',').match(/^,?(.+),?$/)[1];}catch(e){try{if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){return(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1];}}catch(e){}}return'0,0,0';};$$.htmlOptions={flashvars:{},pluginspage:'http://www.adobe.com/go/getflashplayer',src:'#',type:'application/x-shockwave-flash'};$$.pluginOptions={expressInstall:false,update:true,version:'6.0.65'};$$.replace=function(htmlOptions){this.innerHTML='<div class="alt">'+this.innerHTML+'</div>';jQuery(this).addClass('flash-replaced').prepend($$.transform(htmlOptions));};$$.update=function(htmlOptions){var url=String(location).split('?');url.splice(1,0,'?hasFlash=true&');url=url.join('');var msg='<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="'+url+'">Click here.</a></p>';this.innerHTML='<span class="alt">'+this.innerHTML+'</span>';jQuery(this).addClass('flash-update').prepend(msg);};function toAttributeString(){var s='';for(var key in this)if(typeof this[key]!='function')s+=key+'="'+this[key]+'" ';return s;};function toFlashvarsString(){var s='';for(var key in this)if(typeof this[key]!='function')s+=key+'='+encodeURIComponent(this[key])+'&';return s.replace(/&$/,'');};$$.transform=function(htmlOptions){htmlOptions.toString=toAttributeString;if(htmlOptions.flashvars)htmlOptions.flashvars.toString=toFlashvarsString;return'<embed '+String(htmlOptions)+'/>';};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}})();

/** jquery sifr embedding **/
jQuery.fn.sifr=function(prefs){var p=jQuery.extend((prefs===false)?{unsifr:true}:{},arguments.callee.prefs,prefs);if(p.save){arguments.callee.prefs=jQuery.extend(p,{save:false});}if(this[0]===document){return;}if(!p.unsifr&&typeof p.before==='function'){p.before.apply(this,[p]);}this.each(function(){var t=jQuery(this);var a=t.children('.sIFR-alternate');if(a){t.html(a.html());if(p.unsifr){return;}}if(typeof p.beforeEach==='function'){p.beforeEach.apply(this,[t,p]);}var s=t.html('<span class="flash-replaced sIFR-replaced">'+(p.content||t.html()).replace(/^\s+|\s+$/g,'')+'</span>').children();a=t.append('<span class="alt sIFR-alternate">'+s.html()+'</span>').children('.sIFR-alternate');if(a.css('display')!=='none'){a.css('display','none');}var toHex=function(c){var h=function(n){if(n===0||isNaN(n)){return'00';}n=Math.round(Math.min(Math.max(0,n),255));return'0123456789ABCDEF'.charAt((n-n%16)/16)+'0123456789ABCDEF'.charAt(n%16);};c=(c)?c.replace(/rgb|\(|\)|#$/g,''):false;if(!c){return false;}if(c.indexOf(',')>-1){c=c.split(', ');return'#'+h(c[0])+h(c[1])+h(c[2]);}if(c.search('#')>-1&&c.length<=4){c=c.split('');return'#'+c[1]+c[1]+c[2]+c[2]+c[3]+c[3];}return c;};if(p.textTransform){if(p.textTransform.toLowerCase()==='uppercase'){s.html(s.html().toUpperCase());}if(p.textTransform.toLowerCase()==='lowercase'){s.html(s.html().toLowerCase());}if(p.textTransform.toLowerCase()==='capitalize'){var c=s.html().replace(/\>/g,'> ').split(' ');for(var i=0;i<c.length;i=i+1){c[i]=c[i].charAt(0).toUpperCase()+c[i].substring(1);}s.html(c.join(' ').replace(/\> /g,'>'));}}var f={flashvars:jQuery.extend({h:s.height()*(p.zoom||1),offsetLeft:p.offsetLeft||undefined,offsetTop:p.offsetTop||undefined,textAlign:p.textAlign||(/(left|center|right)/.exec(t.css('textAlign'))||['center'])[0],textColor:toHex(p.color||t.css('color'))||undefined,txt:p.content||s.html(),underline:(p.underline||(p.underline!==false&&t.css('textDecoration')==='underline'))?true:undefined,w:(p.width||s.width())*(p.zoom||1)},p.flashvars),height:p.height||s.height(),src:(p.path||'')+((p.path&&p.path.substr(p.path.length-1)!=='/')?'/':'')+(p.font||'')+((p.font&&p.font.indexOf('.swf')===-1)?'.swf':''),width:p.width||s.width(),wmode:'transparent'};f.flashvars.linkColor=toHex(p.link||t.find('a').css('color'))||f.flashvars.textColor;f.flashvars.hoverColor=toHex(p.hover)||f.flashvars.linkColor;if(p.zoom){f.flashvars.offsetTop=((p.offsetTop||0)+((s.height()-(s.height()*p.zoom))/2))*(p.zoomTop||1);f.flashvars.offsetLeft=((p.offsetLeft||0)+((s.width()-(s.width()*p.zoom))/2))*(p.zoomLeft||1);}t.flash(jQuery.extend(f,p.embedOptions),jQuery.extend({expressInstall:p.expressInstall||false,version:p.version||7,update:p.update||false},p.pluginOptions),function(f){var preHeight=t.height();var preWidth=t.width();s.html(jQuery.fn.flash.transform(f));var e=s.find(':first');e.css({verticalAlign:'text-bottom',display:'inline',width:p.width,height:p.height});var marginBottom=preHeight-t.height();var width=parseInt(e.css('width'),10)+parseInt(preWidth-t.width(),10);if(!p.height){e.css({marginBottom:marginBottom});}if(!p.width){e.css({width:width});}if(p.height&&p.verticalAlign==='middle'){e.css({marginTop:Math.floor((p.height-s.height())/2),marginBottom:Math.round((p.height-s.height())/2),height:s.height()});e.attr('height',s.height());}if(p.height&&p.verticalAlign==='bottom'){var a=t.find('.sIFR-alternate');e.css({marginTop:(p.height-s.height()),height:s.height()});e.attr('height',s.height());}if(p.css){e.css(p.css);}});if(typeof p.afterEach==='function'){p.afterEach.apply(this,[t,p]);}});if(!p.unsifr&&typeof p.after==='function'){p.after.apply(this,[p]);}};jQuery.sifr=function(prefs){jQuery().sifr(jQuery.extend({save:true},prefs));};jQuery.fn.unsifr=function(){return this.each(function(){jQuery(this).sifr(false);});};


/* tabulate */
(function($){   
 $.fn.tabulate = function(opts) {  
    var defaults = {  
		cell_selector:'.Item',
		table_width:0,
		cell_width:0
    };   
    var o = $.extend(defaults, opts);  
    return this.each(function() { 
		var selfref=$(this);		
        var cells = $(o.cell_selector,selfref).css({'float':'left','display':'block'});
		var availableW;
		if(o.table_width > 0){availableW = o.table_width;}else{availableW = selfref.innerWidth()}
		var cellW;
		if(o.cell_width > 0){cellW = o.cell_width;}else{cellW = cells.outerWidth();}	
		var cols = Math.floor(availableW/cellW);
		
		if(cols < 1){cols=1;}
		if(cells.length > 0){
			cells.each(function(i){
				if(i%cols == cols-1 || i == cells.length-1){
					$(this).after($('<div class="divider" style="clear:left"></div>'));
				}
			});				
			var heights=[];
			function setHeights(e){
				cells.each(function(i){
					var myRow=Math.floor(i/cols);
					$(this).css("height","auto");
					var myH = $(this).innerHeight();
					if(heights[myRow]==undefined || heights[myRow]==null || heights[myRow] < myH){
						heights[myRow] = myH;
					}
				});	
				cells.each(function(i){
					var myRow=Math.floor(i/cols);
					 $(this).css("height",heights[myRow]+"px");				
				});				
			}
			$('img',cells).bind('load',function(e){setHeights(e);});
			setHeights();			
		}
    });   
 };   
})(jQuery);

/* make tabs */
(function($){   
 $.fn.make_tabs = function(opts) {  
    var defaults = {  
		item_selector:'.info_item',
		link_selector:'.info_heading',
		link_subselector:'h3',
		content_selector:'.info_content'
		
    };   
    var o = $.extend(defaults, opts); 	
    return this.each(function() { 
		var selfref=$(this).addClass('tabbed');
		var tabend='<span class="tab_end"><img alt="" src="/images/spacer.gif"/></span>'
		var links=	$(o.link_selector +' '+o.link_subselector,selfref).each(function(){
			var t=$(this);			
			if(t.text() == t.html()){
			 t.html('<a href="#" onclick="return false;">'+t.text()+'</a>')
			}
			if(!(t.children('span:last-child').hasClass('tab_end'))){
				t.append($(tabend));
			}
		});
		if(links.length>1){
			links.css('cursor','pointer');
		}
		//selfref.displayHolder = $('<div class="tab_display"></div>')
		$(o.item_selector+':last',selfref).addClass("last");//.after(selfref.displayHolder);
		selfref.showItem = function(toShow){
			var openTab=$(toShow);
			$(o.item_selector,this).removeClass("tab_open").addClass("tab_closed");
			//$(o.content_selector,this).css('display','none');
			openTab.addClass("tab_open").removeClass("tab_closed");			
			//this.displayHolder.html($(o.content_selector,toShow).html());
			$(o.content_selector, openTab).css('top',($('.last '+o.link_selector, selfref).position().top+$('.last '+o.link_selector, selfref).outerHeight(true))+'px');
			selfref.css('height',($(o.content_selector, openTab).position().top + $(o.content_selector, openTab).outerHeight(true))+'px');
			
		} 
		$(o.item_selector,selfref).each(function(i){
			var me	= this;
			$(o.link_selector, this).click(function(){selfref.showItem(me); var h_ref='#'; h_ref=$('a',this).attr('href');return (h_ref !='#')});
		;});
		
		selfref.showItem($(o.item_selector,selfref)[0]);
    }); 	
 };   
})(jQuery);




function popup(popuptype,identifier,clicked){
	clicked.href='javascript:void(0)';
	if(popuptype==1){
		// type 1 = zoom image
		var w = dhtmlwindow.open('popupbox_zoom', 'ajax', identifier, undefined, 'width=528px,height=600px,center=1,resize=0,scrolling=0');	
		$('.drag-contentarea',w).css({'height':'auto','overflow':'auto'});		
	}else if(popuptype == 2){
		//type 2 = special offer, write/read review
		var w = dhtmlwindow.open('popupbox_'+identifier, 'div', identifier, undefined, 'width=528px,height=600px,center=1,resize=0,scrolling=0');			
		
		$('.drag-contentarea',w).css({'height':'auto','overflow':'auto'});	
		
		
	}else if(popuptype == 3){
		//type 3 = product preview
		var w = dhtmlwindow.open('popupbox_product', 'ajax', identifier, undefined, 'width=528px,height=660px,center=1,resize=0,scrolling=0');
		//dhtmlwindow code has been modified to add the sifr functions when the ajax has loaded
		
		$('.drag-contentarea',w).css({'height':'auto','overflow':'auto'});
	}
	
	return false;
	
}

/* tooltip */
(function($){   
 $.fn.tooltip = function(opts) {  
    var defaults = {  
		link_selector:'.tt_link',
		content_selector:'.tt_tip',
		mouse_activated:false,
		extrawide:false
    };   
    var o = $.extend(defaults, opts); 
	var basetxt 
	if(o.mouse_activated){
		basetxt = '<div class="tt_display"></div>';
	}else{
		basetxt = '<div class="tt_display"><p class="tt_close_holder"><img class="tt_close_button" src="/images/btn_tooltip_close.gif" alt="Close"/></p></div>';
	}
    return this.each(function() { 
		var selfref=$(this);	
       	var display=$(basetxt).append($(o.content_selector,selfref).show());
		if(o.extrawide){
			display.addClass('tt_wider');
		}
		var lnk= $(o.link_selector,selfref)
		var myInt = null;
		function showMe(){
			if(myInt != null){
				clearInterval(myInt);
				myInt = null;
			}
			display.show();
			positionDisplay();
		}
		function hideMe(){
			if(myInt != null){
				clearInterval(myInt);
				myInt = null;
			}
			display.hide();			
		}
		function positionDisplay(){
			var myX=lnk.offset().left + lnk.width() - display.outerWidth(true);
					
			if(myX<10){
				myX=10;
			}
			var myY=selfref.offset().top - display.outerHeight(true);
			if(myY <10){
				myY=10;
			}
			display.css({'position':'absolute','top':myY+'px','left':myX+'px'});
		}
		$('body').append(display);
		positionDisplay()
		if(o.mouse_activated){
			lnk.bind('mouseover',function(){showMe()}).css('cursor','pointer');
			lnk.bind('mouseout',function(){hideMe()});
		}else{
			lnk.bind('click',function(){showMe()}).css('cursor','pointer');
			$('.tt_close_button',display).bind('click',function(){hideMe();});
		}
		hideMe();
    });   
 };   
})(jQuery);

/*
$(document).ready(function(){
	$(document).pngFix();
	//$('#overlay').bind("click",function(){dhtmlwindow.closeallopenwindows();});
	$('.CatalogueListing, .SearchListing, .CrossSell .Related_Products, .CrossSell_HomepageFeature .Related_Products').tabulate();	
	$('.Incentives .Related_Products').tabulate({table_width:576, cell_width:144});	
	$('.home_heading, .CrossSell_HomepageFeature .CrossSell_heading, h1.blog_heading ').sifr({path:'/images/',font:'Gill_Sans_MT_Light',textAlign: 'left' });
	$('h1.catalogue_heading, .flashtext,  .CrossSell .CrossSell_heading, .cart_heading h1, .column_main div.ProductDescription .ItemName, .advanced_search h1.ResultHeading, .QuickOrder h1').sifr({path:'/images/',font:'Gill_Sans_MT_Light_nospace',textAlign: 'left' });
	$(' .column_main div.ProductDescription .ItemBrand').sifr({path:'/images/',font:'Gill_Sans_MT',textAlign: 'left' });
	$('.AdditionalInfoTextHtml').make_tabs();	
	$('.advanced_search_results').make_tabs({item_selector:'.result_type', link_selector:'.result_heading', content_selector:'.result_content'});
	$('.SiteMap').tabulate({cell_selector:'.sitemap_catalogue'});	
;})
*/
$(document).ready(function(){
	$('.CatalogueListing, .SearchListing, .homepage .RelatedProducts').tabulate();
	$('.recent .RelatedProducts, .popular .RelatedProducts').tabulate({table_width:642, cell_width:125});
	$('.Incentives .RelatedProducts').tabulate({table_width:508, cell_width:127});	
	$('.AdditionalInfoTextHtml').make_tabs();
	$('.CrossSell_holder').make_tabs({item_selector:'.CrossSell',link_selector:'.CrossSell_heading',link_subselector:'',content_selector:'.RelatedProducts'});
	$('.advanced_search_results').make_tabs({item_selector:'.result_type', link_selector:'.result_heading', content_selector:'.result_content'});
	$('.tool_tip').tooltip();
	$('.tool_tip_wider').tooltip({extrawide:true});
	if($('.UpSellCart').length ==1){$('.UpSellCart').css('float','none')}else{$('.UpSellCart').css('margin','0 0 0 11px')};
;})