
$(function(){
		   
	$("#btProfessor").hover(function() {
		$("div", this).fadeIn(200);
		},function(){
		$("div", this).fadeOut(100);
		}
	);

	//script para selects de formulario feitos com div
	var objClickAnterior;
	$(".linkSelect").click(function(){
		//se ja foi cliclado  em um anterior seta o novo zindex dos anteriores 							
		if(objClickAnterior){
			//objClickAnterior.css("zIndex","75");
			//objClickAnterior.parents(".groupSelect").find(".groupOptions").css("zIndex","65");	
			$(".groupOptions").fadeOut(100);
		}
		objClickAnterior = $(this);
		//troca o zindex do clicado para sempre ficar sobre os demais
		//$(this).parents(".groupSelect").find(".groupOptions").css("zIndex","85");
		//$(this).css("zIndex","95");		
		//no click do 'a' busca no pai 'groupSelect' um filho 'groupOptions'
		$(this).parents(".groupSelect").find(".groupOptions").slideToggle();
		return false;
	})
	$(".groupOptions ul li a").click(function(){		

			var txt = $(this).text();
			var pai = $(this).parents(".groupSelect").attr("id");
			
			if(pai != "boxAlunonet"){
				$(this).parents(".groupSelect").find(".inputSelect").val(txt);
				$(this).parents(".groupSelect").find(".linkSelect").html(txt);
			}
				
			$(".groupOptions").fadeOut(100);
	
			if($(this).attr("href") != "#"){
				if ($(this).attr("target") != "_blank") {
					location.href = $(this).attr("href");
				} else {
					window.open($(this).attr("href"),"AlunoNet","scrollbars=yes,resizable=yes")
				}
			}
	
		return false;
		
	})
	$(".btOcultar").click(function(){
		$(".groupOptions").fadeOut(100);
		return false;
	})

	// se clicar no 'body' (ou seja, fora do select) enquanto o select estiver aberto, fecha este select
	$("body").click(function(){
		$(".groupOptions").fadeOut(100);							
	})



	//script para abrir os menus internos
	//$(".mnPlus").parents("li").find("ul").display = none;	   
	$(".mnPlus").click(function(){
		//on click do 'a' vai ate o pai (li) e procura uma filha 'ul'
		$(this).parents("li").find("ul").slideToggle();
		
		//abre o menu de cursos
		//$(this).parent("li").parent("ul").find("ul").slideToggle();
		
		return false;
	})

	//script para abrir os menus de cursos
	//$(".mnPlus").parents("li").find("ul").display = none;	   
	$(".mnGroupCursos").click(function(){
		//on click do 'a' vai ate o pai (li) e procura uma filha 'ul'
		$(this).parents("li").find("ul").slideToggle();
		
		//abre o menu de cursos
		//$(this).parent("li").parent("ul").find("ul").slideToggle();
		
		return false;
	})
	
	//MENU DROP DOWN ENSINO -------------------------------------------------------------------------------------------
	//On Hover Over
	function megaHoverOver(){
		var position = $(this).position();
		var pos_left = position.left;
		if($(this).find(".sub").attr("id") == "subMnCursoCap"){
			if ( $.browser.msie && $.browser.version == "6.0")
				pos_left -= 262;
			else
				pos_left -= 253;
		}else if($(this).find(".sub").attr("id") == "subMnEnsinoDist"){
			if ( $.browser.msie && $.browser.version == "6.0")
				pos_left -= 150;
			else
				pos_left -= 141;
		}else if($(this).find(".sub").attr("id") == "subMnCursoPos"){
			if ( $.browser.msie && $.browser.version == "6.0")
				pos_left -= 14;
			else
				pos_left -= 5;
		}
		//alert(pos_left);
		$(this).find(".sub").css({'left': pos_left});
		$(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
		(function($) {
			//Function to calculate total width of all ul's
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() { //for each ul...
					rowWidth += $(this).width(); //Add each ul's width together
				});
			};
		})(jQuery); 
		
		$(this).calcSubWidth();  //Call function to calculate width of all ul's
		
		if ( $.browser.msie && $.browser.version == "6.0"){
			$(this).find(".sub").css({'width' : rowWidth+50}); //Set Width
		}else{
			$(this).find(".sub").css({'min-width' : rowWidth+20}); //Set Width	
		}
	}
	//On Hover Out
	function megaHoverOut(){
		//return;
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
		  $(this).hide();  //after fading, hide it
	  });
	}
	
	//Set custom configurations
	var config = {
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
		 interval: 100, // number = milliseconds for onMouseOver polling interval
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
		 timeout: 100, // number = milliseconds delay before onMouseOut
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};
	
	$("ul#navEnsino li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	$("ul#navEnsino li").hoverIntent(config); //Trigger Hover intent with custom configurations
	
	//-----------------------------------------------------------------------------------
	
	//alert( $.browser.msie );
	//if ( $.browser.msie )
 	//alert( $.browser.version );

});
