// JavaScript Document
$(document).ready(function() {
	$('#artist_browse_dropdown').change(function() {
		window.location = '/artist/'+ $(this).val();
	});
	$('#facebook_artist_browse_dropdown').change(function() {
		window.location = '/fartist/'+ $(this).val();
	});
	$('#cat_browse_dropdown').change(function() {
		window.location = '#'+$(this).val();
	});
	$('#product_category_filter').change(function() {
		window.location = '/products.php?cat='+ $(this).val();
	});
	$("#add_to_cart").click(function(){
		if (parseInt($('#option_id').val()) < 1 || parseInt($('#option_qty').val()) < 1) { 
			alert("Please select an option and quantity for this item");
			return false;
		}
	}); 
	$(".addPackageButton").click(function(){
		//alert($(this).attr("id"));
		var nS = 0;
		$('.packageSelect_' + $(this).attr("id")).each(function(index,item) {
			if ($(item).val() == 0) { 
				nS = 1; 
			}
		});
		if (nS == 1) { 
			alert("Please select an option for all items");
			return false;
		}
		else { 
		
		}
		
	});
	$(".small_add_button").click(function(){
		if (parseInt($($(this)[0]).prev('select').val()) < 1) { 
			alert("Please select an option for this item");
			return false;
		}
	});
	$("#email_notify_button").live("click", function() {
		data = $("#email_notify_form").serialize(); 
		$.ajax({
		   type: "POST",
		   url: "/ajax/ajax-misc.php",
		   data: data,
		   success: function(msg) { 
				if (msg == 1) { 
					$('#email_notifier').html('<div class="success">Thank you! You will be notified when this item is available.</div>');
				}
				else { 
					$('#email_notify_failed').html(msg);
					$('#email_notify_failed').toggle();
				}
		   }
		});
		return false;
	});
	$("#product_image_thumbs li a").click(function() {
		var newImgSrc = "/img/products/m/" + this.id;
		$("#product_image img").attr("src", newImgSrc);
		$('#product_image_thumbs li a').removeClass('thumbActive');
		$(this).addClass('thumbActive');
		return false;
	});
}); 
