	(function($){
			  
	$.fn.jTruncate = function(options) {
	   
		var defaults = {
			length: 25,
			minTrail: 5,
			moreText: "",
			lessText: "",
			ellipsisText: "&hellip;",
			moreAni: "",
			lessAni: ""
		};
		
		var options = $.extend(defaults, options);
	   
		return this.each(function() {
			obj = $(this);
			var body = obj.html();
			
			if(body.length > options.length + options.minTrail) {
				var splitLocation = body.indexOf(' ', options.length);
				if(splitLocation != -1) {
					// truncate tip
					var splitLocation = body.indexOf(' ', options.length);
					var str1 = body.substring(0, splitLocation);
					var str2 = body.substring(splitLocation, body.length - 1);
					obj.html(str1 + '<span class="truncate_ellipsis">' + options.ellipsisText + '</span>');
					//obj.find('.truncate_more').css("display", "none");
					
					// insert more link
					//obj.append(
						//'<div class="clearboth">' +
						//	'<a href="#" class="truncate_more_link">' + options.moreText + '</a>' +
						//'</div>'
					//);

					// set onclick event for more/less link
					var moreLink = $('.truncate_more_link', obj);
					var moreContent = $('.truncate_more', obj);
					var ellipsis = $('.truncate_ellipsis', obj);
					moreLink.click(function() {
						if(moreLink.text() == options.moreText) {
							moreContent.show(options.moreAni);
							moreLink.text(options.lessText);
							ellipsis.css("display", "none");
						} else {
							moreContent.hide(options.lessAni);
							moreLink.text(options.moreText);
							ellipsis.css("display", "inline");
						}
						return false;
				  	});
				}
			} // end if
			
		});
	};
})(jQuery);
	
$(function(){

// truncation rules
$(".st-ec-discover .ec-merch .title a").jTruncate({length: 30});

// support for modules

// rollover effect for full-image hero text bar
$(".bb-message a, .bb-more a, .bb-more").hover(
	function() {
		$(".bb-text").addClass("over");
	},
	function() {
		$(".bb-text").removeClass("over");
	}
);
		
// Featured Categories module interaction
$("div.subject-name, div.subject-image").hover(
	function() {
		this_parent = $(this).parents("div.subject");
		this_parent.children(".subject-name").find("p a").addClass("hover-light");
		this_parent.children(".subject-image").find(".si-top .img-box.blue-hover img").addClass("hover-light2");
	},
	function() {
		this_parent = $(this).parents("div.subject");
		this_parent.children(".subject-name").find("p a").removeClass("hover-light");
		this_parent.children(".subject-image").find(".si-top .img-box.blue-hover img").removeClass("hover-light2");
	}	
);


// Coremetrics Gateway Real-Estate tagging

	$(".module").each(function(i){
		// top level
		var gw_top_level = "Storefront_Module_" + (i + 1);	   
		$(this).attr("id",gw_top_level);
	
	// get second level
	var gw_second_level;
	var t = $(this).attr("class");
	
	if (t.indexOf("st-botm") > 0) {
		gw_second_level = "HERO_One_Product";
	}
	else if (t.indexOf("st-guide-good-reading") > 0) {
		gw_second_level = "HERO_Side_By_Side";
	}
	else if (t.indexOf("sf-todays-deals") > 0) {
		gw_second_level = "3_Across_Promobanner";
	}
	else if (t.indexOf("st-product-person") > 0) {
		gw_second_level = "Single_Product_w_Bio";
	}
	else if (t.indexOf("st-carousel") > 0) {
		gw_second_level = "Standard_Carousel";
	}
	else if (t.indexOf("st-bestseller") > 0) {
		gw_second_level = "Bestsellers_List";
	}
	else if (t.indexOf("featured-author") > 0) {
		gw_second_level = "Carousel_w_Feature";
	}
	else if (t.indexOf("st-single-product") > 0) {
		gw_second_level = "Single_Product_w_Pricing";
	}
	else if (t.indexOf("banner") > 0) {
		gw_second_level = "1_Across_Promobanner";
	}
	else if (t.indexOf("st-ec-discover") > 0) {
		gw_second_level = "Editorial_w_3Products";
	}
	else if (t.indexOf("st-browse-subject") > 0) {
		gw_second_level = "Featured_Categories";
	}
	else if (t.indexOf("st-ec") > 0) {
		gw_second_level = "Recommended_MoreLikeThis";
	}
	else if (t.indexOf("categories-images") > 0) {
		gw_second_level = "Shop_By_Age";
	}
	else if (t.indexOf("hero-1-image") > 0) {
		gw_second_level = "HERO_Product_Text";
	}
	else {
		gw_second_level = "Unknown_Module";
	}
	
	
	// get local level
	$(this).find("a, area").each(function(i){

	if ($(this).attr("rel")){
		var gw_local_level = $(this).attr("rel");
	} else {
		var gw_local_level = "Local_Link_" + (i + 1);
	}
	
	// combine
	var cm_re_tag = gw_top_level + "-_-" + gw_second_level + "-_-" + gw_local_level;
	
	// set cm_re tag
	$(this).attr("manual_cm_re",cm_re_tag);

	});
	});

});

var atHomeLeftNav = {
    expandCategory:function(thePid){
    var listitem = document.getElementById(thePid);
    
    if (listitem) {
            
            // it's a parent
            if (listitem.getElementsByTagName("ul").length > 0) {
                listitem.getElementsByTagName("ul")[0].className="sub-show";
                listitem.className="category-on";
            }
            // it's a non-expandable parent
            else if (listitem.className == "noexpand-off") {
                listitem.className="noexpand-on";
            }
            // it's a child
            else {
                listitem.className="sub-on";
                if (listitem.parentNode) {
                    listitem.parentNode.className="sub-show";
                    if (listitem.parentNode.parentNode && listitem.parentNode.parentNode.tagName=="LI") {
                        
                        listitem.parentNode.parentNode.className="category-on";
                    }
                }
            }
        }
    }

}
