﻿$(document).ready(function() {

    InternaDocumentReady();
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InternaDocumentReady);

    $('.tbFck tbody tr:odd').addClass('alt');
    $('.tbFck tbody tr').each(function(){
        $(this).find('td:last').addClass('last');
    })

    $('.tbFck tbody tr:first').each(function() {
        $(this).find('td').css('border-top', '1px solid #CC092F');
    })
    
    $('.tbFck tbody tr:last').each(function(){
    $(this).find('td').css('border-bottom','1px solid #CC092F');
    })
  
});

function InternaDocumentReady(sender, args) {
    $('.lstAccordion').find('dt a').click(function(event) {
        event.preventDefault();
        $(this).parent().toggleClass('on').next().slideToggle('fast');
    });

    var anchor = location.toString().split('#')[1];
    var selector = 'dt a:first';

    // Se houver uma âncora especificada, abrir o item correspondente
    if (anchor != undefined && anchor != '') {
        selector = 'dt a[name=' + anchor + ']';
    }
	

   //$('.lstAccordion').find(selector).parent().addClass('on').parent().find('dt:not(.on)').next().hide();
   $('.lstAccordion').find('dd').hide();
   $('.lstAccordion:first').find(selector).click();

    // Verificação de altura de conteúdo em relação a altura do menu
    if ($('#colLft').height() > $('#contColLft').height()) {
        var numHeight = -158 + $('#colLft').height();

        if (typeof document.body.style.maxHeight === "undefined") {
            $('#contColLft .contDefault').css('height', numHeight);
        } else {
            $('#contColLft .contDefault').css('min-height', numHeight);
        }

    };

    // tooltipo favoritos 

    $('.lnkAddFavoritos').mouseover(function() {
        $('.logtip').hide();
        $(this).find('.logtip').show();
    })


    $('.icoLembrete').mouseover(function() {
        $('.logtip').hide();
        $(this).find('.logtip').show();
        
        $('.contentBox').hide();
        $(this).find('.contentBox').show();     
    })




    $('.tipClose').click(function() {
        $('.logtip').hide();
        return false;
    })

 

    /* Cotações e índices */
    /* Box Abre e Fecha */
    $('.boxCotInd')
        .find('dt a').click(function() {
            $(this).parent()
                .toggleClass('on')
                .next('dd').slideToggle();
        })
        .end()
        .find('dt:not(.on)').next('dd').hide()

    /* Aba cotações */
    $('.abaAcoes a').click(function(event) {
        event.preventDefault();
        if ($(this).parent().attr('class') != 'on') {
            $('.abaAcoes .on').removeClass('on');
            $(this).parent().addClass('on');

            $('.cotacoes .on').fadeOut();
            $($(this).attr('href'))
                .fadeIn()
                .addClass('on');
        }
    })

    //BUSCA AVANÇADA
    $('#ctl00_ConteudoMiolo_chkTodoSite').click(function() {
        if (this.checked) {
            $('.listRadioBusca li INPUT').each(function() {
                this.checked = false;
            });
        }
    });

    //BUSCA AVANÇADA
    $('.listRadioBusca li INPUT').click(function() {
        if (this.checked) {
            $('#ctl00_ConteudoMiolo_chkTodoSite')[0].checked = false;
        }
    });

}

// sirf
if(typeof sIFR == "function"){
   sIFR.replaceElement(named({sSelector:".contrast h1", sFlashSrc:"../../swf/newJuneBold.swf", sColor:"#FFFFFF", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:".contrast .lightFontTtl", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#FFFFFF", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:".contrast .sifrSubtitle", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#FFFFFF", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:".contrast h2.red", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#FFFFFF", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:".contrast h3", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#FFFFFF", sWmode:"transparent"}))
   
   sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:"../../swf/newJuneBold.swf", sColor:"#C31010", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:".lightFontTtl", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#C31010", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:".sifrSubtitle", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#333333", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:"h2.red", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#C31010", sWmode:"transparent"}))
   sIFR.replaceElement(named({sSelector:"h3", sFlashSrc:"../../swf/newJuneBook.swf", sColor:"#333333", sWmode:"transparent"}))
};


function printCont(itemPrint,lang){
	var urlLang = '';
	if(lang=='2'){
		urlLang = '_en';
	}
    var printVersion = window.open('../../conteudo/print/default'+urlLang+'.htm','windowPrint','width=800, height=600,status=no,toolbar=no,menubar=no,location=no,scrollbars=1')
    
    var strPrint = '';
     $(itemPrint).each(function(){
        strPrint = strPrint + $(this).html();
    })

	//$(printVersion.document).ready(function() {
        setTimeout(function() {
            printVersion.document.getElementById('cont').innerHTML = strPrint;
        }, 2000);
    //});
}


