/******************************************************************************
 *  FileName: UserMain.js
 *  Date    : 2007-12-14
 ******************************************************************************/
 /*************************************************************
 * »ç¿ë¿¹½Ã
 *
 *  window.onload = function() {
 *      paid.UserEvent.addListener(getObject("name"), "event name", function name, useCapture);
 *  }
 *
 *  name
 *   - html ÅÂ±× ³»ÀÇ id ¸íÀ» ÀÔ·ÂÇÑ´Ù.
 *   - ¿¹ : <input id="obj" type.... />¶ó´Â ÅÂ±×°¡ ÀÖ´Ù¸é "obj"¸¦ ÀÔ·ÂÇÑ´Ù.
 *  event name
 *   - ÀÌº¥Æ® ¸íÀ» Àû¾îÁÖ¸ç "" <-- ¹®ÀÚ¿­·Î ³Ñ±ä´Ù.
 *   - ¿¹: "click", "focus", "keydown"
 *  function name
 *   - ÇÔ¼ö¸íÀ» Àû´Â´Ù.
 *   - ¹®ÀÚ¿­ÀÌ ¾Æ´ÔÀ» ÁÖÀÇ
 *   - ¿¹ : doSubmit, getZipCode,
 *
 *  useCapture
 *   - true ¶Ç´Â false °ªÀ» »ç¿ëÇÑ´Ù.
 *   - Ã¢¿¡¼­ ¹ß»ýÇÑ ÀÌº¥Æ®¸¦ ºÎ¸ð¿¡¼­ Ã»ÃëÇÒÁö ¿©ºÎ¸¦ °áÁ¤ÇÑ´Ù.
 *
 *************************************************************/
window.onload = function() {
    paid.UserEvent.addListener(getObject("ancForum"), "click", function(){viewPolicy('ancForum')}, false);
	
    paid.UserEvent.addListener(getObject("ancPolicy"), "click", function(){viewPolicy('ancPolicy')}, false);
	
	paid.UserEvent.addListener(getObject("ancPropos"), "click", function(){viewPolicy('ancPropos')}, false);
	

}

//-------------------------------------------------------------------
// mouser on ÀÏ°æ¿ì ÀÌ¹ÌÁö º¯°æ
//-------------------------------------------------------------------
function onImg(numImg) {
    var targetImg;
    var changeImg;

    if(numImg == "1") {
        targetImg = document.getElementById("imgleftQuick_1");
        changeImg = "/images/user/common/main_app_menu01_r.gif";
    } else if (numImg == "2") {
        targetImg = document.getElementById("imgleftQuick_2");
        changeImg = "/images/user/common/main_app_menu02_r.gif";
    } else if (numImg == "3") {
        targetImg = document.getElementById("imgleftQuick_3");
        changeImg = "/images/user/common/main_app_menu03_r.gif";
    } else if (numImg == "4") {
        targetImg = document.getElementById("imgleftQuick_4");
        changeImg = "/images/user/common/main_app_menu04_r.gif";
    } else if (numImg == "5") {
        targetImg = document.getElementById("imgleftQuick_5");
        changeImg = "/images/user/common/main_app_menu05_r.gif";
    }

    targetImg.setAttribute("src", changeImg);
}

//-------------------------------------------------------------------
// mouser off ÀÏ°æ¿ì ÀÌ¹ÌÁö º¯°æ
//-------------------------------------------------------------------
function offImg(numImg) {
    var targetImg;
    var changeImg;

    if(numImg == "1") {
        targetImg = document.getElementById("imgleftQuick_1");
        changeImg = "/images/user/common/main_app_menu01.gif";
    } else if (numImg == "2") {
        targetImg = document.getElementById("imgleftQuick_2");
        changeImg = "/images/user/common/main_app_menu02.gif";
    } else if (numImg == "3") {
        targetImg = document.getElementById("imgleftQuick_3");
        changeImg = "/images/user/common/main_app_menu03.gif";
    } else if (numImg == "4") {
        targetImg = document.getElementById("imgleftQuick_4");
        changeImg = "/images/user/common/main_app_menu04.gif";
    } else if (numImg == "5") {
        targetImg = document.getElementById("imgleftQuick_5");
        changeImg = "/images/user/common/main_app_menu05.gif";
    }

    targetImg.setAttribute("src", changeImg);
}

//-------------------------------------------------------------------
// Á¤Ã¥Åä·Ð(Æ÷·³, ÀüÀÚ°øÃ»È¸) ÃÖ±Ù±Û º¸±â
//-------------------------------------------------------------------
function viewPolicy(target_div) {
    
    
    if (target_div == "ancForum") {
        document.getElementById("imgForum").src = "/images/user/common/main_forum_tab01_r.gif";
        document.getElementById("imgPolicy").src = "/images/user/common/main_forum_tab02.gif";
		document.getElementById("imgPropos").src = "/images/user/common/main_forum_tab03.gif";
		
        		
        document.getElementById("divPolicy").style.display ="none";        
		document.getElementById("divPropos").style.display ="none";
		document.getElementById("divForum").style.display ="block";
		
		document.getElementById("policy_more_button").style.display ="none";
		document.getElementById("propos_more_button").style.display ="none";
		document.getElementById("forum_more_button").style.display ="inline";
		
    } else if(target_div == "ancPolicy") {
        document.getElementById("imgForum").src = "/images/user/common/main_forum_tab01.gif";
        document.getElementById("imgPolicy").src = "/images/user/common/main_forum_tab02_r.gif";
		document.getElementById("imgPropos").src = "/images/user/common/main_forum_tab03.gif";
        
        document.getElementById("divForum").style.display ="none";	
		document.getElementById("divPropos").style.display ="none";
		document.getElementById("divPolicy").style.display ="block";
		
		
		document.getElementById("forum_more_button").style.display ="none";
		document.getElementById("propos_more_button").style.display ="none";
		document.getElementById("policy_more_button").style.display ="inline";        
		
	}else if(target_div == "ancPropos"){
		document.getElementById("imgForum").src = "/images/user/common/main_forum_tab01.gif";
        document.getElementById("imgPolicy").src = "/images/user/common/main_forum_tab02.gif";
		document.getElementById("imgPropos").src = "/images/user/common/main_forum_tab03_r.gif";
        
        document.getElementById("divForum").style.display ="none";
		document.getElementById("divPolicy").style.display ="none";        
		document.getElementById("divPropos").style.display ="block";
		
		document.getElementById("forum_more_button").style.display ="none";
		document.getElementById("policy_more_button").style.display ="none";
		document.getElementById("propos_more_button").style.display ="inline";
		
	}
    
    
}

//-------------------------------------------------------------------
// ÃÖ±Ù¼Ò½Ä ´õº¸±â ¹öÆ° Å¬¸¯½Ã ÀÌº¥Æ®
//-------------------------------------------------------------------
function viewMoreList(event) {
    var target= paid.UserEvent.getTarget(event);
    if (target.id != null) {
        if (target.id == "imgBoardNews") {
            document.getElementById("imgBoardNews").src = "/images/user/common/main_tab01_r.gif";
            document.getElementById("imgNicePropos").src = "/images/user/common/main_tab03.gif";

            document.getElementById("divBoardNews").style.display ="block";
            document.getElementById("divNicePropos").style.display ="none";

            document.getElementById("ancMore").setAttribute("href", "/jsp/user/on/cu/UOnBbsList.jsp?brd_id_v=news");
        } else {
            document.getElementById("imgBoardNews").src = "/images/user/common/main_tab01.gif";
            document.getElementById("imgNicePropos").src = "/images/user/common/main_tab03_r.gif";

            document.getElementById("divBoardNews").style.display ="none";
            document.getElementById("divNicePropos").style.display ="block";

            document.getElementById("ancMore").setAttribute("href", "/jsp/user/pp/UPpProposNiceList.jsp");
        }
    }
    paid.UserEvent.stopEvent(event);
}


 function La_Check(j)  {
    for (i=1 ; i<5 ; i++){
        sel = 'La'+i;
        if(i == j) {
             document.getElementById(sel).style.display = '';
        }else{
            document.getElementById(sel).style.display = 'none';
       }
    }
 }

 function forum_div_Check(k)  {
    for (i=1 ; i<3 ; i++){
        sel = 'Fo'+i;
        if(i == k) {
             document.getElementById(sel).style.display = '';
        }else{
            document.getElementById(sel).style.display = 'none';
       }
    }
 }

 function detailView(brd_id_v, tbrd_seq_n) {
    var frm = document.frm;
    frm.action="/jsp/user/on/cu/UOnBbsRead.jsp?brd_id_v=" + brd_id_v + "&tbrd_seq_n=" + tbrd_seq_n;
    frm.submit();
 }

 function goView(flag, civilNo, menu1, menuGubun, row) {
    var frm = document.frm;
    frm.civil_no_c.value = civilNo;
    frm.menu1.value = menu1;
    frm.menuGubun.value = menuGubun;
    frm.rnum.value=row;

    if(flag == '1'){
        frm.action = "/jsp/user/pc/example/UPcExampleCvreqView2.jsp";
    }else if(flag == '2'){
        frm.action = "/jsp/user/pc/example/UPcExampleCvreqView.jsp";
    }

    frm.submit();
 }

 // ¿ì¼öÁ¦¾È »ó¼¼º¸±â
 function showDetail(val, ancCode) {
    var frm = document.frm;
    frm.niceYn.value="Y";
    frm.petiNo.value = val;
	frm.ancCode.value = ancCode;
    frm.action="/jsp/user/pp/UPpProposNiceRead.jsp";
    frm.submit();
 }

 // °ø°³Á¦¾È »ó¼¼º¸±â
 function showOpenDetail(val) {
    var frm = document.frm;
    frm.target = '_self';
    frm.action="/jsp/user/pp/UPpProposOpenRead.jsp";
    frm.petiNo.value = val;
    frm.submit();
 }

 //Æ÷·³»ó¼¼º¸±â
 function goForumView(appNo) {
    var frm = document.frm;
    frm.app_no_c.value = appNo;
    frm.action = "/jsp/user/po/filterOff/forum/UPoForumProcessView.jsp?flag=1i&urlGubun=forum&increaseCnt=ok";
    frm.submit();
 }

 //°øÃ»È¸»ó¼¼º¸±â
 function goPolicyView(appNo) {
    var frm = document.frm;
    frm.app_no_c.value = appNo;
    frm.action = "/jsp/user/po/filterOff/puhe/UPoPuheProcessView.jsp?flag=1i&urlGubun=puhe&increaseCnt=ok";
    frm.submit();
 }

// ±ÝÁö ÀÔ·Â ´Ü¾î ÀÔ·Â½Ã Ã¼Å©(Æ¯¼ö¹®ÀÚµî).
function checkSearch(str, msg) {

    var Exp = /.*[$\\@\\\#%\^\&\*\+\_\;\'\{\}\`\\\~\=\|\.\,\:\?\/\"\!].*/;

    if(str.search(Exp) == 0) {
        alert(msg + "°Ë»ö¿¡ À§¹ÝµÇ´Â Æ¯¼ö¹®ÀÚ°¡ Æ÷ÇÔµÇ¾î ÀÖ½À´Ï´Ù.");
        return false;
    }
    return true;
}

function bestKwdSearch() {
    if( !checkSearch(document.BestKwdForm.query.value, "") ) {
            document.BestKwdForm.query.focus();
            return false;
    }
    return true;
}

// µ¿±â½Ä, Get ¹æ½ÄÀ¸·Î Ajax ¸Þ½ÃÁö¸¦ È£ÃâÇÑ´Ù.
function callAjax(url) {
    var request;
    // À¥ ºê¶ó¿ìÀú¿¡ µû¸¥ ºÐ±â
    if (window.XMLHttpRequest) {                             // ¸ðÁú¶ó °è¿­
        request = new XMLHttpRequest();
        request.open("POST", url, false);
        request.send();
    } else if (window.ActiveXObject) {                       // MS IE
        request = new ActiveXObject("Microsoft.XMLHTTP");
        request.open("POST", url, false);
        request.send();
    }

    if (request.readyState == 4) {
        if (request.status == 200) {
            var response = request.responseText;
            return response;
        } else {
            alert("¿¹¿Ü°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù. (¸Þ½ÃÁö=" + request.statusText + ")");
        }
    }
}

/**
 * »ç¿ëÀÚ ¸ÞÀÎ È­¸é °øÁö»çÇ× Æ¼Ä¿ ½ºÅ©·ÑµÇµµ·Ï ÇÏ´Â ÇÔ¼ö
 * @param {Object} target ½ºÅ©·Ñ ´ë»ó °´Ã¼
 * @param {Object} target_width ½ºÅ©·Ñ ³Êºñ
 * @param {Object} target_height ½ºÅ©·Ñ ³ôÀÌ
 */
function doTicker(target, target_width, target_height) {
    var mover = target.getElementsByTagName("ul").item(0);

    // set
    mover.style.position = "absolute";
    mover.style.margin = "0 0 0 0";
    mover.style.left = "0px";
    mover.leftPosition = 0;

    // duplicate text
    mover.style.width = target_width * target_height * 2 + "px";
    mover.innerHTML += mover.innerHTML;

    // set action
    mover.tickerAction = window.setInterval(
        function()
        {
            if (mover.leftPosition * -1 > (target_width * target_height)) {
                mover.leftPosition = -1;
            } else {
                mover.leftPosition -= 1;
            }
            mover.style.left = mover.leftPosition + "px";
        }
    , 40);
}

/**
 * »ç¿ëÀÚ ¸ÞÀÎ È­¸é °øÁö»çÇ× Æ¼Ä¿ ½ºÅ©·ÑµÇµµ·Ï ÇÏ´Â ÇÔ¼ö
 * @param {Object} target ½ºÅ©·Ñ ´ë»ó °´Ã¼
 * @param {Object} target_height ½ºÅ©·Ñ ³Êºñ
 * @param {Object} target_num ½ºÅ©·Ñ °¹¼ö
 */
function doTickerUpper(target, target_height, target_num) {
    var mover = target.getElementsByTagName("ul").item(0);

    // set
    mover.style.position = "absolute";
    mover.style.margin = "0 0 0 0";
    mover.style.top = "0px";
    mover.leftPosition = 0;

    // duplicate text
    mover.style.height = target_height * target_num * 2 + "px";
    mover.innerHTML += mover.innerHTML;

    // set action
    mover.tickerAction = window.setInterval(
        function()
        {
            if (mover.topPosition * -1 > (target_height * target_num)) {
                mover.topPosition = -1;
            } else {
                mover.topPosition -= 1;
            }
            mover.style.top = mover.leftPosition + "px";
        }
    , 40);
}

var popup = false;
var popup2 = false;
var popup3 = false;
var popup4 = false;

// ÀÏ¹Ý ÆË¾÷ 8054, 8055 ¸ðµÎ Àû¿ë
function noticePop() {
    if (popup) {
        if ( getCookie("popup_20080222") != "done") {
            window.open("/html/popup_20080222/popup_20080222.html", "popup080222",
                        "width=480,height=350,marginwidth=0, top=0,left=5,marginheight=0,"+
                        "resizable=0,scrollbars=no,menubar=no");
        }
    }
    if (popup2) {
        if ( getCookie("popup_20080312") != "done") {
            window.open("/html/popup_20080312/popup_20080312.html", "popup080312",
                        "width=480,height=350,marginwidth=0, top=0,left=5,marginheight=0,"+
                        "resizable=0,scrollbars=no,menubar=no");
        }
    }
    if( popup3 ) {
            if ( getCookie("popup080228") != "done") {
            window.open("/html/popup_20080228/popup_20080228.html", "popup080228",
                        "width=410,height=295,marginwidth=0, top=0,left=490,marginheight=0,"+
                        "resizable=0,scrollbars=no,menubar=no");
        }
    }
    if( popup4 ) {
            window.open("/html/popup/popup_20081219.html", "popup081219",
                        "width=333,height=319,marginwidth=0, top=0,left=490,marginheight=0,"+
                        "resizable=0,scrollbars=no,menubar=no");
    }
    
    
}


/**
 * ½Å¹®°í¼Ò½Ä ¹× ÀÚÁÖÇÏ´Â Áú¹® ÅÇÅ¬¸¯½Ã º¸¿©Áö°Ô ÇÏ´Â ÇÔ¼ö 
 */
function boardToggle(id) {

	var BoardNews = document.getElementById("BoardNews");
	var BoardFAQ  = document.getElementById("BoardFAQ");
	var BoardNewsImg 	 = document.getElementById("BoardNewsImg");
	var BoardFAQImg 	 = document.getElementById("BoardFAQImg");
	var ANFmore = document.getElementById("ANFmore");	//more¹öÆ°
	
	if(id=="BoardNews"){			//½Å¹®°í ¼Ò½Ä
		BoardNews.style.display = "block";
		BoardFAQ.style.display = "none";
		BoardNewsImg.src = "/images/user/common/tab01_on.gif";
		BoardFAQImg.src  = "/images/user/common/tab02_off.gif";
		ANFmore.href = "/jsp/user/on/cu/UOnBbsList.jsp?brd_id_v=news";
	}else if(id=="BoardFAQ"){	//ÀÚÁÖÇÏ´Â Áú¹®
		BoardFAQ.style.display = "block";
		BoardNews.style.display = "none";
		BoardNewsImg.src = "/images/user/common/tab01_off.gif";
		BoardFAQImg.src  = "/images/user/common/tab02_on.gif";
		ANFmore.href = "/jsp/user/on/cu/UOnBbsList.jsp?brd_id_v=helpinfo";
	}
	
}




/**
 * ÀÚÁÖÇÏ´Â Áú¹® ½½¶óÀÌµå 
 */
function boardFAQSlide(inSlideNum) {

	var BoardFAQSlide1 = document.getElementById("BoardFAQSlide1");
	var BoardFAQSlide2 = document.getElementById("BoardFAQSlide2");
	var preBtn 	= document.getElementById("preBoardFAQ");
	var nextBtn = document.getElementById("nextBoardFAQ");
	
	
	if(inSlideNum == 1){	
	
		BoardFAQSlide1.style.display = "block";
		BoardFAQSlide2.style.display = "none";

		preBtn.num 	= 2;
		nextBtn.num = 2;
		
	}else if(inSlideNum == 2){
	
		BoardFAQSlide2.style.display = "block";
		BoardFAQSlide1.style.display = "none";
		
		preBtn.num 	= 1;
		nextBtn.num = 1;
		
	}
	
}


/**
 * ÀÌ¿ë¾È³» ¹× ³ªÀÇÀÌ¿ë³»¿ª ¹öÆ° ¸¶¿ì½º ¿À¹ö½Ã ¸µÅ© Ç¥Ãâ 
 */
function btnToggle(id,flag) {


	var minwon 		= document.getElementById("minwon");
	var new_info  = document.getElementById("new_info");
	
	if(id=="minwon"){					//³ªÀÇÀÌ¿ë³»¿ª
		minwon.style.display = flag;
	}else if(id=="new_info"){	//ÀÌ¿ë¾È³»
		new_info.style.display = flag;
	}
	
}




noticePop();