﻿var browser = navigator.userAgent.toLowerCase();
var BROWSER_TYPE = '';
var _WIDTH = '';
var _HEIGHT = '';

if (browser.indexOf('msie') != -1) {
    BROWSER_TYPE = 'E';
}
if (browser.indexOf('chrome') != -1) {
    BROWSER_TYPE = 'C';
}
if (browser.indexOf('firefox') != -1) {
    BROWSER_TYPE = 'F';
}
if (browser.indexOf('opera') != -1) {
    BROWSER_TYPE = 'O';
}

//두 날짜의 차이를 계산한다.
function calDate(toDate, fromDate) {

    if (toDate == null || toDate == "")
        return 0;
    if (fromDate = null || fromDate == "")
        return 0;

    toDate = toDate.replace(/[\D]/g, "");
    fromDate = fromDate.replace(/[\D]/g, "");

    var to = new Date(toDate.substring(0, 4), toDate.substring(4, 6), toDate.substring(6));
    var from = new Date(fromDate.substring(0, 4), fromDate.substring(4, 6), fromDate.substring(6));

    return (to - from) / (24 * 60 * 60 * 1000);

}

//ie6.0에서 png 투명 처리
function setPng24(obj) {
    obj.width = obj.height = 1;
    obj.className = obj.className.replace(/\bpng24\b/i, '');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "',sizingMethod='image');"
    obj.src = '';
    return '';
}



function openWinPop(url, id, width, height, x, y, scrollChk) {

    x += parent.window.screenLeft;
    y += parent.window.screenTop;

    var settings = "scrollbars=" + scrollChk + ",toolbar=no,location=no,directories=no,width=" + width + ",height=" + height + ",resizable=no,mebar=no,left=" + x + ",top=" + y;

    window.open(url, id, settings);
}


function DisplayMenu(index) {
        for (i = 1; i <= 4; i++)
            if (index == i) {
            thisMenu = eval("menu" + index + ".style");
            thisMenu.display = "";
        }
        else {
            otherMenu = eval("menu" + i + ".style");
            otherMenu.display = "none";
        }
    }


    function DisplaySubMenu(num , index) {
        for (i = 1; i <= 4; i++)
            if (index == i) {
            thisMenu = eval("subMenu" + num + "_" + index + ".style");
            thisMenu.display = "";
        }
        else {
            otherMenu = eval("subMenu" + num + "_"  + i + ".style");
            otherMenu.display = "none";
        }
    }

    


    function goprint() {
        window.onbeforeprint = hideDivs;
        window.onafterprint = showDivs;
        window.print();
    }
    
    function hideDivs() {
        document.getElementById("print_area").innerHTML = document.getElementById("area").outerHTML;
        document.getElementById("no_area").style.display = "none";
    }
    function showDivs() {
        document.getElementById("no_area").style.display = "block";
        document.getElementById("print_area").innerHTML = "";
    }


    function centerPopupSetting(url, width, height) {

        var LeftPosition = (screen.width) ? (screen.width - width) / 2 : 100;

        var TopPosition = (screen.height) ? (screen.height - height) / 2 : 100;

        //var settings = "dialogWidth: " + width + "; dialogHeight: " + height + "; center:yes";
        var settings = "dialogLeft:" + LeftPosition + "px; dialogTop:" + TopPosition + "px; dialogWidth: " + width + "px; dialogHeight: " + height + "px; center:no";
        var settings1 = "scrollbars=no,toolbar=no,location=no,directories=no,width=" + width + ",height=" + height + ",resizable=no,mebar=no,left=" + LeftPosition + ",top=" + TopPosition;

        //window.showModalDialog(url, self, settings);
        window.open(url, 'popup', settings1);

        //document.location = "/common/xml/createleftmenu.aspx";
    }

    function centerSPopupSetting(url, width, height) {

        var LeftPosition = (screen.width) ? (screen.width - width) / 2 : 100;

        var TopPosition = (screen.height) ? (screen.height - height) / 2 : 100;

        //var settings = "dialogWidth: " + width + "; dialogHeight: " + height + "; center:yes";
        var settings = "dialogLeft:" + LeftPosition + "px; dialogTop:" + TopPosition + "px; dialogWidth: " + width + "px; dialogHeight: " + height + "px; center:no";
        var settings1 = "scrollbars=yes,toolbar=no,location=no,directories=no,width=" + width + ",height=" + height + ",resizable=no,mebar=no,left=" + LeftPosition + ",top=" + TopPosition;

        //window.showModalDialog(url, self, settings);
        window.open(url, 'popup', settings1);

        //document.location = "/common/xml/createleftmenu.aspx";
    }

    function FnPopup(url) {
        var nHeight = screen.availHeight;
        var nWin = window.open(url, "_TEAMS_TYPE1_", "width=800, height=" + nHeight + ",status=yes, toolbar=no, menubar=no, location=no, titlebar=no, resizable=no, scrollbars=yes");
        if (nWin != null)
            nWin.focus();
       // return nWin;
    }


    function openMenuPopup(url, width, height, scrollChk) {

        var LeftPosition = (screen.width) ? (screen.width - width) / 2 : 100;

        var TopPosition = (screen.height) ? (screen.height - height) / 2 : 100;

        var settings = "scrollbars=" + scrollChk  + ",toolbar=no,location=no,directories=no,width=" + width + ",height=" + height + ",resizable=no,mebar=no,left=" + LeftPosition + ",top=" + TopPosition;

        window.open(url, 'menu', settings);
    }


    var initBody;
    
    function beforePrint() {
        initBody = document.body.innerHTML;
        document.body.style.backgroundImage = 'none';
        document.body.style.textAlign = 'left';
        document.body.innerHTML = print_page.innerHTML;
    }

    function afterPrint() {
        document.body.style.backgroundImage = 'url(/img/new/top_bg.gif)';
        document.body.style.backgroundRepeat = 'repeat-x';
        document.body.style.textAlign = 'center';
        document.body.innerHTML = initBody;
        
    }

    function pageprint() {
        window.onbeforeprint = beforePrint;
        window.onafterprint = afterPrint;
        window.print();
    }


    function flashAreaSet(getSize) {
        $("#FlashID1").css("height", getSize + "px");
    }

    function flashAreaSet2(getSize) {
        $("#leftFlash").css("width", getSize + "px");
    }

