	/*
		
		Ajax lists
		
		Copyright (c) 2010 Alex Silaev (http://alex.twimp.ru/) chrome.alex@gmail.com
		Licensed under the GPL (http://www.opensource.org/licenses/gpl-license.php) license.
		
		Created at 6 Dec 2010
		
		=================================
		* Use:
		=================================
			var lists = new Lists();
			
			lists.load(path, params, array ( selector: 'jquery selector', 'default': 'if value is default, than put selector to disabled' ));
		
	*/
	
	var Lists = function() {
		
	};
	Lists.prototype = {
		
		load: function(path, params, vals, nocache) {
			
			var rbox = vals['selector'];
			var rdef = vals['default'];
			var nobj = params['object'];
			
			if (rdef == $(nobj).val()) {
				
				$(nobj).val(rdef);
				$(rbox).attr('disabled', 'disabled');
				
			} else {
				
				delete params['object'];
				params['val'] = $(nobj).val();
				if (typeof(nocache) == 'undefined') nocache = false;
				JsHttpRequest.query(path, params,
					function(result, resp) {
						
						$(rbox).html(result.list);
						$(rbox).attr('disabled', '');
						
					},
					nocache
				);
				
			}
			
		}
		
	}
	

