jQuery.fn.DeseoSelectReset = function() { 

this.children('input').attr('value', '');
this.children('.DeseoSelectContainer').html('<span class="DeseoSelectTextPlease DeseoSelectSpan">'+lang['choose']+'</span>')

}

jQuery.fn.DeseoSelect = function() { 
	
	

	objName = this.attr('id');
	if(!objName) return false;
	
	
	
	inputName = objName.replace('select_', '');
	
	value = this.val();
	if(value)
	{
		selectedIndex = this.attr('selectedIndex');
		valueName =this.children().eq(selectedIndex).html();
	}

	id = '#'+objName;
	
	html = '<div id="'+objName+'">';
	html += '<input type="hidden" name="'+inputName+'" value="'+value+'" />';

	html += '<div class="DeseoSelectContainer">';
	
	if(value)
	html += '<span class="DeseoSelectSpan">'+valueName+'</span>';
	else
	html += '<span class="DeseoSelectTextPlease DeseoSelectSpan">'+lang['choose']+'</span>';
	
	html += '</div>';
	
	
	//if(this.children().size() > 9)

	html += '<div class="DeseoSelectSelect"><div class="top"></div>';



	limit = this.children().length;

	this.children().each(function(i) {
		add2Class = '';
		addClass = '';
		
		if($(this).attr('alt'))
		addClass = $(this).attr('alt');
		
		if(i%2==0) addClass+=' ac_odd';
		
		if(i%2==0) add2Class=' ac_odd';

		if(i+1==limit) addClass+=' ac_last';
		if(i==0) addClass+=' ac_first';

		//if(this.value=='')
			//name = '<span class="DeseoSelectSpan first '+addClass+'">'+lang['choose']+'</span>';
		//else
			name = '<span class="DeseoSelectSpan '+addClass+'">'+$(this).html()+'</span>';
			
		html += '<div class="DeseoSelectOption '+add2Class+'" alt="'+this.value+'">'+name+'</div>';
		
	});



	html += '</div>';

	this.after(html);
	this.remove();

	jQuery(id+' .DeseoSelectOption, '+id+' .DeseoSelectContainer').hover(
		function () {jQuery(this).addClass('select_hover'); jQuery(this).children().addClass('ac_over'); return false; },
		function () {jQuery(this).removeClass('select_hover'); jQuery(this).children().removeClass('ac_over'); return false;});
	
	

	jQuery(id+' .DeseoSelectOption').click(function() {
		value = jQuery(this).attr('alt');
		name = jQuery(this).html();

		jQuery(this).parent().prev().html(name);
		span = jQuery(this).parent().prev().children();
		
		span.css('color', span.attr('oldcolor'));

		jQuery(this).parent().prev().prev().attr('value', value);
		jQuery(this).parent().hide();
		jQuery(this).parent().parent().children('.DeseoSelectContainer').children('span').removeClass('ac_over');
		

		
	});

	jQuery(id+' .DeseoSelectSelect').mouseover(function() {$(this).parent().children('.DeseoSelectContainer').children('span').eq(0).addClass('ac_over'); });

	jQuery(id+' .DeseoSelectContainer').click(function() {
		jQuery('.DeseoSelectContainer').next().hide(); 
		jQuery(this).next().show();
		return false;
	});

	jQuery(document).click(function() {jQuery('.DeseoSelectContainer').next().hide(); jQuery('.DeseoSelectContainer span').removeClass('ac_over')});
}