//$().ready(function(){
	function po_step1(context){
		/*var $brand = $(".brand .selectbox", context.options.container);
		var $recipient = $(".recipient .selectbox", context.options.container);*/
		
		function clear(select){
			select.children().each(function(i){
				if (!i)
					return;
					
				$(this).remove(); 
			});
		}
		
		function years(){
			if (!$(".brand .selectbox", context.options.container).val())
				return;
			
			$().rpc("/.enum/", {params: {
					wh: "years", 
					brand: $(".brand .selectbox", context.options.container).val()
				}}, function(data){
						$(".year", context.options.container).html(data);
			});
			
			clear($(".model .selectbox", context.options.container));
			clear($(".evolume .selectbox", context.options.container));
			
			//$(".recipient .selectbox", context.options.container).attr('ovalue')
			var $recip = $(".recipient .selectbox", context.options.container);
			//$("[value=b]", $recip).text($("[value=b]", $recip).text() + ' ' + $(':selected', this).text());
			var brand_txt = $(':selected', this).text();
			if (brand_txt){
				$("[value=b]", $recip).text($recip.attr('b') + ' ' + brand_txt); //$recip.attr('base')
				$("[value=r]", $recip).text($recip.attr('r') + ' для ' + brand_txt);
			}
		}
		
		$(".brand .selectbox", context.options.container).live("change", years); //$brand.change(function(){  }); //focus
		
		$(".year .selectbox", context.options.container).live("change", function(){
			if (!$(".brand .selectbox", context.options.container).val())
				return;
			
			$().rpc("/.enum/", {params: {
					wh: "models", 
					brand: $(".brand .selectbox", context.options.container).val(), 
					year: $(":selected", this).val()
				}}, function(data){
						$(".model", context.options.container).html(data);
			});
			
			clear($(".evolume .selectbox", context.options.container));
		});
		
		$(".model .selectbox", context.options.container).live("change", function(){
			if (!$(".brand .selectbox", context.options.container).val() || !$(".year .selectbox :selected", context.options.container).val())
				return;
			
			$().rpc("/.enum/", {params: {
					wh: "evolumes", 
					brand: $(".brand .selectbox", context.options.container).val(), 
					year: $(":selected", $(".year .selectbox", context.options.container)).val(), 
					model: $(":selected", this).val()
				}}, function(data){
						$(".evolume", context.options.container).html(data);
			});
		});
	}
	
//});
