(function ($) {

Drupal.behaviors.tranquill = {
  attach: function (context) {
	  
	  
	  
    $("ul.mensen li").hover(function () {
      $(this).addClass("over");
    }, function () {
      $(this).removeClass("over");
    });
	
	
	$("#comment-form .form-type-select").each(function(){
		
		/* HIDE SELECT */
		
		$(this).children("select").hide();
		
		/* APPEND ICON LIST */
		$(this).append('<ul></ul>');
		
		$(this).find("option").each(function(){
			// don't display the "<ANY>"-item
			if($(this).val() !="_none") {
				
				rootelem = $(this).parents(".form-type-select");
				
				// make class
				class1 = 'id_' + $(this).val();
				// check if the item is selected
				class2 = '';
				if($(this).attr("selected")) {
					class2 = ' class="selected"';
				}
				// append icons to div
				rootelem.find("ul").append('<li' + class2 + '><a class="' + class1 + '" href="">' + $(this).text() + '</a></li>');
				
				// bind click action to link
				rootelem.find(".id_" + $(this).val()).bind("click", function(){
																			 
					// redefine rootelem, out of scope
					rootelem2 = $(this).parents(".form-type-select")

					// only one at a time can be selected
					rootelem2.find("option:selected").removeAttr("selected");
					
					// if the item was allready selected, the filter will be set tot <ANY>
					rootelem2.find(".selected").removeClass("selected");
					rootelem2.find("option:contains(" + $(this).text() + ")").attr("selected","selected");	
					$(this).parent("li").addClass("selected");				
					return false;
					
				});
			}
		});
	});
	
	
  }
};

})(jQuery);;

