
$(function() {

    $("#tabProdutos").addClass("atual");
    $("ul#tbs li a[href='#tabProdutos']").parent().addClass("atual");

    $("ul#tbs li a").click(function() {
        $("ul#tbs li").removeClass("atual");
        $("#tabProdutos").removeClass("atual");
        $("#tabMarcas").removeClass("atual");
        $("#tabLojas").removeClass("atual");

        $(this).parent().addClass("atual");
        var id = $(this).attr("href");
        //console.info(id + " ")
        $(id).addClass("atual");
        return false;
    });


    $('.menuCategoriasPadrao').superfish({
        delay: 0,
        animation: { opacity: 'show' },
        speed: 'fast',
        autoArrows: false,
        dropShadows: false
    });

 
    $('.aquimenu').superfish({
        delay: 0,
        animation: { opacity: 'show' },
        speed: 'fast',
        autoArrows: false,
        dropShadows: false
    });

    $('.abas').superfish({
        delay: 0,
        animation: { opacity: 'show' },
        speed: 'fast',
        autoArrows: false,
        dropShadows: false
    });


    $('.menuSite').superfish({
        delay: 0,
        animation: { opacity: 'show' },
        speed: 'fast',
        autoArrows: false,
        dropShadows: false
    });


    $("a.buscaFirefox").click(function() {
        installSearchPlugin();
        return false;

    });

    $("ul.tags li a").click(function() {
        var busca = $(this).html();
        $("input.txtBusca").val(busca);
       $("input.btnProcurar").click();
        return false;
    });


    $('tbody tr:nth-child(even)').addClass('alt');

    $('#ctl00_corpo_ucBuscaNova1_btnProcurar').click(function() {
	var busca = $('#ctl00_corpo_ucBuscaNova1_txtBusca').val();
		if(busca.length > 1){
			return true;
		}else{
			alert("A busca deve ter pelo menos uma palavra");return false;
		} 
	});

	$('#ctl00_ucBuscaNova1_btnProcurar').click(function() {
	var busca = $('#ctl00_ucBuscaNova1_txtBusca').val();
		if(busca.length > 1){
			return true;
		}else{
			alert("A busca deve ter pelo menos uma palavra");return false;
		} 
	});	

    $(".boxFotoPro").hover(
        function() {
            $(this).addClass("mostraFoto");
            //alert($(this).find("img:first").attr("src"));
            var srcFoto = $(this).find("img:first").attr("src");
            if (srcFoto.lastIndexOf("fotoN.gif") == -1)
                $(this).append("<div class='bigFoto'><img alt='FotoGrande' src='" + srcFoto + "' /></div>");

        },
        function() {
            $(this).removeClass("mostraFoto");
            $(this).find("div:last").remove();
        }
       );
    

});


function abreDetalhes(cod) {

    var popup = window.open('http://www.comprape.com.br/Redirecionador.aspx?BannerID=' + cod, 'Loja' + cod, 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,width=840,height=600,top=50,left=50');
    if (!popup) {
        window.location = 'http://www.comprape.com.br/Redirecionador.aspx?BannerID=' + codigoLoja;
    }
    void (0); return false;
}


function abreLoja(caminho, codigoLoja) {

    var popup = window.open(caminho + 'DetalheLoja.aspx?Loja=' + codigoLoja, 'Loja' + codigoLoja, 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,width=840,height=600,top=50,left=50');
    var UOL_rm_prd = 38;
    var UOL_rm_mod = 1;
    try {
        var rm = new UOL_rm(UOL_rm_prd);
        rm.mod = UOL_rm_mod;
        rm.doCPA_MSR("Conversoes", "1");
    } catch (err) {
        //console.info("Erro: " + err);
    }
    if (!popup) {
        window.location = 'DetalheLoja.aspx?Loja=' + codigoLoja;
    }
    void (0); return false;
}




function visualizarImpressao() {
    
//    if (navigator.appName == "Microsoft Internet Explorer") {
//        var Navegador = '<object id="Navegador1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
//        document.body.insertAdjacentHTML('beforeEnd', Navegador);
//        Navegador1.ExecWB(7, 1);
//        Navegador1.outerHTML = "";
//    }
//    else {
        window.print();
//    }

}


function alerta(texto) {
    if ($(document).ready) {
        //alert(texto);
    }
}






//-----------------------------------------------------------------------------------------
//

function installSearchPlugin() {
    var endHost = "http://www.comprape.com.br/";
    try {
        window.external.AddSearchProvider(endHost + "comprapeBarraBusca.xml");
    } catch (e) {
        if (e.message == 'window.external has no properties' && (typeof (window.sidebar.addSearchEngine) == 'function')) {
            window.sidebar.addSearchEngine(endHost + "comprapeBarraBusca.src", endHost + "images/tema/favicon.ico", 'Comprape', 'web');
        } else {
            alert("Aparentemente seu browser não suporta nosso plugin. A busca do InfoDica requer Firefox 2+ ou Internet Explorer 7+.");
        }
    }
}



