var xmlDoc = new ActiveXObject("Msxml.DOMDocument");

xmlDoc.load("/AD/contentBannerResource.xml");

// IEÀÎÁö ¾Æ´ÑÁö¸¦ ÆÇ´ÜÇÕ´Ï´Ù.
var isNotIE = (navigator.appName.indexOf("Netscape") != -1);

// ÄÁÆ®·ÑÀÇ Client¸¦ ÀúÀåÇÕ´Ï´Ù.
var clientIDList = new Array();

// ÇØ´ç Ã¢ Å©±âÀÇ Á¤ Áß¾Ó ÁÂÇ¥¸¦ °¡Áö°í ¿É´Ï´Ù.
function Global_Width(popupWindowWidth) {
    return (document.body.clientWidth / 2) - (popupWindowWidth / 2);
}

function Global_Height(popupWindowHeight) {
    return (document.body.clientHeight / 2) - (popupWindowHeight / 2);
}

// Ã¢À» Áß¾Ó/ÀÌº¥Æ® ¹ß»ý À§Ä¡ÇÏµµ·Ï ¿±´Ï´Ù.
function Global_WindowCenterOpen(url, name, width, height, enableScroll, isCenter) {
    var properties = "width=" + width;
    properties += ", height=" + height;

    if (isCenter) {
        properties += ", left=" + Global_Width(width);
        properties += ", top=" + Global_Height(height);
    }
    else {
        properties += ", left=" + (window.event.clientX + 10);
        properties += ", top=" + (window.event.clientY + height);
    }

    if (enableScroll)
        properties += ", scrollbars=1";


    var popWindow = window.open(url, name, properties);
}


function Global_GetClinicOpen(url, name, width, height, enableScroll, isCenter, items) {

    var item_value = document.getElementById(items).value;
    var seturl = url + "?ControlName=" + item_value;
    if (item_value != "") {


        var properties = "width=" + width;
        properties += ", height=" + height;

        if (isCenter) {
            properties += ", left=" + Global_Width(width);
            properties += ", top=" + Global_Height(height);
        }
        else {
            properties += ", left=" + (window.event.clientX + 10);
            properties += ", top=" + (window.event.clientY + height);
        }

        if (enableScroll) {
            properties += ", scrollbars=1";
        }

        var popWindow = window.open(seturl, name, properties);
    }
    else {
        alert("Áø·á°ú¸¦ ¸ÕÀú ¼±ÅÃÇÏ¿©ÁÖ¼¼¿ä");
    }
}

function Global_OpenMovie(srno, moduleID) {
    window.open('/Library/Modules/Movie/MovieViewer.aspx?srno=' + srno + '&moduleID=' + moduleID, 'movie', 'left=20, top=20, width=607,height=650,scrollbars=1');
}

function Global_ViewMovie(fileName) {
    var thisWin = window.open("/Library/Modules/Movie/Player.aspx?fileName=" + fileName, 'ViewMovie', 'width=567,height=305');
    if (thisWin == null)
        alert("ÆË¾÷Â÷´ÜÀ» ÇØÁ¦ÇØ ÁÖ½Ê½Ã¿À.");
}

function Global_HospitalSearchPop(fileName) {
    var thisWin = window.open("/HospitalSearch/" + fileName, 'HospitalSearch', 'width=650,height=500');

}

function Global_Search() {
    try {
        var searchKey = document.getElementById("searchKey");
        var searchKeyWord = document.getElementById("searchKeyWord");

        if (searchKey != null && searchKeyWord != null) {
            if (Global_TrimSpaces(searchKeyWord.value) != "") {
                location.href = "http://www.hidoc.co.kr/Search/Search.aspx?searchKey=" + searchKey.value + "&searchKeyWord=" + searchKeyWord.value;
            }
            else {
                alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
                searchKeyWord.focus();
                return false;
            }
        }
        else {
            alert("ÄÜÆ®·ÑÀÌ ¾ø½À´Ï´Ù.");
            return false;
        }
    }
    catch (error) {
        alert(error.description);
        return false;
    }
}
function Movie_Search() {
    try {

        //var searchKey = document.getElementById("moviesearchKey");
        var searchKeyWord = document.getElementById("ctl00_mainContentPlaceHolder_MovieSearch1_movieSearchKeyWord");
        var checkvalue = "";

        for (i = 0; i < 3; i++) {
            if (document.all["ctl00_mainContentPlaceHolder_MovieSearch1_movieSearchKey_" + i].checked) {
                checkvalue = document.all["ctl00_mainContentPlaceHolder_MovieSearch1_movieSearchKey_" + i].value;
            }
        }

        // alert(checkvalue);
        // alert(searchKeyWord);
        if (checkvalue != null && searchKeyWord != null) {
            if (Global_TrimSpaces(searchKeyWord.value) != "") {
                location.href = "http://www.hidoc.co.kr/Search/MovieSearch.aspx?searchKey=" + checkvalue + "&searchKeyWord=" + searchKeyWord.value;
            }
            else {
                alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
                searchKeyWord.focus();
                return false;
            }
        }
        else {
            alert("ÄÜÆ®·ÑÀÌ ¾ø½À´Ï´Ù.");
            return false;
        }
    }
    catch (error) {
        alert(error.description);
        return false;
    }
}
function Global_SetCookie(name, value, expiredays) {
    var todayDate = new Date();
    todayDate.setDate(todayDate.getDate() + expiredays);
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function Global_ResizeImage(areaID, maxWidth) {
    var contentObject = document.getElementById(areaID);

    Global_FindImgObject(contentObject, maxWidth);
}

function Global_FindImgObject(parentsObject, maxWidth) {
    for (var i = 0; i < parentsObject.children.length; i++) {
        if (parentsObject.children[i].tagName == "IMG") {
            var img = parentsObject.children[i];

            var width = img.width;
            var height = img.height;

            if (width > maxWidth) {
                img.sourceWidth = img.width;
                img.sourceHeight = img.height;

                img.width = maxWidth;
                img.height = (maxWidth * height) / width;
                img.title = "Å¬¸¯ÇÏ½Ã¸é ¿øº» ÀÌ¹ÌÁö¸¦ º¸½Ç ¼ö ÀÖ½À´Ï´Ù.";
                img.style.cursor = "hand";
                img.attachEvent('onclick', OnResizedImageClick);
            }
        }
        else if (parentsObject.children[i].children.length > 0) {
            Global_FindImgObject(parentsObject.children[i], maxWidth);
        }
    }
}

function OnResizedImageClick() {
    var sourceObject = event.srcElement;

    var width = sourceObject.sourceWidth;
    var height = sourceObject.sourceHeight;

    var screenX = (event.clientX) - (width / 2);
    var screenY = (event.clientY) + (height / 2) - 100;

    var resizedImagePopUp = window.open('', 'resizedImage', 'top=' + screenY + ',left=' + screenX + ',width=' + width + ',height=' + height);

    resizedImagePopUp.document.write("<html>");
    resizedImagePopUp.document.write("<title>ÀÌ¹ÌÁö ¿øº»</title>");
    resizedImagePopUp.document.write("<body style='margin:0px'>");
    resizedImagePopUp.document.write("<img src='" + sourceObject.src + "' onclick='self.close();' title='Å¬¸¯ÇÏ¸é Ã¢À» ´Ý½À´Ï´Ù.' style='cursor:hand'>");
    resizedImagePopUp.document.write("</body>");
    resizedImagePopUp.document.write("</html>");
}

// ÁöÁ¤µÈ ÄÁÆ®·Ñ¿¡ Click()ÀÌº¥Æ®¸¦ ¹ß»ýÇÕ´Ï´Ù.
function Global_RaiseClickEvent(controlName) {
    var temp = FindObject(controlName);

    if (temp != null) {
        temp.click();
    }
}

// ¸Þ½ÃÁö ¹Ú½º¸¦ ¿±´Ï´Ù.
function Global_ShowMessageBox() {
    try {
        // ¸Þ½ÃÁö ÆÄÀÏÀ» ¸¸µé·Á¸é °øÅëÆÄÀÏ¿¡ ÇØ´ç °´Ã¼¸¦ ³Ö¾î¾ß ÇÕ´Ï´Ù.
        if (document.getElementById("paggingMessageBox") != null) {
            var message = document.getElementById("paggingMessageBox");

            message.style.setExpression("posLeft", (document.body.clientWidth - 400) / 2);
            message.style.setExpression("posTop", ((document.body.scrollHeight - 100) / 2) - 100);

            document.getElementById("paggingMessageBox").style.display = "block";
        }
    }
    catch (error) {
        alert(error.description);
        return false;
    }
}

// 28±Ý¿¬µ¿¿µ»óÀ» ¿±´Ï´Ù.
function Global_NosmokingViewMovie(days) {
    window.open('http://www.hidoc.co.kr/hidoc/NoSmokeView.aspx?day=' + days, 'nosmoke', 'top=20,left=20,width=617,height=650,scrollbars=1');
}

// ´Þ·ÂÀ» ºÒ·¯¿É´Ï´Ù.
function Global_ViewCalender(controlName) {
    var result = showModalDialog('/Library/Modules/calendar.htm', window, "scroll:no; status:no; dialogLeft:100px; dialogTop:100px; dialogWidth:310px; dialogHeight:350px;");

    if (result != null || result == "") {
        FindObject(controlName).value = result;
    }
}

// Å×ÀÌºíÀ» ¼û±â°í ³ªÅ¸³À´Ï´Ù.
// Å×ÀÌºíÀÇ ¾ÆÀÌµð´Â ¼øÂ÷ÀûÀ¸·Î contentTable1~µÇ¾î¾ß ÇÏ¸ç Global_ViewContent()¿Í °°ÀÌ È£ÃâÇÕ´Ï´Ù.
// ÀÌ¹ÌÁö¸íÀº ¹Ýµå½Ã _off.gif, _on.gif·Î ³¡³ª¾ß ÇÏ¸ç id´Â contentImage1~·Î µÇ¾î¾ß ÇÕ´Ï´Ù.
function Global_ViewContent() {
    try {
        var thisObject = window.event.srcElement;

        if (thisObject.id == "") {
            alert("ÇØ´ç IMG¿¡ id°¡ ¾ø½À´Ï´Ù.");
            return false;
        }

        var index = thisObject.id.replace("contentImage", "");

        for (var i = 0; i < document.all.length; i++) {
            if (document.all[i].id.indexOf("contentTable") >= 0) {
                document.all[i].style.display = "none";
            }

            if (document.all[i].id.indexOf("contentImage") >= 0) {
                document.all[i].src = document.all[i].src.replace("_on.gif", "_off.gif");
            }
        }

        document.getElementById("contentTable" + index).style.display = "block";

        // ÇØ´ç ÀÌ¹ÌÁö º¯°æ
        thisObject.src = thisObject.src.replace("_off.gif", "_on.gif");
    }
    catch (exception) {
        alert(exception.description);
        return false;
    }

}


// ÀÌ¸ÞÀÏÀÇ Çü½ÄÀ» Ã¼Å©ÇÕ´Ï´Ù. -------------------------------------------------------------------------------------
function Global_EmailCheck(emailValue) {
    if (emailValue != "") {
        if (Global_TrimSpaces(emailValue) != "") {
            var chkEmail = emailValue.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);

            if (chkEmail == null) {
                alert("¸ÞÀÏ ÁÖ¼ÒÀÇ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}

// Select Ç×¸ñÀ» Á¶Á¤ÇÕ´Ï´Ù. ----------------------------------------------------------------------------------------

//Ç×¸ñÀ» Ãß°¡ÇÕ´Ï´Ù.
function Global_AddOption(theForm, text, value) {
    var newOpt = document.createElement("OPTION");
    newOpt.text = text;
    newOpt.value = value;
    theForm.add(newOpt);
}

// Ç×¸ñÀ» Á¦°Å ÇÕ´Ï´Ù.
function Global_ReMoveOption(theForm, selectedIndex) {
    var selLength = theForm.length;

    if (selLength > 0) {
        theForm.remove(selectedIndex);
    }
}

// ÄíÅ°¿¡ ÀÔ·ÂµÈ °ªÀ» °¡Áö°í ¿É´Ï´Ù. --------------------------------------------------------------------------------

function Global_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 "";
}

// ÄÁÆ®·ÑÀ» Ã£½À´Ï´Ù. ----------------------------------------------------------------------------------------------
function FindObject(objectName) {
    
    var tempObjectName = objectName;
    // °Ë»ç´ë»ó ÄÁÆ®·ÑÀ» Ã£½À´Ï´Ù.
    // Á¤ÀÇµÈ clientID¸®½ºÆ®¸¦ µ½´Ï´Ù.
    if (clientIDList != null) {
        for (var i = 0; i < clientIDList.length; i++) {
            // °´Ã¼°¡ ÀÖ´Ù.
            if (document.getElementById(clientIDList[i] + "_" + objectName) != null) {
                // ¾ÆÁ÷ ÄÁÆ®·ÑÀÇ ÀÌ¸§ÀÌ ¼³Á¤µÇÁö ¾Ê¾Ò´Ù¸é
                if (tempObjectName == objectName) {
                    // ÀÌ¸§À» ¼³Á¤
                    tempObjectName = clientIDList[i] + "_" + objectName;
                }
            }
        }
    }

    if (document.getElementById(tempObjectName) != null) {
        return document.getElementById(tempObjectName);
    }
    else {
        return null;
    }
}

// Javascript·Î QueryString ±¸ÇÏ±â ---------------------------------------------------------------------------------------------
function Global_Request(valuename) {
    var rtnval = "";
    var nowAddress = unescape(location.href);
    var parameters = (nowAddress.slice(nowAddress.indexOf("?") + 1, nowAddress.length)).split("&");

    for (var i = 0; i < parameters.length; i++) {
        var varName = parameters[i].split("=")[0];
        if (varName.toUpperCase() == valuename.toUpperCase()) {
            rtnval = parameters[i].split("=")[1];
            break;
        }
    }

    return rtnval;
}

// ÇÊ¿äÇÑ ÀÌ¹ÌÁö¸¦ ¹Ì¸® ·Îµå ÇÕ´Ï´Ù. -------------------------------------------------------------------------------------------

function Global_PreloadImage() {
    var img_list = Global_PreloadImage.arguments;
    if (document.preloadlist == null)
        document.preloadlist = new Array();
    var top = document.preloadlist.length;
    for (var i = 0; i < img_list.length; i++) {
        document.preloadlist[top + i] = new Image;
        document.preloadlist[top + i].src = img_list[i + 1];
    }
}

// µÎ°³ÀÇ ÄÁÆ®·ÑÀÇ °ªÀ» ºñ±³ÇØ¼­ °°ÀºÁö¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù. --------------------------------------------------------------------------

function Globl_ControlToControlValueCheck(sourceControlName, targetControlName, message) {
    var sourceControl = FindObject(sourceControlName);
    var targetControl = FindObject(targetControlName);

    if (sourceControl == null || targetControl == null) {
        alert("ÇÑ°³ÀÇ ÀÌ»óÀÇ ÄÁÆ®·ÑÀÌ ¾ø½À´Ï´Ù.");
        return false;
    }
    else {
        if (Global_TrimSpaces(sourceControl.value) != Global_TrimSpaces(targetControl.value)) {
            alert(message);
            return false;
        }
        else {
            return true;
        }

    }
}

// ÇØ´ç ÅØ½ºÆ® ÄÁÆ®·ÑÀÌ °ø¹éÀÎÁö¸¦ °Ë»ç  ---------------------------------------------------------------------------------------
function Global_ControlValueCheck(controlName, message, enableBadWordCheck) {

    var control = FindObject(controlName);

    if (control != null) {
        if (Global_TrimSpaces(control.value) == '') {
            alert(message);
            control.value = '';
            control.focus();
            return false;
        }
        else {
            if (enableBadWordCheck) {
                // ºÒ·®´Ü¾î ÇÊÅÍ¸µÀÌ °É¸±°æ¿ì ºÒ·®´Ü¾î¸¦ °Ë»ç
                return Global_ChkeckBadWord(control);
            }
            else {
                return true;
            }
        }
    }
    else {
        return true;
    }
}

// ÇØ´ç ¹®ÀÚ¿­ÀÇ ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç ----------------------------------------------------------------------------------------------------
function Global_RRNCheck(controlName) {
    var control = FindObject(controlName);
    var con = Global_TrimSpaces(control.value);
    var reg = /[\d]{6}[\s-]*?[\d]{7}/;

    if (control != null) {
        if (con.match(reg) != null) {
            var progressTrue;
            progressTrue = confirm("»ó´ã³»¿ë¿¡ ÁÖ¹Î¹øÈ£¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Â °Í °°½À´Ï´Ù.(" + con.match(reg) + ") °ø°³»ó´ã½ÇÀÇ ±ÛÀº Å¸ÀÎÀÌ º¼ ¼ö ÀÖ½À´Ï´Ù. ±×´ë·Î °ø°³»ó´ãÀ» ½ÅÃ» ÇÏ½Ã°Ú½À´Ï±î?");

            if (progressTrue == false) {
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}

// ÇØ´ç ¹®ÀÚ¿­ÀÇ °ø¹éÀ» Á¦°Å ----------------------------------------------------------------------------------------------------
function Global_TrimSpaces(text) {
    var temp = "";

    text = '' + text.toUpperCase();

    splitstring = text.split(" ");

    for (i = 0; i < splitstring.length; i++)

        temp += splitstring[i];

    return temp;
}

// ±ÝÁö´Ü¾î¸¦ °Ë»ç --------------------------------------------------------------------------------------------------------------

// ±ÝÁö´Ü¾î µî·Ï
var BadWords = "°³»õ³¢,¼Ò»õ³¢,º´½Å,Áö¶ö,¾¾ÆÈ,½ÊÆÈ,´Ï±â¹Ì,Âî¶ö,Áö¶ö,½Ö³â,½Ö³ð,ºù½Å,Á¿±î,´Ï±â¹Ì,Á¿°°Àº°Ô,Àâ³ð,º­¾û½Å,¹Ùº¸»õ³¢,¾Ã»õ³¢,¾¾¹ß,¾¾ÆÈ,½Ã¹ú,¾¾¹ú,¶°±×¶ö,Á¿¹ä,ÃßÃµÀÎ,ÃßÃµid,ÃßÃµ¾ÆÀÌµð,ÃßÃµid,ÃßÃµ¾ÆÀÌµð,Ãß/Ãµ/ÀÎ,µî½Å,½Î°¡Áö,¹ÌÄ£³ð,¹ÌÄ£³Ñ,Âî¶ö,Á×½À´Ï´Ù,´Ô¾Æ,´Ôµé¾Æ,¾¾¹ë³Ñ";

function Global_ChkeckBadWord(control) {
    //  ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇÏ±â À§ÇØ¼­´Â ºÒ·® ´Ü¾î º¯¼ö BadWord¸¦ ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù.
    var TempObj = control;

    if (BadWords == null) {
        return;
    }

    var BadText = BadWords.split(",");

    if (BadText == "") {
        return false;
    }

    var swear_words_arr = new Array();

    for (var i = 0; i < BadText.length; i++) {
        swear_words_arr = swear_words_arr.concat(BadText[i]);
    }

    var swear_alert_arr = new Array;
    var swear_alert_count = 0;

    var compare_text = TempObj.value;

    for (var i = 0; i < swear_words_arr.length; i++) {
        for (var j = 0; j < (compare_text.length); j++) {
            if (swear_words_arr[i] == compare_text.substring(j, (j + swear_words_arr[i].length)).toLowerCase()) {
                swear_alert_arr[swear_alert_count] = compare_text.substring(j, (j + swear_words_arr[i].length));
                swear_alert_count++;
            }
        }
    }

    var alert_text = "";

    for (var k = 1; k <= swear_alert_count; k++) {
        alert_text += "\n" + "* " + swear_alert_arr[k - 1];
    }

    if (swear_alert_count > 0) {
        alert("±ÝÁöµÈ ´Ü¾î¸¦ »ç¿ëÇÏ¿´½À´Ï´Ù.\n_______________________________\n" + alert_text + "\n_______________________________");
        return false;
    }
    else {
        return true;
    }
}

// --------------- SSL ÀÎÁõ ----------------
function Global_SendMemberSSLFormNew(SSLUrl) {
    try {
        var newForm = document.createElement("FORM");
        newForm.id = "SSLSenForm";

        var objElements = document.getElementsByTagName('*');
        
        for (var i = 0; i < objElements.length; i++) {
            var obj = objElements[i];

            if (obj.tagName == "INPUT" || obj.tagName == "SELECT") {

                if (obj.type.toUpperCase() != "IMAGE" && obj.id.indexOf("__") < 0) {

                    if (obj.type.toUpperCase() != "CHECKBOX") {
                        var newInput = document.createElement("INPUT");
                        newInput.type = "hidden";
                        if (clientIDList != null) {
                            newInput.name = obj.id.replace(clientIDList[0] + "_", "");                        
                        }
                        else{
                            newInput.name = obj.id;
                        }
                        newInput.value = obj.value;
                        newForm.appendChild(newInput);                        
                    }
                    else if (obj.checked) {
                        var newInput = document.createElement("INPUT");
                        newInput.type = "hidden";
                        if (clientIDList != null) {
                            newInput.name = obj.id.replace(clientIDList[0] + "_", "");                        
                        }
                        else {
                            newInput.name = obj.id;
                        }
                        newInput.value = "Y";
                        newForm.appendChild(newInput);
                    }
                }
            }

        }
        document.body.appendChild(newForm);
                
        var lastFormIndex = 1;

        if (document.forms.length == 1)
            lastFormIndex = 0;


        // µ¹¾Æ¿Ã ÆäÀÌÁö ¼³Á¤ ----------------------------------------------------------------------

        var newObj = document.createElement("INPUT");

        newObj.type = "hidden";
        newObj.name = "RedirectURL";

        newObj.value = "http://" + location.host + "/Member/Login.aspx";

        //alert(document.forms[lastFormIndex].id);

        document.forms[lastFormIndex].appendChild(newObj);

        // ------------------------------------------------------------------------------------------

        // ·Î±×ÀÎ ÈÄ µ¹¾Æ°¥ URL ¼³Á¤
        var returnObject = document.createElement("INPUT");

        returnObject.type = "hidden";
        returnObject.name = "ReturnUrl";

        returnObject.value = ReturnUrl;

        document.forms[lastFormIndex].appendChild(returnObject);

        // ------------------------------------------------------------------------------------------

        document.forms[lastFormIndex].action = "https://Login.mcircle.co.kr" + SSLUrl;

        document.forms[lastFormIndex].method = "post";

        document.forms[lastFormIndex].submit();

    }
    catch (exception) {
        alert(exception.description);
    }

    return false;
}

function Global_SendMemberSSLForm(SSLUrl) {
    try {
        var newForm = document.createElement("FORM");
        newForm.id = "SSLSenForm";

        for (var i = 0; i < document.all.length; i++) {
            var obj = document.all[i];

            if (obj.tagName == "INPUT" || obj.tagName == "SELECT") {
                if (obj.type.toUpperCase() != "IMAGE" && obj.id.indexOf("__") < 0) {
                    if (obj.type.toUpperCase() != "CHECKBOX") {
                        var newInput = document.createElement("INPUT");
                        newInput.type = "hidden";
                        newInput.name = obj.id.replace(clientIDList[0] + "_", "");
                        newInput.value = obj.value;
                        newForm.appendChild(newInput);
                    }
                    else if (obj.checked) {
                        var newInput = document.createElement("INPUT");
                        newInput.type = "hidden";
                        newInput.name = obj.id.replace(clientIDList[0] + "_", "");
                        newInput.value = "Y";
                        newForm.appendChild(newInput);
                    }
                }
            }
        }

        document.appendChild(newForm);

        var lastFormIndex = 1;

        if (document.forms.length == 1)
            lastFormIndex = 0;


        // µ¹¾Æ¿Ã ÆäÀÌÁö ¼³Á¤ ----------------------------------------------------------------------

        var newObj = document.createElement("INPUT");

        newObj.type = "hidden";
        newObj.name = "RedirectURL";

        newObj.value = "http://" + location.host + "/Member/Login.aspx";

        //alert(document.forms[lastFormIndex].id);

        document.forms[lastFormIndex].appendChild(newObj);

        // ------------------------------------------------------------------------------------------

        // ·Î±×ÀÎ ÈÄ µ¹¾Æ°¥ URL ¼³Á¤
        var returnObject = document.createElement("INPUT");

        returnObject.type = "hidden";
        returnObject.name = "ReturnUrl";

        returnObject.value = ReturnUrl;

        document.forms[lastFormIndex].appendChild(returnObject);

        // ------------------------------------------------------------------------------------------

        document.forms[lastFormIndex].action = "https://Login.mcircle.co.kr" + SSLUrl;

        document.forms[lastFormIndex].method = "post";

        document.forms[lastFormIndex].submit();

    }
    catch (exception) {
        alert(exception.description);
    }

    return false;
}

function Global_SendSSLForm(SSLUrl, ReturnUrl) {
    try {
        var newForm = document.createElement("FORM");

        for (var i = 0; i < document.all.length; i++) {
            var obj = document.all[i];

            if (obj.tagName == "INPUT" || obj.tagName == "SELECT") {
                if (obj.type.toUpperCase() != "IMAGE" && obj.id.indexOf("__") < 0) {
                    if (obj.type.toUpperCase() != "CHECKBOX") {
                        var newInput = document.createElement("INPUT");
                        newInput.type = "hidden";
                        newInput.name = obj.id.replace(clientIDList[0] + "_", "");
                        newInput.value = obj.value;
                        newForm.appendChild(newInput);
                    }
                    else if (obj.checked) {
                        var newInput = document.createElement("INPUT");
                        newInput.type = "hidden";
                        newInput.name = obj.id.replace(clientIDList[0] + "_", "");
                        newInput.value = "Y";
                        newForm.appendChild(newInput);
                    }
                }
            }
        }

        document.appendChild(newForm);

        var newObj = document.createElement("INPUT");

        newObj.type = "hidden";
        newObj.name = "RedirectURL";

        if (ReturnUrl == "")
            ReturnUrl = location.href;
        else
            ReturnUrl = "http://" + location.host + ReturnUrl;

        newObj.value = ReturnUrl;

        var lastFormIndex = 1;

        document.forms[lastFormIndex].appendChild(newObj);

        document.forms[lastFormIndex].action = "https://Login.mcircle.co.kr" + SSLUrl;

        document.forms[lastFormIndex].method = "post";

        document.forms[lastFormIndex].submit();

    }
    catch (exception) {
        alert(exception.description);
    }

    return false;

}

function Global_SendSSLForm1(SSLUrl, ReturnUrl, ID, Password) {
    try {
        var newForm = document.createElement("FORM");




        var newInput = document.createElement("INPUT");
        newInput.type = "hidden";
        newInput.name = "txtID";
        newInput.value = ID;
        newForm.appendChild(newInput);

        var newInput = document.createElement("INPUT");
        newInput.type = "hidden";
        newInput.name = "txtPassword";
        newInput.value = Password;
        newForm.appendChild(newInput);


        document.appendChild(newForm);

        var newObj = document.createElement("INPUT");

        newObj.type = "hidden";
        newObj.name = "RedirectURL";

        if (ReturnUrl == "")
            ReturnUrl = location.href;
        else
            ReturnUrl = "http://" + location.host + ReturnUrl;

        newObj.value = ReturnUrl;

        var lastFormIndex = 1;

        document.forms[lastFormIndex].appendChild(newObj);

        document.forms[lastFormIndex].action = "https://Login.mcircle.co.kr" + SSLUrl;

        document.forms[lastFormIndex].method = "post";

        document.forms[lastFormIndex].submit();

    }
    catch (exception) {
        alert(exception.description);
    }

    return false;

}

// ÇØ´ç ÅØ½ºÆ® °ª¿¡¼­ È®ÀåÀÚ¸¦ ÃßÃâÇÕ´Ï´Ù.

function Global_GetFileExtension(controlObject) {
    var contolValue = controlObject.value;

    var index = contolValue.lastIndexOf(".");

    if ((Global_TrimSpaces(contolValue) != "") && (contolValue.length != 0)) {
        return contolValue.substring(index + 1).toLowerCase();
    }
    else {
        return '';
    }
}

// ·Î±×ÀÎÃ³¸®
function Global_Login() {

    var returnurl = parent.document.location.href;
    parent.document.location = "http://www.hidoc.co.kr/Member/Login.aspx?returnUrl=" + escape(returnurl);
}

// ·Î±×¾Æ¿ôÃ³¸®
function Global_Logout() {
    var returnurl = parent.document.location.href;
    parent.document.location = "http://www.hidoc.co.kr/Member/Logout.aspx?returnUrl=" + escape(returnurl);
}

// ÅÇÃ³¸®
function Global_TabMenu(controlName, totalnumber, currentnumber) {
    for (i = 0; i <= totalnumber; i++) {
        if (i == currentnumber) {
            document.getElementsByName(controlName)(i).style.display = 'block';
        }
        else {
            document.getElementsByName(controlName)(i).style.display = 'none';
        }
    }
}

// Å¬¸®´Ð ÁöµµÃ£±â
function area_move(sitetype, area) {
    var siteurl;

    if (sitetype == "hidoc") {
        siteurl = "http://www.hidoc.co.kr/Hospital/Hospital01.aspx?SI=" + area;
    }
    else if (sitetype == "beauty") {
        siteurl = "http://beauty.hidoc.co.kr/FamousDoctor/HospitalSearch.aspx?mode=directory&hospitalpart=¼ºÇü¿Ü°ú&si=" + area;
    }
    else if (sitetype == "dm") {
        siteurl = "http://dm.hidoc.co.kr/SearchClinic/SearchClinic02.aspx?HOSPITALPART=³»°ú&si=" + area;
    }

    window.location.href = siteurl;
}

// Window Open
function Global_OpenWindow(JWinName, JOpenedFile, JWidth, JHeight) {
    var x = (screen.width / 2) - (JWidth / 2);
    var y = (screen.height / 2) - (JHeight / 2);
    var NewWin = window.open('', JWinName, 'toolbar=no,resizable=no,scrollbars=yes,status=0,width=' + JWidth + ',height=' + JHeight + ',left=' + x + ',top=' + y);
    NewWin.location = JOpenedFile;
}

function Global_CheckPID(controlName1, controlName2) {
    var NUM = "0123456789";

    var PID1 = FindObject(controlName1).value;
    var PID2 = FindObject(controlName2).value;

    var chk = 0;

    var nYear = PID1.substring(0, 2);

    var nMondth = PID1.substring(2, 4);

    var nDay = PID1.substring(4, 6);

    var nSex = PID2.charAt(0);

    if (!IsValid(PID1, NUM)) {
        alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
        FindObject(controlName1).select();
        return false//-1;
    }

    if (PID1.length != 6 || nMondth < 1 || nMondth > 12 || nDay < 1 || nDay > 31) {
        alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
        FindObject(controlName1).select();
        return false//-1;
    }

    if (!IsValid(PID2, NUM)) {
        alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
        FindObject(controlName1).select();
        return false//1;
    }

    if (PID2.length != 7 || (nSex != 1 && nSex != 2 && nSex != 3 && nSex != 4 && nSex != 5 && nSex != 6 && nSex != 7 && nSex != 8)) {
        alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
        FindObject(controlName1).select();
        return false//1;
    }

    if (nSex == 5 || nSex == 6 || nSex == 7 || nSex == 8) {
        var sum = 0;
        var odd = 0;
        var PID = PID1 + PID2;
        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) {
            alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
            FindObject(controlName1).select();
            return false//-1;
        }

        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]) {
            alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
            FindObject(controlName1).select();
            return false//-1;
        }
    }
    else {
        var i;
        for (i = 0; i < 6; i++) {
            chk += ((i + 2) * parseInt(PID1.charAt(i)));
        }

        for (i = 6; i < 12; i++) {
            chk += ((i % 8 + 2) * parseInt(PID2.charAt(i - 6)));
        }

        chk = 11 - (chk % 11);
        chk %= 10;

        if (chk != parseInt(PID2.charAt(6))) {
            alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
            FindObject(controlName1).select();

            return false//-1;
        }
    }

    return true//0;
}

// ÁÖ¹Îµî·ÏÃ¼Å©ÀÇ ¼­ºê ÇÔ¼ö·Î »ç¿ëµË´Ï´Ù.
function IsValid(s, spc) {
    var i;
    if (s.length < 1) return false;
    for (i = 0; i < s.length; i++) {
        if (spc.indexOf(s.substring(i, i + 1)) < 0) {
            return false;
        }
    }

    return true;
}

function Global_moduleIDPlayer(srno, moduleID) {
    var nowstring = "";
    var nowlocation = location.href;
    if (nowlocation.indexOf("?") > 0) {
        nowstring = "&" + nowlocation.slice(nowlocation.indexOf("?") + 1, nowlocation.length);
    }

    var thisWin = window.location.href = "/MedicalTV/Player.aspx?moduleID=" + moduleID + "&srno=" + srno + nowstring;

}
function Global_Player(srno) {
    var nowstring = "";
    var nowlocation = location.href;
    if (nowlocation.indexOf("?") > 0) {
        nowstring = "&" + nowlocation.slice(nowlocation.indexOf("?") + 1, nowlocation.length);
    }

    var thisWin = window.location.href = "/MedicalTV/Player.aspx?srno=" + srno + nowstring;

}

function Global_Player2(srno, moduleID) {
    var nowstring = "";
    var nowlocation = location.href;
    if (nowlocation.indexOf("?") > 0) {
        nowstring = "&" + nowlocation.slice(nowlocation.indexOf("?") + 1, nowlocation.length);
    }

    var thisWin = window.location.href = "/MedicalTV/Player.aspx?moduleID=" + moduleID + "&srno=" + srno;

}

function Global_SearchHospitalEvent() {
    window.open('/Event/080430/Eventpopup.aspx', 'popup', 'left=20, top=20, width=472,height=419,scrollbars=1');
}


function MovieWrite(moduleID) {
    var nowstring = "";
    var nowlocation = location.href;
    if (nowlocation.indexOf("?") > 0) {
        nowstring = "&" + nowlocation.slice(nowlocation.indexOf("?") + 1, nowlocation.length);
    }

    var thisWin = window.location.href = "/MedicalTV/MedicalWrite.aspx?Moduleid=" + moduleID;

}
function SearchHospital(Url) {
    document.location = "/SearchHospital/HospitalView.aspx?srno=" + Url
}
function CoworkSearchHospital(Url) {
    document.location = "/CoworkSearchHospital/HospitalView.aspx?srno=" + Url
}
function Global_OpenNewsLetter(srno) {
    window.open('/Library/Modules/Newsletter/Newsletter_v.aspx?srno=' + srno, 'popup', 'left=20, top=20, width=725,height=780,scrollbars=1');
}
function Global_OpenDoctorNewsLetter(srno) {
    window.open('/Library/Modules/DoctorNewsletter/DoctorNewsletter_v.aspx?srno=' + srno, 'popup', 'left=20, top=20, width=875,height=850,scrollbars=1');
}

function GlobalDeleteNewsLetter(srno) {
    if (confirm('Á¤¸»·Î »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?')) {

        document.location = "/Library/Modules/Newsletter/Newsletter_d.aspx?srno=" + srno;
    }
}
function SetCommonFlashObject(src, width, Height, loop, quality, wmode, bgcolor, FlashVars) {

    var strflash;

    strflash = "";

    strflash = strflash + "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + width + "' height='" + Height + "' align='middle'>";
    strflash = strflash + "<param name='movie' value='" + src + "'>";
    strflash = strflash + "<param name='loop' value='" + loop + "'>";
    strflash = strflash + "<param name='quality' value='" + quality + "'>";
    strflash = strflash + "<param name='wmode' value='" + wmode + "'>";
    strflash = strflash + "<PARAM NAME='FlashVars' Value='" + FlashVars + "'>";
    strflash = strflash + "<embed src='" + src + "' loop='" + loop + "' quality='" + quality + "' wmode='" + wmode + "' bgcolor='" + bgcolor + "' width='" + width + "' height='" + Height + "'>";
    strflash = strflash + "</object>";

    document.write(strflash);
}
