var url = self.location.href.replace(/\\/, "/").split("/");
var idioma = url[url.length - 3].toLowerCase();
var pasta = url[url.length - 2].toLowerCase();
var pg = url[url.length - 1];
var titulopg = document.title;


if ((pg == "" || pg == "Default.aspx") && (pasta == "pt" || pasta == "en")) {
    stepcarousel.setup({ galleryid: 'fqpdentroin', beltclass: 'belt', panelclass: 'panel', autostep: { enable: false }, panelbehavior: { speed: 800, wraparound: true, persist: true },
        defaultbuttons: { enable: true, moveby: 1, leftnav: ['/App_Themes/Imagens/bt_setas_bottom_esq.png', 0, 18], rightnav: ['/App_Themes/Imagens/bt_setas_bottom_dir.png', 0, 18] }, contenttype: ['inline']
    });

    $(function () {
        $('.tooltip').tipsy({ gravity: 's' });
    });
}


$(document).ready(function () {



    function megaHoverOver() {
        $(this).find(".sub").stop().fadeTo('fast', 1, function() 
            {
                if (jQuery.browser.msie)
                    this.style.removeAttribute('filter');
            }).show();

    }

    function megaHoverOut() {
        $(this).find(".sub").stop().fadeTo('fast', 0, function () {
            $(this).hide();
        });
    }

    var config = {
        sensitivity: 2,
        interval: 100,
        over: megaHoverOver,
        timeout: 200,
        out: megaHoverOut
    };

    $("ul#topnav li .sub").css({ 'opacity': '0' });
    $("ul#topnav li").hoverIntent(config);


    var fonte = 11;

    $('.link_mais').click(function () {
        if (fonte < 17) {
            fonte = fonte + 1;
            $('.content_center').css({ 'font-size': fonte + 'px' });
        }
    });



    $('.link_menos').click(function () {
        if (fonte > 11) {
            fonte = fonte - 1;
            $('.content_center').css({ 'font-size': fonte + 'px' });
        }
    });

    function flash(movie, flashvars, width, height, retorna) {
        swfid = movie.split("/");
        swfid = swfid[swfid.length - 1].replace(".swf", "");
        strSWF = '<object id="' + swfid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '">' +
			'<param name="movie" value="' + movie + '">' +
			'<param name="quality" value="high">' +
			'<param name="wmode" value="transparent">' +
			'<param name="FlashVars" value="' + flashvars + '">' +
			'<embed name="' + swfid + '" src="' + movie + '" width="' + width + '" height="' + height + '" flashvars="' + flashvars + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>' +
			'</object>';
        if (!retorna) this.document.write(strSWF);
        else return (strSWF);
    }


    if (!((pg == "" || pg == "Default.aspx") && (pasta == "pt" || pasta == "en")))
	{
        $(".Titulo_Paginas").html(titulopg);


        $(".Titulo_Paginas").dropShadow({ left: 0, top: 0, opacity: 0.5, blur: 5 });

        var secao = $("#topnav a[href*=" + pasta + "]").attr("rel");

        $('.content_top').addClass("top_" + pasta);


        $("#topnav a[rel=" + secao + "]").css('background-image', "url(/App_Themes/Imagens/menu/bg_item_menu_" + secao + ".png)");
        

        $("#topnav a[rel=" + secao + "]").css('color', "#FFF");
    }


    $(".tabela tr:nth-child(odd)").addClass("pinta");



    $(".negociossp").colorbox({ iframe: true, innerWidth: 400, innerHeight: 575 });
    
    $(".negocios").colorbox({ iframe: true, innerWidth: 400, innerHeight: 150 });

    $(".historia").colorbox({ iframe: true, innerWidth: 450, innerHeight: 350 });

    $(".administracao").colorbox({ iframe: true, innerWidth: 600, innerHeight: 350 });

    $("a[rel='grafico']").colorbox({ iframe: true, innerWidth: '400', innerHeight: '280' });

    $("a[rel='graficohome']").colorbox({ iframe: true, innerWidth: '520', innerHeight: '450' });

    $("a[rel='webcast_box']").colorbox({ iframe: true, innerWidth: '790', innerHeight: '542' });



    $("#click").click(function () {
        $('#click').css({ "background-color": "#FFF", "color": "#fff", "cursor": "inherit" }).text("Open this window again and this message will still be here.");
        return false;
    });


});


var slideDown_atual;

function slideDown(div) {
    $(".link_expansivel").fadeOut("slow");

    if (slideDown_atual) {
        $("#" + slideDown_atual).slideUp(800, "easeOutQuad");
    }

    slideDown_atual = div;

    $(".link_expansivel").fadeIn("slow");

    if ($("#" + div).css("display") == "none") {
        $("#" + div).slideDown(800, "easeInQuad");
    }
    else {
        $("#" + div).slideUp(800, "easeOutQuad");
    }
}



//Setão botão padrão por javascript
function clickButton(e, buttonid) {
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
        $(buttonid).click();
        return false;
    } else {
        return true;
    }
}

