//---------------------------------------
// shop admin options
//---------------------------------------

var ShopAdminOptionsController = Class.create({
	
	toggles : Array(),
	
	init : function() {
		if(x = $('order_type')) {
			x.observe('change', this.handleOrderType.bind(this)); 
			$('user_type').observe('change', this.handleUserType.bind(this)); 
			this.showOrderType($F('order_type'));
			this.showUserType($F('user_type'));
		}
		if(y = $('new_option_link')) {
			$('new_option').hide();	
			y.observe('click', this.handleNewOption.bind(this)); 
		}
	},
	
	handleNewOption : function(e) {
		Event.stop(e);
		$('new_option').show();
	},
	
	handleOrderType : function(e) {
		var t = Event.element(e);
		var v = t.value;
		this.showOrderType(v);
	},
	
	showOrderType : function(v) {
		switch(v) {
			case 'standard' :		$('admin_order').hide();
													break;
			default :						$('admin_order').show();
													break;
		}
	},
	
	handleUserType : function(e) {
		var t = Event.element(e);
		var v = t.value;
		this.showUserType(v);
	},
	
	showUserType : function(v) {
		switch(v) {
			case 'existing_user' :	$('new_user').hide();
															$('existing_user').show();
															break;
			case 'new_user' :				$('existing_user').hide();
															$('new_user').show();
															break;
		}
	}
	
});

document.observe('dom:loaded', function() { var rb = new ShopAdminOptionsController(); rb.init(); });
