/* ImageBox.js v 1.8
 * author : yeongun@ncsoft.net
 * last update: 2009.2.25
 * (c) 2008 ncsoft UIDevelopment Team */
var sturl='http://static.fr.aiononline.com/aion/common/popview/';
var $i={hnd:'#imagebox_area #imagebox_handle ',tmb:'#imagebox_area .utils_thumb ',dot:'#imagebox_area .utils_dot ',rel:'#imagebox_area .imagebox_rel ',gb:'#imagebox_ghost_box .preview_bg ',bf:'_background:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''};
var IBCss='<style type=\"text\/css\">#imagebox_modal {position:absolute;top:0;left:0;z-index:999;display:none;width:100%;height:100%;}#imagebox_area {position:absolute;top:-50000px;left:0;z-index:1000;overflow:hidden;}#imagebox_area #imagebox_ready { position:absolute;width:0;height:0;overflow:hidden;}'+$i.hnd+'{padding:0 7px;position:relative;display:block;z-index:1005;cursor:move;}'+$i.hnd+'.rd_left, #imagebox_area #imagebox_handle .rd_right {width:7px;height:119px;overflow:hidden;position:absolute;top:0;}'+$i.hnd+'.rd_left {background:url(\''+sturl+'bg_round.gif\') top left no-repeat;left:0;}'+$i.hnd+'.rd_right {background:url(\''+sturl+'bg_round.gif\') top right no-repeat;right:0;}'+$i.hnd+'#imagebox_close {position:absolute;right:7px;top:0;cursor:pointer;}'+$i.hnd+'#imagebox_status .prev {width:9px;height:23px;margin-right:12px;background:url(\''+sturl+'btn_list_prev_on.gif\') 0 6px no-repeat;cursor:pointer;}'+$i.hnd+'#imagebox_status .next {width:9px;height:23px;margin-left:7px;background:url(\''+sturl+'btn_list_next_on.gif\') 0 6px no-repeat;cursor:pointer;}'+$i.hnd+'#imagebox_status .p_d {background:url(\''+sturl+'btn_list_prev_d.gif\') 0 6px no-repeat;cursor:default;}'+$i.hnd+'#imagebox_status .n_d {background:url(\''+sturl+'btn_list_next_d.gif\') 0 6px no-repeat;cursor:default;}'+$i.hnd+'#imagebox_natural,#imagebox_area #imagebox_handle #imagebox_window {position:absolute;top:0;right:47px;display:none;cursor:default;cursor:pointer;}'+$i.hnd+'#imagebox_logo #imagebox_tutorial {position:absolute;top:0;right:47px;cursor:help; display:none;}'+$i.hnd+'#imagebox_tip {position:absolute;top:21px;right:22px;display:none;cursor:default;}'+$i.tmb+'#imagebox_logo {background:url(\''+sturl+'bg_vertical.gif\') top repeat-x;height:38px;padding:12px 7px 0 7px;margin:0;}'+$i.tmb+'#imagebox_logo img.logo {position:absolute;top:17px;left:15px;width:70px;height:18px;background:url(\''+sturl+'logo_plaync.gif\') top left no-repeat;}'+$i.tmb+'#imagebox_status {list-style-type:none;margin:0 auto;height:38px;padding:0;}'+$i.tmb+'#imagebox_status li {overflow:hidden;float:left;margin:0 5px 0 0;cursor:pointer;}'+$i.tmb+'#imagebox_status li.off {border:1px solid #808386;width:38px;height:28px;}'+$i.tmb+'#imagebox_status li.on { border:2px solid #029cdf;width:36px;height:26px;}'+$i.tmb+'#imagebox_status li.blank { border:1px solid #808386;background:url(\''+sturl+'noimage.gif\') top left no-repeat;width:38px;height:28px;cursor:default;}'+$i.dot+'#imagebox_logo {background:url(\''+sturl+'bg_vertical.gif\') top repeat-x;height:24px;padding:11px 7px 0 7px;margin:0;}'+$i.dot+'#imagebox_logo img.logo {position:absolute;top:11px;left:15px;width:54px;height:14px;background:url(\''+sturl+'logo_plaync_s.gif\') top left no-repeat;}'+$i.dot+'#imagebox_status {list-style-type:none;margin:0 auto;height:24px;padding:0;}'+$i.dot+'#imagebox_status li {overflow:hidden;float:left;margin:0 4px 0 0;cursor:pointer;}#imagebox_area #imagebox_handle.utils_dot #imagebox_status .prev,#imagebox_area #imagebox_handle.utils_dot #imagebox_status .next {background-position:0 0;}'+$i.dot+'#imagebox_status li.off {margin-top:2px;width:13px;height:13px;background:url(\''+sturl+'list_dot_off.gif\') top left no-repeat;}'+$i.dot+'#imagebox_status li.on {margin-top:2px;width:13px;height:13px;background:url(\''+sturl+'list_dot_on.gif\') top left no-repeat;}'+$i.dot+'#imagebox_status li.blank {margin-top:2px;width:13px;height:13px;background:url(\''+sturl+'list_dot_blank.gif\') top left no-repeat;cursor:default;}'+$i.rel+'{position:relative;background-color:#000;padding:0 7px;margin:0;overflow:hidden;z-index:1004;}'+$i.rel+'#short_tip {background:url(\''+sturl+'short_tip.png\') top left no-repeat;'+$i.bf+sturl+'short_tip.png\', sizingMethod=\'crop\');width:218px;height:36px;position:absolute;display:none;z-index:1010;}'+$i.rel+'.bg_left,#imagebox_area .imagebox_rel .bg_right {position:absolute;height:100%;width:7px;top:0;}'+$i.rel+'.bg_left {background: url(\''+sturl+'bg_horizontal.gif\') left repeat-y;left:0;}'+$i.rel+'.bg_right {border-right:1px solid #424242;background-color:#ffffff;right:0;}'+$i.rel+'#imagebox {position:relative;border:1px solid #85878a;background-color:#000000;display:block;overflow:hidden;}'+$i.rel+'#imagebox img {display:block;top:0;left:0;margin:auto;}'+$i.rel+'#imagebox_prev {cursor:pointer;position:absolute;top:45%;left:22px;width:29px;height:54px;background:url(\''+sturl+'btn_go_prev.png\') top left;'+$i.bf+sturl+'btn_go_prev.png\', sizingMethod=\'crop\');display:none;}'+$i.rel+'#imagebox_prev.on {background:url(\''+sturl+'btn_go_prev_on.png\') top left;'+$i.bf+sturl+'btn_go_prev_on.png\', sizingMethod=\'crop\');}'+$i.rel+'#imagebox_next {cursor:pointer;position:absolute;top:45%;right:22px;width:29px;height:54px;background:url(\''+sturl+'btn_go_next.png\') top left;'+$i.bf+sturl+'btn_go_next.png\', sizingMethod=\'crop\');display:none;}'+$i.rel+'#imagebox_next.on {background:url(\''+sturl+'btn_go_next_on.png\') top left;'+$i.bf+sturl+'btn_go_next_on.png\', sizingMethod=\'crop\');}'+$i.rel+'#imagebox_natural_sp {display:none;position:absolute;right:20px;bottom:20px;background:url(\''+sturl+'btn_natural.png\') top left no-repeat;'+$i.bf+sturl+'btn_natural.png\', sizingMethod=\'crop\');width:70px;height:62px;cursor:pointer;}'+$i.rel+'#imagebox_ghost_tog {position:absolute;right:20px;bottom:13px;}'+$i.rel+'#imagebox_ghost_box {position:absolute;right:20px;bottom:13px;width:140px;height:155px;overflow:hidden;display:none;}'+$i.rel+$i.gb+'{position:relative;}'+$i.rel+$i.gb+'#lowest_layer {position:absolute;border:1px solid #fff;width:138px;height:153px;}'+$i.rel+$i.gb+'#second_layer {position:absolute;top:1px;left:1px;background-color:#000;width:138px;height:153px;}'+$i.rel+$i.gb+'#third_layer {position:absolute;top:22px;left:8px;background:#000;width:114px;height:114px;z-index:1007;}'+$i.rel+$i.gb+'img.ghost_close {position:absolute;top:1px;right:1px;cursor:pointer;}'+$i.rel+$i.gb+'#imagebox_ghost_wrap {position:absolute;display:block;top:18px;right:8px;width:114px;height:114px;}'+$i.rel+$i.gb+'#imagebox_ghost {position:absolute;width:80px;height:60px;overflow:hidden;z-index:1008;border:2px solid #029cdf;}'+$i.rel+$i.gb+'#imagebox_ghost img {position:absolute;}#imagebox_area .imagebox_btm { position:relative;background:url(\''+sturl+'bg_round.gif\') bottom left no-repeat;padding:0 7px;height:7px;}#imagebox_area .imagebox_btm .rd_right{background:url(\''+sturl+'bg_round.gif\') bottom right no-repeat;position:absolute;bottom:0px;_bottom:-1px;right:0;width:7px;height:7px;}#imagebox_area .imagebox_btm .line {background:#fff url(\''+sturl+'bg_btm_line.gif\') bottom repeat-x;height:7px;overflow:hidden;}</style>';
var ImageBoxHtml='<div id="imagebox_area"><div id="imagebox_ready"></div><div id="imagebox_handle" class="utils_dot"><div class="rd_left"></div><div class="rd_right"></div><div id="imagebox_logo"><img src="'+sturl+'blank.gif" class="logo" alt="plaync" /><img src="'+sturl+'btn_natural.gif" id="imagebox_natural" alt="" onmouseover="IBUTLS.imgOver(this);" onmouseout="IBUTLS.imgOut(this);" /><img src="'+sturl+'btn_window.gif" id="imagebox_window" alt="" onmouseover="IBUTLS.imgOver(this);" onmouseout="IBUTLS.imgOut(this);" /><img id="imagebox_tutorial" src="'+sturl+'btn_tutorial.gif" alt="" onmouseover="IBUTLS.imgOver(this);" onmouseout="IBUTLS.imgOut(this);" /><div id="imagebox_tip"><img src="'+sturl+'tip.gif" alt="" /></div><ul id="imagebox_status"></ul></div><img src="'+sturl+'btn_close_viewer.gif" onmouseover="IBUTLS.imgOver(this);" onmouseout="IBUTLS.imgOut(this);" onmouseout="" id="imagebox_close" onclick="IBUTLS.close();" /></div><div class="imagebox_rel" id="imagebox_rel"><div class="bg_left"></div><div class="bg_right"></div><div id="imagebox"></div><div id="imagebox_prev" onmouseover="this.addClassName(\'on\');" onmouseout="this.removeClassName(\'on\');"></div><div id="imagebox_next" onmouseover="this.addClassName(\'on\');" onmouseout="this.removeClassName(\'on\');"></div><div id="short_tip"></div><div id="imagebox_natural_sp"></div><div id="imagebox_ghost_tog"><img src="'+sturl+'btn_ghtoggle.gif" alt="" /></div><div id="imagebox_ghost_box"><div class="preview_bg"><div id="lowest_layer"></div><div id="second_layer"></div><div id="third_layer"></div><div id="imagebox_ghost_wrap"></div><img src="'+sturl+'btn_close_preview.gif" id="imagebox_ghost_close" class="ghost_close" alt="" /></div></div></div><div class="imagebox_btm"><div class="rd_right"></div><div class="line"><div class="btm_blank"></div></div></div></div>';
document.write(IBCss);
document.write(ImageBoxHtml);
try {if (navigator.userAgent.toUpperCase().indexOf('MSIE')>=0) doument.execCommand("BackgroundImageCache", false, true);} catch(ignored) {}
Object.extend(Event, {
	wheel:function (event){
		var delta = 0;
		if (!event) event = window.event;
		if (event.wheelDelta) {
		    delta = event.wheelDelta/120;
		    if (window.opera) delta = -delta;
		} else if (event.detail) delta = -event.detail/3;
		return Math.round(delta);
	}
});
var IBUTLS={
	close:function() {
		$('imagebox_area').setStyle({top:'-10000px'});
		$('imagebox').update('');
		$A($('imagebox_prev','imagebox_next','imagebox_tip','imagebox_ghost_box','imagebox_prev','imagebox_next')).each(Element.hide);
		if ($('imagebox_modal')) $('imagebox_modal').hide();
		Event.stopObserving(document,'keyup');
		$('imagebox_status','imagebox','imagebox_prev','imagebox_next','imagebox_natural','imagebox_window').each(function(o) {Event.stopObserving(o);});
		IBUTLS.viewAvailable=false;
	},
	mouseWheelControl:function(e) {
		Event.stop(e);
		var diff=IBUTLS.crtImg.getHeight()-$('imagebox').getHeight();
		var top=parseInt(IBUTLS.crtImg.getStyle('top'));
		var move=parseInt(top+(Event.wheel(e)*($('imagebox').getHeight()/2)));
		move=(move<=0&&move>=-diff) ? move:(move>0) ? 0:(move<=-diff) ? -diff:false;
		if (move===false) return;
		IBUTLS.crtImg.setStyle({top: move + 'px'});
		IBUTLS.imageToGhost([0,move]);
	},
	ghostToggle:function() {
		var ghost=$('imagebox_ghost_box');
		var changedStyle,boxtog;
		if (ghost.visible()) changedStyle={width:'26px',height:'26px'};
		else changedStyle={width:'140px',height:'155px'};
		IBUTLS.effects[0]=new Effect.Morph(ghost,{duration:0.4,style:changedStyle,beforeStart:function() {
			IBUTLS.ghost.hidden=false;
			$('imagebox_ghost_tog').hide();
			$('imagebox_ghost_box').setStyle({display:'block'});
		},afterFinish:function() {
			if (ghost.getWidth()<=26) {
				$('imagebox_ghost_box').hide();
				$('imagebox_ghost_tog').setStyle({display:'block'});
				IBUTLS.ghost.hidden=true;
			}
		}});		
	},	
	imageToGhost:function(delta) {
		var ghostBoxSetup=IBUTLS.ghost.setup;
		var ghostSetup = [Math.ceil(-(delta[0]/IBUTLS.ghost.mag)+ghostBoxSetup.left),Math.ceil(-(delta[1]/IBUTLS.ghost.mag)+ghostBoxSetup.top)];
		$('imagebox_ghost').setStyle({top:ghostSetup[1]+'px',left:ghostSetup[0]+'px'});
		IBUTLS.ghostInside(ghostSetup);
	},
	ghostInside:function(delta) {
		$('imagebox_ghost').select('img')[0].setStyle({top:(-(delta[1]-IBUTLS.ghost.setup.top))+'px',left:(-(delta[0]-IBUTLS.ghost.setup.left))+'px'});
	},
	setMSz:function(size) {return (size<1) ? 1 : parseInt(size);},
	wdSz:function() {return [document.viewport.getWidth(),document.viewport.getHeight()];},
	wdMx:function() {return [document.viewport.getWidth()-200,document.viewport.getHeight()-120];},
	mSz:[490,315],frSz:[16,44],crtSz:[0,0],crtImg:0,
	toggleTip:function() {
		if ($('imagebox_tip').getStyle('display')!='none') $('imagebox_tip').hide();
		else $('imagebox_tip').setStyle({display:'block'});
	},
	imgOver:function(o) {o.src=o.src.replace('.gif','_on.gif');},
	imgOut:function(o) {o.src=o.src.replace('_on.gif','.gif');},	
	isIE6:(navigator.userAgent.indexOf('MSIE 6')>=0),
	isIE7:(navigator.userAgent.indexOf('MSIE 7')>=0),
	ghost:{mag:0,size:[124,124],setup:{},hidden:false},
	window:0,effects:[],viewAvailable:false,magFlag:false,isDrag:false
};
var IMAGEBOX=Class.create({
	initialize:function(field,option) {
		if (!$('imagebox_area')) {
			
		}
		popView=function() {};
		$('imagebox_ghost_close').observe('click',IBUTLS.ghostToggle);
		$('imagebox_tutorial','imagebox_tip').each(function(o){Event.observe(o,'click',IBUTLS.toggleTip);});
		$('lowest_layer').setOpacity(0.2);
		$('second_layer').setOpacity(0.8);
		$('third_layer').setOpacity(0.6);
		var _field=(Object.isString(field)) ? $(field) : field;
		if (!_field) return;
		var _option={
			selector:'img',
			viewControl:true,
			defaultView:'natural',
			maxSize:'win',
			displayText:false,
			thumb:false,
			modal:false,
			modules:[],
			topPos:35
		};
		var _deliv=this;
		var _isInData=Object.isElement(_field);		
		this.field=_field;
		this.current=0;
		this.option=Object.extend(_option,option||{});
		this.originMax=(option&&Object.isArray(option.maxSize)) ? option.maxSize : 'win';
		this.option.selector=(navigator.userAgent.toLowerCase().indexOf('msie 8')!=-1) ? 'img' : this.option.selector;
		if (this.option.modal&&!$('imagebox_modal')) {
			Insertion.After($('imagebox_area'),'<div id="imagebox_modal"></div>');
			var modal=$('imagebox_modal');
			var modalHeight=(IBUTLS.wdSz()[1] > $$('body')[0].getHeight()) ? IBUTLS.wdSz()[1]:$$('body')[0].getHeight();
			modal.setStyle({
				backgroundColor:this.option.modal[0],
				opacity:this.option.modal[1],
				top:0,left:0,position:'absolute',display:'none',height:modalHeight+'px'
			});
			if (IBUTLS.isIE6) modal.setStyle({width:IBUTLS.wdSz()[0]+'px'});
			Event.observe(modal,'click',IBUTLS.close);
		}
		if (IBUTLS.window===0) IBUTLS.window=new Draggable('imagebox_area',{handle:'imagebox_handle',starteffect:false,endeffect:false});		
		this.datas=(_isInData) ? _field.getElementsBySelector(this.option.selector):_field.getElementsByTagName(this.option.selector);
		//if (this.datas.length==0) return;
		this.plural=(this.datas.length>1) ? this.datas.length : 0;
		if (this.option.defaultView==='natural') this.option.maxSize='win';
		if (IBUTLS.isIE6&&!IBUTLS.isIE7) $('imagebox_handle').select('div.rd_left')[0].setStyle({left:'-7px'});
		if (this.option.viewControl===false) $A($('imagebox_natural','imagebox_window')).each(Element.hide);
		if (_isInData) Event.observe(this.field,'click',function(e) {_deliv.open(e);});
		Event.observe(document,'mousemove',function(e) {_deliv.prevnext(e);});
		Event.observe($('imagebox_natural_sp'),'click',function(e) {_deliv.changeView(e);});
		Event.observe($('imagebox_area'),'mousedown',function(e) {
			if (!Event.element(e).descendantOf($('imagebox'))) IBUTLS.isDrag=true;
		});
		Event.observe($('imagebox_area'),'mouseup',function(e) {
			$('imagebox_ready').update('refresh');
			if (Event.element(e).descendantOf($('imagebox'))&&!IBUTLS.isDrag) IBUTLS.close();
			else IBUTLS.isDrag=false;
		});
	},
	prevnext:function(e) {
		var element=Event.element(e);
		var point=[Event.pointerX(e),Event.pointerY(e)];
		var area=[];
		var status;
		if (Object.isElement(element)) {
			if (element.descendantOf('imagebox_rel')&&this.plural!=0) {
				var relPos=$('imagebox_area').positionedOffset();
				area[0]=point[0]-relPos[0];
				area[1]=point[1]-relPos[1];
				if (area[1]>=IBUTLS.crtSz[1]/2&&area[1]<=(IBUTLS.crtSz[1]/2)+120) {
					if (area[0]>=0&&area[0]<=60||area[0]>=IBUTLS.crtSz[0]-60&&area[0]<=IBUTLS.crtSz[0]) {
						if (this.current===0) $('imagebox_prev').hide();
						else $('imagebox_prev').setStyle({display: 'block'});
						if (this.current===this.datas.length-1) $('imagebox_next').hide();
						else $('imagebox_next').setStyle({display:'block'});
						status=true;
					}
				}
				var ghostStatus=(this.option.defaultView=='natural'&&area[0]>IBUTLS.crtSz[0]-20&&area[0]<IBUTLS.crtSz[0]+50&&area[1]>IBUTLS.crtSz[1]-20&&area[1]<IBUTLS.crtSz[1]+50);
				if (IBUTLS.ghost.hidden&&ghostStatus) IBUTLS.ghostToggle();
				else  $('imagebox_ghost_tog').hide();				
				if (IBUTLS.magFlag) $('imagebox_natural_sp').setStyle({display:'block'});
				if (!status) $A($('imagebox_prev','imagebox_next')).each(Element.hide);
			}
			else $A($('imagebox_prev','imagebox_next','imagebox_natural_sp','imagebox_ghost_tog')).each(Element.hide);
		}
	},
	keyControl:function(e) {
		var inputKey=e.keyCode;
		var target;
		if (inputKey===27) IBUTLS.close();
		if (inputKey===32||inputKey===37||inputKey==39) {
			if (inputKey===37&&this.current!==0) target=this.datas[this.current-1];
			else if ((inputKey===32||inputKey===39)&&this.current!==this.datas.length-1) target=this.datas[this.current+1];
			if (target) this.open(target);
		}
	},
	changeView:function(e) {
		var element=Event.element(e);
		var currentMode=element.getAttribute('id').split('_')[1];
		if (element.visible()) {
			this.option.defaultView=currentMode;
			this.option.maxSize=(currentMode==='natural') ? 'win' : this.originMax;
			element.hide();
			if (currentMode==='natural') $('imagebox_window').setStyle({display:''});
			else $('imagebox_natural').setStyle({display:''});
			this.open(this.datas[this.current]);
		}
	},
	navigation:function(e) {
		var element=Event.element(e);
		var _deliv=this;
		if (element.tagName.toUpperCase()==='DIV') goNeighbor(element);
		else if (element.tagName.toUpperCase()==='IMG'||element.tagName.toUpperCase()==='LI') {
			element.ancestors().each(function(o) {
				if (o.getAttribute('id') == 'imagebox_status') {
					if (element.parentNode.className=='off') goDirect(parseInt(element.parentNode.getAttribute('rel')));
					else if ((element.parentNode.hasClassName('prev')||element.hasClassName('prev'))&&_deliv.current!==0)
						_deliv.open(_deliv.datas[_deliv.current-1]);
					else if ((element.parentNode.hasClassName('next')||element.hasClassName('next'))&&_deliv.current!==_deliv.datas.length-1)
						_deliv.open(_deliv.datas[_deliv.current+1]);
					else if (element.className=='off') goDirect(parseInt(element.getAttribute('rel')));
				}
			});
		}
		function goDirect(o) {if (Object.isNumber(parseInt(o))) _deliv.open(_deliv.datas[parseInt(o)]);}
		function goNeighbor(obj) {
			var isPrev = (obj.getAttribute('id') === 'imagebox_prev') ? true : false;
			if (isPrev && _deliv.current !== 0)	_deliv.open(_deliv.datas[_deliv.current - 1]);
			else if (!isPrev&&_deliv.current!==_deliv.datas.length-1)	_deliv.open(_deliv.datas[_deliv.current + 1]);
		}
	},
	open:function(e) {
		var element=(Object.isElement(e)) ? e : Event.element(e);
		var _deliv=this;
		if ((!(Object.isElement(e))&&element.parentNode.tagName.toUpperCase()=='A')||element.tagName!=='IMG'||!element.match(_deliv.option.selector)) return;
		$('imagebox').update('').hide();
		if (!IBUTLS.viewAvailable) $('imagebox_status').update('');
		IBUTLS.magFlag=false;
		IBUTLS.isDrag=false;
		IBUTLS.effects.each(function(o){o.cancel();});
		$('imagebox_tutorial').setOpacity(1.0);
		var cpImg=Builder.node('img',{src:element.getAttribute('src')});
		var currentopts=this.option;
		var maxSize=(this.option.maxSize==='win') ? IBUTLS.wdMx() : this.option.maxSize;
		$('imagebox_ready').update(cpImg);
		Event.observe(cpImg,'load',function() {
			Event.stopObserving(cpImg,'load');
			$A($('imagebox_prev','imagebox_next','imagebox_ghost_box','imagebox_natural_sp')).each(Element.hide);
			if (_deliv.option.viewControl) {
				$('imagebox_natural','imagebox_window').each(function(o) {
					if (o.getAttribute('id').split('_')[1]==_deliv.option.defaultView) o.hide();
					else o.setStyle({display:'block'});
				});
			}
			if ($('imagebox_modal')&&!$('imagebox_modal').visible()) $('imagebox_modal').setStyle({display:'block'});
			if (!_deliv.option.thumb||_deliv.datas.length===1) {
				IBUTLS.frSz=[16,44];
				$('imagebox_handle').removeClassName('utils_thumb');
				$('imagebox_handle').addClassName('utils_dot');				
			}
			else {
				IBUTLS.frSz=[16,59];
				$('imagebox_handle').removeClassName('utils_dot');
				$('imagebox_handle').addClassName('utils_thumb');				
			}
			var mag,magFlag;
			var opts={};
			opts.oSz=cpImg.getDimensions();
			opts.dSz={};
			opts.wSz={};
			opts.wPs=[];
			if (currentopts.defaultView === 'window') {
				magFlag=opts.oSz.width>maxSize[0]||opts.oSz.height>maxSize[1];
				mag=(opts.oSz.width/maxSize[0] > opts.oSz.height/maxSize[1]) ? opts.oSz.width/maxSize[0] : opts.oSz.height/maxSize[1];
				opts.dSz.width=magFlag ? parseInt(opts.oSz.width/mag) : opts.oSz.width;
				opts.dSz.height=magFlag ? parseInt(opts.oSz.height/mag) : opts.oSz.height;
				cpImg.setStyle({width: opts.dSz.width + 'px',height: opts.dSz.height + 'px'});
				IBUTLS.magFlag=(magFlag) ? true : false;
			}
			else {
				opts.dSz.width=parseInt((opts.oSz.width>maxSize[0]) ? maxSize[0] : opts.oSz.width);
				opts.dSz.height=parseInt((opts.oSz.height>maxSize[1]) ? maxSize[1] : opts.oSz.height);
			}
			opts.dSz.width=(opts.dSz.width<IBUTLS.mSz[0]) ? IBUTLS.mSz[0] : opts.dSz.width;
			if (opts.dSz.height < IBUTLS.mSz[1]) {
				opts.dSz.height = IBUTLS.mSz[1];
				var imgMrg=((IBUTLS.mSz[1]/2)-(opts.oSz.height/2)<0) ? 0:parseInt((IBUTLS.mSz[1]/2)-(opts.oSz.height/2));
				cpImg.setStyle({marginTop:imgMrg+'px'});
			}
			if (currentopts.defaultView === 'natural') {
				if (opts.oSz.width>maxSize[0]||opts.oSz.height>maxSize[1]) {
					IBUTLS.ghost.mag = (opts.oSz.width / IBUTLS.ghost.size[0] > opts.oSz.height / IBUTLS.ghost.size[1]) ? opts.oSz.width / IBUTLS.ghost.size[0] : opts.oSz.height / IBUTLS.ghost.size[1];
					if ($('imagebox_ghost')) $('imagebox_ghost').remove();
					var GSz={width:IBUTLS.setMSz((opts.oSz.width/IBUTLS.ghost.mag)),height:IBUTLS.setMSz(opts.oSz.height/IBUTLS.ghost.mag)};
					var GHt=[opts.dSz.width>opts.oSz.width ? opts.oSz.width : opts.dSz.width,opts.dSz.height>opts.oSz.height ? opts.oSz.height : opts.dSz.height];
					var GHSz={width:IBUTLS.setMSz(GHt[0]/IBUTLS.ghost.mag-4),height:IBUTLS.setMSz(GHt[1]/IBUTLS.ghost.mag-4)};
					var GH=new Element('div',{id:'imagebox_ghost',className:'imagebox_ghost'});
					var GBset={top:parseInt((IBUTLS.ghost.size[1]/2)-(GSz.height/2)+22),left:parseInt((IBUTLS.ghost.size[0]/2)-(GSz.width/2)+8)};
					GBset.image='<img src="'+cpImg.getAttribute('src')+'" style="left:0;width:'+GSz.width+'px;height:'+GSz.height+';" />';
					IBUTLS.ghost.setup=GBset;
					Insertion.After($('imagebox_ghost_wrap'),GH);
					$('imagebox_ghost_wrap').update(GBset.image).setStyle({width:GSz.width+'px',top:GBset.top+'px',left:GBset.left+'px'});
					$('imagebox_ghost').update(GBset.image).setStyle({width:GHSz.width+'px',height:GHSz.height+'px',top:GBset.top+'px',left:GBset.left+'px'});
					$('imagebox_ghost').insert('<img src="'+sturl+'blank.gif" style="width:'+GSz.width+'px;height:'+GSz.height+'px;z-index:1010;" />');
					$('third_layer').setStyle({width:GSz.width+'px',height:GSz.height+'px',top:GBset.top+'px',left:GBset.left+'px'});
					new Draggable(GH,{starteffect:false,endeffect:false,zindex:1009,
					onDrag:function(obj) {
						var delta=obj.currentDelta();
						var xmove=opts.oSz.width-opts.dSz.width;
						var ymove=opts.oSz.height-opts.dSz.height;
						IBUTLS.ghostInside(delta);
						var setup={top:Math.ceil(-(delta[1]*IBUTLS.ghost.mag)+(GBset.top*IBUTLS.ghost.mag)),left:Math.ceil(-(delta[0]*IBUTLS.ghost.mag)+(GBset.left*IBUTLS.ghost.mag))};
						setup.top=(setup.top<-ymove)?-ymove:setup.top;
						setup.left=(setup.left<-xmove)?-xmove:setup.left;
						setup.top=(setup.top>0)?0:setup.top;
						setup.left=(setup.left>0)?0:setup.left;
						cpImg.setStyle({top:setup.top+'px',left:setup.left+'px'});
					},
					snap:function(x, y, draggable) {
						var xmove=GSz.width-(GHSz.width+4);
						var ymove=GSz.height-(GHSz.height+4);
			            return [(xmove<0)?GBset.left:(x>=GBset.left&&x<=GBset.left+xmove)?x:(x<GBset.left)?GBset.left:GBset.left+xmove,(ymove<0)?GBset.top:(y>=GBset.top&&y<=ymove+GBset.top)?y:(y<GBset.top)?GBset.top:ymove+GBset.top];
			        }});
					if (!IBUTLS.ghost.hidden) $('imagebox_ghost_box').setStyle({display:'block'});
					new Draggable(cpImg,{zIndex:999,starteffect:false,endeffect:false,zindex:0,
					onStart:function() {IBUTLS.isDrag=true;},
					onEnd:function() {setTimeout('IBUTLS.isDrag=false;',100);},
					onDrag:function(obj) {
						var delta=obj.currentDelta();
						IBUTLS.imageToGhost(delta);
					},
					snap:function(x, y, draggable) {
						var xmove=opts.oSz.width-maxSize[0];
						var ymove=opts.oSz.height-maxSize[1];
			            return [(xmove<0)?0:(x<=0&&x>-xmove)?x:(x>0)?0:-xmove,(ymove<0)?0:(y<=0&&y>-ymove)?y:(y>=0)?0:-ymove];
			        }});
					Event.observe($('imagebox'),"mousewheel",IBUTLS.mouseWheelControl);
					Event.observe($('imagebox'),"DOMMouseScroll",IBUTLS.mouseWheelControl);
				}
			}
			for (var i=0;i<_deliv.plural;i++) {if (element===_deliv.datas[i]) {_deliv.current=i;break;}}
			IBUTLS.crtSz=[opts.dSz.width,opts.dSz.height];
			_deliv.draw(cpImg,opts);
		});
		IBUTLS.crtImg=cpImg;
		if (!IBUTLS.viewAvailable) {
			Event.observe(document, 'keyup', function(e){_deliv.keyControl(e);});
			Event.observe($('imagebox_status'),'click',function(e) {_deliv.navigation(e);});
			$('imagebox_prev','imagebox_next').each(function(o) {
				Event.observe(o,'click',function(e) {_deliv.navigation(e);});
			});
			$('imagebox_natural','imagebox_window').each(function(o) {
				if (o.getAttribute('id').split('_')[1]==_deliv.option.defaultView) o.hide();
				Event.observe(o,'click',function(e) {_deliv.changeView(e);});
			});
		}
	},
	draw:function(image,opts) {
		var _deliv=this;
		if (_deliv.plural) {
			var statusList=[];
			var status,content,start,end,ev;
			start=0,end=_deliv.plural;
			if (_deliv.plural>5) {
				start=Math.floor(_deliv.current/5)*5;
				end=start+5;
			}
			for (i=start;i<end+2;i++) {
				ev='';
				if (i===_deliv.current+1) status='on';
				else if (i===start) {
					ev=(_deliv.current==0) ? '':'';
					status=(_deliv.current==0) ? 'prev p_d' : 'prev';
				} else if (i===end+1) {
					ev=(_deliv.current==_deliv.plural-1) ? '':'';
					status=(_deliv.current==_deliv.plural-1) ? 'next n_d' : 'next';
				} else status=(_deliv.plural<=i-1) ? 'blank':'off';
				if (_deliv.option.thumb) {
					if (status=='off'||status=='on') content='<img style="width:38px;height:28px;" src="'+_deliv.datas[i-1].getAttribute('src')+'" />';
					else content='';
					statusList.push('<li'+ ev +' class="'+status+'" rel="'+(i-1)+'">'+content+'</li>');
				}
				else statusList.push('<li'+ ev +' class="'+status+'" rel="'+(i-1)+'"></li>');
			}
			status=(_deliv.option.thumb) ? ((statusList.length-2)*45)+42:((statusList.length-2)*17)+42;
			$('imagebox_status').setStyle({width:status+'px'}).update(statusList.join(''));
		}
		if (IBUTLS.viewAvailable===false) $('short_tip').setStyle({left:((opts.dSz.width/2)-108)+'px',top:((opts.dSz.height/2)-22)+'px',display:'block'});
		opts.wSz.width=opts.dSz.width+IBUTLS.frSz[0];
		opts.wSz.height=opts.dSz.height+IBUTLS.frSz[1];
		opts.wPs[0]=parseInt((IBUTLS.wdSz()[0]/2)-(opts.wSz.width/2));
		opts.wPs[1]=parseInt($('imagebox_area').getStyle('top'))>0 ? parseInt($('imagebox_area').getStyle('top')) : document.viewport.getScrollOffsets().top + _deliv.option.topPos;
		$('imagebox').setStyle({width:opts.dSz.width+'px',height:opts.dSz.height+'px'});
		$('imagebox_area').setStyle({top:((opts.wPs[1]<0) ?0:opts.wPs[1])+'px'});
		IBUTLS.effects[0]=new Effect.Morph($('imagebox_rel'),{
			duration:0.2,
			style: {width: (opts.dSz.width+2)+'px',height:(opts.dSz.height+2)+'px'}
		});
		IBUTLS.effects[1]=new Effect.Morph($('imagebox_area'), {
			style: {width:opts.wSz.width+'px',height:opts.wSz.height+'px',left:((opts.wPs[0]<0) ? 0 : opts.wPs[0]) + 'px'},
			duration: 0.2,
			afterFinish:function() {
				if (parseInt($('imagebox_area').getStyle('top'))>=0) {
					$('imagebox').update(image);
					$('imagebox').setStyle({display:'block'});
					if (IBUTLS.viewAvailable===false) {
						setTimeout(function() {$('short_tip').fade({duration:0.5});},500);
						IBUTLS.viewAvailable=true;
					}
				}
			}
		});
	}
});