(function($) {
	$.fn.selectMultipleClick = function(opts) {
		this.each( function() {
			var selected = [];
			if ( ! this.multiple ) {
				return ;
			}
			jQuery(this).mouseover(function() {
				for ( var i = 0, a = 0; i < this.options.length; i++) {
					if (this.options[i].selected == true) {
						selected[a] = this.options[i].value;
						a++;
					}
				}
			});
			jQuery(this).click(function() {
				var clickNotAll = false;
				for ( var i = 0; i < selected.length; i++) {
					for ( var a = 0; a < this.options.length; a++) {
						if (selected[i] == this.options[a].value
								&& this.options[a].selected == true) {
							this.options[a].selected = false;
							selected.splice(i, 1);
						} else if (selected[i] == this.options[a].value) {
							this.options[a].selected = true;
						}
					}
				}
				for ( var i = 0, a = 0; i < this.options.length; i++) {
					if (this.options[i].selected == true) {
						selected[a] = this.options[i].value;
						a++;
					}
				}
				if ( ( this.options[0].value == '' ) && this.options[0].selected && ( selected.length > 1 ) ) {
					this.options[0].selected = false;
					for ( var i = 0; i < selected.length; i++) {
						if (selected[i] == this.options[0].value) {
							selected.splice(i, 1);
						}
					}
				}
			});
		});
		return this;
	};
})(jQuery);

