﻿/*********************************************
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 PNG Fix
jQuery.fn.supersleight=function(settings){settings=jQuery.extend({imgs:true,backgrounds:true,shim:'x.gif',apply_positioning:true},settings);return this.each(function(){if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<7&&parseInt(jQuery.browser.version,10)>4){jQuery(this).find('*').andSelf().each(function(i,obj){var self=jQuery(obj);if(settings.backgrounds&&self.css('background-image').match(/\.png/i)!==null){var bg=self.css('background-image');var src=bg.substring(5,bg.length-2);var mode=(self.css('background-repeat')=='no-repeat'?'crop':'scale');var styles={'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='"+mode+"')",'background-image':'url('+settings.shim+')'};self.css(styles)};if(settings.imgs&&self.is('img[src$=png]')){var styles={'width':self.width()+'px','height':self.height()+'px','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+self.attr('src')+"', sizingMethod='scale')"};self.css(styles).attr('src',settings.shim)};if(settings.apply_positioning&&self.is('a, input')&&(self.css('position')===''||self.css('position')=='static')){self.css('position','relative')}})}})};
// End PNG Fix

// 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

/**********************************************************************************************************/
/****************************** 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();}});
		//auto-png fix:
		$('body').supersleight();
		// 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");
            }
        }
		
		
});
