(function ($) {
    $.fn.extend({
        accordion: function () {
            return this.each(function () {
                if ($(this).data('accordiated')) return false;
                $.each($(this).find('ul, li>div'), function () {
                    $(this).data('accordiated', true);
                    $(this).hide()
                });
                $.each($(this).find('a:not(.foo)'), function () {
                    $(this).click(function (e) {
                        activate(e.target);
                        return void(0)
                    })
                });
                var active = false;
                if (location.hash) active = $(this).find('a[href=' + location.hash + ']')[0];
                else if ($(this).find('li.current')) active = $(this).find('li.current a')[0];
                if (active) {
                    activate(active, 'toggle', 'parents');
                    $(active).parents().show()
                }
                function activate(el, effect, parents) {
                    $(el)[(parents || 'parent')]('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp('fast');
                    $(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect) ? 'fast' : null)
                }
            })
        }
    })
})(jQuery);
$(document).ready(function () {
    $('ul#navGlobal').accordion();
    $(".see table tr:odd").addClass("zb")
    $("a[href^=http]").attr("target", "_blank");
    $("#ctl00_Busca").Watermark("O que voc\u00EA est\u00E1 procurando?");
    $('#s1').cycle({
        fx: 'fade',
        speed: 500,
        pager: '.dest-nav',
        before: function () {
            $('#caption').html(this.title);
        }
    });
    var url = $(location).attr("href").split("/");
    var length = url.length;
    var find = "/" + url[length - 2] + "/" + url[length - 1];
    $("#navGlobal a").each(function () {
        if ($(this).attr("href") != undefined) {
            var vhref = $(this).attr("href").split("/");
            var href = vhref.length == 1 ? url[length - 2] + "/" + vhref : vhref[1] + "/" + vhref[2];
            href = "/" + href;
            if (find.indexOf("&") != -1) find = find.split("&")[0];
            find = find.replace("Detalhes", "Default");
            if (find == href) {
                if ($(this).parentsUntil("#navGlobal").last().get(0).tagName == "LI") $(this).parentsUntil("#navGlobal").last().addClass("mopen");
            }
        }
    });
});
