﻿$(function() {
    var navlist = $("#navs li");
    navlist.each(function(i) {
        var linkurl = $(this).children().attr("href").replace("../", "").toLowerCase();
        var currenturl = document.location.href.toLowerCase();
        if (currenturl.indexOf(linkurl) != -1) {
            $(this).attr("class", "current").siblings().attr("class", "")
        }
    });

    navlist.hover(function() {
        if ($(this).attr("class") != "current" ) {
            $(this).after("<li class=\"back\"></li>");
            var position = $(this).position();
            $(this).next().css({ "left": position.left + "px", "opacity": "0" });
            $(this).next().stop().animate({ opacity: 1 }, "slow");
        }
    },
	function() {
	    $(".back", "#navs").remove();
	});
});

(function ($) {
    $.fn.wait = function (time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function () {
            var self = this;
            setTimeout(function () {
                $(self).dequeue();
            }, time);
        });
    };
})(jQuery);
function pageHeight() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    } else {
        return self.innerHeight;
    }
};
function disable(obj, state) {
    if (obj) {
        if (obj.length > 0) {
            obj.attr("disabled", state);
        }
    }
};
function showmsg(msg, path, obj) {
    disable(obj, true);
    var msgblock = $("#msg");
    if (msgblock.length == 0) {
        $("body").append("<div id=\"msg\"></div>");
        msgblock = $("#msg");
    }
    var ptop = pageHeight() / 3;
    msgblock.css({ "top": ptop }).html(msg)
        .animate({ opacity: "show", top: ptop + 10 }, "fast")
        .wait(1000)
        .animate({ opacity: "hide", top: ptop }, "fast", function () {
            if (path) {
                location.href = path;
            }
            disable(obj, false);
        });
};
