// WUI : worthy user interface libraries 
//    last updated 2006/12/07 
//	support UA : IE6,Firefox1.5/2.0(win/OSX),Opera9

WUI = { 
mcapture:undefined,

//for debug 
dbgmsg : function(msg,f) {
	try {
		if(f) $('dbgmsg').innerHTML += msg ;
		else $('dbgmsg').innerHTML = msg   ;
	}catch(e) {} ;
}
,
// Initialize 
OnLoad : function() {
	WUI.mcapture = new WUI.MouseCapture() ;
	WUI.OnloadInit.loaded() ;
}
,
// set initializer
OnloadInit : new function() {
	var _f = [] ;
	this.setinit = function(f) {
		_f.push( f ) ;
	}
	this.loaded = function() {
		for(i in _f) {
			try {
				_f[i]() ;
			} catch(err) { }
		}
	}
}
,
// randezvous 
Sync : function(ids,func) {
	var i={},f ;
	f = func ;
	for(a in ids) {
		i[ids[a]] = 0 ;
	}
	this.set = function(id) {
		i[id] = 1 ;
		for(a in i) {
			if( i[a] == 0 ) return ;
			f() ;
		}
	}
}
,
// check enter key and exec script
ExecEnter : function(ev,script) {
	var key ;
	if(window.event) key=event.keyCode ;
	else key=ev.keyCode ;
	if(key==13){ 
		if(typeof script =='function') script() ;
		else eval(script) ;
	}
	return false ;
}
,
//wheel 
AddWheel : function(c,min,max){
 	var func = function(e){
	var d=(e.wheelDelta||(e.preventDefault(),-e.detail) );
	if(d<0) c.value-- ;
		if(d>0) c.value++;
		return false ;
	}
	c.attachEvent?c.attachEvent("onmousewheel",func):c.addEventListener("DOMMouseScroll",func,false);
}
,
// mouse capture on object
MouseCapture : function(obj) {
	if(obj==null) obj = document ;
	var f_move,f_up,f_down,f_out,f_over ;
	var mx,my ;
	obj.onmousemove = function(ev) {
		if(f_move != null ) {
			var mouse = MouseAbs(ev) ;
			if(mouse.x != mx || mouse.y != my ) {
				mx = mouse.x ;
				my = mouse.y ;
				f_move( ev ) ;
			}
			return false ;
		}
	}
	obj.onmouseup = function(ev) {
		if(f_up != null ) {
			var mouse = MouseAbs(ev) ;
			f_up( ev ) ;
			return false ;
		}
	}
	obj.onmousedown = function(ev) {
		if(f_down != null ) {
			var mouse = MouseAbs(ev) ;
			f_down( ev ) ;
			return false ;
		}
	}
	obj.onmouseout = function(ev) {
		if(f_out != null ) {
			var mouse = MouseAbs(ev) ;
			f_out( ev ) ;
			return false ;
		}
	}
	obj.onmouseover = function(ev) {
		if(f_over != null ) {
			var mouse = MouseAbs(ev) ;
			f_over( ev ) ;
			return false ;
		}
	}
	this.setMove = function( fn ) {
		f_move =fn ;
	}
	this.setUp = function( fn ) {
		f_up =fn ;
	}
	this.setDown = function( fn ) {
		f_down =fn ;
	}
	this.setOut = function( fn ) {
		f_out =fn ;
	}
	this.setOver = function( fn ) {
		f_over =fn ;
	}
}
,
// cancel event bubble 
CancelEvent : function(ev) {
	if(window.addEventListener) ev.stopPropagation() ;
	else window.event.cancelBubble = true ;
}
,
// calc element position on absolute axis
ElemPos : function(obj) {
	var t = obj ;
	var x=0,y=0 ;
	while(t) {
		x += t.offsetLeft ;
		y += t.offsetTop ;
		t = t.offsetParent ;
	}
	return {x:x,y:y } ;
}
,
// return window size 
WinSize : function(obj) {
	var w,h ;
	obj = $(obj);
	if(window.innerHeight) {w = window.innerWidth; h=window.innerHeight; } //ff
	else { w=document.documentElement.clientWidth; h=document.documentElement.clientHeight;} //IE
	if(typeof obj=="object") {
		obj.style.width = w + "px" ;
		obj.style.height = h + "px" ;
		if(obj._fitdiv) obj._fitdiv() ;
		var i ;
		for(i in obj.childNodes) if(obj.childNodes[i].nodeName=="DIV") break;
		if(obj.childNodes[i]._fitdiv) obj.childNodes[i]._fitdiv() ;
	}
	return {'width':w, 'height':h } ;
}
,
// fit div element to parent size 
FitDiv : function(o,m,func) {
	var _o = $(o) ;
	var _f = func ;
	var _po = _o.parentNode ;
//	_o.style.width = "100px" ;
//	_o.style.height = "100px" ;
//	var _pw = _o.offsetWidth -100 ;
//	var _ph = _o.offsetHeight - 100;
	var _pw = 0 ;
	var _ph = 0 ;
	var _mx,_my ;
	if(typeof m == "object" ) {
		_mx = m.x ; _my = m.y ;
	} else {
		_mx = m ; _my = m ;
	}

	_o._fitdiv = function() {
			var x = 	(_po.clientWidth - _pw -_mx)  ;
			if(x>0) _o.style.width = 	x + "px"  ;
			var y = (_po.clientHeight - _ph -_my)  ;
			if(y>0) _o.style.height = y + "px" ;
			if(_f) _f(_o,x,y) ;
			var i ;
			for(i in _o.childNodes) if(_o.childNodes[i].nodeName=="DIV") break;
			if(_o.childNodes[i]._fitdiv) _o.childNodes[i]._fitdiv() ;
	}
//	_o._fitdiv() ;
}
,
// scroll table 
ScrollTable : function(div) {
	var _o = Elem(div) ;
	var ch = _o.childNodes ;
	var d = [] ;  
	for(var i=0;i<ch.length;i++) if(ch[i].nodeName=="DIV") d.push(ch[i]) ;
	var _d_h = d[0] ;
	var _d_b = d[1] ;


	function scan_tr(t) {
		var t = Elem(t) ;
		if(!t) return ;
		var i,o,s,e ;
		for(i=0;i<t.childNodes.length;i++) {
			o = t.childNodes[i] ;
			if(o.nodeName == "TBODY" ) break ;
		}
		t = o ;
		if(!t) return ;
		for(i=0;i<t.childNodes.length;i++) {
			o = t.childNodes[i] ;
			if(o.nodeName == "TR" ) break ;
		}
		o = o.childNodes ; //td
		s = [] ;
		for( e in o) {
			if(o[e].nodeName == "TD" || o[e].nodeName=="TH") {
				if(o[e].offsetWidth) s.push(o[e].offsetWidth) ;
				else s.push(o[e].width)  ;
			}
		}
		return s ;
	}
	function set_tr(t,s,m) {
		t = Elem(t) ;
		if(!t) return ;
		for(i=0;i<t.childNodes.length;i++) {
			o = t.childNodes[i] ;
			if(o.nodeName == "TBODY" ) break ;
		}
		t = o ;
		if(!t) return ;
		for(i=0;i<t.childNodes.length;i++) {
			o = t.childNodes[i] ;
			if(o.nodeName == "TR" ) break ;
		}
		o = o.childNodes ; //td
		var i = 0;
		for( e in o) {
			if(o[e].nodeName == "TD" ) {
				o[e].style.width = (s[i++]-m) +"px";
			}
			if(o[e].nodeName == "TH" ) {
				o[e].style.width = (s[i++]-m) +"px";
			}
		}
	}
	this.setCols = function(margin) {
		if(!_d_b || !_d_h) return ;
		if(margin==undefined) margin = 0 ;
		var s= [] ;
		var s1 = scan_tr(_d_h.firstChild) ;
		var s2 = scan_tr(_d_b.firstChild) ;
		if(s1.length==0 || s2.length==0 ) return ;
		for(i =0;i<s1.length;i++ ) {
			s[i] = (s1[i]>s2[i])?s1[i]:s2[i]; 
		}
		set_tr(_d_h.firstChild,s,margin) ;
		set_tr(_d_b.firstChild,s,margin) ;
	}
	this.setScroll = function(height) {
		if(height!=undefined) _o.style.height = height + "px" ;
		else height = _o.offsetHeight ;
		if(height<0) return ;
		_d_b.style.height = (height-_d_h.offsetHeight) + "px" ;

//$I('msg',height+"/"+_d_h.offsetHeight+"/"+_d_b.offsetHeight) ;
	}
}
,
// iframe tab
TabFrame : function(tab,base) {
	var _t = $(tab) ;
	var _b = $(base) ;
	var _tabs = {} ;
	var _ctab = "" ;
	var _lasttab = "" ;
	var _this = this ;
	var _s = 1 ;

	this.currentTabName = "" ;

	function callback(name,param) {
		var obj = _tabs[name].obj;
		try {
			if( typeof obj.contentWindow.ontabchange == 'function') 
				obj.contentWindow.ontabchange(name,param) ;
		} catch(e) {} ;
	}
	function addtab(name,title) {
		f = document.createElement('li') ;
		f.id = "b_"+name ;
		f.innerHTML = title ;
		f.className = "taboff" ;
		f.onclick = function() {
			if(_ctab==name) return ;
			_this.change(name) ;
		} ;
		_t.appendChild(f) ;
	}
	function getuniqid() {
			var name = "f"+_s ;
			_s++ ;
			return name ;
	}
	this.add = function(src,title,name) {
		if(name==undefined) name = getuniqid();
		var f = document.createElement('iframe') ;
		f.id = "tf_"+name ;
		f.setAttribute('frameborder',"0") ;
		f.className = "tabframe" ;
		
		f.onload = function() {		//mozilla
			callback(name) ;
		} ;
		f.onreadystatechange = function() { //IE
			if(this.readyState=="complete") callback(name) ;
		} ;
		var obj = _b.appendChild( f ) ;
		_tabs[name] = {'obj':obj,'src':src,'id':f.id,'loaded':false,'title':title} ;
		addtab(name,title) ;
		return name ;
	}
	this.getcurrent = function() {
		return {'name':_ctab,'frame':_tabs[_ctab].obj} ;
	}
	this.adddiv = function(title,name) {
		if(name==undefined) name = getuniqid();
		var f = document.createElement('div') ;
		f.id = "tf_"+name ;
		f.className = "tabdiv" ;
		var obj = _b.appendChild( f ) ;
		_tabs[name] = {'obj':obj,'id':f.id,'title':title} ;
		addtab(name,title) ;
		return name ;
	}
	this.close = function(name)  {
		if(name==undefined) name=_ctab ;
		if( _tabs[name] == undefined) return -1 ;
		var o = _tabs[name].obj ;
		if(_ctab==name) {
			delete _tabs[name] ;	
			if(_tabs[_lasttab]!=undefined) {
				_this.change(_lasttab) ;
			} else {
				for(var i in _tabs) {
					if(_tabs[i]) { _this.change(i) ; break ;}
				}
			}
		}
		o.src ="" ;
		_b.removeChild(o)
		_t.removeChild($('b_'+name));
	}
	this.load = function(name,src,param) {
		if( _tabs[name] == undefined) return -1 ;
		var o = _tabs[name].obj ;
		o.src = name ;
		_this.change(name,param) ;
	}
	this.change = function(name,param) {
		var t = _tabs[name] ;
		if( t == undefined) return -1 ;
		if(_ctab!="") {
			_this.hide(_ctab) ;
			$('b_'+_ctab).className = "taboff" ;
			_lasttab = _ctab ;
		}
		$('b_'+name).className = "tabon" ;
		t.obj.style.display="block" ;
		if(!t.loaded) {
			t.obj.src = t.src ;
			t.loaded = true ;
		}
		_ctab = name ;
		_this.currentTabName = _ctab ;
		callback(name,param) ;
	}
	this.hide = function(name) {
		var t = _tabs[name] ;
		if( t == undefined) return -1 ;
		t.obj.style.display="none" ;
	}
}
,
//box fill
SetSizeY : function(divs) {

  var base,mb=0, af=[],fill ;
  for(i in divs) {
		switch(divs[i].type) {
		case 'base':
			base =$(divs[i].obj) ;
			break ;
		case 'fixed':
		case 'auto':
			af.push($(divs[i].obj)) ;
			mb += divs[i].margin ;
			break ;
		case 'fill':
			fill = $(divs[i].obj) ;
			mb += divs[i].margin ;
			break ;
		}
	}

	this.resize = function() {
		var wh = base.offsetHeight ;
		for(i in af) {
			wh -= af[i].offsetHeight ;
		}
		fill.style.height = (wh-mb)+"px" ;
	}
}
,
// popup dialog
Popup : function(tid) {
	var o = $(tid) ;
	var tim =null ;
	var copy = this ;
	var flag = null ;
	o.style.position = "absolute" ;
	o.style.visibility = "hidden" ;
	o.style.display = "none" ;
	o.onmouseout = function(event) {
		if(flag) return ;
		var m= MouseAbs(event) ;
		var b = { sx:o.offsetLeft,sy:o.offsetTop,ex:o.offsetLeft+o.offsetWidth,ey:o.offsetTop+o.offsetHeight}; 
		if(m.x <= b.sx || m.x >= b.ex || m.y <= b.sy || m.y >= b.ey ) {
			o.style.visibility = "hidden" ;
			o.style.display = "none" ;
		}
	}

	this.open = function(obj,ox,oy,f) {
		var p = WUI.ElemPos(obj) ;
		flag = f ;
		if(!ox) ox = 0 ;
		if(!oy) oy = 0 ;
		o.style.top = p.y + oy + "px" ;
		o.style.left = p.x + ox+ "px"  ;
		o.style.visibility = "visible" ;
		o.style.display = "block" ;
	}
	this.close = function() {
		o.style.visibility = "hidden" ;
		o.style.display = "none" ;
		if(tim) clearTimeout(tim) ;
		tim=null ;
	}
	this.delay_open = function(obj,ox,oy,delay){
		var _obj = obj ;
		var _ox = ox ;
		var _oy = oy ;
		tim = setTimeout(function(){ copy.open(_obj,_ox,_oy);} , delay ) ;
	}
}
,
// set element draggable
SetDrag : function(obj,cobj) {
	var _obj = $(obj) ;
	var _cobj ;
	if(cobj) _cobj = cobj; else _cobj = _obj ;
  _obj.dragging = 0;
  _obj.sx = 0;
  _obj.sy = 0;
  _cobj.onmousedown = down ;
	if(!_obj.style.top) _obj.style.top=_obj.offsetTop +"px";
	if(!_obj.style.left) _obj.style.left=_obj.offsetLeft+"px" ;
	_obj.style.position = "absolute" ;
	_cobj.onmouseover = over ;
	_cobj.onmouseout = out ;

	function over() {
		_cobj.style.cursor = "move" ;	
		return true ;
	}
	function out() {
		_cobj.style.cursor = "auto" ;	
		return true ;
	}

  function down(ev,a) {
		var m = MouseAbs(ev) ;
		_obj.style.top=_obj.offsetTop+"px" ;
		_obj.style.left=_obj.offsetLeft+"px" ;
		_obj.style.cursor = "move";
		_obj.sx = m.x ;
		_obj.sy = m.y ;
    _obj.dragging = 1 ;
		WUI.mcapture.setMove( move ) ;
		WUI.mcapture.setUp( up ) ;
		return false ;
  }
  function up() {
		_obj.style.cursor = "auto";
    _obj.dragging = 0 ;
		return true ;
  }
	
  function move(ev) {
		if(_obj.dragging==0) return ;
		var m = MouseAbs(ev) ;
		var dx = _obj.sx - m.x ;
		var dy = _obj.sy - m.y ;
		var py = _obj.offsetTop - dy ;
		var px = _obj.offsetLeft - dx ;	
		_obj.style.top = py+"px" ;
		_obj.style.left = px+"px" ;
		_obj.sx = m.x ;
		_obj.sy = m.y ;
		return false ;
  }
}
,

//panel
PanelMoveH : function( base,p1_ratio,p1_min,p2_min) {
	var pb = $(base) ;
	var i,a=[] ;
	for(i=0;i<pb.childNodes.length;i++) if(pb.childNodes[i].nodeName=="DIV") a.push(pb.childNodes[i]) ;
	if( a.length <3 ) return null ;
	var min_h1 = 50 ;
	if(p1_min) min_h1 = p1_min ;
	var min_h2 = 50 ;
	if(p2_min) min_h2 = p2_min ;
	var pm = a[1] ;
	var p1 = a[0] ;
	var p2 = a[2] ;
	var dragging = false ;
	var sm,left ;
	var pm_h = pm.offsetWidth ;
	var onchangefunc = null ;
	var onendfunc = null ;
	var ratio =p1_ratio;
	if(p1_ratio==null) ratio = 0.5 ;
	var ph,p1_h,p2_h;

	this.setOnChange = function(func) {
		onchangefunc = func ;
	}
	this.setOnEnd = function(func) {
		onendfunc = func ;
	}
	this.setSize = function(w,h) {
		setsize(w,h) ;
	}

	function setsize(w,h) {
		pb.style.height = h + "px" ;
		pb.style.width = w + "px" ;
		pm.style.height = h + "px" ;
		ph = w ;
		if(p1_h==null) p1_h = Math.floor(ph*ratio) ;
		p2_h = ph-pm_h-p1_h ;
		if(p2_h<min_h2) {
			p2_h = min_h2 ;
			p1_h = ph - p2_h - pm_h ;
		}
//WUI.dbgmsg("setsize"+ph+"/"+p1_h+"/"+p2_h,1) ;
		setpos();
		end() ;
	}
	pb._fitdiv = function() {
		var p = pb.parentNode ;
//WUI.dbgmsg(pb.id+"/"+p.offsetWidth+"/"+p.offsetHeight,1 );
		setsize(p.offsetWidth,p.offsetHeight );
	}
	function setpos() {
		p1.style.width = p1_h+"px" ;
		p2.style.width = p2_h+"px" ;
		pm.style.left = p1_h+"px" ;
		p2.style.left = (p1_h+pm_h)+"px" ;
	}
	function change() {
		if(onchangefunc) onchangefunc(p1_h,p2_h) ;
	}
	function end() {
		var i ;
		for(i in p1.childNodes) if(p1.childNodes[i].nodeName=="DIV") break ;
		if(p1.childNodes[i]._fitdiv) p1.childNodes[i]._fitdiv() ;
		for(i in p2.childNodes) if(p2.childNodes[i].nodeName=="DIV") break ;
		if(p2.childNodes[i]._fitdiv) p2.childNodes[i]._fitdiv() ;
		if(onendfunc) onendfunc(p1_h,p2_h) ;
	}

	function mosmove(ev) {
		if(!dragging) return ;
		var mm = MouseAbs(ev) ;
		var dx = mm.x - sm.x ;
		p1_h = (left+dx) ;
		if(p1_h<min_h1) {
			p1_h = min_h1 ;
		}
		p2_h = (ph - p1_h -pm_h ) ;
		if(p2_h<min_h2) {
			p2_h = min_h2 ;
			p1_h = ph - p2_h - pm_h ;
		}
//WUI.dbgmsg(ph+"/"+p1_h+"/"+p2_h) ;
		setpos() ;
		end();
	
	}
	pm.onmousedown = function(ev) {
		sm = MouseAbs(ev) ;
		dragging = true ;
		left = pm.offsetLeft ;
		WUI.mcapture.setMove( mosmove ) ;
		WUI.mcapture.setUp( function(){ 
			dragging=false;
			WUI.mcapture.setMove( null ) ;
			WUI.mcapture.setUp( null ) ;
			end() ;
		} ) ;
	}
}
,
PanelMoveV : function(base,p1_ratio,p1_min,p2_min) {
	var pb = $(base) ;
	var i,a=[] ;
	for(i=0;i<pb.childNodes.length;i++) if(pb.childNodes[i].nodeName=="DIV") a.push(pb.childNodes[i]) ;
	if( a.length <3 ) return null ;
	var min_h1 = 50 ;
	if(p1_min) min_h1 = p1_min ;
	var min_h2 = 50 ;
	if(p2_min) min_h2 = p2_min ;
	var pm = a[1] ;
	var p1 = a[0] ;
	var p2 = a[2] ;
	var dragging = false ;
	var sm,top ;
	var pm_h = pm.offsetHeight ;
	var onchangefunc = null ;
	var onendfunc = null ;
	var ratio =p1_ratio;
	if(p1_ratio==null) ratio = 0.5 ;
	var ph,p1_h,p2_h;

//WUI.dbgmsg(ph+"/"+p1_h+"/"+pm_h+"/"+p2_h) ;

	this.setOnChange = function(func) {
		onchangefunc = func ;
	}
	this.setOnEnd = function(func) {
		onendfunc = func ;
	}

	this.setSize = function(w,h) {
		setsize(w,h) ;
	}

	function setsize(w,h) {
		pb.style.width = w + "px" ;
		pb.style.height = h + "px" ;
		pm.style.width = w + "px" ;
		ph = h ;
		if(p1_h==null) p1_h = Math.floor(ph*ratio) ;
		p2_h = ph-pm_h-p1_h ;
		if(p2_h<min_h2) {
			p2_h = min_h2 ;
			p1_h = ph - p2_h - pm_h ;
		}
		setpos();
		end() ;
	}
	pb._fitdiv = function() {
		var p = pb.parentNode ;
//WUI.dbgmsg(pb.id+"/"+p.offsetWidth+"/"+p.offsetHeight,1 );
		setsize(p.offsetWidth,p.offsetHeight );
	}
	function setpos() {
		p1.style.height = p1_h+"px" ;
		p2.style.height = p2_h+"px" ;
		pm.style.top = p1_h+"px" ;
		p2.style.top = (p1_h+pm_h)+"px" ;
	}

	function change() {
		if(onchangefunc) onchangefunc(p1_h,p2_h) ;
	}
	function end() {
		var i ;
		for(i in p1.childNodes) if(p1.childNodes[i].nodeName=="DIV") break ;
		if(p1.childNodes[i]._fitdiv) p1.childNodes[i]._fitdiv() ;
		for(i in p2.childNodes) if(p2.childNodes[i].nodeName=="DIV") break ;
		if(p2.childNodes[i]._fitdiv) p2.childNodes[i]._fitdiv() ;
		if(onendfunc) onendfunc(p1_h,p2_h) ;
	}

	function mosmove(ev) {
		if(!dragging) return ;
		var mm = MouseAbs(ev) ;
		var dy = mm.y - sm.y ;
		p1_h = (top+dy) ;
		if(p1_h<min_h1) {
			p1_h = min_h1 ;
		}
		p2_h = (ph - p1_h -pm_h ) ;
		if(p2_h<min_h2) {
			p2_h = min_h2 ;
			p1_h = ph - p2_h - pm_h ;
		}
		setpos() ;
//WUI.dbgmsg(p1_h+"/"+p2_h) ;
		change() ;
	}
	pm.onmousedown = function(ev) {
		sm = MouseAbs(ev) ;
		top = pm.offsetTop ;
		dragging = true ;
		WUI.mcapture.setMove( mosmove ) ;
		WUI.mcapture.setUp( function(){ 
			dragging=false;
			WUI.mcapture.setMove( null ) ;
			WUI.mcapture.setUp( null ) ;
			end() ;
		} ) ;
	}
}
,
// slider parts
Slider : function(id,size,amin,amax,apos,v) {
	var pos = apos;
	var ck = 0 ;
	var mx,my = 0;
	var id = id ;
	var min=0;
	var max=size-1 ;
	var vmin = amin ;
	var vmax = amax ;
	var value = vmin ;
	var mxs,mys ;
	var fonchange  ;
	var vertical =0 ;
	if(v) vertical = 1 ;
	if(!apos) pos = min ;

	function _setpos(x,f) {
		if(x<min) x = min ;
		if(x>max) x = max ;
		pos = x ;
		if(vertical) $(id+'_btn').style.top = x-max + "px";
		else $(id+'_btn').style.left = x + "px";
		value = (vmax-vmin)*pos/(max-min)+vmin ;
		$(id+'_btn').title = value;
		if(!f && fonchange) {
			fonchange(value) ;
		}
	}

	//method
	this.setvalue = function(v) {
		var p = (max-min)*v/(vmax-vmin) ;
		_setpos(parseInt(p),1);
	}
	this.getvalue = function() {
		return value ;
	}
	this.setonchange = function(f) {
		fonchange = f ;
	}

	//event handler
	function sclick(ev) {
		var o = MouseRel(ev) ;
		if(vertical) _setpos(o.y) ;
		else _setpos(o.x) ;
		sdown(ev) ;
	}
	function sdown(ev) {
		ck = 1 ;
		m = MouseAbs(ev);
		mx = m.x ;
		my = m.y ;
		WUI.mcapture.setMove( smove ) ;
		WUI.mcapture.setUp( sup ) ;
		return false ;
	}
	function sup(ev) {
		ck = 0 ;
		WUI.mcapture.setMove( null ) ;
		WUI.mcapture.setUp( null ) ;
	}
	function smove(ev) {
		var m = MouseAbs(ev) ;
		if(ck) {
			if(vertical) pos = pos + m.y - my ;
			else pos = pos + m.x - mx ;
			_setpos(pos) ;
			mx = m.x ;
			my = m.y ;
		}
	}
	function wheel(e) {
		var d=(e.wheelDelta||(e.preventDefault(),-e.detail) );
		if(vertical) d = -d ;
		if(d<0) _setpos(--pos) ;
		if(d>0) _setpos(++pos) ;
		return false ;
	}

	//constructor
	_setpos(pos);
  $(id+'_bar').onmousedown=sclick ;
  $(id+'_btn').onmousedown=sdown ;

	if(vertical) {
		$(id+'_bar').style.height = size + "px" ;
		$(id+'_base').style.height = size+16 + "px" ;
	} else {
		$(id+'_bar').style.width = size + "px" ;
		$(id+'_base').style.width = size+16 + "px" ;
	}
	//wheel support
	var o =$(id+'_base') ;
	o.attachEvent?o.attachEvent("onmousewheel",wheel):o.addEventListener("DOMMouseScroll",wheel,false);
}
,
// shutter gimik
Shutter : function(obj,ratio){
	var divh,ofs,tid,i,dh ;
	var bobj,sobj ;
	var flag = 0 ;
	var endf = null ;
	bobj = $(obj) ;
	for( i = 0; i < bobj.childNodes.length ; i++ ) {
		if( bobj.childNodes[i].tagName == "DIV" ) break ;
	}
	if(!ratio) var ratio=2 ;
	sobj = bobj.childNodes[i] ;
	divh = sobj.offsetHeight+2 ;
	dh = Math.floor(divh/20*ratio)||1;
	sobj.style.top = -divh + "px" ;
//	bobj.style.height = divh + "px" ;

	function _op() {
		ofs+= dh ;
		if(ofs>0) ofs = 0;
		sobj.style.top = ofs + "px" ;
		if(ofs==0) {
			clearInterval(tid) ; 
			flag = 1 ;
			if(endf!=null) { endf() ; endf = null; }
		}
	}
	function _close()  {
		ofs-= dh ;
		if(ofs<-divh) ofs = -divh;
		sobj.style.top = ofs + "px" ;
		if(ofs==-divh) { 
			clearInterval(tid) ; 
			bobj.style.height = 0 + "px" ;
			flag = 0 ;
			if(endf!=null) { endf() ; endf = null; }
		}
	}
	this.sopen = function(f) {
		endf = f ;
		ofs= -divh ;
		bobj.style.height = divh + "px" ;
		tid = setInterval(_op,50);
	}
	this.sclose = function(f) {
		endf = f ;
		tid = setInterval(_close,50);
	}
	this.toggle = function(f) {
		endf = f ;
		if( flag ) this.sclose(f) ;
		else this.sopen(f) ;
	}
}
}

