function ToggleMenus(omenu,osubmenu){
	if(omenu!=='#menu_1 a.item'){
		$('#menu_1 a.item').toggle(
		function(){
				$('#menu_1 .submenus').slideDown(450);
		},
		function(){
				$('#menu_1 .submenus').slideUp(450);
		});
	}
	if(omenu!=='#menu_2 a.item'){
		$('#menu_2 a.item').toggle(
		function(){
				$('#menu_2 .submenus').slideDown(450);
		},
		function(){
				$('#menu_2 .submenus').slideUp(450);
		});
	}
	if(omenu!=='#menu_3 a.item'){
		$('#menu_3 a.item').toggle(
		function(){
				$('#menu_3 .submenus').slideDown(450);
		},
		function(){
				$('#menu_3 .submenus').slideUp(450);
		});
	}
	if(omenu!=='#menu_4 a.item'){
		$('#menu_4 a.item').toggle(
		function(){
				$('#menu_4 .submenus').slideDown(450);
		},
		function(){
				$('#menu_4 .submenus').slideUp(450);
		});
	}
	//menu 5 was removed
	if(omenu!=='#menu_6 a.item'){
		$('#menu_6 a.item').toggle(
		function(){
			var iniHeight=$(".wrapEmps").height();
			$(".wrapEmps").height(iniHeight-160);
			$('#menu_6 .submenus').slideDown(450);
		},
		function(){
			var iniHeight=$(".wrapEmps").height();
			
			$('#menu_6 .submenus').slideUp(450,function(){
				$(".wrapEmps").height(iniHeight+160);
			});
		}
		);
	}
	//este não necessita de verificação, pois está sempre aberto por defeito
	$('#menu_7 a.item').toggle(
	function(){
			$('#menu_7 .submenus').slideUp(450);
	},
	function(){
			$('#menu_7 .submenus').slideDown(450);
	});
	//toggle para o que está aberto por defeito
	$(omenu).toggle(
	function(){
			$(osubmenu).slideUp(450);
	},
	function(){
			$(osubmenu).slideDown(450);
	});
}
/////////
function ToggleTabs(){
		$('ul.tabs li').each(function(){$(this).click(//instead of toggle
			function(){
				//reset aos outros;	
				var divToShow = $('a',this).attr('rel');	
				$('.images_container').fadeOut(1);
				$('ul.tabs li').each(function(){
					$(this).css('background','url(images/fundo_tab.jpg) repeat-x');
					$('img:eq(0)',this).attr('src','images/left_tab.jpg');
					$('img:eq(1)',this).attr('src','images/right_tab.jpg');
				});
				$('#'+divToShow).fadeIn();
				$(this).css('background','url(images/fundo_tab_hov.jpg) repeat-x');
				$('img:eq(0)',this).attr('src','images/left_tab_hov.jpg');
				$('img:eq(1)',this).attr('src','images/right_tab_on.jpg');
				
			});					  
	});
}
function ToggleTabs2(){
		$('ul.tabs li').each(function(){$(this).click(//instead of toggle
			function(){
				$('ul.tabs li').each(function(){
					$(this).css('background','url(images/fundo_tab.jpg) repeat-x');
					$('img:eq(0)',this).attr('src','images/left_tab.jpg');
					$('img:eq(1)',this).attr('src','images/right_tab.jpg');
				});
				$(this).css('background','url(images/fundo_tab_hov.jpg) repeat-x');
				$('img:eq(0)',this).attr('src','images/left_tab_hov.jpg');
				$('img:eq(1)',this).attr('src','images/right_tab_on.jpg');
				
			});					  
	});
}
/////////
jQuery.jQueryRandom = 0;  
jQuery.extend(jQuery.expr[":"],  
{  
   random: function(a, i, m, r) {  
	   if (i == 0) {  
		   jQuery.jQueryRandom = Math.floor(Math.random() * r.length);  
	   };  
	   return i == jQuery.jQueryRandom;  
   }  
});  

function CheckRef(oRef,oVal){
	if($("#"+oRef).attr("value")==oVal)
	{
		$("#"+oRef).attr("value","");
	}
	else{
		$("#"+oRef).attr("value","*"+$("#"+oRef).attr("value")+"*");
	}
}	
////////
function CheckValue(oId , oVal){
	if($("#"+oId).attr("value")==oVal)
	{
		$("#"+oId).attr("value","");
	}
}
/////////
function ResetValue(oId , oVal){
	if(!$("#"+oId).attr("value"))
	{
		$("#"+oId).attr("value",oVal);
	}
}
////Chamar detalhe
function myajax(oDiv, oUrl){
    //$('#divloader').html('<img class="ajax_loader" src="../images/ajaxloader.gif">');
    $.get(oUrl, function(dados){
        $(oDiv).empty();
        $(oDiv).html((dados));
		//alert('olé');
		//$('#divloader').html('');
        return true;
   });
};
////sIFR// color:#008180//fontSize:2em;
/*
$(function () {
	$.sifr({path:'../sIFR'});
	$('h1').sifr({
	font:'Gill Sans',
	textTransform: 'uppercase',
	textAlign:'left',
	color:'#008180',
	width:500,
	height:50
	});
	$('h2.emps').sifr({
	font:'Gill Sans',
	textTransform: 'uppercase',
	textAlign:'left',
	color:'#008180',
	width:500,
	height:30
	});
});
*/
//Noticias Rolantes
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
  function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 
   $("li.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
     $(this).css('top','210px');
   });
   $("li.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
   old_headline = current_headline;
}

/////
$(document).ready(function(){
	headline_count = $("li.headline").size();
    $("li.headline:eq("+current_headline+")").css('top','5px');
    headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
    $('ul.news').hover(function() {
     clearInterval(headline_interval);
    }, function() {
    	headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
    	headline_rotate();
    });
})
 
/**************************/
// Create a self-invoking anonymous function. That way, 
// we're free to use the jQuery dollar symbol anywhere within.

// We name our plugin "newscroll". When creating our function, 
// we'll allow the user to pass in a couple of parameters.
$.fn.newsScroll = function(options) {
	// For each item in the wrapped set, perform the following. 
	return this.each(function() {	
		var
		  // Caches this - or the ul widget(s) that was passed in.
		  //  Saves time and improves performance.
		  $this = $(this), 
		  // If the user doesn't pass in parameters, we'll use this object. 
		  defaults = {
		  	speed: 400, // How quickly should the items scroll?
		  	delay: 3000, // How long a rest between transitions?
		  	list_item_height: $this.children('li').outerHeight() // How tall is each list item? If this parameter isn't passed in, jQuery will grab it.
	     },
	      // Create a new object that merges the defaults and the 
	      // user's "options".  The latter takes precedence.
		  settings = $.extend({}, defaults, options);
	  // This sets an interval that will be called continuously.

		function accao() {
	  	    // Get the very first list item in the wrapped set.
	  	    $this.children('li:first')
	  	    		// Animate it
	  	    		.animate({ 
	  	    			marginTop : '-' + settings.list_item_height, // Shift this first item upwards.
	  	    		   opacity: 'hide' }, // Fade the li out.
	  	    		   
	  	    		   // Over the course of however long is 
	  	    		   // passed in. (settings.speed)
	  	    		   settings.speed, 
	  	    		   
	  	    		   // When complete, run a callback function.
	  	    		   function() {
	  	    		   	
	  	    		   	// Get that first list item again. 
	  	 					$this.children('li:first')
	  	 					     .appendTo($this) // Move it the very bottom of the ul.
	  	 					     
	  	 					     // Reset its margin top back to 0. Otherwise, 
	  	 					     // it will still contain the negative value that we set earlier.
	  	 					     .css('marginTop', 0) 
	  	 					     .fadeIn(300); // Fade in back in.
  		 			  }
 	 			  ); // end animate
 	  }		

		var myinterval = setInterval(accao, settings.delay);
		
		$this.children('li').mouseover(function(){
			//$this.children('li').stop();
			window.clearInterval(myinterval);
		});
		
		$this.children('li').mouseout(function(){
			myinterval = setInterval(accao, settings.delay);
		});

		

	  });
}


