
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// SaySelect Environment Constants
var SS1_ENV = new Object();
SS1_ENV.IE_Version = new Number(((window.navigator.appVersion.split('; '))[1].split(' '))[1]);
SS1_ENV.CR = new Object();
SS1_ENV.CR.ReverseBackground = '#B4B4B4';
SS1_ENV.CR.ReverseText = 'white';
SS1_ENV.CR.Border = '#DBDBD7';
SS1_ENV.CR.BorderActive = '#B4B4B4';
SS1_ENV.ImgPrefix = '/images/common/';
SS1_ENV.DefaultHeight = 20;
SS1_ENV.ButtonWidth = 19;
SS1_ENV.OptionsDivStyle = "\
  display:none;\
  z-index:10;\
  position:absolute;\
  border:1 solid "+ SS1_ENV.CR.Border+";\
  background-color:white;\
  scrollbar-face-color:#D4D0C8;\
  scrollbar-shadow-color:white;\
  scrollbar-highlight-color:#F6F5F4;\
  scrollbar-3dlight-color:white\
  scrollbar-darkshadow-color:#86837E;\
  scrollbar-track-color:#F6F5F4;\
  scrollbar-arrow-color:#86837E;";
SS1_ENV.OptionNobrStyle = "\
  font-size:11px;\
  font-family:µ¸¿ò;";
// SaySelect Variables
var SS1_VAR = new Object();
SS1_VAR.DivDummy = document.createElement("DIV");
SS1_VAR.SelectList = new Array();
SS1_VAR.bEventAttached = false;

var SS1_CreatedElements = new Object();

function unloadObjects()
{
  try {
    if (SS1_VAR && SS1_VAR.SelectList)
    {
      for (key in SS1_VAR.SelectList)
      {
	if (SS1_VAR.SelectList[key])
	{
	  try {
	   SS1_VAR.SelectList[key].select.setAttribute('SS1', 0);
	  } catch (e) {};
	  delete SS1_VAR.SelectList[key];
	}
      }
    }
  } catch (e) {};
}

attachEvent("onunload", unloadObjects);

function SS1_create (srcHTML, ListMax, bAutoDetect)
{
  // property
  this.SS1ID = SS1_VAR.SelectList.length;
  this.bOriginalSelect = (bAutoDetect && SS1_ENV.IE_Version < 5.5);
  this.select = SS1_createElement(srcHTML);
  this.selectedIndex = this.select.selectedIndex;
  this.options = this.select.options;
  this.width = parseInt(this.select.style.width);
  this.height = (this.select.style.height) ? parseInt(this.select.style.height) : SS1_ENV.DefaultHeight;
  this.OptionHeight = this.height - 4;
  this.bListDown = (ListMax && '-'==ListMax.toString().substr(0, 1)) ? false : true;
  this.ListMax = (!isNaN(parseInt(ListMax))) ? Math.abs(ListMax) : 100;

  this.Table;
  this.TitleDiv;
  this.TitleTable;
  this.TitleWrapper;
  this.OptionsDiv;
  this.OptionsWrapper;
  this.OptionsTable;
  this.bFocused = false;
  this.bExpanded = false;
  this.bReverse = false;

  // private method
  this.isThisEventToBeCanceled = SS1_isThisEventToBeCanceled;
  this.toggleTitle = SS1_toggleTitle;
  this.syncSelectedIndex = SS1_syncSelectedIndex;
  this.toggleOptions = SS1_toggleOptions;
  this.turnOnOption = SS1_turnOnOption;
  this.turnOffOption = SS1_turnOffOption;
  this.handleMousewheel = SS1_handleMousewheel;
  this.handleOverTitle = SS1_handleOverTitle;
  this.handleOutTitle = SS1_handleOutTitle;
  this.handleOverOption = SS1_handleOverOption;
  this.createTable = SS1_createTable;
  this.createTitleDiv = SS1_createTitleDiv;
  this.checkOptionsDiv = SS1_checkOptionsDiv;
  this.createOptionsDiv = SS1_createOptionsDiv;
  this.createOptionTr = SS1_createOptionTr;
  this.adjustOptionsDiv = SS1_adjustOptionsDiv;
  this.syncOptions = SS1_syncOptions;
  this.preSS1Option = SS1_preSS1Option;
  this.moveOption = SS1_moveOption;
  this.releaseOption = SS1_releaseOption;
  this.preSS1Title = SS1_preSS1Title;
  this.releaseTitle = SS1_releaseTitle;

  // public method
  this.display = SS1_display;
  this.disableSelect = SS1_disableSelect;
  this.enableSelect = SS1_enableSelect;
  this.insertOption = SS1_insertOption;
  this.deleteOption = SS1_deleteOption;
  this.changeOption = SS1_changeOption;

  // initiate
  this.createTable();
  this.select.setAttribute('SS1', this);
  if (!this.bOriginalSelect)
    this.select.onpropertychange = SS1_handlePropertychange;
  SS1_VAR.SelectList[this.SS1ID] = this;
}
function SS1_display ()
{
  document.write("<div id=SS1_TempDiv></div>\n");
  document.all.SS1_TempDiv.appendChild(this.Table);
  document.all.SS1_TempDiv.removeNode();
}
function SS1_write (srcHTML, ListMax, bAutoDetect)
{
  var oSS1 = new SS1_create(srcHTML, ListMax, bAutoDetect);
  oSS1.display();
  return oSS1;
}
function SS1_disableSelect ()
{
  this.select.disabled = true;
  this.TitleTable.cells(0).childNodes(0).style.color = 'gray';
  this.toggleTitle(false);
}
function SS1_enableSelect ()
{
  this.select.disabled = false;
  this.TitleTable.cells(0).childNodes(0).style.color = '';
}
function SS1_insertOption (value, innerText, idx)
{
  this.checkOptionsDiv();

  var NewOption = document.createElement("OPTION");
  SS1_CreatedElements[SS1_CreatedElements.length] = NewOption;
  this.options.add(NewOption, idx);
  NewOption.innerText = innerText;
  NewOption.value = value;

  if (!this.bOriginalSelect)
    this.createOptionTr(idx);
  this.syncOptions();
  this.adjustOptionsDiv();
  this.syncSelectedIndex();
}
function SS1_deleteOption (idx)
{
  this.checkOptionsDiv();

  this.options.remove(idx);
  if (!this.bOriginalSelect)
    this.OptionsTable.deleteRow(idx);
  this.syncOptions();
  this.adjustOptionsDiv();
  this.syncSelectedIndex();
}
function SS1_changeOption (idx, value, innerText)
{
  this.checkOptionsDiv();

  this.options[idx].value = value;
  this.options[idx].innerText = innerText;
  this.syncOptions();
  this.syncSelectedIndex();
}

function SS1_cancelEvent (event)
{
  event.cancelBubble = true;
  event.returnValue = false;
}
function SS1_isThisEventToBeCanceled (event)
{
  if ('object' == typeof(event)) {
    switch (event.type) {
      case 'mousedown':
        if (!(event.button & 1)) return true;
        break;
      case 'mouseup':
        if (!(event.button & 1)) return true;
        if (SS1_ENV.IE_Version >= 5.5 && event.srcElement != this.srcElementOfLastMousedown && this.srcElementOfLastMousedown != null) {
          this.srcElementOfLastMousedown = null;
          return true;
        }
        break;
      case 'mouseout':
        if (!(SS1_ENV.IE_Version < 5.5 && event.srcElement == this.srcElementOfLastMousedown))
          return true;
        break;
      case 'mousemove':
        if (SS1_ENV.IE_Version >= 5.5 && event.srcElement != this.srcElementOfLastMousedown && this.srcElementOfLastMousedown != null)
          return true;
        break;
    }
  }
  return false;
}
function SS1_createElement (html)
{
  SS1_VAR.DivDummy.insertAdjacentHTML('afterBegin', html);
  var oEl = SS1_VAR.DivDummy.children(0);
  while (SS1_VAR.DivDummy.children.length > 0) {
    SS1_VAR.DivDummy.removeChild(SS1_VAR.DivDummy.children(0));
  }
  return oEl;
}
function SS1_blurExcept (except)
{
  SS1_cancelEvent(window.event);

  except = ('number'==typeof(except)) ? except : -1;

  var bHasToDetachEvent = true;
  for (var i=0; i < SS1_VAR.SelectList.length; i++) {
    if (-1==except && SS1_VAR.SelectList[i].bFocused && SS1_VAR.SelectList[i].bExpanded) {
      SS1_VAR.SelectList[i].toggleOptions(false, true);
      SS1_VAR.SelectList[i].toggleTitle(true);
      bHasToDetachEvent = false;
    }
    else if (i!=except) {
      if (SS1_VAR.SelectList[i].bExpanded)
        SS1_VAR.SelectList[i].toggleOptions(false, true);
      if (SS1_VAR.SelectList[i].bReverse)
        SS1_VAR.SelectList[i].toggleTitle(false);
      SS1_VAR.SelectList[i].bFocused = false;
    }
  }

  if (SS1_VAR.bEventAttached && bHasToDetachEvent) {
    document.detachEvent('onmousedown', SS1_blurExcept);
    document.detachEvent('ondblclick', SS1_blurExcept);
    SS1_VAR.bEventAttached = false;
  }
}
function SS1_syncSelectedIndex ()
{
  this.selectedIndex = this.select.selectedIndex;

  if (this.bOriginalSelect) return;

  if (this.TitleTable.cells(0).childNodes(0).innerText != this.options[this.selectedIndex].innerText)
    this.TitleTable.cells(0).childNodes(0).innerText = this.options[this.selectedIndex].innerText;
  if (this.bExpanded)
    this.toggleOptions(false);
}
function SS1_toggleTitle (bReverse)
{
  this.bReverse = ('undefined'!=typeof(bReverse)) ? bReverse: (!this.bReverse);
  this.TitleTable.cells(0).style.backgroundColor = this.bReverse ? SS1_ENV.CR.ReverseBackground : '';
  this.TitleTable.cells(0).style.color = this.bReverse ? SS1_ENV.CR.ReverseText : '';
}
function SS1_checkOptionsDiv ()
{
  if (!this.OptionsDiv) {
    this.createOptionsDiv();
    this.Table.cells(0).appendChild(this.OptionsDiv);
  }
}
function SS1_toggleOptions (bExpanded, bStrict)
{
  this.checkOptionsDiv();

  if (!bStrict && !this.bFocused) {
    SS1_blurExcept(this.SS1ID);
  }
  this.bExpanded = ('undefined'!=typeof(bExpanded)) ? bExpanded: (!this.bExpanded);
  if (this.bExpanded) {
    this.adjustOptionsDiv();
    this.OptionsDiv.style.display = 'block';
    if (!bStrict) {
      this.toggleTitle(false);
      this.handleOverOption(this.selectedIndex);
    }
    this.handleOutTitle();
  }
  else {
    this.OptionsDiv.style.display = 'none';
    if (!bStrict) {
      this.toggleTitle(true);
    }
  }
  if (!bStrict) {
    this.bFocused = true;

    if (!SS1_VAR.bEventAttached) {
      document.attachEvent('onmousedown', SS1_blurExcept);
      document.attachEvent('ondblclick', SS1_blurExcept);
      SS1_VAR.bEventAttached = true;
    }
  }
}
function SS1_handlePropertychange ()
{
  if ('propertychange'==window.event.type && 'selectedIndex'==window.event.propertyName) {
    var oSS1 = window.event.srcElement.SS1;
    oSS1.syncSelectedIndex();

    if (null != oSS1.select.onchange)
      oSS1.select.onchange();
  }
}
function SS1_handleMousewheel (event)
{
  var idx = this.selectedIndex;
  if ('mousewheel'==event.type && this.bFocused && this.bReverse) {
    for (var i=0; i < event.wheelDelta; i += 120)
      idx--;
    for (var i=0; i > event.wheelDelta; i -= 120)
      idx++;
  }
  idx = Math.max(idx, 0);
  idx = Math.min(idx, this.options.length - 1);
  this.select.selectedIndex = idx;
}
function SS1_handleOverTitle ()
{
  if (this.bExpanded || this.select.disabled)
    return;

  this.TitleTable.style.borderColor = SS1_ENV.CR.BorderActive;
  this.TitleTable.cells(1).style.display = 'none';
  this.TitleTable.cells(2).style.display = 'block';
}
function SS1_handleOutTitle ()
{
  this.TitleTable.style.borderColor = SS1_ENV.CR.Border;
  this.TitleTable.cells(2).style.display = 'none';
  this.TitleTable.cells(1).style.display = 'block';
}
function SS1_handleOverOption (idx)
{
  for (var i=0; i < this.options.length; i++) {
    if (i==idx)
      this.turnOnOption(i);
    else
      this.turnOffOption(i);
  }
}
function SS1_turnOnOption (idx)
{
  this.OptionsTable.cells(idx).style.color = SS1_ENV.CR.ReverseText;
  this.OptionsTable.cells(idx).style.backgroundColor = SS1_ENV.CR.ReverseBackground;
}
function SS1_turnOffOption (idx)
{
  this.OptionsTable.cells(idx).style.color = '';
  this.OptionsTable.cells(idx).style.backgroundColor = '';
}
function SS1_adjustOptionsDiv ()
{
  if (this.bOriginalSelect) return;

  this.OptionsDiv.style.width = this.width;
  this.OptionsDiv.style.height = Math.min(this.options.length, this.ListMax) * this.OptionHeight + 2;
  this.OptionsWrapper.style.height = this.options.length * this.OptionHeight;
  this.OptionsDiv.style.overflowY = (this.options.length > this.ListMax) ? 'scroll' : '';

  var top = this.Table.offsetTop;
  var left = this.Table.offsetLeft;
  for (var El = this.Table.offsetParent; 'BODY'!=El.tagName && 'absolute'!=El.style.position && 'relative'!=El.style.position; El = El.offsetParent) {
    if ('TABLE' != El.tagName) {
      top += El.clientTop;
      left += El.clientLeft;
    }
    top += El.offsetTop;
    left += El.offsetLeft;
  }
  this.OptionsDiv.style.top = (this.bListDown) ? (top + this.height) : (top - parseInt(this.OptionsDiv.style.height));
  this.OptionsDiv.style.left = left;

  this.TitleWrapper.style.top = 0;
  this.TitleWrapper.style.left = 0;
}
function SS1_syncOptions ()
{
  if (this.bOriginalSelect) return;

  for (var i=0; i < this.options.length; i++) {
    this.OptionsTable.cells(i).setAttribute('index', i);
    if (this.OptionsTable.cells(i).childNodes(0).innerText != this.options[i].innerText)
      this.OptionsTable.cells(i).childNodes(0).innerText = this.options[i].innerText;
  }
}
function SS1_preSS1Title (event)
{
  SS1_cancelEvent(event);

  if (this.select.disabled)
    return;

  this.srcElementOfLastMousedown = event.srcElement;

  this.toggleOptions();
}
function SS1_releaseTitle (event)
{
  SS1_cancelEvent(event);

  if (this.isThisEventToBeCanceled(event)) return;

  this.srcElementOfLastMousedown = null;
}
function SS1_preSS1Option (event)
{
  SS1_cancelEvent(event);

  this.srcElementOfLastMousedown = event.srcElement;
}
function SS1_moveOption (event)
{
  SS1_cancelEvent(event);

  if (this.isThisEventToBeCanceled(event)) return;
  if (!(event.offsetX >= 0 && event.offsetX <= this.OptionsTable.offsetWidth)) return;

  this.handleOverOption(Math.floor(event.offsetY / this.OptionHeight));
}
function SS1_releaseOption (event)
{
  SS1_cancelEvent(event);

  if (this.isThisEventToBeCanceled(event)) return;

  this.srcElementOfLastMousedown = null;

  if (event.offsetX >= 0 && event.offsetX <= this.OptionsTable.offsetWidth) {
    this.toggleOptions(false);
    this.select.selectedIndex = Math.floor(event.offsetY / this.OptionHeight);
  }
}
function SS1_createTable ()
{
  this.Table = SS1_createElement("\
    <table border=0 cellpadding=0 cellspacing=0 style='table-layout:fixed; cursor:default'>\
    <tr><td></td></tr>\
    </table>"
  );
  if (!isNaN(this.width))
    this.Table.style.width = this.width;
  this.Table.style.height = this.height;

  if (!this.bOriginalSelect) {
    this.createTitleDiv();
    this.Table.cells(0).appendChild(this.TitleDiv);
  }
  else {
    this.Table.cells(0).appendChild(this.select);
  }
}
function SS1_createTitleDiv ()
{
  this.TitleDiv = SS1_createElement("\
    <div style='position:relative; top:0; left:0;'>\
      <table border=0 cellpadding=0 cellspacing=0\
        height="+this.height+"\
        bgcolor=white\
        style='table-layout:fixed; border:1 solid "+SS1_ENV.CR.Border+";'\
        onmouseover='SS1_VAR.SelectList["+this.SS1ID+"].adjustOptionsDiv()'\
      >\
      <tr align=left valign=middle>\
        <td bgcolor=#ffffff><nobr style='text-oveflow:hidden;"+SS1_ENV.OptionNobrStyle+";padding:0 0 0 5px;'></nobr></td>\
        <td width="+SS1_ENV.ButtonWidth+" align=left style='word-wrap:normal;font-size:11px;'></td>\
        <td style='display:none' width="+SS1_ENV.ButtonWidth+" style='word-wrap:normal'></td>\
        <td style='display:none'></td>\
      </tr>\
      </table>\
    </div>"
  );
  this.TitleTable = this.TitleDiv.childNodes(0);
  this.TitleTable.cells(0).childNodes(0).innerText = this.options[this.selectedIndex].innerText;
  this.TitleTable.cells(0).childNodes(0).style.color = this.select.disabled ? 'gray' : '';
  this.TitleTable.cells(1).innerHTML = "<img src='"+SS1_ENV.ImgPrefix+"/btn_down.gif' border=0 align=absmiddle>";
  this.TitleTable.cells(2).innerHTML = "<img src='"+SS1_ENV.ImgPrefix+"/btn_down_s.gif' border=0 align=absmiddle>";
  this.TitleTable.cells(3).appendChild(this.select);
  this.TitleWrapper = document.createElement(""
    + "<img src='"+SS1_ENV.ImgPrefix+"/blank.gif'"
    + "  style='position:absolute; top:0; left:0; z-index:2; width:100%; height:"+this.height+";'"
    + "  onmouseover='SS1_VAR.SelectList["+this.SS1ID+"].handleOverTitle()'"
    + "  onmouseout='SS1_VAR.SelectList["+this.SS1ID+"].handleOutTitle(); SS1_VAR.SelectList["+this.SS1ID+"].releaseTitle(window.event);'"
    + "  onmousedown='SS1_VAR.SelectList["+this.SS1ID+"].preSS1Title(window.event)'"
    + "  ondblclick='SS1_VAR.SelectList["+this.SS1ID+"].preSS1Title(window.event); SS1_VAR.SelectList["+this.SS1ID+"].releaseTitle(window.event);'"
    + "  onmouseup='SS1_VAR.SelectList["+this.SS1ID+"].releaseTitle(window.event)'"
    + "  onmousewheel='SS1_VAR.SelectList["+this.SS1ID+"].handleMousewheel(window.event)'"
    + "  ondragstart='SS1_cancelEvent(window.event)'"
    + ">"
  );
  SS1_CreatedElements[SS1_CreatedElements.length] = this.TitleWrapper;
  this.TitleDiv.appendChild(this.TitleWrapper);
}
function SS1_createOptionsDiv ()
{
  this.OptionsDiv = SS1_createElement("\
    <div style='"+SS1_ENV.OptionsDivStyle+"'\
      onscroll='SS1_VAR.SelectList["+this.SS1ID+"].moveOption(window.event)'\
      onmousedown='SS1_cancelEvent(window.event)'\
    >\
      <table border=0 cellpadding=0 cellspacing=0 width=100% style='table-layout:fixed'>\
      </table>\
    </div>"
  );
  this.OptionsTable = this.OptionsDiv.childNodes(0);
  for (var i=0; i < this.options.length; i++) {
    this.createOptionTr(i);
  }
  this.syncOptions();
  this.OptionsWrapper = document.createElement(""
    + "<img src='"+SS1_ENV.ImgPrefix+"/blank.gif'"
    + "  style='position:absolute; top:0; left:0; width:100%;'"
    + "  onmousedown='SS1_VAR.SelectList["+this.SS1ID+"].preSS1Option(window.event)'"
    + "  onmousemove='SS1_VAR.SelectList["+this.SS1ID+"].moveOption(window.event)'"
    + "  onmouseup='SS1_VAR.SelectList["+this.SS1ID+"].releaseOption(window.event)'"
    + "  onmouseout='SS1_VAR.SelectList["+this.SS1ID+"].releaseOption(window.event)'"
    + "  ondragstart='SS1_cancelEvent(window.event)'"
    + ">"
  );
  SS1_CreatedElements[SS1_CreatedElements.length] = this.OptionsWrapper;
  this.OptionsDiv.appendChild(this.OptionsWrapper);
}
function SS1_createOptionTr (idx)
{
  idx = ('undefined'!=typeof(idx)) ? idx : this.options.length - 1;
  var OptionTr = this.OptionsTable.insertRow(-1);
  var OptionTd = document.createElement("<td height="+this.OptionHeight+"></td>");
  SS1_CreatedElements[SS1_CreatedElements.length] = this.OptionsTd;
  OptionTd.appendChild(document.createElement("<nobr style='"+SS1_ENV.OptionNobrStyle+"'></nobr>"));
  OptionTr.appendChild(OptionTd);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// SaySelect Environment Constants
var SS2_ENV = new Object();
SS2_ENV.IE_Version = new Number(((window.navigator.appVersion.split('; '))[1].split(' '))[1]);
SS2_ENV.CR = new Object();
SS2_ENV.CR.ReverseBackground = '#225588';
SS2_ENV.CR.ReverseText = 'white';
SS2_ENV.CR.Border = '#979797';
SS2_ENV.CR.BorderActive = '#979797';
SS2_ENV.ImgPrefix = 'images/';
SS2_ENV.DefaultHeight = 20;
SS2_ENV.ButtonWidth = 16;
SS2_ENV.OptionsDivStyle = "\
  display:none;\
  z-index:10;\
  position:absolute;\
  border:1 solid "+ SS2_ENV.CR.Border+";\
  background-color:white;\
  scrollbar-face-color:#D4D0C8;\
  scrollbar-shadow-color:white;\
  scrollbar-highlight-color:#F6F5F4;\
  scrollbar-3dlight-color:white\
  scrollbar-darkshadow-color:#86837E;\
  scrollbar-track-color:#F6F5F4;\
  scrollbar-arrow-color:#86837E;";
SS2_ENV.OptionNobrStyle = "\
  font-size:12px;\
  font-family:µ¸¿ò;";
// SaySelect Variables
var SS2_VAR = new Object();
SS2_VAR.DivDummy = document.createElement("DIV");
SS2_VAR.SelectList = new Array();
SS2_VAR.bEventAttached = false;

var SS2_CreatedElements = new Object();

function unloadObjects()
{
  try {
    if (SS2_VAR && SS2_VAR.SelectList)
    {
      for (key in SS2_VAR.SelectList)
      {
	if (SS2_VAR.SelectList[key])
	{
	  try {
	   SS2_VAR.SelectList[key].select.setAttribute('SS2', 0);
	  } catch (e) {};
	  delete SS2_VAR.SelectList[key];
	}
      }
    }
  } catch (e) {};
}

attachEvent("onunload", unloadObjects);

function SS2_create (srcHTML, ListMax, bAutoDetect)
{
  // property
  this.SS2ID = SS2_VAR.SelectList.length;
  this.bOriginalSelect = (bAutoDetect && SS2_ENV.IE_Version < 5.5);
  this.select = SS2_createElement(srcHTML);
  this.selectedIndex = this.select.selectedIndex;
  this.options = this.select.options;
  this.width = parseInt(this.select.style.width);
  this.height = (this.select.style.height) ? parseInt(this.select.style.height) : SS2_ENV.DefaultHeight;
  this.OptionHeight = this.height - 4;
  this.bListDown = (ListMax && '-'==ListMax.toString().substr(0, 1)) ? false : true;
  this.ListMax = (!isNaN(parseInt(ListMax))) ? Math.abs(ListMax) : 100;

  this.Table;
  this.TitleDiv;
  this.TitleTable;
  this.TitleWrapper;
  this.OptionsDiv;
  this.OptionsWrapper;
  this.OptionsTable;
  this.bFocused = false;
  this.bExpanded = false;
  this.bReverse = false;

  // private method
  this.isThisEventToBeCanceled = SS2_isThisEventToBeCanceled;
  this.toggleTitle = SS2_toggleTitle;
  this.syncSelectedIndex = SS2_syncSelectedIndex;
  this.toggleOptions = SS2_toggleOptions;
  this.turnOnOption = SS2_turnOnOption;
  this.turnOffOption = SS2_turnOffOption;
  this.handleMousewheel = SS2_handleMousewheel;
  this.handleOverTitle = SS2_handleOverTitle;
  this.handleOutTitle = SS2_handleOutTitle;
  this.handleOverOption = SS2_handleOverOption;
  this.createTable = SS2_createTable;
  this.createTitleDiv = SS2_createTitleDiv;
  this.checkOptionsDiv = SS2_checkOptionsDiv;
  this.createOptionsDiv = SS2_createOptionsDiv;
  this.createOptionTr = SS2_createOptionTr;
  this.adjustOptionsDiv = SS2_adjustOptionsDiv;
  this.syncOptions = SS2_syncOptions;
  this.preSS2Option = SS2_preSS2Option;
  this.moveOption = SS2_moveOption;
  this.releaseOption = SS2_releaseOption;
  this.preSS2Title = SS2_preSS2Title;
  this.releaseTitle = SS2_releaseTitle;

  // public method
  this.display = SS2_display;
  this.disableSelect = SS2_disableSelect;
  this.enableSelect = SS2_enableSelect;
  this.insertOption = SS2_insertOption;
  this.deleteOption = SS2_deleteOption;
  this.changeOption = SS2_changeOption;

  // initiate
  this.createTable();
  this.select.setAttribute('SS2', this);
  if (!this.bOriginalSelect)
    this.select.onpropertychange = SS2_handlePropertychange;
  SS2_VAR.SelectList[this.SS2ID] = this;
}
function SS2_display ()
{
  document.write("<div id=SS2_TempDiv></div>\n");
  document.all.SS2_TempDiv.appendChild(this.Table);
  document.all.SS2_TempDiv.removeNode();
}
function SS2_write (srcHTML, ListMax, bAutoDetect)
{
  var oSS2 = new SS2_create(srcHTML, ListMax, bAutoDetect);
  oSS2.display();
  return oSS2;
}
function SS2_disableSelect ()
{
  this.select.disabled = true;
  this.TitleTable.cells(0).childNodes(0).style.color = 'gray';
  this.toggleTitle(false);
}
function SS2_enableSelect ()
{
  this.select.disabled = false;
  this.TitleTable.cells(0).childNodes(0).style.color = '';
}
function SS2_insertOption (value, innerText, idx)
{
  this.checkOptionsDiv();

  var NewOption = document.createElement("OPTION");
  SS2_CreatedElements[SS2_CreatedElements.length] = NewOption;
  this.options.add(NewOption, idx);
  NewOption.innerText = innerText;
  NewOption.value = value;

  if (!this.bOriginalSelect)
    this.createOptionTr(idx);
  this.syncOptions();
  this.adjustOptionsDiv();
  this.syncSelectedIndex();
}
function SS2_deleteOption (idx)
{
  this.checkOptionsDiv();

  this.options.remove(idx);
  if (!this.bOriginalSelect)
    this.OptionsTable.deleteRow(idx);
  this.syncOptions();
  this.adjustOptionsDiv();
  this.syncSelectedIndex();
}
function SS2_changeOption (idx, value, innerText)
{
  this.checkOptionsDiv();

  this.options[idx].value = value;
  this.options[idx].innerText = innerText;
  this.syncOptions();
  this.syncSelectedIndex();
}

function SS2_cancelEvent (event)
{
  event.cancelBubble = true;
  event.returnValue = false;
}
function SS2_isThisEventToBeCanceled (event)
{
  if ('object' == typeof(event)) {
    switch (event.type) {
      case 'mousedown':
        if (!(event.button & 1)) return true;
        break;
      case 'mouseup':
        if (!(event.button & 1)) return true;
        if (SS2_ENV.IE_Version >= 5.5 && event.srcElement != this.srcElementOfLastMousedown && this.srcElementOfLastMousedown != null) {
          this.srcElementOfLastMousedown = null;
          return true;
        }
        break;
      case 'mouseout':
        if (!(SS2_ENV.IE_Version < 5.5 && event.srcElement == this.srcElementOfLastMousedown))
          return true;
        break;
      case 'mousemove':
        if (SS2_ENV.IE_Version >= 5.5 && event.srcElement != this.srcElementOfLastMousedown && this.srcElementOfLastMousedown != null)
          return true;
        break;
    }
  }
  return false;
}
function SS2_createElement (html)
{
  SS2_VAR.DivDummy.insertAdjacentHTML('afterBegin', html);
  var oEl = SS2_VAR.DivDummy.children(0);
  while (SS2_VAR.DivDummy.children.length > 0) {
    SS2_VAR.DivDummy.removeChild(SS2_VAR.DivDummy.children(0));
  }
  return oEl;
}
function SS2_blurExcept (except)
{
  SS2_cancelEvent(window.event);

  except = ('number'==typeof(except)) ? except : -1;

  var bHasToDetachEvent = true;
  for (var i=0; i < SS2_VAR.SelectList.length; i++) {
    if (-1==except && SS2_VAR.SelectList[i].bFocused && SS2_VAR.SelectList[i].bExpanded) {
      SS2_VAR.SelectList[i].toggleOptions(false, true);
      SS2_VAR.SelectList[i].toggleTitle(true);
      bHasToDetachEvent = false;
    }
    else if (i!=except) {
      if (SS2_VAR.SelectList[i].bExpanded)
        SS2_VAR.SelectList[i].toggleOptions(false, true);
      if (SS2_VAR.SelectList[i].bReverse)
        SS2_VAR.SelectList[i].toggleTitle(false);
      SS2_VAR.SelectList[i].bFocused = false;
    }
  }

  if (SS2_VAR.bEventAttached && bHasToDetachEvent) {
    document.detachEvent('onmousedown', SS2_blurExcept);
    document.detachEvent('ondblclick', SS2_blurExcept);
    SS2_VAR.bEventAttached = false;
  }
}
function SS2_syncSelectedIndex ()
{
  this.selectedIndex = this.select.selectedIndex;

  if (this.bOriginalSelect) return;

  if (this.TitleTable.cells(0).childNodes(0).innerText != this.options[this.selectedIndex].innerText)
    this.TitleTable.cells(0).childNodes(0).innerText = this.options[this.selectedIndex].innerText;
  if (this.bExpanded)
    this.toggleOptions(false);
}
function SS2_toggleTitle (bReverse)
{
  this.bReverse = ('undefined'!=typeof(bReverse)) ? bReverse: (!this.bReverse);
  this.TitleTable.cells(0).style.backgroundColor = this.bReverse ? SS2_ENV.CR.ReverseBackground : '';
  this.TitleTable.cells(0).style.color = this.bReverse ? SS2_ENV.CR.ReverseText : '';
}
function SS2_checkOptionsDiv ()
{
  if (!this.OptionsDiv) {
    this.createOptionsDiv();
    this.Table.cells(0).appendChild(this.OptionsDiv);
  }
}
function SS2_toggleOptions (bExpanded, bStrict)
{
  this.checkOptionsDiv();

  if (!bStrict && !this.bFocused) {
    SS2_blurExcept(this.SS2ID);
  }
  this.bExpanded = ('undefined'!=typeof(bExpanded)) ? bExpanded: (!this.bExpanded);
  if (this.bExpanded) {
    this.adjustOptionsDiv();
    this.OptionsDiv.style.display = 'block';
    if (!bStrict) {
      this.toggleTitle(false);
      this.handleOverOption(this.selectedIndex);
    }
    this.handleOutTitle();
  }
  else {
    this.OptionsDiv.style.display = 'none';
    if (!bStrict) {
      this.toggleTitle(true);
    }
  }
  if (!bStrict) {
    this.bFocused = true;

    if (!SS2_VAR.bEventAttached) {
      document.attachEvent('onmousedown', SS2_blurExcept);
      document.attachEvent('ondblclick', SS2_blurExcept);
      SS2_VAR.bEventAttached = true;
    }
  }
}
function SS2_handlePropertychange ()
{
  if ('propertychange'==window.event.type && 'selectedIndex'==window.event.propertyName) {
    var oSS2 = window.event.srcElement.SS2;
    oSS2.syncSelectedIndex();

    if (null != oSS2.select.onchange)
      oSS2.select.onchange();
  }
}
function SS2_handleMousewheel (event)
{
  var idx = this.selectedIndex;
  if ('mousewheel'==event.type && this.bFocused && this.bReverse) {
    for (var i=0; i < event.wheelDelta; i += 120)
      idx--;
    for (var i=0; i > event.wheelDelta; i -= 120)
      idx++;
  }
  idx = Math.max(idx, 0);
  idx = Math.min(idx, this.options.length - 1);
  this.select.selectedIndex = idx;
}
function SS2_handleOverTitle ()
{
  if (this.bExpanded || this.select.disabled)
    return;

  this.TitleTable.style.borderColor = SS2_ENV.CR.BorderActive;
  this.TitleTable.cells(1).style.display = 'none';
  this.TitleTable.cells(2).style.display = 'block';
}
function SS2_handleOutTitle ()
{
  this.TitleTable.style.borderColor = SS2_ENV.CR.Border;
  this.TitleTable.cells(2).style.display = 'none';
  this.TitleTable.cells(1).style.display = 'block';
}
function SS2_handleOverOption (idx)
{
  for (var i=0; i < this.options.length; i++) {
    if (i==idx)
      this.turnOnOption(i);
    else
      this.turnOffOption(i);
  }
}
function SS2_turnOnOption (idx)
{
  this.OptionsTable.cells(idx).style.color = SS2_ENV.CR.ReverseText;
  this.OptionsTable.cells(idx).style.backgroundColor = SS2_ENV.CR.ReverseBackground;
}
function SS2_turnOffOption (idx)
{
  this.OptionsTable.cells(idx).style.color = '';
  this.OptionsTable.cells(idx).style.backgroundColor = '';
}
function SS2_adjustOptionsDiv ()
{
  if (this.bOriginalSelect) return;

  this.OptionsDiv.style.width = this.width;
  this.OptionsDiv.style.height = Math.min(this.options.length, this.ListMax) * this.OptionHeight + 2;
  this.OptionsWrapper.style.height = this.options.length * this.OptionHeight;
  this.OptionsDiv.style.overflowY = (this.options.length > this.ListMax) ? 'scroll' : '';

  var top = this.Table.offsetTop;
  var left = this.Table.offsetLeft;
  for (var El = this.Table.offsetParent; 'BODY'!=El.tagName && 'absolute'!=El.style.position && 'relative'!=El.style.position; El = El.offsetParent) {
    if ('TABLE' != El.tagName) {
      top += El.clientTop;
      left += El.clientLeft;
    }
    top += El.offsetTop;
    left += El.offsetLeft;
  }
  this.OptionsDiv.style.top = (this.bListDown) ? (top + this.height) : (top - parseInt(this.OptionsDiv.style.height));
  this.OptionsDiv.style.left = left;

  this.TitleWrapper.style.top = 0;
  this.TitleWrapper.style.left = 0;
}
function SS2_syncOptions ()
{
  if (this.bOriginalSelect) return;

  for (var i=0; i < this.options.length; i++) {
    this.OptionsTable.cells(i).setAttribute('index', i);
    if (this.OptionsTable.cells(i).childNodes(0).innerText != this.options[i].innerText)
      this.OptionsTable.cells(i).childNodes(0).innerText = this.options[i].innerText;
  }
}
function SS2_preSS2Title (event)
{
  SS2_cancelEvent(event);

  if (this.select.disabled)
    return;

  this.srcElementOfLastMousedown = event.srcElement;

  this.toggleOptions();
}
function SS2_releaseTitle (event)
{
  SS2_cancelEvent(event);

  if (this.isThisEventToBeCanceled(event)) return;

  this.srcElementOfLastMousedown = null;
}
function SS2_preSS2Option (event)
{
  SS2_cancelEvent(event);

  this.srcElementOfLastMousedown = event.srcElement;
}
function SS2_moveOption (event)
{
  SS2_cancelEvent(event);

  if (this.isThisEventToBeCanceled(event)) return;
  if (!(event.offsetX >= 0 && event.offsetX <= this.OptionsTable.offsetWidth)) return;

  this.handleOverOption(Math.floor(event.offsetY / this.OptionHeight));
}
function SS2_releaseOption (event)
{
  SS2_cancelEvent(event);

  if (this.isThisEventToBeCanceled(event)) return;

  this.srcElementOfLastMousedown = null;

  if (event.offsetX >= 0 && event.offsetX <= this.OptionsTable.offsetWidth) {
    this.toggleOptions(false);
    this.select.selectedIndex = Math.floor(event.offsetY / this.OptionHeight);
  }
}
function SS2_createTable ()
{
  this.Table = SS2_createElement("\
    <table border=0 cellpadding=0 cellspacing=0 style='table-layout:fixed; cursor:default'>\
    <tr><td></td></tr>\
    </table>"
  );
  if (!isNaN(this.width))
    this.Table.style.width = this.width;
  this.Table.style.height = this.height;

  if (!this.bOriginalSelect) {
    this.createTitleDiv();
    this.Table.cells(0).appendChild(this.TitleDiv);
  }
  else {
    this.Table.cells(0).appendChild(this.select);
  }
}
function SS2_createTitleDiv ()
{
  this.TitleDiv = SS2_createElement("\
    <div style='position:relative; top:0; left:0;'>\
      <table border=0 cellpadding=0 cellspacing=0\
        height="+this.height+"\
        bgcolor=white\
        style='table-layout:fixed; border:1 solid "+SS2_ENV.CR.Border+";'\
        onmouseover='SS2_VAR.SelectList["+this.SS2ID+"].adjustOptionsDiv()'\
      >\
      <tr align=center valign=middle>\
        <td><nobr style='text-oveflow:hidden;"+SS2_ENV.OptionNobrStyle+"'></nobr></td>\
        <td width="+SS2_ENV.ButtonWidth+" align=center style='word-wrap:normal'></td>\
        <td style='display:none' width="+SS2_ENV.ButtonWidth+" align=center style='word-wrap:normal'></td>\
        <td style='display:none'></td>\
      </tr>\
      </table>\
    </div>"
  );
  this.TitleTable = this.TitleDiv.childNodes(0);
  this.TitleTable.cells(0).childNodes(0).innerText = this.options[this.selectedIndex].innerText;
  this.TitleTable.cells(0).childNodes(0).style.color = this.select.disabled ? 'gray' : '';
  this.TitleTable.cells(1).innerHTML = "<img src='"+SS2_ENV.ImgPrefix+"/btn_down01.gif' border=0 align=absmiddle>";
  this.TitleTable.cells(2).innerHTML = "<img src='"+SS2_ENV.ImgPrefix+"/btn_down01.gif' border=0 align=absmiddle>";
  this.TitleTable.cells(3).appendChild(this.select);
  this.TitleWrapper = document.createElement(""
    + "<img src='"+SS2_ENV.ImgPrefix+"/blank.gif'"
    + "  style='position:absolute; top:0; left:0; z-index:2; width:100%; height:"+this.height+";'"
    + "  onmouseover='SS2_VAR.SelectList["+this.SS2ID+"].handleOverTitle()'"
    + "  onmouseout='SS2_VAR.SelectList["+this.SS2ID+"].handleOutTitle(); SS2_VAR.SelectList["+this.SS2ID+"].releaseTitle(window.event);'"
    + "  onmousedown='SS2_VAR.SelectList["+this.SS2ID+"].preSS2Title(window.event)'"
    + "  ondblclick='SS2_VAR.SelectList["+this.SS2ID+"].preSS2Title(window.event); SS2_VAR.SelectList["+this.SS2ID+"].releaseTitle(window.event);'"
    + "  onmouseup='SS2_VAR.SelectList["+this.SS2ID+"].releaseTitle(window.event)'"
    + "  onmousewheel='SS2_VAR.SelectList["+this.SS2ID+"].handleMousewheel(window.event)'"
    + "  ondragstart='SS2_cancelEvent(window.event)'"
    + ">"
  );
  SS2_CreatedElements[SS2_CreatedElements.length] = this.TitleWrapper;
  this.TitleDiv.appendChild(this.TitleWrapper);
}
function SS2_createOptionsDiv ()
{
  this.OptionsDiv = SS2_createElement("\
    <div style='"+SS2_ENV.OptionsDivStyle+"'\
      onscroll='SS2_VAR.SelectList["+this.SS2ID+"].moveOption(window.event)'\
      onmousedown='SS2_cancelEvent(window.event)'\
    >\
      <table border=0 cellpadding=0 cellspacing=0 width=100% style='table-layout:fixed'>\
      </table>\
    </div>"
  );
  this.OptionsTable = this.OptionsDiv.childNodes(0);
  for (var i=0; i < this.options.length; i++) {
    this.createOptionTr(i);
  }
  this.syncOptions();
  this.OptionsWrapper = document.createElement(""
    + "<img src='"+SS2_ENV.ImgPrefix+"/blank.gif'"
    + "  style='position:absolute; top:0; left:0; width:100%;'"
    + "  onmousedown='SS2_VAR.SelectList["+this.SS2ID+"].preSS2Option(window.event)'"
    + "  onmousemove='SS2_VAR.SelectList["+this.SS2ID+"].moveOption(window.event)'"
    + "  onmouseup='SS2_VAR.SelectList["+this.SS2ID+"].releaseOption(window.event)'"
    + "  onmouseout='SS2_VAR.SelectList["+this.SS2ID+"].releaseOption(window.event)'"
    + "  ondragstart='SS2_cancelEvent(window.event)'"
    + ">"
  );
  SS2_CreatedElements[SS2_CreatedElements.length] = this.OptionsWrapper;
  this.OptionsDiv.appendChild(this.OptionsWrapper);
}
function SS2_createOptionTr (idx)
{
  idx = ('undefined'!=typeof(idx)) ? idx : this.options.length - 1;
  var OptionTr = this.OptionsTable.insertRow(-1);
  var OptionTd = document.createElement("<td height="+this.OptionHeight+"></td>");
  SS2_CreatedElements[SS2_CreatedElements.length] = this.OptionsTd;
  OptionTd.appendChild(document.createElement("<nobr style='"+SS2_ENV.OptionNobrStyle+"'></nobr>"));
  OptionTr.appendChild(OptionTd);
}


