
// C�digo para valida��o de formul�rio
//
campos_erro	= "";
erro 		= false;
function isNumero(valor){	
	var ver_numero = "1234567890";
	var cont = 0;
	
	for (i = 0;  i < valor.length;  i++){
		ch = valor.charAt(i);
		for (j = 0;  j < ver_numero.length;  j++){
			if (ch == ver_numero.charAt(j)){
				cont++;
			}
		}
	}
	if (cont == valor.length){
		return true
	}else{
		return false;
	}
}
function validaData(campo){
	dia = document.form[campo].value.substring(0,2); 
	mes = document.form[campo].value.substring(3,5); 
	ano = document.form[campo].value.substring(6,10); 		

	mensagem = "Erro na data";		
	if(!isNumero(dia+mes+ano)){
		alert("No campo 'DATA' deve conter apenas n�mero!");
		
		comando2 = "document.all."+campo+".style.backgroundColor = 'red'";
		erro = true;
		eval(comando2);
	}else if(document.form[campo].value.length != 10){
		alert("Tamanho da data inv�lido!");
		
		comando2 = "document.all.data.style.backgroundColor = 'red'";
		erro = true;
		eval(comando2);
	}else{
		if(dia < 1 || dia > 31){
			alert("No campo 'DATA' o dia � inv�lido!");
			
			comando2 = "document.all."+campo+".style.backgroundColor = 'red'";
		    erro = true;
		    eval(comando2);
		}else if(mes < 1 || mes > 12){
			alert("No campo 'DATA' o m�s � inv�lido!");
			
			comando2 = "document.all."+campo+".style.backgroundColor = 'red'";
		    erro = true;
		    eval(comando2);	
		}else if(ano < 1900 || ano > 3000){
			alert("No campo 'DATA' o ano � inv�lido!");
			
			comando2 = "document.all."+campo+".style.backgroundColor = 'red'";
		    erro = true;
		    eval(comando2);
		}	
	}	
}
function valida(campo){
	comando = "document.form."+campo+".value";
	resulta = eval(comando);

	if (resulta == ""){
		comando2 = "document.all."+campo+".style.backgroundColor = 'red'";
		erro = true;
		eval(comando2);
	}
}
function submeter(arrayComCampos){
	campos 	= arrayComCampos;
	cont	= campos.length;
	
	for (i=0 ; i<cont; i++){
		
		if (campos[i] == "asd") {
		validaData(campos[i]);
		} else {
		valida(campos[i]);
		}
	}

	if(!erro){
		cmd_sub = "document.form.submit()";
		eval (cmd_sub);
		
	}else{
		alert ('Os campos marcados em vermelho sao de preenchimento obrigat�rio!');
		campos_erro="";
	}
}
function limpa_fundo(campo){
		comando3 = "document.all."+campo+".style.backgroundColor = 'white'";
		eval(comando3);
		erro = false;
}


// ------------------------------------------ FIM do C�digo para valida��o de formul�rio



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function DisplayInfo(pagina,janela,w,h,scrolling) {
 if (!scrolling) { scrolling="auto" } resultado = window.open(pagina,janela,"width="+w+",height="+h+",scrollbars="+scrolling+",toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=5,top=5")
}


function boldThis(from) { 
	strSelection = document.selection.createRange().text 
	if (strSelection == "") { 
	return false; 
	} 
	else document.selection.createRange().text = "<b>" + strSelection 
	+ "</b>" 
	return;
}

function italicThis(from) { 
	strSelection = document.selection.createRange().text 
	if (strSelection == "") { 
	return false; 
	} 
	else document.selection.createRange().text = "<i>" + strSelection 
	+ "</i>" 
	return;
}

function underlineThis(from) { 
	strSelection = document.selection.createRange().text 
	if (strSelection == "") { 
	return false; 
	} 
	else document.selection.createRange().text = "<u>" + strSelection 
	+ "</u>" 
	return;
}

function changecolor(t) { 
	strSelection = document.selection.createRange().text 
	if (strSelection == "") { 
	return false; 
	} 
	else document.selection.createRange().text = "<font" + " color" +"=" +t+">" + strSelection 
	+ "</font>" 
	return;
}

function changesize(t) { 
	strSelection = document.selection.createRange().text 
	if (strSelection == "") { 
	return false; 
	} 
	else document.selection.createRange().text = "<font" + " size" +"=" +t+">" + strSelection 
	+ "</font>" 
	return;
}
function changealign(t) { 
	strSelection = document.selection.createRange().text 
	if (strSelection == "") { 
	return false; 
	} 
	else document.selection.createRange().text = "<div" + " align" +"=" +t+">" + strSelection 
	+ "</div>" 
	return;
}

function DisplayInfo(pagina,janela,w,h,scrolling) {
 if (!scrolling) { scrolling="auto" } resultado = window.open(pagina,janela,"width="+w+",height="+h+",scrollbars="+scrolling+",toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=5,top=5")
}

function FormataData(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			document.form[campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			document.form[campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}
}

function imprimir(id) {
 DisplayInfo("imprimir.php?id="+id,"imprimir",600,500,"yes","no");
}

function opened(url,frame,param)
{
window.open(url,frame,param);
}
function home_sub(url)
{
top.opener.top.location.href=url;
window.self.close();
}
function openPopUp(URL, NAME, OPTIONS) 
{
window.open(URL, NAME, OPTIONS)
window.self.close();
}

function clearall (form) {
	form.reset();
}

function jczOpenWindow(theURL,winName) {
	window.open(theURL,winName,'status=yes,scrollbars=no,width=300,height=300');

}
function DisplayInfo(pagina,janela,w,h,scrolling) {
 if (!scrolling) { scrolling="auto" } resultado = window.open(pagina,janela,"width="+w+",height="+h+",scrollbars="+scrolling+",toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=5,top=5")
}

function submit_login() {
	if (document.implogin.imapuser.value == "") {
		alert('Por favor, informe seu nome de usu�rio e sua senha');
		return false;
	} else if (document.implogin.pass.value == "") {
		alert('Por favor, informe seu nome de usu�rio e sua senha');
		return false;
	} else {
		document.implogin.submit();
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function popup(menuName,mostra) {
			if (mostra) {
			document.getElementById(menuName).style.visibility = "visible";
			} else {
			document.getElementById(menuName).style.visibility = "hidden";
		}
	}


/*****MENU*******/

function horizontal() {
 
   var navItems = document.getElementById("menu_dropdown").getElementsByTagName("li");
    
   for (var i=0; i< navItems.length; i++) {
      if((navItems[i].className == "submenu") || (navItems[i].className == "empresa"))
      {
         if(navItems[i].getElementsByTagName('ul')[0] != null)
         {
            navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "";}
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "";}
         }
      }
   }
 
}

var valEmail = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
function cadastraNews(){
	
	var nome = document.news.nome.value;
	var email = document.news.email.value;


	if(nome == "" || nome == "Nome" ){
		alert("Nome não preenchido.");
	} else if(email == ""){
		alert("E-mail não preenchido.");
	} else if(!valEmail.test(email)){
		alert("E-mail inválido.");
	} else {
		$('news').submit();
		//document.form[0].submit();			
	}
}


/*****FIM MENU*****/

