﻿(function (a) { a.scrollFollow = function (f, d) { f = a(f); var b = f.css("position"); function c() { f.queue([]); var h = parseInt(a(window).height()); var j = parseInt(a(document).scrollTop()); var k = parseInt(f.cont.offset().top); var i = parseInt(f.cont.outerHeight()); var l = parseInt(f.outerHeight() + (parseInt(f.css("margin-top")) || 0) + (parseInt(f.css("margin-bottom")) || 0)); var g; if (e) { if (d.relativeTo == "top") { if (f.initialOffsetTop >= (j + d.offset)) { g = f.initialTop } else { g = Math.min((Math.max((-k), (j - f.initialOffsetTop + f.initialTop)) + d.offset), (i - l - f.paddingAdjustment)) } } else { if (d.relativeTo == "bottom") { if ((f.initialOffsetTop + l) >= (j + d.offset + h)) { g = f.initialTop } else { g = Math.min((j + h - l - d.offset), (i - l)) } } } if ((new Date().getTime() - f.lastScroll) >= (d.delay - 20)) { f.animate({ top: g }, d.speed, d.easing) } } } var e = true; if (a.cookie != undefined) { if (a.cookie("scrollFollowSetting" + f.attr("id")) == "false") { var e = false; a("#" + d.killSwitch).text(d.offText).toggle(function () { e = true; a(this).text(d.onText); a.cookie("scrollFollowSetting" + f.attr("id"), true, { expires: 365, path: "/" }); c() }, function () { e = false; a(this).text(d.offText); f.animate({ top: f.initialTop }, d.speed, d.easing); a.cookie("scrollFollowSetting" + f.attr("id"), false, { expires: 365, path: "/" }) }) } else { a("#" + d.killSwitch).text(d.onText).toggle(function () { e = false; a(this).text(d.offText); f.animate({ top: f.initialTop }, 0); a.cookie("scrollFollowSetting" + f.attr("id"), false, { expires: 365, path: "/" }) }, function () { e = true; a(this).text(d.onText); a.cookie("scrollFollowSetting" + f.attr("id"), true, { expires: 365, path: "/" }); c() }) } } f.cont = d.container ? f.parent() : a("#" + d.container); f.initialOffsetTop = parseInt(f.offset().top); f.initialTop = parseInt(f.css("top")) || 0; if (f.css("position") == "relative") { f.paddingAdjustment = parseInt(f.cont.css("padding-top")) + parseInt(f.cont.css("padding-bottom")) } else { f.paddingAdjustment = 0 } a(window).scroll(function () { a.fn.scrollFollow.interval = setTimeout(function () { c() }, d.delay); f.lastScroll = new Date().getTime() }); a(window).resize(function () { a.fn.scrollFollow.interval = setTimeout(function () { c() }, d.delay); f.lastScroll = new Date().getTime() }); f.lastScroll = 0; c() }; a.fn.scrollFollow = function (b) { b = b || {}; b.relativeTo = b.relativeTo || "top"; b.speed = b.speed || 500; b.offset = b.offset || 0; b.easing = b.easing || "swing"; b.container = b.container || this.parent().attr("id"); b.killSwitch = b.killSwitch || "killSwitch"; b.onText = b.onText || "Turn Slide Off"; b.offText = b.offText || "Turn Slide On"; b.delay = b.delay || 0; this.each(function () { new a.scrollFollow(this, b) }); return this } })(jQuery);

$(function () {
    $("#caixa-cinza").css("min-height", ($('#orcamento-box').outerHeight(true) + 64));
    $("#busca input:text").bind({
        focus: function () {
            if ($(this).val() == "Encontre aqui o cartucho desejado...") {
                $(this).val("")
            }
        },
        blur: function () {
            if ($(this).val() == "") {
                $(this).val("Encontre aqui o cartucho desejado...")
            }
        }
    })
    if ($("#menu-adm").length != 0) {
        $('#menu-adm > li').bind({
            mouseenter: function () {
                $(this).children('ul').css("display", "block")
            },
            mouseleave: function () {
                $(this).children('ul').css("display", "none")
            }
        });


        $(".excluir").click(function (e) {
            e.preventDefault();
            var href = $(this).attr('href');
            var texto = $(this).attr('rel');
            excluir(href, texto);
        });
        $(".calendario").button({
            icons: {
                primary: "ui-icon-calendar"
            }
        })
        $(".excluir").button({
            icons: {
                primary: "ui-icon-closethick"
            }
        })
        $(".editar").button({
            icons: {
                primary: "ui-icon-pencil"
            }
        })
        $(".procurar").button({
            icons: {
                primary: "ui-icon-search"
            }
        })
        $(".relatorio").button({
            icons: {
                primary: "ui-icon-clipboard"
            }
        })
        $(".gravar").button({
            icons: {
                primary: "ui-icon-disk"
            }
        })
    }
    function modal() {
        $("#dialog-message").dialog({
            modal: true,
            buttons: {
                Ok: function () {
                    $(this).dialog("close");
                }
            },
            resizable: false,
            draggable: false
        });
    }

    function excluir(href, texto) {
        $("#dialog-message").attr("title", "Confirmação de exclusão");
        $("#dialog-message span").next().html(texto);
        $("#dialog-message").dialog({
            resizable: false,
            modal: true,
            buttons: {
                "Excluir": function () {
                    $(this).dialog("close");
                    location.href = href;
                },
                "Cancelar": function () {
                    $(this).dialog("close");
                }
            },
            draggable: false
        });
    }
});
