
function ItisPopup(opt){
	var scroll		= "scrollbars";
	var toolbar		= ",toolbar=no";
	var locate		= ",location=no,directories=no";
	var status		= ",status=no";
	var menubar		= ",menubar=no";
	var resize		= ",resizable=no";
	var PopSize		= ",width=500,height=400";
	var PopName		= "itisMem";
	var popItem		= scroll + toolbar + locate + status + menubar + resize + PopSize;
	var href		= "";
	switch(opt) {
		case "3" :
			href = "http://www.itis.or.kr/member/join.asp?signupFrom=SHRDC";
			break; 
		case "4" :
			href = "http://www.itis.or.kr/member/find.asp";
			break;
		case "5" :
			href = "http://www.itis.or.kr/member/myInfo.asp";
			break;
		default : 
	}
	window.open(href, PopName, popItem); 
} 
/* ========================================================================== */
/* fn_isIE(): ºê¶ó¿ìÀú Ã¼Å©                                                   */
/* fn_property(props, token): ÇÁ·ÎÆÛÆ¼ ÆÄ½Ì                                   */
/* fn_getElementsByClass(cls, tag, pid): Å¬·¡½º ÀÌ¸§À¸·Î ¿¤¸®¸ÕÆ® ¾ò±â        */
/* fn_flash(url, props): ÇÃ·¡½Ã »ðÀÔ                                          */
/* fn_getX(obj): body¸¦ ±âÁØÀ¸·Î xÁÂÇ¥ °è»ê                                   */
/* fn_getY(obj): body¸¦ ±âÁØÀ¸·Î yÁÂÇ¥ °è»ê                                   */
/* fn_layer_on(id, html, top, left, width, height): ·¹ÀÌ¾î ¶ç¿ì±â             */
/* fn_layer_off(id, doDestory): ·¹ÀÌ¾î ¼û±â±â                                 */
/* fn_getXMLHTTP(): XMLHTTP °³Ã¼ »ý¼º                                         */
/* fn_getSource(url): ¼Ò½º ³»¿ë ÀÐ±â                                          */
/* fn_include(url, id): include ±¸Çö                                          */
/* ========================================================================== */

/* -----------------------------------------------------------------------------
    ºê¶ó¿ìÀú Ã¼Å©

    @function
        fn_isIE()
    @return
        IE(true), etc.(false)
----------------------------------------------------------------------------- */
function fn_isIE() {
    return (navigator.appVersion.indexOf("MSIE")!=-1 ? true : false);
}

/* -----------------------------------------------------------------------------
    ÇÁ·ÎÆÛÆ¼ ÆÄ½Ì

    @function
        fn_property(props, token)
    @param
        props: ÇÁ·ÎÆÛÆ¼
        token: ±¸ºÐÀÚ
    @return
        list: key¿Í value·Î ÀÌ·ç¾îÁø 2Â÷¿ø ¹è¿­°´Ã¼
    @description
        propsÀÇ ÇüÅÂ´Â "key=value" °ú °°ÀÌ ÀÛ¼ºÇÏ¸ç ±¸ºÐÀÚ´Â ","°¡ µðÆúÆ®ÀÌ´Ù.
        ÆÄ½ÌµÈ °ªÀº list.get(key, sub)·Î ¾òÀ» ¼ö ÀÖ´Ù.
----------------------------------------------------------------------------- */
function fn_property(props, token) {
    var list = new Array();

    if (props != null) {
        var item = props.replace(/ /g, "").split(token!=null ? token : ",");

        for (fn_property_i in item) {
            var value = item[fn_property_i].split("=");

            list.push(new Array(value[0], value[1]));
        }
    }

    list.get = function(key, sub) {
        for (fn_property_i=0; fn_property_i<this.length; fn_property_i++) {
            if (this[fn_property_i][0] == key) return this[fn_property_i][1];
        }
        return sub;
    }

    return list;
}

/* -----------------------------------------------------------------------------
    Å¬·¡½º ÀÌ¸§À¸·Î ¿¤¸®¸ÕÆ® ¾ò±â

    @function
        fn_getElementsByClass(cls, tag, pid)
    @param
        cls: Å¬·¡½º ÀÌ¸§
        tag: ÅÂ±× ÀÌ¸§
        pid: ºÎ¸ð ID
    @return
        list: ¿¤¸®¸ÕÆ®°¡ ÀúÀåµÈ ¹è¿­°´Ã¼
----------------------------------------------------------------------------- */
function fn_getElementsByClass(cls, tag, pid) {
    var list = new Array();

    if (cls != null) {
        var parent = pid!=null ? document.getElementById(pid) : document;
        var els = null;

        if (parent == null) parent = document;
        els = parent.getElementsByTagName(tag!=null ? tag : "*");

        for (fn_getElementsByClass_i=0; fn_getElementsByClass_i<els.length; fn_getElementsByClass_i++) {
            if (els[fn_getElementsByClass_i].className.match(cls)) {
                list.push(els[fn_getElementsByClass_i]);
            }
        }
    }

    return list;
}

/* -----------------------------------------------------------------------------
    ÇÃ·¡½Ã »ðÀÔ

    @function
        fn_flash(src, props)
    @used
        fn_property(props, token)
    @param
        *url: ÆÄÀÏ°æ·Î
        props: ÇÁ·ÎÆÛÆ¼
    @description
        propsÀÇ ÇüÅÂ´Â "width=100, height=100, align=middle" °ú °°ÀÌ ÀÛ¼ºÇÑ´Ù.
        - width: ³ÐÀÌ
        - height: ³ôÀÌ
        - align: Á¤·Ä
        - quality: È­Áú
        - bgcolor: ¹é±×¶ó¿îµå
        - wmode: Åõ¸íµµ(window, opaque, transparent)
----------------------------------------------------------------------------- */
function fn_flash(url, props) {
    if (url != null) {
        var html = null;
        var list = fn_property(props);

        if (fn_isIE()) {
            html = "classid=\"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"";
        } else {
            html = "type=\"application/x-shockwave-flash\" data=\""+url+"\"";
        }

        html = "\
            <object "+html+" width=\""+list.get("width","100%")+"\" height=\""+list.get("height","100%")+"\" align=\""+list.get("align","middle")+"\">\n\
                <param name=\"movie\" value=\""+url+"\">\n\
                <param name=\"quality\" value=\""+list.get("quality","high")+"\">\n\
                <param name=\"bgcolor\" value=\""+list.get("bgcolor","#FFFFFF")+"\">\n\
                <param name=\"wmode\" value=\""+list.get("wmode","window")+"\">\n\
                <param name=\"allowScriptAccess\" value=\"sameDomain\">\n\
            </object>\
        ";

        document.write(html);
    }
}

/* -----------------------------------------------------------------------------
    body¸¦ ±âÁØÀ¸·Î xÁÂÇ¥ °è»ê

    @function
        fn_getX(obj)
    @param
        obj: ¿¤¸®¸ÕÆ®
    @return
        x: xÁÂÇ¥
----------------------------------------------------------------------------- */
function fn_getX(obj) {
    var x = 0;

    if (obj != null) {
        do {
            x += obj.offsetLeft;
            obj = obj.offsetParent;
        } while (obj != document.body);
    }

    return x;
}

/* -----------------------------------------------------------------------------
    body¸¦ ±âÁØÀ¸·Î yÁÂÇ¥ °è»ê

    @function
        fn_getY(obj)
    @param
        obj: ¿¤¸®¸ÕÆ®
    @return
        y: yÁÂÇ¥
----------------------------------------------------------------------------- */
function fn_getY(obj) {
    var y = 0

    if (obj != null) {
        do {
            y += obj.offsetTop;
            obj = obj.offsetParent;
        } while (obj != document.body);
    }

    return y;
}

/* -----------------------------------------------------------------------------
    ·¹ÀÌ¾î ¶ç¿ì±â

    @function
        fn_layer_on(id, html, left, top, width, height)
    @param
        *id: ID
        *html: ³»¿ë
        top: y ÁÂÇ¥
        left: x ÁÂÇ¥
        width: ³ÐÀÌ
        height: ³ôÀÌ
    @description
        select¿Í °ãÄ¡´Â ¹®Á¦¶§¹®¿¡ iframeÀ¸·Î ·¹ÀÌ¾î¸¦ ±¸¼º
----------------------------------------------------------------------------- */
function fn_layer_on(id, html, top, left, width, height) {
    var layer = document.getElementById(id);

    if (layer==null && html!=null) {
        layer = document.createElement("iframe");

        layer.id = id;
        layer.frameBorder = 0;
        layer.style.display = "none";
        layer.style.position = "absolute";
        layer.style.background = "#FFFFFF";

        document.body.appendChild(layer);

        layer.contentWindow.document.open();
        layer.contentWindow.document.write(html);
        layer.contentWindow.document.close();
    }

    if (layer != null) {
        layer.style.display = "block";
        layer.style.top = top!=null ? top : 0;
        layer.style.left = left!=null ? left : 0;
        layer.style.width = width!=null ? width : 100;
        layer.style.height = height!=null ? height : 100;
    }
}

/* -----------------------------------------------------------------------------
    ·¹ÀÌ¾î ¼û±â±â

    @function
        fn_layer_off(id, doDestory)
    @param
        *id: ·¹ÀÌ¾îÀÇ ID
        doDestory: Á¦°Å/¼û±è °áÁ¤
----------------------------------------------------------------------------- */
function fn_layer_off(id, doDestroy) {
    var layer = document.getElementById(id);

    if (layer != null) {
        if (doDestroy) {
            document.body.removeChild(layer);
        } else {
            layer.style.display = "none";
        }
    }
}

/* -----------------------------------------------------------------------------
    XMLHTTP °³Ã¼ »ý¼º

    @function
        fn_getXMLHTTP()
    @return
        req: XMLHTTP °³Ã¼
    @description
        Å×½ºÆ®¿ëÀ¸·Î¸¸ »ç¿ëÇÏ°í, ½Ç °³¹ß½Ã¿¡´Â »ç¿ëÇÏÁö ¾Ê´Â´Ù.
----------------------------------------------------------------------------- */
function fn_getXMLHTTP() {
    var req = false;

    if (window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch (e) {
            req = false;
        }
    } else if (window.ActiveXObject) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                req = false;
            }
        }
    }

    return req;
}

/* -----------------------------------------------------------------------------
    ¼Ò½º ³»¿ë ÀÐ±â

    @function
        fn_getSource(url)
    @used
        fn_getXMLHTTP()
    @param
        url: ÆÄÀÏ°æ·Î
    @return
        obj: ÆÄÀÏÀÇ ³»¿ë
    @description
        ÆÄÀÏÀÇ Çü½ÄÀÌ UTF-8 Çü½ÄÀÌ¾î¾ß Á¤»óÀûÀ¸·Î ÀÛµ¿, ±× ¿ÜÀÇ Çü½ÄÀº ÇÑ±ÛÀÌ ±úÁø´Ù.
        Å×½ºÆ®¿ëÀ¸·Î¸¸ »ç¿ëÇÏ°í, ½Ç °³¹ß½Ã¿¡´Â »ç¿ëÇÏÁö ¾Ê´Â´Ù.
    @TODO
        onreadystatechange ±¸Çö
----------------------------------------------------------------------------- */
function fn_getSource(url) {
    var obj = null;

    if (url != null) {
        var req = fn_getXMLHTTP();

        if (req) {
            var ext = url.substring(url.lastIndexOf(".")+1).toLowerCase();

            req.open("Get", url, false);
            req.send(null);

            switch(ext) {
                case "xml":
                    obj = req.responseXML;

                    if (!obj.hasChildNodes() && fn_isIE()) {
                        obj = new ActiveXObject("Microsoft.XMLDOM");
                        obj.load(url);
                    }

                    break;
                default:
                    obj = req.responseText;
                    break;
            }
        } else {
            return ("<strong style='color:red'>Error initializing XMLHTTPRequest!!!</strong>");
        }
    } else {
        return ("<strong style='color:red'>URL is not found!!!</strong>");
    }

    return obj;
}

/* -----------------------------------------------------------------------------
    include ±¸Çö

    @function
        fn_include(url, id);
    @used
        fn_getSource(url)
    @param
        url: ÆÄÀÏ°æ·Î
        id: ³»¿ëÀÌ Ãâ·ÂµÉ ¿¤¸®¸ÕÆ®ÀÇ ID
    @description
        ÆÄÀÏÀÇ Çü½ÄÀÌ UTF-8 Çü½ÄÀÌ¾î¾ß Á¤»óÀûÀ¸·Î ÀÛµ¿, ±× ¿ÜÀÇ Çü½ÄÀº ÇÑ±ÛÀÌ ±úÁø´Ù.
        Å×½ºÆ®¿ëÀ¸·Î¸¸ »ç¿ëÇÏ°í, ½Ç °³¹ß½Ã¿¡´Â »ç¿ëÇÏÁö ¾Ê´Â´Ù.
    @TODO
        XMLÇü½ÄÀ¸·Î ±¸Çö
----------------------------------------------------------------------------- */
function fn_include(url, id) {
    if (url != null) {
        var html = fn_getSource(url);

        if (html.indexOf("<body") != -1) {
            var head = html.indexOf(">", html.indexOf("<body")) + 1;
            var tail = html.indexOf("</body>");

            html = html.substring(head, tail);
        }

        if (id!=null && document.getElementById(id)!=null) {
            document.getElementById(id).innerHTML = html;
        } else {
            document.write(html);
        }
    }

    return false;
}
/* ------------- MAGICSSO °ü·Ã ÆË¾÷ Ãß°¡ ---------------------*/

function js_login() {
	var winLogin = openPopup("https://www.kiat.or.kr/member/kiatMemberLoginView.do?siteNick=SHR","LogIn");
	winLogin.focus();
}

function js_logout() {
	var answer = confirm("·Î±×¾Æ¿ôÇÏ½Ã°Ú½À´Ï±î?");

	if (answer == true) {
		try
		{
			MagicPass.siteLogout();
		}
		catch (e)
		{
			window.location.replace("/magicsso/logout.jsp");
		}
	}
}

function js_join() {
    var winJoin = openPopup("https://www.kiat.or.kr/member/kiatMemberRegister1.do?siteNick=SHR","JOIN");
	winJoin.focus();
}

function js_mypage() {
    var winMyPage = openPopup("https://www.kiat.or.kr/member/kiatMemberUpdateView.do?siteNick=SHR","MYPAGE");
	winMyPage.focus();
}

function js_passsearch(){
	var winSearch = openPopup("https://www.kiat.or.kr/member/searchPasswordView1.do?siteNick=SHR","FIND_ID_PASSWORD");
	winSearch.focus();
}

function js_qna() {
	var winQna = window.open("https://www.kiat.or.kr/site/program/board/write.jsp?menuID=001003001&type=&boardTypeID=4&boardID=&siteNick=SHR");
	winQna.focus();
}

function openPopup (sURL, title) {
    var sWidth, sHeight;
    var sFeatures;
    var oWindow;
    var SP2 = false;
    var POPUP_WIDTH     = 800;
    var POPUP_HEIGHT    = 760;
    var B_MAIN_PAGE     = true;

    sWidth  = POPUP_WIDTH;
	sHeight = POPUP_HEIGHT;
	var x = (screen.width) ? (screen.width-sWidth)/2 : 0;
    var y = (screen.height) ? (screen.height-sHeight)/2 : 0;  
    sTitle = title;

    try {
      SP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
      
      if (SP2)     {   // XP SP2 ºê¶ó¿ìÀúÀÓ..
        sHeight = Number(sHeight)+10;
      }else{  //±×¿Ü ºê¶ó¿ìÀú
      }
    } catch(e) {}
    
    sFeatures =  "width=" + sWidth + ",height=" + sHeight ;
    sFeatures += ",left=" + x + ",top=" + y ;
    sFeatures += ",directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no";
        
    if(sURL!=null && sURL.length > 0) {
      if(sURL.indexOf("?") > 0) {
        sURL += "&thref="+encodeURI(location.href);
      } else {
        sURL += "?thref="+encodeURI(location.href);
      }
    }
    oWindow = window.open(sURL, sTitle, sFeatures);
    oWindow.focus();
 
    return oWindow;
}
/* ------------- // MAGICSSO °ü·Ã ÆË¾÷ Ãß°¡ ---------------------*/