function Show(Show)
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		if(document.all(Show).style.display == 'none')
		document.all(Show).style.display = 'block';
		else
		document.all(Show).style.display = 'none';
	}
	else if(navigator.appName == "Netscape")
	{
		if(document.getElementById(Show).style.display == 'none')
		document.getElementById(Show).style.display = 'block';
		else
		document.getElementById(Show).style.display = 'none';
	}
}

function Show_Top(Show,Hide)
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		if(document.all(Show).style.display == 'none')
		{
			document.all(Show).style.display = 'block';
			document.all(Hide).style.display = 'none';
		} else { 
		    document.all(Show).style.display = 'none';
			document.all(Hide).style.display = 'none';
		}
	}
	else if(navigator.appName == "Netscape")
	{
		if(document.getElementById(Show).style.display == 'none')
		{
		  document.getElementById(Show).style.display = 'block';
		  document.getElementById(Hide).style.display = 'none';
		} else {
		  document.getElementById(Show).style.display = 'none';
		  document.getElementById(Hide).style.display = 'none';
		}
	}
}

function ChecarData()
{
  if (document.frmBusca.Ond.value == "D")
  {
	checkDate(document.frmBusca.Termo);  
  }
}

function Janela(vURL,vAlt,vLarg,vRoll,vScr)
 {
  window.open(vURL,'Janela','width='+vLarg+',height='+vAlt+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+vScr+',resizable='+vRoll+',copyhistory=no,maximized=no');
 }

function Fazer(vPer)
{
 if (vPer.value != "")
 {
  document.frmBusca.Ond.value = 'D';
 }
}

function Confirma(vText)
{
  vConf = window.confirm(vText)
  if (vConf == false)
   {
     return false;
   }
  return true;
}

function Abre_Flash(vLarg, vAlt, vName) {
  var archivo = vName; 
  var ancho = vLarg;
  var alto = vAlt; 
  var version = "7,0,19,0"; // Versao do Flash Player - NAO É NECESSÁRIO MEXER AQUI
  var quality = "high"; // Qualidade da visualizacao do flash
  var bgcolor = "#000000"; 
  var wmode = "transparent"; 
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width='+ancho+' height='+alto+'>\n');
	document.write('<param name="movie" value='+archivo+' />\n');
	document.write('<param name="quality" value='+quality+'>\n');
	document.write('<param name="bgcolor" value='+bgcolor+'>\n');
	document.write('<param name="wmode" value='+wmode+'>\n');
	document.write('<embed src='+archivo+' bgcolor='+bgcolor+' quality='+quality+' wmode='+wmode+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+'></embed>');
	document.write('</object>\n');
}

function Pesquisar(vForm,vSize)
{
  var _options="width=700,height=600,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable="+vSize+",copyhistory=no,maximized="+vSize;
  
  _newWin=window.open("","",_options);
  _newWin.document.open();
  var _s ="";
  
  _s+="<html><body bgcolor=#FFFFFF><center><font color=#FFFFFF face=Tahoma size=2><b>";
  _s+="<form method=post name=f1 action='busca.php'>";
  _s+="<input type=hidden name=Termo value='"+document.frmBusca.Termo.value+"'>";
  _s+="<input type=hidden name=Ond value='"+document.frmBusca.Ond.value+"'>";
  _s+="<input type=hidden name=Per value='"+document.frmBusca.Per.value+"'>";
  _s+="<"+"script>";
  _s+="document.write('Pesquisando...');";
  _s+="document.f1.submit();";
  _s+="</"+"script>";
  _s+="</form>";
  _s+="</font></b></center></body></html>";
  _newWin.document.write(_s);
  _newWin.document.close();
}

/**********************************************************************/ 
/*Function name :isDigit(theDigit) */ 
/*Usage of this function :test for an digit */ 
/*Input parameter required:thedata=string for test whether is digit */ 
/*Return value :if is digit,return true */ 
/* else return false */ 
/**********************************************************************/ 
function isDigit(theDigit) 
{ 
  var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j; 

  for (j = 0; j < digitArray.length; j++) 
  {
	  if (theDigit == digitArray[j]) 
   return true 
  } 
return false 

} 
/*************************************************************************/ 
/*Function name :isPositiveInteger(theString) */ 
/*Usage of this function :test for an +ve integer */ 
/*Input parameter required:thedata=string for test whether is +ve integer*/ 
/*Return value :if is +ve integer,return true */ 
/* else return false */ 
/*function require :isDigit */ 
/*************************************************************************/ 
function isPositiveInteger(theString) 
{ 
  var theData = new String(theString); 

  if (!isDigit(theData.charAt(0))) 
  if (!(theData.charAt(0)== '+')) 
  return false 

  for (var i = 1; i < theData.length; i++) 
  if (!isDigit(theData.charAt(i))) 
  return false 
  return true 
} 
/**********************************************************************/ 
/*Function name :isDate(s,f) */ 
/*Usage of this function :To check s is a valid format */ 
/*Input parameter required:s=input string */ 
/* f=input string format */ 
/* =1,in mm/dd/yyyy format */ 
/* else in dd/mm/yyyy */ 
/*Return value :if is a valid date return 1 */ 
/* else return 0 */ 
/*Function required :isPositiveInteger() */ 
/**********************************************************************/ 
function isDate(s,f) 
{
  var a1=s.split("/"); 
  var a2=s.split("-"); 
  var e=true; 
  if ((a1.length!=3) && (a2.length!=3)) 
  { 
    e=false; 
  } 
    else
	{
	  if (a1.length==3)
		  var na=a1;
			if (a2.length==3)
			  var na=a2;
				if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2]))
				{
				  if (f==1)
					{
					  var d=na[1],m=na[0];
				  }
					else
					{
					  var d=na[0],m=na[1];
				  }
					var y=na[2];
					if (((e) && (y<1000)||y.length>4))
					  e=false
					if (e)
					{
					  v=new Date(m+"/"+d+"/"+y);
						if (v.getMonth()!=m-1)
						e=false;
					}
					}
					else
					{
					e=false;
					}
				}
				return e
			}
			 
function checkDate(v) 
{ 
  var s=v.value; 
	if (s.length>8)
	{
   if (isDate(s,0)) //dd/mm/yyyy format
	  { 
  //   alert("Data válida!");
		} 
   else
	  {
     alert("A data informada não é uma data válida!");
			v.focus();
		}
    return false;
	}
	else
	{
	  if (s.length>0)
		 {
    	alert("Preencha o campo com uma data válida!");
			v.value = "";
			v.focus();
		 }
	} 
}
