var undefined; // ÀÍ½ºÇÃ·Î·¯ ÇÏÀ§¹öÁ¯ È£È¯À» À§ÇÑ º¯¼ö


/**
 * ÀÍ½ºÇÃ·Î·¯ ActiveXÄÁÆ®·Ñ·¯ ÆÐÄ¡°ü·Ã ¿ÀºêÁ§Æ®Ã³¸®
 */
function PrintEmbed2( EmbID ) 
{ 
    document.write(document.getElementById(EmbID).value);
} 

/**
WebBrowser1.ExecWB(6, 2); ´Â ¾Æ·¡¿Í °°ÀÌ º¯°æÇÏ¿© »ç¿ëµË´Ï´Ù. 
WebBrowser1.ExecWB(7,1); //ÀÎ¼â ¹Ì¸®º¸±â 
WebBrowser1.ExecWB(8,1); //ÆäÀÌÁö¼³Á¤ 
WebBrowser1.ExecWB(6,1); //ÀÎ¼âÇÏ±â(´ëÈ­»óÀÚ Ç¥½Ã) 
WebBrowser1.ExecWB(6,-1); //ÀÎ¼â ¹Ù·ÎÇÏ±â 
*/

function printIt()
{
  var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
  document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
  WebBrowser1.ExecWB(6, 2);
  WebBrowser1.header = "ENVICO È­¸é Á¤ÀÇ¼­ ";
  WebBrowser1.footer = "";
  WebBrowser1.outerHTML ="";
}


/**
 * ÀÌ¹ÌÁö¸¦ ÁöÁ¤ÇÑ Å©±â·Î Á¶Á¤ÇÏ¿© viewing
 * @param id  ÀÌ¹ÌÁö°¡ »ðÀÔµÉ div ¿µ¿ª id
 * @param url ÀÌ¹ÌÁö url ÁÖ¼Ò
 * @param wd  °¡·ÎÇÈ¼¿
 */
function assignImageById(id, url, wd ) 
{
  var img = new Image();
  img.src = url;
  if(img == null || img.width < 30) 
  {
    return;
  }
   
  var width   = img.width;
  var height  = img.height;   
  var per     = height / width;
  var width   = parseInt(wd, 10);
  var height  = parseInt(width * per, 10);
  var element = getElementById( id );
   
  var value   = "<img src='" + url + "' width='" + width + "' height='" + height + "' />";
 
  // alert( value );   
  element.innerHTML = value;
  element.style.height = height + 6;
  // alert( element.innerHTML ); 
} 


/**
 * URL ÁÖ¼Ò·Î ÀÌµ¿
 * goUrl("http-url")
 *
 * @param url
 */
function goUrl(url) {
  location.href = url;
}

/**
 * HTML ID ¿µ¿ª ¼û±è
 * hide("id")
 *
 * @param id
 */
function show( id ) 
{
  document.getElementById(id).style.display="block";
}

/**
 * HTML ID ¿µ¿ª ¼û±è
 * hide("id")
 *
 * @param id
 */
function hide( id ) 
{
  document.getElementById(id).style.display="none";
}

/**
 * HTML ID ¿µ¿ª ¼û±è ¶Ç´Â ÆîÄ§
 * showHide("id")
 *
 * @param id
 */
function showHide( id ) 
{
  if ( document.getElementById(id).style.display.toLowerCase() == "none") 
  {
    document.getElementById(id).style.display="block";
  }
  else 
  {
    document.getElementById(id).style.display="none";
  }
}

// ÆË¾÷ °´Ã¼ Á¤º¸¸¦ ´ã´Â º¯¼ö
var winHandle = null;

// ÆË¾÷
function popWin(URL, width, height, target, option ) {
  if( width  == undefined || width  == "" ) width  = 420;
  if( height == undefined || height == "" ) height = 410;
  if( target == undefined || target == "" ) target = "_ENVICO_POP";
  
  if( option == undefined || option == "" ) {
      option = ",scrollbars=0,resizable=0,status=1";
  }
  else if(option == 1)
  {
      option = ",scrollbars=1,resizable=1,status=1";    
  }
  else if(option == 2)
  {
      option = ",scrollbars=0,resizable=1,status=1";    
  }

  var w_avail = screen.availWidth;
  var h_avail = screen.availHeight;
  var top     = Math.round ( (h_avail - height) * .5);
  var left    = Math.round ( (w_avail - width ) * .5);
  
  var winOptions = "toolbar=0,location=0,directories=0,menubar=0,copyhistory=0,left=" 
      + left + ",top=" + top + ",width=" + width + ",height=" + height + option;
  if (winHandle != null) {
      winHandle.close();
  }
  winHandle = window.open(URL, target,  winOptions);
  winHandle.focus();
}

// ÆË¾÷
function popWinR(URL, width, height, target, option ) {
  if( width  == undefined || width  == "" ) width  = 420;
  if( height == undefined || height == "" ) height = 410;
  if( target == undefined || target == "" ) target = "_ENVICO_POP";
  
  if( option == undefined || option == "" ) {
      option = ",scrollbars=0,resizable=0,status=1";
  }
  else if(option == 1)
  {
      option = ",scrollbars=1,resizable=1,status=1";    
  }
  else if(option == 2)
  {
      option = ",scrollbars=0,resizable=1,status=1";    
  }

  var w_avail = screen.availWidth;
  var h_avail = screen.availHeight;
  var top     = Math.round ( (h_avail - height) * .5);
  var left    = Math.round ( (w_avail - width ) * .5);
  
  var winOptions = "toolbar=0,location=0,directories=0,menubar=0,copyhistory=0,left=" 
      + left + ",top=" + top + ",width=" + width + ",height=" + height + option;
  if (winHandle != null) {
      winHandle.close();
  }
  winHandle = window.open(URL, target,  winOptions);
  winHandle.focus();
  return winHandle;
}

/**
 * pop »õÃ¢À» ¶ç¿ì´Â ¸Þ¼­µå
 *
 * @param URL           »õÃ¢À» ¶ç¿ï ÁÖ°í 
 * @param target        »õÃ¢ÀÇ ÀÌ¸§
 * @param width         »õÃ¢ÀÇ °¡·ÎÅ©±â
 * @param height        »õÃ¢ÀÇ ¼¼·ÎÅ©±â
 * @param userOption    »ç¿ëÀÚ ¿É¼Ç 
 */
function pop(URL, target, width, height, userOption, isViewStaus )
{
  var option = "";
  var left = 10;
  var top  = 10;

  if ( width  == undefined || width  == "" )
  {
      width  = 300;
  }
  else 
  {
      width = parseInt(width, 10);
  }
  
  if ( height == undefined || height == "" )
  {
      height = 400;
  }
  else 
  {
      height = parseInt(height, 10);
  }

  if ( isViewStaus == undefined || isViewStaus == "" )
  {
      option += ",scrollbars=0,resizable=0,status=0";
  }
  else
  {
      option += ",scrollbars=1,resizable=1,status=1";    
  }

  if( width < 700 ) 
  {
      left = (screen.width  - width) / 2;
  }

  if( height < 500 )
  {
      top =  (screen.height - height) / 2;
  }

  if (  userOption == null || userOption == undefined || userOption == "" )
  {
      option += ",left=" + left + ",top=" + top;
  }
  else
  {
      option += "," + userOption;
  }

  var winOptions = "toolbar=0,location=0,directories=0,menubar=0,copyhistory=0"
                  +",width=" + width + ",height=" + height + option;

  if (winHandle != null) 
  {
      winHandle.close();
  }

  winHandle = window.open(URL, target,  winOptions);
  winHandle.focus();
}

// ¸ð´ÞÃ¢ ÆË¾÷
function popMd(URL, w, h) 
{
  if (h == null || h < 10) {
      h = 200;
  }
  if (w == null || w < 10) {
      w = 400;
  }

  var top  = 10;
  var left = 10;
  if(screen.height < 500) top = (screen.height - h) / 3;
  if(screen.width < 700) left = (screen.width  - w) / 2;

  var settings ="dialogHeight: " + h +"px; dialogWidth: " + w + "px; dialogTop: " + top + "px; dialogLeft: " + left + "px; "; 
  settings +="scrollbars:auto; resizable:1; status:1; help:0"; 
  return this.showModalDialog(URL, this, settings);
}

/* This function is used to set cookies */
function setCookie(name, value, expire, path) 
{ 
  path = (!path) ? "/" : path; 
  var todaydate = new Date();
  unixtime = todaydate.getTime();

  if (value==null) expire = 0;

  if (expire != null) 
  {
    extime = unixtime+(expire*1000);
    todaydate.setTime(extime);
    expiretime = " expires=" + todaydate.toUTCString() +";"; 
  }
  else
  {
    expiretime = ""; 
  }
  document.cookie = name + "=" + escape(value) + "; path=" + path + ";" + expiretime; 
}

/* This function is used to get cookies */
function getCookie( name ) 
{
    var prefix = name + "=" 
    var start = document.cookie.indexOf(prefix) 

    if (start==-1) {
        return null;
    }
    
    var end = document.cookie.indexOf(";", start+prefix.length) 
    if (end==-1) {
        end=document.cookie.length;
    }

    var value=document.cookie.substring(start+prefix.length, end) 
    return unescape(value);
}

/* This function is used to delete cookies */
function removeCookie(name, path, domain) 
{
  if ( getCookie(name) ) 
  {
    document.cookie = name + "=" + ((path) ? "; path=" + path : "") 
      + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

/* Æû Ã³¸® °ü·Ã ¸Þ¼­µå */

/**
 * Ã·ºÎÆÄÀÏ ¾Ù¸®¸ÕÆ®¸¦ »ý¼º
 * @param id   ¾Ù¸®¸ÕÆ® ¾ÆÀÌµð
 * @param type ¾Ù¸®¸ÕÆ® Å¸ÀÔ (file, text, button)
 * @param name ¾Ù¸®¸ÕÆ® ¸í
 * ´ÙÁß ¾÷·Îµå ¾Ù¸®¸ÕÆ®¸¦ ±¸¼ºÇÏ±â À§ÇØ name ÆÄ¶ó¹ÌÅÍ°¡ ÇÊ¿ä
 */
function addElementToId(id, type, nm) {
    uploadElements  = document.getElementById(id);
    listItem        = document.createElement("div");
    element         = document.createElement("input");
    element.type    = type;
    element.name    = nm;
    // element.id      = nm;
    listItem.appendChild( element );
    uploadElements.appendChild(listItem);
}

function selectedAll( id ) {
   var element = document.getElementById( id ); 
   if(element == null) 
   {
      return false;
   } 
   for (var i=0; i<element.length; i++) 
   {
       element.options[i].selected = true;
   }
}
onChange="alert(this.id);"

/**
 * µ¿ÀûÀ¸·Î JS ÆÄÀÏÀ» ÀÎÅ©·çµå ÇÕ´Ï´Ù.
 * ÀÎÅ©·çµå½Ã ¹Ýµå½Ã eval ¸Þ¼­µå·Î °¨½Î ÁÖ¼¼¿ä
 * eval( includeJS('$YOUR_JS_SRC.js') );
 */
function includeJS( jsFile ) {
    try {
        if (getBrowserType() == 'IE') {
            var textDoc = new ActiveXObject('Msxml2.XMLHTTP');
            textDoc.open('GET', jsFile, false);
            textDoc.send(null);
            return textDoc.responseText;
        }
    }
    catch (ex) {
        // alert('Exception in loading JavaScript file:\n\n'+ex);
    }
}

/**
 * ºê¶ó¿ìÁ® À¯ÇüÀ» ¸®ÅÏ
 */
function getBrowserType() {
    if (document.documentElement && document.documentElement.applyElement) 
    {
        return 'IE';
    } 
    else if (document.implementation && document.implementation.createDocument) 
    {
        return 'NN';
    } 
    else 
    {
        return "NOT";
    }
}

/**
 * ½ÃÀÛÆäÀÌÁö ¼³Á¤
 */
function setStartWebsite(url) 
{
    this.setHomePage(url);
}

/**
 * Áñ°ÜÃ£±â Ãß°¡
 */
function addFavorite(name, url) 
{
    window.external.AddFavorite(url, name);
}

/**
 * 
 */
function setRoleId(id, entn_type)
{
   var element = document.getElementById( id ); 
   if (element == null) {
      return false;
   }
    switch( entn_type ) {
    case '01' :
      element.value = '5'; // ¹èÃâÀÚ 
      break;
    case '02' :
      element.value = '6'; // ¿î¹ÝÀÚ
      break;
    case '03' :
      element.value = '3,7'; // Ã³¸®ÀÚ 
      break;
    case '04' :
      element.value = '3,7,6';  // Ã³¸®¿î¹ÝÀÚ 
      break;
    case '05' :
      element.value = '5,6';  // ¹èÃâ¿î¹ÝÀÚ 
      break;
    case '06' :
      element.value = '3,5,7';  // ¹èÃâÃ³¸®ÀÚ 
      break;
    case '07' :
      element.value = '3,5,6,7'; // ¹èÃâÃ³¸® ¿î¹ÝÀÚ 
      break;
    case '08' :
      element.value = '27';     // ±×·ì ¹èÃâÀÚ 
      break;
    case 'ptrt' :
      element.value = '13';     // °øµ¿Ã³¸®
      break;
    }
}