/* 레이어 팝업 쿠키설정 시작 */
function getCookie(name) {
    var nameOfCookie = name + "=";
    var x = 0;

    while (x <= document.cookie.length) {
        var y = x + nameOfCookie.length;
        if (document.cookie.substring(x, y) == nameOfCookie) {
            if ((endOfCookie=document.cookie.indexOf(";", y)) == -1) {
                endOfCookie = document.cookie.length;
            }
            return unescape(document.cookie.substring(y, endOfCookie));
        }
        x = document.cookie.indexOf(" ", x) + 1;
        if (x == 0) {
            break;
        }
    }
    return "";
}
/* 레이어 팝업 쿠키설정 끝 */


/* 레이어 팝업 드래그 앤 드랍 시작*/
var Drag={

        "obj":null,

        "init":function(a, aRoot, ee){
                if (!ee) {      //ee == null 을 변경 2008-05-13 박준영
                    a.onmousedown=Drag.start;
                }
                a.root = aRoot;
                if(isNaN(parseInt(a.root.style.left))) { a.root.style.left="0px"; }
                if(isNaN(parseInt(a.root.style.top))) { a.root.style.top="0px"; }
                a.root.onDragStart = new Function();
                a.root.onDragEnd = new Function();
                a.root.onDrag = new Function();

                if (!!ee) {     //ee != null 을 변경 2008-05-13 박준영
                    var b = Drag.obj = a;
                    ee = Drag.fixE(ee);
                    var c = parseInt(b.root.style.top);
                    var d = parseInt(b.root.style.left);
                    b.root.onDragStart(d,c,ee.clientX,ee.clientY);
                    b.lastMouseX = ee.clientX;
                    b.lastMouseY = ee.clientY;
                    document.onmousemove    = Drag.drag;
                    document.onmouseup      = Drag.end;
                }

            },


        // 드레그 스타트 시에... cron 생성 처리
        "start":function(a){
                
                var b=Drag.obj=this;
                a=Drag.fixE(a);

                var c = parseInt(b.root.style.top);
                var d = parseInt(b.root.style.left);

                b.root.onDragStart(d,c,a.clientX,a.clientY);

                b.lastMouseX = a.clientX;
                b.lastMouseY = a.clientY;

                document.onmousemove    = Drag.drag;
                document.onmouseup      = Drag.end;
                return false;
            },


        "drag":function(a){
                a = Drag.fixE(a);
                var b = Drag.obj;
                var c = a.clientY;
                var d = a.clientX;
                var e = parseInt(b.root.style.top);
                var f = parseInt(b.root.style.left);
                var h,g;
                h = f + d - b.lastMouseX;
                g = e + c - b.lastMouseY;
                b.root.style.left   = h + "px";
                b.root.style.top    = g + "px";
                b.lastMouseX        = d;
                b.lastMouseY        = c;
                b.root.onDrag(h, g, a.clientX, a.clientY);          
                return false;
            },


        "end":function(){
                document.onmousemove    = null;
                document.onmouseup      = null;
                Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top));          
                Drag.obj = null;
            },


        "fixE":function(a){
                if(typeof a == "undefined") { a=window.event; }
                if(typeof a.layerX == "undefined") { a.layerX=a.offsetX; }
                if(typeof a.layerY == "undefined") { a.layerY=a.offsetY; }
                return a;
            }
};
/* 레이어 팝업 드래그 앤 드랍 끝*/

