var UserAgent = navigator.userAgent;
var AppVersion = (((navigator.appVersion.split('; '))[1].split(' '))[1]);

var SL_MouseDown = false;
var SL_Idx = 0;

var TableCellAttr = " cellpadding=0 cellspacing=0";
/* list border */
var ContourStyle = " border:1px solid #BEBEBE; cursor:hand;";
var ScrollBarStyle = " scrollbar-face-color:#FFFFFF;scrollbar-shadow-color:#AEADAB;"
+"scrollbar-highlight-color:#AEADAB;scrollbar-3dlight-color:#EEEEEE;"
+"scrollbar-darkshadow-color:#EEEEEE;scrollbar-track-color:#EEEEEE;"
+"scrollbar-arrow-color:#AEADAB;";
var ItemStyle = "text-indent:2px;cursor:hand;font-size:9pt;height:16px;padding-top:2px;";
var ALTStyle = "'filter:alpha(opacity=100); border:1 solid #AFB086'";

SList = new Array();

document.onmousedown = dispList;

function dispList() {
var hideList = true;
if ( event.srcElement.id == "bground") hideList = false;
if ( !SL_MouseDown ) {
for ( i = 0; i < SList.length; i++ ) SList[i].hideList = true;
}
if ( SList.length > 0 ) {
for ( i = 0; i < SList.length; i++ ) {
if ( SList[i].hideList && hideList ) SList[i].List.style.visibility = "hidden";
}
SL_MouseDown = false;
SList[SL_Idx].Title.children(0).cells(0).childNodes(0).innerText = SList[SL_Idx].SelectedItemName;
}
return;
}

/* ---------- SelectList Creation ---------- */

function SelectList(src) {
if ( UserAgent.indexOf("MSIE") < 0 || AppVersion < 5 ) {
document.write(src);
return;
} else {
var SListObj = new setSelectList(src);
SListObj.append();
return SListObj;
}
}

function setSelectList(src) {
this.IDX = SList.length;
this.src = src;

/*list bgcolor*/

this.bgcolor = '#FFFFFF';
this.hideList = true;
/* SelectList Object */
this.Table;
this.Title;
this.List;
this.Items;
this.SelectedItemName;
this.width;
this.getWidth = getWidth;
/* Object Function */
this.itemObj = createSLItem;
this.ListObj = createSLList;
this.TitleObj = createSLTitle;
this.TableObj = createSLTable;
/* Event Handler */
this.TitleMouseDown = SL_TitleMouseDown;
this.ListMouseOver = SL_ListMouseOver;
this.ListMouseOut = SL_ListMouseOut;
this.ListMouseDown = SL_ListMouseDown;
this.append = appendSList;
this.TableObj();
SList[this.IDX] = this;
return;
}

function appendSList() {
document.write("<div id=TempDiv></div>\n");
document.all.TempDiv.appendChild(this.Table);
document.all.TempDiv.removeNode();
return;
}

/* ---------- Object Function ---------- */

function createSLItem(src) {
oObj = new Object();
oObj.Div = document.createElement("DIV");
oObj.Div.insertAdjacentHTML("afterBegin",src);
this.Items = oObj.Div.children(0);
return this.Items;
}

function createSLList() {
var ListItem = "";
var ListLength = this.Items.length;
var ListHeight;
var scrollbarStyle = "";
for ( i = 0; i < ListLength; i++ ) {
ListItem += "<div id=List idx="+i+" style="+ItemStyle
+" onMouseDown='SList["+this.IDX+"].ListMouseDown(this);'"
+" onMouseOver='SList["+this.IDX+"].ListMouseOver(this);'"
+" onMouseOut='SList["+this.IDX+"].ListMouseOut(this);'>"
+this.Items[i].innerText+"</div>";
}
if ( ListLength < 10 ) { scrollbarStyle = "hidden"; }
else { scrollbarStyle = "scroll"; ListHeight = 160; }
this.List = createSLItem(""
+"<div id=bground style='"+ContourStyle+ScrollBarStyle
+"z-index:1;background:"+this.bgcolor+";position:absolute;visibility:hidden;"
+"width:"+(this.width+18)+";height:"+ListHeight+";overflow-Y:"+scrollbarStyle+";'>"
+ListItem+"</div>");
return;
}

function createSLTitle() {
var MaxLength = 0;
var width;
var ListLength = this.Items.length;
for ( i = 0; i < ListLength; i++ ) {
if (this.Items.options[i].selected) {
this.SelectedItemName = this.Items.options[i].innerText;
SelectedItemValue = this.Items.options[i].value;
}
}
this.getWidth();
TitleItem = createSLItem(""
+"<table height=17 border=0"+TableCellAttr
+" style='background-color:"+this.bgcolor+";'><tr>\n"

/* ---------- ÅØ½ºÆ® ¹Ú½º °¡·Î±æÀÌ ---------- */

+"<td width="+(this.width+55)+" nowrap></td>"
+"<td style='display:none;'></td>"
+"<td width=14 align=center><img src='../img/sort.gif' border=0></td>"
+"</tr></table>");
SelectedItemObj = createSLItem(""
+"<div style='position:absolute;font-size:9pt;top:4px;left:2px;'>"+this.SelectedItemName
+"</div>");
TitleItem.cells(0).appendChild(SelectedItemObj);
TitleItem.cells(1).appendChild(this.Items);
this.Title = createSLItem(""
+"<div style='position:relative;top:0px;left:0px;"+ContourStyle
+"' onMouseDown='SList["+this.IDX+"].TitleMouseDown();'>"
+TitleItem.outerHTML+"</div>");
return;
}

function createSLTable() {
this.itemObj(this.src);
this.TitleObj();
this.ListObj();
this.Table = createSLItem(""
+"<table border=0"+TableCellAttr+">\n"
+"<tr><td></td></tr>"
+"</table>");
this.Table.cells(0).appendChild(this.Title);
this.Table.cells(0).appendChild(this.List);
return;
}

/* ---------- Event Handler ---------- */

function SL_TitleMouseDown() {
if ( this.List.style.visibility == "visible" ) {
this.List.style.visibility = "hidden";
this.hideList = true;
} else {
this.List.style.visibility = "visible";
this.hideList = false;
}
for ( i = 0; i < SList.length; i++ )
if ( i != this.IDX ) SList[i].hideList = true;
SList[SL_Idx].Title.children(0).cells(0).childNodes(0).innerText = SList[SL_Idx].SelectedItemName;
SL_MouseDown = true;
SL_Idx = this.IDX;
return;
}

/* sub ¼±ÅÃ»ö±ò */

function SL_ListMouseOver(f) {
f.style.background = "#70593E";
f.style.color = "white";
return;
}

function SL_ListMouseOut(f) {
f.style.background = this.bgcolor;
f.style.color = "black";
return;
}

function SL_ListMouseDown(f) {
var TChildren = this.Title.children(0).cells;
var obj_length = this.Items.length;
for ( i = 0; i < obj_length; i++ ) {
this.Items.options[i].selected = false;
if ( i == f.idx ) {
this.Items.options[i].selected = true;
SI_Name = this.Items.options[i].innerText;
}
}
if ( this.goKin && ( obj_length - 1 ) == f.idx )
location.href = this.Items.options[f.idx].value;
this.SelectedItemName = SI_Name;
TChildren(1).childNodes(0).outerHTML = this.Items.outerHTML;
this.List.style.visibility = "hidden";
return;
}

function getWidth() {
document.all.sl_Div.innerHTML = this.Items.outerHTML;
this.width = document.all.sl_Div.scrollWidth - 20;
return;
}

/*function goAskCR (o) {
//newwin = window.replace();

//var url = 'http://clickpc.kppinc.com/rd.tsp/';
//url += 'S=' + o.S.value + '/N=' + o.N.value + '/K=' + o.K.value + '/*' + o.u.value;
var url=o.u.value;

//newwin.location.href = url;
location.href = url;
return false ;
}*/

