function tbr(txt) {
	if( (txt != "undefined") && (txt != "") ) {
		return false;
	}
	else {
		return true;
	}
}

function obrigatorio(campo, label) {
	if( tbr(campo.value) ) {
		alert("Por favor, preencha o campo: " + label);
		campo.focus();
		return false;
	}
	else {
		return true;
	}
}

function isDate(dt) {

	var objRegExp  = /^\d{2}\/\d{2}\/\d{4}$/;	// 00/00/0000
	var dia, mes, ano;
	var diasdomes = new Array

	// Caso não esteja no formado acima
	if( !objRegExp.test(dt) ) {
		return false;
	}
	else {

		// Separa o dia, mes e ano
		if ( parseInt(dt.substring(0,2)) == 0 ) { dia = parseInt(dt.substring(1,2)); }
		else { dia = parseInt(dt.substring(0,2)); }

		if ( parseInt(dt.substring(3,5)) == 0 ) { mes = parseInt(dt.substring(4,5)); }
		else { mes = parseInt(dt.substring(3,5)); }

		ano = parseInt(dt.substring(6,13));

		for (var i = 1; i <= 12; i++) {
			diasdomes[i] = 31
			if (i==4 || i==6 || i==9 || i==11) { diasdomes[i] = 30 }
			if (i==2) { 
				diasdomes[i] = (((ano % 4 == 0) && ( (!(ano % 100 == 0)) || (ano % 400 == 0))) ? 29 : 28 )
			}
		} 

		if( (dia > 0) && ( dia <= diasdomes[mes]) ) { return true }
		else { return false; }
	}

}

function njc(pg, jn, w, h) {

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=no,scrollbars=no,resizable=no,menubar=no'
	
	win = window.open(pg, jn, winprops)
    	
	if (parseInt(navigator.appVersion) >= 4) { 
       		win.window.focus(); 
    	}

}

verifiqueTAB = false;

function Mostra(objInput, tamMax) {
	if ( (objInput.value.length == tamMax) && (verifiqueTAB) ) {
		var i=0, j=0, indice= - 1;
		for (i=0; i<document.forms.length; i++) {
			for (j=0; j < document.forms[i].elements.length; j++) {
				if (document.forms[i].elements[j].name == objInput.name) {
					indice = i; break;
				}
			}
			if (indice != -1) { break; }
		}
		for (i=0; i < document.forms[indice].elements.length; i++) {
			if (document.forms[indice].elements[i].name == objInput.name) {
				// So vai passar para o proximo campo se este nao for o ultimo
				if( i < (document.forms[indice].elements.length - 1) ) {
					while ( (document.forms[indice].elements[(i+1)].type == "hidden") && (i < document.forms[indice].elements.length) ) {
						i++;
					}
					document.forms[indice].elements[(i+1)].focus();
				}
				PararTAB();
				break;
			}
		}
	}
}

function PararTAB() {
	verifiqueTAB = false;
}

function ChecarTAB() {
	verifiqueTAB = true;
}

function enviarEmail(form) {

	if( !obrigatorio(form.nome, "Nome") )						{	return;	}
	if( !obrigatorio(form.email, "Email") )						{	return;	}
	if( !obrigatorio(form.conheceu, "Aonde nos conheceu") )		{	return;	}
	if( !obrigatorio(form.comentario, "Comentario") )			{	return;	}
	this.form.submit();

}