// JavaScript Document
var t = new Number();
var t2 = new Number();

function openPop(url){
	window.open(url, "fotos", "scrollbars=no, menubar=no, resizable=no, statusbar=no, width=400, height=300, top=20, left=20");
}
function abrePop(url){
	window.open(url, "fotos", "scrollbars=yes, menubar=no, resizable=no, statusbar=no, width=737, height=550, top=10, left=10");
}

function validaForm(x){
	for(var i = 0; i < x.elements.length; i++){
		if(x.elements[i].title != "" && x.elements[i].title.indexOf("Google") == -1){
			if(x.elements[i].title.indexOf("mail") != -1){
				if(x.elements[i].value.indexOf("@") == -1 || x.elements[i].value.indexOf(".") == -1){
					alert("Por favor, preencha o campo " + x.elements[i].title + " corretamente!");
					x.elements[i].focus();
					return false;
				}
			}else{
				if(x.elements[i].value == ""){
					alert("Por favor, preencha o campo " + x.elements[i].title + " corretamente!");
					x.elements[i].focus();
					return false;
				}
			}
		}
	}
}
function formatPhone(x, nextFocus){
	var y = document.getElementById(nextFocus);
	
	if(x.value.length == 2 || x.value.length == 7){
		x.value += " ";
	}else if(x.value.length == 12){
		y.focus();
	}
}
function formatDate(x, nextFocus){
	var y = document.getElementById(nextFocus);
	
	if(x.value.length == 2 || x.value.length == 5){
		x.value += "/";
	}else if(x.value.length == 10){
		y.focus();
	}
}
function onlyNumber(campo){
	var x = document.getElementById(campo);
	var nonNumbers = /\D/;
	
	if(nonNumbers.test(x.value)){
		alert("O campo suporta apenas números!");
		x.value = x.value.substring(0, x.value.length - 1);
		return false;
	}
}

function countHome(id){ t = setTimeout("hideBox('" + id + "')", 15000); }
function countHomeEsp(id1, id2){
    t = setTimeout("hideEsp('" + id1 + "', '" + id2 + "')", 10000);
}
function countHide(id){ t = setTimeout("hideBox('" + id + "')", 3000); }
function hideBox(id){
	var x = document.getElementById(id);
    x.style.display = "none";
    clearTimeout(t);
}
function hideEsp(id1, id2){
    var x = document.getElementById(id1);
    var y = document.getElementById(id2);
    
    x.style.display =  "none";
    y.style.display =  "block";
    clearTimeout(t);
    if(id2 != ""){
        t = setTimeout("hideBox('" + id2 + "')", 10000);
    }
}
