function onBtnClick( link, strTarget )
{
  if ( strTarget && strTarget.length > 0 ) window.open( link, strTarget );
  else document.location = link;
}

function forceQuote( str )
{
  var nDouble = 0;
  var ch;
  var i;

  ch = str.charCodeAt( 0 );
  if ( ( ch == 34 ) || ( ch == 39 ) ) return str;

  for ( i = 1 ; i < str.length - 1 ; i++ )
  {
    ch = str.charCodeAt( i );
    if ( ch == 39 )
    {
      nDouble = 1;
      break;
    }
  }

  if ( nDouble ) strQuote = "\"";
  else strQuote = "'";

  return ( strQuote + str + strQuote );
}

function getRealLink( link )
{
  var strOnBtnClick = "";
  var nPos = -1;
  var strHREF = "";
  var strTarget = "";
  var strLow;

  strLow = link;
  strLow.toLowerCase();
  nPos = strLow.indexOf( "javascript:" );
  if ( nPos >= 0 ) return forceQuote( link );

  nPos = link.indexOf( " " );
  if ( nPos > 0 ) strHREF = link.substring( 0, nPos );
  else strHREF = link;

  nPos = link.indexOf( "target=" );
  if ( nPos > 0 ) strTarget = link.substr( nPos + 7 );

  strHREF = forceQuote( strHREF );
  strTarget = forceQuote( strTarget );
  strOnBtnClick = "javascript:onBtnClick( " + strHREF + " , " + strTarget + " )";
  strOnBtnClick = forceQuote( strOnBtnClick );

  return strOnBtnClick;
}


function changeC(currentBtnID, lightC, midC, darkC)
{
  var colLiteCR = document.getElementsByName("lightArea_"+currentBtnID);
  var colMidCR = document.getElementsByName("midArea_"+currentBtnID);
  var colDarkCR = document.getElementsByName("darkArea_"+currentBtnID);

  for (var i=0; i<colLiteCR.length; i++)
    colLiteCR[i].bgColor = lightC;
  for (var i=0; i<colMidCR.length; i++)
    colMidCR[i].bgColor = midC;
  for (var i=0; i<colDarkCR.length; i++)
    colDarkCR[i].bgColor = darkC;
}


/*****************************************************************************
(int) roundType: ¸ð¼­¸® rounding type (0~6)
(string) edgePos: ¸ð¼­¸® À§Ä¡ ('UL', 'UR', 'LL', 'LR')
(string) borderC: ¹öÆ° °æ°è »ö±ò
(string) lightC: ¹öÆ° ¹ÙÅÁÁß ¿ÞÂÊ°ú À§ÂÊÀÇ ¹àÀº ºÎºÐ »ö±ò
(string) midC: ¹öÆ° ¹ÙÅÁ »ö±ò
(string) darkC: ¹öÆ° ¹ÙÅÁÁß ¿À¸¥ÂÊ°ú ¾Æ·¡ÂÊÀÇ ¾îµÎ¿î ºÎºÐ »ö±ò
(bool) border: °æ°è À¯¹« ('0' or '1') => Tab¿¡¸¸ »ç¿ë
(bool) iduse: color º¯È­¸¦ À§ÇÑ id »ç¿ë À¯¹« ('0' or '1')
*****************************************************************************/
function getEdgeTag (roundType, edgePos, borderC, lightC, darkC, midC, border, iduse) {
  if (!border) border = '1';
  if (!iduse) iduse = '1';

  /* shape for "LL (Lower Left)" */
  shape0 = new Array (5);
  shape0[0] = new Array (1,2,4,4,4);
  shape0[1] = new Array (1,2,4,4,4);
  shape0[2] = new Array (1,2,4,4,4);
  shape0[3] = new Array (1,3,3,3,3);
  shape0[4] = new Array (1,1,1,1,1);
  shape1 = new Array (5);
  shape1[0] = new Array (1,2,4,4,4);
  shape1[1] = new Array (1,2,4,4,4);
  shape1[2] = new Array (1,2,4,4,4);
  shape1[3] = new Array (1,3,3,3,3);
  shape1[4] = new Array (0,1,1,1,1);
  shape2 = new Array (5);
  shape2[0] = new Array (1,2,4,4,4);
  shape2[1] = new Array (1,2,4,4,4);
  shape2[2] = new Array (1,2,4,4,4);
  shape2[3] = new Array (0,1,3,3,3);
  shape2[4] = new Array (0,0,1,1,1);
  shape3 = new Array (5);
  shape3[0] = new Array (1,2,4,4,4);
  shape3[1] = new Array (1,2,4,4,4);
  shape3[2] = new Array (0,1,3,4,4);
  shape3[3] = new Array (0,0,1,3,3);
  shape3[4] = new Array (0,0,0,1,1);
  shape4 = new Array (5);
  shape4[0] = new Array (1,2,4,4,4);
  shape4[1] = new Array (1,2,4,4,4);
  shape4[2] = new Array (0,1,3,4,4);
  shape4[3] = new Array (0,1,1,3,3);
  shape4[4] = new Array (0,0,0,1,1);
  shape5 = new Array (5);
  shape5[0] = new Array (1,2,4,4,4);
  shape5[1] = new Array (0,1,3,4,4);
  shape5[2] = new Array (0,1,3,3,4);
  shape5[3] = new Array (0,0,1,1,3);
  shape5[4] = new Array (0,0,0,0,1);
  shape6 = new Array (5);
  shape6[0] = new Array (0,1,2,4,4);
  shape6[1] = new Array (0,1,2,4,4);
  shape6[2] = new Array (0,0,1,3,3);
  shape6[3] = new Array (0,0,0,1,1);
  shape6[4] = new Array (0,0,0,0,0);

  shape = eval ('shape'+roundType);
  cv0 = ''; cv1 = borderC; cv2 = lightC; cv3 = darkC; cv4 = midC;
  xbegin = 0; xend = 5; xinc= 1;
  ybegin = 0; yend = 5; yinc= 1;

  if (edgePos == "UL") {
    cv3 = lightC;
    xbegin = 4; xend = -1; xinc = -1;
  }
  else if (edgePos == "UR") {
    cv2 = darkC; cv3 = lightC;
    xbegin = 4; xend = -1; xinc = -1;
    ybegin = 4; yend = -1; yinc = -1;
  }
  else if (edgePos == "LR") {
    cv2 = darkC;
    ybegin = 4; yend = -1; yinc = -1;
  }

  str = "<table border=0 cellpadding=0 cellspacing=0>\n";
  for (x = xbegin; x != xend; x += xinc) {
    str += "<tr>";
    for (y = ybegin; y != yend; y += yinc) {
      if (border == '0' && y == 0) continue;

      bgtag = '';
      color = eval ('cv'+shape[x][y]);
      if (color != '') bgtag = " bgcolor="+color;

      idtag = '';
      if (iduse == '1') {
        if (color == lightC && color != darkC) idtag = " id=lightArea_"+btnID;
        else if (color == darkC && color != lightC) idtag = " id=darkArea_"+btnID;
        else if (color == midC) idtag = " id=midArea_"+btnID;
      }

      wtag = ''; htag = '';
      if (x == xbegin) wtag = " width=1"; 
      if (y == ybegin || y == ybegin+yinc) htag = " height=1"; 

      str += "<td" + wtag + htag + idtag + bgtag + ">"
    }
    str += "</tr>\n";
  }
  str += "</table>";

  return str;
}

function docWrite (strFormat, codeOnly) {
  if (codeOnly){
    strFormat = strFormat.replace (/</g,"&lt;");
    strFormat = strFormat.replace (/>/g,"&gt;");
    document.write (strFormat);
  }
  else
    document.write (strFormat);
}

var btnID = 0;

/*****************************************************************************
(string) title: ¹öÆ° Á¦¸ñ
(string) cssName: cascading style sheet ÀÌ¸§
(string) link: ¹öÆ° link
(int) roundType: round type (0~6)
(boolean) disable: ¹öÆ° ºñÈ°¼ºÈ­ flag
(string) borderC: ¹öÆ° °æ°è »ö±ò
(string) lightC: ¹öÆ° ¹ÙÅÁÁß ¿ÞÂÊ°ú À§ÂÊÀÇ ¹àÀº ºÎºÐ »ö±ò
(string) midC: ¹öÆ° ¹ÙÅÁ »ö±ò
(string) darkC: ¹öÆ° ¹ÙÅÁÁß ¿À¸¥ÂÊ°ú ¾Æ·¡ÂÊÀÇ ¾îµÎ¿î ºÎºÐ »ö±ò
(string) moMidC: mouse over ½Ã¿¡ ¹öÆ° ¹ÙÅÁ »ö±ò
(string) mcMidC: mouse click ½Ã¿¡ ¹öÆ° ¹ÙÅÁ »ö±ò
(int) width: ¹öÆ° ³Êºñ
(int) height: ¹öÆ° ³ôÀÌ 
(string) iconURL: image icon URL
(string) iconPos: image icon position ('top', 'left', 'right', 'bottom');
(int) codeOnly: code return for debugging(default 0)
*****************************************************************************/
function zubuButton(title, link, width, height, cssName, roundType, disable, borderC, lightC, darkC, midC, moMidC, mcMidC, iconURL, iconPos, codeOnly)
{
	if (!cssName) cssName = "black9";
	if (!height) height = 26;
	makeButton(title, link, width, height, cssName, roundType, disable, borderC, lightC, darkC, midC, moMidC, mcMidC, iconURL, iconPos, codeOnly);
}
function smallButton(title, link, width, height, cssName, roundType, disable, borderC, lightC, darkC, midC, moMidC, mcMidC, iconURL, iconPos, codeOnly)
{
	if (!cssName) cssName = "black8";
	if (!height) height = 18;
	makeButton(title, link, width, height, cssName, roundType, disable, borderC, lightC, darkC, midC, moMidC, mcMidC, iconURL, iconPos, codeOnly);
}
function makeButton(title, link, width, height, cssName, roundType, disable, borderC, lightC, darkC, midC, moMidC, mcMidC, iconURL, iconPos, codeOnly)
{
  var strFormat;

  btnID++;
<!--  if (!title) title = "È® ÀÎ"; -->
  if (!title) return; 
  if (!cssName) cssName = "black9";
  if (!roundType) roundType = 4;
  if (!disable) disable = 0;
  if (!link) link = "#";
  if (!borderC) borderC = "#BBBBBB";
  if (!lightC) lightC = "#FFFFFF";
  if (!darkC) darkC = "#DDDDDD";
  if (!midC) midC = "#f8f8f8";
  if (!moMidC) moMidC = midC;
  if (!mcMidC) mcMidC = midC;
  if (!height) height = 26;
  if (!codeOnly) codeOnly = 0;

  imgGap = 4;
  leftGap = 5;
  rightGap = 5;
  topGap = 2;
  bottomGap = 0;

  link = getRealLink( link );

  if (!width || (width <= 0)) widthTag = "";
  else widthTag = " width="+width;
  if (!height || (height <= 0)) heightTag = "";
  else heightTag = " height="+height;

  // Get round tag
  ULEdgeTag = getEdgeTag (roundType, "UL", borderC, lightC, darkC, midC);
  UREdgeTag = getEdgeTag (roundType, "UR", borderC, lightC, darkC, midC);
  LLEdgeTag = getEdgeTag (roundType, "LL", borderC, lightC, darkC, midC);
  LREdgeTag = getEdgeTag (roundType, "LR", borderC, lightC, darkC, midC);

  aTagB = ""; aTagE = "";
  mouseAction = " onmouseover=\"this.style.cursor='default'\"";
  if (!disable) {
    onmouseoverTag = "onmouseover=\"this.style.cursor='hand';changeC("+btnID+", '"+lightC+"', '"+moMidC+"', '"+darkC+"')\"";
    aTagB = "<a href="+link+" onclick='window.event.returnValue=false' "+onmouseoverTag+" onfocus='this.blur()'>";
    aTagE = "</a>";
    mouseAction = " onclick="+link+" onmousedown=\"changeC("+btnID+", '"+darkC+"', '"+mcMidC+"', '"+lightC+"')\" onmouseup=\"changeC("+btnID+", '"+lightC+"', '"+moMidC+"', '"+darkC+"')\" "+onmouseoverTag+" onmouseout=\"changeC("+btnID+", '"+lightC+"', '"+midC+"', '"+darkC+"')\"";
  }

  strFormat = "<table id=nhnButton border=0"+widthTag+heightTag+" cellpadding=0 cellspacing=0"+mouseAction+"><tr>";
  docWrite (strFormat, codeOnly);

  ///////////////////////////////////////////////////////////////////////////
  // Make 1st column (left)
  strFormat = ""+
  "<td width=5 height=100%>"+
    "<table width=5 height=100% border=0 cellpadding=0 cellspacing=0>"+
      "<tr><td width=5 height=5>"+ULEdgeTag+"</td>"+
      "<tr><td width=5 height=100%>"+
        "<table border=0 cellpadding=0 cellspacing=0 height=100%><tr>"+
          "<td width=1 height=100% bgcolor="+borderC+"></td>"+
          "<td width=1 id=lightArea_"+btnID+" bgcolor="+lightC+"></td>"+
          "<td width=3 id=midArea_"+btnID+" bgcolor="+midC+"></td>"+
        "</tr></table>"+
      "</td></tr>"+
      "<tr><td width=5 height=5>"+LLEdgeTag+"</td>"+
    "</table>"+
  "</td>";
  docWrite (strFormat, codeOnly);

  ///////////////////////////////////////////////////////////////////////////
  // Make 2nd column (center)
  strFormat = ""+
  "<td height=100%><table width=100% height=100% border=0 cellpadding=0 cellspacing=0>"+
    "<tr><td height=1 bgcolor="+borderC+"></td></tr>"+
    "<tr><td height=1 id=lightArea_"+btnID+" bgcolor="+lightC+"></td></tr>";
  if (topGap) strFormat += "<tr><td height=topGap id=midArea_"+btnID+" bgcolor="+midC+"></td></tr>";
  strFormat += 
    "<tr><td id=midArea_"+btnID+" bgcolor="+midC+" align=center><table border=0 cellpadding=0 cellspacing=0>";

  // Show top icon image if it exists
  if (iconURL && iconPos == "top") {
    strFormat += "<tr><td colspan=3 align=center>"+aTagB+"<img src='"+iconURL+"' border=0>"+aTagE+"</td></tr>";
    strFormat += "<tr><td colspan=3 height="+imgGap+"></td></tr>";
  }

  strFormat += "<tr>";
  strFormat += "<td width="+leftGap+"></td>";

  // Set left, right icon image tags if they exist
  lIconTag = ''; rIconTag = '';
  if (iconURL && iconPos == "left")
    lIconTag = "<img src='"+iconURL+"' border=0 align=absmiddle>&nbsp;";
  else if (iconURL && iconPos == "right")
    rIconTag = "&nbsp;<img src='"+iconURL+"' border=0 align=absmiddle>";

  strFormat += "<td align=center nowrap>"+lIconTag+aTagB+"<font id="+cssName+">"+title+"</font>"+aTagE+rIconTag+"</td>";

  // Show left icon image if it exists
  //if (iconURL && iconPos == "left") {
  //  strFormat += "<td>"+aTagB+"<img src='"+iconURL+"' border=0>"+aTagE+"</td>";
  //  strFormat += "<td width="+imgGap+"></td>";
  //}

  //strFormat += "<td align=center class='"+cssName+"' nowrap>"+aTagB+title+aTagE+"</td>";

  // Show right icon image if it exists
  //if (iconURL && iconPos == 'right') {
  //  strFormat += "<td width="+imgGap+"></td>";
  //  strFormat += "<td>"+aTagB+"<img src='"+iconURL+"' border=0>"+aTagE+"</td>";
  //}

  strFormat += "<td width="+rightGap+"></td>";
  strFormat += "</tr>";

  // Show bottom icon image if it exists
  if (iconURL && iconPos == "bottom") {
    strFormat += "<tr><td colspan=3 height="+imgGap+"></td></tr>";
    strFormat += "<tr><td colspan=3 align=center>"+aTagB+"<img src='"+iconURL+"' border=0>"+aTagE+"</td></tr>";
  }

  strFormat += "</table></td></tr>";
  if (bottomGap) strFormat += "<tr><td height=bottomGap id=midArea_"+btnID+" bgcolor="+midC+"></td></tr>";
  strFormat += 
    "<tr><td height=1 id=darkArea_"+btnID+" bgcolor="+darkC+"></td></tr>"+
    "<tr><td height=1 bgcolor="+borderC+"></td></tr>"+
  "</table></td>";
  docWrite (strFormat, codeOnly);

  ///////////////////////////////////////////////////////////////////////////
  // Make 3nd column (right)
  strFormat = ""+
  "<td width=5>"+
    "<table width=5 height=100% border=0 cellpadding=0 cellspacing=0>"+
      "<tr><td width=5 height=5>"+UREdgeTag+"</td>"+
      "<tr><td width=5 height=100%>"+
        "<table border=0 cellpadding=0 cellspacing=0 height=100%><tr>"+
          "<td width=3 height=100% id=midArea_"+btnID+" bgcolor="+midC+"></td>"+
          "<td width=1 id=darkArea_"+btnID+" bgcolor="+darkC+"></td>"+
          "<td width=1 bgcolor="+borderC+"></td>"+
        "</tr></table>"+
      "</td></tr>"+
      "<tr><td width=5 height=5>"+LREdgeTag+"</td>"+
    "</table>"+
  "</td>";
  docWrite (strFormat, codeOnly);

  strFormat = "</tr></table>";
  docWrite (strFormat, codeOnly);
}


//////////////////////////////////////////////////////////////////////////////
// CSS definition for button text
//////////////////////////////////////////////////////////////////////////////
document.write ("\
<style type=text/css>\
#white9 { line-height: 11pt ; font-size: 9pt ; text-decoration: none ; color: #FFFFFF ;}\
#white9b { line-height: 11pt ; font-size: 9pt ; font-weight: bold ; text-decoration: none ; color: #FFFFFF ;}\
#black8 { font-family: 'µ¸¿ò' ; line-height: 11pt ; font-size: 8pt ; text-decoration: none ; color: #000000 ;}\
#black9 { line-height: 11pt ; font-size: 9pt ; text-decoration: none ; color: #000000 ;}\
#black9b { line-height: 11pt ; font-size: 9pt ; font-weight: bold ; text-decoration: none ; color: #000000 ;}\
#gulim9 { line-height: 11pt ; font-size: 9pt ; text-decoration: none ; color: #000000 ;}\
#gulim9b { line-height: 11pt ; font-size: 9pt ; font-weight: bold ; text-decoration: none ; color: #000000 ;}\
#gulim9W { line-height: 11pt ; font-size: 9pt ; text-decoration: none ; color: #FFFFFF ;}\
#gulim9Wb { line-height: 11pt ; font-size: 9pt ; font-weight: bold ; text-decoration: none ; color: #FFFFFF ;}\
#gulim10 { line-height: 11pt ; font-size: 10pt ; text-decoration: none ; color: #000000 ;}\
#gulim10b { line-height: 11pt ; font-size: 10pt ; font-weight: bold ; text-decoration: none ; color: #000000 ;}\
#gulim10W { line-height: 11pt ; font-size: 10pt ; text-decoration: none ; color: #FFFFFF ;}\
#gulim10Wb { line-height: 11pt ; font-size: 10pt ; font-weight: bold ; text-decoration: none ; color: #FFFFFF ;}\
\
</style>\
")

