$(document).ready(function() {
		
		
	function change_back()	{
		setTimeout( "$('#purchase').val('Add to Cart')", 3000 );
	}
	
	
	$.validator.addMethod("greaterThanZero", function(value, element) {
		var val_total = 0;
		$('.qty_field').each(function(){	//	check for quantities
		 	if($(this).val()) 	{	//	check for entered value
				var this_num = parseInt( $(this).val() );	//	convert to number
				val_total = val_total + this_num ;
				}
		 	});
			 if (val_total == 0)	{
			 	$('#purchase').val( 'Please enter a quantity' );
//			 	change_back();	//	if we want ot change thebutton text back
			 	return false;
			 	}
			 else	{
			 	return true;	// or leave blank 
			 	}
	}, "");


	$("#add-to-cart-form").validate({		//	http://docs.jquery.com/Plugins/Validation/validate
					ignore: ".disabled",	// to turn off password for no reg. etc.
					errorPlacement: function(error, element){error.appendTo(element.parent());},
				    rules : {
				            "quantity[1]" : { greaterThanZero : true }
				        }
				    
	});
	
	
	$("a.single_image").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	400, 
			'speedOut'		:	400
		});
	
	
	
});
