/**
 * cms페이지 로그아웃
 * @return void
 */
function logout(){
  document.location.href = "../cms/logout.jsp";
}
 

/**
 * 토글메뉴 
 * @param obj
 * @return
 */
function ShowContent(MenuName, ShowMenuID) {
  var i=1;
  while(document.getElementById(MenuName + i)){
    var menu=document.getElementById(MenuName + i).style;
    if ( i == ShowMenuID ) {
      if (menu.display=="block")      {
        $("#"+MenuName + i+"").hide(200);
      } else {
        $("#"+MenuName + i+"").show(200);  
      }
    } else {
      $("#"+MenuName + i+"").hide(200);
    }
    i++;
  }
}



/**
 * depth1메뉴 포커스변경시 이미지교체
 * @param obj
 * @return
 */
function changeTopMenu( position ){
  var topMenuImages = document.getElementById('topmenulist').getElementsByTagName("img");
  for( var i = 0; i < topMenuImages.length; i++ ){
      topMenuImages[i].src = ( i == position )?topMenuImages[i].src.replace('_off', '_on')
                                      :topMenuImages[i].src.replace('_on', '_off');
  }
}



/**
 * depth2메뉴에 마우스오버시 스타일변경
 * @param position
 * @return
 */
function changeSubmenu( position ){
  var subMenuLists = document.getElementById('submenulist').getElementsByTagName("li");
  for( var i = 0; i < subMenuLists.length; i++ ){
    subMenuLists[i].className = ( i == position )?'menuOn':'menuOff';
  }
}



/**
 * 관리자메뉴수정(editAdminMenu.jsp)페이지의 하위링크 추가
 * @param liId
 * @return
 */
function addSubMenu(){
  var root = document.getElementById('subitemlist');
  var items = root.getElementsByTagName('li');
  
  var maxrow = 0;
  for( var i = 0; i < items.length; i++ ){
    maxrow = ( maxrow < ( (items[i].getAttribute('rowid') == null)?0:items[i].getAttribute('rowid') )
               ?    items[i].getAttribute('rowid') : maxrow );
  }
  if( maxrow == 0 && items.length == 1 ){
    root.removeChild(items[0]);
  }else{
    maxrow += 1;
  }
  var li = document.createElement('li');
  li.setAttribute('rowid', maxrow);
  var tempArray = new Array();
  tempArray.push('<label style="cursor:move;">메뉴명: <input type="text" name="menuname" class="txt" /></label>\n');
  tempArray.push('<label>링크: <input type="text" name="menulink" class="txt" size="50" /></label>\n');
  tempArray.push('<a href="#" onclick="deleteSubMenu(\''+maxrow+'\');return false;" class="btnType2 btnType2Style"><span class="btnType2SpanStyle">삭제</span></a>');
  tempArray.push(' <a href=\"#\" onclick="moveSubMenu(this, \'up\'); return false;" class="btnType2 btnType2Style"><span class="btnType2SpanStyle">위로</span></a>');
  tempArray.push(' <a href=\"#\" onclick="moveSubMenu(this, \'down\'); return false;" class="btnType2 btnType2Style"><span class="btnType2SpanStyle">아래로</span></a>');

  li.innerHTML = tempArray.join('');
  root.appendChild(li);

}



/**
 * 관리자메뉴수정(editAdminMenu.jsp)페이지의 하위링크 삭제
 * @param liId
 * @return
 */
function deleteSubMenu( liId ){
  if( confirm('선택하신 하위메뉴를 삭제하시겠습니까?') ){
    var root = document.getElementById('subitemlist');
    var items = root.getElementsByTagName('li');
    for( var i = 0; i < items.length; i++ ){
      if( items[i].getAttribute('rowid') == liId ){
        root.removeChild(items[i]);
      }
    }
  }
}




/**
 * editAdminMenu.jsp 하위메뉴의 순서변경함수
 * @param obj anchor태그개체
 * @param direction 방향('up' or '아무거나')
 * @return
 */
function moveSubMenu( obj, direction ){
  var parentLi = obj.parentNode;
  var root = parentLi.parentNode;
  var liList = root.getElementsByTagName('li');
  var prevLinumber = 0;
  var replacedNode;
  
  for( var i = 0; i < liList.length; i++ ){
    
    if( ( parentLi == liList[i] ) ){
      
      if( direction == 'up' ){
        root.insertBefore( parentLi, liList[prevLinumber] );
      }else if( i < (liList.length - 1) ){
        replacedNode = root.replaceChild( parentLi, liList[i + 1] );
        root.insertBefore( replacedNode, parentLi );
        i++;
      }
      
    }
    
    prevLinumber = i;
    
  }
  
}



/**
 * 달력 보여주는 함수
 * @param target
 * @param frame
 * @param e
 * @return
 */
function showCalendar(target, frame, e){
  var event = window.event || e;
  var x = event.pageX || event.clientX + document.body.scrollLeft;
  var y = event.pageY || event.clientY + document.body.scrollTop;
  document.getElementById(frame).style.left = x + 'px';
  document.getElementById(frame).style.top = y + 'px';
  document.getElementById(frame).src = "../calendar/calendarFrame.jsp?targetId="+target+"&frameId="+frame;
  document.getElementById(frame).style.display = "inline";
}




/**
 * <script>fncCalendarImg('inputid');</script>
 * 달력 이미지보여주는 함수
 * @param e
 * @return
 */
function fncCalendarImg(type){
  $("#"+type).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });
  //document.write("<img src=\"../../files/board/images/board/icon_calendar.gif\" align=\"absmiddle\" onclick=\"showCalendar2('"+type+"');\" style=\"cursor:pointer;margin-right:5px;\"><div id='"+type+"_cal' style='display:none;'></div>");
  
}

/**
 * 게시판관리분류입력
 * @author 김지은
 * @param 분류텍스트객체
 * @param 분류select객체
 * @param text
 * @return 
 */
function addItem(obj1, obj2, text) {
  if( obj1.value.replace(/\s/g, '')=="" ) {
    alert("입력할 "+text+"를 입력하세요");
    obj1.focus();
    return;
  }
  
  var sOption = document.createElement("OPTION");
/*
  if ( objectid != "" ) {
    $.post("itemProcess.jsp",        //ajax 로 페이지 부르기 
          { 'itemFieldName':obj1.value, 'mode':"insertItemProcess", 'groupID':groupid, 'objectID':objectid },  // 선택된 것 Array로 넘기기
          function(data) {            // Callback 함수
            aData = data.split("|");
            len = aData.length ;
            for (i=0;i<len;i++) {
              if ( i == 0 ) {
                sOption.value=aData[0];
              } else if ( i == 1 ) {
                alert(aData[1]);
              }
            }
          }, 
          "text");
  } else {
    sOption.value=" ";
  }
  */
  sOption.value="";
  sOption.text=obj1.value;
  obj2.options.add(sOption);
  obj1.value = "";
}


/**
 * 게시판관리분류삭제
 * @author 김지은
 * @param 분류select객체
 * @param text
 * @return
 */
function deleteItem(obj2, text) {
  if( obj2.selectedIndex == -1 ) {
    alert("삭제할  "+text+"를 선택하세요");
    obj2.focus();
    return;
  }
  $.post("itemProcess.jsp",        //ajax 로 페이지 부르기 
          { 'itemID':obj2.options[obj2.selectedIndex].value, 'mode':"checkItemProcess" },  // 선택된 것 Array로 넘기기
          function(data) {            // Callback 함수
            aData = data.split("|");
            len = aData.length ;
            for (i=0;i<len;i++) {
              if ( i == 0 ) {
                //obj2.remove(obj2.selectedIndex);
              } else if ( i == 1 ) {
                if ( confirm(aData[i]) ) {
                  obj2.remove(obj2.selectedIndex);
                }
              }
            }
          }, 
          "text");
  /*
  if ( objectid != "" ) {
    $.post("itemProcess.jsp",        //ajax 로 페이지 부르기 
          { 'itemID':obj2.options[obj2.selectedIndex].value, 'mode':"deleteItemProcess", 'groupID':groupid, 'objectID':objectid },  // 선택된 것 Array로 넘기기
          function(data) {            // Callback 함수
            aData = data.split("|");
            len = aData.length ;
            for (i=0;i<len;i++) {
              if ( i == 0 ) {
                obj2.remove(obj2.selectedIndex);
              } else if ( i == 1 ) {
                alert(aData[1]);
              }
            }
          }, 
          "text");
  } else {
    obj2.remove(obj2.selectedIndex);
  }
  */
  //obj2.remove(obj2.selectedIndex);
}

function editItemDisplay(obj1, obj2) {
  obj2.value = obj1.options[obj1.selectedIndex].text;
  /*
  obj3.value = obj1.options[obj1.selectedIndex].value;
  */
}

function editItem(itemfieldname, obj){
/*
        $.post("itemProcess.jsp",        //ajax 로 페이지 부르기 
          { 'itemFieldName':itemfieldname, 'itemID':itemid, 'mode':"updateItemProcess", 'groupID':groupid, 'objectID':objectid },  // 선택된 것 Array로 넘기기
          function(data) {            // Callback 함수
            aData = data.split("|");
            len = aData.length ;
            for (i=0;i<len;i++) {
              if ( i == 0 ) {
                if ( obj.options[obj.selectedIndex].value == itemid ) {
*/
                  obj.options[obj.selectedIndex].text = itemfieldname;
/*
                }
              } else if ( i == 1 ) {
                alert(aData[1]);
              }
            }
          }, 
          "text");
*/
}
/**
 * 게시판관리분류   위로
 * @author 김지은
 * @param 분류select객체
 * @return
 */
function upItem(obj2) {
  var nSelectedIndex = obj2.selectedIndex;
  if ( nSelectedIndex < 0 ) {
    alert("선택한 값이 없습니다.");
    return;
  }
  if ( nSelectedIndex == 0 ) {
    alert("처음입니다.");
    return;
  }

  var sText = obj2.options[nSelectedIndex].text;
  var sValue = obj2.options[nSelectedIndex].value;
  obj2.options[nSelectedIndex].text = obj2.options[nSelectedIndex-1].text;
  obj2.options[nSelectedIndex].value = obj2.options[nSelectedIndex-1].value;
  obj2.options[nSelectedIndex-1].text = sText;
  obj2.options[nSelectedIndex-1].value = sValue;
}



/**
 * 게시판관리분류아래로
 * @author 김지은
 * @param 분류select객체
 * @return
 */
function downItem(obj2) {
  var nSelectedIndex = obj2.selectedIndex;
  if ( nSelectedIndex < 0 ) {
    alert("선택한 값이 없습니다.");
    return;
  }
  if ( nSelectedIndex == obj2.length -1 ) {
    alert("마지막입니다.");
    return;
  }

  var sText = obj2.options[nSelectedIndex].text;
  var sValue = obj2.options[nSelectedIndex].value;
  obj2.options[nSelectedIndex].text = obj2.options[nSelectedIndex+1].text;
  obj2.options[nSelectedIndex].value = obj2.options[nSelectedIndex+1].value;
  obj2.options[nSelectedIndex+1].text = sText;
  obj2.options[nSelectedIndex+1].value = sValue;
}

/**
 * 분류select객체의 text를 아이템필드로 삽입
 * @author 조지은
 * @param 분류select객체
 * @param 아이템필트네임객체
 * @return
 */
function checkItemFieldName(sSelectItem, sItemFieldName){
  if ( sSelectItem && sItemFieldName ) {
    var sTxt = "";
    var nOption = sSelectItem.length;
    for( i = 0; i < nOption; i++ ) {
     sTxt += sSelectItem.options[i].value;
     sTxt += ":";
     sTxt += sSelectItem.options[i].text;
      if( i < nOption - 1 ) {
        sTxt = sTxt + "|";
      }
    }
    sItemFieldName.value = sTxt;
  }
}

/**
* 첨부파일 확장자 검사
* @author 조지은
* @param 첨부파일 허용종류
* @param 파일 객체
* @return
*/ 
function checkFile(existExt){
  existExtArray = existExt.split("|");
  var inputs = document.getElementsByTagName("input");
  var file = new Array();
  var idx =0;
        
  for ( var i=0; i<inputs.length;i++){
    if ( inputs[i].type == "file" && inputs[i].value != "" ) {
      file[idx] = inputs[i];
      idx++;
    }
  }
  
  if ( file.length > 0 ) {
    for ( var i=0; i<file.length;i++){
      Temp_file1_name = file[i].value;
      if (Temp_file1_name != "") {
        bi = false;
        Temp_strExt1_num = Temp_file1_name.slice(Temp_file1_name.lastIndexOf(".")).toLowerCase();
        for (var j=0; j < existExtArray.length; j++){
          if (Temp_strExt1_num == existExtArray[j]){
            bi = true;
          }
          if ( ( j == existExtArray.length - 1 ) && !bi ) {
            if ( !bi ) {
              alert(Temp_strExt1_num+"は添付できない拡張子です。");
              return false;
            } else {
              return true;
            }
          }
        }
      } else {
        return true;
      }
    }
    if ( !bi ) {
      alert(Temp_strExt1_num+"는 첨부할 수 없는 확장자입니다.");
      return false;
    } else {
      return true;
    }
  } else {
    return true;
  } 
}

/**
* 글쓰기제한단어 검사
* @author 조지은
* @param 글쓰기제한단어
* @param 인풋
* @return
*/
function checkRestrictWord(restrictWord, input){
  Temp_name = input.value;
  restrictWordArray = restrictWord.split(",");
  if ( restrictWord != "" && Temp_name != "" ) {
    ci = false;
    for(i=0;i<restrictWordArray.length;i++){
      var c = new RegExp(restrictWordArray[i].replace(/(^\s*)|(\s*$)/g, ""));
      if ( c.test(Temp_name) ) {
        ci = false;
        break;
      } else {
        ci = true;
      }
    }
    if ( !ci ) {
      alert("금지어를 포함하고 있습니다. 다시 작성해주세요.");
      return false;
    } else {
      return true;
    }
  } else {
    return true;
  }
}


/**
 * open popup, window open을 이용, 인자전달 없음
 *
 * @param       sURL    url
 * @param       sWidth  window width(optional)
 * @param       sHeight window height(optional)
 * @return  window  object
 * @since       1.0
 */
function openPopup (sURL) {
    var sWidth, sHeight;
    var sFeatures;
    var oWindow;
    var SP2 = false;
    var POPUP_WIDTH     = 400;
    var POPUP_HEIGHT    = 300;
    var B_MAIN_PAGE     = true;

    sHeight = POPUP_HEIGHT;
    sWidth  = POPUP_WIDTH;
    sTitle = "PopupWindow";

    try {
      SP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
      if (arguments[1] != null && arguments[1] != "") sWidth = arguments[1] ;
      if (arguments[2] != null && arguments[2] != "") sHeight = arguments[2] ;
      if (arguments[3] != null && arguments[3] != "") sTitle = arguments[3] ;
      if (SP2)     {   // XP SP2 브라우저임..
        sHeight = Number(sHeight)+10;
      }else{  //그외 브라우저
      }
    } catch(e) {}
    
    if(sURL.indexOf("printPopup.jsp") > 0) {
    	sWidth = 760;
    }
    sFeatures =  "width=" + sWidth + ",height=" + sHeight ;
    sFeatures += ",left=0,top=0" ;
    if(sURL.indexOf("printPopup.jsp") > 0) {
    	sFeatures += ",directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no";
    } else {
    	sFeatures += ",directories=no,location=no,menubar=no,resizable=no,scrollbars=no,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();

    // move to screen center
    //oWindow.moveTo( (window.screen.availWidth - sWidth) / 2, (window.screen.availHeight - sHeight) / 2);

    return oWindow;
}

/**
 * open popup, window open을 이용, 인자전달 없음
 *
 * @param       sURL    url
 * @param       sWidth  window width(optional)
 * @param       sHeight window height(optional)
 * @return  window  object
 * @since       1.0
 */
function openPopupScroll (sURL) {
  var sWidth, sHeight;
  var sFeatures;
  var oWindow;
  var SP2 = false;
  var POPUP_WIDTH     = 400;
  var POPUP_HEIGHT    = 300;
  var B_MAIN_PAGE     = true;
  
  sHeight = POPUP_HEIGHT;
  sWidth  = POPUP_WIDTH;
  sTitle = "PopupWindow";
  
  try {
    SP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
    if (arguments[1] != null && arguments[1] != "") sWidth = arguments[1] ;
    if (arguments[2] != null && arguments[2] != "") sHeight = arguments[2] ;
    if (arguments[3] != null && arguments[3] != "") sTitle = arguments[3] ;
    if (SP2)     {   // XP SP2 브라우저임..
      sHeight = Number(sHeight)+10;
    }else{  //그외 브라우저
    }
  } catch(e) {}
  
  if(sURL.indexOf("printPopup.jsp") > 0) sWidth = 680;

  sFeatures =  "width=" + sWidth + ",height=" + sHeight ;
  sFeatures += ",left=0,top=0" ;
  sFeatures += ",directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no";
  
  if(sURL!=null && sURL.length > 0 && sURL.indexOf("printPopup.jsp") > 0) {
    if(sURL.indexOf("?") > 0) {
      sURL += "&thref="+encodeURI(location.href);
    } else {
      sURL += "?thref="+encodeURI(location.href);
    }
  }
  oWindow = window.open(sURL, sTitle, sFeatures);
  oWindow.focus();
  
  // move to screen center
  //oWindow.moveTo( (window.screen.availWidth - sWidth) / 2, (window.screen.availHeight - sHeight) / 2);
  
  return oWindow;
}

/**
* textarea 바이트체크
* @author 인터넷
* @param obj(textarea), iSize(byte), sId(textarea id)
* @return
*/
function char_length(obj, iSize, sId) {
  var tmpStr;
  var temp=0;
  var onechar;
  var tcount;
  tcount = 0;
  aquery = obj.value;
  tmpStr = new String(aquery);
  temp = tmpStr.length;
  
  for (k=0;k<temp;k++)
  {
    onechar = tmpStr.charAt(k);
    if (escape(onechar) =='%0D') { } else if (escape(onechar).length > 4) { tcount += 2; } else { tcount++; }
  }
  
  document.getElementById(sId).innerHTML = tcount;
  
  if(tcount>iSize) {
    reserve = tcount-iSize;
    alert(iSize+"Btye 以上は入力できません。.");
    cutText(obj, iSize, sId);
    return;
  }
}

/**
* textarea 바이트수  보여주기
* @author 인터넷
* @param obj(textarea), iSize(byte), sId(textarea id)
* @return
*/
function cutText(obj, iSize, sId){
  var tmpStr;
  var temp=0;
  var onechar;
  var tcount;
  tcount = 0;
  aquery = obj.value;
  tmpStr = new String(aquery);
  temp = tmpStr.length;
  
  for(k=0;k<temp;k++)
  {
    onechar = tmpStr.charAt(k);
    
    if(escape(onechar).length > 4) {
      tcount += 2;
    } else {
      // 엔터값이 들어왔을때 값(\r\n)이 두번실행되는데 첫번째 값(\n)이 들어왔을때 tcount를 증가시키지 않는다.
      if(escape(onechar)=='%0A') {
      } else {
        tcount++;
      }
    }
  
    if(tcount>iSize) {
      tmpStr = tmpStr.substring(0,k);
      break;
    }
  }
  obj.value = tmpStr;
  char_length(obj, iSize, sId);
}

/*
 * 팝업 자동 리사이징
 *  - 윈도 환경에 따라 사이즈가 다를 수 있습니다.
 *  - 팝업페이지의 스크립트 최하단에서 실행하십시오.
 *
 * (ex.) window.onload = function(){popupAutoResize();}
*/
/*
function popupAutoResize() {
  //window.resizeTo(arguments[0], 50);
  if ( navigator.userAgent.indexOf("Linux") < 0 ) {
    var thisX = parseInt(document.documentElement.scrollWidth);
    var thisY = parseInt(document.documentElement.scrollHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
    var SP2 = (navigator.appVersion.indexOf("MSIE 7.0") != -1);
   
    //alert(thisX + "===" + thisY);
    //alert("임시 브라우저 확인 : " + navigator.userAgent);
    // 브라우저별 높이 조절. (표준 창 하에서 조절해 주십시오.)
    if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 52;  
    else if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 29;  
    else if (navigator.userAgent.indexOf("MSIE 8") > 0) marginY = 80;   
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 82;   
    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;   
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  
    //window.resizeTo(arguments[0], thisY);
        
    if (SP2)     {   // XP SP2 브라우저임..
      marginY = Number(marginY)-23;
    }else{  //그외 브라우저
    }
    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
  //alert("thisY : " + thisY);   
    if (arguments[0] != null && arguments[0] != "") {
  //alert("arguments[0] : " + arguments[0]);
  //alert(thisY+marginY);    
      window.resizeTo(arguments[0], thisY+marginY);
    } else {
      window.resizeTo(thisX+8, thisY+marginY);
    }
    //window.resizeBy(0, 0);
    // 센터 정렬
    // var windowX = (screen.width - (thisX+10))/2;
    // var windowY = (screen.height - (thisY+marginY))/2 - 20;
    // window.moveTo(windowX,windowY);
  }
}
*/  

//리사이즈 문제있으면 원래함수로 복구하세요
function popupAutoResize() {
  if ( navigator.userAgent.indexOf("Linux") < 0 ) {
    var thisX = parseInt(document.documentElement.scrollWidth);
    var thisY = parseInt(document.documentElement.scrollHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
    //var SP2 = (navigator.appVersion.indexOf("MSIE 7.0") != -1);   
    //WindowsXP SP2
    if(navigator.userAgent.indexOf("MSIE 8") > 0) {
      marginY = 78;
    } else if(navigator.userAgent.indexOf("MSIE 7") > 0) {
      marginY = 78;                       
    } else if (navigator.userAgent.indexOf("MSIE 6") > 0) {
      marginY = 58;         
    } else if (navigator.userAgent.indexOf("Firefox") > 0) {
      marginY = 84;         
    } else if (navigator.userAgent.indexOf("Chrome") > 0) {
      marginY = 0;            
      thisX -= 8;     
    } else {
      marginY = 50;
    } 
    /*
    if (SP2) { 
      marginY = Number(marginY) - 23;
    }else{    
    }
    */
    //WindowsVISTA, Windows7
    if(navigator.userAgent.indexOf("Windows NT 6") > 0) { 
      if (navigator.userAgent.indexOf("MSIE") > 0) {
        marginY += 0;    
      } else if (navigator.userAgent.indexOf("Firefox") > 0) {
        marginY += -1;      
        thisX += 8;                
      } else if (navigator.userAgent.indexOf("Chrome") > 0) {
        marginY += 3;
      }   
    }
    //Windows2000
    if(navigator.userAgent.indexOf("Windows NT 5.0") > 0) {
      if (navigator.userAgent.indexOf("MSIE") > 0) {
        marginY -= 41;         
      } else if (navigator.userAgent.indexOf("Firefox") > 0) {
        marginY -= 3;      
      } 
    }
    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    if (arguments[0] != null && arguments[0] != "") {
      window.resizeTo(arguments[0], thisY+marginY);
    } else {
      window.resizeTo(thisX+8, thisY+marginY);
    }  
  }
}

/**
 * 글자수check
 * @param obj
 * @param max
 * @param checkMaxID
 * @return
 */
function displayStateData (targetID, displayState) {
  var targetArray = targetID.split('|');
  for( var i = 0; ( i < targetArray.length ) && targetArray[i] != '' ; i++ ){
    document.getElementById(targetArray[i]).style.display = displayState;
  }
}

/**
 * cookie
 * @param targetID
 * @return
 */
function setCookie(name,value,expiredays) {
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
  
function 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 "";
}

 /**
  * 쿠키 삭제
  * @param cookieName 삭제할 쿠키명
  */
function deleteCookie( cookieName )
{
  var expireDate = new Date();
  
  //어제 날짜를 쿠키 소멸 날짜로 설정한다.
  expireDate.setDate( expireDate.getDate() - 1 );
  document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}
/**
 * 글자수check
 * @param obj
 * @param max
 * @param checkMaxID
 * @return
 */
function checkMax(obj, max, checkMaxID){
  var sTxt = obj.value;
  if( sTxt.length > max ) {
    alert(max+'桁に限って入力してください。');
    obj.value = obj.value.substring(0, max );
    return false;
  }
  var sCheckMaxID = document.getElementById(checkMaxID);
  sCheckMaxID.innerHTML = sTxt.length;
  return true;
}

/**
 * 트리밍
 * @param str
 * @return
 */
function trim(str){
  //alert(str);
  str = str.replace(/^\s*/,'').replace(/\s*$/, '');
  return str;
}

/**
 * 첨부파일 다운로드
 * @param str
 * @return
 */
function fncDownload( arg1, arg2 ) {
 
  if ( !document.getElementById("fileDownloadForm") ) {
    fncCreateDownloadForm();
  }
  
  if ( document.getElementsByName("hFrame").length == 0 ) {
    fncCreateHiddenFrame();
  }
  
  document.getElementById("fileDownloadForm").action = "../../inc/download.jsp";
  document.getElementById("fileDownloadForm").dirName.value = arg1;
  document.getElementById("fileDownloadForm").fileName.value = arg2;
  document.getElementById("fileDownloadForm").target = "hFrame";
  document.getElementById("fileDownloadForm").submit();
}

/**
 * 다운로드 폼이 없을 경우 생성
 * @param str
 * @return
 */
function fncCreateDownloadForm() {
  var addHtml = "<form id=\"fileDownloadForm\" name=\"fileDownloadForm\" action=\"\" method=\"post\"><input id=\"dirName\" type=\"hidden\" name=\"dirName\"/> <input id=\"fileName\" type=\"hidden\" name=\"fileName\"/></form>";
  $(addHtml).appendTo("body");  
}

/**
 * HiddenFrame이 없을 경우 생성
 * @return
 */
function fncCreateHiddenFrame() {
  var addHiddenFrame = "<iframe name=\"hFrame\" src=\"\" frameborder=\"0\" width=\"0\" scrolling=\"no\" height=\"0\"></iframe>";
  $(addHiddenFrame).appendTo("body");  
}


function fncCreateDiv(id) {
  var addHiddenFrame = "<div id=\"popLayerContent"+id+"\""
+"style=\"position: absolute; top: 0px; left: 0px; z-index: 1000;\" >"
+"<iframe title=\"이벤트 알림\" name=\"popLay"+id+"\" id=\"popLay"+id+"\" src=\"#\" width=\"0px\""
+"height=\"0px\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\""
+"frameborder=\"0\"></iframe></div>";
  $(addHiddenFrame).appendTo("body");
  return true;
}
/**
 * add combobox list
 *
 * @param   oCombo      combo object
 * @param   sValue      combo data string
 * @param   sText       combo text string
 * @since   1.0
 */
function addCombo (oCombo, sValue, sText) {
    if (sValue == null || sValue == "") return;

    var optionElem = document.createElement("OPTION");
    optionElem.setAttribute("value", sValue);
    optionElem.appendChild(document.createTextNode(sText));

    eval(oCombo).appendChild(optionElem);
}

/**
 * remove combobox list
 *
 * @param   oCombo          combo object
 * @since   1.0
 */
function removeCombo (oCombo, idx) {
  var cntOption = eval(oCombo).getElementsByTagName("option");

  if ( idx < 0 || idx > (cntOption.length - 1 ) ) {
    return;
  }

  aCompare = (oCombo.options[idx].value).split(":");
  len = aCompare.length;
  for (i=0;i<len;i++){
    if ( i == 0 ) {
      if ( aCompare[i] == "U" ) {
        var DEL_FILE_LIST = document.createElement("input");
        DEL_FILE_LIST.type = "hidden"
        DEL_FILE_LIST.name = "DEL_FILE_LIST";
        DEL_FILE_LIST.setAttribute("name", "DEL_FILE_LIST");
        DEL_FILE_LIST.value = (oCombo.options[idx].value).replace("U:", "");
        document.forms['writeForm'].appendChild(DEL_FILE_LIST);
      } 
      oCombo.removeChild(cntOption[idx]);    
    }
  }
}

/**
 * remove combobox list
 *
 * @param   oCombo          combo object
 * @since   1.0
 */
function removeImageCombo (oCombo, idx) {
  var cntOption = eval(oCombo).getElementsByTagName("option");

  if ( idx < 0 || idx > (cntOption.length - 1 ) ) {
    return;
  }

  aCompare = (oCombo.options[idx].value).split(":");
  len = aCompare.length;
  for (i=0;i<len;i++){
    if ( i == 0 ) {
      if ( aCompare[i] == "U" ) {
        var DEL_IMAGE_LIST = document.createElement("input");
        DEL_IMAGE_LIST.type = "hidden"
        DEL_IMAGE_LIST.name = "DEL_IMAGE_LIST";
        DEL_IMAGE_LIST.setAttribute("name", "DEL_IMAGE_LIST");
        DEL_IMAGE_LIST.value = (oCombo.options[idx].value).replace("U:", "");
        document.writeForm.appendChild(DEL_IMAGE_LIST);
      } 
      oCombo.removeChild(cntOption[idx]);    
    }
  }
}
/**
 * remove combobox list
 *
 * @param   oCombo          combo object
 * @since   1.0
 */
function removePosterCombo (oCombo, idx) {
  var cntOption = eval(oCombo).getElementsByTagName("option");

  if ( idx < 0 || idx > (cntOption.length - 1 ) ) {
    return;
  }

  aCompare = (oCombo.options[idx].value).split(":");
  len = aCompare.length;
  for (i=0;i<len;i++){
    if ( i == 0 ) {
      if ( aCompare[i] == "U" ) {
        var DEL_POSTER_LIST = document.createElement("input");
        DEL_POSTER_LIST.type = "hidden"
        DEL_POSTER_LIST.name = "DEL_POSTER_LIST";
        DEL_POSTER_LIST.setAttribute("name", "DEL_POSTER_LIST");
        DEL_POSTER_LIST.value = (oCombo.options[idx].value).replace("U:", "");
        document.writeForm.appendChild(DEL_POSTER_LIST);
      } 
      oCombo.removeChild(cntOption[idx]);    
    }
  }
}
/**
 * remove combobox list
 *
 * @param   oCombo          combo object
 * @since   1.0
 */
function removeMainimageCombo (oCombo, idx) {
  var cntOption = eval(oCombo).getElementsByTagName("option");

  if ( idx < 0 || idx > (cntOption.length - 1 ) ) {
    return;
  }

  aCompare = (oCombo.options[idx].value).split(":");
  len = aCompare.length;
  for (i=0;i<len;i++){
    if ( i == 0 ) {
      if ( aCompare[i] == "U" ) {
        var DEL_MAINIMAGE_LIST = document.createElement("input");
        DEL_MAINIMAGE_LIST.type = "hidden"
        DEL_MAINIMAGE_LIST.name = "DEL_MAINIMAGE_LIST";
        DEL_MAINIMAGE_LIST.setAttribute("name", "DEL_MAINIMAGE_LIST");
        DEL_MAINIMAGE_LIST.value = (oCombo.options[idx].value).replace("U:", "");
        document.writeForm.appendChild(DEL_MAINIMAGE_LIST);
      } 
      oCombo.removeChild(cntOption[idx]);    
    }
  }
}

/**
 * file 삭제
 * @param path
 * @return
 */
function fileDelSubmit (path) {
  var frm = document.forms['writeForm'];
  if(frm.file_list.length == 0){
    alert('削除するファイルがありません。');
    return;
  }

  if(frm.file_list.selectedIndex == -1){
    alert('削除するファイルを選択してください。');
    return;
  }
  var fileID   = frm.file_list.options[frm.file_list.options.selectedIndex].value;
  var fileName = frm.file_list.options[frm.file_list.options.selectedIndex].innerHTML;

  hFrame.location.href = "../../inc/fileUploading.jsp?path="+path+"&fileID="+ encodeURI(fileID) + "&fileName="+ encodeURI(fileName);
}

/**
 * image 삭제
 * @param path
 * @return
 */
function imageDelSubmit (path) {
  var frm = document.writeForm;
  if(frm.image_list.length == 0){
    alert('削除するファイルがありません。');
    return;
  }

  if(frm.image_list.selectedIndex == -1){
    alert('削除するファイルを選択してください。');
    return;
  }
  var fileID   = frm.image_list.options[frm.image_list.options.selectedIndex].value;
  var fileName = frm.image_list.options[frm.image_list.options.selectedIndex].innerHTML;
  hFrame.location.href = "../../inc/imageUploading.jsp?path="+path+"&fileID="+ encodeURI(fileID) + "&fileName="+ encodeURI(fileName);
}
/**
 * poster 삭제
 * @param path
 * @return
 */
function posterDelSubmit (path) {
  var frm = document.writeForm;
  if(frm.poster_list.length == 0){
	alert('削除するファイルがありません。');
    return;
  }

  if(frm.poster_list.selectedIndex == -1){
	alert('削除するファイルを選択してください。');
    return;
  }
  var fileID   = frm.poster_list.options[frm.poster_list.options.selectedIndex].value;
  var fileName = frm.poster_list.options[frm.poster_list.options.selectedIndex].innerHTML;
  hFrame.location.href = "../../inc/posterUploading.jsp?path="+path+"&fileID="+ encodeURI(fileID) + "&fileName="+ encodeURI(fileName);
}
/**
 * mainimage 삭제
 * @param path
 * @return
 */
function mainimageDelSubmit (path) {
  var frm = document.writeForm;
  if(frm.mainimage_list.length == 0){
	alert('削除するファイルがありません。');
    return;
  }

  if(frm.mainimage_list.selectedIndex == -1){
	alert('削除するファイルを選択してください。');
    return;
  }
  var fileID   = frm.mainimage_list.options[frm.mainimage_list.options.selectedIndex].value;
  var fileName = frm.mainimage_list.options[frm.mainimage_list.options.selectedIndex].innerHTML;
  hFrame.location.href = "../../inc/mainimageUploading.jsp?path="+path+"&fileID="+ encodeURI(fileID) + "&fileName="+ encodeURI(fileName);
}

/**
 * file 첨부 후 
 * @param fileID
 * @param fileName
 * @return
 */
function afterFileSave(fileID, fileName){
  var frm = document.forms['writeForm'];
  addCombo(frm.file_list, fileID, fileName);
}

/**
 * file 삭제 후 
 * @param file_list
 * @param idx
 * @return
 */
function afterFileDelete(file_list, idx){
  if ( file_list == null || file_list == "" ) {
    file_list = document.forms['writeForm'].file_list;
  }
  if ( idx == null || idx == "" ) {
    idx = file_list.options.selectedIndex;
  }
  removeCombo(file_list, idx);
}
 
/**
 * image 첨부 후 
 * @param fileID
 * @param fileName
 * @return
 */
function afterImageSave(fileID, fileName){
  var frm = document.writeForm;
  addCombo(frm.image_list, fileID, fileName);
}

/**
 * image 삭제 후 
 * @param image_list
 * @param idx
 * @return
 */
function afterImageDelete(image_list, idx){
  if ( image_list == null || image_list == "" ) {
    image_list = document.writeForm.image_list;
  }
  if ( idx == null || idx == "" ) {
    idx = image_list.options.selectedIndex;
  }
  removeImageCombo(image_list, idx);
}
/**
 * poster 첨부 후 
 * @param fileID
 * @param fileName
 * @return
 */
function afterPosterSave(fileID, fileName){
  var frm = document.writeForm;
  addCombo(frm.poster_list, fileID, fileName);
}
/**
 * mainimage 첨부 후 
 * @param fileID
 * @param fileName
 * @return
 */
function afterMainimageSave(fileID, fileName){
  var frm = document.writeForm;
  addCombo(frm.mainimage_list, fileID, fileName);
}
/**
 * poster 삭제 후 
 * @param poster_list
 * @param idx
 * @return
 */
function afterPosterDelete(poster_list, idx){
  if ( poster_list == null || poster_list == "" ) {
    poster_list = document.writeForm.poster_list;
  }
  if ( idx == null || idx == "" ) {
    idx = poster_list.options.selectedIndex;
  }
  removePosterCombo(poster_list, idx);
}
/**
 * mainimage 삭제 후 
 * @param mainimage_list
 * @param idx
 * @return
 */
function afterMainimageDelete(mainimage_list, idx){
  if ( mainimage_list == null || mainimage_list == "" ) {
    mainimage_list = document.writeForm.mainimage_list;
  }
  if ( idx == null || idx == "" ) {
    idx = mainimage_list.options.selectedIndex;
  }
  removeMainimageCombo(mainimage_list, idx);
}
/**
 * 폼 전송 전에 file list 생성  
 * 형식은 (모드):VALUE:TEXT|의 반복
 * @param obj(form)
 * @param input(select)
 * @return
 */
function fileListEdit(obj, input){
  var FILE_LIST = document.createElement("input");
  FILE_LIST.type = "hidden"
  FILE_LIST.id = "FILE_LIST";
  FILE_LIST.name = "FILE_LIST";
  FILE_LIST.setAttribute("name", "FILE_LIST");
  FILE_LIST.value = "";
  obj.appendChild(FILE_LIST);
  
  var file_list = input;
  var fOption = file_list.getElementsByTagName("option");
  FILE_LIST.value = "";
  for(var i=0;i<fOption.length;i++){
    FILE_LIST.value = FILE_LIST.value + fOption[i].value+":"+fOption[i].innerHTML;
    FILE_LIST.value = FILE_LIST.value + "|";
  }
  return true;
}

 
/**
 * 폼 전송 전에 image list 생성  
 * 형식은 (모드):VALUE:TEXT|의 반복
 * @param obj(form)
 * @param input(select)
 * @return
 */
function imageListEdit(obj, input){
  var IMAGE_LIST = document.createElement("input");
  IMAGE_LIST.type = "hidden"
  IMAGE_LIST.id = "IMAGE_LIST";
  IMAGE_LIST.name = "IMAGE_LIST";
  IMAGE_LIST.setAttribute("name", "IMAGE_LIST");
  IMAGE_LIST.value = "";
  obj.appendChild(IMAGE_LIST);
  
  var image_list = input;
  var fOption = image_list.getElementsByTagName("option");
  IMAGE_LIST.value = "";
  for(var i=0;i<fOption.length;i++){
    IMAGE_LIST.value = IMAGE_LIST.value + fOption[i].value+":"+fOption[i].innerHTML;
    IMAGE_LIST.value = IMAGE_LIST.value + "|";
  }
  return true;
}

/**
 * 폼 전송 전에 poster list 생성  
 * 형식은 (모드):VALUE:TEXT|의 반복
 * @param obj(form)
 * @param input(select)
 * @return
 */
function posterListEdit(obj, input){
  var POSTER_LIST = document.createElement("input");
  POSTER_LIST.type = "hidden"
  POSTER_LIST.id = "POSTER_LIST";
  POSTER_LIST.name = "POSTER_LIST";
  POSTER_LIST.setAttribute("name", "POSTER_LIST");
  POSTER_LIST.value = "";
  obj.appendChild(POSTER_LIST);
  
  var poster_list = input;
  var fOption = poster_list.getElementsByTagName("option");
  POSTER_LIST.value = "";
  for(var i=0;i<fOption.length;i++){
    POSTER_LIST.value = POSTER_LIST.value + fOption[i].value+":"+fOption[i].innerHTML;
    POSTER_LIST.value = POSTER_LIST.value + "|";
  }
  return true;
}
/**
 * 폼 전송 전에 mainimage list 생성  
 * 형식은 (모드):VALUE:TEXT|의 반복
 * @param obj(form)
 * @param input(select)
 * @return
 */
function mainimageListEdit(obj, input){
  var MAINIMAGE_LIST = document.createElement("input");
  MAINIMAGE_LIST.type = "hidden"
  MAINIMAGE_LIST.id = "MAINIMAGE_LIST";
  MAINIMAGE_LIST.name = "MAINIMAGE_LIST";
  MAINIMAGE_LIST.setAttribute("name", "MAINIMAGE_LIST");
  MAINIMAGE_LIST.value = "";
  obj.appendChild(MAINIMAGE_LIST);
  
  var mainimage_list = input;
  var fOption = mainimage_list.getElementsByTagName("option");
  MAINIMAGE_LIST.value = "";
  for(var i=0;i<fOption.length;i++){
    MAINIMAGE_LIST.value = MAINIMAGE_LIST.value + fOption[i].value+":"+fOption[i].innerHTML;
    MAINIMAGE_LIST.value = MAINIMAGE_LIST.value + "|";
  }
  return true;
}

 /**
 *  Ajax 이용한 로그인 구현
 *
 *
 *
 */
 function loginCheckAjax() {   
   var sMenuID = "";
   if ( $("#mySiteID").val() ) {
	   sMenuID = $("#mySiteID").val(); 
   }
   $.post("../../main/loginCheckAjax.jsp", { menuID : sMenuID },
        function(msg) {
          if ( jQuery.trim(msg) == "login" ) {
            $(".loginStatus").css("display","inline");
            $(".logoutStatus").css("display","none");
            $(".loginBlock").css("display","block");
            $(".logoutBlock").css("display","none");
            $("#logout").css("display","inline");
            $("#login").css("display","none");
          } else if ( jQuery.trim(msg) == "logout" ) {            
            $(".logoutStatus").css("display","inline");
            $(".loginStatus").css("display","none");
            $(".logoutBlock").css("display","block");
            $(".loginSBlock").css("display","none");
            $(".loginBlock").css("display","none");
            $("#login").css("display","inline");
            $("#logout").css("display","none");
            $(".moologinStatus").css("display","none");
          } else if ( jQuery.trim(msg) == "mooMember" ) {  /* webzine moo */          
        	  $(".loginStatus").css("display","inline");
              $(".logoutStatus").css("display","none");
              $(".loginBlock").css("display","block");
              $(".logoutBlock").css("display","none");
              $("#logout").css("display","inline");
              $("#login").css("display","none");
              $(".moologinStatus").css("display","inline");
          }
        });
 } 
 $(document).ready(loginCheckAjax);

 
 
 /**
  *  Ajax 이용한 로그인 구현
  *
  *
  *
  */
 function artMemberLoginCheckAjax() {
   $.post("../../program/artMember/artMemberLoginCheckAjax.jsp",function(data){
     if ( jQuery.trim(data) == "login" ) {
       $(".loginStatus").css("display","inline");
       $(".logoutStatus").css("display","none");
     } else if ( jQuery.trim(data) == "logout" ) {            
       $(".logoutStatus").css("display","inline");
       $(".loginStatus").css("display","none");       
     }
   });      
 }
 
 /**
  * 
  */
 function fncLoginCheckMypage(id) {   
   if ( id == '' ) {
     if(confirm("ログインしてから使用することができます。\n ログインのページに移動しますか。")){
         //var link = location.href; 
         var link = "/program/mypage/mypage.jsp?menuID=102003";
         link = link.replace(/&/gi, "$");          
         link = link.replace(/\?/gi, "@");          
                   
         location.replace("../../program/member/login.jsp?menuID=001011001&thref="+link);
     }   
     return ;
   }else{
     location.replace("../../program/mypage/mypage.jsp?menuID=102003");
   }
 } 
 
 function fncLoginCheck() {
	 alert("ログインしてください。");
	 var link = location.href;
	 
	 link = link.replace(/&/gi, "$");          
	 link = link.replace(/\?/gi, "@");          
	           
	 location.replace("../../program/member/login.jsp?menuID=001011001&thref="+link);
 }
 
 function fncLogin() {
   var link = location.href;
   
   link = link.replace(/&/gi, "$");          
   link = link.replace(/\?/gi, "@");          
             
   location.replace("../../program/member/login.jsp?menuID=001011001&thref="+link);
 }
 
 function fncLogout(){
   var link = location.href;
   
   link = link.replace(/&/gi, "$");          
   link = link.replace(/\?/gi, "@");          
             
   location.replace("../../program/publicMember/memberLogout.jsp?menuID=102002&thref="+link); 
 }

 /**
  * 이미지리사이즈
  * 이미지를 둘러싸고있는   객체ID, 축소할가로사이즈, 축소할세로사이즈
  * IMG태그에 width,height주지말고, style="display:none;" 으로 세팅
  * @param targetID, targetWidth, targetHeight
  * @return
  */
  function imageResize(targetID ,targetWidth, targetHeight){    
    if (document.getElementById(targetID) != null) {      
      var images = document.getElementById(targetID).getElementsByTagName('IMG');
      var newWidth;
      var newHeight;
      for ( var i = 0; i < images.length; i++) {
    	if ( images[i].style.display == 'none' ) {
	        images[i].style.display = "";
	        var originalWidth = images[i].width;
	        var originalHeight = images[i].height;
	        
	        if ( originalWidth < targetWidth && originalHeight < targetHeight ) {
	          newWidth = originalWidth;
	          newHeight =  originalHeight;
	        } else {
	          if ( images[i].width > images[i].height ) {
	            newWidth = targetWidth;
	            newHeight = Math.ceil(images[i].height * targetWidth / images[i].width);
	          } else if ( images[i].width <= images[i].height ) {
	            newWidth = Math.ceil(images[i].width * targetHeight / images[i].height);
	            newHeight = targetHeight;
	          } else {
	            newWidth = targetWidth;
	            newHeight = targetHeight;
	          }
	          if( newWidth > targetWidth ) {
	            newWidth = targetWidth;
	            newHeight = Math.ceil(images[i].height * targetWidth / images[i].width);
	          }
	          if( newHeight > targetHeight ) {
	            newWidth = Math.ceil(images[i].width * targetHeight / images[i].height);
	            newHeight = targetHeight;
	          }
	        }
	        images[i].width = newWidth;
	        images[i].height = newHeight;
	      }
      }
    }
  }

  function imageResizeTwo(targetID ,targetWidth, targetHeight){    
    if (document.getElementById(targetID) != null) {      
      var images = document.getElementById(targetID).getElementsByTagName('IMG');
      var newWidth;
      var newHeight;
      for ( var i = 0; i < images.length; i++) {
    	if ( images[i].style.display == 'none' ) {
	        images[i].style.display = "";
	        var originalWidth = images[i].width;
	        var originalHeight = images[i].height;
	        
	        if ( originalWidth < targetWidth && originalHeight < targetHeight ) {
	          newWidth = originalWidth;
	          newHeight =  targetHeight;
	        } else {
	          if ( images[i].width > images[i].height ) {
	            newWidth = targetWidth;
	            newHeight = targetHeight;
	          } else if ( images[i].width <= images[i].height ) {
	            newWidth = Math.ceil(images[i].width * targetHeight / images[i].height);
	            newHeight = targetHeight;
	          } else {
	            newWidth = targetWidth;
	            newHeight = targetHeight;
	          }
	          if( newWidth > targetWidth ) {
	            newWidth = targetWidth;
	            newHeight = targetHeight;
	          }
	          if( newHeight > targetHeight ) {
	            newWidth = Math.ceil(images[i].width * targetHeight / images[i].height);
	            newHeight = targetHeight;
	          }
	        }
	        images[i].width = newWidth;
	        images[i].height = newHeight;
	      }
      }
    }
  }

  /**
   * 에디터에서 호스트 삭제
   * @author: 서경대
   * @param: 
   * @return
   */
  function replaceHost(content, sUserURL) {  
    var reg = new RegExp("\\/","g");  
    sUserURL = sUserURL.replace(reg, "\\/");
    
    reg = new RegExp(sUserURL,"g");  
    content = content.replace(reg,"../../");
    // img, br 종료 처리
    reg = new RegExp("(<[img|br][^>]{0,}[^/])>","ig");  
    content = content.replace(reg,"$1/>");
    // TAB toLowerCase 처리
    reg = new RegExp("(<[A-Z/]{0,}[> ])","g");  
    content = content.replace(reg, function($1){return $1.toLowerCase();});
    // class \" 처리
    reg = new RegExp("( [a-zA-Z]{1,}=)([a-zA-Z0-9-_]{1,})","gi");  
    content = content.replace(reg, "$1\"$2\"");
    
    // ID관련 변경
    content = content.replace("menuid","menuID");
    content = content.replace("boardtypeid","boardTypeID");
    
    return content;
  }

  /**
   * 우편번호검색 팝업 
   * @author: 조지은
   * @param: zipcodeobj
   * @param: addr1obj
   * @param: addr2obj
   * @return
   */
  function zipcodeSearch(zipcodeobj, addr1obj, addr2obj){
    var sUrl = "../../inc/zipcode/findZipcode.jsp?zipcodeobj="+zipcodeobj+"&addr1obj="+addr1obj+"&addr2obj="+addr2obj;
    openPopup(encodeURI(sUrl), 540, 520, "zipcode");
  }
  
  
  /**
   * 우편번호검색 팝업 
   * @author: 김준철
   * @param: zipcodeobj
   * @param: addr1obj
   * @param: addr2obj
   * @return
   */
  function zipcodeSearch2(zipcodeobj1, zipcodeobj2, addr1obj, addr2obj){
    var sUrl = "../../inc/zipcode/findZipcode.jsp?zipcodeobj1="+zipcodeobj1+"&zipcodeobj2="+zipcodeobj2+"&addr1obj="+addr1obj+"&addr2obj="+addr2obj;
    openPopup(encodeURI(sUrl), 540, 520, "zipcode");
  }
  
  /**
   * 우편번호세팅 
   * @author: 조지은
   * @param: zipcode
   * @param: addr
   * @param: edps
   * @param: zipcodeobj
   * @param: addr1obj
   * @param: addr2obj
   * @return
   */
  function setZipInfo(zipcode, addr, edps, zipcodeobj, addr1obj, addr2obj){
    if ( document.getElementById(zipcodeobj) ) {
      document.getElementById(zipcodeobj).value = zipcode;
    }
    if ( document.getElementById(addr1obj) ) {
      document.getElementById(addr1obj).value = addr;
    }
    if ( document.getElementById(addr2obj) ) {
      document.getElementById(addr2obj).value = "";
      //document.getElementById(addr2obj).value = edps;
      document.getElementById(addr2obj).focus();
    }
  }
  
  /**
   * 우편번호세팅 
   * @author: 조지은
   * @param: zipcode
   * @param: addr
   * @param: edps
   * @param: zipcodeobj
   * @param: addr1obj
   * @param: addr2obj
   * @return
   */
  function setZipInfo2(zipcode, addr, edps, zipcodeobj1, zipcodeobj2, addr1obj, addr2obj){
    if ( document.getElementById(zipcodeobj1) ) {
      document.getElementById(zipcodeobj1).value = zipcode.substring(0,3);
    }
    if ( document.getElementById(zipcodeobj2) ) {
        document.getElementById(zipcodeobj2).value = zipcode.substring(4,7);
      }
    if ( document.getElementById(addr1obj) ) {
      document.getElementById(addr1obj).value = addr;
    }
    if ( document.getElementById(addr2obj) ) {
      document.getElementById(addr2obj).value = "";
      //document.getElementById(addr2obj).value = edps;
      document.getElementById(addr2obj).focus();
    }
  }
  
  /**
   * 라디오버튼의 선택된값   RETURN
   * @param targetID
   * @return 선택된radio object값
   */
  function getCheckedValue( targetID ){
    var radioObject = document.getElementsByName(targetID);
    var checkedValud = '-1';
    for( var i = 0; i < radioObject.length; i++ ){
      if( radioObject[i].checked == true ){
        checkedValud = radioObject[i].value;
      }
    }
    return checkedValud;
  }

  /**
   * tag
   * @param groupid
   * @param objectid
   * @param articleid
   * @param menuid
   * @param type
   * @param mode
   * @return
   */
  function fncTagPopup(groupid, objectid, articleid, menuid, type, mode) {
    var sUrl = "../../inc/tagPopup.jsp?groupID="+groupid+"&objectID="+objectid+"&articldID="+articleid+"&menuID="+menuid+"&type="+type+"&mode="+mode;
    PopUp(encodeURI(sUrl), "tag", 560, 200);
  }

  function getH() {

    var h=0;

    if (navigator.userAgent.indexOf("SV1") > 0){  h=14; }
    else if(navigator.userAgent.indexOf("NT 5.0") > 0){  h=14; }
    else if(navigator.userAgent.indexOf("MSIE 7")>0) { h=45; }
    else if(navigator.userAgent.indexOf("Gecko")>0 && navigator.userAgent.indexOf("Firefox") <= 0 && navigator.userAgent.indexOf("Netscape") <= 0 ){ h=22; }
    else if(navigator.userAgent.indexOf("Firefox") >0 ){  h=18; } 
    else if(navigator.userAgent.indexOf("Netscape") >0 ){ h=-2; }
    else { h=0;} 
   
    return parseInt(h);
  }
  function PopUp(url, winName, xx, yy) {
    window.open(url,winName,'width='+ xx +',height='+ (yy+getH()) +',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
  } 

function phoneCheck(phone, phone1, phone2, phone3){
  if(phone1 != "" && phone2 != "" && phone3 != ""){
    phone.value = phone1 + "-" + phone2 + "-" + phone3;
  }
}

/**
 * display변경
 * @param targetID
 * @return
 */

function displayData (targetID) {
  var obj = document.getElementById(targetID);
  if ( obj.style.display == "none" ){
  obj.style.display = "";
  } else {
  obj.style.display = "none";
  }
}

// objname이 있는 checkbox들의 체크된 값들을 값|값|... 의 형태로 만들어 resultobjid를 가진 객체의 값으로 만든다
function fncCheckValue(objname, resultobjid){
  var obj = document.getElementsByName(objname);
  document.getElementById(resultobjid).value = "";
  for ( i = 0; i < obj.length; i++ ) {
    if ( obj[i].checked ) {
      document.getElementById(resultobjid).value += obj[i].value;
      if ( i < obj.length -1 ) {
        if ( document.getElementById(resultobjid).value != "" ) {
          document.getElementById(resultobjid).value += "|";
        }
      }
    }
  }
}  

// selectobjid가 있는 select의 text들을 text|text|...의 형태로 만들어 resultobjid를 가진 객체의 값으로 만든다.
function fncSelectValue(selectobjid,resultobjid){
  var selectobj = document.getElementById(selectobjid);
  var fOption = selectobj.getElementsByTagName("option");
  var resultobj = document.getElementById(resultobjid);
  resultobj.value = "";
  for ( var i = 0; i < fOption.length; i++ ) {
    resultobj.value = resultobj.value + fOption[i].innerHTML;
    if ( i < fOption.length-1 ) {
      if ( resultobj.value != "" ) {
        resultobj.value = resultobj.value + "|";
      }
    }
  }
}

// 텍스트 합성 resultobjid.value = objid1.value + op + objid2.value
function fncAddText(resultobjid, objid1, objid2) {
  var op = ":";
  if ( arguments[3] != null && arguments[3] != "" ) {
    op = arguments[3];
  }
  if ( document.getElementById(objid1).value != "" && document.getElementById(objid2).value != "" ) {
    document.getElementById(resultobjid).value = document.getElementById(objid1).value + op + document.getElementById(objid2).value; 
  } else {
    document.getElementById(resultobjid).value = "";
  }
}

// obj1 onchange시 obj2에 obj1.selectedIndex의 value
function fncEmailSet(obj1, obj2){
  if ( obj1.selectedIndex > -1 ) {
    obj2.value = obj1.options[obj1.selectedIndex].value;
  }
}
//동적 SELECTBOX 구현을 위한 사용자 함수  
(function($) {    //SELECT OPTION 삭제
    $.fn.emptySelect = function() {       
        return this.each(function(){         
            if (this.tagName=='SELECT'){ 
              this.options.length = 0;  
            }
        });    
    }     //SELECT OPTION 등록
    $.fn.loadSelect = function(optionsDataArray,defaultValue) {       
        return this.emptySelect().each(function(){         
          if (this.tagName=='SELECT') {             
            var selectElement = this;             
            if(optionsDataArray.length > 0 && defaultValue != null && defaultValue != ""){
              selectElement.add(new Option(defaultValue,""));  
            }
            $.each(optionsDataArray,function(idx, optionData){                 
                var option = new Option(optionData.key, optionData.value);                 
                if ($.browser.msie) {                     
                  selectElement.add(option);                 
                } else {                     
                  selectElement.add(option,null);                 
                }             
            });         
          }      
        });    
    }
    $.fn.loadForm = function(formDataArray){
      alert("checkloadForm");
    }  
})(jQuery);

function openURL(url) {
  if(url == ''){
    alert('URLが正しくないです。');
    return false;
  }
  window.open(url,name,'width=1000px,height=700px,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,status=yes');
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() {//v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function copyUrl(id) {
  var curl = $("#"+id).attr("href");   
  window.clipboardData.setData('Text', curl);   
  alert ("URLをコピしました。"); 
}

function copyThisPageUrl() {
  if ($.browser.msie) {
    var curl = location.href;  
    window.clipboardData.setData('Text', curl);   
    alert ("URLをコピしました。");
  } else {
    alert("URLのコピ機能ができないブラウザーです。");
  }
  return false;
}

$(document).ready( function() {
  if(document.getElementById("rsslist")){    
    $("#rsslist").appendTo("body");  
    $("#rsslist").css("position","absolute");     
    $(".sl_td > A :odd").bind("click", xypos);
    $(document).click(function(e){      
      if($("#rsslist").css("visibility")=="visible" && !$(e.target).hasClass("rsslist") && $(e.target).attr("id")!='rsslist'){
        layer_hidden();
      }else{        
      }
    });
  }
  $("#zoomIn").bind("click", zoomIn);
  $("#zoomOut").bind("click", zoomOut);
  $("#zoomZero").bind("click", zoomZero);
  $("#zoomZero").css("cursor", "pointer");
});
var fSize = 12;
function zoomIn() {
  if( fSize < 25){
    fSize++;
    $("#zoomZone").css("font-size", fSize+"px");
    return false;    
  }else {
    alert("더이상 커질 수 없습니다.");
  }
}

function zoomZero() { 
  fSize = 12;
  $("#zoomZone").css("font-size", fSize+"px");
  return false;
}

function zoomOut() {
  if( fSize > 12){    
    fSize--;
    $("#zoomZone").css("font-size",fSize+"px");
    return false;
  } else {
    alert("더이상 줄일수 없습니다.");
    return false;
  }
}

function fncPrintPopup() {
  alert($(this).attr("href"));
  return false;
}

function xypos(e){
  
  var dd = document.documentElement; //최신버전의 브라우저들
  var db = document.body;//구 버전의 브라우저들

  var scrollLeft=0;scrollTop=0;

  if(dd){
      scrollLeft+=dd.scrollLeft;
      scrollTop+=dd.scrollTop;
  }

  else if(db){
      scrollLeft+=db.scrollLeft;
      scrollTop+=db.scrollTop;
  }

  var mouseX = e.clientX;

  var mouseY = e.clientY;

  if(dd){
      mouseX+=dd.scrollLeft;
      mouseY+=dd.scrollTop;
  }else if(db){
      mouseX+=db.scrollLeft;
      mouseY+=db.scrollTop;
  }
  
  var left = 0;
  var top = 0;
  
  left = mouseX - 10;
  top  = mouseY - 10; 
    
  $("#rsslist").css({"left":left+"px"});
  $("#rsslist").css({"top":top+"px"});
  
  var temp = $(e.target).attr("id");
  var urlID = $("#board"+temp).attr("href");

  $("#rsslist>ul>li>A").eq(0).attr("href",urlID);    
  $("#rsslist>ul>li>A").eq(1).attr("href","http://blog.daum.net/_blog/rss/ManagerChannelInsertForm.do?channelUrl="+urlID+"&channelCheck=true&event=t");    
  $("#rsslist>ul>li>A").eq(2).attr("href","http://www.hanrss.com/add_sub.qst?url="+urlID);
  $("#rsslist>ul>li>A").eq(3).attr("href","http://fusion.google.com/add?feedurl="+urlID);
  //$("#rsslist>ul>li>A").eq(4).attr("href","http://blog.daum.net/_blog/rss/ManagerChannellnesrtForm.do?channelCheck=true&event=t&channelUrl=board"+urlID);
  $("#rsslist>ul>li>A").eq(4).attr("href","http://wzd.com/subscribe?"+urlID);
  $("#rsslist>ul>li>A").eq(5).attr("href","http://www.bloglines.com/sub/"+urlID);
    
  MM_showHideLayers('rsslist',' ','show');
  return false;
}

function layer_hidden() {
  MM_showHideLayers('rsslist',' ','hidden');  
}


function onlyNumber(e){
  evt = e || window.event;
  var keyCode = (window.netscape) ? evt.which : evt.keyCode;
  if(  
  (keyCode >= 48 && keyCode <=57) ||  // 중간 숫자키
  (keyCode >= 37 && keyCode <=40) || // 중간화살표 
  keyCode == 9 || keyCode == 8 || keyCode == 46 || keyCode == 0 || // 탭, 백스페이스, DELETE, 탭 
  keyCode == 109 || keyCode == 189 || keyCode == 45 // 오른쪽 -, 중간 -
  ){    
  }else{
      if (window.netscape){
        evt.preventDefault();
      } else{
        evt.returnValue=false;
      } 
  }
}

function resize_frame(obj){   
  var obj_document = obj.contentWindow.document;
  if( navigator.appVersion.indexOf("MSIE 6") > -1 ||  navigator.appVersion.indexOf("MSIE 7") > -1){
    obj.style.height = obj_document.body.scrollHeight;
  } else {
    obj.style.height = Number(obj_document.documentElement.scrollHeight) + Number(400) + 'px';
  }
}

function my_album(objID){    
  
  if ($(objID+":animated").size()) return false;
  var width = $(objID).attr("width");
  var pos = (parseInt($(objID).attr("top"))+1);    
  var px = pos * width;      
  $(objID).attr("top", pos);
  $(objID).animate({ 
    left: ((px * -1) + "px")
  }, 1500, $(objID).attr("motion"), 
    function() {
      var pos = parseInt($(objID).attr("top"));
      var total = parseInt($(objID).attr("total"));
      
      if (pos>=total) {
        $(objID).attr("top", 0);
        $(objID).css("left", "0px");
      }
    }
  );
}

function my_albumBack(objID){    
  
  if ($(objID+":animated").size()) return false;
  var width = $(objID).attr("width");
  var pos = (parseInt($(objID).attr("top"))-1);    
  var px = pos * width;      
  $(objID).attr("top", pos);
  $(objID).animate({ 
    left: ((px * -1) + "px")
  }, 1500, $(objID).attr("motion"), 
    function() {
      var pos = parseInt($(objID).attr("top"));
      var total = parseInt($(objID).attr("total"));
      
      if (pos>=total) {
        $(objID).attr("top", 0);
        $(objID).css("left", "0px");
      }
    }
  );
}

function nextBanner(mode){    
  clearInterval($("#banner").attr("timer"));
  if ( mode == "right" ) {      
      my_album("#banner");      
  } else if ( mode == "left" ) {      
    if( parseInt($("#banner").attr("top")) == 0 ) {
      alert('最初です。もっと前には移動できません。');
    } else {
      my_albumBack("#banner");
    }
  }
  $("#banner").attr("timer", setInterval("my_album('#banner')", 3000));
}

  /* 셀렉트박스 IE6 버그 해결을 위한 DIV*/
  function showHideDivSelect(divID,blank,type){
    showHide(divID,blank,type);
    if ( type == "show" ) {
      hideSelect(divID);
    }else if ( "hide" ) {
      showSelect(divID);
    }
  }  
  
//팝업 설정
function pcenter_s_yes(theURL, name,  width, height ){
  var x = (screen.width) ? (screen.width-width)/2 : 0;
  var y = (screen.height) ? (screen.height-height)/2 : 0;  
  var pop = window.open(theURL,name,"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height+",left="+x+",top="+y);
  //pop.focus;
}

function showCoreMenu(menuCoreUrl) {
  $("#menuCore").load(menuCoreUrl); 
  showHide('menuCore', '', 'show');
  hideSelect("#menuCore");
}

/*IE6에서 셀렉트 박스가 DIV위로 올라가는 문제해결을 위한 설정(나타내기)
 * 작성자 : 서경대
 * 작성일 : 2009.09.24
 * */
function showSelect(objID){
  $("select").css("visibility","visible");
}

/*IE6에서 셀렉트 박스가 DIV위로 올라가는 문제해결을 위한 설정(숨기기)
 * 작성자 : 서경대
 * 작성일 : 2009.09.24
 * */
function hideSelect(objID){
  $("select").css("visibility","hidden");
  $("#" + objID + " select").css("visibility","visible");  
}  
//Http:// 제거
function replaceHttp(str){ 
  str = str.replace(/http:\/\//gi, "");
  return str;
}
function makeSelectGIS(addressID, codeID, selectVal) {  
  $("#addrSelect").append( $("<select>").attr("id", "sidoListG") )
          .append( $("<select>").attr("id", "guListG") )
          .append( $("<select>").attr("id", "dongListG") )
          .append( $("<input>").attr("type", "hidden").attr("id", addressID) )          
          .append( $("<input>").attr("type", "text").attr("id", "addressID2").addClass("txt txtSize1") )
          .append(" 番地")
          .append( $("<input>").attr("type", "hidden").attr("id", codeID));
  requestLevel1(selectVal);
  $("#sidoListG").bind("change", function() { requestLevel2(); } );
  $("#guListG").bind("change", function() { requestLevel3(); } );
  $("#dongListG").bind("change", function() { insertAddressCode(); } );
  $("#addressID2").bind("change", function() { insertAddressCode(); } );
}
function requestLevel1(selectVal) {
  var defaultValue = "28";
  if ( selectVal ) {
    defaultValue = selectVal.substring(0, 2);
  }
  
  $("#sidoListG").ajaxAddOption("../../program/weather/top.json.txt", {}, false, function() { $("#sidoListG").selectOptions(defaultValue, true); requestLevel2(selectVal); } );   
}

function requestLevel2(selectVal) {
  var defaultValue = "28200";
  if ( selectVal ) {
    defaultValue = selectVal.substring(0, 5);
  }
  
  $("#guListG").removeOption(/./);
  $("#guListG").ajaxAddOption("../../program/weather/json/"+$("#sidoListG").selectedValues(), {}, false, function() { $("#guListG").selectOptions(defaultValue, true); requestLevel3(selectVal); } );   
}
function requestLevel3(selectVal) {
  var defaultValue = "2820051000";
  if ( selectVal ) {
    defaultValue = selectVal.substring(6, 16);
  }
  $("#dongListG").removeOption(/./);
  $.getJSON("../../program/weather/json2/"+$("#guListG").selectedValues(), function(data) {
    $.each(data, function(i, item){       
        $("#dongListG").addOption(item.code, item.value);           
          }); 
    
    $("#dongListG").selectOptions(defaultValue, true);    
    insertAddressCode(selectVal);
  } );
}
function insertAddressCode(selectVal) {
  if ( selectVal ) {
    $("#addressID2").val(selectVal.split("&")[2]);
  }
  $("#addrSelect>input:first").val( $("#sidoListG").selectedTexts() + " " + $("#guListG").selectedTexts() + " " + $("#dongListG").selectedTexts() + " " + $("#addressID2").val());  
  $("#addrSelect>input:last").val( $("#guListG").selectedValues() + "&" + $("#dongListG").selectedValues() + "&" + $("#addressID2").val());
}

function checkSearch(searchID){
  if ( $("#search"+searchID).val() == '' ) {
    alert("検索語を入力してください。");
    document.getElementById("search" + searchID).focus();
    return false;
  } else {
    document.getElementById("searchForm" + searchID).submit();
  }
}

// 웹로그를 위한 쿠키 생성 시작
function Nethru_getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function Nethru_SetCookie(name, value){
   var argv = Nethru_SetCookie.arguments;
   var argc = Nethru_SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;

  // alert("DOMAIN = " + domain);
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires="+expires.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");

//	alert(document.cookie);
}

function Nethru_GetCookie(name){
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return Nethru_getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0)
         break;
      }
  return null;
}

function Nethru_makePersistentCookie(name,length,path,domain)
{
    var today = new Date();
    var expiredDate = new Date(2011,1,1);
    var cookie;
	var value;

    cookie = Nethru_GetCookie(name);
    if ( cookie ) {
//		alert(cookie);
        return 1;
	}

	var values = new Array();
	for ( i=0; i < length ; i++ ) {
		values[i] = "" + Math.random();
	}

	value = today.getTime();

	// use first decimal
	for ( i=0; i < length ; i++ ) {
		value += values[i].charAt(2);
	}

    Nethru_SetCookie(name,value,expiredDate,path,domain);
}

function Nethru_getDomain() {
	var _host   = document.domain;
	var so      = _host.split('.');
	var dm    = so[so.length-2] + '.' + so[so.length-1];
	return (so[so.length-1].length == 2) ? so[so.length-3] + '.' + dm : dm;
}

var Nethru_domain  = Nethru_getDomain();

Nethru_makePersistentCookie("PCID",10,"/",Nethru_domain);
//웹로그를 위한 쿠키 생성 끝


/**
 * 버블 이벤트를 종료시킴.
 * 필요한 함수를 호출시 내장 버블 함수들의 실행을 종료시킴. 
 * function 안에 stopChainEvent(event); 추가
 * @param event e
 * @return 
 */
function stopChainEvent(e){
  if (!e) {
    e = window.event;
  }
  if (e.stopPropagation) { 
    e.stopPropagation();
    e.preventDefault();
  } else {
    e.cancelBubble = true;
    e.returnValue = false;
	  e.keyCode = 0;
  }
}

/**
 * 스크랩함수
 * @param event e
 * @return 
 */
function scrapMenu( menuID ){
	var location = document.location.href; 
	location = location.replace(/\?/g,"@");
	location = location.replace(/\&/g,"$");
	window.open('../../program/mypage/scrapPopup.jsp?menuID='+menuID+'&location='+location, 'scrap', 'toolbar=no, scrollbars=no, status=no, width=100, height=100' );
}

/**
 * JQUERY extend 함수 syncPost 정의..
 * 기존의 post 에 동기화 옵션 추가.
 * @param async false면 동기, true 면 비동기
 * @return 
 */  
jQuery.extend({  
		syncPost: function( url, data, callback, type, async ) {
			if ( jQuery.isFunction( data ) ) {
				callback = data;
				data = {};
			}

			return jQuery.ajax({
				type: "POST",
				url: url,
				data: data,
				success: callback,
				dataType: type,
				async: async			
			});
		}
	});  

/* 일본사이트 용 function 
 * 작성자 : 김기영
 * 작성일 : 2010.03.22
 * */
// 일본사이트용 start

/**
 * 에러 메세지 처리후 포커스를 다음으로 이동.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type
 * @param msg
 *            alert message
 * @return
 */
function errMsg(obj, msg) {
	alert(msg);
	obj.select();
	obj.focus();
}

/**
 * Enter Key 확인
 * 
 * @return {boolean}
 */
function isEnterKey() {
	if (window.event.keyCode == 13) {
		return true;
	}

	return false;
}

/**
 * 문자열로 token 해서 리턴
 * 
 * @param str
 *            입력치
 * @param delim
 *            구분자
 * @return {array}
 */
function makeToken(str, delim) {
	var array = str.split(delim);
	return array;
}

/**
 * Enter key로 method를 실행시킴
 * 
 * @param obj
 *            Form Element object type 
 * @param method
 *            실행 method
 * @return
 */
function exeMethodWithEnterKey(obj, method) {
	keynum = event.keyCode;

	if (keynum == 13) {
		eval(method);
		if (obj.getAttribute("submit") != "")
			window.event.keyCode = 9;
	}
}

/**
 * Tab key를 key-in한다.。
 * 
 * @return
 */
function nextFocus() {
	window.event.keyCode = 9;
}

/**
 * Del key 입력시 두개의 formfield를 초기화 한다.
 * 
 * @param obj1
 *            Form Element object type 오브젝트
 * @param obj2
 *            Form Element object type 오브젝트
 * @return
 */
function delKey(obj1, obj2) {
	if (event.keyCode == 46) {
		obj1.value = "";
		obj2.value = "";
	}
}

/**
 * 좌측 마우스 버튼사용을 금지 한다.
 * 
 * @return
 */
function chkRightButton() {
	if ((event.button == 2) || (event.button == 3)) {
		alert("右側マウスボタンは使うことができません。");
	}
}

/**
 * 윈도우 중앙에 Popup창을 연다.
 * 
 * @param url
 *            표시할 화면의 URL
 * @param winname
 *            윈도우 명
 * @param width
 *            윈도우의 너비
 * @param height
 *            윈도우의 높이
 * @param scroll
 *            스크롤의 생성여부(yes/no/auto)
 * @return
 */
function openWindow(url, winname, width, height, scroll) {
	var winx = (screen.width - width) / 2;
	var winy = (screen.height - height) / 2;
	var settings = "height=    " + height + ", ";
	settings += "width=     " + width + ", ";
	settings += "top=       " + winy + ", ";
	settings += "left=      " + winx + ", ";
	settings += "scrollbars=" + scroll + ", ";
	settings += "resizable =yes";

	var win = window.open(url, winname, settings);
	win.opener = this;
	return win;
}

/**
 * 윈도우의 중앙에 Modal Popup창을 연다.
 * 
 * @param url
 *            표시할 화면의 URL
 * @param winname
 *            윈도우 명
 * @param width
 *            윈도우의 너비
 * @param height
 *            윈도우의 높이
 * @param scroll
 *            스크롤의 생성여부(yes/no/auto)
 * @return
 */
function openModal(url, width, height, scroll) {
	var winx = (screen.width - width) / 2;
	var winy = (screen.height - height) / 2;
	var settings = "dialogHeight:    " + height + "px; ";
	settings += "dialogWidth:     " + width + "px; ";
	settings += "dialogTop:       " + winy + "px; ";
	settings += "dialogLeft:      " + winx + "px; ";
	settings += "scroll    :" + scroll + "; ";
	settings += "resizable :no; ";
	settings += "help      :no; ";
	settings += "status    :no; ";
	settings += "unadorned:yes";

	returnValue = showModalDialog(url, arguments, settings);

	return returnValue;
}

/**
 * 전체크기 브라우저를 연다.
 * @param url
 *            표시할 화면의 URL
 * @return
 */
function openFullScreen(url) {
	var newWin;
	newWin = window.open(url, "", "fullScreen");
	self.opener = self;
	window.close();
}

/**
 * 날짜 입력시 날짜의 dash('-') 를 삭제한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @return
 */
function delDateDelim(obj) {
	obj.value = obj.value.replace(/-/gi, "");
}

/**
 * 날짜 입력시 날짜의 dash('-') 를 삭제한다.
 * 
 * @param dateValue
 *            입력치
 * @return {string}
 */
function delDateDelimiter(dateValue) {
	if (dateValue.value) {
		dateValue = dateValue.value;
	}

	objvalue = dateValue.replace(/-/gi, "");

	return objvalue;
}

/**
 * 날짜 입력시 날짜의 dash('-') 를 추가한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @return
 */
function addDateDelim(obj) {
	var varDate = obj.value;

	obj.value = addDateDelimiter(varDate);
}

/**
 * 날짜 입력시 날짜의 dash('-') 를 추가한다.
 * 
 * @param dateValue
 *            입력치('YYYYMMDD')
 * @return {string}
 */
function addDateDelimiter(dateValue) {
	var value = dateValue;

	if (value.length != 8)
		return value;

	year = value.substring(0, 4);
	month = value.substring(4, 6);
	day = value.substring(6, 8);

	return year + "-" + month + "-" + day;
}

/**
 * 날짜입력시 날짜에 slash('/')를 추가해서 반환한다.
 * 
 * @param objValue
 *            입력치('YYYYMMDD')
 * @return
 */
function addDateDelimiterSlash(objValue) {
	year = objValue.substring(0, 4);
	month = objValue.substring(4, 6);
	day = objValue.substring(6, 8);

	return year + "/" + month + "/" + day;
}
/**
 * 시간입력시 시간에 Colon(':')을 삭제한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @return
 */
function delTimeDelim(obj) {
	obj.value = obj.value.replace(/:/gi, "");
}

/**
 * 시간입력시 시간에 Colon(':')을 추가한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @return
 */
function addTimeDelim(obj) {
	var varTime = obj.value;

	if ((varTime != null) && (varTime != "")) {
		hour = varTime.substring(0, 2);
		min = varTime.substring(2, 4);
		if (obj.value.length == 6) {
			sec = varTime.substring(4, 6);
			obj.value = hour + ":" + min + ":" + sec;
		} else
			obj.value = hour + ":" + min;
	}
}

/**
 * 時間入力の時時間の Colon(':')を削除する。
 * 시간입력시 시간에 Colon(':')을 삭제한다.
 * 
 * @param objValue
 *            入力値
 * @return {string}
 */
function delTimeDelimiter(objValue) {
	objValue = objValue.replace(/:/gi, "");

	return objValue;
}

/**
 * 시간입력시 시간에 Colon(':')을 추가한다.
 * 
 * @param objValue
 *            입력치
 * @return {string}
 */
function addTimeDelimiter(objValue) {
	if ((objValue != null) && (objValue != "")) {
		hour = objValue.substring(0, 2);
		min = objValue.substring(2, 4);
		sec = objValue.substring(4, 6);

		objValue = hour + ":" + min + ":" + sec;
	}
	return objValue;
}

/**
 * 통화입력시 통화에 comma('、')를 삭제한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @return {number}
 * 
 */
function delCurrencyDelim(obj) {
	var cur = trim(obj.value.replace(/,/gi, ""));

	return cur;
}

/**
 * 통화입력시 통화에 comma('、')를 추가한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @return {string}
 */
function addCurrencyDelim(obj) {
	var str = trim(obj.value.replace(/,/gi, ""));

	var index = 0;
	var negative = 0;

	if (str.indexOf('-') == 0) {
		str = str.replace(/-/gi, "");
	} else
		negative = -1;

	var strLength = str.length;

	if (str.indexOf('.') == -1)
		index = strLength - 1;
	else
		index = str.indexOf('.') - 1;

	var res = "";
	var p = 0;
	for (i = index; i >= 0; i--, p++) {
		if ((p != 0) && ((p % 3) == 0))
			res = "," + res;

		res = str.charAt(i) + res;
	}

	if (negative == 0)
		res = "-" + res;

	return res;
}

/**
 * 현재시간('HH')를 반환
 * 
 * @return {number}
 */
function getHour() {
	var cDate = new Date();

	return cDate.getHours();
}

/**
 * 현재시간('MI')를 반환
 * 
 * @return {number}
 */
function getMinute() {
	var cDate = new Date();

	return cDate.getMinutes();
}

/**
 * 현재시간('SS')를 반환
 * 
 * @return {number}
 */
function getSecond() {
	var cDate = new Date();

	return cDate.getSeconds();
}

/**
 * 현재시간을 'HHMIDD' 형식으로 반환
 * 
 * @return {string}
 */
function getCurrentTime() {
	var h = getHour();
	var m = getMinute();
	var s = getSecond();

	if (h < 10)
		h = "0" + h;
	if (m < 10)
		m = "0" + m;
	if (s < 10)
		s = "0" + s;

	return h + "" + m + "" + s;
}

/**
 * 입력한 날짜값{'YYYYMMDD'}을 특정시간 정도 +、- 해서 날짜값('YYYYMMDD')을 반환
 * 
 * @param tda
 *            날짜값
 * @param plan
 *            변환한 날짜값
 * @return {string}
 */
function addDate(tda, plan) {
	year = tda.substring(0, 4);
	month = tda.substring(4, 6);
	day = tda.substring(6, 8);

	dt = year + "/" + month + "/" + day;

	var cDate = new Date(dt);
	cTime = cDate.getTime() + plan * 1000 * 3600 * 24;
	var bTime = new Date();
	bTime.setTime(cTime);

	bY = (bTime.getYear() < 100) ? "19" + bTime.getYear() : bTime.getYear();
	bM = bTime.getMonth() + 1;
	bD = bTime.getDate();

	if (bM < 10)
		bM = "0" + bM;
	if (bD < 10)
		bD = "0" + bD;

	bDate = bY + "" + bM + "" + bD;

	return bDate;
}


/**
 * 入力した文字列を日程パターンで変換する。
 * 입력한 문자열을 일정 패턴으로 변환한다.
 * 
 * @param mode
 *            변환 모드
 *            1:ひらがな -> 半角カタカナ (히라가나 -> 반각 카타카나)、 
 *            2:ひらがな -> 全角カタカナ (히라가나 -> 전각 카나카나)、 
 *            3:全角カタカナ -> 半角カタカナ (전각 카나카나 -> 반각 카타카나)、
 *            4:半角カタカナ -> 全角カタカナ (반각 카타카나 -> 전각 카타카나)、 
 *            5:全角数字 -> 半角数字 (전각 숫자 -> 반각 숫자)、 
 *            6:半角小文字 -> 半角大文字 (반각 소문자 -> 반각 대문자), 
 *            7:半角数字 -> 全角数字 (반각 숫자 -> 전각숫자)
 *            8:半角英字 -> 全角英字 (반각영자 -> 전각영자)
 *            9:全角英字 -> 半角英字 (전각영자 -> 반각영자)
 * @param str
 *            입력값
 * @return {string}
 */
function chgString(mode, str) {

	var hir = new Array("が", "ぎ", "ぐ", "げ", "ご", "ざ", "じ", "ず", "ぜ", "ぞ", "だ",
			"ぢ", "づ", "で", "ど", "ば", "び", "ぶ", "べ", "ぼ", "ぱ", "ぴ", "ぷ", "ぺ",
			"ぽ", "を", "ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゃ", "ゅ", "ょ", "っ", "ー", "あ",
			"い", "う", "え", "お", "か", "き", "く", "け", "こ", "さ", "し", "す", "せ",
			"そ", "た", "ち", "つ", "て", "と", "な", "に", "ぬ", "ね", "の", "は", "ひ",
			"ふ", "へ", "ほ", "ま", "み", "む", "め", "も", "や", "ゆ", "よ", "ら", "り",
			/* US-09-0423 START */
			/*
			 * "る", "れ", "ろ", "わ", "ん", " ");
			 */
			"る", "れ", "ろ", "わ", "ん", "　", "（", "）");
	/* US-09-0423 END */

	var h_kat = new Array("ｶﾞ", "ｷﾞ", "ｸﾞ", "ｹﾞ", "ｺﾞ", "ｻﾞ", "ｼﾞ", "ｽﾞ", "ｾﾞ",
			"ｿﾞ", "ﾀﾞ", "ﾁﾞ", "ﾂﾞ", "ﾃﾞ", "ﾄﾞ", "ﾊﾞ", "ﾋﾞ", "ﾌﾞ", "ﾍﾞ", "ﾎﾞ",
			"ﾊﾟ", "ﾋﾟ", "ﾌﾟ", "ﾍﾟ", "ﾎﾟ", "ｦ", "ｧ", "ｨ", "ｩ", "ｪ", "ｫ", "ｬ",
			"ｭ", "ｮ", "ｯ", "ｰ", "ｱ", "ｲ", "ｳ", "ｴ", "ｵ", "ｶ", "ｷ", "ｸ", "ｹ",
			"ｺ", "ｻ", "ｼ", "ｽ", "ｾ", "ｿ", "ﾀ", "ﾁ", "ﾂ", "ﾃ", "ﾄ", "ﾅ", "ﾆ",
			"ﾇ", "ﾈ", "ﾉ", "ﾊ", "ﾋ", "ﾌ", "ﾍ", "ﾎ", "ﾏ", "ﾐ", "ﾑ", "ﾒ", "ﾓ",
			/* US-09-0423 START */
			/* "ﾔ", "ﾕ", "ﾖ", "ﾗ", "ﾘ", "ﾙ", "ﾚ", "ﾛ", "ﾜ", "ﾝ", " "); */
			"ﾔ", "ﾕ", "ﾖ", "ﾗ", "ﾘ", "ﾙ", "ﾚ", "ﾛ", "ﾜ", "ﾝ", " ", "(", ")");
	/* US-09-0423 END */

	var f_kat = new Array("ガ", "ギ", "グ", "ゲ", "ゴ", "ザ", "ジ", "ズ", "ゼ", "ゾ",
			"ダ", "ヂ", "ヅ", "デ", "ド", "バ", "ビ", "ブ", "ベ", "ボ", "パ", "ピ", "プ",
			"ペ", "ポ", "ヲ", "ァ", "ィ", "ゥ", "ェ", "ォ", "ャ", "ュ", "ョ", "ッ", "ー",
			"ア", "イ", "ウ", "エ", "オ", "カ", "キ", "ク", "ケ", "コ", "サ", "シ", "ス",
			"セ", "ソ", "タ", "チ", "ツ", "テ", "ト", "ナ", "ニ", "ヌ", "ネ", "ノ", "ハ",
			"ヒ", "フ", "ヘ", "ホ", "マ", "ミ", "ム", "メ", "モ", "ヤ", "ユ", "ヨ", "ラ",
			"リ", "ル", "レ", "ロ", "ワ", "ン", "　");

	var h_num = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
			"*", " ");

	var f_num = new Array("０", "１", "２", "３", "４", "５", "６", "７", "８", "９",
			"＊", "　");

	var h_kat_s = new Array("ｧ", "ｩ", "ｪ", "ｫ", "ｬ", "ｭ", "ｮ", "ｨ", "ｯ");

	var h_kat_l = new Array("ｱ", "ｳ", "ｴ", "ｵ", "ﾔ", "ﾕ", "ﾖ", "ｲ", "ﾂ");

	var h_eng = new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
			"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
			"x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
			"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
			"X", "Y", "Z", " ");

	var f_eng = new Array("ａ", "ｂ", "ｃ", "ｄ", "ｅ", "ｆ", "ｇ", "ｈ", "ｉ", "ｊ",
			"ｋ", "ｌ", "ｍ", "ｎ", "ｏ", "ｐ", "ｑ", "ｒ", "ｓ", "ｔ", "ｕ", "ｖ", "ｗ",
			"ｘ", "ｙ", "ｚ", "Ａ", "Ｂ", "Ｃ", "Ｄ", "Ｅ", "Ｆ", "Ｇ", "Ｈ", "Ｉ", "Ｊ",
			"Ｋ", "Ｌ", "Ｍ", "Ｎ", "Ｏ", "Ｐ", "Ｑ", "Ｒ", "Ｓ", "Ｔ", "Ｕ", "Ｖ", "Ｗ",
			"Ｘ", "Ｙ", "Ｚ", "　");

	if (mode == 1) { // ひらがな -> 半角カタナカ
		for ( var i = 0; i < hir.length; i++) {
			str = replaceAll(str, hir[i], h_kat[i]);
		}
		str = chgString(6, str);
	} else if (mode == 2) { // ひらがな-> 全角カタカナ
		for ( var i = 0; i < hir.length; i++) {
			str = replaceAll(str, hir[i], f_kat[i]);
		}
	} else if (mode == 3) { // 全角カタカナ -> 半角カタナカ
		for ( var i = 0; i < f_kat.length; i++) {
			str = replaceAll(str, f_kat[i], h_kat[i]);
		}
	} else if (mode == 4) { // 半角カタナカ -> 全角カタカナ
		for ( var i = 0; i < h_kat.length; i++) {
			str = replaceAll(str, h_kat[i], f_kat[i]);
		}
	} else if (mode == 5) { // 全角数字 -> 半角数字
		for ( var i = 0; i < f_num.length; i++) {
			str = replaceAll(str, f_num[i], h_num[i]);
		}
	} else if (mode == 6) { // 半角小文字 -> 半角大文字
		for ( var i = 0; i < h_kat_s.length; i++) {
			str = replaceAll(str, h_kat_s[i], h_kat_l[i]);
		}
	} else if (mode == 7) { // 半角数字 -> 全角数字
		for ( var i = 0; i < f_num.length; i++) {
			str = replaceAll(str, h_num[i], f_num[i]);
		}
	} else if (mode == 8) { // 半角英字 -> 全角英字
		for ( var i = 0; i < h_eng.length; i++) {
			str = replaceAll(str, h_eng[i], f_eng[i]);
		}
	} else if (mode == 9) { // 全角英字 -> 半角英字
		for ( var i = 0; i < f_eng.length; i++) {
			str = replaceAll(str, f_eng[i], h_eng[i]);
		}
	}

	return str;
}

/**
 * 문자열이 전부 반각영어로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkAlphabet(StrSrc) {

	return /^[a-zA-Z ]+$/.test(StrSrc);
}

/**
 * 문자열이 전부 반각영자로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkNumber(StrSrc) {

	var ObjReg = /[^0-9\-]/;

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 전부 반각영자 또는 반각숫자로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkAlphabetNumber(StrSrc) {

	var ObjReg = /[^a-zA-Z0-9\- ]/;

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 전체 반각기호로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkKigo(StrSrc) {

	var StrReg = "[^";
	StrReg += unescape("%u0021"); /* 0021 = "!" */
	StrReg += "-\\" + unescape("%u002F"); /* 002F = "/" */
	StrReg += unescape("%u003A"); /* 003A = ":" */
	StrReg += "-" + unescape("%u0040"); /* 0040 = "@" */
	StrReg += "\\" + unescape("%u005B"); /* 005B = "[" */
	StrReg += "-" + unescape("%u0060"); /* 0060 = "`" */
	StrReg += unescape("%u007B"); /* 007B = "{" */
	StrReg += "-" + unescape("%u007E"); /* 007E = "~" */
	StrReg += " ]";
	var ObjReg = new RegExp(StrReg);

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 전체 반각카타카나로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkHanKana(StrSrc) {

	var StrReg = "[^";
	StrReg += unescape("%uFF61"); /* FF61 = "? */
	StrReg += "-" + unescape("%uFF9F"); /* FF9F = "? */
	StrReg += " ]";
	var ObjReg = new RegExp(StrReg);

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 모두 반각문자로 구성되어있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkHankaku(StrSrc) {

	var StrReg = "[^";
	StrReg += unescape("%u0001"); /* 0001 = */
	StrReg += "-" + unescape("%u007E"); /* 007E = "~" */
	StrReg += unescape("%uFF61"); /* FF61 = "? */
	StrReg += "-" + unescape("%uFF9F"); /* FF9F = "? */
	StrReg += " ]";
	var ObjReg = new RegExp(StrReg);

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 전부 전각문자로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkZenkaku(StrSrc) {

	var StrReg = "[";
	StrReg += unescape("%u0001"); /* 0001 = */
	StrReg += "-" + unescape("%u007E"); /* 007E = "~" */
	StrReg += unescape("%uFF61"); /* FF61 = "? */
	StrReg += "-" + unescape("%uFF9F"); /* FF9F = "? */
	StrReg += " ]";
	var ObjReg = new RegExp(StrReg);

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 전부 반각대문자로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkUpperCase(StrSrc) {

	var ObjReg = /[^A-Z ]/;

	return !ObjReg.test(StrSrc);
}

/**
 * 문자열이 전부 반각소문자로 구성되어 있는지 판단한다.
 * 
 * @param StrSrc
 *            입력값
 * @return {boolean}
 */
function chkLowerCase(StrSrc) {

	var ObjReg = /[^a-z ]/;

	return !ObjReg.test(StrSrc);
}


/**
 * 입력값의 오른쪽을 전체글자수 만큼 특정문자로 채운다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @param slength
 *           전체 문자 길이
 * @param chars
 *           처리문자
 * @return {String}
 */
function fillCharLeftValue(value, slength, chars) {

	var stemp = "";
	if (value != "") {
		for ( var i = 0; i < slength - value.length; i++) {
			stemp = chars + stemp;
		}
		return stemp + value;
	}

	return "";
}

/**
 * 입력값의 왼쪽의 특정문자를 삭제한다.
 * 
 * @param value
 *            입력한 내용이 있는 Form Element object type 오브젝트
 * @param chars
 *            처리문자
 * @return {String}
 */
function delCharLeftValue(value, chars) {

	var posNotChar = 0;
	if (value != "") {
		for ( var i = 0; i < value.length; i++) {
			if (value.charAt(i) != chars) {
				posNotChar = i;
				break;
			}
		}
		return value.substring(posNotChar);
	}

	return "";

}


/**
 * 날짜형식의 입력값에 '.'을 추가한다.
 * 
 * @param objValue
 *            yyymm, yyymmdd 형식의 입력값
 * @return {String}
 */
function addDateDelimiterDotJA(objValue) {
	if (objValue.length == 7) {
		year = objValue.substring(0, 3);
		month = objValue.substring(3, 5);
		day = objValue.substring(5, 7);
		return year + "." + month + "." + day;
	} else if (objValue.length == 5) {
		year = objValue.substring(0, 3);
		month = objValue.substring(3, 5);
		return year + "." + month;
	} else
		return objValue;
}

/**
 * 입력시yyyymmdd,yyyymm,yyyy,yyymmdd,yyymm,yyy형식을nyy. m. d,nyy. m,nyy으로 변환해서 반환한다.
 * 
 * @param str
 *            날짜형식의 입력값
 * @return {String}
 */
function dateJNF2(str) {

	str = addDateDelimiterDotJA(dateJNF(str));

	if (str.substring(4, 5) == "0")
		str = str.substring(0, 4) + " " + str.substring(5);
	if (str.substring(7, 8) == "0")
		str = str.substring(0, 7) + " " + str.substring(8);

	return str;
}

/**
 * 입력시yyyymmdd,yyyymm,yyyy,yyymmdd,yyymm,yyy형식을nyy.mmdd,nyy.mm,nyy으로 변환한다.
 * 
 * @param str
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function updDateJNFwithZero(obj) {

	var objOrigin = obj.value;

	if (objOrigin.length > 2 && objOrigin.substring(0, 3) == "999") {
		return;
	}

	if (obj.value != "") {

		var seireki = ja2ad(obj.value);

		if (seireki.length == 4)
			seireki = seireki + "0101";
		else if (seireki.length == 6)
			seireki = seireki + "01";

		if (!is_valid_dates(seireki)) {
			obj.value = objOrigin;
			obj.focus();
			obj.select();
			return;
		}

		var str = addDateDelimiterDotJA(dateJNF(obj.value));
		if (str == "") {
			alert("入力に誤りがあります。");
			obj.value = objOrigin;
			obj.focus();
			obj.select();
		} else
			obj.value = str;
	} else {
		obj.value = "";
	}
}

/**
 * 입력한yyyymmdd,yyyymm,yyyy,yyymmdd,yyymm,yyy형식을nyy. m. d,nyy. m,nyy으로 변환한다.
 * 
 * @param obj
 *            입력한 내용이 있는  Form Elemnet  오브젝트
 * @return
 */
function updDateJNFwithSpace(obj) {
	var str = dateJNF2(obj.value);
	obj.value = str;
}

/**
 * InputBox의 값에SelectBox의 선택값으로 변경
 * 
 * @param objText
 *            텍스트박스 오브젝트
 * @param objSel
 *            셀렉트박스 오브젝트
 * @return
 */
function setSelectNm(objText, objSel) {
	var chk = 0;

	for (i = 0; i < objSel.length; i++) {
		if (objSel[i].value == objText.value) {
			objSel[i].selected = true;
			chk++;
		}
	}

	if (objText.value.length > 0 && chk == 0) {
		objText.select();
		alert('該当する値がありません。');
	}
}

/**
 * 통화형식의 데이타에 구분하는 기호를 넣는다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function addCurrencyDelimObj(obj) {
	if (obj.value != '') {
		var str = trim(obj.value.replace(/,/gi, ""));
		var negative = 0;

		if (str.indexOf('-') == 0) {
			str = str.replace(/-/gi, "");
		} else
			negative = -1;

		var strLength = str.length;
		var index = 0;

		if (str.indexOf('.') == -1)
			index = strLength - 1;
		else
			index = str.indexOf('.') - 1;

		var minus = "";
		if (negative > -1)
			minus = "-";

		var res = "";
		var p = 0;
		for (i = index; i >= 0; i--, p++) {
			if ((p != 0) && ((p % 3) == 0))
				res = "," + res;

			res = str.charAt(i) + res;
		}

		obj.value = minus + res + str.substr(index + 1);
	}
}

/**
 * 통화형식의 데이터에 구분하는 기호를 넣어 반환한다.
 * 
 * @param objvalue
 *            입력값
 * @return
 */
function addCurrencyDelimValue(objvalue) {
	var str = trim(objvalue.replace(/,/gi, ""));
	var negative = 0;

	if (str.indexOf('-') == 0) {
		str = str.replace(/-/gi, "");
	} else
		negative = -1;

	var strLength = str.length;
	var index = 0;

	if (str.indexOf('.') == -1)
		index = strLength - 1;
	else
		index = str.indexOf('.') - 1;

	var minus = "";
	if (negative > -1)
		minus = "-";

	var res = "";
	var p = 0;
	for (i = index; i >= 0; i--, p++) {
		if ((p != 0) && ((p % 3) == 0))
			res = "," + res;

		res = str.charAt(i) + res;
	}
	
	return res;
}

/**
 * 통화형식의 데이터에 구분하는 기호를 소거한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function delCurrencyDelimObj(obj) {
	if (obj.value != '') {
		obj.value = obj.value.replace(/,/gi, "")
		obj.select();
	}
}

/**
 * 통화형식의 데이터에 구분하는 기호를 넣고, 공백이 입력된 경우는 0으로 처리한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function ChgCurrencyBase(obj) {
	var temp = obj.value.replace(/,/gi, "");
	if (trim(temp).length == 0) {
		obj.value = "0";
	} else {
		obj.value = parseInt(temp, 10);
		addCurrencyDelimObj(obj);
	}
}

/**
 * 통화형식의 데이타에 구분하는 기호를 넣고, 공백이 입력된 경우는 공백으로 처리한다.
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function ChgCurrencyNull(obj) {
	var temp = obj.value.replace(/,/gi, "");
	if (trim(temp).length == 0) {
		obj.value = "";
	} else {
		obj.value = parseInt(temp, 10);
		addCurrencyDelimObj(obj);
	}
}

/**
 * 通貨形式のデータに区分する記号を入れ、空白が入力された場合は0で処理する。(サブキー使用禁止)
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function ChgCurrency(obj) {
	if (!is_keycode_subkey()) {
		var temp = obj.value.replace(/,/gi, "");
		if (trim(temp).length == 0) {
			obj.value = "0";
		} else {
			obj.value = parseInt(temp, 10);
			addCurrencyDelimObj(obj);
		}
	}
}

/**
 * 通貨形式のデータに区分する記号を入れ、空白が入力された場合は0で処理する。(サブキー使用禁止)
 * 통화형식의 데이터에 구분하는 기호를 넣고, 공백이 입력됐을 경우는 0으로 처리한다.(서브키 사용금지)
 * 
 * @param obj
 *            입력한 내용이 있는 Form Element 오브젝트
 * @return
 */
function ChgCurrencyZero(obj) {
	if (!is_keycode_subkey()) {
		var temp = obj.value.replace(/,/gi, "");
		if (trim(temp).length == 0) {
			obj.value = "0";
		} else {
			addCurrencyDelimObj(obj);
		}
	}
}

/**
 * フォーム内の全ての通貨形式のデータに区分する記号を入れ、空白が入力された場合は0で処理する。
 * 폼내 전체 통화형식의 데이타에 구분하는 기호를 넣고, 공백이 입력됐을경우는 0으로 처리한다.
 * 
 * @param f_nm
 *            フォーム名
 *            폼명
 * @return
 */
function ChgCurrencyAll(f_nm) {
	var obj_f = eval("document." + f_nm);
	for ( var i = 0; i < obj_f.length; i++) {
		if (obj_f.elements[i].cha_chk == "NC") {
			ChgCurrencyBase(obj_f.elements[i]);
		}
	}
}

/**
 * フォーム内の全オブジェクトのtabIndexを確認し、tabIndexが0より少ない、かつ同じ値のオブジェクトはフォーカスの移動を禁止する。
 * 폼내 전체 오브젝트에 tabIndex를 확인하고, tabIndex가 0보다 적거나 같은 값의 오브젝트는 포커스의 이동을 금지한다. 
 * 
 * @param f_nm
 *            フォーム名
 *            폼명
 * @return
 */
function tabSetter() {
	for ( var i = 0; i < document.all.length; i++) {
		if (!document.all[i].tabIndex || document.all[i].tabIndex <= 0) {
			document.all[i].tabIndex = "-1";
		}

	}
}

/**
 * 서력을 와력으로 변환한다.
 * @param n
 *            서력년도 YYYY
 * @return  와력문자 ex)平成 22年
 */
function convertWareki(yyyy){
	var nengou, base;
	if (yyyy == "") return;
	yyyy = parseInt(yyyy);
	if(yyyy <= 0) return;
	if (yyyy < 1868) {
		nengou = "西暦";
		base = 1;
	}
	else if ((1868 <= yyyy) && (yyyy <= 1911)) {
		nengou = "明治";
		base = 1968;
	}
	else if ((1912 <= yyyy) && (yyyy <= 1925)) {
		nengou = "大正";
		base = 1912;
	}
	else if ((1926 <= yyyy) && (yyyy <= 1988)) {
		nengou = "昭和";
		base = 1926;
	}
	else {
		nengou = "平成";
		base = 1989;
	}
	return nengou + " " + (yyyy - base + 1) + " 年";
}

/**
 * 와력을 서력으로 변환한다.
 * @param wa
 *            와력연호  明治 or 1 , 大正 or 2, 昭和 or 3, 平成 or 4
 * @param yy
 *            년도 YY
 * @return  서력년도 YYYY
 */
function convertSeireki(wa, yy) {
	var base, seireki;
	if (yy == "") return;
	// 西暦を調べる
	switch (wa) {
		case "明治": base = 1867; break;
		case "大正": base = 1911; break;
		case "昭和": base = 1925; break;
		case "平成": base = 1988; break;
		case "1": base = 1867; break;
		case "2": base = 1911; break;
		case "3": base = 1925; break;
		case "4": base = 1988; break;
	}
	seireki = base + parseInt(yy);
	return seireki;
}
// 일본사이트용 end

function printDiv(urlLink){
  if( !urlLink || urlLink == ''){    
    urlLink = window.location
  }
  var url = '../../inc/jsp/printPopup.jsp?thref='+urlLink;  
  window.open(url, 'Popup', 'width=600, height=400, scrollbars=no, menubar=no, status=no, resizable=no');
}

function printDivCoupon(urlLink){
	  if( !urlLink || urlLink == ''){     
	    urlLink = window.location
	  }
	  var url = '../../inc/jsp/printPopupCoupon.jsp?thref='+urlLink;  
	  window.open(url, 'Popup', 'width=600, height=400, scrollbars=no, menubar=no, status=no, resizable=no');
	}

function f_link(parameter){
  if ( Number(parameter) == 1 ) {
    location.href = "../../program/coupon/listCoupon.jsp?menuID=001011006";
  } else if ( Number(parameter) == 2 ) {
    location.href = "../../program/mypage/pointList.jsp?menuID=001010001";     
  }
}

var nMenu = 0;

function subTopOver( menuID ) {
	$(".topSearch").hide();
	$("#subTop_"+menuID).show();
}  
function subTopOut( menuID ) {
	$(".subMenu").hide();
	$(".topSearch").show();
}


function convertTemp(degree, temp){
	  var result = 0;
	  if (degree=="C"){
	     result = Number(temp) * 9 / 5 + 32;
	  }else{
	     result = (Number(temp) -32) * 5 / 9;
	  }
	  result =  (Math.round(result*100)) / 100; // 반올림
    return result;
}


function getJapanDate(param, plan){
	var aDate = param.split("-");
	var object = new Date(aDate[0],Number(aDate[1])-1,aDate[2]);
	
	cTime = object.getTime() + plan * 1000 * 3600 * 24;
	object.setTime(cTime);
	
    var year = object.getYear();
    var month = object.getMonth()+1;
    var date = object.getDate();
    var day = object.getDay();
    var dayJP = "";

    switch (day) {
      case 0: dayJP = "日"; break;
	  case 1: dayJP = "月"; break;
	  case 2: dayJP = "火"; break;
  	  case 3: dayJP = "水"; break;
	  case 4: dayJP = "木"; break;
	  case 5: dayJP = "金"; break;
	  case 6: dayJP = "土"; break;
    }
    
    var result = month +"月 " + date + "日 ("+ dayJP + ")"; 
   return  result;
  }

/*
function subTopOver( menuID ) {
	$(".subMenu").hide();
	$("#subTop_"+menuID).show();
	nMenu = menuID;
	setTimeout(function(){
		if ( nMenu == 0 ) {
			$(".subMenu").hide(); 
		}
	}, 1000);    
}  

function subTopOut( menuID ) {
	nMenu = 0;
	setTimeout(function(){
		if ( nMenu == 0 ) {
			$(".subMenu").hide(); 
		}
	}, 100);    
}

function subTopMenuOut( menuID ) {
	nMenu = 0;
	$(".subMenu").hide();
}
*/

function quickReset() {
	$(".quickSub").stop().animate({"top":"0px"},500);
	$(".quick").stop().animate({"top":"0px"},500);
}

/* 레프트 퀵메뉴 */  
$(window).load(function(){
	  var prevScrollHeight;
	  var quickHeight = 1050;
	  var quickTop = $("#quickTop").val();
	  if ( $.trim(quickTop) != "" ) {
		  if ( quickTop == "001002" || quickTop == "001003" || quickTop == "001004"  ) {
			  quickHeight = "800";  
		  }  
	  }
	  quickHeight = Number(quickHeight);
	  var firstPosition = parseInt($("#snb").css("height"));
	  //alert(firstPosition);
	  var currentPosition = 0;  
	  var currentPosition2 = 0;  
	  if(!isNaN($(".quick").css("top"))){    
	    currentPosition = parseInt($(".quick").css("top"));
	  }
	  if(!isNaN($(".quickSub").css("top"))){    
		  currentPosition2 = parseInt($(".quickSub").css("top"));
	  }
		$(window).scroll(function() {
			var position = $(window).scrollTop(); // 현재 스크롤바의 위치값을 반환합니다.		
			//alert(Number(position));     
			var newPosition = position + currentPosition;
			var newPosition2 = position + currentPosition2;
			var scrollHeight = parseInt(document.documentElement.scrollHeight);     
			//alert(scrollHeight + " | " + newPosition  + " | " + quickHeight );
			if ( Number(scrollHeight) - Number(newPosition) > quickHeight ) {
				if ( position == 0 ) {
					newPosition = 0;
				}    
				var snbHeight = 100;
				if ( !isNaN($("#snb").css("height")) ) {
					snbHeight = parseInt($("#snb").css("height") + 100);
				}  
				//alert(snbHeight + " | " + position  + " | " + newPosition );
				if ( parseInt(snbHeight) < Number(position) || newPosition == 0 ) {
					var newTop = newPosition - parseInt(snbHeight);
					if ( Number(newTop) >= 0 ) {
						$(".quick").stop().animate({"top":Number(newTop)+"px"},500);
					}
				}
			}      
			if ( Number(scrollHeight) - Number(newPosition2) > quickHeight ) {
				if ( position == 0 ) {
					newPosition2 = 0;
				}    
				var snbHeight = -280;
				if ( !isNaN($("#snb").css("height")) ) {
					snbHeight = parseInt($("#snb").css("height") - 280);
				}  
				//alert(snbHeight + " | " + position  + " | " + newPosition );
				if ( parseInt(snbHeight) < Number(position) || newPosition2 == 0 ) {
					var newTop = newPosition2 - parseInt(snbHeight);
					if ( Number(newTop) >= 0 ) {
						$(".quickSub").stop().animate({"top":Number(newTop)+"px"},500);
					}
				}
			}
		});
	});
function Set_AddComma (Cost) {

 // Cost값이 0보다작으면(음수이면) Cost를 양수로변경하고 minus값도 변경
	if (Cost < 0) { Cost *= -1; var minus = true; }
	else var minus = false;


 // Cost값에서 소숫점위와 아래를 분리하여 dotU/dotD변수에저장
 // Cost가 숫자이기 때문에 문자로 변환하기 위해 (Cost + "") 에서 ""을 붙여줌
 // split함수사용예     
 // AF = abcdefg.split("c")
 // AF[0] =>ab
 // AF[1] =>defg
	var dotPos = (Cost + "").split (",");
	var dotU = dotPos [0];
    var dotD = dotPos [1];

    // dotU(소수점위)를 3으로나누어 그 나머지를 CommaFlag에저장
    // 돈에 콤마를 표시할때 3자리 단위로 표시하기때문에...
    var CommaFlag = dotU.length % 3;

// 나머지가 있을경우 (예: 12345 또는 12345678 ...)
    if (CommaFlag) {
 // out에 dotU앞자리를 CommaFlag길이만큼 대입
     var out = dotU.substring (0, CommaFlag);
  // dotU의 길이가 3자리 초과이면 out문자끝에 콤마를 추가
	 if (dotU.length > 3) out += ",";
	    } 
 
 // 나머지가 없을경우(예: 123  또는 123456 ...)
    else var out = "";

// dotU문자에서 CommaFlag만큼 이동한후 세글자 단위로 콤마를 찍음
	for (var i = CommaFlag; i < dotU.length; i += 3) {
	 out += dotU.substring (i, i + 3);
	 if (i < dotU.length - 3) out += ",";
	}

// 음수일경우 out 변수값앞에 "-"를 추가
	if (minus) out = "-" + out;

 // 소숫점이하값이 있으면 out변수값에 소숫점을 추가하여 리턴
	if (dotD) return out + "." + dotD;
	    else return out;
}


/* 헤더부분 최근 공지사항 */
var nNoticeList;
var nNoticePrev;
var nNoticeNext;
function notice() {
  if (nNoticeList >= nNoticePrev + 1) {
  	nNoticeNext++;
  } else {
  	nNoticeNext = 0;   
  }  
  $("#notice_"+nNoticePrev).hide();
  $("#notice_"+nNoticeNext).show("clip", "", 300);
  nNoticePrev++;   
  if ( nNoticeNext == 0 ) {
  	nNoticePrev = 0;
  }
  setTimeout("notice()", 5000);
}
