 //Verifica qual o browser do visitante e armazena na variável púbica clientNavigator,
 //Caso Internet Explorer(IE) outros (Other)
if (navigator.appName.indexOf('Microsoft') != -1){
 	clientNavigator = "IE";
}else{
	clientNavigator = "Other";
}

// Permite somente números - onkeypress="return SoNumeros(event);"
function SoNumeros(caracter) {
   var tecla = 0;
   if (caracter.keyCode != '') {
      tecla = event.keyCode;
   }
   else {
      tecla = caracter.which;
   }

  if(tecla > 47 && tecla < 58) { // numeros de 0 a 9
		return true;
   }else 
      if ((tecla == 0) || (tecla == 8) || (tecla == 13)) { // backspace e Del
        return true;
    }
      else {
         return false;
    }

}

function ExibeFlash(w,h,wmode,movie) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="wmode" value="'+wmode+'"/>');
	document.write('<param name="quality" value="high"/>');
	document.write('<param name="menu" value="false"/>');
	document.write('<param name="movie" value="'+movie+'"/>');
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="'+wmode+'" menu="false" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}

// bloqueia seleção
// function disableselect(e){return false}
// function reEnable(){return true}
// document.onselectstart=new Function ("return false")
// if (window.sidebar){document.onmousedown=disableselect
// document.onclick=reEnable}

// oculta menu - clique inverso
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if (document.layers||(document.getElementByid&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

//Ajusta máscara de Data e só permite digitação de números - onKeypress="return MascaraData(this, event);"
function MascaraData(input, evnt){
 	if (input.value.length == 2 || input.value.length == 5){
 		if(clientNavigator == "IE"){
 			input.value += "/";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "/";
 			}
 		}
 	}
//Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return SoNumeros(evnt);
}

// Verifica data - onBlur="VerificaData(this)"
function VerificaData(data)
 { 
	if (data.value != "") {
	dia = (data.value.substring(0,2));
	mes = (data.value.substring(3,5)); 
	ano = (data.value.substring(6,10)); 
	situacao = ""; 
	if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31)
	{ 
		situacao = "falsa"; 
	} 
	
	if (mes < 01 || mes > 12 )
	{ 
		situacao = "falsa"; 
	}
	
	if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4))))
	{ 
		situacao = "falsa"; 
	} 
	
	if (ano < 2000)
	{ 
		situacao = "falsa"; 
	} 

	if (situacao == "falsa")
	{ 
		data.select();
		alert("Data inválida!"); 
	}
 }
}

function MascaraCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres){
 var wTecla, wVr, wTam;
 
       // alert(pForm[pCampo].value);
  
 wTecla = pTeclaPres.keyCode;
 wVr = pForm[pCampo].value;
 wVr = wVr.toString().replace( "-", "" );
 wVr = wVr.toString().replace( ".", "" );
 wVr = wVr.toString().replace( ".", "" );
 wVr = wVr.toString().replace( "/", "" );
 wTam = wVr.length ;

 if (wTam < pTamMax && wTecla != 8) { 
    wTam = wVr.length + 1 ; 
 }

 if (wTecla == 8 ) { 
    wTam = wTam - 1 ; 
 }
   
 if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
  if ( wTam <= 2 ){
    pForm[pCampo].value = wVr ;
  }
  if (wTam > pPosTraco && wTam <= pTamMax) {
        wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam);
  }
  if ( wTam == pTamMax){
        wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam);
  }
  pForm[pCampo].value = wVr;
 
 }

}

function ExibeGestor(Numero) {
document.all.Eduardo.style.display='none';
document.all.Francisco.style.display='none';

	if (Numero == 1) {
	document.all.Eduardo.style.display='';
		if (document.all.Eduardo.style.display) {
		document.all.Eduardo.style.display='none';
		}
	}
	if (Numero == 2) {
	document.all.Francisco.style.display='';
		if (document.all.Francisco.style.display) {
		document.all.Francisco.style.display='none';
		}
	}
}

function ExibeProduto(Numero) {
document.all.Produto1.style.display='none';
document.all.Produto2.style.display='none';
document.all.Produto3.style.display='none';
document.all.Produto4.style.display='none';
document.all.Produto5.style.display='none';
document.all.Produto6.style.display='none';

	if (Numero == 1) {
	document.all.Produto1.style.display='';
	}
	if (Numero == 2) {
	document.all.Produto2.style.display='';
	}
	if (Numero == 3) {
	document.all.Produto3.style.display='';
	}
	if (Numero == 4) {
	document.all.Produto4.style.display='';
	}
	if (Numero == 5) {
	document.all.Produto5.style.display='';
	}
	if (Numero == 6) {
	document.all.Produto6.style.display='';
	}
}

function ExibeServico(Numero) {
document.all.Servico1.style.display='none';
document.all.Servico2.style.display='none';
document.all.Servico3.style.display='none';
document.all.Servico4.style.display='none';
	if (Numero == 1) {
	document.all.Servico1.style.display='';
	}
	if (Numero == 2) {
	document.all.Servico2.style.display='';
	}
	if (Numero == 3) {
	document.all.Servico3.style.display='';
	}
	if (Numero == 4) {
	document.all.Servico4.style.display='';
	}
}

function CadastroEtapa(Etapa) {

document.all.Etapa1.style.display='none';
document.all.Etapa2.style.display='none';
document.all.Etapa3.style.display='none';
document.all.Etapa4.style.display='none';
document.all.Etapa5.style.display='none';

	if (Etapa != "") {
	eval('document.all.Etapa'+Etapa+'.style.display=""')
	}
}

function AgriManager() {
   window.open('http://agrimanager.itprovider.com.br','AgriManager', 'scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=yes');
}

function CasesUpload(URL) {
   var width = 400;
   var height = 300;
   var left = (screen.width - width) / 2;
   var top = (screen.height - height) / 2;
   window.open(URL,'CasesUpload', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function Fotos(Noticia) {
   var width = 450;
   var height = 270;
   var left = (screen.width - width) / 2;
   var top = (screen.height - height) / 2;
   window.open('noticiasfotos.asp?Noticia='+Noticia+'','Fotos', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=1, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

function Fotos2(Noticia) {
   var width = 400;
   var height = 150;
   var left = (screen.width - width) / 2;
   var top = (screen.height - height) / 2;
   window.open('noticiasfotosupload.asp?Noticia='+Noticia+'','Fotos2', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}