(function($) {
	$.fn.clickMe = function(op_user) {
		

		var menuName = this,				
			op = $.extend( cm.op_default , op_user);
			
		// move content to inicial margin
		$(op.moveIt).css({ marginTop: op.moveItMargin });
		
		//  anchor inside menu active the code
		$(menuName).find(".menu").click(function() {
			var ulsVisible = $(menuName).find("ul").is(":visible");
			var testUl = $(this).next("ul").is(":visible");
			
			// hide and remove op.activeMenu class from visible list inside the menu 
			if (ulsVisible) {
				// know if the anchor that active the function is visible
				if(testUl) {					
					$(menuName).find("li").removeClass(op.activeMenu);
					$(this).next("ul").animate(op.aniHide, op.speed, moveContent() );			
				} else {
					$(menuName).find("li").removeClass(op.activeMenu);						
					$(menuName).find("ul").animate(op.aniHide, op.speed);
					$(this).parent("li").addClass(op.activeMenu);
					$(this).next("ul").animate(op.aniShow, op.speed , moveContent() );
				}
			} else {
				$(this).parent("li").addClass(op.activeMenu);
				$(this).next("ul").animate( op.aniShow, op.speed, moveContent() );			
			}
		
		});
			
		// Move content 
		function moveContent() {
				
			var ulHeight = $("."+op.activeMenu +" ul").height() ;
			var moveMargin = parseFloat($(op.moveIt).css("margin-top"));
			var dif = ulHeight + op.moveItMargin - moveMargin;					
						
			if (ulHeight == moveMargin) {

			} else if (ulHeight < moveMargin) {			
				$(op.moveIt).animate({marginTop: "+=" + dif}, op.speed);

			} else if (ulHeight > moveMargin){
				$(op.moveIt).animate({marginTop: "+=" + dif}, op.speed);			
				
			}				 							
		}
		
		
	};

	var cm = $.fn.clickMe;
	cm.op = {};
	cm.op_default = {
		activeMenu: "current",
		moveIt: ".jack",
		moveItMargin : 0,
		aniShow: { opacity: "show", height: "show"},
		aniHide: { opacity: "hide", height: "hide"},
		speed: "slow"
	};
	
})(jQuery);
