$(document).ready(function() {

	jQuery("#prod-info .more-prod-info :first-child").addClass("nt");
	jQuery("#prod-info .more-prod-info").hide();
	jQuery("#prod-info").append("<p class=more><a href=# title='read more'>read more...</a></p>");
	jQuery('#prod-info p.more a').toggle(
		function() {
			jQuery(this).text('close');
			jQuery(this).attr({title:'close'});
			jQuery("#prod-info .more-prod-info").slideDown(400);
		},
		function() {
			jQuery(this).text('read more...');
			jQuery(this).attr({title:'read more'});
			jQuery("#prod-info .more-prod-info").slideUp(400);
	});

	jQuery('#prod-info p.more a').click(function(){
		return false;
	});


	var count = $("h2.subCategory").length;
	jQuery("#pgProducts hr.category:first").each(function() {
		if (count > 1) {
			jQuery(this).before("<div id=page-nav><h3 id=top>Products on this Page</h3></div>");
		}	
	});		
	jQuery("h2.subCategory").each(function(index) {
		if (count > 1) {
			jQuery(this).attr("id", index);
			jQuery(this).prev("img.subCategory").before("<p class=toplink><a href=#top>- top -</a></p>");
			var productimgsrc = jQuery(this).prev("img.subCategory").attr("src");
			var productimgalt = jQuery(this).prev("img.subCategory").attr("alt");
			var productimgwidth = jQuery(this).prev("img.subCategory").attr("width");
				if (productimgwidth == 240) {
					var productimg = "<img src=" + productimgsrc + " alt=" + productimgalt + " width=120 height=36 >";
					jQuery("#page-nav").append("<p>" + "<a href=#" + jQuery(this).attr("id") + " >" + productimg + jQuery(this).text() + "</a>" + "</p>");
				}
				else {
					var productimg = "<img src=" + productimgsrc + " alt=" + productimgalt + " width=50 height=36 >";
					jQuery("#page-nav").append("<p>" + "<a href=#" + jQuery(this).attr("id") + " >" + productimg + jQuery(this).text() + "</a>" + "</p>");
				}	
		}
	});
	jQuery("#page-nav").after("<div class=cb></div>");
	$("#pgSamples").keypress(function(e) {
  		if (e.which == 13 && !$(e.target).is("textarea")) {
    		return false;
 		 }
	}); 
	jQuery("h2#0").prevAll("p.toplink").addClass("hide");
	
	jQuery(".tabnav").tabs(	{ selected: 0 }	);
	
	
	
	var target = '#topprod .prod';
  	var hoverClass = 'hover-moreprod-prod';

	jQuery(target).each(function() {
		jQuery(this).hover(
	      function() {
	         jQuery(this).addClass(hoverClass);
	         status=jQuery(this).find('h3 a').attr('href');
			 },
	      function () {
	         jQuery(this).removeClass(hoverClass);
	      });
	    jQuery(this).click(function() {
	       location = jQuery(this).find('a').attr('href');
	    });
	    jQuery(this).css('cursor','pointer');
	  });


	// cart2 page: after user clicks buy button display message
	
	jQuery("input[name='checkout_done']").removeClass("disable").css('cursor','default');
	jQuery("#buy-msg").hide();
	
	jQuery("input[name='checkout_done']").click(function() {
		jQuery("#buy-msg").show();	
		jQuery(this).addClass("disable");
		jQuery(this).css('cursor','wait');
	});
	

	
});

