//function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
//{
//   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 = 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
//         }
//      }
//   }   
//}
//window.attachEvent("onload", correctPNG);

function validaForm(){
	
		document.getElementById('statusEmail').innerHTML = "<center><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' width='289' height='15'><param name='width' value='289' /><param name='height' value='15' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='src' value='../images/load_email.swf' /><embed type='application/x-shockwave-flash' width='289' height='15' quality='high' wmode='transparent' src='../images/load_email.swf'></embed></object></center>";
		
		var msgErro = '';
		d = document.form1;

		//validar mensagem
         if ((d.mensagem.value == "Digite aqui sua mensagem") || (d.mensagem.value.length < 10)){
					msgErro = 'Digite seu recado!';
                    d.mensagem.focus();
         }
		 //validar assunto
         if (d.assunto.value == "Digite aqui o assunto"){
					msgErro = 'Digite o assunto!';
                    d.assunto.focus();
         }
		 
		 //validar telefone
         if ((d.telefone.value == "Digite aqui seu telefone") || (d.telefone.value.length < 8)){
				msgErro = 'Digite seu telefone!';
                d.telefone.focus();
         }
		 
         //validar email(verificao de endereco eletrônico)
         parte1 = d.email.value.indexOf("@");
         parte2 = d.email.value.indexOf(".");
         parte3 = d.email.value.length;
         if (!(parte1 >= 1 && parte2 >= 4 && parte3 >= 5)) {
				msgErro = 'Formato de e-mail inv&aacute;lido!';
                d.email.focus();
         }
         //validar email
         if (d.email.value == "Digite aqui seu nome e-mail"){
				msgErro = 'Digite seu e-mail!';
                d.email.focus();
         }

		 //validar nome
           if ((d.nome.value == "Digite aqui seu nome") || (d.nome.value.length < 6)){
				msgErro = 'Digite seu nome completo!';
                d.nome.focus();
           }
		   
		 
		
		//verifica se encontrou algum erro, retorna o erro ao usuário e cancela a operação
		if(msgErro != ''){
			document.getElementById('statusEmail').innerHTML = msgErro;
			return false;
		}
		
		//recupera valores do form para pasar como parâmetro para a página de envio de emails
		var nome = document.getElementById('nome').value;
		var email = document.getElementById('email').value;
		var telefone = document.getElementById('telefone').value;
		var assunto = document.getElementById('assunto').value;
		var mensagem = document.getElementById('mensagem').value;
		
 		//define a página que será requisitada, já passando os valores para enviar o email
		var url="enviar.php?sid=" + Math.random() + "&nome=" + escape(nome) + "&email=" + escape(email) + "&telefone=" + escape(telefone) +"&assunto=" + escape(assunto) + "&mensagem=" + escape(mensagem);
		//cria o objeto que irá fazer esta ponte entre cliente e servidor (Esta função se encontra no arquivo. xmlhttp.js) e define a função que será executadaquando este estado mudar(stateChanged)
		xmlHttp=GetXmlHttpObject(stateChanged);
		//abre a página requisitada...
		xmlHttp.open("GET", url, true);
		//finaliza a operação!
		xmlHttp.send(null);
		//retorna falso para não recarregar a página!
		return false;
		
}

function stateChanged() 
{ 
//se o estado for igual a 4, ou seja, completo...ele exibe ao usuário a mensagem de sucesso!
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("statusEmail").innerHTML = 'E-mail enviado com sucesso!';
document.getElementById('nome').value="Digite aqui seu nome";
document.getElementById('email').value="Digite aqui seu e-mail";
document.getElementById('telefone').value="Digite aqui seu telefone";
document.getElementById('assunto').value="Digite aqui o assunto";
document.getElementById('mensagem').value="Digite aqui sua mensagem"; 
} 
}
// JavaScript para exibir o flash
function flash(largura, altura, arquivo){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" />');
	document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="transparent" quality="best" width="'+largura+'" height="'+altura+'" name="teste" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}