function jafafa(selectID, addClassName){
	var init = false;
	var selectBox = jQuery('#' + selectID);
	
	if(selectBox.hasClass('jafafa')){
		reInit();
	};
	
	if(init == true) { 
		var jafafaOption = jQuery('#jafafa-select-options-' + selectID);
		var jafafaSelect = jQuery('#jafafa-select-' + selectID);
		jQuery('#jafafa-select-options-' + selectID).children('p').bind('click', function(e){
			//e.stopPropagation()
			closeOptions();
			jQuery('#' + selectID).attr('value', jQuery(this).attr('rel'));
			fireEvent($(selectID), 'change');
			jafafaOption.children('p').each(function(){
				jQuery(this).removeClass('selected');
			});
			jQuery(this).addClass('selected');
			refresh();
		});
		
		return; 
	}
	
	var parent = selectBox.parent();
	var selectOption = selectBox.children('option');
	var className = "";
	if(addClassName){ className = addClassName; };
	var jafafaWrapper;
	var jafafaSelect;
	var jafafaOption;
	var jafafaOptionShow = false;

	jQuery(document).click(function(){
		if(jafafaOptionShow == true){
			closeOptions();
		}
	});
	
	selectBox.addClass('jafafa');
	
	parent.addClass("jafafa-" + selectID);
	parent.prepend('<div id="jafafa-select-wrapper-' + selectID + '" rel="' + selectID + '" class="jafafa-wrapper ' + selectID + ' ' + className + '" style="position: relative;"></div>');
	jafafaWrapper = jQuery('#jafafa-select-wrapper-' + selectID);
	
	if (selectBox.attr('disabled')){
		jafafaWrapper.addClass('disabled');
	} else {
		jafafaWrapper.removeClass('disabled');
	};
	
	jafafaWrapper.append('<div id="jafafa-select-' + selectID + '" class="jafafa-select ' + selectID + '"><p rel="">' + selectBox.children('option:selected').text() + '</p></div>');
	jafafaSelect = jQuery('#jafafa-select-' + selectID);
	jafafaWrapper.append('<div id="jafafa-select-options-' + selectID + '" class="jafafa-options ' + selectID + '" style="display: none; position: absolute; z-index: 1002"></div>');
	jafafaOption = jQuery('#jafafa-select-options-' + selectID);
	
	//Get all options from select
	selectOption.each(function(){
		jafafaOption.append('<p rel="' + jQuery(this).attr('value') + '">' + jQuery(this).html() + '</p>');
	});
	
	//Bind click event on Div to show Options
	jafafaSelect.bind('click', function(e){
		if(!jQuery('select#' + jafafaWrapper.attr('rel')).attr('disabled')){
			e.stopPropagation();
			// e.stop();
			e.preventDefault();
			if(jafafaOptionShow == true){
				closeOptions();
			}else{
				openOptions();	
			}
		}
	});

	//Bind click event on Option
	jafafaOption.children('p').bind('click', function(e){
		closeOptions();	
		jQuery('#' + selectID).attr('value', jQuery(this).attr('rel'));
		fireEvent($(selectID), 'change');
		jafafaOption.children('p').each(function(){
			jQuery(this).removeClass('selected');
		});
		jQuery(this).addClass('selected');
		refresh();
	});

	//Open Options
	function openOptions(){
		jafafaOption.show();
		jafafaSelect.addClass('open');
		jafafaOptionShow = true;
	}

	//Close Options
	function closeOptions(){
		jafafaOption.hide();
		jafafaSelect.removeClass('open');
		jafafaOptionShow = false;
	}
	
	function reInit(){
		jafafaOption = jQuery('#jafafa-select-options-' + selectID);
		selectOption = jQuery('#' + selectID).children('option');
		jQuery('#jafafa-select-wrapper-' + selectID).removeClass('disabled');
		jafafaOption.html('');
		selectOption.each(function(){
			jafafaOption.append('<p rel="' + jQuery(this).attr('value') + '">' + jQuery(this).html() + '</p>');
		});
		
		init = true;
	}
	
	function fireEvent(element,event){
	    if (document.createEventObject){
	        // dispatch for IE
	        var evt = document.createEventObject();
	        return element.fireEvent('on'+event,evt);
	    } else {
	        // dispatch for firefox + others
	        var evt = document.createEvent("HTMLEvents");
	        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
	        return !element.dispatchEvent(evt);
	    }
	}
	
	function refresh(){
		jQuery('.jafafa-wrapper').each(function(){
			if(!jQuery('select#' + jQuery(this).attr('rel')).attr('disabled')){ 
				jQuery(this).removeClass('disabled');
			} else {
				jQuery(this).addClass('disabled');
			};
			
			jQuery('#jafafa-select-' + jQuery(this).attr('rel')).html('<p rel="' + jQuery('select#' + jQuery(this).attr('rel')).children('option:selected').val() + '">' + jQuery('select#' + jQuery(this).attr('rel')).children('option:selected').html() + '</p>');
			jafafa(jQuery(this).attr('rel'));
			
		});
	}
	
}
