var pause	= 10000;
var timer	= "";

var hourResult = 0;
var minResult  = 0;
var secResult  = 0;

function countdown()
{
   currentDate 	= new Date();
   dateResult	= myDate - currentDate;
   dayResult	= Math.floor(dateResult/(60*60*1000*24)*1)
   
   hourResult = Math.floor((dateResult%(60*60*1000*24))/(60*60*1000)*1) + ( dayResult * 24 );
   minResult  = Math.floor(((dateResult%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
   secResult  = Math.floor((((dateResult%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
   
     
   if(dayResult==0&&hourResult==0&&minResult==0&&secResult== 0){      
      pause_me();
      return
   }
   
   if(myDate<currentDate){
      dayResult  = -dayResult-1;
      hourResult = -hourResult-1;
      minResult  = -minResult-1;
      secResult  = -secResult;   
   }

   timer=setTimeout("countdown()",1000);
   
   // dayResult   +"<span style='font-size:12;vertical-align:top'> Days  </span>"+
   
   //document.getElementById("display").innerHTML=hourResult
   //+"<span style='font-size:12;vertical-align:top'> Hours</span> "+minResult
   //+"<span style='font-size:12;vertical-align:top'> Minutes</span> "+secResult
   //+"<span style='font-size:12;vertical-align:top'> Seconds</span>"
}

function pause_me(){
   clearTimeout(timer);
   setTimeout("countdown()",pause);
}


/*var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

var pageTracker = _gat._getTracker("UA-648439-4");
pageTracker._trackPageview();
*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

// filtra por categorias na listagem de noticias
function noticias_categorias( valor )
{
	document.location = 'noticias_lista.php?categoria_id=' + valor; 
}

//filtra por categorias na listagem de agenda
function agenda_categorias( valor )
{
	document.location = 'agenda.php?categoria_id=' + valor; 
}

//filtra por categorias na listagem de galerias
function galerias_categorias( valor )
{
	document.location = 'galerias_index.php?categoria_id=' + valor; 
}

//filtra por categorias na listagem de videos
function videos_categorias( valor )
{
	document.location = 'videos.php?categoria_id=' + valor; 
}

// testa form de cadastro
function testa_cadastro()
{
	var f = document.form_cadastro;
		
	var msg = '';
	
	if ( f.login.value == '' )
	{
		msg = msg + '- Login\n';
	}
	
	if ( f.senha.value == '' )
	{
		msg = msg + '- Senha\n';
	}
	
	if ( f.senha_verifica.value == '' )
	{
		msg = msg + '- Senha\n';
	}
	else
	{
		if ( f.senha_verifica.value != f.senha.value )
		{
			msg = msg + '- As senhas digitadas não estão iguais.\n'
		}
	}
	
	if ( f.nome.value == '' )
	{
		msg = msg + '- Nome\n';
	}
	
	if ( f.email.value == '' )
	{
		msg = msg + '- Email\n';
	}	
	
	/*
	if ( f.cd_contrato.options[ f.cd_contrato.selectedIndex ].value == '' )
	{
		msg = msg + '- Contrato\n';
	}
	
	
	
		
	if ( f.qtd_meses_intervalo.value == '' )
	{
		msg = msg + '- Intervalo entre as avaliações\n';
	}
	else
	{		
		try
		{
			var qtd = f.qtd_meses_intervalo.value;
			var exp =/(^\d+$)|(^\d+\.\d+$)/
			
			if ( ! exp.test(qtd) || qtd <= 0 )
			{			
				msg = msg + '- Intervalo entre as avaliações\n';
			}
		}
		catch( e )
		{			
			return false;
		}
	}
	*/
	
	
	if ( msg == '' )
	{
		f.submit();
		return true;
	}
	else
	{
		alert('Você precisa preencher corretamente os seguintes campos:\n' + msg);
		return false;
	}
}




