﻿/* list row over/out style */
function overRow(ctl, isfocus) {
    if (ctl.tagName == "TR") {
        var arr = ctl.getElementsByTagName("td");
        for (var i = 0; i < arr.length; i++)
            arr[i].style.backgroundColor = "#EAEFF2";
    }
    else {
        ctl.style.backgroundColor = "#EAEFF2";
        if (isfocus != null)
            ctl.style.cursor = "hand";
    }
}

function outRow(ctl, isfocus) {
    if (ctl.tagName == "TR") {
        var arr = ctl.getElementsByTagName("td");
        for (var i = 0; i < arr.length; i++)
            arr[i].style.backgroundColor = "#fff";
    }
    else {
        ctl.style.backgroundColor = "#fff";

        if (isfocus != null)
            ctl.style.cursor = "pointer";
    }
}
/****** 팝업 ******/
function popupOpen(cookieName, url, width, height, top, left) {
    try {
        if (getCookie(cookieName) == "") {
            var options = "toolbar=0";
            options += ",scrollbars=0";
            options += ",menubar=0";
            options += ",resizable=0";
            options += ",width=" + width;
            options += ",height=" + height;
            if (top != null)
                options += ",top=" + top;
            if (left != null)
                options += ",left=" + left;

            window.open(url, cookieName, options)
        }
    }
    catch (err) {
        alert(err.message);
    }

    return false;
}

function popupLayer(cookieName, content, w, h, topPos, leftPos) {
    try {
        if (findCookie(cookieName) == false) {
            if ($('#' + cookieName).size() > 0) {
                $('#' + cookieName + ' .popupContent').css({ width: w, height: h });
                $('#' + cookieName + ' .popupActionBox').css({ width: w });
                $('#' + cookieName).css({ top: topPos, left: leftPos }).show();

                return false;
            }

            var layer = $("<div id='" + cookieName + "' class='popupLayer'><div class='popupContent'>" + content +
                    "</div><div class='popupActionBox'><label><input type='checkbox' id='chkToday' name='chkToday' class='" + cookieName +
                    "' />오늘하루만 보기</label><a class='close' href='#'>[닫기]</a></div></div>");

            $('.popupContent', layer).css({ width: w, height: h, overflow: 'auto' });
            $('.popupActionBox', layer).css({ width: w });
            $('.popupActionBox a.close', layer).click(
                    function () {
                        var chk = $(":checked", layer);
                        if (chk.size() == 1)
                            setCookie(chk.attr("class"), "1", 1);

                        $(layer).hide();
                    });

            $('body div:first').append(layer);

            layer.css({ top: topPos, left: leftPos }).show();
        }
    }
    catch (err) {
        alert(err.message);
    }

    return false;
}

function popupWindow(cookieName, contentSn, w, h, topPos, leftPos) {
    try {
        popupOpen(cookieName, "/common/popup.aspx?cSn=" + contentSn, w, h, topPos, leftPos);
    }
    catch (err) {
        alert(err.message);
    }

    return false;
}



// 시작페이지 설정
function setStartPage(ctl, link)
{
    ctl.style.behavior = 'url(#default#homepage)';
    ctl.setHomePage(link);
}

// 영역내의 모든 체크박스에 대하여 선택/해제를 시킨다.
function selectAll(fireControl, regionId)
{
    var selected = fireControl.checked;
    $("#" + regionId + " :checkbox").each(function() { $(this).checked = selected; });
}

/***** prototype *****/
String.prototype.trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
}
String.prototype.getBytes = function()
{
    var str = this;
    var l = 0;
    for( var i = 0; i < str.length; i++ ) 
	{
		if( str.charCodeAt( i ) == 13 ) continue;
		l += ( str.charCodeAt( i ) > 128 ) ? 2 : 1;
	}
    return l;
}
String.prototype.replaceAll = function(str1, str2)
{
  var temp_str = "";
  if (this.trim() != "" && str1 != str2)
  {
    temp_str = this.trim();

    while (temp_str.indexOf(str1) > -1)
    {
      temp_str = temp_str.replace(str1, str2);
    }
  }

  return temp_str;
}

/***** 새창띄우기 *****/
function openWindow(mode, url, options)
{
    var settings = $.extend(
    {
        windowName: null,
        top: null,
        left: null,
        width:100,
        height:100,
        toolbar: 0,
        scrollbar:1,
        menubar: 0,
        resiable:0
        
    }, options || {});

    if (mode == 'fixed')
    {
        settings.toolbar = 0;
        settings.scrollbar = 0;
        settings.menubar = 0;
        settings.resiable = 0;
    }
    else if (mode == "scroll")
    {
        settings.toolbar = 0;
        settings.scrollbar = 1;
        settings.menubar = 0;
        settings.resiable = 0;
    }
    else if (mode == "standard")
    {
        settings.toolbar = 0;
        settings.scrollbar = 1;
        settings.menubar = 0;
        settings.resiable = 1;
    }
    else if (mode == "full")
    {
    }
    else if (mode == "center")
    {
    }

    var optionString = "toolbar=" + settings.toolbar;
    optionString += ",scrollbars=" + settings.scrollbar;
    optionString += ",menubar=" + settings.menubar;
    optionString += ",resizable=" + settings.resizable;
    optionString += ",width=" + settings.width;
    optionString += ",height=" + settings.height;
    if (settings.top != null)
        optionString += ",top=" + settings.top;
    if (settings.left != null)
        optionString += ",left=" + settings.left;

    window.open(url, settings.windowName, optionString) 
}

/****** 쿠키관련 ******/
function getCookie(name) 
{ 
    var found = false; 
    var start, end; 
    var i = 0; 
    var foundString;
    // cookie 문자열 전체를 검색 
    while(i <= document.cookie.length) 
    { 
        start = i 
        end = start + name.length 
        // name과 동일한 문자가 있다면 
        foundString = document.cookie.substring(start, end);
        if(foundString == name) 
        {
            found = true;
            break;
        } 
        i++;
    } 
    
    // name 문자열을 cookie에서 찾았다면 
    if(found == true) 
    { 
        start = end + 1 
        end = document.cookie.indexOf(";", start) 
        
        // 마지막 부분이라 는 것을 의미(마지막에는 ";"가 없다) 
        if(end < start) 
            end = document.cookie.length;
        // name에 해당하는 value값을 추출하여 리턴한다. 
        foundString = unescape(document.cookie.substring(start, end));
       
        return foundString;
    } 
    
    // 찾지 못했다면 
    return "";
} 
// 쿠키설정
function setCookie( name, value, expiredays ) 
{ 
    var todayDate = new Date(); 
    todayDate.setDate( todayDate.getDate() + expiredays ); 
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 
//쿠키 소멸 함수
function clearCookie(name) 
{
    var expire_date = new Date();
    
    //어제 날짜를 쿠키 소멸 날짜로 설정한다.
    expire_date.setDate(expire_date.getDate() - 1)
    
    document.cookie = name + "= " + "; expires=" + expire_date.toGMTString() + "; path=/"
}
// 쿠키찾기
function findCookie(name)
{
    if( getCookie(name) == "" )
        return false;
        
    return true;
}



/****** Embed *****/
// flash
function loadFlash(src, options)
{
    var settings = $.extend(
        {
            id: "",
            width: 100,
            height: 100,
            wmode: "opaque",
            bgColor: null,
            flashvars: ""
        }, options || {});

    var tags = 
    "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" " +
    " id=\"" + settings.id + "\" width=\"" + settings.width + "\" height=\"" + settings.height + "\" VIEWASTEXT>" +
    "<param name=\"movie\" value=\"" + src + "\" />" + 
    "<param name=\"quality\" value=\"high\" />" + 
    "<param name=\"menu\" value=\"false\" />" + 
    "<param name=\"wmode\" value=\"" + settings.wmode + "\" />";

    if (settings.flashvars != null) tags += '<param name="FlashVars" value="' + settings.flashvars + '"/>';    
    if( settings.bgColor != null ) tags += "<param name=\"bgcolor\" value=\"" + settings.bgColor + "\" />";

    tags += "<embed id=\"" + settings.id + "\"  src=\"" + src + "\" width=\"" + settings.width + "\" height=\"" + settings.height + "\" align=\"middle\" quality=\"high\" ";
    if (settings.bgColor != null) tags += "bgcolor=\"" + settings.bgColor + "\" ";
    if (settings.flashvars != null) tags += "flashvars=\"" + settings.flashvars + "\" ";
    tags += "wmode=\"" + settings.wmode + "\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>"
    
    document.write(tags);
}
// movie
function loadMovie(src, options)
{
    var settings = $.extend(
    {
        id: "",
        width: null,
        height: null,
        style: "",
        showControls: true,
        showDisplay:true,
        autoStart:true,
        playCount:1,
        loop:false
    }, options || {});

    var tag = "<object classid=\"clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" " +
    "codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=6,4,5,715\" " +
    "standby=\"loading microsoft windows media player components...\" type=\"application/x-oleobject\" ";
    if( settings.width != null ) tag += "width=\"" + settings.width + "\" ";
    if (settings.height != null) tag += "height=\"" + settings.height + "\" ";
    tag += "style=\"" + settings.style + "\" ";
    tag += "loop=\"" + settings.loop + "\" ";
    tag += "id=\"" + settings.id + "\" ";
    tag += ">";
    
    tag += "<param name=\"filename\" value=\"" + src + "\" />";
    tag += "<param name=\"showcontrols\" value=\"" + settings.showControls + "\" />";
    tag += "<param name=\"showstatusbar\" value=\"" + settings.showStatusBar + "\" />";
    tag += "<param name=\"showdisplay\" value=\"" + settings.showDisply + "\" />";
    tag += "<param name=\"autostart\" value=\"" + settings.autoStart + "\" />";
    tag += "<param name=\"playcount\" value=\"" + settings.playCount + "\" />";
    tag += "<param name=\"enablecontextmenu\" value=\"true\" />";
    tag += "<param name=\"transparentatstart\" value=\"true\" />";
    tag += "<param name=\"animationatstart\" value=\"true\" />";
    tag += "<param name=\"volume\" value=\"-600\" />";
    
    tag += "<embed src=\"" + src;
    if( settings.width != null ) tag += "width=\"" + settings.width + "\" ";
    if (settings.height != null) tag += "height=\"" + settings.height + "\" ";    
     tag += "\" type=\"application/x-mplayer2\" autostart=\"" + settings.autoStart + 
    "\" showstatusbar=\"" + settings.showStatusBar + 
    "\" showcontrols=\"" + settings.showControls + 
    "\" loop=\"" + settings.loop + 
    "\"></embed>";
    tag += "</object>";

    document.write(tag);
}
// MP3 듣기
function loadMP3(src, options)
{
    var settings = $.extend(
        {
            id: "mp3_player",            
            visible: true,
            autoStart: false,
            repeat: false
        }, options || {});

    var hidden = "";
    if (settings.visible == false)
        hidden = " width=0 height=0 ";

    var str = "<EMBED id='" + settings.id + "' invokeURLs='false' " + "SRC='" + src + "' " + hidden + 
        " AUTOSTART='" + settings.autoStart + "' LOOP='" + settings.repeat + "' />";

    document.write(str);
}

/***** Tiny Validator *****/
//registerScript("null", "로그인을 하셔야 합니다.", "history.back();", false);
function registerScript(ctlId, message, scriptCode, isFireLoad)
{
//    if (isFireLoad)
//        postbackAlertTarget = $('#' + ctlId);
//    else
        postbackAlertTarget = document.getElementById(ctlId);  //$('#' + ctlId);
    postbackAlertMessage = message;
    postbackScriptCode = scriptCode;

    if (isFireLoad)
    {
        $(window).load(function()
        {
            alertControl(postbackAlertTarget, postbackAlertMessage);

            if (postbackScriptCode != "")
                eval(postbackScriptCode);
        });
    }
    else
    {
        alertControl(postbackAlertTarget, postbackAlertMessage);

        if (postbackScriptCode != "")
            eval(postbackScriptCode);
    }
}

function alertControl(ctl, message)
{
    if (message != "")
        alert(message);
    if (ctl != null && ctl.type != "hidden" && ctl.style.display != 'none'  ) ctl.focus();

    return false;
}

function checkOtherProcess(isNecessary, value)
{
    return isNecessary || (!isNecessary && value != null && value.length > 0);
}

function enterKeyPressValidate(ctlId, message)
{
    var ctl = $('#' + ctlId).get(0);
    if (((ctl.type == "text" || ctl.type == "password" || ctl.type == "hidden" || ctl.tagName.toLowerCase() == "textarea") && ctl.value.trim().length == 0))
        return alertControl(ctl, message);

    return true;
}

function requiredValidate(ctlId, message)
{
    var ctl = $('#' + ctlId).get(0);
    if (((ctl.type == "text" || ctl.type == "password" || ctl.type == "hidden" || ctl.tagName.toLowerCase() == "textarea") && ctl.value.trim().length == 0) ||
        (ctl.type == "checkbox" && !ctl.checked))
        return alertControl(ctl, message);

    return true;
}


function compareValidate(ctlId1, ctlId2, message, ignoreCase, isNecessary)
{
    try
    {
        var ctl = $('#' + ctlId1);
        var value1 = ctl.val().trim();
        var value2 = $('#' + ctlId2).val().trim();

        if (checkOtherProcess(isNecessary, value1))
        {
            if (ignoreCase)
            {
                value1 = value1.toLowerCase();
                value2 = value2.toLowerCase();
            }

            if (value1.length == 0 || value2 == 0 || value1 != value2)
            {
                return alertControl(ctl.get(0), message);
            }
        }
    } 
    catch (err)
    {
        alert(err.message);
        return false;
    }

    return true;
}

function rangeValidate(ctlId, type, message, min, max, isNecessary)
{
    try
    {
        var ctl = $('#' + ctlId);
        var value = ctl.val();
        var num = 0;

        if (checkOtherProcess(isNecessary, value))
        {
            if (type == "integer" && isInteger(value))
                num = parseInt(value);
            else if (type == "string")
                num = value.length;
            else
                return alertControl(ctl.get(0), message);

            if (value.length == 0 || !isIntegerRange(num, min, max))
            {
                return alertControl(ctl.get(0), message);
            }
        }
    }
    catch (err)
    {
        alert(err.message);
        return false;
    }

    return true;
}

function businessValidate(ctlId, type, message, isNecessary, secondId, thirdId)
{
    try
    {
        var ctl = $('#' + ctlId);
        var value = ctl.val().trim();

        var ctl2 = null;
        var value2 = "";
        if (secondId != null)
        {
            ctl2 = $('#' + secondId);
            value2 = ctl2.val().trim();
        }        

        var ctl3 = null;
        var value3 = "";
        if (thirdId != null)
        {
            ctl3 = $('#' + thirdId);
            value3 = ctl3.val().trim();
        }
    

        if (type == "juminno" && secondId != null)
            value = value + "-" + value2;
        else if (type == "email" && secondId != null)
            value = value + "@" + value2;
        else if (type == "phone" || type == "phone_mobile" || type == "mobile")
        {
            if (secondId != null && thirdId != null)
                value = value + value2 + value3;
            else if (secondId != null)
                value = value + value2;
        }
        else if (type == "zipcode" && secondId != null)
            value = value + "-" + value2;
        

        if (checkOtherProcess(isNecessary, value))
        {
            if (value.length == 0)
                return alertControl(ctl.get(0), message);
            else if (type == "juminno" && !isJuminNo(value))
                return alertControl(ctl.get(0), message);
            else if (type == "email" && !isEmail(value))
                return alertControl(ctl.get(0), message);
            else if (type == "phone" && !isTel(value))
                return alertControl(ctl.get(0), message);
            else if (type == "mobile" && !isMobile(value))
                return alertControl(ctl.get(0), message);
            else if (type == "domain" && !isDomain(value))
                return alertControl(ctl.get(0), message);
            else if (type == "zipcode" && !isZipcode(value))
                return alertControl(ctl.get(0), message);
            else if (type == "phone_mobile" && (!isTel(value) && !isMobile(value)))
                return alertControl(ctl.get(0), message);
            else if (type == "weburl" && !isWebUrl(value))
                return alertControl(ctl.get(0), message);
        }
    }
    catch (err)
    {
        alert(err.message);
        return false;
    }
    
    return true;
}

function validateUserId(ctlId, minLength, maxLength, message)
{
    var ctl = $('#' + ctlId);
    var userId = ctl.val();
    var regex = /^[a-z]{1,}[a-z0-9]*$/gi;
    if (userId.length == 0 || regex.test(userId) == false || userId.length < minLength || userId.length > maxLength)
        return alertControl(ctl.get(0), message);

    return true;
}

function validatePassword(ctlId, minLength, maxLength, message)
{
    var ctl = $('#' + ctlId);
    var password = ctl.val();
    if (password.length == 0 || password.length < 5 || password.length > 15)
        return alertControl(ctl.get(0), message);

    return true;
}

function formatValidate(ctlId, type, message, extension, isNecessary, extensionOther)
{
    try
    {
        var ctl = $('#' + ctlId);
        var value = ctl.val().trim();

        if (checkOtherProcess(isNecessary, value))
        {
            if (value.length == 0)
                return alertControl(ctl.get(0), message);
            else if (type == "hanguel" && !isHangeul(value))
                return alertControl(ctl.get(0), message);
            else if (type == "english_number" && !isEnglishNumber(value))
                return alertControl(ctl.get(0), message);
            else if (type == "english" && !isEnglish(value))
                return alertControl(ctl.get(0), message);
            else if (type == "number" && !isInteger(value))
                return alertControl(ctl.get(0), message);
            else if (type == "file" && !isUploadFormat(value, extension, extensionOther))
                return alertControl(ctl.get(0), message);
            else if (type == "userid" && !isValidUserIdFormat(value))
                return alertControl(ctl.get(0), message);
        }
    }
    catch (err)
    {
        alert(err.message);
        return false;
    }

    return true;
}

function isValidUserIdFormat(text)
{
    var regex = /^[a-z][a-z0-9]{3,15}$/;
    return regex.test(text);
}

function isHangeul(text)
{
    for (i = 0; i < text.length; i++)
    {
        if (!((text.charCodeAt(i) > 0x3130 && text.charCodeAt(i) < 0x318F) ||
            (text.charCodeAt(i) >= 0xAC00 && text.charCodeAt(i) <= 0xD7A3)))
            return false;
    }

    return true;
}

function isEnglishNumber(data)
{
    var regex = /^[A-Za-z]+[0-9]+$/;
    return regex.test(data);
}

function isEnglish(data)
{
    var regex = /^[A-Za-z]+$/;
    return regex.test(data);
}

function isIntegerRange(intValue, min, max)
{
    if (isInteger(intValue) == false) return false;

    if (min != null && max != null)
        return (intValue >= min && intValue <= max);
    else if (min != null)
        return intValue >= min;
    else if (max != null)
        return intValue <= max;

    return true;
}

function isInteger(data)
{
    var integerRegex = /^\d+$/;
    return integerRegex.test(data);
}

function isZipcode(zipCode)
{
    var zipCodeRegex = /^\d{3}-?\d{3}$/;

    return zipCodeRegex.test(zipCode);
}


function isMobile(mobile)
{
    var mobileRegex = /^0(?:10|11|16|17|18|19)-?(?:\d{3}|\d{4})-?\d{4}$/;

    return mobileRegex.test(mobile);
}

function isTel(tel)
{
    var telRegex = /^((0(?:2|31|32|33|41|42|43|51|52|53|54|55|61|62|63|64|70))-?([0-9]{3,4})-?([0-9]{4}))|(([0-9]{4})-?([0-9]{4}))$/;
    ///^(0(?:2|31|32|33|41|42|43|51|52|53|54|55|61|62|63|64|70))-?([0-9]{3,4})-?([0-9]{4})$/;

    return telRegex.test(tel);
}

function isJuminNo(juminNo)
{
    juminNo = juminNo.trim().replace(/-/gi, "").trim();

    if (juminNo.length != 13) return false;

    var jumin1 = juminNo.substring(0, 6);
    var jumin2 = juminNo.substring(6);

    if (!isInteger(jumin1) || !isInteger(jumin2)) return false;

    var chk = 0;
    var nYear = jumin1.substring(0, 2);
    var nMondth = jumin1.substring(2, 4);
    var nDay = jumin1.substring(4, 6);
    var nSex = jumin2.charAt(0);

    if (jumin1.length != 6 || nMondth < 1 || nMondth > 12 || nDay < 1 || nDay > 31)
    {
        return false;
    }

    if (jumin2.length != 7 || (nSex != 1 && nSex != 2 && nSex != 3 && nSex != 4 && nSex != 5 && nSex != 6 && nSex != 7 && nSex != 8))
    {
        return false;
    }

    if (nSex == 5 || nSex == 6 || nSex == 7 || nSex == 8)
    {
        var sum = 0;
        var odd = 0;
        var PID = jumin1 + jumin2;
        buf = new Array(13);
        for (i = 0; i < 13; i++) buf[i] = parseInt(PID.charAt(i));
        odd = buf[7] * 10 + buf[8];
        if (odd % 2 != 0) return false;
        multipliers = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
        for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

        sum = 11 - (sum % 11);
        if (sum >= 10) sum -= 10;
        sum += 2;
        if (sum >= 10) sum -= 10;
        if (sum != buf[12]) return false;
    }
    else
    {
        var i;
        for (i = 0; i < 6; i++)
        {
            chk += ((i + 2) * parseInt(jumin1.charAt(i)));
        }

        for (i = 6; i < 12; i++)
        {
            chk += ((i % 8 + 2) * parseInt(jumin2.charAt(i - 6)));
        }

        chk = 11 - (chk % 11);
        chk %= 10;
        if (chk != parseInt(jumin2.charAt(6)))
        {
            return false;
        }
    }

    return true;
}


function isEmail(email)
{
    var mailRegex = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

    return mailRegex.test(email);
}

function isWebUrl(url)
{
    var urlRegex = /http(s)?:\/\/\S+(\.[^(\n|\t|\s|\/))]+)+/gi;

    return urlRegex.test(url);
}

function isDomain(domain)
{
    var domainRegex = /.com|.net|.org|.kr|.mobi|.in|.eu|.co.kr|.biz|.info|.ac|.tw|.tv|.cc|.cn|.com.cn|.jp|.pe.kr|.or.kr|.go.kr|.kr$/i;

    return domainRegex.test(domain);
}

/* formatString : .gif|.aspx|.js| */
function isUploadFormat(filename, extension, extensionOther)
{
    var fileRegex = eval("/" + extension + "/");

    if (fileRegex.test(filename) == false)
    {
        if (extensionOther != null)
        {
            fileRegex = eval("/" + extension + "$/");
            return fileRegex.test(filename);
        }
    }

    return true;
}


function enterKeyPress(fireControlID, ctlID, msg)
{
    $('#' + ctlID).keypress(function(event)
    {
        if (event.keyCode == 13)
        {
            if (requiredValidate(ctlID, msg))
            {
                var ctl = $('#' + fireControlID);
                var tagName = ctl.get(0).tagName.toLowerCase();
                if (tagName == "a")
                {
                    var func = $(ctl).attr("href").replace("javascript:", "");
                    eval(func);
                }
                else if (tagName == "input")
                    $('#' + fireControlID).click();

                return true;
            }
            else
                return false;
        }

        return true;
    });
}




/***** */
function get_body_scroll()
{
    var x, y;
    if (self.pageYOffset)
    {
        x = self.pageXOffset;
        y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
    {
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    else if (document.body)
    {
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    }
    var result = new Object;
    result.left = x;
    result.top = y;
    return result;
}


function get_body_inner_size()
{
    var result = new Object;
    if (self.innerWidth)
    {
        result.width = self.innerWidth;
        result.height = self.innerHeight;
        return result;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
        result.width = document.documentElement.clientWidth;
        result.height = document.documentElement.clientHeight;
        return result;
    }
    else if (document.body)
    {
        result.width = document.body.clientWidth;
        result.height = document.body.clientHeight;
        return result;
    }
}

/* 
(left, top)      (right, top)
*----------------*
|                |
|                |
*----------------*
(left, bottom)   (left, bottom) 
*/
var Region =
{
    getLeft: function(element)
    {
        var x = 0;
        do
        {
            if (element.style.position == 'absolute')
            {
                return x + element.offsetLeft;
            }
            else
            {
                x += element.offsetLeft;
                if (element.offsetParent)
                    if (element.offsetParent.tagName == 'TABLE')
                    if (parseInt(element.offsetParent.border) > 0)
                {
                    x += 1;
                }
            }
        }
        while ((element = element.offsetParent));
        return x;
    },

    getTop: function(element)
    {
        var y = 0;
        do
        {
            if (element.style.position == 'absolute')
            {
                return y + element.offsetTop;
            }
            else
            {
                y += element.offsetTop - element.scrollTop;
                if (element.offsetParent)
                    if (element.offsetParent.tagName == 'TABLE')
                    if (parseInt(element.offsetParent.border) > 0)
                {
                    y += 1;
                }
            }
        }
        while ((element = element.offsetParent));
        return y;
    },

    getRight: function(element)
    {
        return this.getLeft(element) + element.offsetWidth;
    },

    getBottom: function(element)
    {
        return this.getTop(element) + element.offsetHeight;
    }
}

/* 퀵메뉴
******************************************************************/
function quickMoving(ele, interval) {
    this.element = ele;
    this.defaultTop = parseInt($(ele).css('top').replace('px', ''));
    this.interval = interval;

    var local = this;
    this.move = function () {
        $(local.element).stop().animate({ top: ($(this).scrollTop() + local.defaultTop) + 'px' }, local.interval);
    };

    $(window).load(this.move).resize(this.move).scroll(this.move);
}
