﻿function JsDelete() {
    if (confirm("Tem certeza que deseja excluir esse registro?")) {
        return true;
    }
    else {
        return false;
    }
}

function AbrePopUpNormal(Pagina, Comprimento, Altura, Nome, Scroll, toolbar)
{

    
			if (Scroll=='true')
			{
				Scroll = ',scrollbars=yes';
			}
			if (toolbar=='true')
			{
				toolbar = ',toolbar=1,menubar=0';
			}
			var winl = (window.screen.width  - Comprimento) / 2;
			var wint = (window.screen.height - Altura) / 2;
			winprops = 'status=yes,height='+Altura+',width='+Comprimento+',top='+wint+',left='+winl+Scroll+toolbar;
    		if (Nome == "") 
			{
			 Nome = "Janela"; 
			}
			var pops = window.open(Pagina,Nome,winprops);

}

function AbreJanela(Pagina, Elementos)
{
    winprops = 'status=yes,scrollbars=yes,toolbar=1,menubar=0';
    if (Elementos =='true')
    {
        winprops = '';
    }
    var pops = window.open(Pagina,'NovaJanela',winprops);
}

function objeto(nome, largura, altura) {

    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' +
' width="' + largura + '" height="' + altura + '" id="' + nome + '" align="middle">');

    document.write('<param name="allowScriptAccess" value="sameDomain" />');

    document.write('<param name="movie" value="Flash/' + nome + '.swf" />');

    document.write('<param name="quality" value="high" />');

    document.write('<param name="menu" value="false" />');

    document.write('<param name="wmode" value="transparent" />');

    document.write('<embed src="Flash/' + nome + '.swf" quality="high" menu="false" wmode="transparent" ' +
' width="' + largura + '" height="' + altura + '" name="' + nome + '" align="middle"' +
' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"' +
' pluginspage="http://www.macromedia.com/go/getflashplayer" />');

    document.write('</object>');

}
function Nada() {
    return '';
}

    // verifies only a number was typed into the form element
    function numbersonly(e){
        //alert(e.keyCode)
        var unicode=e.charCode? e.charCode : e.keyCode
        // if (unicode!=8||unicode!=9)
        if (unicode!=44)
        {
            //if the key isn't the backspace key or tab key (which we shouldallow)
            if (unicode<48||unicode>57) //if not a number
            return false //disable key press
        }
    }

function formatadata(obj, tecla)
{
   if (tecla.keyCode == 8)
      return true; 
   var continuar = false;	  
   if ((tecla.keyCode >= 48) && (tecla.keyCode <= 57)) { continuar = true; }
   //if ((tecla.keyCode >= 96) && (tecla.keyCode <= 105)) { continuar = true; }
   //if ((tecla.keyCode == 46) || (tecla.keyCode == 8)) { continuar = true; }
   if (continuar == false)
     return false;

   vlr = obj.value;
   vlr2 = "";
   vlr = vlr.replace("/","");
   vlr = vlr.replace("/","");
   vlr2 = vlr2 + vlr.substr(0,2);
   if (vlr.length >= 2) 
     vlr2 = vlr2 + "/";
   vlr2 = vlr2 + vlr.substr(2,2);
   if (vlr.length >= 4) 
     vlr2 = vlr2 +"/";
   vlr2 = vlr2 + vlr.substr(4,4);
   obj.value = vlr2;
   return true;
}

function VerificaData(DataVinda) 
{
    var digData = DataVinda.value;
	var bissexto = 0;
    var data = digData; 
    var tam = data.length;
	//deixa passar se estiver sem anda
	if (tam==0) {
		 return true;
	}
    if (tam == 10) 
    {
        var dia = data.substr(0,2)
        var mes = data.substr(3,2)
        var ano = data.substr(6,4)
        if ((ano > 1900)||(ano < 2100))
        {
            switch (mes) 
            {
                case '01':
                case '03':
                case '05':
                case '07':
                case '08':
                case '10':
                case '12':
                    if  (dia <= 31) 
                    {
                        return true;
                    }
                    break
                
                case '04':        
                case '06':
                case '09':
                case '11':
                    if  (dia <= 30) 
                    {
                        return true;
                    }
                    break
                case '02':
                    /* Validando ano Bissexto / fevereiro / dia */ 
                    if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)) 
                    { 
                        bissexto = 1; 
                    } 
                    if ((bissexto == 1) && (dia <= 29)) 
                    { 
                        return true;                 
                    } 
                    if ((bissexto != 1) && (dia <= 28)) 
                    { 
                        return true; 
                    }            
                    break                        
            }
        }
    }    
    alert("A Data "+data+" é inválida!");
	DataVinda.focus();
	DataVinda.select();
    return false;
}

function sonumero(mobjeto, mevento)
{
  if ((mevento.keyCode >= 48) && (mevento.keyCode <= 57)) { return true; }
  //if ((mevento.keyCode >= 96) && (mevento.keyCode <= 105)) { return true; }
  if ((mevento.keyCode == 46) || (mevento.keyCode == 8)) { return true; }
  return false;
}

function mascaraData(campoData) {
    var data = campoData.value;
    if (data.length == 2) {
        data = data + '/';
        campoData.value = data;
        return true;
    }
    if (data.length == 5) {
        data = data + '/';
        campoData.value = data;
        return true;
    }
}
function CheckLen(Target, texto, qtd) {
    StrLen = Target.value.length;
    maxLeght = qtd;
    if (StrLen > maxLeght) {
        Target.value = Target.value.substring(0, (maxLeght - 1));
        CharsLeft = 0;
    }
    else {
        CharsLeft = maxLeght - StrLen;
    }
    texto.value = CharsLeft;
}
