﻿// JScript File

function addFav(url, title){
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div' );

//Specify spectrum of different font sizes:
var szs = new Array( '12px','13px','14px','15px','16px','17px','18px','19px','20px' );
var startSz = 0;

function ts( trgt,inc ) 
{
    if (!document.getElementById) return
    var d = document,cEl = null,sz = startSz,i,j,cTags;
    sz += inc;
    if ( sz < 0 ) sz = 0;
    if ( sz > 8 ) sz = 8;
    startSz = sz;
    if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

    cEl.style.fontSize = szs[ sz ];

    for ( i = 0; i < tgs.length; i++ ) 
    {
        cTags = cEl.getElementsByTagName( tgs[ i ] );
        for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
    }
}

function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return false;
    if (whichCode < 48 || whichCode > 57)  
    {  
        return true;  
    }
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
    if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
    if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
    if (j == 3) {
    aux2 += SeparadorMilesimo;
    j = 0;
    }
    aux2 += aux.charAt(i);
    j++;
    }
    objTextBox.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    objTextBox.value += aux2.charAt(i);
    objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
} 

function AbrirJanela(endereco, titulo, largura, altura, top, left, scroll)
{
    var myWin = window.open(endereco, 'titulo','width='+largura+', height='+altura+', top='+top+', left='+left+', location=1,fullscreen=no,scrollbars='+scroll); 
    myWin.focus();
}

function del()
{
    return confirm('Deseja realmente excluir este registro?');
}

//Função chamada pelos pops de tipos, botao de ok
function send(fecha)
{
    if (fecha)
        window.opener.location.replace(window.opener.location);
    self.close();
}

//MontaFlash
function MontaFlash(arquivo, largura, altura, variaveis, transparente)
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+largura+'" height="'+altura+'">\n');
    document.write('<param name="movie" value="'+arquivo+'" />\n');
    document.write('<param name="quality" value="high" />\n');
    if(transparente)
    {
        document.write('<param name="wmode" value="transparent" />\n');
    }
    document.write('<param name="flashvars" value="'+variaveis+'">\n');
    document.write('<embed src="'+arquivo+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'" wmode="transparent" flashvars="'+variaveis+'"></embed>\n');
    document.write('</object>\n');
}

function MontaCaixa(parte)
{
    if(parte=="abre")
    {
        document.write('<table width="100%" cellpadding="0" cellspacing="0" border="0">\n');
        document.write('<tr>\n');
        document.write('<td><img src="Img/Layout/Box_1.gif" /><br></td>\n');
        document.write('<td width="100%" background="Img/Layout/Box_2.gif"></td>\n');
        document.write('<td><img src="Img/Layout/Box_3.gif" /><br></td>\n');
        document.write('</tr>\n');
        document.write('<tr>\n');
        document.write('<td background="Img/Layout/Box_4.gif"><br></td>\n');
        document.write('<td bgcolor="#FFFFFF">');
    }
    else if(parte=="fecha")
    {
        document.write('</td>\n');
        document.write('<td background="Img/Layout/Box_5.gif"></td>\n');
        document.write('</tr>\n');
        document.write('<tr>\n');
        document.write('<td><img src="Img/Layout/Box_6.gif" /><br></td>\n');
        document.write('<td background="Img/Layout/Box_7.gif"></td>\n');
        document.write('<td><img src="Img/Layout/Box_8.gif" /><br></td>\n');
        document.write('</tr>\n');
        document.write('</table>\n');
    }
    else if(parte=="abreint")
    {
        document.write('<table width="577" cellpadding="0" cellspacing="0" border="0">\n');
        document.write('<tr>\n');
        document.write('<td colspan="3">\n');
        document.write('<div style="position:absolute;width:586px;"><table width="100%" cellpadding="0" cellspacing="0" border="0">\n');
        document.write('<tr>\n');
        document.write('<td><img src="Img/Layout/Boxint_1.gif" /></td>\n');
        document.write('<td background="Img/Layout/Boxint_2.gif">\n');
    }
    else if(parte=="meioint")
    {
        document.write('</td>');
        document.write('<td><img src="Img/Layout/Boxint_3.gif" /></td>');
        document.write('<td width="100%" background="Img/Layout/Boxint_4.gif">&nbsp;</td>');
        document.write('<td><img src="Img/Layout/Boxint_5.gif" /></td>');
        document.write('<tr>');
        document.write('</table></div>');
        Espaco(27);        
        document.write('</td>\n');
        document.write('</tr>\n');
        document.write('<tr>\n');
        document.write('<td background="Img/Layout/Box_4.gif">&nbsp;</td>\n');
        document.write('<td width="100%" bgcolor="#FFFFFF">');
    }
    else if(parte=="fechaint")
    {
        document.write('</td>\n');
        document.write('<td background="Img/Layout/Box_5.gif">&nbsp;</td>\n');
        document.write('</tr>\n');
        document.write('<tr>\n');
        document.write('<td><img src="Img/Layout/Box_6.gif" /></td>\n');
        document.write('<td width="100%" background="Img/Layout/Box_7.gif">&nbsp;</td>\n');
        document.write('<td><img src="Img/Layout/Box_8.gif" /></td>\n');
        document.write('</tr>\n');
        document.write('</table>\n');
    }
}

function MontaBordaFoto(parte)
{
    if (parte=="abre")
    {
        document.write('<table cellpadding="0" cellspacing="0" style="font-size:1px;">\n');
        document.write('<tr>\n');
        document.write('<td><img src="Img/Layout/BoxFoto_1.gif" border="0" /></td>\n');
        document.write('<td background="Img/Layout/BoxFoto_2.gif" style="background-repeat:repeat-x;"></td>\n');
        document.write('<td><img src="Img/Layout/BoxFoto_3.gif" border="0" /></td>\n');
        document.write('</tr>\n');
        document.write('<tr>\n');
        document.write('<td background="Img/Layout/BoxFoto_4.gif" style="background-repeat:repeat-y;"></td>\n');
        document.write('<td><div style="border:solid #CCCCCC 1px;">\n');        
    }
    else if(parte=="fecha")
    {
        document.write('</div></td>\n');
        document.write('<td background="Img/Layout/BoxFoto_5.gif" style="background-repeat:repeat-y;"></td>\n');
        document.write('</tr>\n');
        document.write('<tr>\n');
        document.write('<td><img src="Img/Layout/BoxFoto_6.gif" border="0" /></td>\n');
        document.write('<td background="Img/Layout/BoxFoto_7.gif" style="background-repeat:repeat-x;"></td>\n');
        document.write('<td><img src="Img/Layout/BoxFoto_8.gif" border="0" /></td>\n');
        document.write('</tr>\n');
        document.write('</table>\n');    
    }
}

function Espaco(tamanho)
{
    document.write('<br /><font style="font-size:'+ tamanho +'px;">&nbsp;</font><br />');
}

//Contorna proble dos Enters em textbox
function clickButton(e, buttonid){
     var bt = document.getElementById(buttonid);
     if (typeof bt == 'object'){
           if(navigator.appName.indexOf("Netscape")>(-1)){
                 if (e.keyCode == 13){
                       bt.click();
                       return false;
                 }
           }
           if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
                 if (event.keyCode == 13){
                       bt.click();
                       return false;
                 }
           }
     }
}

//Cancela enter em textbox indesejado
function HandleEnter (field, event) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13) {
        return false;
    } 
    else {
        return true;
    }
}

//Botao voltar
function MontaVoltar()
{
    Espaco(18);
    document.write('<div align="right">');
    document.write('<a href="JavaScript:history.go(-1);"><img src="Img/Layout/bt_Voltar.gif" alt="Voltar" border="0" /></a>');
    document.write('</div>');
}

/*
function escondeCal()
{
    document.all.getElementById('divCal').style.display='none'";
}*/

/*function mostraCal()
{
    document.all.getElementById('divCal').style.display='block'";
}*/

