/*file: js/product.js, too small for adequate compression*/
$(document).ready(function() {
	$('#contentswitchactivity').hide();
	$('#item_color_table').hide();
	$('#ItemUrlSafeName').change(function(obj) {
		$('#item_color_table').show();
		var item = escape($(this).val());
		$('#CartAddToCart, #colortable').hide();
		$('#contentswitchactivity').fadeIn('normal', function() {
			$('#ItemId').val(item);
			$.ajax({
				beforeSend:	function(req) {},
				complete:	function(req, msg) {},
				error:		function(req, status, err) {alert("There was an error trying to get the selected item.  Please try again in a few moments.");},
				success:	function(data, status) {$('#colortable').replaceWith(data); $('#contentswitchactivity').fadeOut('normal', function() {$('#CartAddToCart, #colortable').show();});},
				url:		'/items/getItem/' + item
			});
		});
	});
	
	$('#CartAddToCart').submit(function() {
		var quantity	= parseInt($('#CartQuantity').val());
		var item		= $('#ItemId').val();
		if(quantity > 0 && item != "") {
			return true;
		}
		alert('You must select a color from the drop-down menu above.');
		return false;
	});
});
