/*Open Flash*/
function openFlash(path,variaveis,_width,_height)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,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>')
}

function verificacao(nomeForm){

var msgBranco = "Favor preencher o campo";//Mensagem para campos vazios
var msgBrancoRadio = "Favor selecionar o campo";//Mensagem para radio buttons
var msgEmail = "com um e-mail válido";
var msgNumero = "Somente com números";
var msgCPF = "com um CPF válido";
var msgCEP = "com um CEP válido";
var msgCNPJ = "com um CNPJ válido";
var msgFone = "com um telefone válido";
var msgCaracteres = "com no mínimo";
var msgLink = "com um link válido";
var msgData = "com uma data válida";
var msgCkecked = "Favor selecionar ao menos uma opção do campo";
var msgHora = "com uma hora válida";
var msgCompara1 = "O campo";
var msgCompara2 = "deve ser idêntico ao campo";
var msgArquivo1 = "O nome de arquivo no campo"
var msgArquivo2 = "não pode conter espaços ou acentos"
var msgFormato1 = "O formato de arquivo no campo"
var msgFormato2 = "deve ser"

fv = document.getElementById(nomeForm);

for(q=0;q<fv.length;q++){
	if(fv[q].getAttribute("verificar")!='' && fv[q].getAttribute("verificar")!=undefined ){
		if(fv[q].value==''){
			alert(msgBranco+' "'+fv[q].getAttribute("verificar")+'".');
			fv[q].focus();
			return false;
		}
		if(fv[q].getAttribute("type")=='checkbox' || fv[q].getAttribute("type")=='radio'){
			h=0;
			for(y=1;y<=fv[q].getAttribute("quantCampos");y++){
					if(fv[q+y-1].checked==false){
						h++
					}
			}
			if(h==fv[q].getAttribute("quantCampos")){
				if(fv[q].getAttribute("type")=='checkbox'){
					alert(msgCkecked+' "'+fv[q].getAttribute("verificar")+'".');
				}else{
					alert(msgBrancoRadio+' "'+fv[q].getAttribute("verificar")+'".');
				}
				fv[q].focus();
				return false;	
			}
		}
	}
	if(fv[q].getAttribute("email")!=undefined && fv[q].value!=""){
		formatoEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(fv[q].value)
		if(formatoEmail==false ){
			alert(msgBranco+' "'+fv[q].getAttribute("email")+'" ' + msgEmail+'.');
			fv[q].focus();
			return false;
		}
	}
	if (fv[q].getAttribute("numero")!=undefined && fv[q].value!=""){
		if((fv[q].value * 0)!=0){					
			alert(msgBranco+'"'+fv[q].getAttribute("numero")+'" '+msgNumero+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("cpf")!=undefined && fv[q].value!=""){
		valorCPF = String(fv[q].value).replace(/\D/g,"");
		if(valorCPF.length!=11){
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false;
		}
		var i; 
		s = valorCPF; 
		var c = s.substr(0,9); 
		var dv = s.substr(9,2); 
		var d1 = 0; 
		for (i = 0; i < 9; i++){ 
			d1 += c.charAt(i)*(10-i); 
		} 
		if (d1 == 0){ 
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false;
		} 
		d1 = 11 - (d1 % 11); 
		if (d1 > 9){d1 = 0}; 
		if (dv.charAt(0) != d1){ 
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false;
		}
		d1 *= 2; 
		for (i = 0; i < 9; i++){ 
			d1 += c.charAt(i)*(11-i); 
		} 
		d1 = 11 - (d1 % 11); 
		if (d1 > 9) {d1 = 0}; 
		if (dv.charAt(1) != d1){ 
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false; 
		} 
	}
	if(fv[q].getAttribute("cep")!=undefined && fv[q].value!=""){
		valorCEP = String(fv[q].value).replace(/[.-]/g,"");
		if(valorCEP.length!=8){
			alert(msgBranco+' "'+fv[q].getAttribute("cep")+'" '+msgCEP+'.');
			fv[q].focus();
			return false;
		}
		if(valorCEP == "00000000" || valorCEP == "11111111" || valorCEP == "22222222" || valorCEP == "33333333" || valorCEP == "44444444" || valorCEP == "55555555" || valorCEP == "66666666" || valorCEP == "77777777" || valorCEP == "88888888" || valorCEP == "99999999"){
			alert(msgBranco+' "'+fv[q].getAttribute("cep")+'" '+msgCEP+'.');
			fv[q].focus();
			return false;	
		}
		if((valorCEP.charAt(0)==valorCEP.charAt(2) && valorCEP.charAt(1)==valorCEP.charAt(3) && valorCEP.charAt(2)==valorCEP.charAt(4))){
			alert(msgBranco+' "'+fv[q].getAttribute("cep")+'" '+msgCEP+'.');
			fv[q].focus();
			return false;	
		}
	}
	if(fv[q].getAttribute("cnpj")!=undefined && fv[q].value!=""){
		valorCNPJ = String(fv[q].value).replace(/\D/g,"");
		if(valorCNPJ.length!=14){
			alert(msgBranco+' "'+fv[q].getAttribute("cnpj")+'" '+msgCNPJ+'.');
			fv[q].focus();
			return false;
		}
		a = [];
		b = new Number;
		c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
		for (i=0; i<12; i++){
			a[i] = valorCNPJ.charAt(i);
			b += a[i] * c[i+1];
		}
		if ((x = b % 11) < 2){
			a[12] = 0
		}else{ 
			a[12] = 11-x 
		}
		b = 0;
		for (y=0; y<13; y++){
			b += (a[y] * c[y]);
		}
		if ((x = b % 11) < 2){ 
			a[13] = 0; 
		}else{ 
			a[13] = 11-x; 
		}
		if((valorCNPJ.charAt(12) != a[12]) || (valorCNPJ.charAt(13) != a[13])){
			alert(msgBranco+' "'+fv[q].getAttribute("cnpj")+'" '+msgCNPJ+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("fone")!=undefined && fv[q].value!=""){
		valorFone = String(fv[q].value).replace(/\D/g,"");
		if((/[a-z]/g).test(valorFone)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("fone")+'" '+msgFone+'.');
			fv[q].focus();
			return false;	
		}
		if(valorFone == "0000000000" || valorFone == "1111111111" || valorFone == "2222222222"|| valorFone == "3333333333" || valorFone == "4444444444" || valorFone == "5555555555" || valorFone == "6666666666" || valorFone == "7777777777" || valorFone == "8888888888" || valorFone == "9999999999"){
			alert(msgBranco+' "'+fv[q].getAttribute("fone")+'" '+msgFone+'.');
			fv[q].focus();
			return false;	
		}
		if((valorFone.charAt(0)==valorFone.charAt(2) && valorFone.charAt(1)==valorFone.charAt(3) && valorFone.charAt(2)==valorFone.charAt(4) &&valorFone.charAt(3)==valorFone.charAt(5) && valorFone.charAt(4)==valorFone.charAt(6))){
			alert(msgBranco+' "'+fv[q].getAttribute("fone")+'" '+msgFone+'.');
			fv[q].focus();
			return false;	
		}
	}
	if(fv[q].getAttribute("caracteres")!=undefined && fv[q].value!=""){
		numeroCaractere = fv[q].getAttribute("quantCaracteres");
		valorCaractere = String(fv[q].value).replace(/[ ]/g,"");
		if(valorCaractere.length<numeroCaractere){
			alert(msgBranco+' "'+fv[q].getAttribute("caracteres")+'" '+msgCaracteres+' "'+fv[q].getAttribute("quantCaracteres")+'" caracteres.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("link")!=undefined && fv[q].value!=""){
		testeURL_a = /^http:\/\//;
		testeURL_b = /^https:\/\//;
		testeURL_c = /[^a-z:\/\/]/g;
		if(testeURL_a.test(fv[q].value)==false || testeURL_b.test(fv[q].value)==false && testeURL_c.test(fv[q].value)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("link")+'" '+msgLink+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("data")!=undefined && fv[q].value!=""){
		valorData = String(fv[q].value).replace(/\D/g,"");
		dataTeste_a = valorData.charAt(0) + valorData.charAt(1);
		dataTeste_b = valorData.charAt(2) + valorData.charAt(3);
		dataTeste_c = valorData.charAt(4) + valorData.charAt(5) + valorData.charAt(6) + valorData.charAt(7);
		dataTesteBi = dataTeste_c / 4;
		if(dataTeste_b>12){
			alert(msgBranco+' "'+fv[q].getAttribute("data")+'" '+msgData+'.');
			fv[q].focus();
			return false;
		}
		if(dataTeste_b==01 || dataTeste_b==03 || dataTeste_b==05 || dataTeste_b==07 || dataTeste_b==08 || dataTeste_b==10 || dataTeste_b==12){
			valorMes=31
		}
		if(dataTeste_b==04 || dataTeste_b==06 || dataTeste_b==09 || dataTeste_b==11){
			valorMes=30
		}
		if(dataTeste_b==02){
			if((/\D/g).test(dataTesteBi)==false){
				valorMes=29;
			}else{
				valorMes=28;
			}
		}
		dataTeste_c = /-/g;
		if(dataTeste_a>valorMes || dataTeste_c.test(fv[q].value)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("data")+'" '+msgData+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("hora")!=undefined && fv[q].getAttribute("hora")!="" && fv[q].value!=""){//hora
		valorHora = String(fv[q].value).replace(/\D/g,"");
		horaTeste_a = valorHora.charAt(0) + valorHora.charAt(1);
		horaTeste_b = valorHora.charAt(2) + valorHora.charAt(3);
		horaTeste_c = /-/g;
		if(horaTeste_a>24 || horaTeste_b>59 || horaTeste_c.test(fv[q].value)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("hora")+'" '+msgHora+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("verificaNomeArquivo")!=undefined && fv[q].getAttribute("verificaNomeArquivo")!="" && fv[q].value!=""){//hora
		var arq = fv[q].value.split("\\")
		var nome = arq[arq.length-1]
		if(nome.split(" ").length > 1){
			alert(msgArquivo1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgArquivo2 + ".")
			fv[q].focus();
			return false;
		}
		var ext = nome.split(".")
		switch(fv[q].getAttribute("formato")){
			case "audio":
				if(ext[ext.length-1].toLowerCase()!="mp3"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " mp3.")
					fv[q].focus();
					return false;
				}
				break;
			case "video":
				if(ext[ext.length-1].toLowerCase()!="flv"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " mp3.")
					fv[q].focus();
					return false;
				}
				break;
			case "arquivo":
				if(ext[ext.length-1].toLowerCase()=="exe" || ext[ext.length-1].toLowerCase()=="bat" || ext[ext.length-1].toLowerCase()=="dll" || ext[ext.length-1].toLowerCase()=="vbs" || ext[ext.length-1].toLowerCase()=="scr"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " não " + msgFormato2 + " " + ext[ext.length-1].toLowerCase() + ".")
					fv[q].focus();
					return false;
				}
				break;
			case "imagem":
				if(ext[ext.length-1].toLowerCase()!="jpg" && ext[ext.length-1].toLowerCase()!="gif"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " jpg ou gif.")
					fv[q].focus();
					return false;
				}
				break;
		}
		acentos = /[áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÅÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ=+^~&%$#@]/
		if(nome.search(acentos)!=-1){
			alert(msgArquivo1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgArquivo2 + ".")
			fv[q].focus();
			return false;
		}			
	}
	if(fv[q].getAttribute("comparar")!=undefined && fv[q].getAttribute("comparar")!="" && fv[q].value!=""){
		campoComp = fv[q].getAttribute("campo")
		switch(fv[q].getAttribute("modoComparar")){
		case "maior":
			if(fv[q].value < document.getElementById(campoComp).value){
				alert(msgCompara1+' "'+fv[q].getAttribute("comparar")+'" '+msgCompara2+' "'+document.getElementById(campoComp).getAttribute("nomeComparar")+'".');
				fv[q].focus();
				return false;
			}			
			break;
		case "menor":
			if(fv[q].value > document.getElementById(campoComp).value){
				alert(msgCompara1+' "'+fv[q].getAttribute("comparar")+'" '+msgCompara2+' "'+document.getElementById(campoComp).getAttribute("nomeComparar")+'".');
				fv[q].focus();
				return false;
			}			
			break;
		case "igual":
			if(fv[q].value != document.getElementById(campoComp).value){
				alert(msgCompara1+' "'+fv[q].getAttribute("comparar")+'" '+msgCompara2+' "'+document.getElementById(campoComp).getAttribute("nomeComparar")+'".');
				fv[q].focus();
				return false;
			}		
			break;		
		}

	}
}}

//Função para colocar data e as horas atualizando em seg e seg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function mostradata(){
dt = new Date()
dia = dt.getDate()
mes = dt.getMonth()
ano = dt.getYear()
function CriaArray (n) {
this.length = n }
NomeMes = new CriaArray(12)
NomeMes[0] = "Janeiro"
NomeMes[1] = "Fevereiro"
NomeMes[2] = "Março"
NomeMes[3] = "Abril"
NomeMes[4] = "Maio"
NomeMes[5] = "Junho"
NomeMes[6] = "Julho"
NomeMes[7] = "Agosto"
NomeMes[8] = "Setembro"
NomeMes[9] = "Outubro"
NomeMes[10] = "Novembro"
NomeMes[11] = "Dezembro"
var nmData = "<span style='font-size:11px; color:#3B6602;'>"+dia+" de "+NomeMes[mes]+" de "+ano+"</span>"
nmDate.innerHTML= nmData;
}

function mostrahora(){
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds()
	if (hours <=9)
hours="0"+hours;
	if (minutes<=9)
minutes="0"+minutes;
	if (seconds<=9)
seconds="0"+seconds;
	var cdate="<span style='font-size:11px; color:#3B6602;'>"+hours+":"+minutes+":"+seconds+" "+"</span>" 
	clock.innerHTML= cdate;
setTimeout("mostrahora()",1000);
}

function limpaForm(){
	for( i=0; i<document.frm.length; i++ )
	{
		document.frm[i].value = ""
	}
}

//FUNÇÃO IMPRIMIR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function DoPrinting() {
	if (!window.print){
		alert("Use o Netscape ou Internet Explorer \n nas versões 4.0 ou superior!")
		return
	}
	window.print()
}
	
function VerificarForm()
{
	for( i=0; i<document.frm.length; i++ )
	{
		if( document.frm[i].value == "" && document.getElementById("msg_" + document.frm[i].name) )
		{
			alert(document.getElementById("msg_" + document.frm[i].name).innerHTML);
			document.frm[i].focus();
			return false;
		} else if(!(document.frm[i].value.indexOf("@") >= 3 && document.frm[i].value.indexOf(".") >= 6 && document.frm[i].value.length >= 9) && document.getElementById("msg_email_" + document.frm[i].name) ) {
			alert(document.getElementById("msg_email_" + document.frm[i].name).innerHTML);
			document.frm[i].select();
			return false;
		}
	}
}

function textosize(i) {
	obj1 = document.getElementById("conteudo");
	tag0 = obj1.getElementsByTagName("a");
	tag1 = obj1.getElementsByTagName("h2");
	tag2 = obj1.getElementsByTagName("h3");
	tag3 = obj1.getElementsByTagName("h4");
	tag4 = obj1.getElementsByTagName("p");
	tag5 = obj1.getElementsByTagName("em");
	tag6 = obj1.getElementsByTagName("strong");
	tag7 = obj1.getElementsByTagName("div");
	tag8 = obj1.getElementsByTagName("font");
	tag0size = tag0.length
	tag1size = tag1.length
	tag2size = tag2.length
	tag3size = tag3.length
	tag4size = tag4.length
	tag5size = tag5.length
	tag6size = tag6.length
	tag7size = tag7.length
	tag8size = tag8.length
	if (i == 1) { soma = 0; }
	if (i == 2) { soma = 3; }
	if (i == 3) { soma = 4; }
	obj1.style.fontSize = 10+soma+'px';
	obj1.style.lineHeight = 15+soma+'px';
	for(a=0;a<tag0size;a++) { tag0[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag1size;a++) { tag1[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag2size;a++) { tag2[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag3size;a++) { tag3[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag4size;a++) { tag4[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag5size;a++) { tag5[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag6size;a++) { tag6[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag7size;a++) { tag7[a].style.fontSize = 10+soma+'px'; }
	for(a=0;a<tag8size;a++) { tag8[a].style.fontSize = 10+soma+'px'; }
	window.top.altera_iframe_meio(eval(document.getElementById('altura')).clientHeight);
}