// JavaScript Document

// ABRIR POP-UP
function popup(url, pagina) {
	var atributos = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=618,height=475';
	window.open(url,pagina,atributos);
}

// ABRIR POP-UP2
function popup2(url, pagina) {
	var atributos = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=857';
	window.open(url,pagina,atributos);
}


// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
var navegador; 
navegador = navigator.appName;

function correctPNG(){
	//alert(navegador);
   	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 CarregaPNG(){
  	if(navegador=='Microsoft Internet Explorer'){
		correctPNG();
	}
  }
  
  

<!-- Evento menu da News -->
function exibeMenu(){
	//alert("Função Exibe Menu");//avisa sobre o evento (didático)
	document.getElementById('sub-news').style.display="block";
}

function escondeMenu(){
	//alert("Função Esconde Menu");//avisa sobre o evento (didático)
	document.getElementById('sub-news').style.display="none";
}


// CAMPOS OBRIGATORIOS
<!-- Evento menu da News -->
function camposObrigatorios(){
	document.getElementById('nomeobrigatorios').style.color="#d13e3e";
	document.getElementById('emailobrigatorio').style.color="#d13e3e";
	document.getElementById('assuntoobrigatorio').style.color="#d13e3e";
	document.getElementById('textobrigatorio').style.color="#d13e3e";
}

// Função de validação do formulário
function ValidaFormulario(){
	
	//Atribuindo Variaveis
	var assunto		= document.formulario.assunto.value; // Atribui o conteúdo do campo NOME à Variavel ASSUNTO
	var nome 		= document.formulario.nome.value; // Atribui o conteúdo do campo NOME à Variavel NOME
	var email	 	= document.formulario.email.value; // Atribui o conteúdo do campo EMAIL à Variavel EMAIL
	var mensagem 	= document.formulario.falemsg.value; // Atribui o conteúdo do campo MENSAGEM à Variavel MENSAGEM
	
	
	// Função de validação do campo - Nome
		if ( nome == null || nome == '' || nome.length<3){ 
		document.getElementById('assuntoobrigatorio').style.color="#000";
		document.getElementById('nomeobrigatorios').style.color="#d13e3e";
		document.getElementById('emailobrigatorio').style.color="#000";
		document.getElementById('textobrigatorio').style.color="#000";
		alert("Preencha o campo NOME corretamente");
		document.formulario.nome.value=''; //Limpa o campo ao retornar
		document.formulario.nome.focus();
		
		return false;
	}
  
	// Função de validação do formulário - Email
		if ( email == null || email == '' ) { 
		document.getElementById('assuntoobrigatorio').style.color="#000";
		document.getElementById('nomeobrigatorios').style.color="#000";
		document.getElementById('emailobrigatorio').style.color="#d13e3e";
		document.getElementById('textobrigatorio').style.color="#000";
		alert("Preencha o campo E-MAIL corretamente");
		document.formulario.email.value=''; //Limpa o campo ao retornar
		document.formulario.email.focus(); 
		return false;
	}
	//validar email(verificao de endereco eletronico)
		parte1 = email.indexOf("@");
		parte2 = email.indexOf(".");
		parte3 = email.length;
		if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
			document.getElementById('assuntoobrigatorio').style.color="#000";
			document.getElementById('nomeobrigatorios').style.color="#000";
			document.getElementById('emailobrigatorio').style.color="#d13e3e";
			document.getElementById('textobrigatorio').style.color="#000";
			alert("O campo E-mail deve ser conter um endereco eletronico valido!");
			document.formulario.email.value=''; //Limpa o campo ao retornar
			document.formulario.email.focus();
			return false;
		}
		
	// Função de validação do campo - ASSUNTO
		if ( assunto == null || assunto == '' || assunto.length<3){ 
		document.getElementById('assuntoobrigatorio').style.color="#d13e3e";
		document.getElementById('nomeobrigatorios').style.color="#000";
		document.getElementById('emailobrigatorio').style.color="#000";
		document.getElementById('textobrigatorio').style.color="#000";
		alert("Preencha o campo ASSUNTO corretamente");
		document.formulario.assunto.value=''; //Limpa o campo ao retornar
		document.formulario.assunto.focus();
		
		return false;
	}
  
	// Função de validação do campo - Mensagem
		if ( mensagem == null || mensagem == '' || mensagem.length<3){
		document.getElementById('assuntoobrigatorio').style.color="#000";
		document.getElementById('nomeobrigatorios').style.color="#000";
		document.getElementById('emailobrigatorio').style.color="#000";
		document.getElementById('textobrigatorio').style.color="#d13e3e";
		alert("Preencha o campo MENSAGEM corretamente"); 
		document.formulario.falemsg.value=''; //Limpa o campo ao retornar
		document.formulario.falemsg.focus();
		return false;
	}
	
	return true;
	
	
}
