
function Mostrar_Menu(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 Confirmar(vText)
{
  vConf = window.confirm(vText)
  if (vConf == false)
   {
     return false;
   }
  return true;
}

function OrderList(frm, valor)
 {
   eval(frm + '.order.value='+valor);
   eval('document.' + frm + '.submit()');
 }
 
function Janela_Pop(vURL,vAlt,vLarg,vScroll,vRell)
 {
var w = 800, h = 600;

if (document.all) {
   /* the following is only available after onLoad */
   w = document.body.clientWidth;
   h = document.body.clientHeight;
}
else if (document.layers) {
   w = window.innerWidth;
   h = window.innerHeight;
}
  var popW = vLarg, popH = vAlt;
  var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  window.open(vURL,'Janela','width='+vLarg+',height='+vAlt+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+vScroll+',resizable='+vRell+',copyhistory=no,maximized=no,top='+topPos+',left='+leftPos);
 }
 

/**********************************************************************/ 
/*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();
		 }
	} 
}

function mask(str,textbox,loc,delim)
{
  var locs = loc.split(',');
  for (var i = 0; i <= locs.length; i++)
    {
	  for (var k = 0; k <= str.length; k++)
	   {
	     if (k == locs[i])
		  {
		    if (str.substring(k, k+1) != delim)
			 {
			 str = str.substring(0,k) + delim + str.substring(k,str.length)
			 }
		  }
	   }
	}
  textbox.value = str
}
