(function($){
	$.fn.customSelect = function(className) {
		var className = className?className:'select';
		this.each(function(){
			$(this).css({'display':'block', 'position':'absolute', 'width':0, 'height':0, 'overflow':'hidden'});
			$(this).wrap('<div />');
			var select = $(this).parent();
			select.append('<a /><ul />');
			select.attr(
				{'data-select':'true', 'class':className}
			).css(
				{'position':'relative'}
			).click(function(){
				$('a', this).focus();
			}).keydown(function(event){
				if (event.keyCode=='32' || event.keyCode=='13' || event.keyCode=='38' || event.keyCode=='40') event.preventDefault();
			});
			$('a', select).attr(
				{'href':'#'}
			).css(
				{'display':'block', 'text-decoration':'none', 'cursor':'default'}
			).html(
				$('option:selected', this).html()
			).click(function(event){
				event.preventDefault();
				if ($('ul', select).css('display')=='none') {
					$('div[data-select=true] ul').css('display', 'none');
					$('li', select).css({ background: 'Window', color: 'WindowText' });
					$('li:eq('+($('option[value='+$('select', select).val()+']', select).index())+')', select).css({ background: 'HighLight', color: 'HighLightText' });
					$('ul', select).css('display', 'block');
				}
				else $('ul', select).css('display', 'none');
			}).hover(
				function(){ $(this).addClass('hover'); },
				function(){ $(this).removeClass('hover'); }
			);
			$('ul', select).css(
				{'display':'none', 'position':'absolute', 'left':'0', 'border':'1px solid activecaption', 'background':'Window'}
			);
			$('option', this).each(function(){
				$('ul', select).append(
					$('<li />').attr(
						{'data-val':$(this).attr('value')}
					).css(
						{'background':'Window','color':'WindowText','white-space':'nowrap','cursor':'default'}
					).html(
						$(this).html()
					).click(function(){
						$('a', select).html($(this).html());
						$('select', select).attr('value', $(this).attr('data-val'));
						$('ul', select).css('display', 'none');
					}).hover(function(){
						$('li', select).css({ background: 'Window', color: 'WindowText' });
						$(this).css({ background: 'HighLight', color: 'HighLightText' });
					})
				);
			});
		});
		$(document).click(function(event){
			if (!$(event.target).parent().attr('data-select')) $('div[data-select=true] ul').css('display', 'none');
		});
	};
})(jQuery);
function chSelect(el){
			var select = el.parent();
			$('ul', select).html('');
			$('a', select).html($('option:selected', el).html())
			$('option', el).each(function(){
				$('ul', select).append(
					$('<li />').attr(
						{'data-val':$(this).attr('value')}
					).css(
						{'background':'Window','color':'WindowText','white-space':'nowrap','cursor':'default'}
					).html(
						$(this).html()
					).click(function(){
						$('a', select).html($(this).html());
						$('select', select).attr('value', $(this).attr('data-val'));
						$('ul', select).css('display', 'none');
					}).hover(function(){
						$('li', select).css({ background: 'Window', color: 'WindowText' });
						$(this).css({ background: 'HighLight', color: 'HighLightText' });
					})
				);
			});
}
