jQuery(document).ready(function($) {
	
	/** General */
	// Add clearing divs to the end of .BlockContent
	$(".Content .BlockContent").append('<div style="clear:both"></div><!-- added in scripts.js at line 5 -->');
	
	/** Home page specific scripting */
	if ($("body.home").length > 0) {
	
		// Slideshow
		$('.banner_home_page_top p').cycle({
			timeout:4000
		});
	
		// BC isn't returning a default height for product details on the homepage, so we'll do it ourselves.
		var topHeight = 0;
		var _topHeight = 0;
		$("#HomeFeaturedProducts .ProductDetails").each(function () {
			_topHeight = $(this).height();
			if (_topHeight > topHeight) {
			  topHeight = _topHeight;
			}
		});
		$("#HomeFeaturedProducts .ProductDetails").css("height", topHeight + "px");

	}
	
	/** Category specific scripting */
	if ($("body.category").length > 0) {
		
		// Include a category name for the top level content categories page, since
		// it doesn't display one by default
		if ($(".Content h2").text() == '') {
		
			// See if there is a title set by a link on the page
			var title = $("a[href='"+window.location+"'], a[href='"+window.location.pathname+"']").text();
			if (!title) {
				title = 'Products';
			}
			$(".Content h2").text(title);
		}
	
		// Fix for the sort box
		if ($("ul.ProductList li").length > 1) {
			$("select[name='sort']").removeAttr("onChange");
			$("select[name='sort']").bind("change", function () {
				window.location = window.location.pathname.split("?")[0] + "?sort=" + $(this).val();
			});
		}
		else {
			$(".SortBox").remove();
		}
	
	}
	
	// General form cleanup
	$('.ContactButton').addClass('button');
	
	if ($.browser.safari) {
		$("ul.ProductList a.button").css("font-weight", "normal");
	}
	
	// Add CurvyBox to Create Account //
	//$('.createaccount .Textbox, .createaccount select, .createaccount .JSHidden, #EditAccountForm .Textbox, #ShippingAddressForm .Textbox, #ShippingAddressForm select').addClass('CurvyBox');
	
	// Add CurvyBox to Product Page //
	//$('#qty_, #text_qty_, .productAttributeFluidWidth, .fileInput label input, .dateselector select, .productOptionViewSelect select, .productOptionViewRectangle ul li label, .productAttributeConfigurableEntryNumbersOnlyText input').addClass('CurvyBox');
	
	// Add CurvyBox to Contact Form //
	//$('#ContactForm .Textbox, #ContactForm textarea').addClass('CurvyBox');
		
	// Checkout Overhaul //
	$('.checkout #CreateAccountButton, .checkout #LoginButton, .checkout .billingButton').addClass('button');	
});
