// <select id=sel2 name=sel>
//   <option value=1>1111</option>
//   <option value=2>2222</option>
//   <option value=3>3333</option>
//   <option value=4>4444</option>
//   <option value=6>5555</option>
// </select>
//
// <script>makeselbox('sel2', 100, "alert(this.value)")</script>

  document.onmouseup = SmouseUp;
  if(navigator.appName == 'Netscape') 
    document.captureEvents(Event.MOUSEUP);

  var tmpsel = '';

  function SmouseUp(e)
  {
    if (tmpsel)
    {
      document.getElementById(tmpsel).style.display = 'none';
    }
  }

  function makeselbox(sname, width, scriptfunc)
  {
    imgurl = 'http://bntnews.hankyung.com/img/';

    f = document.getElementById(sname);
    len = f.options.length;
    sublayername = 'layer' + sname;
    f.style.display = 'none';

    selvalue = getselectvalue(sname);

    document.writeln('<table width="' + width + '" height="20" border="0" cellspacing="0" cellpadding="0" style="cursor:pointer; border:solid 1px #C8C8C8">');
    document.writeln('<tr onclick="showlist(\'' + sublayername + '\')">');
    document.writeln('<td width="106" valign="top" style="padding:4 0 0 5" class="arti_select1 sp01"><span id="span' + sname + '">' + selvalue[1] + '</span></td>');
    document.writeln('<td width="11"><img src="/img/icon_bntnews_downarw01.gif" border="0"></td>');
    document.writeln('</tr>');
    document.writeln('</table>');
    document.writeln('<table id=' + sublayername + ' border="0" width="' + width + '" cellpadding="0" cellspacing="0" style="position:absolute; display:none; border:solid 1px #C8C8C8; border-top:none; cursor:pointer"><tr><td height="6"></td></tr>');

    if (scriptfunc)
    {
      r = /\"/g;
      scriptfunc = scriptfunc.replace(r, '\'');
    }

    if (len)
    {
      for(i=0; i<len; i++)
      {
        if (scriptfunc)
        {
          //r = /this\.value/g;
          //scriptfunction = scriptfunc.replace(r, '\'' + f.options[i].value + '\'');
          r = /this/g;
          scriptfunction = scriptfunc.replace(r, 'document.getElementById(\''+sname+'\')');
        }
        else
          scriptfunction = '';

        document.writeln('<tr><td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td style="padding:3 6 2 6" class="arti_select1 sp01" onclick="selectitem(\'' + f.options[i].value + '\', \'' + sname + '\', this);' + scriptfunction + '"  onmouseover="mover(this)" onmouseout="mout(this)"><nobr style="display:block; overflow:hidden;">' + f.options[i].text + '</nobr></td></tr></table></td></tr>');
      }
    }
    else
      document.writeln('<tr><td bgcolor="#FFFFFF">' + f.options.text + '</td></tr>');

    document.writeln('<tr><td height="3" bgcolor="#FFFFFF"></td></tr></table>');

  }

  function selectitem(v, sname, t)
  {
    sublayername = 'layer' + sname;

    f = document.getElementById(sname);
    l = document.getElementById(sublayername);
    len = f.length;
    spanname = 'span' + sname;

    if (len)
    {
      for(i=0; i<len; i++)
      {
        if (f.options[i].value == v)
        {
          f.options[i].selected = true;
          document.getElementById(spanname).innerHTML = f.options[i].text;
        }
        else
          f.options[i].selected = false;
      }
    }
    else
    {
      f.options.selected = true;
    }

    t.style.background = '#FFFFFF';
		t.style.color = '#777777';
    l.style.display = 'none';
  }

  function mover(obj)
  {
    obj.style.background = '#E8E8E8';
		obj.style.color = '#777777';
  }

  function mout(obj)
  {
    obj.style.background = '#FFFFFF';
		obj.style.color = '#777777';
  }

  function getselectvalue(sname)
  {
    var f, len;
    var r = new Array();

    f = document.getElementById(sname);
    len = f.options.length;

    if (len)
    {
      for(i=0;i<len;i++)
      {
        if (f.options[i].selected == true)
        {
          r[0] = f.options[i].value;
          r[1] = f.options[i].text;
          break;
        }
      }

      if (!r)
      {
        r[0] = f.options[0].value;
        r[1] = f.options[0].text;
      }
    }
    else
    {
      r[0] = f.options.value;
      r[1] = f.options.text;
    }

    return r;
  }

  function showlist(lname)
  {
    tmpsel = lname;

    f = document.getElementById(lname);

    if (f.style.display == '')
      f.style.display = 'none';
    else
      f.style.display = '';
  }

  function nowtime()
  {
    toNow = new Date();

	write(toNow.getYear() + "/" + toNow.getMonth() + "/" +  toNow.getDate() + " " + toNow.getHours() + ":" + toNow.getMinutes());

  }

  function MM_findObj(n, d) {
	  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 && document.getElementById) x=document.getElementById(n); return x;
	}
  
  function MM_swapImage() {
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

