function valida(form){
				
	for (i=0;i<form.length;i++)
	{
		var obg = form[i].obrigatorio;
		if (obg==1)
		{
			if (form[i].value == "")
			{
				var nome = form[i].descricao
				alert("O campo " + nome + " é obrigatório.")
				form[i].focus();
				return false
			}
			else if(form[i].value == "0")
			{
				var nome = form[i].descricao
				alert("O campo " + nome + " é obrigatório.")
				form[i].focus();
				return false
			}
		}
	}
	return true
}
function checarEmail(email){
	var valor = email.value;
	if (valor != ""){
	    if(valor.indexOf("@") == -1 || valor.indexOf(".") == -1 || valor == ""){
	    	alert("Insira um e-mail valido!");
	    	email.focus();
	    	
	    }
	}
}
function SomenteNumero(e)
{ 
	var key;

	if (window.event) 
	{
		key = event.keyCode;
	}
	else
	{ 
		key = e.which;
	}

	if(key > 47 && key < 58 || key == 8 || key == 0)
	{
		return; 
	}
	else
	{
		if(window.event)
		{
			window.event.returnValue = null; 
		}
		else 
		{
			e.preventDefault();
		}
	}
}
function Mascara(src, mask) 
{
	 var i = src.value.length;
	 var saida = mask.substring(0,1);
	 var texto = mask.substring(i)
	 if (texto.substring(0,1) != saida) 
	 {
		  src.value += texto.substring (0,1);
	 }
}
function maxLength(textAreaField, limit) {
	if (textAreaField.value.length > limit) {
		alert("Numero de caracteres excedeu o limite em "+(textAreaField.value.length-limit)+" caracter(es)");
		textAreaField.focus();
	}
}

function validaEnviaAmigo(form){
	
	for (i=0;i<form.length;i++)
	{
		
		var obg = form[i].obrigatorio;
		if (obg==1)
		{
			if(form[i].value == "seu nome*")
			{				
				var nome = form[i].descricao
				alert("O campo " + nome + " é obrigatório.")
				form[i].focus();
				return false
			}
			else if(form[i].value == "seu e-mail*")
			{				
				var nome = form[i].descricao
				alert("O campo " + nome + " é obrigatório.")
				form[i].focus();
				return false
			}
			else if(form[i].value == "nome do destinatário*")
			{				
				var nome = form[i].descricao
				alert("O campo " + nome + " é obrigatório.")
				form[i].focus();
				return false
			}
			else if(form[i].value == "e-mail do destinatário*")
			{				
				var nome = form[i].descricao
				alert("O campo " + nome + " é obrigatório.")
				form[i].focus();
				return false
			}
			
		}
	}
	return true
}

//envento onkeyup
function mascaraCPF(e, CPF) {
    var evt = e || window.event;
    kcode=evt.keyCode;
    if (kcode == 8) return;
    if (CPF.value.length == 3) { CPF.value = CPF.value + '.'; }
    if (CPF.value.length == 7) { CPF.value = CPF.value + '.'; }
    if (CPF.value.length == 11) { CPF.value = CPF.value + '-'; }
}

//valida o CPF digitado
function validarCPF(Objcpf){
	var valor = Objcpf.value;
	if (valor != ""){
	    var cpf = Objcpf.value;
	    exp = /\.|\-/g
	    cpf = cpf.toString().replace( exp, "" ); 
	    var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));
	    var soma1=0, soma2=0;
	    var vlr =11;
	    
	    for(i=0;i<9;i++){
	        soma1+=eval(cpf.charAt(i)*(vlr-1));
	        soma2+=eval(cpf.charAt(i)*vlr);
	        vlr--;
	    }    
	    soma1 = (((soma1*10)%11)==10 ? 0:((soma1*10)%11));
	    soma2=(((soma2+(2*soma1))*10)%11);
	    
	    var digitoGerado=(soma1*10)+soma2;
	    if(digitoGerado!=digitoDigitado){    
	        alert('CPF Invalido!'); 
	    	Objcpf.focus();
	    }
	}
}

function validaDepoimento(form){
	
	if (document.getElementById('radioImagem').checked){
		
		if (form.imagem.value == "")
		{
			alert("O campo imagem é obrigatório.")
			form.imagem.focus();
			return false
		}
	}else{
		if (document.getElementById('radioVideo').checked){
		
			if(form.video.value == "" && form.videoExterno.value == ""){
				alert("O campo video é obrigatório.")
				form.video.focus();
				return false
			}else{
				if(form.video.value != "" && form.videoExterno.value != ""){
					alert("Preencher somente uma opção de video.")
					form.video.focus();
					return false
				}
			}
		}
	}	
	return true
}

function imprimirDiv(urlBase,divName)
{
	var WinPrint = window.open('','newwin','toolbar=no,status=no,scrollbars=yes,width=700,height=800');
	var allDivTags = document.getElementsByTagName("div");
	var divTagContent;
	var stylesPath = urlBase+'/system/modules/br.gov.turismo.salao/resources/css/';
	
	for(var i=0; i < allDivTags.length; i++){
		if(  allDivTags[i].className == divName){
			divTagContent = allDivTags[i];
			 break;
			}
	}

	with (WinPrint.document) {
	write('<html>');
	write('<head>' + 
		'<link rel="stylesheet" type="text/css" href="'+stylesPath+'sdt_print.css" />'+
		'<link rel="stylesheet" type="text/css" href="'+stylesPath+'sdt_interna.css" />'+
		'<link rel="stylesheet" type="text/css" href="'+stylesPath+'sdt_geral.css" />'+
		'</head>');
	write('<body onload="print();">');
	write('<div class="printArea">');
	write(divTagContent.innerHTML);
	write('</div>');
	write('</body>');
	write('</html>');
	close();
	focus();
	}
}	