
function checkAllBox(theform)
{
    if(theform.checkAllBoxFg.checked == true)
    {
        for(var i=0; i < theform.length; i++)
        {
            if(theform[i].name == "p_checkbox" && theform[i].checked == false)
            {
                theform[i].checked = true;
            }
        }
    }
    else
    {
        for(var i=0; i < theform.length; i++)
        {
            if(theform[i].name == "p_checkbox" && theform[i].checked == true)
            {
                theform[i].checked = false;
            }
        }
    }
}

function getSelectedItemCount(theform)
{
    var item_count = 0;
    for(var i=0; i < theform.length; i++)
    {
        if(theform[i].name == "p_checkbox" &&  theform[i].checked == true)
        {
            item_count++;
        }
    }

    return item_count;
}



// 20061208 joshua
function getSelectedItemChunkString(form)
{
    var item_count = 0;
    var resultString = "";
    for(var i=0; i < form.length; i++)
    {
        if(form[i].name == "p_checkbox" &&  form[i].checked == true)
        {
            resultString = resultString + form[i].value;
            resultString = resultString + "|";
        }
    }
    return resultString;
}




function getSelectedItemList(theform)
{
    var item_list = "";
    for(var i=0; i < theform.length; i++)
    {
        if(theform[i].name == "p_checkbox" &&  theform[i].checked == true)
        {
            item_list = item_list + theform[i].value + ";";
        }
    }

    return item_list;
}

function getSelectedItemList(theform, deli)
{
    var item_list = "";
    for(var i=0; i < theform.length; i++)
    {
        if(theform[i].name == "p_checkbox" &&  theform[i].checked == true)
        {
            item_list = item_list + theform[i].value + deli;
        }
    }

    return item_list;
}

function getBodySize() {
    wid = document.body.scrollWidth+10;
    hei = document.body.scrollHeight+29;
    self.resizeTo(wid,hei);
}

function move2PrevPage(curPageNum, lastPageNum, moveUrl) {

    var prevPageNum = curPageNum - 1;
    if (prevPageNum >= 1) {
        location.replace(moveUrl + "&p_page_num=" + prevPageNum);
    } else {
        alert("첫 페이지입니다.");
    }
}

function move2NextPage(curPageNum, lastPageNum, moveUrl) {

    var nextPageNum = curPageNum + 1;
    if (nextPageNum <= lastPageNum) {
        location.replace(moveUrl + "&p_page_num=" + nextPageNum);
    } else {
        alert("마지막 페이지입니다.");
    }
}

function move2PrevItem(itemType, itemName, itemId, moveUrl) {

    if (itemId) {
        location.replace(moveUrl + "&"+ itemType + "=" + itemId);
    } else {
        alert("이전 " + itemName + "이 없습니다.");
    }
}

function move2NextItem(itemType, itemName, itemId, moveUrl) {

    if (itemId) {
        location.replace(moveUrl + "&"+ itemType + "=" + itemId);
    } else {
        alert("다음 " + itemName + "이 없습니다.");
    }
}


function clearField(obj) {
    obj.value = "";
}



// 이미지 크기를 계산하기 좋게 하기 위해 메모리에 로드시켜놓으려고
// image객체 생성하고, 이름을 주었다. 안 그러면, 이미지 로드되기 전 계산치가 나온다.
/*
<img onclick="javascript:view_original_image(this);" style="cursor:hand"
    src="http://photo-media.hanmail.net/daum/cartoon/200408/16/d2m.jpg">
*/

var imageWindow;

var FILTER = /^http:\/\/local.netville.co.kr:8080\/club/i

function viewOriginalImage(obj) {

//    if (FILTER.test(obj.src) == true)
//    {
        var nWnWidth, nWnHeight;
        var strUrl;

        strUrl = "../../../originalImage.do?image=" + obj.src;

        nWnWidth = (window.screen.width / 2) - (122 * 10);
        nWnHeight = (window.screen.height / 2) - (27 + 50);

    /*	이미 클릭시 원본 크기로 복원*/
        imageWindow = window.open(strUrl,
                    "imageViewer",
                    "width=100, height=100, left=" + nWnWidth + ", top=" + nWnHeight + ", screenX=" + nWnWidth + ", screenY=" + nWnHeight + ", status=no, toolbar=no, scrollbars=1, resizable=1");
        imageWindow.focus();
//    }
//    else
//    {
//        return;
//    }
}

/*
function utfpatch()
{
	for (i=0;i<document.images.length;i++)
		if (!document.images[i].complete)
			document.images[i].src = toUtf(document.images[i].src);
}

function toUtf(strUrl)
{
	var p1,p2;
	p1 = strUrl.lastIndexOf("/");
	if (p1 == -1)
		p1 = 0;
	p2 = strUrl.lastIndexOf(".");
	if (p2 == -1)
		return strUrl;
	return strUrl.substring(0,p1+1) + escape(strUrl.substring(p1+1,p2)) + strUrl.substring(p2,strUrl.length);
}

function checkImgFormat(imgPath) {
	var len = imgPath.length;
	var sFormat = imgPath.substring(len-4);

	if ( sFormat == ".PNG" ||
		sFormat == ".JPG" ||
		sFormat == ".BMP" ||
		sFormat == ".GIF" ||
		sFormat == ".png" ||
		sFormat == ".bmp" ||
		sFormat == ".gif" ||
		sFormat == ".jpg" ) {

		document.previewImg.src = imgPath;

	} else {
		if ( imgPath != "" ) {
			alert("지원하지 않는 파일형식입니다. 사진은 jpg,gif,bmp,png 포맷을 지원합니다. 파일을 다시 선택해주세요.");
			return
		}
	}
}
*/

    function cmmLoginAction(url) {
    	date =new Date();
    	nowYear=date.getFullYear();
    	nowMonth=date.getMonth()+1;
    	nowDate=date.getDate();
    	nowHour=date.getHours();
    	nowMinute=date.getMinutes();
    	nowTime="";
    	nowTime+=nowYear;
    	nowTime+=(nowMonth<10)?"0"+nowMonth:nowMonth;
    	nowTime+=(nowDate<10)?"0"+nowDate:nowDate;
    	nowTime+=(nowHour<10)?"0"+nowHour:nowHour;
    	nowTime+=(nowMinute<10)?"0"+nowMinute:nowMinute;
        if(parseInt(nowTime)>=200909032350&&parseInt(nowTime)<=200909040800){
            alert("시스템 점검으로 인해 로그인 서비스 이용이 불가능합니다.\n\n이용에 불편을 드려서 죄송합니다.");
            return;
        }
        if(confirm("로그인  하시겠습니까?")) {
            if (document.domain.indexOf("enclean") >= 0)
                window.top.location.href="http://eps.enclean.com/user/jsp/index.jsp?sid=ENCLEAN&returnurl=" + url;
            else
                window.top.location.href="http://deveps2009.enclean.com/user/jsp/index.jsp?sid=DWORLD&returnurl=" + url;
        }
    }

    function clgLoginAction(url) {
    	date =new Date();
    	nowYear=date.getFullYear();
    	nowMonth=date.getMonth()+1;
    	nowDate=date.getDate();
    	nowHour=date.getHours();
    	nowMinute=date.getMinutes();
    	nowTime="";
    	nowTime+=nowYear;
    	nowTime+=(nowMonth<10)?"0"+nowMonth:nowMonth;
    	nowTime+=(nowDate<10)?"0"+nowDate:nowDate;
    	nowTime+=(nowHour<10)?"0"+nowHour:nowHour;
    	nowTime+=(nowMinute<10)?"0"+nowMinute:nowMinute;
        if(parseInt(nowTime)>=200812090050&&parseInt(nowTime)<=200812090900){
            alert("시스템 점검으로 인해 로그인 서비스 이용이 불가능합니다.\n\n이용에 불편을 드려서 죄송합니다.");
            return;
        }
        if(confirm("로그인  하시겠습니까?")) {
            if (document.domain.indexOf("enclean") >= 0)
                window.location.href="http://eps.enclean.com/user/jsp/index.jsp?sid=ENCLEAN&returnurl=" + url;
            else
                window.location.href="http://deveps2009.enclean.com/user/jsp/index.jsp?sid=DWORLD&returnurl=" + url;
        }
    }

    function clgCommLoginAction(url) {
    	date =new Date();
    	nowYear=date.getFullYear();
    	nowMonth=date.getMonth()+1;
    	nowDate=date.getDate();
    	nowHour=date.getHours();
    	nowMinute=date.getMinutes();
    	nowTime="";
    	nowTime+=nowYear;
    	nowTime+=(nowMonth<10)?"0"+nowMonth:nowMonth;
    	nowTime+=(nowDate<10)?"0"+nowDate:nowDate;
    	nowTime+=(nowHour<10)?"0"+nowHour:nowHour;
    	nowTime+=(nowMinute<10)?"0"+nowMinute:nowMinute;
        if(parseInt(nowTime)>=200812090050&&parseInt(nowTime)<=200812090900){
            alert("시스템 점검으로 인해 로그인 서비스 이용이 불가능합니다.\n\n이용에 불편을 드려서 죄송합니다.");
            return;
        }
        if(confirm("로그인  하시겠습니까?")) {
            if (document.domain.indexOf("enclean") >= 0)
                window.parent.location.href="http://eps.enclean.com/user/jsp/index.jsp?sid=ENCLEAN&returnurl=" + url;
            else
                window.parent.location.href="http://deveps2009.enclean.com/user/jsp/index.jsp?sid=DWORLD&returnurl=" + url;
        }
    }

    /*  Function Equivalent to java.net.URLEncoder.encode(String, "UTF-8")
        Copyright (C) 2002, Cresc Corp.
        Version: 1.0
    */
    function encodeURL(str){
        var s0, i, s, u;
        s0 = "";                // encoded str
        for (i = 0; i < str.length; i++){   // scan the source
            s = str.charAt(i);
            u = str.charCodeAt(i);          // get unicode of the char
            if (s == " "){s0 += "+";}       // SP should be converted to "+"
            else {
                if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
                    s0 = s0 + s;            // don't escape
                }
                else {                  // escape
                    if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
                        s = "0"+u.toString(16);
                        s0 += "%"+ s.substr(s.length-2);
                    }
                    else if (u > 0x1fffff){     // quaternary byte format (extended)
                        s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                        s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                        s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                        s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                    }
                    else if (u > 0x7ff){        // triple byte format
                        s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                        s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                        s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                    }
                    else {                      // double byte format
                        s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                        s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                    }
                }
            }
        }
        return s0;
    }

    /*  Function Equivalent to java.net.URLDecoder.decode(String, "UTF-8")
        Copyright (C) 2002, Cresc Corp.
        Version: 1.0
    */
    function decodeURL(str){
        var s0, i, j, s, ss, u, n, f;
        s0 = "";                // decoded str
        for (i = 0; i < str.length; i++){   // scan the source str
            s = str.charAt(i);
            if (s == "+"){s0 += " ";}       // "+" should be changed to SP
            else {
                if (s != "%"){s0 += s;}     // add an unescaped char
                else{               // escape sequence decoding
                    u = 0;          // unicode of the character
                    f = 1;          // escape flag, zero means end of this sequence
                    while (true) {
                        ss = "";        // local str to parse as int
                            for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse
                                sss = str.charAt(++i);
                                if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {
                                    ss += sss;      // if hex, add the hex character
                                } else {--i; break;}    // not a hex char., exit the loop
                            }
                        n = parseInt(ss, 16);           // parse the hex str as byte
                        if (n <= 0x7f){u = n; f = 1;}   // single byte format
                        if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;}   // double byte format
                        if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;}   // triple byte format
                        if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;}   // quaternary byte format (extended)
                        if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;}         // not a first, shift and add 6 lower bits
                        if (f <= 1){break;}         // end of the utf byte sequence
                        if (str.charAt(i + 1) == "%"){ i++ ;}                   // test for the next shift byte
                        else {break;}                   // abnormal, format error
                    }
                s0 += String.fromCharCode(u);           // add the escaped character
                }
            }
        }
        return s0;
    }
