
// Lightbox
function abrirLightBox(ind) {
    // START - SIMPLE MODAL jQuery	
    $('.window .close, #mask').click(function(e) {
        $('.window').fadeOut('normal', function() {
            $('#mask').fadeOut('normal');
        });
        e.preventDefault();
    });


    var id = ind;
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    $('#mask').css({
        'width': maskWidth,
        'height': maskHeight,
        'background': '#000',
        'opacity': 0.8,
        'cursor': 'pointer'
    });


    $('#mask').fadeIn();

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    $(id).css('top', winH / 2 - $(id).height() / 2);
    $(id).css('left', winW / 2 - $(id).width() / 2);

    $(id).fadeIn(2000);

    // END - SIMPLE MODAL jQuery
}

function Alterafoto(imgSrc) {
    $('#imgPrincipal').attr("src", imgSrc);
}


//Nova Funçao Abre Abas
function AbreAba(nome_div)   {
       var total_divs = document.getElementById('top-navigation').getElementsByTagName('ul').length;
       var div = "";
       var td = "";

       for (var i=1; i < total_divs+1; i++)   {
             div = "div"+i;
             td = "td"+i;
             document.getElementById(div).style.display = "none";
             document.getElementById(td).style.backgroundColor = "";
             document.getElementById(div).className="div";
                   if (div == nome_div) {
                         //caso a div seja a selecionada, abre o conteudo correspondente e marca a aba selecionada.
                         document.getElementById(nome_div).style.display = "block";
                         document.getElementById(td).style.backgroundColor = "#CCCCCC";
                  }
      }
}


//ABAS
function trocaAbas(aba,opcao)
{
    var x = document.getElementById(aba +'_'+ opcao);
    var listaAbas = document.getElementById('top-navigation').getElementsByTagName('li').length;
    for (var i=0; i<listaAbas; i++)
    {
        if (opcao == (i+1))
        {
            x.className = 'active';
            //document.getElementById('div_'+ opcao).style.display = 'block';
        }
        else
        {
            document.getElementById(aba + '_' + (i+1)).className = '#';
            //document.getElementById('div_'+ (i+1)).style.display = 'none';
        }
    }
}
                   

function formatar(mascara, documento){
  var i = documento.value.length;
  var saida = mascara.substring(0,1);
  var texto = mascara.substring(i)
  
  if (texto.substring(0,1) != saida){
            documento.value += texto.substring(0,1);
  }
}


function v_NR(tecla){
    if(typeof(tecla) == 'undefined')
    var tecla = window.event;
    var codigo = (tecla.which ? tecla.which : tecla.keyCode ? tecla.keyCode : tecla.charCode);
    // permite números, 8=backspace, 46=del e 9=tab
    if ( (codigo >= 48 && codigo <= 57) || (codigo >= 96 && codigo <= 105) || codigo == 8 || codigo == 46 || codigo == 9 )
    { 
        return true; 
    }
    else
    {   
        return false; 
    }
} 




//function trocaFaixaIdade()
//{
//    if (document.getElementById('faixa1'))
//    {
//        document.getElementById("lstvBrinquedos").DataSource = document.getElementById('hdnFaixa1').value;
//    }
//}


