$(document).ready(function(){

	$("#myController").jFlow({
		slides: "#mySlides",
		width: "761px",
		height: "145px",
		duration: 400
	});
});

function aContato() {
	document.getElementById('BGcontato').style.display='block';
	document.getElementById('form_contato').style.display='block';
	}

function sContato() {
	document.getElementById('BGcontato').style.display='none';
	document.getElementById('form_contato').style.display='none';
	document.form_contato.assunto.value="";
	document.form_contato.email.value="";
	document.form_contato.msg.value="";
	}
function lContato() {
	document.form_contato.assunto.value="";
	document.form_contato.email.value="";
	document.form_contato.msg.value="";
	}
function mIdiomaPtOn() {
	document.getElementById('idioma_pt').className="idiomason_pt";
}
function mIdiomaEnOn() {
	document.getElementById('idioma_en').className="idiomason_en";
}
function mHomeOn() {
	document.getElementById('home').className="bt_homeon";
}
function mFolderOn() {
	document.getElementById('folder').className="bt_folderon";
}
function mIdiomaPtOff() {
	document.getElementById('idioma_pt').className="c_idiomas_pt";
}
function mIdiomaEnOff() {
	document.getElementById('idioma_en').className="c_idiomas_en";
}
function mHomeOff() {
	document.getElementById('home').className="bt_home";
}
function mFolderOff() {
	document.getElementById('folder').className="bt_folder";
}


function mostraCasos(i) {
  var x;
    
  x = document.getElementById("casos" + i);

  if (x.style.display == 'block') {
       x.style.display = 'none';
       }
      else {
       x.style.display = 'block';
       }
}
function Enviar(fm) {
	e_mail=trim(fm.email.value);
	erro=0;

    if (e_mail=="") {
	   erro=1;
	   alert("Favor informar e-mail.");
	   
       fm.email.focus();
    }

	if (erro==0) {
		if (e_mail!="") {
	       if (val_email(e_mail)==1) {
		      erro=1;
		      alert("E-mail contém caracteres inválidos.");
	          fm.email.focus();
			  }
	       else	{
			  if (val_email(e_mail)==2) {
			     erro=1;
			     alert("E-mail não contém '@'");
		         fm.email.focus();
				 }
		      else {
			     if (val_email(e_mail)==3) {
			        erro=1;
					alert("E-mail contém @ em lugar inválido.");
		            fm.email.focus();
					}
		         else {
				    if (val_email(e_mail)==4) {
				       erro=1;
					   alert("E-mail não contém '.'");
		               fm.email.focus();
					   }
		            else {
					   if (val_email(e_mail)==5) {
					      erro=1;
					      alert("E-mail incompleto.");
		                  fm.email.focus();
						  }
		               else {
					      if (val_email(e_mail)==6) {
					         erro=1;
							 alert("E-mail incorreto.");
		                     fm.email.focus();
	                      }
					   }
					}
				 }
			  }         
		   }
		  }
		 }


 	if (erro==0) {	
		assunto=trim(fm.assunto.value);
   	 	if (assunto=="") {
		  erro=1;
	 	  alert("Favor informar o assunto do e-mail.");
     	  fm.msg.focus();
    	}
	}	

	
	if (erro==0) {	
		msg=trim(fm.msg.value);
   	 	if (msg=="") {
		  erro=1;
	 	  alert("Favor informar o texto do e-mail.");
     	  fm.msg.focus();
    	}
	}	

   
	if (erro==0) {

       fm.action="/cgi-bin/envia_email.py";

	   fm.submit();
	}
	   
}


function val_email(email) 
{
 invalidChars = "/:,;"
 for   (i=0; i<invalidChars.length; i++) 
       {
       badChar = invalidChars.charAt(i)
       if (email.indexOf(badChar,0) > -1)
	      {
	      return 1;
	      }
	   }

	   atPos = email.indexOf("@",1)
       if (atPos == -1)
          {
		  return 2;
	      }

	   if (email.indexOf("@",atPos+1) > -1)
          {
		  return 3;
		  }

	   periodPos = email.indexOf(".",atPos)
       if (periodPos == -1)
          {
		  return 4;
		  }

	   if (periodPos+3 > email.length)
          {
		  return 5;
		  }

	   if
(email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
       {}
       else
       {	
		 return 6;
	   }
}	

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
