/**
 * SelectBox Component
 * @author hooriza
 * @version 0.1.4
 */
 // encoded UTF-8

// @author hooriza - timer.js 2338
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6=2(){0.7.f(0,g)};6.h={3:i,1:8,7:2(a){0.3=a.j()=="k"},l:2(a,b,c){0.4();9(0.3){0.1=5.m(b,a)}n{e d=0;0.1=5.o(2(){c?b.p(c):b();d.4()},a)}},4:2(){e a=5[0.3?"q":"r"];9(0.1)a(0.1);0.1=8}};',28,28,'this|_oInstance|function|_bInterval|stop|window|Timer|initialize|null|if|||||var|apply|arguments|prototype|false|toLowerCase|interval|start|setInterval|else|setTimeout|call|clearInterval|clearTimeout'.split('|'),0,{}));

// @author hooriza - $Element.prototype.fireEvent.js 2268
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$J.K.s=L(a,b){2 c=M.$N();2 d=t;4(O a!=\'P\'){d=a.Q||a;a=a.R}4(5.u){2 e=d;4(!e||b){e=5.u();4(d)i(2 k j d)v{e[k]=d[k]}w(x){}4(b)i(2 k j b)e[k]=b[k]}y c.s(\'S\'+a,e)}2 e;2 f={p:z,6:z,7:A,B:1,C:0,D:0,E:0,F:0,8:l,9:l,g:l,h:l,G:1,H:t,m:0,n:0};4(d)i(2 k j d)v{f[k]=d[k]}w(x){}4(b)i(2 k j b)f[k]=b[k];T(a){3\'U\':3\'V\':3\'W\':3\'X\':3\'Y\':3\'Z\':e=5.o(\'10\');e.q(a,f.p,f.6,f.7,f.B,f.C,f.D,f.E,f.F,f.8,f.9,f.g,f.h,f.G,f.H);r;3\'11\':3\'12\':3\'13\':4(A.14){e=5.o(\'15\');e.16(a,f.I,f.6,f.7,f.8,f.9,f.g,f.h,f.m,f.n);r}17{e=5.o(\'18\');e.q(a,f.I,f.6);e.7=f.7;e.9=f.9;e.8=f.8;e.g=f.g;e.h=f.h;e.m=f.m;e.n=f.n}19:e=5.o(\'1a\');e.q(a,f.p,f.6);r}y c.1b(e)};',62,74,'||var|case|if|document|cancelable|view|ctrlKey|altKey|||||||shiftKey|metaKey|for|in||false|keyCode|charCode|createEvent|canBubble|initEvent|break|fireEvent|null|createEventObject|try|catch|ex|return|true|window|detail|screenX|screenY|clientX|clientY|button|relatedTarget|cancelBubble|Element|prototype|function|this|value|typeof|string|_event|type|on|switch|click|mousedown|mouseup|mouseover|mouseout|mousemove|MouseEvents|keydown|keypress|keyup|KeyEvent|KeyEvents|initKeyEvent|else|Events|default|HTMLEvents|dispatchEvent'.split('|'),0,{}));

// @author hooriza - simulateFocus.js 2493
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('R=$S({6:h,2:h,8:h,q:h,m:j,$T:3(a,b){4 e=$y(a);1.q={z:j};A(4 k U b)1.q[k]=b[k];1.6=a;4 c=1;1.6.l=3(){c.2.s=j;9 c.2.l()};1.6.n=3(){9 c.2.n()};1.B();1.C()},B:3(){1.2=$(1.q.z?\'<t>\':\'<u>\');V(1.2.W){X=\'Y\';Z=\'11\';12=\'-13\';14=\'15\'};1.2.16=\'17\';1.2.18=r;1.D()},D:3(){1.6.19.1a(1.2,1.6)},v:3(a){f(1.8)E(1.8);1.8=h;f(1.m==r)9;1.m=r;1.p(\'l\',a)},w:3(a){4 b=1;f(1.8)E(1.8);4 c=F.G?F.G(a.H):a.H;1.8=I(3(){f(b.m==j)9;b.m=j;b.p(\'n\',c);1b c;c=h},10)},x:3(a){f(!1.p(a.1c,a))a.1d()},J:3(b){4 c=K(\'u, L, t, 1e, a\',b);4 d=$g(1.x,1);A(4 i=0,7;7=c[i];i++){4 o=$y(7);f(o.1f(\'-M-N\'))9;o.1g(\'-M-N\');$g(3(a){1.2.s=r;1.v(a);1.p(\'1h\',a)},1).5(7,\'l\');$g(3(a){1.2.s=j;1.w(a);1.p(\'1i\',a)},1).5(7,\'n\');d.5(7,\'O\');d.5(7,\'P\');d.5(7,\'Q\')}9 1},C:3(){$g(3(a){4 b=a.1j;f(K.1k(b,\'L, u, t, a\'))9;4 c=1;I(3(){1l{c.2.l()}1m(e){}},0)},1).5(1.6,\'1n\');$g(1.v,1).5(1.2,\'l\');$g(1.w,1).5(1.2,\'n\');4 d=$g(1.x,1);d.5(1.2,\'O\');d.5(1.2,\'P\');d.5(1.2,\'Q\');1.J(1.6)}}).1o(1p.1q);',62,89,'|this|_dummy|function|var|attach|_object|textbox|_timer|return||||||if|Fn|null||false||focus|_focused|blur||fireEvent|_options|true|disabled|button|textarea|_fireFocusEvent|_fireBlurEvent|_onDummyEvents|Element|scrollable|for|_createDummy|_bindEvents|_rePositionDummy|clearTimeout|document|createEventObject|_event|setTimeout|setFriend|cssquery|input|simfocus|friend|keydown|keypress|keyup|SimulateFocus|Class|init|in|with|style|position|absolute|display||block|left|999999px|width|50px|value|dummy|readOnly|parentNode|insertBefore|delete|type|stop|select|hasClass|addClass|fieldfocus|fieldblur|element|test|try|catch|mousedown|extend|nhn|Component'.split('|'),0,{}));

var Selectbox=$Class({tagName:'select',_agent:$Agent().navigator(),_object:null,_options:null,_focusTimer:null,_comboTimer:null,_customTimer:null,_simfocus:null,_items:null,_customs:null,_title:'',_selectedIndex:-1,_hoveredIndex:-1,_heightFitted:false,_heightOverflowed:false,_comboChanged:false,
_needle:'',_handlers:{box:{focus:function(a){var o=this._object;var b=this.option('classPrefix');this._focusTimer.stop();var c=$Element(o.selectbox);if(c.hasClass(b+'focused'))return;c.addClass(b+'focused');this.fireEvent('focus')},blur:
function(a){var o=this._object;var b=this.option('classPrefix');this._focusTimer.start(50,function(){$Element(o.selectbox).removeClass(b+'focused');this._showLayer(false);this.fireEvent('blur')},this)},keydown:function(b){var o=this._object;var c=b.key().keyCode;
var d=b.element;if(this.fireEvent('keydown',b)){switch(c){case 38:this.selectAbove(1);this._paintLabel();b.stop();break;case 40:this.selectBelow(1);this._paintLabel();b.stop();break;case 33:this.selectAbove(Infinity);this._paintLabel();b.stop();break;case 34:
this.selectBelow(Infinity);this._paintLabel();b.stop();break;case 13:if(this._isVisibleLayer())this._showLayer(false);b.stop();break}var e=this._items[this._selectedIndex];if(d==o.combobox){var f=o.combobox.value;this._comboTimer.start(0,function(){var a=
o.combobox.value;if(f==a)return;this._comboChanged=true;o.source.selectedIndex=this._pseudoIndex;this._pseudo.value=a;this._paintItem()},this)}else if(e&&!e.custom){switch(c){case 37:this.selectAbove(1);this._paintLabel();b.stop();break;case 39:
this.selectBelow(1);this._paintLabel();b.stop();break;default:var g=String.fromCharCode(c);if(/[a-z0-9 ]/i.test(g)){this._needle+=g.toUpperCase();var h=this._findMatchItem();if(h!=-1)this._setSelectedIndex(h);b.stop()}this._paintLabel();break}}else if
(this.option('customValue')){var f=this.option('customValue').call(this,e.custom,e.object);this._comboTimer.start(0,function(){e=this._setCustomValue(e);if(f==e.source.value)return;this._comboChanged=true;this._paintLabel()},this)}}this._paintItem()},mousedown:
function(a){var o=this._object;if(a.element==o.combobox){this._showLayer(false);return}this._showLayer();if(o.combobox)setTimeout(function(){o.combobox.focus()},10)}},combobox:{keyup:function(a){}},layer:{mousedown:function(a){var o=this._object;var b=
this._getItemIndexFromEvent(a);if(b!=-1&&this._items[b].custom)return;this._delayCall(0,function(){try{o.box.focus()}catch(e){}})}},list:{mouseover:function(a){var b=this._getItemIndexFromEvent(a);if(b==-1)return;var c=this._items[b];if(c.disable)return;
this._addHoveredClass(b)},mousedown:function(a){var b=this._getItemIndexFromEvent(a);if(b==-1)return;if(!this.fireEvent('itemclick',{itemIndex:b,itemObject:c}))return;var c=this._items[b];if(c.disable)return;this._setSelectedIndex(b);this._paintLabel();
this._paintItem();if(this.option('closeOnClickItem')&&!c.custom)this._showLayer(false)}},field:{focus:function(a){var b=a.element;var c=this.option('classPrefix');this._customTimer.start(10,function(){for(;b&&b.tagName;b=b.parentNode){var e=$Element(b);if(e.hasClass(c
+'item-selected'))return;if(e.hasClass(c+'list'))return this._showLayer(false)}},this)}}},$init:function(a,b){var o=this._object={};var c=Math.round(new Date().getTime()*10000)+Math.random()*10000;var d='selectbox('+c+')';this.option({useHtml:false,closeOnClickItem:true,
classPrefix:'selectbox-'});this.option(b||{});var e=this.option('classPrefix');o.selectbox=$(a);if(cssquery.test(o.selectbox,'select'))o.selectbox=cssquery('! .'+e+'naked',o.selectbox)[0];o.source=cssquery('select.'+e+'source',o.selectbox)[0];o.box=cssquery('.'+e+
'box',o.selectbox)[0];o.label=cssquery('.'+e+'label',o.selectbox)[0];o.combobox=cssquery('input.'+e+'combobox',o.selectbox)[0];var f=this.option('layer');if(f){o.layer=$(f);document.body.insertBefore(o.layer,document.body.firstChild)}else{o.layer=cssquery('.'+e+
'layer',o.selectbox)[0]}o.list=cssquery.test(o.layer,'ul.'+e+'list')?o.layer:cssquery('ul.'+e+'list',o.layer)[0];if(o.combobox)o.label.appendChild(o.combobox);$Element(o.selectbox).removeClass(e+'naked');$Element(o.selectbox).addClass(e+'applied');$Element(o.source).css({
position:'absolute',visibility:'hidden',display:'block'});this._processCustoms();this._showLayer(false);this._focusTimer=new Timer('timeout');this._comboTimer=new Timer('timeout');this._customTimer=new Timer('timeout');this._simfocus=new SimulateFocus(o.box);this._bindEvents();this.paint();
$Element(o.selectbox).addClass(d);$Element(o.layer).addClass(d);Selectbox._instanceKeys[c]=this},_toRegExp:function(a){return a.replace(/\-/g,'\\-')},_getCustom:function(a){var b=this.option('classPrefix');if(new RegExp('\\b'+this._toRegExp(b)+
'item\\-custom\\(([^\\)]+)\\)').test(a.className))return RegExp.$1},_processCustoms:function(){var o=this._object;var a=cssquery('> li',o.list);this._custom=[];var b;for(var i=0,li;li=a[i];i++){if(b=this._getCustom(li)){var q=cssquery('input',li)[0];this._custom[b]=
li.cloneNode(true)}}},_paintPseudoItem:function(){var a=this.option('classPrefix');var o=this._object;if(!o.combobox)return;var b=cssquery('option.'+a+'item-pseudo',o.source)[0];if(b){this._pseudo=b;this._pseudoIndex=b.index;return}var b=this._pseudo=
$('<option>');this._pseudoIndex=o.source.options.length;b.className=a+'item-pseudo '+a+'invisible';b.innerHTML='肄ㅻ낫諛뺤뒪 ??ぉ';o.source.appendChild(b)},_findMatchItem:function(a){var b=this._items.length;var c=this._object.source.selectedIndex;var d=
this._needle;var e=-1;if(typeof a=='undefined')a=0;for(var i=c+a;i<c+b;i++){var f=i%b;var g=this._items[f].found;if(g.indexOf(d)==0){e=f;break}}if(e==-1&&d.length>1){this._needle=d=d.substr(d.length-1);e=
this._findMatchItem(1)}return e},_delayCall:function(a,b){setTimeout($Fn(b,this).bind(),a)},_text:function(a){var b=this._options;return b.useHtml?(a.textContent||a.innerText):a.innerHTML},_value:function(a){
return a.getAttribute('value')||''},_isVisibleLayer:function(){var a=this._object.layer;return $Element(a).visible()},_showLayer:function(a){var b=$Element(this._object.layer);var c=b.visible();if(typeof a=='undefined')a=!c;if(a!=c&&
!this.fireEvent(a?'open':'close'))return;b[a?'show':'hide']();if(a){this._paintHeight();this._paintItem();this._paintLayer()}else{this._fireChangeEvent()}},_fireChangeEvent:function(){var o=this._object;if(this._comboChanged){this._comboChanged=false;this._onCustomSelect();
$Element(o.source).fireEvent('change');this.fireEvent('change')}},_onCustomSelect:function(){var o=this._object;var a=this.option('classPrefix');if(!$Element(o.selectbox).hasClass(a+'focused'))return;var b=this._setCustomValue();if(!b)return;if(!this._isVisibleLayer())
this._showLayer(true);var c=this;if(this.option('customSelect'))setTimeout(function(){c.option('customSelect').call(c,b.custom,b.object)},0)},_setCustomValue:function(a){var o=this._object;if(!a)a=this._items[o.source.selectedIndex];if(!a.custom)return;var b=
this.option('customValue').call(this,a.custom,a.object);a.source.value=b;return a},_getItemIndexFromEvent:function(a){var b=a.element;if(b.tagName.toLowerCase()!='li')b=cssquery('! li',b)[0];return this._getItemIndex(b)},_getItemIndex:function(a){var b=
this.option('classPrefix');if(a&&new RegExp('\\b'+this._toRegExp(b)+'item\\(([0-9]+)\\)').test(a.className)){var r=parseInt(RegExp.$1);return isNaN(r)?-1:r}return-1},selectAbove:function(a){return this._addSelectedIndex(-a)},selectBelow:function(a){
return this._addSelectedIndex(a)},_addSelectedIndex:function(a){var o=this._object;var b=-1;var c=this._selectedIndex;var d=c+a;var e=this._items.length;if(d<0)d=0;if(d>e-1)d=e-1;if(c<d){for(b=
d;b<e&&this._items[b].disable;b++){}if(b>=e)for(b=d;b>=c&&this._items[b].disable;b--){}}else{for(b=d;b>=0&&this._items[b].disable;b--){}if(b<0)for(b=d;b<=
c&&this._items[b].disable;b++){}}this._setSelectedIndex(b)},_setSelectedIndex:function(a){var o=this._object;if(o.source.selectedIndex==a)return;o.source.selectedIndex=a;this._comboChanged=true;this._fireChangeEvent()},_bindEvents:function(){var o=
this._object;this._simfocus.attach({focus:$Fn(this._handlers.box.focus,this).bind(),blur:$Fn(this._handlers.box.blur,this).bind(),fieldfocus:$Fn(this._handlers.field.focus,this).bind()});this._simfocus.attach(this._agent.opera?'keypress':'keydown',$Fn(this._handlers.box.keydown,this).bind());
$Fn(this._handlers.box.mousedown,this).attach(o.box,'mousedown');$Fn(this._handlers.combobox.keyup,this).attach(o.box,'keyup');$Fn(this._handlers.layer.mousedown,this).attach(o.layer,'mousedown');$Fn(this._handlers.list.mouseover,this).attach(o.list,'mouseover');$Fn(this._handlers.list.mousedown,
this).attach(o.list,'mousedown')},_removeSelectedClass:function(){var a=this.option('classPrefix');var b;var c=this._selectedIndex;if(c==-1)return;if((b=this._items[c])&&b.object){$Element(b.object).removeClass(a+'item-selected')}this._selectedIndex=-1},
_addSelectedClass:function(a){var b=this.option('classPrefix');this._removeSelectedClass();var c;if(a==-1)return;if((c=this._items[a])&&c.object){$Element(c.object).addClass(b+'item-selected');this._selectedIndex=a}},_removeHoveredClass:function(){
var a=this.option('classPrefix');var b;var c=this._hoveredIndex;if(c==-1)return;if((b=this._items[c])&&b.object){$Element(b.object).removeClass(a+'item-hovered')}this._hoveredIndex=-1},_addHoveredClass:function(a){var b=this.option('classPrefix');
this._removeHoveredClass();var c;if(a==-1)return;if((c=this._items[a])&&c.object){$Element(c.object).addClass(b+'item-hovered');this._hoveredIndex=a}},paint:function(){this._paintWidth();this._paintPseudoItem();this._paintItems();this._paintLabel();
this._paintItem()},paintValue:function(){this._setCustomValue();this._paintLabel()},_paintWidth:function(){var o=this._object;var b=this._options;var c=function(a){if(typeof a=='string'){if(/^[0-9]+%$/.test(a))a=Math.round(parseInt(a)*o.source.offsetWidth/100);
else a=parseInt(a)}return a};$Element(o.source).show();var d=c(b.boxWidth||b.width);var e=c(b.layerWidth||b.width);$Element(o.source).hide();if(!isNaN(d))$Element(o.box).css({width:d+'px'});if(!isNaN(e))
$Element(o.layer).css({width:e+'px'})},_paintHeight:function(){var a=this.option('height');if(!a||this._heightFitted)return;var o=this._object;if(o.list.offsetHeight>a){o.list.style.height=a+'px';if(this._agent.safari){o.list.style.overflow='scroll';
o.list.style.overflowX='hidden'}else{o.list.style.overflow='auto'}this._heightOverflowed=true}this._heightFitted=true},_paintLayer:function(){var o=this._object;var a=this.option('classPrefix');var b=$Element(o.layer);var c=$Element(o.box);var d=c.offset();var e=
b.height('margin');var f=c.height('margin');var g=d.top+o.box.offsetHeight+e;var h=(document.documentElement.scrollTop||document.body.scrollTop)+(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight);var i=
g>h;b[i?'addClass':'removeClass'](a+'layer-above');if(this.option('layer')){if(i){o.layer.style.top=d.top-e+'px';o.layer.style.left=d.left+'px'}else{o.layer.style.top=d.top+f+'px';o.layer.style.left=d.left+'px'}}},_paintItems:
function(){var o=this._object;var a=this.option('classPrefix');var b=cssquery('option',o.source);this._items=[];o.list.innerHTML='';o.list.style.height='auto';for(var i=0,eOption;eOption=b[i];i++){var c=$Element(eOption);var d=c.hasClass(a+'invisible');
var e=d||c.hasClass(a+'item-pseudo')||eOption.disabled;var f=this._getCustom(eOption);var g=null;var h=this._text(eOption)||'';if(!d){if(f&&this._custom[f]){g=this._custom[f].cloneNode(true)}else{g=$('<li>');g.style.cssText=
eOption.style.cssText;g.innerHTML=h}g.className=(eOption.className||'')+' '+a+'item('+i+')';o.list.appendChild(g)}this._items[i]={'index':i,'source':eOption,'object':g,'text':h,'found':h.toUpperCase(),'invisible':d,'disable':e,'custom':f}}
this._simfocus.setFriend(o.list);this._heightFitted=false;this._heightOverflowed=false},_paintLabel:function(){var o=this._object;var a=o.source.selectedIndex;if(a==-1)return;var b=this._items[a];if(o.combobox){if(b.custom){o.combobox.value=this._value(b.source)}else{
o.combobox.value=this._value(b.source);o.combobox.select()}return}var c=o.source.title;if(!c)c=b.text;$Element(o.label).html(c)},_paintItem:function(){var o=this._object;var a=o.source.selectedIndex;this._customTimer.stop();this._addSelectedClass(a);
this._addHoveredClass(a);var b=this._items[a];if(!b)return;var c=b.object;if(c&&this._isVisibleLayer()&&this._heightOverflowed){var d=c.offsetParent;var e=c.offsetTop-c.parentNode.offsetTop;var f=[o.list.scrollTop,o.list.scrollTop+o.list.clientHeight];var g=
[e,e+c.offsetHeight];if(f[0]>g[0])o.list.scrollTop=g[0];if(f[1]<g[1])o.list.scrollTop+=g[1]-f[1]}}}).extend(nhn.HTMLComponent);Selectbox._instanceKeys={};Selectbox.getInstance=function(o){var a=/\bselectbox\(([0-9]+)\)/;for(var b;o&&(b=
o.className);o=o.parentNode)if(a.test(b))return Selectbox._instanceKeys[RegExp.$1];return null};
