// JavaScript Document
function Galeria(op,pasta){
	if(op==1){
		window.open("popup.php","","left=20,top=10,width=560,height=420")
	}else{
		window.open("popup.php?pasta="+pasta,"","left=20,top=10,width=560,height=420")
	}	
}
function emBranco(str) {
	tamanho = str.length;
	contador = 0;
	for (x=0; x<tamanho; x++) {
		if (str.substring(x,x+1) == " ") { ++contador;}
		}
	return ((contador == tamanho) || (str == ""));
}
//
function validaMail(obj){
var email = obj.value;
var BadChars = "*|,\":<>[]{}`\'';()&$#% ";
var GoodChars = "@."; 
var posarroba = email.indexOf ('@',0);
if (email.length < 6) // o email é menor que 6 caracteres
{
   alert("\"E-mail\" inválido!"); 
   obj.focus();
   return false;
}
for (var i = 0; i < email.length; i++) 
{
   if (BadChars.indexOf(email.charAt(i)) != -1) // Contém caracteres inválidos, badchars
	{
	alert("Seu \"E-mail\" contém caracteres inválidos!");
	obj.email.value = '';
	obj.focus();
	return false;
	}
}
for (var i = 0; i < GoodChars.length; i++) 
{
	if (email.indexOf(GoodChars.charAt(i)) == -1) // não tem goodchars
	{
	alert("\"E-mail\" inválido!");
	obj.focus();
	return false;
	}
	if (email.indexOf(GoodChars.charAt(i),0) == 0) // começou com goodchars (. ou @)
	{
		alert("\"E-mail\" inválido!");
		obj.focus();
		return false;
	}
	if (email.lastIndexOf(GoodChars.charAt(i)) > email.length-3) //existe menos de 2 caracteres depois do ultimo goodchar
		{
		alert("\"E-mail\" inválido! Seu e-mail não deve terminar com @.");
		obj.focus();
		return false;
		}
}
if (email.lastIndexOf('@') > email.lastIndexOf('.')) //Não tem ponto depois do arroba
	{
	alert("\"E-mail\" inválido!");
	obj.focus();
	return false;
	}
if (email.indexOf ('@.',0) != -1 || email.indexOf ('.@',0) != -1) // . e @ colados
	{
	alert("\"E-mail\" inválido!");
	obj.focus();
	return false;
	}
if (email.indexOf ('@',posarroba+1) != -1) // Contém mais de um " @ " 
	{
	alert("\"E-mail\" inválido! Contém mais de um @");
	obj.focus();
	return false;
	}
return true;
}
function valida(){
	obj = document.Contato;
	if (emBranco(obj.nome.value)){
	   alert("O 'Nome' deve ser preenchido. Favor corrigir.");
	   obj.nome.focus();
	   return false;
	}
	if (!validaMail(obj.contato)) {
 	  return false;
   	}
	if (emBranco(obj.assunto.value)){
		alert("O 'Assunto' deve ser preenchido. Favor corrigir.");
		obj.assunto.focus();
	    return false;
	}
	if (emBranco(obj.mensagem.value)){
   		alert("A 'Mensagem' deve ser preenchida. Favor corrigir.");
	    obj.mensagem.focus();
	    return false;
	}
	obj.submit();
}
window.defaultStatus='Itacaramby: (62) 3092-3090';