function getItemId(){
	if ($("#pricetag").val() != "---") {location.href = "shoppingcart.html?item_id=" + $("#item_id option:selected").val() + "&update_cart=1";} else 
		return false;
}

( function($) {
	$.fn.doubleSelect = function(doubleid, values, more, options) {
		options = $.extend( {
			preselectFirst :null,
			preselectSecond :null,
			emptyOption :false ,
			emptyKey :-1,
			emptyValue :'-- Choose Category --'
		}, options || {});
		var $first = this;var $secondid = "#" + doubleid;var $second = $($secondid);
		var setValue = function(value) {$second.val(value).change();}
		var removeValues = function() {$($secondid + " option").remove();};
		$(this).change( function() {		
			
			removeValues();
			$current = this.options[this.selectedIndex].value;
			if ($current != '') {
				$.each(values, function(k, v) {
					if ($current == v.key) {
						$.each(v.values, function(k, v2) {
							var o = $("<option>").html(k).attr('value', v2);
							o.appendTo($second);
						});
					}
				});	
			} else {
				setValue(options.emptyValue);
			}
		});
		return this.each( function() {
			$first.children().remove();$second.children().remove();
			if (options.emptyOption) {
				var o = $("<option>").html(options.emptyValue).attr('value',options.emptyKey);
				//$("#first").addOption("value","--SELECT--");
				//o.appendTo ($first);
				o.appendTo ($second);
//				o.appendTo $("#first");
			}
			$.each(values, function(k, v) {
				var o = $("<option>").html(k).attr('value', v.key);o.appendTo($first);
			});	
			if (options.preselectFirst == null) {
				$current = this.options[this.selectedIndex].value;
				if ($current != '') {
					$.each(values, function(k, v) {
						if ($current == v.key) {
							$.each(v.values,function(k, v2) {var o = $("<option>").html(k).attr('value', v2);o.appendTo($second);});
						}
					});
				} else {
					setValue(options.emptyValue);
				}
			} else {
				$("#first").val("select").change();
			}
		});
	}
})(jQuery);

$(document).ready(function() {
	$('#first').doubleSelect('second', selectoptions,'');      
	$('#second').doubleSelect('item_id', dosageOptions,'');     
	$('#first').doubleSelect('second', selectoptions,'');      
	$('#second').change (function() {
		var currentDos = $("#item_id option:selected").val();
		$('#pricetag').html(id_price[currentDos]);
	});
	$('#item_id').change (function (){
		var currentDos = this.options[this.selectedIndex].value;
		$('#pricetag').html(id_price[currentDos]);
	});
	 $('#first').change(function (){
		$("#item_id" + " option").remove();
		var $item_id = $("#item_id");
		$current = this.options[this.selectedIndex].value; 
		$c = $("#second option:first").val();
		values = dosageOptions;
		$.each(values, function(k, v) {
				if ($c == v.key) {
					$.each(v.values, function(k, v2) {
						var o = $("<option>").html(k).attr('value', v2);
						o.appendTo($item_id);
					});
				}
		});	
		var currentDos = $("#item_id option:selected").val();
		$('#pricetag').html(id_price[currentDos]);
		
	});
});
