

function init_submenu (obj){
	
	if ($(obj).length>0)	{
		
		
		$(".show").hover(
		  function () {
			obj=$(this).attr("ref"); 
			var pos=$(this).offset();
			
			$("."+obj).css({ left:pos.left});
			show_sub_id("."+obj);
			
		  },
		  function () {
			obj=$(this).attr("ref"); 
			hide_sub_id("."+obj);
		  }
		);
		
		$(".submenu").each(function () {
									 
									 
									 
			 });
		
		
		
		$(".submenu").hover(
		  function () {
			show_sub_id(this)
		  },
		  function () {
			 hide_sub_id(this)
		  }
		);
		
		
		$(obj + ' .active').each(function(){
				$(this).parent().children("ul").css({  display:"none" });					 
			});	
		
		$(obj + ' .active').bind('click', function (e) {
				show_submenu(this);
			});	
			
		
	}
}


function show_sub_id(obj) {
	
	$(obj).stop(true,true).fadeIn(50);
	
}

function hide_sub_id(obj) {
	
	$(obj).stop(true,true).fadeOut();
}


function show_submenu(obj) {

	
	if ($(obj).parent().children("ul").is(":visible")) {
		
		$(obj).parent().children("ul").hide();
		$(obj).addClass("close");
		$(obj).removeClass("open");
	}
	else {
		
		$(obj).parent().children("ul").show();
		$(obj).addClass("open");
		$(obj).removeClass("close");
		
	}
	
}





