var Notice =
{
    pop_state : false,
    notice_state : false,
    notice_reload : false,
    showLoad : false,
    myAjax : $,
    loadPop : function(url)
    {
        Notice.myAjax.get(url,function(data)
        {
            $("#pop_notice").html(data);
            $("#alpha").show();
            $("#pop_notice").hide();
            Notice.pop_state = true;
            document.documentElement.style.overflow = 'hidden';
            document.body.style.overflow = "hidden";
        });
    },
    closePop: function(reload)
    {
        $("#alpha").hide();
        $("#pop_notice").hide();
        $("#pop_notice").hide();
        document.documentElement.style.overflow = 'auto';
        document.body.style.overflow = "auto";
        Notice.pop_state = false;
        if(reload)
        {
            window.location.replace(window.location.href);
        }
    },
    loadUidPop : function(url, id)
    {
        Notice.myAjax.get(url,function(data){
            var
            $pop = $('#' + id),
            $win = $(window),
            winW = $win.width(),
            winH = $win.height(),
            winT = $win.scrollTop(),
            winL = $win.scrollLeft();

            $("#alpha").height(winH+winT+200).show();
            $pop.html(data).show();
            var nTop = winT + (winH - $pop.outerHeight()) / 2;
            var nLeft = winL + (winW - $pop.outerWidth()) / 2;

            $pop.css({position:"absolute", top:nTop+"px", left:nLeft+"px"});
            $('html,body').css('overflow', 'hidden');
        });

        return false;
    },
    closeUidPop: function(obj,reload)
    {
        $("#alpha").hide();
        $("#"+obj).hide();
        $('html,body').css('overflow', 'auto');
        if (reload) {
            window.location.replace(window.location.href);
        }

        return false;
    },
    closeNotice : function()
    {
        $("#pop_notice").hide();
        if(Notice.notice_reload) window.location.replace(window.location.href);
        else if(Notice.showLoad) $("#pop_notice").show();
        else{
            document.documentElement.style.overflow = 'auto';
            document.body.style.overflow = "auto";
            $("#alpha").hide();
        }
        Notice.notice_state = false;
        Notice.showLoad = false;
        $('#pop_notice').trigger('close');
    },
    showNotice : function(notice,state,showload, reload)
    {
        $("#alpha").height((document.documentElement.clientHeight || document.body.clientHeight) + (document.documentElement.scrollTop || document.body.scrollTop) + 200 + 'px');
        if(state !== false) $("#pop_notice").removeClass("err").addClass("sec");
        else $("#pop_notice").removeClass("sec").addClass("err");
        $("#notice_content").html(notice);
        $("#alpha").show();
        $("#pop_notice").show();
        var h1 = document.body.clientHeight, h2=document.documentElement.clientHeight;
        var clientH = (h1>h2 && h2>0)?h2:h1;
        var sTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
        var t = (clientH - $("#pop_notice").height())/2 + sTop;
        var nleft = ($(window).width() - $('#pop_notice').outerWidth())/2;
        $("#pop_notice").css("top",t > 0 ? (t+'px') : '0').css('left', nleft + 'px');
        document.documentElement.style.overflow = 'hidden';
        document.body.style.overflow = "hidden";
        Notice.notice_state = true;
        Notice.showLoad = !!showload;
        Notice.notice_reload = (reload === true);
    },
	showObjNotice : function(obj)
    {
		$("#alpha").height((document.documentElement.clientHeight || document.body.clientHeight) + (document.documentElement.scrollTop || document.body.scrollTop) + 200 + 'px');
		var o=$("#"+obj);
		var itop=Math.max(160,(document.body.scrollTop+document.documentElement.scrollTop+($(window).height()-o.height())/2));
		var ileft=(document.documentElement.clientWidth-o.width())/2+document.documentElement.scrollLeft;
		o.css({position:"absolute",top:itop+"px",left:ileft+"px"});
		$("#alpha").show();
		o.fadeIn();	
    }
};
