//VALIDA EMAIL
function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("O endereço de email "+emailStr+" não está correto.")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	if (user.match(userPat)==null) {
		// user is not valid
		alert("O nome do usuário do e-mail "+emailStr+" não parece ser válido.")
		return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("O número do IP não é válido no e-mai "+emailStr+" !")
			return false
			}
		}
		return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("O domínio do e-mail "+emailStr+" não parece estar correto.")
		return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>3) {
	   alert("O endereço precisa terminar com 3 letras do domínio ou 2 letras do país.")
	   return false
	}
	
	if (len<2) {
	   var errStr="O endereço "+emailStr+" não contém o domínio!"
	   alert(errStr)
	   return false
	}
	
	return true;
}

//VOLTA PARA A PÁGINA ANTERIOR
function volta(){
		window.history.go(-1);
}

//ABRE POPUP DA FOTO - REQUISITO: ARQUIVO FOTO.PHP
function abreFoto(album, imagem, altu, larg, rolagem){
	window.open("foto.php?album="+album+"&imagem="+imagem+"", "Foto", "width="+larg+",height="+altu+",top=90,left=90,menubar=no,location=no,resizable=no,scrollbars="+rolagem+",status=no");
}

// CORRIGE A EXIBIÇÃO DE PNGS TRANSPARENTE NO IE 5.5 & 6.
function correctPNG(){
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function redim(){
	alturatotal = document.getElementById('cabecalho_').offsetHeight;//tamanho do cabeçalho
	alturatotal += document.getElementById('cabecalho-esquerda_').offsetHeight;//tamanho do cabeçalho do frame de conteudo
	//tamanho do maior frame da área central da home (estes são os frames que variam de tamanho)
	x = 0;
	y = 0;
	maior = 0;
	if(	document.getElementById('conteudo_').offsetHeight >= document.getElementById('destaques_').offsetHeight){
		x = document.getElementById('conteudo_').offsetHeight;
	}else{
		x = document.getElementById('destaques_').offsetHeight;
	}
	if(document.getElementById('conteudo_').offsetHeight >= document.getElementById('menu_').offsetHeight){
		y = document.getElementById('conteudo_').offsetHeight;
	}else{
		y = document.getElementById('menu_').offsetHeight;
	}
	if(x>=y){
		maior = x;
	}else{
		maior = y;
	}
	alturatotal += maior;
	document.getElementById('patrocinadores_').style.top=""+alturatotal+"px";//seta a posição da barra de patrocinios
	alturatotal += document.getElementById('patrocinadores_').offsetHeight;//tamanho do frame de patrocinadores
	document.getElementById('rodape_').style.top=""+alturatotal+"px";//seta posicao do rodape
	alturatotal += document.getElementById('rodape_').offsetHeight;//tamanho do rodape
	document.getElementById('master_frame').style.height=""+alturatotal+"px";
}
window.attachEvent("onload", correctPNG);
window.attachEvent("onload", redim);