$(document).ready(function()
{
	$('.nav_hover').hover(function()
	{
		$(this).children('ul').show('fast').css({'position':'absolute'});
	},function(){$('.subnav').hide();});

	$("#slide").slide_me({
		width: 920,
		height: 282,
		transparent: "no",
		transition: 'fade'
	 });
	 
	 $("form.product_form").each(function(){
		var select_elements = $(this).children("select");
		var select_count = select_elements.length;
		
		$(this).submit(function(){
			var submit_error = false;
			$(this).children("select").each(function(){
				if ($(this).val() == "0")
					submit_error = true;
			});
		
			if (submit_error){
				alert("You must choose all product options!");
				return false;
			}
		});

		select_elements.not(":last").change(function(e){
			var new_val = $(this).val();
			if (new_val == "0"){
				// var other_select = $(this).parent().children("select").not($(this)).not(":first");
				var other_select = $(this).parent().children("select").not(":first");
				other_select.children("option").not(":first").remove();
				other_select.attr("disabled", "disabled");
			}
			else {
				var other_select = $(this).parent().children("select").not(":first");
				other_select.attr("disabled", "");
				other_select.children("option").not(":first").remove();
				$.each(product_options[new_val], function(key, value){
					// console.log("[" + key + "]: " + value);
					other_select.append('<option value="' + key + '">' + value + '</option>');
				});
				// console.log("undisabling");
			}
			// $(this).next().attr("disabled", "");
			// console.log("Changed to: " + $(this).val());
			// console.log(e);
		});
	 });
	 
	 
});
