(function(){
		var getLeadingHtml = function(input, maxChars) {
		// token matches a word, tag, or special character
		var	token = /\w+|[^\w<]|<(\/)?(\w+)[^>]*(\/)?>|</g;
		var	selfClosingTag = /^(?:[hb]r|img|)$/i;
		var	output = "";
		var	charCount = 0;
		var	openTags = [];
		var	match;
		//reset regex
		token.exec("");
		// Set the default for the max number of characters
		// (only counts characters outside of HTML tags)
		maxChars =  300;
		charCount = 0;
		var i = 0;
		while ((charCount < maxChars) && (match = token.exec(input))) {
			// If this is an HTML tag
			if (match[2]) {
				output += match[0];
				// If this is not a self-closing tag
				if (!(match[3] || selfClosingTag.test(match[2]))) {
					// If this is a closing tag
					if (match[1]) openTags.pop();
					else openTags.push(match[2]);
				}
			} else { 
				charCount += match[0].length;
				if (charCount <= maxChars) output += match[0];
				i++;
			}
		}
		output += "..."
		// Close any tags which were left open
		var i = openTags.length;
		while (i--) output += "</" + openTags[i] + ">";
		return output;
	};
	
	var tempImg = [];
	tempImg[0] = new Image();
	tempImg.src = configure.imgDir + "btn_AddToCart_on.gif";
	$(function(){
		$('.addCart').hover(
			function() {
				$(this).attr("src",$(this).attr("src").replace("_off","_on"));
			},
			function() {
				$(this).attr("src",$(this).attr("src").replace("_on","_off"));
			}
		);
		
		// more and less links on page
		$('.prod-Desc').each(function(i){
			if(this.innerHTML.replace(/<[^>]*>/g,"").length > 400) {
				//try{
				$(this).after('<div style="display:none;" class="prod-Desc-Full">'+this.innerHTML+'</div>');
				//}catch(e){ alert(this.nextSibling.innerHTML)}
				$(this).next().append('<div style="padding:12px 0px;"><a href="#" class="seeless" id="seeless-'+i+'"><img src="'+configure.imgDir+'btn_lessInfo.gif" alt="Less Info" /></a></div>');
				$(this).html(getLeadingHtml(this.innerHTML));
				$(this).append('<div style="padding:12px 0px;"><a href="#" class="seymour" id="seymour-'+i+'"><img src="'+configure.imgDir+'btn_moreInfo.gif" alt="More Info" /></a></div>');
				$('#seymour-'+i).click(function(){
					$('.prod-Desc').show().next().hide();
					$(this).parent().parent().hide().next().show();
					return false;
				});
				$('#seeless-'+i).click(function(){
					$(this).parent().parent().hide().prev().show();
					return false;
				});
			}
		});
		if($('.seymour').length > 1) {
			$('#open-all').html('<a class="expandInfo" href="">Expand All</a><a style="display:none;" class="collapseInfo" href="">Collapse All</a>');
			$('#open-all').children('a.expandInfo').click(function(){ 				
				$('.seymour').parent().parent().hide().next().show();
				$('#open-all').children('a.expandInfo').hide();
				$('#open-all').children('a.collapseInfo').show();
				return false;
			});
			$('#open-all').children('a.collapseInfo').click(function(){
				$('.prod-Desc').show().next().hide();
				$('#open-all').children('a.expandInfo').show();
				$('#open-all').children('a.collapseInfo').hide()
				return false;
			})
		}
		
		$('img.hoverTab').hover(
			function() {
				$(this).attr("src",$(this).attr("src").replace("-off","-over"));
			},
			function() {
				$(this).attr("src",$(this).attr("src").replace("-over","-off"));
			}
		);
	
	});
	
		
})(jQuery);
