/*
 * Html.js : ÀüÃ¼ È­¸é¿¡¼­ »ç¿ëÇÏ´Â À¯¿ëÇÑ ÇÔ¼ö ¸ðÀ½
 * 
 * Version 1.0
 * 
 * Created  : 2006/08/30  °³¹ßÀÚ
 * Updated  : 2006/08/30  °³¹ßÀÚ
 */


//
// alert() ÇÔ¼ö ´ë½Å »ç¿ëÇÑ´Ù.
function ht_ShowAlert(strMessage, strTitle)
{
    var nHeight = "400"; //180
    var strIcon = "";

    if (arguments[2] != null) nHeight = arguments[2].toString();
    if (arguments[3] != null) strIcon = arguments[3].toString();

    var objMsg = new Object();
    objMsg.Message = strMessage;
    objMsg.Icon    = strIcon;

    window.showModalDialog("/Common/WebForms/dlgAlertMsg.aspx?title=" + escape(strTitle), objMsg, "dialogHeight: " + nHeight + "px; dialogWidth: 500px; status: no; scroll: no; help: no;");
    
}

//
// confirm() ÇÔ¼ö ´ë½Å »ç¿ëÇÑ´Ù.
function ht_ShowConfirm(strMessage, strTitle)
{
    var nHeight = "180";
    var strIcon = "";
    
    if (arguments[2] != null) nHeight = arguments[2].toString();
    if (arguments[3] != null) strIcon = arguments[3].toString();
        
    var objMsg = new Object();
    objMsg.Message = strMessage;
    objMsg.Icon    = strIcon;
    
    var objResult = window.showModalDialog("Common/WebForms/dlgConfirmMsg.aspx?title=" + escape(strTitle), objMsg, "dialogHeight: " + nHeight + "px; dialogWidth: 500px; status: no; scroll: no; help: no;");
    if (objResult != null)
        return objResult;
    else
        return false;
}

//
// ShowError() ¿¡·¯ ¸Þ½ÃÁö À©µµ¿ì¸¦ Ãâ·ÂÇÑ´Ù.
// intAfterProcType : 0:None, 1:HistoryBack, 2:WindowClose
function ht_ShowError(strMessage, strTitle, intAfterProcType)
{
    var nHeight = "570";
    var strIcon = "";

    var objMsg = new Object();
    objMsg.Message = strMessage;
    objMsg.Icon    = strIcon;
    
    window.showModalDialog("/Common/WebForms/dlgErrorMsg.aspx?title=" + escape(strTitle), objMsg, "dialogHeight: " + nHeight + "px; dialogWidth: 800px; status: no; scroll: yes; help: no;");
    
    if (intAfterProcType = 1)
    {
      history.go(-1);
    }
    else if (intAfterProcType = 2)
    {
      self.opener = self;
      self.close();
    }
}

//
// ´ëÈ­»óÀÚ¿¡¼­ Enter ³ª Esc Å°¸¦ ´©¸£¸é Ã¢À» ´Ý´Â´Ù.
function ht_CheckKeyPress()
{
    if (event.keyCode == 13 || event.keyCode == 27)
        self.close();
}

//
// ÁöÁ¤ÇÑ Select Box ÀÇ ¸ðµç Ç×¸ñµéÀ» Áö¿î´Ù.
function ht_SelectBoxClear(objSelect)
{
    if (objSelect == null) return;
 
    if (objSelect.tagName.toUpperCase() == "SELECT")
    {
        var nCount = objSelect.options.length;
        for (var i = nCount - 1; i >= 0; i--)
            objSelect.remove(i);
    }
}

//
// ÁöÁ¤ÇÑ Select Box ÀÇ ¸ðµç Ç×¸ñµéÀ» Áö¿ì°í »õ·Î¿î µ¥ÀÌÅÍ¸¦ ÀÔ·ÂÇÑ´Ù.
function ht_SelectBoxFill(objSelect, strData, strRowSeperator, strColSeperator)
{
    if (objSelect       == null) return;
    if (strRowSeperator == null) strRowSeperator = ",";
    if (strColSeperator == null) strColSeperator = ":";
 
    SelectBoxClear(objSelect);
    
    if (objSelect.tagName.toUpperCase() == "SELECT")
    {
        var aryRows = strData.split(strRowSeperator);
        for (var i = 0; i < aryRows.length; i++)
        {
            var aryColumns = aryRows[i].split(strColSeperator);
            
            var objOption  = document.createElement("OPTION");
            objSelect.options.add(objOption);
            objOption.innerText = aryColumns[1];
            objOption.value     = aryColumns[0];
        }
    }
}

//
// ÃÖÇÏ´Ü ¸Þ´º Å¬¸¯½Ã ÀÌµ¿
function ht_SubJobDisplay(subMenuCode)
{
  top.Contents.location.href = subMenuCode;
}

//
// ÄíÅ°¸¦ ¼³Á¤ÇÑ´Ù.
function ht_SetCookie(name,value,expiredays) 
{
  var todayDate=new Date();
  
  todayDate.setDate(todayDate.getDate()+expiredays);
  document.cookie=name+"="+escape(value)+"; path=/; expires="+todayDate.toGMTString()+";"
}

//
// ÇöÀç ÆäÀÌÁö ¸í¸¸ °¡Á®¿Â´Ù.
//    extName : È®ÀåÀÚ ¸í(Á¡À» »« °ª)
//    hasExt  : È®ÀåÀÚ Æ÷ÇÔ À¯¹« boolean
function ht_GetCurFileName(outExtName, hasExt)
{
  var pathName  = location.pathname.toLowerCase();  //lastIndexOf(....)
  var extName   = outExtName.toLowerCase();

  var extPos  = pathName.lastIndexOf("." + extName);
  var pathPos = pathName.lastIndexOf("/");

  if (pathPos >= extPos)
    return "";

  var fileName  = location.pathname.substr(pathPos+1, extPos-pathPos-1);
  
  if (hasExt)
    fileName  += "." + outExtName;
  
  return fileName;   
}

//
// ÆÄÀÏ Ã·ºÎ ´ëÈ­ »óÀÚ¸¦ ¿ÀÇÂÇÑ´Ù.
//    maxSize : ÃÖ´ë Ã·ºÎ ¿ë·®
//    curSize : ÇöÀç »ç¿ë ÁßÀÎ ¿ë·®
function ht_ShowAddFile(maxSize, curSize)
{
  if (maxSize == null || maxSize == "")
    maxSize = "0";

  if (curSize == null || curSize == "")
    curSize = "0";

  var linkPage  = "/Common/WebForms/dlgAddFile.aspx?cursize=" + curSize + "&maxsize=" + maxSize;
  var objResult = window.showModalDialog(linkPage, null, "dialogHeight: 140px; dialogWidth: 420px; status: no; scroll: no; help: no;");
  
//  window.open(linkPage,"","")
//  var objResult = null;

  return objResult;    
}

//
// ÆÄÀÏÀÇ Å©±â¸¦ ¾Ë·ÁÁØ´Ù. ÀÌ ¶§ Å©±â´Â byte ´ÜÀ§.
//  (2007.01.18 Ãß°¡)
//    pathAndFileNm : ÆÄÀÏ¸íÀÌ Æ÷ÇÔµÈ °æ·Î(input file ³»ÀÇ ³»¿ë)
//      ex>c:\abc.txt
function ht_GetFileSize(pathAndFileNm)
{
  var img = new Image();
  img.dynsrc  = pathAndFileNm;

  return img.fileSize;
}

//
// ÇØ´ç ÆÄÀÏÀÌ µ¿ÀÏÇÑ È®ÀåÀÚÀÎÁö ¾Ë·ÁÁØ´Ù.
//  (2007.01.18 Ãß°¡)
//    fileType      : È®ÀåÀÚ ¸í("txt", "gif")
//    pathAndFileNm : ÆÄÀÏ¸íÀÌ Æ÷ÇÔµÈ °æ·Î(input file ³»ÀÇ ³»¿ë)
function ht_CheckFileType(fileType, pathAndFileNm)
{
  var lastIdx   = -1;
  
  lastIdx = pathAndFileNm.lastIndexOf('.');
  var extension = pathAndFileNm.substring(lastIdx+1, pathAndFileNm.length);
 
  if((lastIdx != -1) && (extension.toLowerCase() == fileType.toLowerCase()))
    return true;

  return false;
}

//
// ÀÔ·Â ÄÁÆ®·ÑÀÌ À¯È¿ÇÑ °ªÀÎÁö È®ÀÎ
//  (2007.02.04 Ãß°¡)
//    objInput      : ÀÔ·Â ÄÁÆ®·Ñ
function ht_IsValidInput(objInput)
{
  if (objInput.value == null || objInput.value == "")
    return false;
  
  return true;
}

//
// ÀÌ¹ÌÁö ¸ÂÃã ÆË¾÷
//  (2007.02.14 Ãß°¡)
//    objInput      : ÀÔ·Â ÄÁÆ®·Ñ
function ht_ShowImageViewer(imageSrc)
{
  var linkUrl = "/common/webforms/ShowImage.aspx?image=" + imageSrc
  window.open(linkUrl, "showImage", "left=30,top=30,width=400,height=500");
}

//
// URL °ú ±× ¼³¸íÀ» Áñ°Ü Ã£±â¿¡ Ãß°¡ÇÑ´Ù.
//  (2007.03.31)
function ht_AddFavorite(siteUrl, siteName)
{
  if (confirm("Àå¾ÖÀÎ º¹Áö ÁøÈïÈ¸ »çÀÌÆ®¸¦ Áñ°ÜÃ£±â¿¡ µî·ÏÇÏ½Ã°Ú½À´Ï±î?"))
    window.external.AddFavorite(siteUrl,siteName);
}

