
$(document).ready(function(){
	$(".lightbox").click(function(){
		
		$.get(jQuery.ez.url + 'run/content/view/full/'+ $(this).attr('id'), function(data){
			if (data.error_text )
				$("#teststatus").html( data.error_text );
			else
				/*$("#successful").html( data );*/
				$.colorbox({html:data,innerWidth:600,innerHeight:600,opacity:0.6});
		});
		return false;
		
	});	
	

	//this will only work if the framework calls for the required colorbox css and includes the script
	$(document).ready(function(){
		$(".popup").colorbox({iframe:true,height:800,width:"80%", opacity:0.5});
	});
	
		
	
		
		

	
	
	//Menu width calculation
	$(".n2-wrapper").each(function(){
	/*
	var size = 0;
	 $(this).find("ul.n2").each(function(){
		 size += $(this).width();
		 $(this).css("width", $(this).width() +"px");
	 });
	 
	 if(size>0) $(this).width(size);*/
	 
	 $(this).css("visibility","visible");
	 $(this).css("display","none");
	});
	
	// Menu
	var config = {
			over:topMenuEnter,
			timeout:10,
			out:topMenuLeave			
	};
	
	$(".n1").children("li").hoverIntent(config);
	
	$(".n1 li .n2-wrapper").mouseenter(function(event){
		//stop event propagation and close menu
		$(this).show();
		event.stopPropagation();
	}).mouseleave(function(event){
	$(this).hide();
	event.stopPropagation();
	$(this).parents(".active").removeClass("active");
	$(this).prevAll("a").find(".active-marker").remove();
	});
	

	
	// Menu
	$(".n1 li .n2-wrapper").click(function(event){
		//stop event propagation and close menu
		$(this).hide();
		event.stopPropagation();
	});

	
	
});

function topMenuEnter(){
	var $child_link = $(this).find("a:first"); 
	$(this).addClass("active");
	if($child_link.find(".active-marker").length<1) $child_link.append("<span class='active-marker'></span>");	
	$(this).children(".n2-wrapper").show();
}

function topMenuLeave(){
	$(this).children(".n2-wrapper").hide();
	$(this).find("a > .active-marker").remove();
	$(this).removeClass("active");
}
/*include something here... related to menu */

