/*********************************************
Copyright 2009 Solid Cactus/Web.com inc.
Last Updated: 8/7/2009
Customized: N
packer: http://dean.edwards.name/packer/
*********************************************/
// Start Features List JS/Plugins

// Start Simple Text Popup
(function($){
	$.fn.scSimpleText = function(options){
		var defaults = {
			popCloseTxt : ''
		};
		var settings = $.extend({},defaults,options);
		return this.each(function(){  
			var nextElm = $(this).next();
			var closeElement = $(document.createElement("a")).attr("href","").text(settings.popCloseTxt).addClass("scSimpleTextClose").click(function(e){nextElm.fadeOut("slow"); e.preventDefault();});
			$(this).click(function(e){	
				nextElm.fadeIn("slow");
				nextElm.append(closeElement);
				e.preventDefault();
			});
		});
	}
})(jQuery);
// End Simple Text Popup

// Start sc Animated Nav JS
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}
if(p==this){return false;}
var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}
if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);jQuery.animateNav=function(animateId,clickThrough){$('#navcontainer > ul').attr("id",animateId);function unSheathed(){$(this).addClass(' flyout');$('#cNav > li.flyout > ul').show(450);}
function Sheathed(){$('#cNav > li.flyout > ul').hide(350);$('#cNav > li.flyout').removeClass(' flyout');}
function unSheathed2(){$(this).addClass(' flyout');$('#cNav > li > ul > li.flyout > ul').show(450);}
function Sheathed2(){$('#cNav > li > ul > li.flyout > ul').hide(350);$('#cNav > li > ul > li.flyout').removeClass(' flyout');}
if(animateId=="eNav"){$(document).ready(function(){$('#eNav > li > a').click(function(event){if($(this).next().html()!=null){if($(this).parent().is("#clicked")==false){event.preventDefault();}}
if(clickThrough){$(this).parent().attr("id","clicked");}
$(this).parent().addClass(' expand');$('#eNav > li.expand > ul').toggle("slow");$(this).parent().removeClass(' expand');});});}else if(animateId=="cNav"){$(document).ready(function(){$('#cNav > li').hoverIntent({sensitivity:3,interval:75,over:unSheathed,timeout:75,out:Sheathed});$('#cNav > li > ul > li').hoverIntent({sensitivity:3,interval:75,over:unSheathed2,timeout:75,out:Sheathed2});});}else{return false;}};
// END sc Animated Nav JS

/**********************************************************************************************************/
/****************************** Place all add on JS above here, please minify *****************************/
/**********************************************************************************************************/

/************************************* Document on Load jQuery Functions **********************************/

jQuery(document).ready(function() {
		// add a class to the last li in the header and footerlinks.
		$("ul#secondary-links li:last").addClass("last");$("ul#primary-links li:last").addClass("last");$("ul#primary-links").removeAttr("id");$("ul#secondary-links").removeAttr("id");
		// Hide Empty containers and headers (previous element)
		$(".checkempty").each(function(i){var $thisele = $(this);if($.trim($thisele.text()).length < 1){$thisele.prev().hide();}});
		// Hide empty product info table rows
		$("#product-info-table td").each(function(i){var $thisele = $(this);if($.trim($thisele.text()).length < 1){$thisele.parent().hide();}});
		// write seperators for contents.
		var numconts = 3; // change this with number of columns
		$(".results-grid").find('.result').each(function(c){var thisresult = $(this);if((c + 1)%numconts!=0){thisresult.addClass("vertsep");} else {thisresult.parent().after("<div class='horzsep'><div></div><div></div><div></div></div>");}});
		$("#homefeatured").find('.product').each(function(c){var thisresult = $(this);if((c + 1)%numconts!=0){thisresult.addClass("vertsep");} else {thisresult.parent().after("<div class='horzsep'></div>");}});
		$("div.horzsep:last").addClass("last");
		// remove styles from image on item page.
		$("#product_image").removeAttr("style");
		// simple text popup
		$("#simpleTextLink").scSimpleText({popClose:".simpleTextRight"});
		// If product description is empty, add default text
		if ($(".itemcontain").length != 0){
		    if ($("div.description").html().length == 0){
               $("div.description").html("Product Description is currently unavailable");
            }
        }
		//Add "SALE: " before sale prices.
		$("div.product .product-details .price span.sale, div.result .amount .price span.sale").prepend("SALE: ");
		// nav plugin, pass in cNav for cascading nav eNav for expanding can add "click" as the second parameter.
		$.animateNav("cNav");
});
