// ½ºÅ©·Ñ¹Ù¿¡ µðÀÚÀÎÀ» ÀÔÈ÷±â À§ÇÑ ½ºÅ©¸³Æ®// http://www.psyonline.krfunction fakescroll(tg,v){	if(typeof(tg)=='string') tg=document.getElementById(tg);	if(!tg) return;	//if(tg.scrollWidth==tg.offsetWidth && tg.scrollHeight==tg.offsetHeight) return;	if(!v) var v={}	if(!v.animate) v.animate=false;	if(!v.movesize_y) v.movesize_y=50;	if(!v.movesize_x) v.movesize_x=50;	if(!v.movebarsize_y) v.movebarsize_y='auto';	if(!v.movebarsize_x) v.movebarsize_x='auto';	if(!v.minsize_y) v.minsize_y=20;	if(!v.minsize_x) v.minsize_x=20;	if(!v.innerhtml) v.innerhtml={};	if(!v.onmouseover) v.onmouseover={};	if(!v.onmouseout) v.onmouseout={};	if(!v.onmousedown) v.onmousedown={};	if(!v.onmouseup) v.onmouseup={};	if(!v.onclick) v.onclick={};	var isie=navigator.userAgent.match(/msie/i);	var isie6=navigator.userAgent.match(/msie 6/i);	var isie7=navigator.userAgent.match(/msie 7/i);	var isfirefox=navigator.userAgent.match(/firefox/i);	var isapple=navigator.userAgent.match(/applewebkit/i);	var isopera=navigator.userAgent.match(/opera/i);	if(isie7) isie6=false;	if(getstyle(tg,'position')=='static') tg.style.position='relative';	tg.style.overflow='hidden';	tg.moveable=true;	if(tg.onmouseover) tg.saveonmouseover=tg.onmouseover;	tg.onmouseover=function(){		if(isie) this.onmousewheel=handle_wheel;		else this.addEventListener((isfirefox)? 'DOMMouseScroll' : 'mousewheel',handle_wheel,false);		this.onmouseover=(this.saveonmouseover)? this.saveonmouseover : null;	}	tg.content=ce();	tg.content.className='fs_content';	tg.content.innerHTML=tg.innerHTML;	tg.innerHTML='';	tg.appendChild(tg.content);	tg.track=[];	var classes=['fs_track_y','fs_track_x'];	for(var i=0; i<2; i++){		tg.track[i]=ce();		tg.track[i].className=classes[i];		tg.appendChild(basicset(tg.track[i],classes[i]));	}	tg.bar=[];	classes=['fs_bar_y','fs_bar_x'];	for(var i=0; i<2; i++){		tg.bar[i]=ce();		tg.bar[i].className=classes[i];		tg.bar[i].style.top=0;		tg.bar[i].style.left=0;		tg.track[i].appendChild(basicset(tg.bar[i],classes[i]));	}	tg.arrow=[];	classes=['fs_arrow_up','fs_arrow_down','fs_arrow_left','fs_arrow_right'];	for(var i=0; i<4; i++){		tg.arrow[i]=ce();		tg.arrow[i].className=classes[i];		if(i!=1) tg.arrow[i].style.top=0;		if(i==1) tg.arrow[i].style.bottom=0;		else if(i==2) tg.arrow[i].style.left=0;		else if(i==3) tg.arrow[i].style.right=0;		tg.track[Math.floor(i/2)].appendChild(basicset(tg.arrow[i],classes[i]));	}	tg.reset=function(){		if(isie7){tg.track[0].offsetLeft;tg.track[1].offsetLeft;}		tg.scrollTop=0;		tg.scrollLeft=0;		tg.content.style.marginTop=0;		tg.content.style.marginLeft=0;		if(isie7) tg.style.overflow='visible';		tg.track[0].ss=(isopera && getstyle(tg,'borderTopStyle')!='none')? tg.scrollHeight-parseInt(getstyle(tg,'borderTopWidth')) : tg.scrollHeight;		tg.track[1].ss=(isopera && getstyle(tg,'borderLeftStyle')!='none')? tg.scrollWidth-parseInt(getstyle(tg,'borderLeftWidth')) : tg.scrollWidth;		tg.track[0].show=tg.track[0].ss>tg.clientHeight;		tg.track[1].show=tg.track[1].ss>tg.clientWidth;		tg.track[0].size=(tg.track[0].show && tg.track[1].show)? tg.clientHeight-tg.track[1].offsetHeight : tg.clientHeight;		tg.track[1].size=(tg.track[0].show && tg.track[1].show)? tg.clientWidth-tg.track[0].offsetWidth : tg.clientWidth;		tg.track[0].style.display=(tg.track[0].show)? 'block' : 'none';		tg.track[1].style.display=(tg.track[1].show)? 'block' : 'none';		if(tg.track[0].show){			if(tg.content.className.indexOf('fs_content')==-1) tg.content.className=tg.content.className+'fs_content';			tg.track[0].style.top=(tg.track[1].offsetHeight>tg.track[1].offsetTop)? px(tg.track[1].offsetHeight) : 0;			tg.track[0].style.height=px(tg.track[0].size);			tg.bar[0].bs=tg.arrow[0].offsetHeight;			tg.bar[0].style.top=px(tg.bar[0].bs);			if(!v.movebarsize_y || v.movebarsize_y=='auto'){				tg.bar[0].style.height=px(tg.clientHeight*((tg.clientHeight-tg.arrow[0].offsetHeight-tg.arrow[1].offsetHeight)/tg.track[0].ss));				if(v.minsize_y>tg.bar[0].offsetHeight) tg.bar[0].style.height=px(parseInt(getstyle(tg.bar[0],'height'))+(v.minsize_y-tg.bar[0].offsetHeight));			}else{				tg.bar[0].style.height=px(v.movebarsize_y);				if(v.movebarsize_y!=tg.bar[0].offsetHeight) tg.bar[0].style.height=px(parseInt(getstyle(tg.bar[0],'height'))+(v.movebarsize_y-tg.bar[0].offsetHeight));			}			tg.bar[0].able=tg.track[0].offsetHeight-tg.bar[0].offsetHeight-tg.arrow[0].offsetHeight-tg.arrow[1].offsetHeight;		}else{			tg.content.className=tg.content.className.replace('fs_content','');		}		if(tg.track[1].show){			tg.track[1].style.left=(tg.track[0].offsetWidth>tg.track[0].offsetLeft)? px(tg.track[0].offsetWidth) : 0;			tg.track[1].style.width=px(tg.track[1].size);			tg.bar[1].bs=tg.arrow[2].offsetWidth;			tg.bar[1].style.left=px(tg.bar[1].bs);			if(!v.movebarsize_x || v.movebarsize_x=='auto'){				tg.bar[1].style.width=px(tg.clientWidth*((tg.clientWidth-tg.arrow[2].offsetWidth-tg.arrow[3].offsetWidth)/tg.track[1].ss));				if(v.minsize_x>tg.bar[1].offsetWidth) tg.bar[1].style.width=px(parseInt(getstyle(tg.bar[1],'width'))+(v.minsize_x-tg.bar[1].offsetWidth));			}else{				tg.bar[1].style.width=px(v.movebarsize_x);				if(v.movebarsize_x!=tg.bar[1].offsetWidth) tg.bar[1].style.width=px(parseInt(getstyle(tg.bar[1],'width'))+(v.movebarsize_x-tg.bar[1].offsetWidth));			}			tg.bar[1].able=tg.track[1].offsetWidth-tg.bar[1].offsetWidth-tg.arrow[2].offsetWidth-tg.arrow[3].offsetWidth;		}		tg.content.able_y=tg.clientHeight-tg.scrollHeight;		tg.content.able_x=tg.clientWidth-tg.scrollWidth;		if(isie7) tg.style.overflow='hidden';	}	tg.reset();	tg.update=function(v){		tg.content.innerHTML=v;		tg.reset();	}	tg.scroll=scroll;	function scroll(flag,mv){		if(flag=='y' || flag=='up' || flag=='down'){			var nv=parseInt(tg.content.style.marginTop);			var value=(mv || mv===0)? mv : (flag=='up')? nv+v.movesize_y : nv-v.movesize_y;			if(value>0) value=0;			else if(value<tg.content.able_y) value=tg.content.able_y;			if(v.animate){				tg.content.bar=tg.bar[0];				tg.content.av=Math.round(value);				animate(tg.content,'marginTop');			}else{				tg.content.style.marginTop=px(value);				if(!mv) tg.bar[0].style.top=px(tg.arrow[0].offsetHeight+(tg.bar[0].able*(value/tg.content.able_y)));			}		}else{			var nv=parseInt(tg.content.style.marginLeft);			var value=value=(mv || mv===0)? mv : (flag=='left')? nv+v.movesize_x : nv-v.movesize_x;			if(value>0) value=0;			else if(value<tg.content.able_x) value=tg.content.able_x;			tg.content.style.marginLeft=px(value);			if(!mv) tg.bar[1].style.left=px(tg.arrow[2].offsetWidth+(tg.bar[1].able*(value/tg.content.able_x)));		}	}	function animate(tgc,flag){		clearTimeout(tgc.timer);		var action=function(){			var nv=parseInt(tgc.style[flag]);			if(nv!=tgc.av){				nv=(nv>tgc.av)? Math.floor(nv+((tgc.av-nv)/5)) : Math.ceil(nv+((tgc.av-nv)/5));				tgc.style[flag]=px(nv);				tgc.bar.style.top=px(Math.round(tg.arrow[0].offsetHeight+(tg.bar[0].able*(nv/tg.content.able_y))));				tgc.timer=setTimeout(action,20);			}		}		action();	}	var scrolltimer=null;	function autoscroll(flag,value){		clearTimeout(scrolltimer);		if(flag.match(/track/)){			if(flag=='track_y') flag=((tg.bar[0].offsetTop+tg.bar[0].offsetHeight)>value)? 'up' : 'down';			else flag=((tg.bar[0].offsetLeft+tg.bar[0].offsetWidth)>value)? 'left' : 'right';		}else flag=flag.replace('arrow_','');		var isfirst=true;		var action=function(){			if(value &&				((flag=='up' && (tg.bar[0].offsetTop<value)) || 				(flag=='down' && ((tg.bar[0].offsetTop+tg.bar[0].offsetHeight)>value)))			) return;			scroll(flag);			scrolltimer=setTimeout(action,(isfirst)? 500 : 50);			isfirst=false;		}		action();	}	function handle_over(e){		if(!e) e=window.event;		e.tg=gettarget(e);		if(v.onmouseover[e.tg.flag]){			e.tg.onmouseover=v.onmouseover[e.tg.flag];			e.tg.onmouseover();		}		if(e.stopPropagation) e.stopPropagation();		else e.cancelBubble=true;	}	function handle_out(e){		if(!e) e=window.event;		e.tg=gettarget(e);		if(v.onmouseout[e.tg.flag]){			e.tg.onmouseout=v.onmouseout[e.tg.flag];			e.tg.onmouseout();		}		if(e.stopPropagation) e.stopPropagation();		else e.cancelBubble=true;	}	function handle_down(e){		if(!e) e=window.event;		e.tg=gettarget(e);		if(e.tg.flag.match(/track/)){			autoscroll(e.tg.flag,(e.tg.flag=='track_y')? (e.layerY)? e.layerY : e.offsetY : (e.layerX)? e.layerX : e.offsetX);		}else if(e.tg.flag.match(/arrow/)){			autoscroll(e.tg.flag);		}else{			var barclicktg=e.tg;			var barsavepos=(e.tg.flag=='bar_y')? e.tg.offsetTop : e.tg.offsetLeft;			var barclickpos=(e.tg.flag=='bar_y')? e.clientY : e.clientX;			document.onmousemove=function(e){				if(!e) e=window.event;				var as,value,nowpos=(barclicktg.flag=='bar_y')? e.clientY : e.clientX;				if(barclickpos!=nowpos){					value=barsavepos-(barclickpos-nowpos);					as=(barclicktg.flag=='bar_y')? tg.arrow[0].offsetHeight : tg.arrow[2].offsetWidth;					if(as>value) value=as;					else if(value>barclicktg.able+as) value=barclicktg.able+as;					if(barclicktg.flag=='bar_y'){						barclicktg.style.top=px(value);						scroll('y',tg.content.able_y*((value-as)/barclicktg.able));					}else{						barclicktg.style.left=px(value);						scroll('x',tg.content.able_x*((value-as)/barclicktg.able));					}				}				return false;			}			e.tg.onmouseup=document.onmouseup=function(){				document.onmousemove=null;			}		}		if(v.onmousedown[e.tg.flag]){			e.tg.onmousedown=v.onmousedown[e.tg.flag];			e.tg.onmousedown();		}		if(e.stopPropagation) e.stopPropagation();		else e.cancelBubble=true;	}	function handle_up(e){		clearTimeout(scrolltimer);		if(!e) e=window.event;		e.tg=gettarget(e);		if(v.onmouseup[e.tg.flag]){			e.tg.onmouseup=v.onmouseup[e.tg.flag];			e.tg.onmouseup();		}		if(e.stopPropagation) e.stopPropagation();		else e.cancelBubble=true;	}	function handle_click(e){		if(!e) e=window.event;		e.tg=gettarget(e);		if(v.onclick[e.tg.flag]){			e.tg.onclick=v.onclick[e.tg.flag];			e.tg.onclick();		}		if(e.stopPropagation) e.stopPropagation();		else e.cancelBubble=true;	}	function handle_wheel(e){		if(tg.track[0].show){			if(!e) e=window.event;			var wdata=(e.wheelDelta)? e.wheelDelta : e.detail;			if(isfirefox) wdata=wdata*-1;			if(wdata>0) scroll('up');			else scroll('down');			if(tg.moveable){				if(e.preventDefault) e.preventDefault();				return false;			}		}	}	function ce(){		return document.createElement('div');	}	function px(v){		return v+'px';	}	function getstyle(tg,v){		var gv;		if(tg.currentStyle) gv=tg.currentStyle[v];		else gv=document.defaultView.getComputedStyle(tg,null)[v];		return gv;	}	function basicset(tg,classname){		tg.style.position='absolute';		tg.style.overflow='hidden';		tg.flag=classname.replace('fs_','');		tg.onmouseover=handle_over;		tg.onmouseout=handle_out;		tg.onmousedown=handle_down;		tg.onmouseup=handle_up;		tg.onclick=handle_click;		if(v.innerhtml){			if(v.innerhtml[classname.replace('fs_','')]) tg.innerHTML=v.innerhtml[classname.replace('fs_','')];		}		return tg;	}	function gettarget(e){		e.tg=(e.target)? e.target : e.srcElement;		while(!e.tg.className.match(/(fs_track_|fs_bar_|fs_arrow)/)) e.tg=e.tg.parentNode;		return e.tg;	}}
