// JavaScript Document

/*SCRIPT PARA FOCUS DO CAMPO BUSCAR*/
	$(function() {
		swapValues = [];
		$(".swap_value").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValues[i]) {
			$(this).val("");
			}
			}).blur(function(){
			if ($.trim($(this).val()) == "") {
			$(this).val(swapValues[i]);
		}
		});
		});
	});
	
/*SCRIPT PARA MENU*/
	$(document).ready(function() {
	$('#menu li.headlink').hover(
		function() {
		$('ul', this).css('display', 'block');	
		},
		function() {
		$('ul', this).css('display', 'none');
		
		});
	});
	
	$(document).ready(function() {
	$('#menu li.headlink').hover(
		function() {
		$('div.container_submenu_form', this).css('visibility', 'visible');	
		},
		function() {
		$('div.container_submenu_form', this).css('visibility', 'hidden');
		
		});
	});

/*SCRIPT PARA CYCLE*/
	/*$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
		$(pager).find('a').removeClass('active')
			.filter('a:eq('+currSlideIndex+')').addClass('active');
	};

	$(function() {
		$('#destaqueImages').cycle({
			timeout: 3000,
			pager:  '#destaqueNav',
			pagerAnchorBuilder: function(idx, slide) {
				idx = idx+1;
				return '<a href="#">'+idx+'</a>';
			}
		});
		
	});*/
	
	
$(document).ready
(function() 
	{
		if($('a.nyroModal').nyroModal != undefined)
		{
			$('a.nyroModal').nyroModal
			(
				{ 
				zIndexStart: 999,
				closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="Fechar">X</a>', // Adding automaticly as the first child of #nyroModalWrapper 
				contentLoading: '<a href="#" class="nyroModalClose" title="Cancelar">Cancelar</a>', // Loading div content
				contentError: 'O conteúdo solicitado não foi encontrado... tente novamente mais tarde.<br /><a href="#" class="nyroModalClose">Fechar</a>' // Content placed in the loading div in case of error
				}
			);
		}
	}
);	


/**
* INICIO - Faz a transição dos destaques das páginas principais.
*/

tvfCorrente = 1;
tvfProximo = 2;
tvfTotal = 0;
tvfPausa = false;

function hideAllTvFlash() {
	
	for (i = 1 ; i <= tvfTotal ; i++) {
		MM_showHideLayers('destaqueTvFlash_'+i,'','hide'); 
		document.getElementById('linkTvFlash_'+i).className = '';
	}
	i=0;
}

function iniciaTvFlash(tvfTotalTemp) { 
	
	tvfTotal = tvfTotalTemp;
	
	if(tvfTotal > 1){
	
		intervaloTv = window.setInterval(function()
		{
			if (tvfCorrente == tvfTotal) {
				tvfProximo = 1;
			} else if (tvfCorrente > tvfTotal) {
				tvfCorrente=1;
			}
			
			hideAllTvFlash();
			document.getElementById('linkTvFlash_'+tvfProximo).className = 'active';
			//MM_showHideLayers('destaqueTvFlash_'+tvfCorrente,'','hide'); 
			MM_showHideLayers('destaqueTvFlash_'+tvfProximo,'','show');
			  
			tvfCorrente++;
			tvfProximo++;
			
		}, 15000);
	
	}
	
}

function reiniciaTvFlash() { 
	window.clearInterval(intervaloTv);
	iniciaTvFlash(tvfTotal);
}

function trocaTvfs(corrente, proximo) {
	tvfCorrente = corrente;
	tvfProximo = proximo;
	document.getElementById('linkTvFlash_'+tvfCorrente).className = 'active';
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


/**
* FIM - Faz a transição dos destaques das páginas principais.
*/


// adiciona uma função ao window.onload
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	}
	else{
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
