// JavaScrip Document




//
// checks the value type of the input object
// then, the next input can get the focus
//

function checkFieldType(oInput, sType, sIdName) {
	if (oInput == null) {
		return false;
	} else {
		var oFrm = oInput.form;
	}

	switch (sType) {
		
		case 'n': // number
			if (isNaN(parseInt(oInput.value)) && oInput.length > 0) {
				window.alert("o campo possui caracteres não numéricos");
				return false;
			}
			break;

	}

	// focus next element by the actual tabIndex
	// if maxlenght is reached
	if ( (sIdName != null) || (sIdName == '') ) {
		if (oInput.value.length == oInput.maxLength) {
			document.getElementById(sIdName).focus();
		}
	}
	return true;
}




//
// função focus informativo
//

function Aq_newsletter()
{
	if (document.newsform.nome.value == "" || document.newsform.nome.value == "NOME |")
	{
		alert("Por favor, digite o seu nome.");
		return false;
	} else if ((document.newsform.email.value == "") || (!valida_mail(document.newsform.email.value))) {
		alert("Por favor, digite um e-mail válido.");
		return false;
	} else
		return true;
}




//
// função validar enquete
//

var selecionado = 0;
function selecionar() {
	selecionado = 1;
}

function validaEnquete(){
	if (!selecionado) {
	alert("Atenção! Você precisa selecionar uma opção");
	} else {
		return true;
	}
	return false;
}




//
// função validar enquete
//

function validaInfo(informativo) {
	if (informativo.nome.value == "" || informativo.nome.value == "Nome")
	{
		alert("Por favor, digite o seu nome.");
		return false;
	} else if ((informativo.email.value == "") || (!valida_mail(informativo.email.value))) {
		alert("Por favor, digite um e-mail válido.");
		return false;
	} else
		return true;
}

function valida_mail(valor) {
	prim = valor.indexOf("@")
	if(prim < 2) return false;
	if(valor.indexOf("@",prim + 1) != -1) return false
	if(valor.indexOf(".") < 1) return false;
	if(valor.indexOf("zipmeil.com") > 0) return false;
	if(valor.indexOf("hotmeil.com") > 0) return false;
	if(valor.indexOf(".@") > 0) return false;
	if(valor.indexOf("@.") > 0) return false;
	if(valor.indexOf(".com.br.") > 0) return false;
	if(valor.indexOf("/") > 0) return false;
	if(valor.indexOf("[") > 0) return false;
	if(valor.indexOf("]") > 0) return false;
	if(valor.indexOf("(") > 0) return false;
	if(valor.indexOf(")") > 0) return false;
	if(valor.indexOf("..") > 0) return false;
	if(valor.indexOf(",") > 0) return false;
	return true;
}




//
//
//

function setTall() {
	if (document.getElementById) {
		// the divs array contains references to each column's div element.  
		// Replace 'center' 'right' and 'left' with your own.  
		// Or remove the last one entirely if you've got 2 columns.  Or add another if you've got 4!
		var divs = new Array(document.getElementById('main_menu'), document.getElementById('main_main'), document.getElementById('main_lateral'));
		
		// Let's determine the maximum height out of all columns specified
		var maxHeight = 0;
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
		}
		
		// Let's set all columns to that maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';

			// Now, if the browser's in standards-compliant mode, the height property
			// sets the height excluding padding, so we figure the padding out by subtracting the
			// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}

window.onload = function() {
	setTall();
}

window.onresize = function() {
	setTall();
}




//
// janela pop
//

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}