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 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 imprimirDiv(urlBase,divName)
{
	var WinPrint = window.open('','newwin','toolbar=no,status=no,scrollbars=yes,width=550,height=800');
	var allDivTags = document.getElementsByTagName("div");
	var divTagContent;
	var stylesPath = urlBase+'/system/modules/br.gov.turismo.viajamais/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+'mtur_print.css" />'+
		'<link rel="stylesheet" type="text/css" href="'+stylesPath+'mtur_geral.css" />'+
		//'<link rel="stylesheet" type="text/css" href="'+stylesPath+'mtur_interna.css" />'+
		'<link rel="stylesheet" type="text/css" href="'+stylesPath+'mtur_viaja_mais.css" />'+
		'</head>');
	write('<body style="background:#FFF;" onload="print();">');
	write('<div class="printArea">');
	
	var divConteudo = divTagContent.innerHTML;
	var obj = document.getElementById("idIcones").innerHTML;
	divConteudo = divConteudo.replace(obj, "");	
	
	write(divConteudo);
	write('</div>');
	write('</body>');
	write('</html>');
	close();
	focus();
	}
}

var homeBusca = false;

function digitadoBusca(){
	homeBusca=true;
}


function validaBuscaHome(){
	if(homeBusca){
		return true
	}else{
		alert('Favor digitar algum valor para busca.')
		return false
	}
}

function limpaCampo(campo){	
	if(campo.value == campo.title)
		campo.value = '';
	campo.className = 'text valido';
}
function checaCampo(campo){	
	while(campo.value.indexOf(' ') == 0){
		campo.value = campo.value.substring(1, campo.value.length);
	}
	if((campo.value == '') || (campo.value.toLowerCase() == campo.title.toLowerCase())){
		campo.value = campo.title;
		campo.className = tiraString(campo.className,'valido');
	}
}
function tiraString(campo,string){
	string = ' '+string;
	if (campo.indexOf(string)>0){
		campo = campo.substring(0, campo.indexOf(string));
	}
	return campo;
}

function abrePopup(){
	document.getElementById('siteSombra').style.height= document.body.clientHeight+'px';
	document.getElementById('siteSombra').style.display = 'block';
	document.getElementById('sitePopup').style.display = 'block';
}

function fechaPopup(botao){

	document.getElementById('siteSombra').style.display = '';
	document.getElementById('sitePopup').style.display = '';
}

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
}
