// ---------------------------------------- +
// - Função para executar flashs
// ---------------------------------------- +
function RodarFlash( path, variaveis, _width, _height ) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+_width+'" height="'+_height+'">');
	document.write('<param name="movie" value="'+path+'?'+variaveis+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="'+path+'?'+variaveis+'" width="'+_width+'" height="'+_height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
	document.write('</object>');
}



// ---------------------------------------- +
// - Função limpa campo busca
// ---------------------------------------- +
function limpaTexto(campo, valor){
	if(document.getElementById(campo).value == valor){
		document.getElementById(campo).value = "";
	}else if(document.getElementById(campo).value == ""){
		document.getElementById(campo).value = valor;
	}
}

// --------------------------------------------------- +
// - Função para abrir e  fechar a introdução na home
// --------------------------------------------------- +
function abrirFecharIntroducao( nomeElemento ) {
	
	divcalendario = document.getElementById( 'calendario' );	
	divIntroducao = document.getElementById( nomeElemento );
	comboscalendario = divcalendario.getElementsByTagName( "select" );
	
	// ----------------------------------------------------------- +
	// - esconde todos os selects da pagina (resolve bug com ie)
	// ----------------------------------------------------------- +
	for( x = 0; x < comboscalendario.length; x++ ) {
		if( divIntroducao.style.display == "" || divIntroducao.style.display == "none" ) {
			comboscalendario[ x ].style.visibility = "hidden";
		} else {
			comboscalendario[ x ].style.visibility = "visible";			
		}
	}
	
	if( divIntroducao.style.display == "" || divIntroducao.style.display == "none" ) {
		divIntroducao.style.display = "block";	
	} else {		
		divIntroducao.style.display = "none";	
	}
	
}
function validaCPF(cpf) 
{
  erro = new String;
if(cpf.length > 11){return false;}
	if (cpf.length == 11)
	{	
			cpf = cpf.replace('.', '');
			cpf = cpf.replace('.', '');
			cpf = cpf.replace('-', '');

			var nonNumbers = /\D/;
	
			if (nonNumbers.test(cpf)) 
			{
					erro = "A verificacao de CPF suporta apenas nï¿½meros!"; 
			}
			else
			{
					if (cpf == "00000000000" || 
							cpf == "11111111111" || 
							cpf == "22222222222" || 
							cpf == "33333333333" || 
							cpf == "44444444444" || 
							cpf == "55555555555" || 
							cpf == "66666666666" || 
							cpf == "77777777777" || 
							cpf == "88888888888" || 
							cpf == "99999999999") {
							
							erro = "CPF inválido!"
					}
	
					var a = [];
					var b = new Number;
					var c = 11;

					for (i=0; i<11; i++){
							a[i] = cpf.charAt(i);
							if (i < 9) b += (a[i] * --c);
					}
	
					if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
					b = 0;
					c = 11;
	
					for (y=0; y<10; y++) b += (a[y] * c--); 
	
					if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	
					if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])) {
						erro = "Nï¿½mero de CPF invï¿½lido.";
					}
			}
	}
	else
	{
		if(cpf.length == 0)
			return false
		else
			erro = "CPF Inválido.";
	}
	if (erro.length > 0) {
			alert(erro);
			return false;
	} 	
	return cpf;	
}