function showiframe(url)
{
        largIfr=300;
        altIfr=300;

        if(screen.availWidth == 800)
                largIfr = 450;
        else if(screen.availWidth > 800) largIfr = 650;
        
        if(screen.availHeight == 600)
                altIfr=450;
        else if(screen.availHeight > 600) altIfr = 500;

        document.write("<iframe src=" + url +" scrolling='yes' height='" + altIfr + "' width='" + largIfr + "' frameborder='0' ></iframe>");
}

function showdate()
{
        var mydate=new Date()
        var theYear=mydate.getFullYear()
        var day=mydate.getDay()
        var month=mydate.getMonth()
        var daym=mydate.getDate()
        if (daym<10)
                daym="0"+daym
        var dayarray=new Array("Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado")
        var montharray=new Array("janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro")
        document.write("<Font face='Arial, Helvetica, sans-serif' size='1'><B>"+dayarray[day]+", "+daym+" de "+montharray[month]+" de "+theYear+"&nbsp;&nbsp;</B></font>")
}

function open_window(URL, Largura, Altura)
{
    
    if(Largura==0 && Altura==0)
    {
        modo = "top=0, left=0, width=800, height=500";
    }
    else
    {
        modo = "top=10, left=10, width="+Largura+", height="+Altura;
    }
    var popup=window.open(URL,"",'toolbar=1, location=0, directories=0, menubar=0, scrollbars=1, status=1, textlabel=0,'+ modo+', copyhistory=no, resizable=yes');
    if( navigator.appName.substring(0,8) == "Netscape" )
    {
            popup.location = URL;
    }
    popup.focus();
}

function open_rss(URL, Descricao)
{
    
    pagina = "docs/abre_noticia.php?link=" + URL + "&descricao=" + Descricao;
    modo = "top=10, left=10, width=" + (screen.availWidth - 10) + ", height=" + (screen.availHeight - 10);
    
    var popup=window.open(pagina,"Noticias",'toolbar=1, location=0, directories=0, menubar=0, scrollbars=1, status=1, textlabel=0,'+ modo+', copyhistory=no, resizable=yes');
    if( navigator.appName.substring(0,8) == "Netscape" )
    {
            popup.location = pagina;
    }
    popup.focus();
}

function open_livro(URL)
{
    
    pagina = "docs/suporte/kurumin_livro/abre_pagina.php?link=" + URL
    modo = "top=10, left=10, width=" + (screen.availWidth - 10) + ", height=" + (screen.availHeight - 10);
    
    var popup=window.open(pagina,"Livro",'toolbar=0, location=0, directories=0, menubar=0, scrollbars=1, status=0, textlabel=0,'+ modo+', copyhistory=no, resizable=yes');
    if( navigator.appName.substring(0,8) == "Netscape" )
    {
            popup.location = pagina;
    }
    popup.focus();
}

function startclock()
{
   var now = new Date();
   var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
   var hours = now.getHours();
   hours = ((hours > 12) ? hours - 12 : hours);
   var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
   var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
   var Time=(hours + minutes + seconds + " " + ampm );
   window.status='Agora é: '+Time;
   timerID = setTimeout("startclock()",1000);
   timerRunning = true;
}

function Mascara(formato, keypress, objeto)
{
    campo = eval(objeto);
    if (formato=='beneficio')
    {
        caracteres = '01234567890';
        separacoes = 3;
        separacao1 = '.';
        separacao2 = '.';
        separacao3 = '-';
        conjuntos = 4;
        conjunto1 = 3;
        conjunto2 = 3;
        conjunto3 = 3;
        conjunto4 = 1;
        x=campo.value.length;
        if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + conjunto4 + 3))
        {
            if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
                if (campo.value.length == conjunto1 + conjunto2 + 1) campo.value = campo.value + separacao2;
                    if (campo.value.length == conjunto1 + conjunto2 + conjunto3 + 2)
                    {
                        campo.value = campo.value + separacao3;
                    }
        }
        else
        {
            event.returnValue=false;
        }
    }
}

function FormataData(objeto, teclapres) 
{
        campo = eval(objeto);
        var tecla = teclapres.keyCode;
        vr = 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 )
                        campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
                if ( tam >= 5 && tam <= 10 )
                        campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
        }
}

function FormataCampo(objeto) 
{
        campo = eval(objeto);
        vr = campo.value;
        
        vr = vr.replace( ".", "" );
        vr = vr.replace( "/", "" );
        vr = vr.replace( "-", "" );
        vr = vr.replace( "*", "" );
        vr = vr.replace( "+", "" );
        vr = vr.replace( "(", "" );
        vr = vr.replace( ")", "" );
        vr = vr.replace( "=", "" );
        vr = vr.replace( ",", "" );
        vr = vr.replace( "<", "" );
        vr = vr.replace( ">", "" );
        vr = vr.replace( ":", "" );
        vr = vr.replace( ";", "" );

        vr = vr.toLowerCase();        
        vr = vr.replace( "a", "" );
        vr = vr.replace( "b", "" );
        vr = vr.replace( "c", "" );
        vr = vr.replace( "d", "" );
        vr = vr.replace( "e", "" );
        vr = vr.replace( "f", "" );
        vr = vr.replace( "g", "" );
        vr = vr.replace( "h", "" );
        vr = vr.replace( "i", "" );
        vr = vr.replace( "j", "" );
        vr = vr.replace( "k", "" );
        vr = vr.replace( "l", "" );
        vr = vr.replace( "m", "" );
        vr = vr.replace( "n", "" );
        vr = vr.replace( "o", "" );
        vr = vr.replace( "p", "" );
        vr = vr.replace( "q", "" );
        vr = vr.replace( "r", "" );
        vr = vr.replace( "s", "" );
        vr = vr.replace( "t", "" );
        vr = vr.replace( "u", "" );
        vr = vr.replace( "v", "" );
        vr = vr.replace( "w", "" );
        vr = vr.replace( "x", "" );
        vr = vr.replace( "y", "" );
        vr = vr.replace( "z", "" );
        
        campo.value = vr;
}



function printPage()
{
  var da = (document.all) ? 1 : 0;
  var pr = (window.print) ? 1 : 0;
  var mac = (navigator.userAgent.indexOf("Mac") != -1); 
  
  if (pr)
    window.print();
  else if (da && !mac) 
    vbPrintPage();
  else 
    alert("Desculpe seu navegador não suporta esta função. Por favor utilize a opção imprimir do seu navegador.");
  return false;
  
}

function isNum( caractere )
{
         var strValidos = "0123456789";
         if ( strValidos.indexOf( caractere ) == -1 )
                 return false;
         return true;
}

function validaTecla(campo, event)
{
         var BACKSPACE=8;
         var key;
         var tecla;

         CheckTAB=true;
         if(navigator.appName.indexOf("Netscape")!= -1)
                 tecla= event.which;
         else
                 tecla= event.keyCode;

         key = String.fromCharCode( tecla);

         if (tecla == 13)
                 return false;
         if (tecla == BACKSPACE)
                 return true;
         return (isNum(key));
}

function validaCNPJ(el)
{

	vr = el.value;
	tam = vr.length;
	vr = vr.replace("/","");
	vr = vr.replace(".","");
	vr = vr.replace("-","");
	//if (vr.strlen <> 14) return 0;
	soma1 = (vr.substr(0,1) * 5) + (vr.substr(1,1) * 4) + (vr.substr(2,1) * 3) + (vr.substr(3,1) * 2) + 
	        (vr.substr(4,1) * 9) + (vr.substr(5,1) * 8) + (vr.substr(6,1) * 7) + (vr.substr(7,1) * 6) + 
        	(vr.substr(8,1) * 5) + (vr.substr(9,1) * 4) + (vr.substr(10,1) * 3) + (vr.substr(11,1) * 2);
	resto = soma1 % 11;
	if(resto < 2)
		digito1 = 0
	else digito1 = 11 - resto;
	
	//alert"digito1:" + digito1; //ativando esta linha, vc vera o digito1 correto
	
	soma2 = (vr.substr(0,1) * 6) + (vr.substr(1,1) * 5) + (vr.substr(2,1) * 4) + (vr.substr(3,1) * 3) + 
	        (vr.substr(4,1) * 2) + (vr.substr(5,1) * 9) + (vr.substr(6,1) * 8) + (vr.substr(7,1) * 7) + 
        	(vr.substr(8,1) * 6) + (vr.substr(9,1) * 5) + (vr.substr(10,1) * 4) + (vr.substr(11,1) * 3)
        	+ (vr.substr(12,1) * 2);
	
	resto = soma2 % 11;
	
	if(resto < 2)
		digito2 = 0
	else digito2 = 11 - resto;

	//alert"digito2:" + digito2; //ativando esta linha, vc vera o digito2 correto

	if ((vr.substr(12,1) == digito1) && (vr.substr(13,1) == digito2))
		return true;
	else return false;
}

function validaCPF(el)
{
        var i;
        s = el.value;
        s = s.replace("/","");
        s = s.replace(".","");
		s = s.replace("-","");
        var c = s.substr(0,9);
        var dv = s.substr(9,2);
        var d1 = 0;
        for (i = 0; i < 9; i++)
        {
            d1 += c.charAt(i)*(10-i);
        }
        if (d1 == 0)
        {
                  return false;
        }
        d1 = 11 - (d1 % 11);
        if (d1 > 9) d1 = 0;
        if (dv.charAt(0) != d1)
        {
            return false;
        }
		else
		{
	        d1 *= 2;
        	for (i = 0; i < 9; i++)
	        {
        	    	d1 += c.charAt(i)*(11-i);
	        }
        	d1 = 11 - (d1 % 11);
	        if (d1 > 9) d1 = 0;
        	if (dv.charAt(1) != d1)
	        {
            		return false;
        	}
		}
		return true;
}