﻿
var iScrollY = 0;

function showNotice() {
	$("#div_notice").show();
	isLogin();
	ScrollImg();
}
function isLogin()
{
	var url = '/admin/ajax/getLoginResult.do';
	var params = {
		test :'0'
	};
	jQuery.post(url, params, isLoginCallback, 'json');
}
var login ="0";
function isLoginCallback(data)
{
	if (data.result == "1") {
		document.getElementById("div_login").style.display="none";
	}
	else
	{
		$("#div_login").show();
	}
}

function close() {
    $("#div_notice").remove();
}

function ScrollImg(){
	if ($("#div_notice").get(0) == null){
		return;
	}
	if ($.browser.msie) {
        var defaultY = document.documentElement.scrollTop;
        var perceH = 0.3 * (defaultY - iScrollY);
        if (perceH > 0) {
            perceH = Math.ceil(perceH);
        }
        else {
            perceH = Math.floor(perceH);
        }
        $("#div_notice").get(0).style.bottom = parseInt($("#div_notice").get(0).style.bottom) + perceH + "px";
        if(login=="0")
        {
        	$("#div_login").get(0).style.top = parseInt($("#div_login").get(0).style.top) + perceH + "px";
        }
        iScrollY = iScrollY + perceH;
        setTimeout("ScrollImg()", 50);
    }
    else {
        window.onscroll = function() {
            $("#div_notice").get(0).style.bottom = parseInt($("#div_notice").get(0).style.bottom) + "px";
            $("#div_notice").get(0).style.position = "fixed";
            if(login=="0")
            {
            	$("#div_login").get(0).style.top = parseInt($("#div_login").get(0).style.top) + "px";
            	$("#div_login").get(0).style.position = "div_login";
            }
        }
    }
}

function createCookie(name, value, days, Tdom) {
    var Tdom = (Tdom) ? Tdom : "/";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString()
    }
    else {
        var expires = ""
    }

    document.cookie = name + "=" + value + expires + "; path=" + Tdom
}

function readCookie(name) {
    var nameEQ = name + "="; var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1, c.length)
        }

        if (c.indexOf(nameEQ) == 0) {

            return c.substring(nameEQ.length, c.length)
        }
    }

    return null;

}
