// JavaScript Document

jQuery().ready(function(){
$(".menu").click(function(){
 //hauteur=$(this).offset().top;
	 if($(this).next("div").is(":hidden")){
		 $(this).next("div").slideDown(500);
		 //$('html,body').animate({scrollTop:hauteur},1000);
	  }else if($(this).next("div").is(":visible")){
		  $(this).next("div").slideUp(500);
		  //$('html,body').animate({scrollTop:hauteur},1000);
	  }

	 
 });

//$(".menu").click(function(){
//$(".menu").next("div:hidden").hide();
// hauteur=$(this).offset().top;
// if (document.getElementById("submenu").style.display=="block"){
// 	if($(this).next("div").is(":visible")){
//		a=2;
// 		$(this).next("div").slideUp("slow");
// 		$('html,body').animate({scrollTop:hauteur},1000);
// 	}
// }
// });

}); 

function validar(){

                  
                 if (document.getElementById("submenu").style.display=="block")
                     {
                            
                         //hide_menuinst();
                     }
                     if (document.getElementById("submenu").style.display=="none")
                    {

                         //show_menuinst();
                     }
                   
           return 0;      
         }
         

function show_menuinst(){

           
		//$(".menu").next("div").hide();
		//$(".menu").click(function(){
		//$(".menu").next("div:visible").hide();
		//hauteur=$(this).offset().top;
		if($(".submenu").is(":hidden")){
		$(this).next("div").slideDown("slow");
		$('html,body').animate({scrollTop:hauteur},1000);
		}
		//});
	 
	 //document.getElementById("submenu").style.display="block";
	//$("submenu").show("slide", { direction: "down" }, 1000);

}

function hide_menuinst(){
	
	$(".menu").next("div").hide();
		$(".menu").click(function(){
		$(".menu").next("div:hidden").hide();
		hauteur=$(this).offset().top;
		if($(this).next("div").is(":hidden")){
		$(this).next("div").slideUp("slow");
		$('html,body').animate({scrollTop:hauteur},1000);
		}
		});
	
	//document.getElementById("submenu").style.display="none";
	//$("submenu").hide("slide", { direction: "up" }, 1000);
}


$(document).ready(function(){
	
	var first = 0;
	var speed = 700;
	var pause = 3500;
	
		function removeFirst(){
			first = $('ul#listticker li:first').html();
			
			$('ul#listticker li:first')
			.animate({opacity: 0}, speed)
			.fadeOut('slow', function() {$(this).remove();});
			addLast(first);
		}
		
		function addLast(first){
			last = '<li style="display:none">'+first+'</li>';
			$('ul#listticker').append(last)
			$('ul#listticker li:last')
			.animate({opacity: 1}, speed)
			.fadeIn('50')
		}
		function newsticker()
		{
			// algorithm:
			// get last element, remove it from the list,
			// add to first position with hidden style
			// slideDown the new first element
			// continue
			last = $('ul#listticker li:last').hide().remove();
			
			
			
			 $('ul#listticker').prepend(last);
			 $('ul#listticker li:first')
			     
                        .animate({opacity: 0}, speed)
			.fadeOut('slow');
			 $('ul#listticker li:first')
                         
                         .slideDown("slow");

			 $('ul#listticker li:first')
			.animate({opacity: 1}, speed)
		
                        .fadeIn('slow')
			
			
		}
		function newsticker2()
		{
			// algorithm:
			// get last element, remove it from the list,
			// add to first position with hidden style
			// slideDown the new first element
			// continue
			last = $('ul#listticker2 li:last').hide().remove();
			
			
			 $('ul#listticker2').prepend(last);
			 $('ul#listticker2 li:first')
			
			.animate({opacity: 0}, speed)
			.fadeOut('slow');
			 $('ul#listticker2 li:first').slideDown("200"); 
			 $('ul#listticker2 li:first')
			.animate({opacity: 1}, speed)
			.fadeIn('slow')
			
			
		}
	
	//interval = setInterval(removeFirst, pause);
	interval2 = setInterval(newsticker, pause); 
	interval3 = setInterval(newsticker2, pause); 
});

function limpautiliz(camp){

		if(camp.value=="Utilizador"){
			camp.value="";
			document.getElementById("password").value="";
		}

}



/*Sistema de Gestão newsletter*/








