/*COIN API-Copyright (c)2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G
このプログラムの無断転載と無断利用、複製、流用、改ざん、改変、転載、リバースエンジニアリング、並びにそれに伴う本サイトプログラムの無断での使用を禁じます。
 */
$j = jQuery.noConflict();

(function(){
	coinDI=function(url){return this instanceof coinDI ? this.initDI(url) : new initDI(url);};
	coinDI.prototype={
	copyright:"©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G",
	url:location.href,
	referer:"",
	o:null,
	ct:null,
	tp:null,
	srvPath:"http://www.infoplayer.net",
	playerPath:"infoplayer/",
	baseDir:location.pathname.match(/\/.*?\//)[0],
	imgDir:null,
	medDir:null,
	cssDir:null,
	itmbDir:null,
	tmbDir:null,
	cntDir:null,
	ext:["jpg","jpeg","swf","mp3","flv","swf","pdf"],
	filter:{type:null,selected:null,cell:{},no:{},length:0,types:{},chip:[0,-2,0,2,4,3,1,6,5,-1]},
	zoom:[0.25,0.5,0.75,1,1.25,1.5,2,3,4],
	zoomct:3,
	free:false,
	temp:{},
	wizMov:{},
	wizEnq:{},
	elements:{},
	timerID:null,
	interval:null,
	urlInt:null,
	scale:3,
	cellCount:0,
	flash:($j.browser.msie)?window:document,
	id:0,
	titleY:0,
	moving:false,
	entry:false,
	wizNew:{},
	nowTop:{},
	cells:{},
	cellNo:{},
	enquetes:{},
	targetSW:true,
	historySW:false,
	showLast:false,
	titleScrolling:null,
	partsTag:'<object .*?><param name="movie" value=\"http:\/\/www.youtube.com\/.*?<embed src="http\:\/\/www.youtube.com\/.*?><\/embed><\/object>?',
	initDI:function(tmp){
		$j('#ip_caption').hide();
		$o=this;
		var self=this;
		this.imgDir=this.baseDir+"img/";
		this.medDir=this.baseDir+"media/";
		this.cssDir=this.baseDir+"css/";
		$o.IE6=$o.isIE6();
		$o._=$j.fn.o.language;
		var d=this.imgDir;
		this.type={
			all: false,
			swidth: 24,
			del: d + "del.gif",
			"-2":{tip:$o._.newMark,icon:d+"new.gif",s:d+"newi.gif"},
			"-1":{tip:$o._.enquete,icon:d+"enq.gif",s:d+"enqi.gif"},
			"0":{tip:$o._.information,icon:d+"info.gif",s:d+"infoi.gif"},
			"1":{tip:$o._.url,icon:d+"url.gif",s:d+"urli.gif"},
			"2":{tip:$o._.picture,icon:d+"pic.gif",s:d+"pici.gif"},
			"3":{tip:$o._.sound,icon:d+"sound.gif",s:d+"sndi.gif"},
			"4":{tip:$o._.movie,icon:d+"movie.gif",s:d+"movi.gif"},
			"5":{tip:$o._.flash,icon:d+"file.gif",s:d+"filei.gif"},
			"6":{tip:$o._.pdf,icon:d+"doc.gif",s:d+"doci.gif"},
			"7":{tip:$o._.html,icon:d+"file.gif",s:d+"filei.gif"}
		};
		this.jQA=$j('#oArea');
		if (tmp) this.jQA.oLoadTemplate(tmp);

		this.jQme={};
		this.jQDg={};
		this.jQP=$j("#oPlay_Panel");
		this.jQPg=$j("#oPlay_progress");

		this.jQIP=$j("#oIF_panel",this.jQA);
		this.jQIF=$j("#oIF_frame",this.jQIP);
		this.jQIV=$j("#oIF_view",this.jQIF);
		this.jQMsg=$j("#oMsg_panel",this.jQIP);
		this.jQEnq=$j("#oEnq_panel",this.jQIP);
		this.jQIm=$j("#oIW_modal",this.jQIP);

		this.jQTP=$j("#oTitle_infoPanel",this.JQA);
		this.jQTF=$j(".oTitleFrame",this.jQTP);
		this.jQTV=$j(".oTitleInfo",this.jQTF);
		this.jQLd=$j("#oNowLoading");

		this.jQRF=$j("#oRoot_frame");
		this.jQRV=$j("#oRoot_view",this.jQRF);
		this.jQSC=$j("#thumbBody");
		this.jQSR=$j("#oRound_panel");

		if (typeof(this.history)=="undefined") this.history={count:1};
		if (typeof(this.root)=="undefined") this.root={no:0};
		if (typeof(this.cache)=="undefined") this.cache={};
		this.jQIF=$j("#oIF_frame").bind('wheel',function(event,delta){
		var jQs= $j("#oIF_slider");
		$o.scrollTo(0,{slider:jQs,frameDiv:$o.jQIF,viewDiv:$o.jQIV,vector:delta,maxValue:100});
			if (event.preventDefault) {
					event.preventDefault();
			}
			event.returnValue = false;
		});
		this.nowTop.topCoinId=(typeof($j().o.opt)!="undefined")?Number($j().o.opt.topCoinId):null;
		$o.jQTF.bind('wheel',function(event,delta){
		$o.titleScroll(-delta*16);
			if (event.preventDefault) {
					event.preventDefault();
			}
			event.returnValue = false;
		});
		$j('#oTool_btnGrid').click(function(){self.gridOnOff("off");});
		$j('#oTool_btnGridOn').click(function(){self.gridOnOff("on");});
		$j('#oBtnBack,#oIf_btnBack').click(function(){self.backCoin();});
		$j('#oBtnBack2').click(function(){self.backCoin();}).hover(function(){
			$j(this).css({backgroundImage:"url("+$o.cssDir+"btnback1.gif)"});
		},function(){
			$j(this).css({backgroundImage:"url("+$o.cssDir+"btnback0.gif)"});
		});
		$j("#oDisp_btnHistory").click(function(){$o.onHistoryClick($j(this));});
		$j("#oBtnTarget").click(function(){$o.onTargetClick($j(this));});
		$j('#oFilter_btnReset').click(function(){self.onFilterClick();});
		$j("#oIF_btnReload").click(function(){$o.showCell();});
		$j("#oTitle_btnUp").mousedown(function(){
			$o.titleScroll(-16,function(){$j("#oTitle_btnUp").mousedown();});
		}).mouseup(function(){
			$o.titleScroll();
		});
		$j("#oTitle_btnDown").mousedown(function(){
			$o.titleScroll(16,function(){$j("#oTitle_btnDown").mousedown();});
		}).mouseup(function(){
			$o.titleScroll();
		});
		$j("#oPrt_btnOpen").click(function(){
			if (!$o.checkSelect()){
				window.open($o.baseDir+"coinprint.html?"+$o.coinUrlHash(),"CoinPrint","width=800,menubar=no,directories=no,location=no,toolbar=no,resizable=yes,scrollbars=yes");
			}
		});
		if ($j.isFunction($j().slider)){
			$j("#oPlay_sliderVol").slider({
				min:0,max:100,value:30,orientation:"vertical",
				change:function(e, ui){
					$o.player.masterVol(ui.value);
				}
			});
			if (!$j("#oPlay_progress").hasClass("ui-slider")){
				$j("#oPlay_progress").slider({
				min:0,max:100,value:0,orientation:"vertical",
				start:function(e,ui){
					clearInterval($o.interval);
					var st=$o.player.status();
					$o.playing=st.playing;
					$o.player.pause();
				},
				stop:function(e, ui){
					var st=$o.player.status();
					var p=Math.round(st.duration*(ui.value/100)),ld=Math.floor(st.duration*(st.loadByte/st.totalByte));
					if ((p < ld)&&(st.trickPlay)){
						$o.player.seek(p,$o.playing);
						$o.playPanel.showStatus($o.player.status());
					}else if (p == ld) {
						$o.playPanel.stop();
					}else{
						$o.player.play();
					}
					$o.interval=setInterval('$o.playProgress()',1000);
					delete $o.playing;
				}
				});
				$j("#oPlay_btnPlay").click(function(){
					var st=$o.flash.externalplay.mediaPlay();
					if (st==null) return;
					$j("img",this).attr("src", (!st.playing)?$o.cssDir+"play.gif":$o.cssDir+"pause.gif");
				});
				$j("#oPlay_btnRew").click(function (){$o.flash.externalplay.mediaRew();});
			}
		}
		$j("#o_close").click(function(){$o.onClose();});
		$j('#oHelp_btnOpen').show();
		$j("#oDoc_btnOpen").click(function(){$j().o.showPDF($o.o,"on");});
		$j("#oBmark_btnSave").click($o.onMark).hover(function(){if ($o.isIE6) $j("span",this).addClass("markHover");},function(){if ($o.isIE6) $j("span",this).removeClass("markHover");});
		$j("#oBmark_btnOpen").click($o.onWarp).hover(function(){if ($o.isIE6) $j("span",this).addClass("warpHover");},function(){if ($o.isIE6) $j("span",this).removeClass("warpHover");});
		if (typeof($j().slider)=="function"){
			$j("#oRoot_slider").slider({
				min:0,max:100,value:0,orientation:"horizontal",
				slide:function(e, ui){
				$o.scrollTo(ui,{slider:$j(this),frameDiv:$o.jQRF,viewDiv:$o.jQRV,nextWidth:($j(this).width()>>1)});
				}
			});
			$j("#oIF_slider").slider({
				min:0,max:100,value:100,orientation:"vertical",
				slide:function(e, ui){
				$o.scrollTo(ui,{slider:$j(this),frameDiv:$o.jQIF,viewDiv:$o.jQIV});
				}
			}).end().hide();
		}
	},

	player:{
		play:function(){
			if ($o.flash.externalplay) return $o.flash.externalplay.mediaPlay();
			return null;
		},
		masterVol:function(v){
			if ($o.flash.externalplay) return $o.flash.externalplay.masterVol(v);
			return null;
		},
		status:function(){
			if ($o.flash.externalplay) return $o.flash.externalplay.playStatus();
			return null;
		},
		pause:function(){
			if ($o.flash.externalplay) return $o.flash.externalplay.mediaPause();
			return null;
		},
		seek:function(p,st){
			if ($o.flash.externalplay) return $o.flash.externalplay.mediaSeek(p,st);
			return null;
		}
	},
	//  mediaPlay:function(md){
	//	var st={playing:false};
	//	if (md=="stop") $o.flash.externalplay.mediaStop(); else st=$o.flash.externalplay.mediaPlay();
	//	$j("#oPlay_btnPlay img").attr("src", (!st.playing)?$o.cssDir+"play.gif":$o.cssDir+"pause.gif");
	//  },
	onMark:function(){
		$o.cookieWrite("W:"+$o.tp.coinCd,$o.coinUrlHash());
		$j().oDialog("",$o._.diag_onMark,$o._.ok);
	},
	onWarp:function(){
		var r=$o.cookieRead("W:"+$o.tp.coinCd);
		if (r!="") $o.loadCoinFromBookmark($j().oURLParam(r));
	},
	onClose:function(){
		$j('#oHelp_btnOpen').hide();
		$j('#oDocViewer').hide().empty();
		$o.playPanel.close();
		var $jO = $j().o.opt,cn=($o.cells[$jO.cellCode])?$o.cells[$jO.cellCode].coinCellId:0,o=$o.o,ct=o.contents,
			isHide=($jO.trigger=="hide"),w=480,h=360,f;
		if (isHide||$jO.trigger=="on"){
			if (ct.contentType==2){
				w=ct.width;
				h=ct.height;
				f =(o.abone)?($o.imgDir+"deleted.gif"):($o.cntDir+o.contents.filename);
			}else{
				f=$o.imgDir+((ct.contentType==3)?"soundl.gif":"moviel.gif");
			}
			var pt=$jO.parent,r=$j().o.fitRect({srcW:pt.width(), srcH:pt.height(), width:w, height:h});
			pt.show().find("img").attr({id:o.coinCd,src:f,width:r.width,height:r.height}).css({marginLeft:r.x,marginTop:r.y});
			if (o.abone)  pt.find(".oImgCourt").append("<div class='oDeleted'>Deleted</div>");
			$o.imgCourt(r.height);
			pt.find(".oImgCourt>.oDeleted").ifShow(o.abone);
			$j("#oTop_title").text(o.title).show();
			$j("#oTop_titleInfo").text(o.titleInfo).show();
		}
		$o.closeCoin();
		$o.jQA.fadeOut("fast");
		$j("#oDisplay").fadeOut("slow",function(){$j("#ip_caption").fadeIn('fast');});
		if ($j.browser.msie) $j("iframe").css({visibility:''});
		$o.moving=false;
		$o.topLoading=false;
		_o.topCoinId=null;
	},

	swfControl:function(){
		if ($j.browser.msie) {
			$j("OBJECT[classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000]:not(:has(>param[name=wmode]))").each(function(){
				//$j(this).wrapAll('<div class="oFlash"></div>').replaceWith($j(this).parent().html().match(/<object .*?>/i)+'<param name="wmode" value="transparent" />'+RegExp.rightContext);
				$j(this).addClass('oFlash').replaceWith($j(this).parent().html().match(/<object .*?>/i)+'<param name="wmode" value="transparent" />'+RegExp.rightContext);
			});
		}else{
			$j("EMBED").hide().attr("wmode","opaque");
			$j("OBJECT[classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000]:not(:has(>param[name=wmode]))").each(function(){
				//$j(this).hide().attr("oFlash",'true').prepend('<param name="wmode" value="opaque" />').show();
				$j(this).hide().addClass('oFlash').prepend('<param name="wmode" value="opaque" />').show();
			});
			$j("EMBED").show();
		}
	},
	drawRoot:function(){
		var x=4,d="",a="<span class='oRootArrow'><b>►</b></span>",b="";
		var jQS=$j("#oRoot_slider");
		$o.titleScroll(0);
		for(var i=0;i<=$o.root.no;i++){
			if (!$o.root[i]) continue;
			var r=$o.root[i],title=r.title,ct=r.contents,img=$o.type[ct.contentType].icon,w=ct.width,h=ct.height;
			if (r.abone){
				img=$o.type.del;w=32;h=32;
			}else{
				if (title.length>=7) title=title.substr(0,6)+"...";
				if (ct.contentType==2) img=$o.contentsDir.ithumb(ct); else {w=32;h=32;}
			}
			if (i==$o.root.no){a="";b="style='border:solid 2px #888'";}
			var t=$j().o.fitRect({srcW:48,srcH:48,width:w,height:h});
			d += "<div style='left:"+x+"px' class='oRootThumb'><div class='oRootNo'>"+(i+1)+"</div>"
				+"<div "+b+" class='oRootImage'><img name='"+i+"' src='"+ img+"' style='position:absolute;left:"+(t.x+2)+"px;top:"+(t.y+2)+"px;width:"+t.width+"px;height:"+t.height+"px'></div>"
				+a+"<div class='oRootTitle' >"+title+"</div></div>";
			x+=70;
		}
		$o.jQRV.html(d).width(x);
		if ($o.jQRV.width() > $o.jQRF.width()) jQS.innerShow(); else jQS.hide();
		$o.scrollTo(100, {slider:jQS,frameDiv:$o.jQRF,viewDiv:$o.jQRV,nextWidth:(jQS.width()>>1)});
		$j("img",$o.jQRV).click(function(){
			$o.jumpCoin(Number(this.name));
		});
	},
	ieSpeedy:function(){
		if ($j.browser.msie){
		eval((function(props) {var code = [];for (var i = 0,l = props.length;i<l;i++){var p = props[i];window['_'+p]=window[p];code.push(p+'=_'+p);}return 'var '+code.join(',');})('document self top parent alert setInterval clearInterval setTimeout clearTimeout'.split(' ')));
		}
	},

	//Coin Data Interfaces
	themeCd:function(frm,isSep){
		var t1=$o.toNum(frm.tension1.value)<<16,t2=$o.toNum(frm.tension2.value)<<8,t3=$o.toNum(frm.doing.value);
		return {
			themeCd: ((t1==0||t2==0||t3==0)&&!isSep) ? 0 : (t1 + t2 + t3),
			themeMask: (t1!=0?0xFF0000:0)+(t2!=0?0xFF00:0)+(t3!=0?0xFF:0)
		};
	},
	toNum:function(v){
		var n=Number(v);
		return ((typeof(n)!="number")||(isNaN(n)))?0:n;
	},
	nextCoin:function(no){
		if ($o.moving) return;
		var st=$o.root.no;
		$o.moving=true;
		$j().o.push($o.o);
		$o.root.vector=1;
		$o.root.no++;
		$o.transitionCoinData($o.nowInfos[no].subCoinCd,$o.root.vector);
	},
	backCoin:function(){
		if ($o.moving) return;
		if ($o.root.no==0) return;
		$o.jumpCoin($o.root.no,-1,true);
	},
	jumpCoin:function(no,v,bk){
		if ($o.moving) return;
		$o.moving=true;
		if (v) no=no+v;
		if ((no < 0) || ($o.root.no < no)) {
		$o.root.vector=0;
		return;
		}
		$o.root.vector=(no<$o.root.no)?-1:((no!=$o.root.no)?1:0);
		$j().o.push($o.o);
		var st;
		$o.root.no=no;
		$o.nowTop.coins=$o.root[$o.root.no];
		$o.o=$o.nowTop.coins;
		$o.cnt=$o.nowTop.coins.contents;
		$o.transitionCoinData($o.o.coinCd,{vector:$o.root.vector,ope:((bk)?1:0)});
	},

	//データ表示
	pageload:function(hash) {
		if ($o.moving) return;
		if ($o.noChange) {
			$o.noChange = false;
			return;
		}
		var h=$j().oURLParam(hash);
		if ($o.o.coinCd != h.id){
			if ((h.o)&&($o.tp.coinCd!=h.o)) $o.closeCoin();
			$o.loadCoinFromBookmark(h);
		}else if (h.n!=$j().o.opt.cellCode){
			var n=(Number(h.n)>=0)?Number(h.n):-1;
			$j().o.cursor.jumpCellCode(n);
		};
	},
	loadCoinFromBookmark:function(h){
		var nh=$j().oURLParam(),id={id:null,initCellCode:null};
		if (!h) var h=nh;
		if (typeof(h.id)=="undefined"){$o.TopCoinLoad(null);return;}
		if (typeof(h.n)!="undefined") id.initCellCode=Number(h.n);
		if (typeof(h.o)!="undefined"){
			id.id=h.id;
			$o.TopCoinLoad(id.id,id.initCellCode);
		}else{
			id.id=h.c;
			$o.rootingCoinCd(id.id,id.initCellCode);
		}
		return id;
	},

	rootingCoinCd:function(cd,cellCode){
		if ($o.isNotFound(1,cd,true)) return;
		if (cellCode==null) cellCode=-1;
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		CoinApi.getRootingCoinCd(cd,function(rt){
			if (rt.topCoin==null||$o.isNotFound(rt.coins.length,cd,true)) return;
			var no=$o.root.no,o=rt.coins;
			if (o[0].abone) o[0].title=rt.o[0].titleInfo=$o._.deleted;
			$o.root=o;
			$o.root.no=o.length-1;
			for (var i=0; i < $o.root.no; i++){
				$j().o.push(o[i],{cellCode:o[i].cellCode});
			}
			$j().o.push(o[$o.root.no],{cellCode:cellCode});
			$o.topLoading=($o.nowTop.coinCd!=o[0].coinCd);
			//CoinApi.getTopCoin(o[0].topCoinId,function(topCoin){
				$o.jQLd.oAjaxMon();
				$o.tp=$o.nowTop=rt.topCoin;
				$o.o=$o.nowTop.coins=o[o.no];
				$o.ct=$o.nowTop.coins.contents;
				$o.transitionCoin($o.o);
			//});
		});
	},
	changeTop:function(cd){
		if (($o.moving)||($o.topLoading)) return;
		if ($j("#oDisplay").isShow()) $j.historyLoad(cd);
		else $j("#oStarting").o({mode:'chgTop',id:cd,trigger:'hide'});
	},
	TopCoinLoad:function(topCoinId,cellCode){
		/*
		var nl=((topCoinId==null)&&(cellCode==null));
		if ((!nl)&&($o.isNotFound(1,topCoinId,true))) return;
		*/
		if ($o.isNotFound(1,topCoinId,true)) return;
		if (cellCode==null) cellCode=-1;
		$o.targetSW=true;
		$o.historySW=false;
		$o.topLoading=false;
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.noChange=true;
		$o.moving==true;
		var t=typeof(topCoinId);
		if (((t=="string")&&($o.nowTop.coinCd!=topCoinId))
		||((t=="number")&&($o.nowTop.topCoinId!=topCoinId))){
		$o.topLoading=true;
		$o.round=null;
		$j("#oRound_panel").find(".roundToggle").hide().removeClass("roundSelect");
		}
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		if (typeof(topCoinId)=="string") CoinApi.getTopCoinByCD(topCoinId,loaded);
		else CoinApi.getTopCoin(topCoinId,loaded);
		function loaded(topCoin){
		if ($o.isNotFound(topCoin.topCoinId,topCoinId,true)) return;
		var id=topCoin.topCoinId;
		if (topCoin.coins.abone) topCoin.coins.title=topCoin.coins.titleInfo=$o._.deleted;
		topCoin.coins.cellCode=cellCode;
		$o.nowTop=topCoin;
		$o.tp=$o.nowTop;
		$o.o=$o.nowTop.coins;
		$o.root={no:0,0:topCoin.coins};
		//if (typeof($o.cache[topCoin.coins.coinId])=="undefined") {$j().o.push(topCoin.coins,{cellCode:cellCode});}
		$j().o.push(topCoin.coins,{cellCode:cellCode});
		$o.jQLd.oAjaxMon();
		$o.transitionCoin();
		}
	},
	transitionCoinData:function(coinCd,v,callback){
		var op=0;
		if ((v==null)||(typeof(v)=="undefined")) v=0;
		if (typeof(v)=="object") {
			op=v.ope;
			v=v.vector;
		}
		if (!coinCd) {
			var coinCd = $o.o.coinCd;
			$j().o.removeCache($o.o.coinId);
		}
		$o.jQLd.oAjaxMon($o._.loading,true);
		CoinApi.getCoin(coinCd,v,op,function(coins){
			$o.jQLd.oAjaxMon();
			$o.transitionCoin(coins);
			if ($j.isFunction(callback)) callback();
		});
	},
	historyEnable:function(mode){
		if ($j().o.opt.mode!='url') return;
		$j.historyEnable(mode);
	},
	transitionCoin:function(o){
		$o.historyEnable();
		$o.urlHash=null;
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		if (o==null) var o=$o.o;
		if ($o.interval) {
		if (typeof($o.flash.externalplay) != "undefined") $o.flash.externalplay.mediaDispose();
		clearInterval($o.interval);
		$o.interval = null;
	}
		$o.initCoin(o);
		var md=$j().o.opt.mode;
		if ((md!="view")&&(md!="cover")&&($o._.serviceName)) document.title = $o._.serviceName+" - "+$o.removeAllTag($o.root[0].title)+"["+$o.removeAllTag($o.o.title)+"]";
		$j(".oTitleName").text(document.title);
//		if ($o._.welcomeUrl){
//			$j("#oIF_welcome a",$o.jQIP).attr('href',$o._.welcomeUrl+"#o="+$o.nowTop.coinCd).html($o._.welcomeTitle);
//		}
		var d=$o.jQIm.css("display");
		if (($j().o.opt.cellCode>0)&&(d!="none" )) $o.jQIm.fadeOut(100);
		if (($o.jQIm.length!=0)&&($j().o.opt.cellCode>0)&&(d!="none" )) $o.jQIm.fadeOut(100);
		$j().o.image.loadFromCoin($o.o,{transiton:true},done);
		function done(){
		if (($o.jQIm.length!=0)&&($j().o.opt.cellCode<0)&&(d=="none")) $o.jQIm.fadeIn(100);
		var ck=$o.topLoading;
		$o.receiveCellData(function(){
			if (ck){
			if ($o.jQSR.length>0) $o.searchRound.init();
			if ($o.jQSC.length>0){
				$o.searchCategory($o.tp.category.categoryId);
				$j("#category_select").val($o.tp.category.categoryId);
			}
			}
			//$j("#oFilter_icons").ifShow(!$j().o.getOneCell());
			if ($o.o.cellPatternId<0) $j("#oTitle_mode").text($o._.free); else $j("#oTitle_mode").text($o._.mesh);
			$o.historyEnable(true);
			$j().o.grid.show();
			$j("#oBtnTarget").oToggleEffect($o.targetSW);
			$o.makeLinkTag();
			$o.moving=false;
			$o.topLoading=false;
		});
		}
	},
	initCoin:function(o){
		if (!o) var o=$o.o;
		var r=$o.root[$o.root.no];
		if ((r)&&(r.coinId==o.coinId)&&(o.coinCellId==null)&&($o.root.vector==0)){
			o.coinCellId=r.coinCellId;
			o.cellCode=r.cellCode;
			$j().o.cursor.setCellCode(r.cellCode);
		}
		if (o.abone) o.title=o.titleInfo=$o._.deleted;
		$o.nowTop.coins=o;
		$o.o=$o.nowTop.coins;
		$o.cnt=$o.o.contents;
		$o.root[$o.root.no]=o;
		$o.free=(o.cellPatternId<0);
		$o.refreshInterfaces();
	},
	showCoin:function(o){
		$o.initCoin(o);
		$j().o.grid.setFromCoin(o);
	},
	closeCoin:function(fn){
		if (typeof($o.nowTop.coins)!="undefined") {
			var c=(typeof($o.cells[$j().o.opt.cellCode])=="undefined")?-1:$o.cells[$j().o.opt.cellCode].coinCellId;
			CoinApi.closeCoin($o.o.coinId,($j().o.opt.cellCode>=0)?(($j().o.opt.oneCell)?0:c):-1,-1,{callback:fn,async:false,timeout:4000});
		}
	},
	cancelInfo:function(){
		if (typeof($o.nowTop.coins)!="undefined") {
			var cd=$j().o.opt.cellCode;
			CoinApi.cancelInfo($o.wizNew.type,$o.o.coinId,((cd>=0)&&($o.cells[cd]))?$o.cells[cd].coinCellId:-1);
		}
	},
	receiveCoinData:function(coinId,callback){
		if (!coinId) var coinId=$o.o.coinId;
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		CoinApi.getCoin(coinId, function(coins){
			$o.jQLd.oAjaxMon();
			$o.showCoin(coins);
			if ($j.isFunction(callback)) callback();
		});
	},

	receiveFilterData:function(coinId,callback){
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		CoinApi.filterCell(coinId,function(types){
			$o.jQLd.oAjaxMon($o._.loading,true);
			$o.setFilterData(types);
			$o.setFilter();
			if ($j.isFunction(callback)) callback();
		});
	},
	setFilterData:function(types){
		var st,min;
		st=min=Number.MAX_VALUE;
		$o.filter.cell={};
		$o.enquetes={};
		$o.temp.hasInfo={};
		if (types) $o.filter.types=types; else var types=$o.filter.types;
		for (var i in types){
		var n=types[i].cellCode;
		if (types[i].contentType==-1) $o.enquetes[n]=types[i].typeCount; else $o.temp.hasInfo[n]=true;
		if ($o.filter.type==types[i].contentType){
			$o.filter.cell[n]={};
			$o.filter.cell[n][types[i].contentType]=types[i].typeCount;
			if (min>n) min=n;
		}
		}
		if (min==st) min=-1;
		return min;
	},
	receiveCellData:function (callback){
		$o.receiveFilterData($o.o.coinId,function(){
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		CoinApi.getCells($o.o.coinId, function(cellData){
			$o.cells=[];$o.cellNo=[];
			cellData.sort(function(a,b){return a.coinCellId-b.coinCellId;});
			$o.cellNo=cellData;
			for (var i=0; i<cellData.length; i++){
			var cd=cellData[i].cellCode;
			$o.cells[cd]=cellData[i];
			$o.cells[cd].cellNo=i;
			$o.cells[cd].hasInfo=(typeof $o.temp.hasInfo == 'undefined')?true:$o.temp.hasInfo[cd];
			}
			$o.cellCount=i;
			delete $o.temp.hasInfo;
			$o.jQLd.oAjaxMon();
			$j().o.isPop($o.o);
			var cd=$j().o.cursor.setCellCode($o.cache[$o.o.coinId].cellCode);
			$o.checkInfo($j().o.opt.cellCode,callback);
		});
		});
	},
	showCell:function(view,fn){
		var f=$j.isFunction(view);
		if ((view==true)||(fn)){
		$o.setFilterData();
		$j().o.grid.show();
		if (fn) fn();
		}else{
		$o.receiveCellData(function(){
			$j().o.grid.show();
			if (f) view();
		});
		}
	},

	receiveInfoData:function(cellId,callback){
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		CoinApi.getInfos(cellId,$o.entry, function(coinInfos){
		$o.jQLd.oAjaxMon();
		$o.updateInfoList(coinInfos);
		if ($j.isFunction(callback)) callback();
		});
	},
	receiveInfoByCellCode:function(no,callback){
		// $o.urlHash=$o.coinUrlHash();
		if (!$o.cells[no]) {
		$o.updateInfoList();
		if ($j.isFunction(callback)) callback();
		return;
		}
		var id=$o.cells[no].coinCellId;
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		var md=(($o.entry)?1:0)+((callback==true)?2:0);
		CoinApi.getInfos(id,md,function(coinInfos){
		$o.jQLd.oAjaxMon();
		$o.entry=false;
		$o.updateInfoList(coinInfos);
		if ($j.isFunction(callback)) callback();
		});
	},
	checkInfo:function(c,callback){
		var id=$o.o.coinId;
		if ($o.cells[c]){
		if (!$o.history[id])$o.history[id]={};
		if (!$o.history[id][c]){
			$o.history[id][c]=$o.history.count;
			$o.history.count++;
			$j().o.showCheck(c);
		}
		}
		if (!$o.topLoading) $o.bookmarkURL();
		if (callback!=null) $o.drawInfo(c,callback); else  $o.drawInfo(c);
	},
	drawInfo:function(c,callback){
		if ((c >= 0)&&($o.jQIm.css("display")!= "none")) $o.jQIm.hide();
		var p=null,id=null;
		if ($o.cells[c]) id=$o.cells[c].coinCellId;
		if (callback!=null) $o.receiveInfoByCellCode(c,callback); else $o.receiveInfoByCellCode(c);
	},

	receiveEnqueteData:function(cellCode,callback){
		var cellId=($o.cells[cellCode])?$o.cells[cellCode].coinCellId:null;
		$o.jQLd.oAjaxMon($o._.loading,true);
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		CoinApi.getEnquete(cellId, function(enq){
		$o.jQLd.oAjaxMon();
		$o.wizEnq.enquete=enq;
		if ($j.isFunction(callback)) callback(enq);
		});
	},

	//Data Utility
	hashRedef:function(dst,src,k){
		if (k) $j.each(src,function(i,v){dst[i][k]=v;}); else $j.each(src,function(i,v){dst[i]=v;});
		},
	clone:function (o){
		//var newObj=new Object();
		//for(var i in o)newObj[i]=o[i];
		//return newObj;
		//var f = function(){};
		//f.prototype = o;
		//return new f();
		return JSON.parse(JSON.stringify(o));
	},
	cloneObject:function (o){
		var f = function(){};
		f.prototype = o;
		return new f();
	},
	cloneCells:function(o){
		var c={};
		for (var i in o) c[o[Number(i)].cellCode]=$o.clone(o[Number(i)]);
		return c;
	},
	cloneCellArray:function(a,md){
		var c=[],n=0;
		for (var i in a) {
		var o=a[Number(i)];
		i=Number(i);
		if (!((md)&&(!o.modified))) {
			c[n] = $o.clone(o);
			n++;
		}
		}
		if (c.length==0) c=null;
		return c;
	},
	//Text Utility
	dateFormat:function(srcDate){
		var yy=srcDate.getYear(),
		mm=srcDate.getMonth()+1,
		dd=srcDate.getDate(),
		hour=srcDate.getHours(),
		min=srcDate.getMinutes(),
		sec=srcDate.getSeconds();
		if (yy<2000) yy+= 1900;
		if (mm<10)  mm="0"+String(mm);
		if (dd<10)  dd="0"+String(dd);
		if (hour<10) hour="0"+String(hour);
		if (min<10)  min="0"+String(min);
		if (sec<10)  sec="0"+String(sec);
		//return (yy+"/"+mm+ '/'+dd+" "+hour+':'+min+':'+sec);
		return (yy+"/"+mm+ '/'+dd+" "+hour+':'+min);
	},
	trim:function(src){
		return String(src).replace(/^[ 　\n\r]*$/g, "").replace(/[ 　\n\r]*$/g, "");
	},
	printVal:function(src,ar){
		$j.each(ar,function(i,v){
			var r = new RegExp("\\{"+i+"\\}");
			src=src.replace(r,v);
		});
		return src;
	},
	checkMaxLength:function(src,lng){
		var m = "",cn=$o.countChr(src);
		if (lng.mb){
			if (cn.zenkaku>lng.max) m = $o.printVal(lng.info,[cn.zenkaku]);
		}else{
			if (cn.byteLen>lng.max) m = $o.printVal(lng.info,[cn.byteLen]);
		}
		return m;
	},
	maxLength:function(str,len){
		var bc=0,dash="";
		for(var i=0;(i<str.length)&&(bc<len);i++){
		var c=str.charCodeAt(i);
		if ((c!=10)&&(c!=13)) bc+=(c<0x100)?0.5:1;
		}
		bc=Math.ceil(bc);
		return ((len<=bc)&&(str.length>bc))?str.substring(0,i):str;
	},
	countChr:function(str){
		if ((str==null)||(str=="")) return {length:0,byteLen:0,zenkaku:0};
		var bc=0;
		for (var i=0;i<str.length;i++) bc+=(str.charCodeAt(i)<0x100)?1:2;
		return {length:str.length,byteLen:bc,zenkaku:Math.ceil(bc/2)};
	},
	countChrOnly:function(src){
		if ((src==null)||(src=="")) return {length:0,byteLen:0,zenkaku:0};
		return $o.countChr(src.replace(/<.*?>|\n|\r/g, ""));
	},
	fileExt:function(src){
		var ext=src.toLowerCase().match(/\.(....?)$/);
		return RegExp.$1;
	},
	//Color Utility
	dec2hex:function (dec) {
		if ((dec==null)||(dec=="")) return "000000";
		var hex="";
		while(dec){
		var last=dec&15;
		hex=String.fromCharCode(((last>9)?55:48)+last)+hex;
		dec >>= 4;
		}
		return ("000000").substr(hex.length)+hex;
	},
	hsv2rgb:function(hsv) {
		var r=0,g=0,b=0;
		var h=hsv.h,s=hsv.s,v=hsv.v;
		if (s<0) s=0;
		if (s>1) s=1;
		if (v<0) v=0;
		if (v>1) v=1;
		h%=360;
		if (h<0) h+=360;
		h/=60;
		i=Math.floor(h);
		f=h-i;
		var p1=v*(1-s),p2=v*(1-s*f),p3=v*(1-s*(1-f));
		switch (i){
		case 0:r=v;g=p3;b=p1;break;
		case 1:r=p2; g=v; b=p1; break;
		case 2:r=p1; g=v; b=p3; break;
		case 3:r=p1; g=p2; b=v; break;
		case 4:r=p3; g=p1; b=v; break;
		case 5:r=v; g=p1; b=p2; break;
		}
		var rgb=$o.dec2hex(Math.floor(r*255)*0x10000+Math.floor(g*255)*0x100+Math.floor(b*255));
		if (hsv.a) return rgb+$o.dec2hex(Math.floor(hsv.a)).substr(4, 5); else return rgb;
	},
	rgba2css:function(rgba){
		var c=parseInt("0x"+rgba.substring(1),16);
		if (rgba.length<=7) c=(c<<8)+70;
		return "rgba("+((c>>24)&0xFF)+","+((c>>16)&0xFF) +","+((c>>8)&0xFF) +","+((c&0xFF)/100)+")";
	},
	rgb2hsv:function(rgb){
		var hsv=({h:0,s:0,v:0});
		if (rgb.length>7) hsv.a=parseInt("0x"+rgb.substring(7),16);
		rgb=parseInt("0x"+rgb.substring(1,7),16);
		var r=(rgb>>16),g=((rgb>>8)&0xFF),b=(rgb&0xFF);
		cmax=(r>=g)?r:g; if (b>cmax) cmax=b;
		cmin=(r<=g)?r:g; if (b<cmin) cmin=b;
		hsv.v=cmax/255;
		var c=cmax-cmin;
		hsv.s=(cmax==0)?0:c/cmax;
		if (hsv.s!=0){
		if (r==cmax) {
			hsv.h=(g-b)/c;
		}else{
			if (g==cmax) hsv.h=2+(b-r)/c; else if (b==cmax) hsv.h=4+(r-g)/c;
		}
		hsv.h*=60;
		if (hsv.h<0) hsv.h+=360;
		}
		return hsv;
	},
	CoinRgb:function(v){
		s=0;
		maxCount=7;
		for (i=0;i<=maxCount;i++){
		if (CoinColorArray[i][0] >= v) {s=i;break;}
		}
		if ((s>0)&&(s<=maxCount)) s--; else if (v >= CoinColorArray[maxCount][0]) s=maxCount;
		return CoinColorArray[s][1];
	},
	//Browser Utilty
	isIE6:function(){
		var vn=$j.browser.version.match(/\./),v=Math.floor(RegExp.leftContext);
		return (($j.browser.msie)&&(v<7));
	},
	imgCourt:function(w){
		if ($o.isIE6()){
		w=(w)?w:"100%";
		$j(".oImgCourt").hover(function(){
			$j(this).height(w).addClass("oImgCourtHover");
		},function(){
			$j(this).removeClass("oImgCourtHover");
		});
		}
	},
	noIE:function(v){
		if ($j.browser.msie) return 0; else return v;
	},
	contentsDir:{
		lastNo:null,
		lastDir:null,
		get:function(srvId,n){
		n=(n>>>12)+1;
		if ($o.contentsDir.lastNo==n) return $o.contentsDir.lastDir;
		$o.contentsDir.lastNo=n;
		var ch="0123456789abcdefghijklmnopqrstuvwx",cd="",b=0;
		for (var i=0; i<4; i++){
			cd = ch.charAt(n & 0x1F) + cd;
			n>>>=5;
		}
		$o.contentsDir.lastDir=$o.medDir+"cl"+srvId+"/"+"fl"+cd+"/";
		return $o.contentsDir.lastDir;
		},
		set:function(cont){
		var d=$o.contentsDir.get(cont.serverId,cont.contentId);
		$o.cntDir=d+"c/";
		$o.itmbDir=d+"i/";
		$o.tmbDir=d+"t/";
		return;
		},
		file:function(cont){
		$o.cntDir=$o.contentsDir.get(cont.serverId,cont.contentId)+"c/";
		return $o.cntDir+cont.filename;
		},
		ithumb:function(cont){
		$o.itmbDir=$o.contentsDir.get(cont.serverId,cont.contentId)+"i/";
		return $o.itmbDir+cont.filename;
		},
		thumb:function(cont){
		$o.tmbDir=$o.contentsDir.get(cont.serverId,cont.contentId)+"t/";
		return $o.tmbDir+cont.filename;
		}
	},
	coinUrlHash:function(){
		var isTop=($o.root.no==0),
			c = (isTop)?"":"c="+$o.o.coinCd
			,n=($j().o.opt.cellCode>=0)?("n="+$j().o.opt.cellCode):"";
		return c+((c!=""&&n!="")?"&":"")+n;
	},
	bookmarkURL:function(){
		if (!$j().o.opt.bookmark) return;
		var r=$j().oURLParam();
		if ((r.id==$o.o.coinCd)&&(r.n==$j().o.opt.cellCode)) return;
		$o.noChange=true;
		if ($o.cnt.contentType==2) $o.makeLinkTag();
		$j.historyLoad($o.coinUrlHash());
	},
	makeLinkTag:function(){
		var b=$o.srvPath+$o.baseDir;
		make("#oAtag_linkTop",$o.root[0],$o.root[0].coinCd);
		make("#oAtag_link",$o.o,$o.coinUrlHash());
		function make(id,o,para){
			var ct=o.contents,
			url=$o.srvPath+$o.baseDir+"infoplayer/"+para,
			f=$o.srvPath+$o.contentsDir.file(ct).replace("/c/","/t/"),
			i=$o.removeAllTag(o.titleInfo.match(/(.*?<br>)|(.*)/)[0]),
			t=(o.title.length<16)?o.title:(o.title.substring(0,15)+"..."),
			h=Math.floor(ct.height/3);
			var m=((120-h)>>1);
			i=(i.length<16)?i:(i.substring(0,15)+"...");
			$j(id).val((ct.contentType==2)?($o.jTmp._templates.ATagLink.get({URL:url,img:f,title:t,info:i,width:Math.floor(ct.width/3),height:h,margin:(m>0)?('margin:'+m+'px 0'):''},[],document.body)):"");
		}
	},
	searchCategory:function(n,id){
		if ((n<1)||isNaN(n)) n=null;
		CoinApi.searchResult({mode:"c",lastcount:0,offset:0,param:n,limit:20,coinId:id},$o.buildSearchBody);
	},
	searchRound:{
		next:function(v){
			var n=$o.round.offset;
			$j("#oRound_"+n).removeClass("roundSelect");
			if (v=="init"){
			$o.round.offset=-1;
			}else{
			if (v=="next"){
				n=(n<($o.round.length-1))?n+1:0;
			}else{
				n=Number(v);
			}
			CoinApi.getRoundUrl($o.nowTop.coinCd,n,round);
			}
			function round(){
			$j("#oRound_"+n).addClass("roundSelect");
			$o.round.offset=n;
			$o.showLast=true;
			$j.historyLoad($o.round[n]);
			}
		},
		init:function(){
		CoinApi.getRoundUrl($o.nowTop.coinCd, null, function(r){
			$j("#oRound_error").ifShow(r.length==0);
			$o.round=r;
			$o.round.offset=null;
			if ((r==null)||(r.length==0)) return;
			for (var i=0; i<5;i++){
			$j("#oRound_"+i).ifShow(i<r.length).click(function(){
				$o.searchRound.next($j(this).attr("id").match(/_(.)/)[1]);
			});
			}
			$o.searchRound.next("init");
		});
		}
	},
	buildSearchBody:function(re){
		if (typeof(re.count)=="undefined"){$j("#thumbBody").empty();return;}
		for (var i=0; i<re.results.length; i++){
		var r=re.results[i];
		var asp=Math.min(Math.min((112/r.width),(84/r.height)),1);
		r.no=i+1;
		r.w=r.width*asp;
		r.h=r.height*asp;
		r.fx=0;
		r.fy=i*116+3;
		r.x=(112-r.w)>>1;
		r.y=(84-r.h)>>1;
		r.filename=$o.contentsDir.file({serverId:r.serverId,contentId:r.contentId,filename:r.filename}).replace("/c/","/t/");
		r.hname = $o.toNanashi(r.hname);
		}
		$j("#thumbBody").processTemplate({result:re.results});
	},
	getCRChars:function(){
		var theAgent=navigator.userAgent;
		if (theAgent.indexOf("Win") >=0) return "\r\n"; else if(theAgent.indexOf("Mac") >=0) return "\r"; else return "\n;";
	},
	checkBlank:function(src){
		if (src.length==0) return 0;
		var reg=new RegExp($o.getCRChars()+"| |　");
		var ok=src.match(reg,"g");
		return src.replace(reg, "").length;
	},
	checkInvalidTag:function(src,col){
		var b=(src.length!=$o.removeTag(src,col).length);
		return (b||$o.checkClosingTag(src));
	},
	checkClosingTag:function(src){
		var st=src.match(/<font /ig),ed=src.match(/<\/font>/ig);
		var b=(((st)?st.length:0)!=((ed)?ed.length:0));
		st=src.match(/<a /ig);ed=src.match(/<\/a>/ig);
		return b|(((st)?st.length:0)!=((ed)?ed.length:0));
	},
	checkURL:function(src){
		if (src.tag){
		var a=src.tag.match(/<a href="(http|https):\/\/[!#-9A-~]+\.+[\w\d\/%#$&?()~_.=+-:]+" target="_blank">.*?<\/a>/i);
		}else{
		var a=src.match(/(http|https):\/\/[!#-9A-~]+\.+[\w\d\/%#$&?()~_.=+-:]+/i);
		}
		return (a!=null);
	},
	br2cr:function(src){
		if (src) {return src.replace(/<br>/g,$o.getCRChars());}else{return "";}
	},
	cr2br:function(src){
		if (src) {return src.replace(/\x0D\x0A|\x0D|\x0A/g, "<br>");}else{return "";}
	},
	isPartsTag:function(src){
		return src.match(new RegExp($o.partsTag));
	},
	toNanashi:function(n){
		return ((n==null)||(n==""))?$o._.anonimouse:n;
	},
	checkNanashi:function(n,md){
		var hn=$o.removeTag(n,$o.wizNew.colors);
		if (md){if (hn==$o._.anonimouse) hn=null;} else {
		hn=$o.toNanashi(hn);

		var mx = $o.checkMaxLength(hn,$o._.vld_maxName);
		if (mx) hn={err:mx};
		}
		return hn;
	},
	removeAllTag:function(src){
		if (src) {return $o.trim(src.replace(/<.*?>/g, ""));}else{return "";}
	},
	removeTag:function(src,col){
		if (src) {
		var reg=new RegExp($o.partsTag);
		var ok=src.match(reg,"g"),c=".*";
		src=src.replace(reg, "_xx_");
		if (typeof(col)=="object"){
			c="";
			$j.each(col,function(i,v){
			c+=((c=="")?"":"|")+"color:"+this+";";
			});
			c=c.replace(/\(/g,"\\\(").replace(/\)/g,"\\\)");
		}
		var reg2=new RegExp('<((?!\/font)(?!font style="('+c+')")(?!br)(?!a href=\".*\" target=\"_blank\">)(?!\/a>)).*?>',"ig");
		src=src.replace(reg2, "");
		if (ok) src=src.replace(/_xx_/g, ok[0]);
		return $o.trim(src);
		}else{return "";}
	},
	cookieWrite:function(k, dt, kd){
		if(!navigator.cookieEnabled){
		alert($o._.err_cantWriteCookie);
		return;
		}
		var d=new Date(),d2;
		if (kd) {
		d.setTime(d.getTime() + (kd*1000*60));
		d2=d.toGMTString();
		} else d2="Tue, 1-Jan-2030 00:00:00 GMT;";
		if (typeof(k)=="object") document.cookie=k.key+"="+k.value+";expires="+d2;
		else document.cookie=$o.root[0].contents.filename+"&"+k+"="+escape(dt) +";expires="+d2;
	},
	cookieRead:function(k){
		if(typeof(k) == "undefined") return "";
		if (typeof(k)=="object") k=k.key+"=";
		else k=$o.root[0].contents.filename+"&"+k+"=";
		var dt="",ck=document.cookie + ";";
		var start = ck.indexOf(k);
		if (start!=-1) dt= unescape(ck.substring(start+k.length, ck.indexOf(";", start)));
		return dt;
	},

	//Filter Operations
	setFilter:function(){
		var jQf=$j("#oFilter_icons").empty(),id,tp=[],y=0,w=$o.type.swidth;
		for (var i in $o.filter.types){
		if (!tp[$o.filter.types[i].contentType]) tp[$o.filter.types[i].contentType]=$o.filter.types[i].typeCount;
		}
		for (var i=1;i<10;i++){
		id=$o.filter.chip[i];
		if (!((!$o.type.all)&&!(tp[id]))) {
			jQf.append("<div id='oFilter" + i + "' onclick='$o.onFilterClick(" + i + ");' class='btnImg'><a title='" + $o.type[id].tip + "' ><img src='" + $o.type[id].s + "'></a></div>").children("div#oFilter"+i).css({position:"absolute",left:0,top:y,width:w,height:w,filter:"alpha(style=0, opacity=40)",opacity:"0.4"});
			$o.filter.no[id]=i;
			y+=w;
		}
		}
		$o.filter.selected=null;
	},
	onFilterClick:function(n){
		var f=$o.filter;
		if ((n==null)||(n==f.selected)) {
		var cd=$o.setFilterData();
		$o.refreshFilterButton();
		if (cd==-1) $j().o.cursor.jumpCellCode($o.filter.beforeCell);
		}else{
		if (f.selected==null) $o.filter.beforeCell=$j().o.opt.cellCode;
		$o.refreshFilterButton(n);
		var cd=$o.setFilterData();
		$j().o.cursor.jumpCellCode(cd);
		}
		$o.showCell(true);
	},
	refreshFilterButton:function(n){
		var f=$o.filter;
		if (f.selected != null) $j("#oFilter" + f.selected).oToggleEffect(false);
		var jQr=$j("#oFilter_reset");
		if (n){
		$j("#oFilter"+n).oToggleEffect(true);
		f.type=$o.filter.chip[n];
		f.selected=n;
		f.length=1;
		//if (jQr.css("display")=="none") jQr.oModal("on").fadeIn("fast");
		jQr.oDivDialog({text:null,ok:"Search Off",okClick: function(){close();$o.showCell(true);}}).fadeIn($o.noIE("fast"));
		}else close();
		function close(){
		$j("#oFilter" + f.selected).oToggleEffect(false);
		$o.filter.type=null;
		$o.filter.selected=null;
		$o.filter.length=0;
		$j("#oFilter_reset").fadeOut($o.noIE("fast")).empty();
		}
	},
	//History Operations
	onHistoryClick:function(self){
		$o.historySW=$o.toggleButton(self,{value:$o.historySW,toggle:true});
		$j().o.setHistory($o.historySW);
		$o.showCell(true);
	},
	//Target Operations
	onTargetClick:function(self){
		$o.targetSW=$o.toggleButton(self,{value:$o.targetSW,toggle:true});
		$j().o.target.show();
	},
	//Grid Operation
	gridOnOff:function(md){
		var z=1,t=(md=="on"),o=$j("#oDisplay").offset(),dg=(t)?"enable":"disable";
		$j("#oModal").css({position:"absolute",left:-o.left,top:-o.top}).oModal((t)?"off":"grid");
		t=$j().o.grid.toggle(t);
		$j("#oTool_btnGridOn").ifShow(!t);
		$j("#oDisplay").draggable(dg);
		var c=$j().o.opt.cellCode;
		CoinApi.checkGridMode(t,$o.o.coinId,(c>=0)?((c)?0:c):-1,{async:false,timeout:4000});
	},
	//Cursor Operation
	cursorOnOff:function(){
		var z=1,md="off",onoff="OFF";
		if ($j().o.cursor.modal()){z=2001;md="grid";onoff="ON";}
		$j().oModal(md);
		var jQ=$j("#oTool_btnCursor").css("z-index",z).children("span").text(onoff);
	},
	//Coin Player Operations
	playProgress:function(){
		var st=$o.player.status();
		if (!st) return;
		if (typeof($o.flash.externalplay)=="undefined"){$o.playPanel.refresh();return;}
		if (typeof($o.flash.externalplay.playStatus)=="undefined") {$o.playPanel.refresh();return;}
		var ok=(st.loadByte>=st.totalByte),pi=$j("a>.oPlayIndicatorPos",$o.jQPg);
		if ($o.o.contentType==3) {if (pi.isShow()!=ok) pi.ifShow(ok);}
		if (!st.loaded){$o.playPanel.refresh();return;}
		if (st.end) $o.playPanel.stop();
		$o.playPanel.showStatus(st);
		if (typeof($o.jQPg.slider) != "undefined") {
		var p=((st.position==0)&&(st.duration==0))?0:(Math.floor((st.position/st.duration)*100));
		/*
		if ($o.isIE6) {
			var h=$o.jQPg.height()-16;pi.css({top:h-(p*h/100)
		});} else
		 */
		$o.jQPg.slider("option","value", p);
		}
	},
	playPanel:{
		open:function(){
		if ($o.o.abone) return;
		if ($o.jQP.css("display")!="none")$o.playPanel.refresh();
		clearInterval($o.interval);
		$j("#oPlay_btnPlay > img",$o.jQP).attr("src",$o.cssDir+"pause.gif");
		var w=$o.jQP.width(),jQv=$j("#oPlay_sliderVol",$o.jQP);
		$o.jQP.show("slide",{direction:"right"},200,function(){
			var v=jQv.slider("option","value");
			if (v!=30) jQv.slider("option","value",30,null,true);
			$o.interval=setInterval('$o.playProgress()',1000);-
			$o.playPanel.refresh();
		});
		},
		showStatus:function(st){
		var h=$o.jQPg.height(),ld=Math.floor(h*(st.loadByte/st.totalByte));
		$j("#oPlay_loading",$o.jQP).css({bottom:0}).height(ld);
		$j("#oPlay_total",$o.jQP).html("Total<br>"+st.strDuration);
		$j("#oPlay_now",$o.jQP).html(st.strTime);
		//f ($o.isIE6) {$o.pg.slider.hide();return;}
		},
		close:function(){
		clearInterval($o.interval);
		if ($o.jQP.isShow()){
			if (typeof($o.flash.externalplay)!="undefined") $o.flash.externalplay.mediaStop();
			$o.jQP.hide("slide",{direction:"right"}, 200);
		}
		},
		refresh:function(){
		var jQv=$j("#oPlay_sliderVol",$o.jQP);
		if (typeof(jQv.slider)!="undefined") jQv.slider("option","value",30);
		if (typeof($o.jQPg.slider)!="undefined") $o.jQPg.slider("option","value",0).innerShow();
		$j("#oPlay_total",$o.jQP).html("Total<br>00:00");
		$j("#oPlay_now",$o.jQP).html("00:00");
		},
		stop:function(){
		if (typeof($o.flash.externalplay)!="undefined"){
			if ((typeof($o.flash.externalplay.mediaStop)=="undefined")) return;
			var st=$o.flash.externalplay.mediaStop();
			$o.playPanel.showStatus(st);
		}
		$j("#oPlay_btnPlay > img",$o.jQP).attr("src",$o.cssDir+"play.gif");
		$o.jQPg.slider("option","value",100,null,true);
		}
	},
	//Coin UI
	getCellCd:function(){
		return $j().o.opt.cellCode;
	},
	scrollTo:function(u,sc){
		var sl=(typeof(sc.slider)=="object"),
			fw=sc.frameDiv.width(),fh=sc.frameDiv.height(),tp=sc.viewDiv.attr("offsetTop"),
			max=(typeof(sc.maxValue)=="number")?sc.maxValue:((sl)?sc.slider.slider('option', 'max'):100),
			ui=(typeof(u.value)!="undefined"),n=(ui)?u.value:u;
		if (typeof(sc.vertical)=="undefined") sc.vertical=(sc.slider.slider("option","orientation")=="vertical");
		if (sc.vertical){
		var vh=sc.viewDiv.height(),h=vh-(fh>>1);
		if ((fh>=vh)&&((ui)||(sc.vector))) return;
		if ((sc.toLast)&&(vh>fh)){
			n=max;
			sc.slider.show();
		}else if (sc.vector){
			n=max-sc.slider.slider("option","value")-32/(h/max)*sc.vector;
		}
		if (ui) n=max-n;
		if ((n<0)||(fh>=vh)) n=0;
		if (n>max) n=max;
		if (sl) {
			sc.slider.slider("option","value",max-n,null,true);
		}
		n=Math.floor(n*(h/max));
		if (tp==n) return;
		if (sc.animate>0){
			sc.viewDiv.css({position:"absolute"}).animate({top:(-n)},sc.animate,null,function(){
			if ($j.isFunction(sc.animeEnd)) sc.animeEnd();
			});
		}else{
			sc.viewDiv.css({position:"absolute",top:(-n)});
			if ($j.isFunction(sc.animeEnd)) sc.animeEnd();
		}
		}else{
		var vw=sc.viewDiv.width(),w=vw-(fw>>1);
		if (max > 0) {
			if (sc.nextWidth>0) w=fw+Math.floor((vw-fw)/sc.nextWidth)*sc.nextWidth-sc.nextWidth;
			sc.slider.slider("option","value", 100, null);
			n = Math.floor(n * (w / max));
		}else{
			var ww=n-fw;
			if (sc.nextWidth>0) n=(ww>0)?fw+Math.floor(ww/sc.nextWidth)*sc.nextWidth-sc.nextWidth:0;
		}
		//if ((sc.toLast)&&(vw>fw)) p=w;
		if (n<0) n=0;
		if (sc.animate>0){
			sc.viewDiv.animate({left:(-n),clip:"rect(0px " + (n+fw)+"px "+fh+"px " + n + "px)"},sc.animate,function(){
			if ($j.isFunction(sc.animeEnd)) sc.animeEnd();
			});
		}else{
			sc.viewDiv.css({left:(-n),clip:"rect(0px " + (n+fw)+"px "+fh+"px " + n + "px)"});
		}
		if ($j.isFunction(sc.animeEnd)) sc.animeEnd();
		}
	},
	titleScroll:function(v,fn){
		if (v == null) {
			$o.titleScrolling=null; $o.jQTV.stop().queue([]);return;
		}
		if (($o.titleScrolling == v) || (($o.titleScrolling == 0) && (v < 0))) return;
		var y = $o.titleY, vy=$o.titleY+v;
		if (vy==$o.titleY) return;
		if (v==0){
			$o.titleY=0;p.animate=null;
		}else{
			var p={vertical:true,animate:100,frameDiv:$o.jQTF,viewDiv:$o.jQTV},
				fh=p.frameDiv.height(),vh=p.viewDiv.height(),eh=vh-(fh>>1);
			if ((fh>vh)||(vy>eh)) return;
			$o.titleScrolling=(v>0)?1:-1;
			$o.titleY=vy;
			if  ($j.isFunction(fn)) {
			p.animate=250;
			p.animeEnd=function(){$o.titliScrolling=null;fn();};
			}
		}
		$o.scrollTo($o.titleY,p);
		if ($o.titleY<0) $o.titleY=0;
	},
	checkSelect:function(){
		var noSel=(isNaN($j().o.opt.cellCode)||($j().o.opt.cellCode<0));
		if  (noSel) $j().oDialog("error",$o._.err_selectCell,$o._.ok);
		return noSel;
	},
	getServerStatus:function(fn){
		CoinApi.getServerStatus(function(status){
		$o.serverStatus=status;
		if ($j.isFunction(fn)) fn(status);
		});
	},
	checkReadOnly:function(fnYes,fnNo){
		$o.getServerStatus(function(status){
		if (status.readOnly==1){
			$j("#oServer_status").html($o._.server_readOnly).show();
			if (fnYes!="noDialog") $j().oDialog("error",$o._.err_serverReadOnly,$o._.ok,function(){if ($j.isFunction(fnYes)) fnYes();});
		}else{
			$j("#oServer_status").empty().hide();
			if ($j.isFunction(fnNo)) fnNo();
		}
		});
	},
	isNotFound:function(no,cd,modal){
		var nt=(typeof(no)=="number")?(!no):((!no)||(cd.match( /[^\-\+0-9A-Za-z]/ )||(cd.length!=11))),fn=null,ok=$o._.ok;
		if (modal) {ok=$o._.btn_returnTop;fn=function(){$j("#oArea,#oDisplay").hide();location.href="/";};};
		if (nt) $j().oDialog("error",$o._.err_notFoundId.title,$o.printVal($o._.err_notFoundId.info,[cd]),ok,fn);
		return nt;
	},
	toggleButton:function(jQ,sw){
		if (sw.toggle) sw.value=!sw.value;
		jQ.oToggleEffect(sw.value);
		return sw.value;
	},
	onWindowLoad:function (e) {
		this.windowLoaded=true;
	},

	/*
	 * Data Entrys
	 */
	addInfo:function(coin,func){
		$o.jQLd.oAjaxMon();
		var txt,info={},hn,cell=($o.wizNew.addcell)?$o.wizNew.cell:cell={coinCd:$o.o.coinCd,cellCode:$j().o.opt.cellCode};
		var fn=function(coinInfo){
			$o.jQLd.oAjaxMon();
			if (coinInfo.coinCellId==-1){
				$j().oDialog("error", $o._.err_cantCellAdd,$o._.yes, function(){
					$o.wizEntry.close();
					return;
				});
				return;
			}
			$o.cache[$o.o.coinId].cellCode=cell.cellCode;
			$o.entry=true;
			$o.showCell(function(){
				$o.showLast=true;
				if ($j.isFunction(func)) func();
			});
		};
		if (coin==null){
			if ((!$o.wizNew.addcell)&&($j().o.opt.cellCode==-1)) {
				$j('#oIW_error > div').html($o._.errCellUnselection);
				return;
			}
			txt=$o.removeTag(document.frmInfoText.text.value,$o.wizNew.colors);
			info ={information:$o.cr2br(txt),coinCd:$o.o.coinCd,contentType:0,hname:$o.wizNew.hname};

			if ((txt.match(/<a .*<\/a>/))||($o.isPartsTag(txt))) info.contentType=1;
			if (info.information.length != 0){
				$o.jQLd.oAjaxMon($o._.saving,true);
				if ($o.editInfoNo==null){
				CoinApi.addInfo(cell, info, fn);
				}else{
				info.coinInfoId=$o.nowInfos[$o.editInfoNo].coinInfoId;
				CoinApi.updateInfo(info, fn);
				}
			}else{
				$j().oDialog("error", $o._.err_illegalText,$o._.yes, function(){
				$o.wizEntry.close();
				return;
				});
			}
		}else{
			info={information:coIn.title,coinCd:coin.coinCd,contentType:$o.wizNew.up.contentType,hname:$o.wizNew.hname};
			$o.jQLd.oAjaxMon($o._.saving,true);
			CoinApi.addInfo(cell, info, fn);
		}
	},
	wizEntry:function(mode,opt,closefn){
		$j.extend($o.wizEntry,{
			close:function(md,refresh){
				diagClose(md,refresh);
			}
		});
		var defuse={6:0,2:1},isRpl = (mode=="replace"||mode=="subrpl"),
			cp=(mode=="new")?2:$o.root[$o.root.no].contents.contentType,tp={2:"img",3:"snd",4:"mov",5:"swf",6:"pdf"},
			dm=((mode=="txt")||(mode=="img")||(mode=="snd"||(mode=="mov")||(mode=="swf")||(mode=="pdf")||isRpl));
		if ($j.isFunction(opt)) {
			var closefn=opt;
			var opt={use:defuse};
		}else if (typeof(opt)!="object"){
			var opt={use:defuse};
		}
		$o.playPanel.stop();
		if (((!mode)&&(!$o.wizNew.addcell))||(dm&&!isRpl)) if ($o.checkSelect()) {return;}
		if (typeof(mode)=="undefined") mode="";
		var cellcd=$j().o.opt.cellCode,tmp,jQW=$j("#oWizard"),fntMode={b:false,i:false},fntRGB=null;
		if ($o.wizNew.addcell) tmp=$o.clone($o.wizNew.cell);
		$o.wizNew={mode:mode,wizard:false,hasParam:true,sending:false,addcell:($o.wizNew.addcell==true),step:1,srcCellId:null,destCellId:null,
				modal:["on","on","on","on","on"],cellCode:cellcd,height:[(mode=="new")?203:177],cell:tmp,direct:dm,type:null,
				closefn:closefn
		};
		jQW.html($o.jTmp._templates.  entry_wiz.get({mode:mode,typeName: $o.type[cp].tip,direct:$o.wizNew.direct,use:opt.use},[],document.body)).oDecoButton().hide();
		delete(h);
		$j("#oIW_CellCode").html("Cell No."+$j().o.grid.getCellNo());
		var jQSt=$j("#oWiz_step",jQW);
		if (mode=='replace'){
			$o.wizNew.hasParam=false;
			setUpload(cp);
			return;
		}
		if (mode=='subrpl'){
			$o.wizNew.hasParam=false;
			setUpload(2);
			return;
		}
		//Step.1
		$j("#oIW_btnText").click(function(){setText();});
		$j("#oIW_btnImage,#oIW_btnEntry").click(function(){setUpload(2);});
		$j("#oIW_btnSound").click(function(){setUpload(3);});
		$j("#oIW_btnMovie").click(function(){setUpload(4);});
		$j("#oIW_btnSwf").click(function(){setUpload(5);});
		$j("#oIW_btnPdf").click(function(){setUpload(6);});
		$j("#oIW_btnBanner").click(function(){setUpload(7);});
		$j("#oIW_btnMenuCancel ").click(function(){diagClose("esc");});
		switch (mode){
			case "txt":
				setText();
				break;
			case "img":
				setUpload(2);
				break;
			case "snd":
				setUpload(3);
				break;
			case "mov":
				setUpload(4);
				break;
			case "swf":
				setUpload(5);
				break;
			case "pdf":
				setUpload(6);
				break;
			case "banner":
				setUpload(6);
				break;
			default:
				jQW.oWizard(null,1,$o.wizNew);
		}

		function diagClose(md,refresh){
			jQW.find(".oDisable").show();
			$j("div.validationTip,#dlgmat,#dlg").remove();
			jQW.fadeOut($o.noIE(200),function(){
				$j(this).empty();
			});
			if ($o.wizNew.addcell){
				$o.wizAddCell.close((md)?"wesc":"done");
				return;
			}
			$o.wizNew.step=0;
			if (md=='esc') $o.cancelInfo();
			if (refresh) $o.showCell();
		}
		function setText(){
			$o.wizNew.type=0;
			jQSt.html($o.jTmp._templates.text_step.get({type:0,typeName: $o.type[0].tip,direct:$o.wizNew.direct}, [], document.body)).oDecoButton();
			var d=($o.wizNew.direct)?-24:0,fmInfo = document.frmInfoText;
			$o.wizNew.height = [(mode=="new")?194:198, 214+d, 160+d,371+d,366+d];
			if (typeof fmInfo.hname == 'undefined') fmInfo.value = $o.wizNew.hname = $o.toNanashi("");
			//Step.2
			$j('#oIW_btnWrite', jQSt).click(function(){if (!$o.validateText()) jQW.oWizard(2, 3, $o.wizNew);});
			$j('#oIW_btnURL', jQSt).click(function(){jQW.oWizard(2, 5, $o.wizNew);});
			$j('#oIW_btnFont', jQSt).click(function(){jQW.oWizard(2, 4, $o.wizNew);});
			$j('#oIW_btnCancel', jQSt).click(function(){if ($o.wizNew.direct) diagClose("esc"); else jQW.oWizardBack(2, 1, $o.wizNew);});
			$j(".oHide").hide();
			$j(".btnEsc").click(function(){diagClose("esc");});
			$j('.oDiag_btnDoneCancel', jQSt).click(function(){jQW.oWizardBack(3, 2, $o.wizNew);});
			$j(".oDiag_btnDone",jQSt).click(function(){
				if ($o.wizNew.sending) return;
				$o.wizNew.sending = true;
				$o.wizNew.hname = (typeof fmInfo.hname == 'undefined')?"":$o.checkNanashi(fmInfo.hname.value,true);
				$j(".buttonLine",jQW).oInputDisable(true);
				$o.addInfo(null,function(){diagClose();});
			});
			$j("#oUp_theme",jQSt).ifShow($o.wizNew.mode!="new");
			$j("#oURL_btnClose",jQSt).click(function(){jQW.oWizardBack(5,2,$o.wizNew);});
			$j("#oURL_btnMake",jQSt).click(function(){
				var url=$o.removeAllTag(document.frmURL.url.value).replace(/\x0D|\x0A| /g,""),
					txt=document.frmURL.text.value,mess="";
				if (!url.match(/^http:\/\//)) url="http://"+url;
				if (!$o.checkBlank(txt)) mess += $o._.vld_reqText;
				if (!$o.checkURL(url)) mess += $o._.vld_url;
				if (mess) {$j("#oURL_error",jQSt).html(mess).end().show();$j("#oURL_tagA",jQSt).val('');}
				else {
					$j("#oURL_error",jQSt).empty().hide();
					$j("#oURL_tagA",jQSt).val('<a href="'+url+'" target="_blank">'+txt+'</a>');
				}
			});
			setFont();
			jQW.oWizard(($o.wizNew.direct)?null:1,2,$o.wizNew);
		}
		function setFont(){
			$j("#oFont_B",jQW).oToggleEffect(false).click(function(){fntMode.b=$o.toggleButton($j(this),{value:fntMode.b,toggle:true});});
			$j("#oFont_I",jQW).oToggleEffect(false).click(function(){fntMode.i=$o.toggleButton($j(this),{value:fntMode.i,toggle:true});});
			var jQC=$j("#oFont_RGB",jQW),jQA=$j("#oFont_tag",jQW);
			$j("#oFont_error",jQW).empty();
			$j("#oFont_btnMake",jQW).click(make);
			$j("#oFont_btnClose",jQW).click(function(){jQW.oWizardBack(4,2,$o.wizNew);});
			$o.wizNew.colors=$j(".oFontCol",jQC).click(color).map(function(){return $j(this).css("background-color");});
			function color(){
				$j(".oFontCol",jQC).css("border-color","#111");
				var clkRGB=$j(this).css("background-color");
				if (clkRGB!=fntRGB) {fntRGB=clkRGB;$j(this).css("border-color","#AAA");} else fntRGB=null;
			}
			function make(){
				var err=null,style="";
				if (fntMode.b) style="font-weight:bold;";
				if (fntMode.i) style+="font-style:oblique;";
				if (fntRGB!=null) style+="color:"+fntRGB+";";
				if (err) {$j("#oFont_error").html(err);return;}
				var tag=$o.removeAllTag(document.frmFont.text.value);
				if (style) tag='<font style="'+style+'">'+tag+'</font>';
				jQA.val(tag);
			}
		}
		function setUpload(type){
			var nW = $o.wizNew;
			nW.type=type;
			nW.ext=(type== 2) ? $o.ext[0] + "," + $o.ext[1] : $o.ext[type];
			nW.hname = $o.toNanashi("");
			var ext="「"+((type== 2) ? $o.ext[0] + "」、「" + $o.ext[1] : $o.ext[type])+"」",d=(nW.direct)?-24:0;
			jQSt.html($o.jTmp._templates.upload_step.get({mode:nW.mode,type:type,typeName:$o.type[type].tip,ext:ext,direct:nW.direct}, [], document.body)).oDecoButton();
			jQSt.oInputDisable(true);
			var m=$o._.cellInfo,fm=document.frmUpload;
			nW.height=[203, (type==3?416:380)+d, 229+d, 160+d];
			var ah=(type==3)?245:218;
			switch (mode){
				case "new":
					nW.height=[203,453,229+d,305];
					ah=263;
					break;
				case "replace":case "subrpl":
					nW.height[1]=255+d;
					ah=59;
					break;
			}
			$j("#oUp_area").height(ah);
			nW.grid=0;
			$j('#oUp_btnCancel', jQSt).click(function(){
				if (nW.direct) diagClose("esc");
				else {
					$j().validation("remove");
					jQW.oWizardBack(2, 1, nW);
				}
			});
			fm.filename.value="";
			$j('#oUp_inpFile').change(function(){fm.filename.value=fm.file.value;});
			if (type==7) fm.banner.value = "";
			if (type==3) {
				fm.subfilename.value="";
				$j('#oUp_inpSub', jQSt).change(function(){fm.subfilename.value=fm.subfile.value;});
				$j("#oUp_sub").addClass((nW.direct)?"oSubDirect":"oSubNew");
			}
			if (type==2){
				$j("#oUp_btnGridNormal", jQSt).oToggleEffect(true).click(function(){
					nW.grid=0;
					$j(this).oToggleEffect(true);
					$j("#oUp_btnGridFree").oToggleEffect(false);
					$j("#oUp_btnGridOneCell").oToggleEffect(false);
					$j("#oUp_btnGridInfo").html(m[0]);
				});
				$j("#oUp_btnGridFree", jQSt).oToggleEffect(false).click(function(){
					nW.grid=-1;
					$j(this).oToggleEffect(true);
					$j("#oUp_btnGridNormal").oToggleEffect(false);
					$j("#oUp_btnGridOneCell").oToggleEffect(false);
					$j("#oUp_btnGridInfo").html(m[1]);
				});
				$j("#oUp_btnGridOneCell", jQSt).oToggleEffect(false).click(function(){
					nW.grid=1;
					$j(this).oToggleEffect(true);
					$j("#oUp_btnGridNormal").oToggleEffect(false);
					$j("#oUp_btnGridFree").oToggleEffect(false);
					$j("#oUp_btnGridInfo").html(m[2]);
				});
				$j("#oUp_btnGridInfo").html(m[0]);
			}else{
				$j("#oUp_btnGridOneCell", jQSt).oToggleEffect(true);
				$j("#oUp_btnGridInfo").html(m[2]);
			}
			//fm.filename.value="C:\Toco Toucan.jpg";
			//fm.category.value="1";
			//fm.tension1.value="1";
			//fm.tension2.value="1";
			//fm.doing.value="1";
			//fm.title.value="ゾウ";
			//fm.info.value="ゾウについておしえてください";
			$j("#oUp_btnUpload").click(function(){
				var fpath,fname,text,isNew=(nW.mode=="new"),fm=document.frmUpload;
				if (type==7){
					fpath=null;
					fname=null;
					text=fm.banner.value;
					fname;
				}else{
					fpath=fm.file.value;
					fname=fpath.split(/[\\\/]/).pop();
					text=null;
				}
				fm.type.value=type;
				if (nW.sending) return;
				if ($j().validation("error")) return;
				if ($o.validateUpload(jQW, nW.type,nW.ext)) return;
				$j().validation("remove");
				$j(".buttonLine",jQW).oInputDisable(true);
				$j.extend(nW,{
					hname:(typeof(fm.hname)=="undefined")?"":$o.checkNanashi(fm.hname.value,true),
					categoryId:(isNew)?Number(fm.category.value):0,
					sending:true,
					filename:fname,
					text:text
				});
				if (isNew) $j.extend(nW,$o.themeCd(fm));
				if (nW.hasParam){
					nW.title=$o.maxLength($o.removeAllTag(fm.title.value),25);
					nW.titleInfo=$o.cr2br($o.maxLength($o.removeAllTag($o.trim(fm.info.value)),200));
				}
				if (type==7) {
					var tmp = $j("body").append('<div id="oTemp" style="position:absolute;filter:alpha(style=0,opacity=0);opacity:0;">'+fm.banner.value+'</div>')
					.find("#oTemp");
					fm.width.value=tmp.width();
					fm.height.value=tmp.height();
					tmp.remove();
					send();
				}else send();
				function send(){
					$j(fm,jQSt).unbind('submit').submit(function(){
						$o.startProgress();
					}).submit();
					jQW.oWizard(2,3,nW);
				}
			});
			$j("#oUp_btnDone").click(function(){
				if ($o.wizNew.mode=="new") location.href=$o.newUrl+$o.tp.coinCd;
				else diagClose();
			});
			if ($j.browser.msie) $j("#oUp_txtTitle input").attr("maxlength","50");
			$j(".oHide").hide();
			$j(".btnEsc").click(function(){diagClose("esc");});
			jQW.oWizard(($o.wizNew.direct)?null:1,2,$o.wizNew,function(){
				$j("#oUp_form").validation({extension:{isFix:true}});
			});
		}
	},
	validateText:function(){
		var jE=$j("#oIW_error > div").empty(),m="",
		fmInfo=document.frmInfoText,text=$o.trim(document.frmInfoText.text.value);
		fmInfo.text.value=text;
		if (typeof fmInfo.hname != 'undefined') {
			var hn = $o.checkNanashi(fmInfo.hname.value);
			if (typeof(hn)=="object") v(hn.err); else fmInfo.hname.value=hn;
		}
		text=$o.removeTag(text,$o.wizNew.colors);
		var a=text.match(/<a.*?>/ig),r=text.match(/href *= *["|']/ig),
			al=(a)?a.length:0,rl=(r)?r.length:0,
			cl=$o.checkClosingTag(text),
			ch=$o.countChrOnly(text);

		if ((fmInfo.text.value!=text)||((al==0)&&(rl>=1))||(cl)) v($o._.vld_illegalTag);
		else if (text.length==0) v($o._.vld_reqInfo);
		if (ch.zenkaku>180) v($o._.vld_maxInfo.info,[ch.zenkaku]);
		if ((al>1)||(rl>1)) v($o._.vld_AtagOnly1,Math.max(al,rl));
		if ((al==1)&&(rl==1)) if (!$o.checkURL({tag:text})) v($o._.vld_url);
		jE.html(m);
		if (m!="") jE.parent().fadeIn("slow");
		return (m!="");
		function v(w,a){m+=$o.err(m,w,a);}
	},
	validateUpload:function(jQV,md,arr){
		if (!arr) var ckext=$o.ext; else var ckext=arr.split(",");
		var fm = document.frmUpload,jE=$j("#oUp_error > div",jQV).empty(),m="",t=$o._.title,ti=$o._.titleInfo,file,ext;
		if (typeof fm.hname != 'undefined'){
			var hn=$o.checkNanashi(fm.hname.value);
			if (typeof(hn)=="object") v(hn.err); else fm.hname.value=hn;
		}
		if (md==7){
			if ($j.isEmpty(fm.banner.value)) v($o._.vld_reqBannerTag);
		}else{
			ext=$o.fileExt(fm.file.value);
			if (ext.length==0)
			v((ext.length==0)?$o._.vld_illegalFileType:
					(($j.inArray(ext, ckext)==-1)?$o._.vld_illegalFileType:""));
		}
		if (md==3) {
			var subext=fm.subfile.value.match(/\..*$/);
			if (subext) {
				subext=subext[0].substr(1).toLowerCase();
				if ((subext!=$o.ext[0])&&(subext!=$o.ext[1])) v($o._.vld_illegalBGType);
			}
		}
		var wk="",title,info;
		if ($o.wizNew.hasParam){
			title=fm.title.value;info=fm.info.value;
			v($o.checkMaxLength(title,$o._.vld_maxTitle))
			v($o.checkMaxLength(info,$o._.vld_maxTitleInfo));
			wk="";
			if (title.match(/<.*?>/)) wk=t;
			if (info.match(/<.*?>/)) wk+=(wk!="")?",&nbsp;":""+ti;
			v($o._.vld_illegalTag,[wk]);
		}
		jE.html(m);
		if (m!="") jE.parent().fadeIn("slow");
		return (m!="");
		function v(w,a){m+=$o.err(m,w,a);}
	},
	err:function(m,w,a){
		if (a) w = ($j.isEmpty(a[0]))?"":$o.printVal(w, a);
		if ($j.isEmpty(w)) return "";
		return (m!=''?'<br>':'')+'*&nbsp;'+w;
	},
	hasSubContent:function(){
		return ($o.wizNew.type==3)&&(document.frmUploadSub.file.value);
	},
	startProgress:function(){
		$j("#oUp_prtTitle").html($o.wizNew.title);
		//if (($o.wizNew.mode=="sndchg")||($o.hasSubContent()&&($o.wizNew.mode!="sndsub"))){
		//  $j("#oUp_prtInfo").html("背景画像アップロード中");
		//  $j("#oUp_prtFile").html(document.frmUploadSub.file.value.split(/[\\\/]/).pop());
		//}else{
		$j("#oUp_prtInfo").html($o.wizNew.titleInfo);
		$j("#oUp_prtFile").html($o.wizNew.filename);
		//}

		$j('#oUp_progressBar').show("slow");
		$j('#oUp_progressBarText').html('upload in progress: 0%').setTemplate('upload in progress:{$T.a}%');
		$o.wizNew.percent = 0;
		setTimeout("$o.refreshProgress()", 1000);
		return true;
	},
	refreshProgress:function(){
		CoinApi.getUploadStatus($o.updateProgress);
	},
	updateProgress:function(up){
		if ($o.wizNew.error) return;
		if (up.status=="error"){
			$o.wizNew.error=true;
			var err=up.message.match(/^(.*):/);
			$j().oError(err);
			$o.wizEntry.close("esc");
			$o.wizNew.sending = false;
			return;
		}
		var p = Math.ceil((up.bytesRead / up.totalSize) * 100);
		var sec = up.elapsedsec,rate = Math.round(up.bytesRead / (sec + 0.00001)/1024),estimatedRuntime = up.totalSize / (rate + 0.00001);
		if (up.bytesRead==0) p=0;
		$j('#oUp_progressBarText').processTemplate({a:p});
		var jQbar = $j('#oUp_progressBarBoxContent');
		jQbar.css({width:$o.wizNew.percent + '%'}).show().stop().animate({width:p + '%'},1000,function(){
			$o.wizNew.percent = p;
			if (up.status=="dbready"){
				jQbar.stop().css({width:'100%'});
				$o.wizNew.up=up;
				switch ($o.wizNew.mode){
					case "new":
						$j().o.cursor.visible = $o.wizNew.cursor;
						$o.createTopCoin(function(){exitProgress(3,4);});
						break;
					case "replace": case "sub": case "subrpl":
						$o.jQLd.oAjaxMon($o._.saving,true);
						exitProgress(3,4);
						return true;
						break;
					case "portrait":
						CoinApi.addPortrait(function(){
							exitProgress(1,2);
						});
						return true;
						break;
					default:
						$o.jQLd.oAjaxMon($o._.saving,true);
						CoinApi.addCoin($o.setNewCoin(), function(coin){
							if (coin==null) {
								$j().oDialog("error",$o._.err_server['0x204'],"OK");
								$o.wizEntry.close("esc");
								$o.wizNew.sending = false;
							}else $o.addInfo(coin,function(){exitProgress(3,4);});
						});
				}
			}else $o.refreshProgress();
		});
	/*
		if (uploadInfo.status=="dbready"){
		jQbar.stop().animate({width:'100%'},1000,function(){
			$o.wizNew.uploadInfo=uploadInfo;
			switch ($o.wizNew.mode){
				case "new":
				$j().o.cursor.visible = $o.wizNew.cursor;
				$o.createTopCoin(exitProgress);
				break;
				case "replace": case "sub": case "subrpl":
				$o.jQLd.oAjaxMon($o._.saving,true);
				exitProgress();
				return true;
				break;
				default:
				$o.jQLd.oAjaxMon($o._.saving,true);
				CoinApi.addCoin($o.setNewCoin(), function(coin){
					$o.addInfo(coin,exitProgress);
				});
			}
		})
		}else{
		setTimeout('$o.refreshProgress()', 1000);
		}
	*/
		return true;
		function exitProgress(st,to){
			$j("#oWizard").oWizard(st,to,$o.wizNew);
			if ($j.isFunction($o.wizNew.closefn)) $o.wizNew.closefn();
		}
	},
	favorite:function(md,cd,fn){
		if ($j.isEmpty(cd)) cd = $o.nowTop.coinCd;
		CoinApi.favorite(md,cd,function(ok){
			if (ok) {
				$j().oDialog("","Done.",((md=="delete")?$o._.diag_favDeleted.titl:$o._.diag_favorite.title),$o._.ok);
				if ($j.isFunction(fn)) fn();
			}else{
				$j().oDialog("error","Error!",((md=="delete")?$o._.err_favDelted.title:$o._.err_favorite.title),$o._.ok);
				if ($j.isFunction(fn)) fn();
			}
		});
	},
	infoWrite:function(){
		$o.checkReadOnly(null,function(){$o.wizEntry();});
	}
	};
})();

(function() {
	$j.extend({
		inherit:function(subClass, superClass){
			function copy_undef_properties(src, dest){for (var prop in src) if (typeof(dest[prop]) == "undefined") dest[prop] = src[prop];}
			copy_undef_properties(superClass.prototype, subClass.prototype);
		},
		isIE6:function(){
			var vn=$j.browser.version.match(/\./),v=Math.floor(RegExp.leftContext);
			return (($j.browser.msie)&&(v<7));
		},
		IE6form:function (C){
			if($o.IE6){jQuery("form").ifShow(C);}
		},
		isEmpty:function(v){
			return (v==null||v=="");
		},
		isUndef:function(v){
			return (typeof window[v] == 'undefined');
		},
		onPageTop: function(n){
		    var href= location.hash; 
		    var t = $j(href == '#top'||n>=0 ? 'body' : href); 
			if (t.size()) {
				var top = n>=0 ? n:t.offset().top;
				$j($j.browser.safari ? 'body' : 'html').animate({
					scrollTop: top
				}, 800, 'swing');
			}
			return false;
		}
	});
	$j.fn.extend({
		oLoadTemplate:function(url){
			if (!$o) $o=null;
			if (!url) url="template/dialog.tpl";
			url=location.pathname.match(/\/.*?\//)[0]+url;
			$o.jTmp =$j.createTemplateURL(url,null, {filter_data:false});
			$j(this).setTemplateURL(url).processTemplate();
			if (typeof $o.jTmp._templates.pageDef != 'undefined') $o._= $j.extend(eval("({"+$o.jTmp._templates.pageDef.get({},{},document.body)+"})"),$o._);
			return this;
		},
		innerShow:function(sl){
			if (!$j(this).show().is(":has(.ui-slider-inner)")){
				var hl = $j(".ui-slider-handle",this).wrap("<div class='ui-slider-inner'></div>");
				var inner = $j(".ui-slider-inner",this);
				if ($j(this).height()>$j(this).width()){
					inner.css({top:hl.height()}).height(inner.height()-hl.height());
				}else{
					inner.width(inner.width()-hl.width());
				}
			}
			return this;
		},
		oWordSelect:function(e,ui,fn){
			if ($j(e.target).is("input,textarea,select")) return;
			var win,key;
			if ($j.browser.msie){
				window.focus();
				sel = document.selection.createRange();
				key = sel.text;
				sel.setEndPoint("EndToStart", sel);
				sel.select();
			}else{
				sel = ($j.browser.opera)?document.getSelection():window.getSelection();
				key = (sel.rangeCount==0)?"":sel.getRangeAt(0).toString();
				sel.collapse(document.body, 0);
			}
			if (key!=""){
				key=key.replace(/<.*?>/g, "");
				if (key.length>40) return;
				_o.player.div.hide();
				var jQW=$j("#oWizard");
				var jQR=$j(".wsResult",jQW);
				if (typeof $wS == 'undefined'){
					$wS =$j.createTemplateURL($o.baseDir+"template/wordsearch.tpl",null, {filter_data:false});
				}
				jQW.setTemplate($wS);
				$j("input",jQW).mouseup(function(){return null;});
				CoinApi.getSearchResult(key,function(result){
					result.keyword=key;
					jQW.processTemplate(result).oDecoButton()
					.oWizard(null,1,{mode:"",step:1,modal:["on"],width:478,height:[400]});
					$j("#oWS_btnSearch").click(function(){
						key=document.frmKeySearch.keyword.value;
						CoinApi.getSearchResult(key,function(result){
							showResult(result);
						});
					});
					$j("#oWS_btnClose").click(function(){jQW.oWizard("close");});
					$j("#oWS_btnSite").click(function(){
						window.open(result.searchEngineUrl,null,"");
					});
					showResult(result);
				});
			}
			function showResult(result){
				$j(".wsResult",jQW).html($wS._templates.result.get(result,[],document.body)).oDecoButton();
			}
		},
		oHelpLayer:function(cd,opt,fn){
			var self=$j(this);
			if (!cd) cd=self.attr("id");
			if (cd==null) return;
			if (typeof $hl != 'undefined'){ show(cd,fn);return;}

			if (typeof $o == 'undefined') new coIn();
			$hl=$j('#oHLayer_window');
			if ($hl.length==0){
				$hl=$j("body").append(
				'<div id="oHLayer" class="oHLayer">'+
					'<div id="oModal" class="oHLayerModal"></div>'+
					'<div id="oHLayer_window" class="oHLayerWindow">'+
						'<div id="oHLayer_disp"></div>'+
					'</div>'+
				'</div>').find("#oHLayer_window");
				$hl.layer=$j("#oHLayer").hide();
				$hl.disp=$j("#oHLayer_disp",$hl.layer);
				if ((!opt)||(opt.mode!="keep")){
				$j(".oHLayerClose",$hl).click(function(){
					$j($hl).fadeOut(100,function(){$j($hl.layer).remove();});
					B(false);
				});
				};
			}
			show(cd,fn);
			function show(cd,fn){
				//if ($hl.data.infos==null) return;
				CoinApi.getHLayer(cd,function(hl){
				if (hl==null) {
					$j($hl.layer).remove();
					return;
				}
				$hl.data=hl;
				var output="",ei=hl.infos,el=ei.length-1;
				for(var n=0;n<=el;n++){
					var i=ei[n];
					output+='<div id="hlText'+i.hlayerInfoId+'" class="hlText '+((i.button)?('oHLayer'+i.button):'')+'" style="position:absolute;left:'+i.xpx+'px;top:'+i.ypx+'px;">'+i.information+'</div>';
				}
				$hl.disp.html(output);
				$hl.find(".oHLayerClose").click(function(){
					$j(this).oBlink('clear');
					$hl.layer.fadeOut(100).remove();
					delete($hl);
				}).oBlink();
				$hl.css({left:hl.leftMargin});
				if (typeof $hl.layer != 'undefined') {
					$j("#oHLayer .oHLayerModal").width($j(window).width()).height($j(window).height());
					$hl.layer.fadeIn($o.noIE(180));
				}
				if ($j.isFunction(fn)) fn();
				});
			}
		},
		oEnquete:function(opt){
			var self=$j(this),cd,md=null,jQW;
			if (self.hasClass("oEqButton")){
				md="float";
				var jQL=$j("#oAEq_layer"),jAE=self.parents(".oEq"),o=jAE.offset(),dis="oEqDisable";
				if (jAE.length==0) return this;
				if (typeof $o == 'undefined') new coIn();
				if (jQL.length==0){
				jQL=$j("body").append("<div id='oAEq_layer'></div>").find("#oAEq_layer");
				}
				var tpl=$j.createTemplateURL("/ip/template/anywhereenquete.tpl",null, {filter_data:false});
				jQL.setTemplate(tpl);
				var opt={cd:jAE.attr("id")};
			}
			CoinApi.getEnquete(opt.cd, function(enq){
				for (var n=5; n>0; n--){if (enq.choices[n].choice!="") break;};
				if (md=="float") {
				jQL.processTemplate(enq).oModal("on").oDecoButton();
				fm=document.frmAEnquete;
				jQW=$j(".oEqWindow",jQL);
				$j("#oAEq_area").css({left:o.left,top:o.top}).width(jAE.width()).height(jAE.height());
				var wd=$j(window),y=wd.scrollTop()+((wd.height()-jQW.height())>>1),x=(wd.width()-jQW.width())>>1;
				jQW.height(jQW.height()-(5-n)*20).css({left:x,top:y});
				} else {
				jQW=self.html($o.jTmp._templates.enquete.get(enq,[],document.body)).oDecoButton();
				fm=document.frmEnquete;
				}
				jQP=$j(".oEqBtnPost",jQW).addClass(dis);
				jQW.find(".oEqChoice").click(function(e){
					$j(this).parent().find(".oEqChoice").removeClass("oEqChoiceOn").end().end()
					.addClass("oEqChoiceOn");
					jQP.removeClass(dis);
					var n=Number($j("input",this).attr("value"))-1;
					fm.answare[n].checked=true;
				}
				).end()
				.find(".oEqBtnClose").click(function(){close();}).end()
				.find(".oEqBtnPost").click(function(){
				if (!jQW.hasClass(dis)) post(enq);
				}).end();
				if ($o.cookieRead({key:"enq_"+enq.enqueteId})){
				jQW.oDivDialog({text: $o._.atn_answeredEnq,ok:$o._.ok,okClick: function(){close();}});
				}
				if (md!="float") {
				$o.commPanel.show(365,jQW);
				}
			});
			function post(enq){
				for (var n=0; n<6; n++){if (fm.answare[n].checked) break;};
				$j().oDialog("keep",$o._.diag_sendEnq,$o._.yes,function(){
					CoinApi.postEnquete({enqueteId:enq.enqueteId,choiceId:enq.choices[n].choiceId},function(){
						$o.cookieWrite({key:"enq_"+enq.enqueteId},"true");
						$j().oDialog("",$o._.diag_doneEnq,$o._.ok,function(){close();});
					});
				},$o._.cancel);
			}
			function close(){
				if (md=="float"){
					jQL.oWizard("close").remove();
					delete $aE;
				}else{
					$o.commPanel.hide();
				}
			}
		},
		oDivDialog:function(opt) {
			var self=this;
			if (opt=="close"){
				$j(".oModalDiv",self).remove();
				return self;
			}
			var opt=$j.extend({text:"",ok:$o._.confirm,okfn:null},opt);
			if ($j(".oModalDiv",self).length==0) self.append($o.jTmp._templates.divDialog.get({text:opt.text,button:opt.ok},[],document.body));
			var d=$j(".oModalDiv",$j(self)).show();
			if (opt.okClick) d.find(".oDivDiagBtnOK").click(function(){
				opt.okClick();
				$j(".oModalDiv",self).remove();
				return self;
			});
			return self;
		},
		ifShow:function(ck,speed,fn) {
			if (ck)  $j(this).show(speed,fn); else $j(this).hide(speed,fn);
			return this;
		},
		isShow:function(){
			return ($j(this).css("display")!="none");
		},
		oModal:function(mode){
			var jQM=$j(this),id;
			if (!jQM[0].id) {jQM=$j("#oModal");id=jQM[0].id;};
			var jQ=(jQM.is(".oModal"))?jQM:jQM.children(".oModal");
			var z=jQM.css("z-index"),md=mode;
			if (typeof(md)=="object") md=mode.modal[mode.step-1];
			if ((!md)||(md=="off")) {jQ.hide(); return this;}
			switch (md){
				case "grid":z=900;break;
				case "config":z=1099;break;
				default:
					if ((z=="auto")||(!z)||(z==900)) z=1008;
			}
			jQM.width($j().width()).height($j().height()).css("zIndex",z);
			jQ.show();
			if (($j.browser.msie) && (id=="oModal")) $o.dialogIE6();
			return this;
		},
		oBlink:function(on,sw){
			var me = $j(this),v=me.get(0);
			if (on=="clear"){
				var tm = $j.data(v,'int');
				if (!$j.isEmpty(tm)){
					clearInterval($j.data(v,'int'));
					var ql = me.queue().length;
					for (var i = 0; i < ql; i++) {
						me.stop();
					}
				}
				me.fadeTo(1,1,function(){if (!sw) $j(this).hide();});
				return this;
			}
			var on = 1500,opa = 1,opa2 = 0;
			$j.data(v,'blink',true);
			me.show().fadeTo(1,opa);
			var tm = setInterval(function(){
				var b = $j.data(me.get(0),'blink');
				$j.data(me.get(0),'blink',!b);
				me.fadeTo(on-100,(b)?opa2:opa);
			},on);
			$j.data(v,'int',tm);
			return this;
		},
		oDecoButton:function(){
			var j=$j(this);
			if (typeof $o == 'undefined') $o={};
			if (!$o.cssDir) $o.cssDir=location.pathname.match(/\/.*?\//)[0]+"css/";
			$j("form",j).submit(function(){return false;});
			(j.hasClass('btnDark')?j:$j(".btnDark",j)).wrapInner('<span class="decoText"></span>').prepend('<img src="'+$o.cssDir+'btndark.png" class="decoImg">').hover(function(){$j(this).addClass("decoHover");},function(){$j(this).removeClass("decoHover");});
			(j.hasClass('btnLight')?j:$j(".btnLight",j)).wrapInner('<span class="decoText"></span>').prepend('<img src="'+$o.cssDir+'btnlight.png" class="decoImg">').hover(function(){$j(this).addClass("decoHover");},function(){$j(this).removeClass("decoHover");});
			return this;
		},
		oToggleEffect:function(sw){
			var op=(sw)?100:40;
			$j(this).css({filter:"alpha(stfyle=0,opacity="+op+")",opacity:Number(op/100)});
			return this;
			},
		oHover:function(){
			if (!$j(this).hasClass("oDivHover")) $j(this).append('<div class="oDivHover"></div>');
			$j(this).hover(function(){
				$j(this).find('.oDivHover').show().fadeTo(160,0.5);
			},function(){
				$j(this).find('.oDivHover').fadeOut(160,0,function(){$j(this).hide()});
			});
		},
		oClick:function(fn){
			$j(this).find("button").attr("onclick",fn);
			return this;
		},
		oWizard:function(divout,divin,mode,callback){
			var jQ=$j(this).oInputDisable(true),jQW=$j(".oWizDiag",jQ);
			$j(".oAlert",jQW).hide();
			if (divout=="close"){
				jQ.fadeOut($o.noIE(200),function(){
					jQW.empty();
				});
				if ($j.isFunction(callback)) callback();
				return jQ;
			}
			jQW.find(".oDisable").show();

			var m,sm="slide",h=((mode) && typeof mode.height != 'undefined')?mode.height[divin-1]:240;
			if (divout!=null){
				$j(".o_"+divout +"i",jQ).fadeOut($o.noIE("fast"),function(){return open();});
			}else return open();

			function open(){
				if (mode) {
					jQ.oModal(mode.modal[divin-1]);
					if (divin != null) mode.step=Number(divin);
					m=typeof(mode.offset);
				}
				jQ.show();

				if (divin==null) return jQ;

				var c={height:h},oc=".o_"+divin,on=$j(oc,jQW),oi=$j(oc+"i",jQW);
				$j(oc+"o",jQ).hide();
				oi.show();
				mode.step=divin;
				if (m=="object"){
					//$j.extend(c,{left:mode.offset.left,top:mode.offset.top});
					jQW.css(mode.offset);
					if (typeof(mode.offset.bottom)=="number") {jQW.css("top",null);}
					if(jQW.is(".oFixDiag")) jQW.addClass("oFixDiag");
				}else{
					c=$j.extend(c,jQW.oCenterOffset(c),c);
					var o=jQW.offset();
					if (((o.left==0)||(o.top==0)) && typeof mode.offset == 'undefined'){jQW.css({left:((o.left==0)?c.left:o.left),top:(c.top+h)}).height(0);sm=null;}
				}
				if (mode.width) {if (divout==null) jQW.width(mode.width); else c.width=mode.width; }
				on.show();
				if (((divout==0)||(divout==null))&&(divin==1)) {
					$j(".oWizHide,.oHide").hide();
					if (divout==0) $j(".o_0",jQ).show();
					jQW.css(c).show("slide",{ direction: "down" },"normal",function(){
						if (divout==0) $j(".o_0",jQ).show();
						jQW.find(".oDisable").hide();
						$j(this).oInputDisable();
						if ($j.isFunction(callback)) callback();
					});
					return jQ;
				}
				if (mode) {
					jQW.animate(c,400);
					setNext();
				}else{
					on.slideDown("fast",function(){
						jQW.find(".oDisable").hide();
						$j(this).oInputDisable();
						if ($j.isFunction(callback)) callback();
					});
				}
				return jQ;
			}
			function setNext(){
			$j(".o_"+divin,jQ).show("slide",{ direction: "down" },500,function(){
				jQW.find(".oDisable").hide();
				$j(this).oInputDisable();
				mode.wizard==false;
				if ($j.isFunction(callback)) callback();
			});
			}
		},
		oURLParam:function(l){
			var QS = new Array;
			if (!l){
			var l=(location.hash.length>1)?location.hash.substr(1):((location.search.length>1)?location.search.substr(1):"");
			}
			if (l.length > 1) {
			var m_Array = l.split("&");
			for (idx in m_Array) {
				var w=m_Array[idx].split("=");
				QS[w[0]]=w[1];
			}
			}
			var p = (location.href.match($o.playerPath+"(.*?)($|#)"));
			if (p!=null) QS.o = p[1];
			if ((QS.c!==null)&&(typeof(QS.c)=="string")) delete QS.o;
			else if (p!=null) QS.o = p[1];
			QS.id=(QS.o)?QS.o:QS.c;
			if (!QS.n) QS.n=-1;
			return QS;
		},
		oInputDisable:function(md){
			//jQW.find(".oDisable").hide();
			//$j("button,input,textarea",$j(this)).attr("disabled",(md)?"disabled":null);
			return this;
		},
		oWizardBack:function(divout,divin,mode){
			var jQ=$j(this).oInputDisable(true),jQW=$j(".oWizDiag",jQ),p=jQ.offset();
			jQ.find(".oDisable").show();
			$j(".oAlert",jQW).hide();
			if(typeof mode.height != 'undefined') var h=mode.height[divin-1];
			if (divout != null) $j(".o_"+divout).hide();//$j(".o_"+divout).fadeOut($o.noIE("fast"));
			if (mode){
			if (divin != null) mode.step=Number(divin);
			jQ.oModal(mode.modal[divin-1]);
			m=typeof(mode.offset);
			}
			if (divin != null) {
			var jQo=$j(".o_"+divin+"o",jQ);
			if (jQo.length!=0){
				jQo.fadeOut($o.noIE("fast"),function(){$j(".o_"+divin+"i").slideDown("fast",setNext(this));});
			}else{
				$j(".o_"+divin+"i",jQ).slideDown("fast",function(){
				setNext(this);
				});
			}
			}
			return jQ;
			function setNext(self){
			var c={height:h};
			if (m=="object"){
				jQW.css(mode.offset);
				if (typeof(mode.offset.bottom)=="number") {jQW.css("top",null);}
			}else
				c=$j.extend(jQW.oCenterOffset(c),c);
			if (mode) $j(".oWizDiag",jQ).show().animate(c,240,function(){
				jQW.find(".oDisable").hide();
				$j(self).oInputDisable();
			});
			}
		},
		oCenterOffset:function(s,p){
			var j=$j(this),b,jw=$j(window),w,h;
			w=j.width();h=j.height();
			if (s) {
			if (s.width) w=s.width;
			if (s.height) h=s.height;
			}
			if (!p) return {left:((jw.width()-w)>>1),top:jw.scrollTop()+((jw.height()-h)>>1)};
			if (p.$j) {b=p.offset();b.width=p.width();b.height=p.height();}
			else {
			if (!p.width) p.top=0;
			if (!p.left) p.left=0;
			if (!p.top) p.top=0;
			if (!p.left) p.left=0;
			}
			var t=($j(this).is(".oFixV"))?0:(p.top+((p.height-h)>>1));
			var l=($j(this).is(".oFixH"))?0:(p.left+(p.width-w)>>1);
			if (!p) return {top:t,left:l};
		},
		oDialog:function(md,st,sm,ok,okProcess,cancel,cancelProcess){
			var self=$j(this),title=st,mess=sm,t=typeof(title),css="oD",csst="oDT"
				,errcssW={backgroundColor:"#333333",border:"4px double #686868"},errcssM={textAlign:'left',color:"#F0F0F0",background:"#222222 none repeat scroll 0 0"};
			if (t=="object"&&t!="undefined"){
				mess=st.info;
				title=st.title;
				cancelProcess=cancel;
				cancel=okProcess;
				okProcess=ok;
				ok=sm;;
			}
			if (md == "wait" && $j.isFunction(sm)) {
				okProcess = sm;
				sm = "";
			}
			if (!mess){
				mess=title;
				title="";
				errcssM.textAlign='center';
			}
			if (md=="refresh"){
				$j("#oWiazrd,#oDialog,#oModal").width($j().width()).height($j().height());
				$j("#oDiag_window,#oWiz_window,#oHelp_window").each(function(){
					if ($j(this).is(".oFixDiag")) return;
					var o=$j(this).oCenterOffset();
					$j(this).css(o);
				});
				return this;
			}
			if ($j("#oDialog").length==0) $j(document.body).prepend('<div id="oDialog"><div id="oDiag_Modal" class="oModal"></div><div id="oDiag_window" class="oDiag"></div></div>');
			$o.jQDg=$j("#oDialog");
			if (!$o.jTmp){$o.jQDg.oLoadTemplate();}
			switch (md){
				case "error":
					css="oDx";
					csst="oDxT";
					errcssW={backgroundColor:"#330000",border:"4px double #680000"};
					errcssM={textAlign:'left',color:"#FF4070",background:"#220000 none repeat scroll 0 0"};
					break;
				case "!":css="oDc"; csst="oDcT";break;
				case "wait":
					ok = "";
			}
			var okw=4+$o.countChr(ok).zenkaku,cx=okw+0.5,cw=0;
			if (cancel!=null) {
				if (cancel=="") cancel=$o._.cancel;
				cw=$o.countChr(cancel);
				cw=cw.zenkaku+4;
			}else{
				cancel="";
			}
			var jW=$j("#oDiag_window",$o.jQDg);
			if (jW.isShow()){
				$j('.oMessage span',jW).oBlink('clear');
				jW.oModal("off").fadeOut($o.noIE(360),show);
			}else show();
			function show(){
				if (mess.length<40) errcssM.textAlign='center';
				jW.html($o.jTmp._templates.dialog.get(
						{title:title,mess:mess,
						titlecss:csst,messcss:css,
						ok:{text:ok,width:okw},
						cancel:{text:cancel,right:cx,width:cw
						}},[],document.body)).css(errcssW)
						.find(".oMessage").css(errcssM).end()
						.oDecoButton().hide();
				var jM=$j('.oMessage span',jW),jOk=$j("#oDiag_btnOk",jW),jNo=$j("#oDiag_btnCancel",jW);
				if (md=='wait') {
					jM.parent('.oMessage').css({textAlign:'center'}).end().oBlink();
					if ($j.isFunction(okProcess)) okProcess();
				}
				jOk.click(function(){
					jOk.unbind('click');jNo.unbind('click');
					var fade=(md=="keep")?jW:$o.jQDg;
					fade.oModal("off").fadeOut($o.noIE(360),function(){
						jM.oBlink('clear');
						if ($j.isFunction(okProcess)) okProcess();
					});
				});
				jNo.click(function(){
					jOk.unbind('click');jNo.unbind('click');
					$o.jQDg.oModal("off").fadeOut($o.noIE(360),function(){
						jM.oBlink('clear');
						if ($j.isFunction(cancelProcess)) cancelProcess();
					});
				});
				$o.jQDg.oModal("on").show();
				var o=jW.oCenterOffset();
				jW.css(o).fadeIn($o.noIE(240));
			}
		},
		oError:function(err){
			err=(err==null)?"0X104":err[1];
			err = (typeof($o._.err_server[err])!="undefined")?$o._.err_server[err]:$o._.err_server['0x104'];
			$j().oDialog("error",err,"OK");
			$o.jQLd.oAjaxMon($o._.saving,false);
		},
		oHelper:function(){
			$j(".oHelper").click(function(){
			B(true);
			var url=$j(".oHelperImg",this).attr("src");
			var para=$j(".oHelperBtn",this).html();
			if ($j("#oDialog").length==0) $j(document.body).append('<div id="oDialog">');
			var jH=$j("#oDialog").html(
			'<div id="oDiag_Modal" class="oModal"></div>'+
			'<div id="oDiag_window" class="oHelpDiag oFixV"><img src="'+url+'" alt="Site Top Help"></div>'+
			'<div id="btnHelpClose" class="oHelperClose">× Help Close</div>'+
			para
			).show();
			$j(".oHelperClose",jH).click(function(){
				$j(this).oBlink('clear');
				$j(jH).fadeOut(100,function(){$j(this).remove();});
				B(false);
			}).oBlink();
			jH.oModal("on").show();
			var img=$j("img",jQW),io=img.offset();
			var jQW=$j("#oDiag_window").width(img.width*io.left).height(img.height+io.top),o=jQW.oCenterOffset();
			jQW.css(o).fadeIn($o.noIE(180));
			});
		},
		oAjaxMon:function(md,v){
			if (md==null) var md="";
			$j(this).html(md).ifShow(v);
		},
		checkSubmit:function(){
			if($j("div.validationTip:visible").length>0) {
				$j().oDialog('error',$o._.err_invalidForm,$o._.ok);
				return false;
			}else{
				$j(this).unbind('submit').submit();
				return true;
			};
		}

	});

	$j.fn.o=function(_opt,iniCallback) {
		function mouse2screen(e){
		var evt = e ? e : window.event;
		if ( evt.pageX == null && evt.clientX != null ) {
		var e = document.documentElement, b = document.body;
			evt.pageX = evt.clientX + (e && e.scrollLeft || b.scrollLeft || 0);
			evt.pageY = evt.clientY + (e && e.scrollTop || b.scrollTop || 0);
		}
		return point2screen({x:evt.pageX,y:evt.pageY});
		};
		function point2screen(c){
		c.x=c.x-_o.inFrame.div.offset().left;
		c.y=c.y-_o.inFrame.div.offset().top;
		return c;
		}
		function cell2screen(c){
		if (!c) return c;
		if (_o.free){
			c.x=c.cellX*_o.scale; c.y=c.cellY*_o.scale;
		}else{
			c.x=Math.floor(c.cellX*_o.grid.width); c.y=Math.floor(c.cellY*_o.grid.height);
		}
		c=cell2screenSize(c);
		return c;
		}
		function cell2screenSize(c){
		if (_o.free){
			c.width=c.cellW*_o.scale; c.height=c.cellH*_o.scale;
		}else{
			c.width=_o.grid.width; c.height=_o.grid.height;
		}
		return c;
		}
		function screen2point(c){
		if (_o.free){
			c.cellX=c.x/_o.scale;
			c.cellY=c.y/_o.scale;
		}else{
			c.cellX=Math.floor(c.x/_o.scale/_o.grid.cellW);
			c.cellY=Math.floor(c.y/_o.scale/_o.grid.cellH);
		}
		return c;
		}
		function screen2cell(c){
		c=screen2point(c);
		if (_o.free){
			c=screen2cellSize(c);
			return checkHit(c);
		}else{
			c=cell2screen(c);
			c.cellCode=cell2CellCode(c);
			if (c.cellCode==-1) return null;
		}
		return c;
		}
		function screen2cellSize(c){
		if (_o.free){
			c.cellW=Math.floor(c.width/_o.scale);
			c.cellH=Math.floor(c.height/_o.scale);
		}else{
			c.cellW=Math.floor(_o.grid.cellW);
			c.cellH=Math.floor(_o.grid.cellH);
		}
		return c;
		}
		function cellCode2cell(c){
		if (c.cellCode==-1) return c;
		c.cellX=c.cellCode&0xFFFF;
		c.cellY=c.cellCode>>16;
		if (_o.free){
			var hc=$o.cells[c.cellCode];
			if (!hc) return c;
			hc.cellX=c.cellX;hc.cellY=c.cellY;
			c=cell2screen(hc);
		}else{
			c=screen2cellSize(c);
			if ((c.cellX>=_o.grid.countW)||(c.cellY>=_o.grid.countH)) c.cellCode=null; else c=cell2screen(c);
		}
		return c;
		}
		function cellCode2No(code){
		if ((code==-1)||(code==null)||((_o.free)&&(!$o.cells[code]))) return null;
		if (_o.free) return $o.cells[code].cellNo+1;
		else return (code&0xFFFF)+(code>>16)*_o.grid.countW+1;
		}
		function cell2CellCode(c){
		if ((!_o.free)&&((c.cellX<0)||(c.cellY<0)||(c.cellX>=_o.grid.countW)||(c.cellY>=_o.grid.countH))) return -1;
		return (Math.floor(c.cellY)<<16)+Math.floor(c.cellX);
		}
		function getOneCell(){
		var cl;
		if (_o.free) {
			if (($o.cellNo==null)||($o.cellNo.length==0)) return;
			if ($o.cellCount>=1) cl={cellW: $o.cellNo[0].cellW,cellH:$o.cellNo[0].cellH};
			else {_o.oneCell = false; return false;}
		} else cl={cellW:_o.grid.countW,cellH:_o.grid.countH};
		_o.oneCell=checkOneCell(cl);
		return _o.oneCell;

		}

		function checkOneCell(c){
		return (((!_o.free)&&(c.cellW==1)&&(c.cellH==1))||(($o.tp.publicType!=4)&&(_o.free)&&($o.cellCount==1)&&((c.width*c.height)>(_o.width*_o.height*0.8))));
		}
		function redefineCell(c){
		var ncd=cell2CellCode(c),nc;
		_o.oneCell=checkOneCell(c);
		if (_o.oneCell) {
			ncd=0;c.x=0;c.y=0;c.cellX=0;c.cellY=0;ncd=0;c.cellW=_o.imgWidth;c.cellH=_o.imgHeight;
		}
		if (ncd!=_o.cellCode){
			$o.cells[ncd]=$o.cells[_o.cellCode];
			delete $o.cells[_o.cellCode];
		}
		$o.cells[ncd].cellCode=c.cellCode=ncd;
		$o.cells[ncd].cellW=c.cellW;
		$o.cells[ncd].cellH=c.cellH;
		$o.cells[ncd].modified=$o.cells[ncd].modified|2;
		c=cell2screenSize(c);
		setRect(c);
		drawRect(c);
		drawGrid();
		}

		function checkHit(src){
		var hit=null;
		if (!src.cellW) src.cellW=0;
		if (!src.cellH) src.cellH=0;
		src.wx=src.cellX+src.cellW;
		src.hy=src.cellY+src.cellH;
		var n=1;
		for (var i in $o.cells) {
			i=Number(i);
			if ($o.cells[i].modified&4) continue;
			var cl={};
			cl.cellCode=i;
			cl=cellCode2cell(cl);
			cl.wx=cl.cellX+cl.cellW;
			cl.hy=cl.cellY+cl.cellH;
			if (( src.wx>=cl.cellX)&&(cl.wx>src.cellX)&&( src.hy>=cl.cellY)&&(cl.hy>src.cellY)) {
			if (src.cellCode!=i) {hit=cl;hit.no=n;break;}
			}
		}
		return hit;
		}

		function pushCache(coins,ex){
			if (!coins) return;
			if (!$o.cache[coins.coinId]) {
				_o.rect.visible=false;
				$o.targetSw=true;
				var fn={
				cellCode:-2,
				cursorvisible:false,
				cell:{},
				targetSW:true,
				zoom:1,
				zoomct:3,
				history:{},
				gridvisible:_o.grid.visible,
				targetvisible:true
				};
			}else{
				var fn={
				cellCode:_o.cellCode,
				cursorvisible:_o.cursor.visible,
				cell:$o.clone(_o.cell),
				targetSW:$o.targetSW,
				zoom:$o.zoom[$o.zoomct],
				zoomct:$o.zoomct,
				history:_o.history,
				gridvisible:_o.grid.visible,
				targetvisible:_o.target.visible
				};
			}
			$o.cache[coins.coinId]=$j.extend(fn,ex);
		}
		function removeCache(id){
			delete $o.cache[id];
		}
		function popCache(coins,ex){
			var id=coins.coinId;
			if (!$o.cache[id]) pushCache(coins,ex);
			_o.cell=$o.clone($o.cache[id].cell);
			_o.cursor.visible=$o.cache[id].cursorvisible;
			_o.target.visible=$o.cache[id].targetvisible;
			$o.targetSW=$o.cache[id].targetSW;
			setZoom($o.cache[id].zoom);
			$o.zoomct=$o.cache[id].zoomct;
			if ((_o.mode=="print")||(_o.mode=="cover")) return;
			$o.root[$o.root.no].cellCode=setCellCode($o.cache[id].cellCode);
		}
		function onLoadImage(){
			var call=_o.callback;
			_o.callback=null;
			_o.loaded=true;
			//if (_o.mode=="print") _o.img=_o.print[0];
			fitDisplay(_o.disp.width,_o.disp.height);
			_o.fitWidth=_o.width;
			_o.fitHeight=_o.height;
			_o.recommend=gridRecommendSize();
			initCanvas();
			//if ((_o.mode!="view")&&(_o.mode!="adjust")&&(_o.mode!="edit")) popCache(_o.coins);
			//if ($o.cellNo[0]) getOneCell();
			_o.transition=false;
			_o.switching=false;
	
			if ($o) $o.jQLd.oAjaxMon();
			if (typeof(call) == "function") call();
			if (typeof(_o.viewReady) == "function") _o.viewReady();
			openUI();
		}
		function onErrorImage() {
			if ($o) $o.jQLd.oAjaxMon();
			_o.loaded=false;
			$j().oDialog("error",$o._.imageLoad,$o._.confirm);
		}
		function docEvent(href) {
			var option=href.replace(/^[^\?]+\??/,'').replace(/&/g, ',');
			window.open(href, this.rel, option+",width=640,height=480,menubar=no,toolbar=no,status=no,location=no").focus();
		}
		function setWidth(w,h){
		var dw=_o.disp.div.width(),dh=_o.disp.div.height();
		var x=(((_o.disp.width<dw)?dw:_o.disp.width)-w)>>1;
		var y=(((_o.disp.height<dh)?dh:_o.disp.height)-h)>>1;
		_o.grid.canvas.css({position:"absolute",left:0, top:0, width:w, height:h}).attr({width:w, height:h});
		_o.inFrame.div.css({position:"absolute",left:x, top:y, width:w, height:h});
		_o.rect.frame.css({position:"absolute",left:x, top:y, width:w, height:h,zIndex:1005}).hide();
		if (_o.mode=="print") _o.print.css({position:"absolute",left:x, top:y, width:w, height:h}).show();
		_o.inFrame.left=x; _o.inFrame.top=y;
		}
		function setCursor(c,v){
			setCell(c);
			_o.cellNo=cellCode2No(c.cellCode);
			_o.cursor.visible=v;
		}
		function setCursorCellCode(cellCode){
		var cl=cellCode2cell({cellCode:cellCode});
		setCell(cl);
		if ((_o.free)&&(!$o.cells[cellCode])){
			_o.cellCode=_o.cellNo=-1;
			_o.cursor.visible=false;
			return false;
		}
		_o.cellNo=cellCode2No(cellCode);
		_o.cursor.visible=true;
		return true;
		}
		function setCell(c){
		if (typeof(c.cellCode)!="number") return;
		_o.cell.x=c.x;
		_o.cell.y=c.y;
		_o.cellCode=c.cellCode;
		_o.cellNo=c.no;
		_o.cell=c;
		if (!_o.free){
			_o.cell.cellW=_o.grid.cellW;
			_o.cell.cellH=_o.grid.cellH;
			_o.cell.width=_o.grid.width;
			_o.cell.height=_o.grid.height;
		}
		}
		function setCursorFreeCell(c){
		setCell(c);
		_o.cursor.visible=true;
		return true;
		}
		function setRect(c){
		if (typeof(c.cellCode)!="number") c.cellCode=cell2CellCode(c);
		_o.cellCode=c.cellCode;
		_o.cellNo=c.no;
		_o.rect.cell=$o.cloneObject(c);
		_o.rect.frame.show();
		_o.rect.visible=true;
		return true;
		}
		function setAimRect(c){
		var w=$o.o.cellW,h=$o.o.cellH,x=c.x/_o.scale,y=c.y/_o.scale,max=96/_o.scale;
		if (w>max) w=max;
		if (h>max) h=max;
		x-=(w>>1); y-=(h>>1);
		if (x<0) x=0;
		if (y<0) y=0;
		if ((x+w)>_o.imgWidth) x=_o.imgWidth-w;
		if ((y+h)>_o.imgHeight) y=_o.imgHeight-h;
		c.x=Math.floor(x*_o.scale);
		c.y=Math.floor(y*_o.scale);
		c.cellW=Math.floor(w);
		c.cellH=Math.floor(h);
		c.cellX=Math.floor(x);
		c.cellY=Math.floor(y);
		c.width=Math.floor(w*_o.scale);
		c.height=Math.floor(h*_o.scale);
		_o.aim.cell=c;
		return c;
		}
		function fitRect(r){
		r.r=r.srcW/r.width;
		var hr=r.srcH/r.height;
		if (r.r>hr) r.r=hr;
		if ((r.r<1)||(r.strech)){r.width*=r.r; r.height*=r.r;}
		r.x=(r.srcW-r.width)>>1;
		r.y=(r.srcH-r.height)>>1;
		return r;
		}

		function onClick(e) {
			if ((_o.mode=="cover")||(_o.mode=="print")||(_o.mode=="view")||((_o.mode=="adjust")&&(!_o.free))||(!_o.grid.visible)||(_o.oneCell)||(_o.cursor.modal)) return;
			if (_o.dragging) {_o.dragging=false; return;}
			var c=mouse2screen(e);
			if (_o.grid.click) return _o.grid.click(e, c);
			c=screen2cell(c);
			if (c==null){
				if ((_o.mode =="edit")&&(_o.free)) toggleRect(false);
				return;
			}
			if (($o.filter.selected && !$o.filter.cell[c.cellCode])||_o.aim.visible) return;
			if (e.target.className!="cursor"){
				if (_o.free) {
				if ((_o.mode=="adjust")&&(_o.rect.multi)){
					setRect(c);
					drawRect();
					return;
				}
				setCursorFreeCell(c);
				}else setCursor(c, true);
				drawCursor();
			}
			$o.checkInfo(_o.cellCode,true);
		}
		function focusDiv(fid){
		if ((!$o.elements[fid])||($o.id==fid)) return;
		$o.elements[$o.id]=_o;
		$j().o.opt=_o=$o.elements[fid];
		$o.id=fid;
		$o.jQme=$j("#"+fid);
		}
		function draw(){
		if ((!_o.grid.layer)||(_o.loaded==false)) return;
		drawGrid();
		drawCursor();
		}
		function initCanvas(){
			return;
		if (_o.loaded==false) return;
		if (_o.mode!="print"){
		}
		setGrid(_o.grid.countW,_o.grid.countH);
		}
		function fitDisplay(w,h,fit){
		var iw,ih;
		if (!_o.coins.abone) {
			if (_o.img){
			if (_o.mode=="print"){
			iw=_o.print.width();
			ih=_o.print.height();
			}else{
			iw=_o.img.width;
			ih=_o.img.height;
			}
			}else{
			iw=_o.disp.width;
			ih=_o.disp.height;
			}
		_o.imgWidth=iw;
		_o.imgHeight=ih;
		}else{
			iw=_o.imgWidth;
			ih=_o.imgHeight;
		}
		_o.scale=1;
		if ((fit)||(iw>w)||(ih>h)) _o.scale=Math.min((w/iw), (h/ih));
		if (!_o.free) setGrid(_o.grid.countW,_o.grid.countH);
		_o.cell=cell2screen(_o.cell);
		_o.rect.cell=cell2screen(_o.rect.cell);
		_o.width=Math.round(iw*_o.scale);
		_o.height =Math.round(ih*_o.scale);
		setWidth(_o.width,_o.height);
		}
		function resetCursor(){
		_o.cellCode=-1;
		_o.cellN=-1;
		toggleCursor(false);
		}
		function resetRect(){
		_o.cellCode=-1;
		_o.cellN=-1;
		drawRect();
		}
		function toggleCursor(sw){
		if (sw==null) _o.cursor.visible=(!_o.cursor.visible); else _o.cursor.visible=sw;
		if ((_o.cursor.visible) && (_o.cellCode >= 0)) _o.cursor.div.show(); else _o.cursor.div.hide();
		drawTarget();
		return _o.cursor.visible;
		}
		function modalCursor(sw){
		if (sw==null) _o.cursor.modal=(!_o.cursor.modal); else _o.cursor.modal=sw;
		toggleCursor(!_o.cursor.modal);
		return _o.cursor.modal;
		}
		function clearTarget(){
		if (_o.target.layer) _o.target.layer.clearRect(0, 0, _o.disp.div.width(), _o.disp.div.height());
		}
		function drawTarget(){
		if ((_o.mode=="cover")||(_o.mode=="print")||(!_o.target.layer)) return;
		var ctx=_o.target.layer,wx=_o.disp.div.width();
		ctx.clearRect(0,0,wx, _o.disp.div.height());
		if ((!_o.cursor.visible)||(_o.contents==null)||(_o.contents.contentType>2)||(_o.cellCode<0)||(_o.transition)||(!_o.target.visible)||(!$o.targetSW)) return;
		//if ((_o.cursor.visible)&&(_o.cellCode>=0)){
		ctx.fillStyle="rgba(128,128,128,0.6)";
		ctx.beginPath();
		ctx.moveTo(wx-16, 0);
		ctx.lineTo(_o.cell.x+(_o.cell.width>>1)+_o.inFrame.left, _o.cell.y+(_o.cell.height>>1)+_o.inFrame.top);
		ctx.lineTo(wx, 16);
		ctx.lineTo(wx, 0);
		ctx.lineTo(wx-16, 0);
		ctx.fill();
		}
		function drawCursor(){
		if ((_o.mode!="adjust")&&(_o.mode!="edit")) drawRect();
		if (_o.mode=="cover") return;
		if ((_o.grid.visible)&&(_o.cursor.visible)&&(_o.cellCode>=0)&&(_o.contents.contentType<3)) {
			if (_o.cell.height){
			var x=0,y=0,w=(_o.mode=="print")?6:0;
			if ($j.browser.msie){
			if ($o.IE6) {
				_o.cursor.div.children(".lineVw").height(_o.cell.height).end()
							.children(".lineHs").css({top:_o.cell.height-1}).end()
							.children(".lineVe").height(_o.cell.height).css({left:_o.cell.width-1});
				}else{x=1;y=1;}
				w=0;
			}
			_o.cursor.div.css({left:_o.cell.x+x,top:_o.cell.y+y,width:_o.cell.width-w,height:_o.cell.height-w,zIndex:1005}).show();
			}
			drawTarget();
		} else {
			_o.cursor.div.hide();
			drawTarget();
			_o.cursor.visible=false;
		}
		}
		function drawRect(){
		if (!_o.free) return;
		var cl=_o.rect.cell;
		if ((cl)&&(_o.rect.visible)&&(_o.cellCode>=0)) {
			_o.rect.div.css({left:cl.x,top:cl.y,width:cl.width,height:cl.height,zIndex:1000}).show();
		}else{
			_o.rect.div.hide();
			//_o.rect.visible=false;
		}
		}
		function toggleRect(mode){
		if (mode==null) _o.rect.visible=!_o.rect.visible; else _o.rect.visible=mode;
		_o.rect.frame.ifShow(_o.rect.visible);
		_o.rect.div.ifShow(_o.rect.visible);
		if (mode) {
			_o.aim.div.hide();
			_o.aim.visible=false;
		}
		drawRect();
		}
		function toggleAimRect(mode){
			_o.aim.div.ifShow(mode);
			_o.aim.visible = mode;
			if (mode) _o.rect.frame.hide();
		}
		function drawAimRect(){
		if (!_o.free) return;
		var cl=_o.aim.cell,a=0;
		if ($o.isIE6) a=-1;
		_o.aim.div.css({left:cl.x,top:cl.y,width:cl.width+a,height:cl.height+a,zIndex:1005,pointer:"move"});
		return cl;
		}
		function setFromCoin(coins){
		_o.id=coins.coinCd;
		_o.grid.color=coins.gridColor;
		_o.grid.cellColor=coins.cellColor;
		_o.grid.lineStyle=coins.cellPatternId;
		//_o.grid.publictype=coins.publictype;
		_o.free=(coins.cellPatternId<0);
		_o.grid.cellStyle=coins.cellStyle;
		_o.coins=coins;
		_o.contents=coins.contents;
		_o.contents.fullPath=$o.contentsDir.file(coins.contents);
		}
		function setImageFromCoin(coins,options,callback){
		$j("#oDocViewer").hide();
		_o.cursor.div.hide();
		_o.cursor.modal=false;
		_o.inFrame.div.css((coins.abone)?{border:"solid 1px black"}:"");
		$j(".oDeleted",_o.inFrame.div).ifShow(coins.abone);
		if ((options)&&(_o.img!=null)) {
			_o.transition=true;
			_o.target.div.fadeOut($o.isIE6(20));
			clearTarget();
			_o.inFrame.div.fadeOut(270,function(){setting();});
		} else setting();
		function setting(){
			_o.deleted=false;
			if (coins.contents.contentType==2){
			setFromCoin(coins);
			f =(coins.abone)?null:_o.contents.fullPath;
			if (_o.mode=="cover") $j(".oTitleName").html(coins.title);
			setImageWithDir(coins.topCoinId, coins.cellW, coins.cellH, f, null,callback);
			}else{
			setContentFromCoin(coins,callback);
			}
		}
		}
	function setContentFromCoin(coins, callback){
		_o.callback=null;
		_o.loaded=true;
		_o.cursor.div.hide();
		setFromCoin(coins);
		setGrid(1,1);
		_o.topCoinId=coins.topCoinId;
		$j("#oDocViewer").hide();
		$j('#oHtml',_o.disp.div).empty();
		var tp=coins.contents.contentType;
		switch (_o.mode){
		case "view":case "adjust"://case "edit":
			if  (tp==6)  _o.player.div.hide();
			break;
		case "print":
			_o.player.div.hide();
			if (coins.subContents.filename) {
			tp+="s";
			var r=fitRect({srcW:Math.floor(_o.disp.width*0.75),srcH:Math.floor(_o.disp.height*0.75),width:coins.subContents.width,height:coins.subContents.height});
			_o.player.div.css({position:"absolute",left:((_o.disp.width-r.width)>>1),top:r.y+8,width:r.width,height:r.height}).html("<img src='"+$o.contentsDir.file(coins.subContents)+"' style='width:100%;height:100%'>").show();
			}else{
			_o.player.div.empty();
			}
			setImageForContent(coins.topCoinId, coins.cellW, coins.cellH, "prt"+tp+".gif",null,callback);
			return;
			break;
		default:
			if (coins.abone) {
			_o.deleted=true;
			}else{
			setting();
			}
		}
		fitDisplay(_o.disp.width,_o.disp.height);
		_o.fitWidth=_o.width=320;
		_o.fitHeight=_o.height=240;
		_o.recommend=gridRecommendSize();
		popCache(_o.coins.coinId);
		initCanvas();
		_o.loaded=true;
		_o.transition=false;
		_o.switching=false;
		if ($j.isFunction(callback)) callback();
		function setting(){
		switch (tp){
		case 3:case 4://mp3,flv
			var r=fitRect({srcW:_o.disp.width,srcH:_o.disp.height,width:320,height:240}),css={position:"absolute",left:r.x,top:r.y,width:r.width,height:r.height,backgroundcolor:"red"},file=_o.contents.fullPath,title=null,sub=null;
			if (!checkFlashPlugin(_o.player.swf,css)) return;
			if (typeof $o.flash.externalplay == 'undefined'||(_o.swf)) _o.player.swf.write(_o.player.swf.id);
			_o.swf=null;
			_o.player.div.css(css).show();
			if (tp==3) {
				title=coins.title;
				sub=(coins.subContents != null && (coins.subContents.filename))?$o.contentsDir.file(coins.subContents):"";
			}
			playerLoad(file,title,sub);
			break;
			case 5://FLASH
			var r=fitRect({srcW:_o.disp.width,srcH:_o.disp.height,width:coins.contents.width,height:coins.contents.height}),css={position:"absolute",left:r.x,top:r.y,width:r.width,height:r.height};
			fitDisplay(_o.disp.width,_o.disp.height);
			if (!checkFlashPlugin(_o.player.swf,css)) return;
			_o.fitWidth=_o.width;
			_o.fitHeight=_o.height;
			initCanvas();
			_o.swf=new SWFObject(_o.contents.fullPath, "externalplay", r.width, r.height, "8", "#222222");
			_o.swf.useExpressInstall($o.imgDir+"expressinstall.swf");
			_o.swf.addParam('wmode', 'opaque');
			_o.swf.addParam('allowScriptAccess', 'always');
			_o.swf.write(_o.player.swf.id);
			_o.player.div.css(css).show();
			break;
			case 6:
			showPDF(coins);
			break;
			case 7:
			showBanner(coins);
			break;
		}
		}
		function checkFlashPlugin(swf,css){
		if (swf.installedVer.major==0) {
			_o.player.div.css(css).html($o.jTmp._templates.no_flash.get({}, [], document.body)).oDecoButton().show();
			$j("#oBtnFlashDl").click(function(){
			window.open("http://www.adobe.com/go/getflashplayer/","FlashPlugin");
			});
			return false;
		}
		return true;
		}
	}
	function showPDF(coins,mode){
		_o.player.div.hide();
		var jQDc=$j('#oDocViewer');
		jQDc.html($o.jTmp._templates.docViewer.get({}, [], document.body)).oDecoButton().hide();
		$j("#oDoc_btnClose").click(function(){showPDF($o.o);}).bind("selectstart",function(){event.returnValue = false;});
		var jQIf=jQDc.children("#oDoc_frame").children("iframe"),pdf=_o.contents.fullPath;
		if (mode=="on"){
		if  ($o.IE6) {window.open(pdf, '_blank', 'menubar=no,toolbar=no'); return;}
		var w=$j(document).width(),h=Math.floor($j(document).height()*0.9);
		var wx=Math.floor(w*0.7),x=Math.floor((w-wx)/2);
		jQDc.hide().css({position:"fixed", left:0,top:0,width:"100%", height:"100%",zIndex:1007})
		.children("#oDoc_modal").show().end()
		.children("#oDoc_frame").css({position:"absolute", left:x,top:32,width:wx+"px", height:"80%"})
		.children("#oDoc_title").show().end();
		jQIf.replaceWith('<iframe src="'+pdf+'" width="100%" height="100%" allowtransparency="true"></iframe>');
		jQDc.show();
		}else{
		var d=_o.disp.div.offset();
		var r=fitRect({srcW:_o.disp.width,srcH:_o.disp.height,width:_o.disp.width,height:_o.disp.height});
		jQDc.hide().css({position:"absolute",left:d.left,top:d.top,width:r.width,height:r.height,zIndex:1003})
		.children("#oDoc_modal").hide().end()
		.children("#oDoc_frame").css({position:"absolute",left:0,top:0,width:r.width,height:r.height})
		.children("#oDoc_title").hide().end();
		jQIf.replaceWith('<iframe src="'+pdf+'#toolbar=0" width="100%" height="100%" allowtransparency="true"></iframe>');
		jQDc.show();
		}
	}
	function showBanner(coins,mode){
		_o.player.div.hide();
		var cnt=coins.contents;
		var r=fitRect({
		srcW:_o.disp.width,
		srcH:_o.disp.height,
		width:cnt.width,
		height:cnt.height
		});
		$j("#oHtml",_o.disp.div).css({position:"absolute",left:r.x,top:r.y}).width(r.width).height(r.height).html(cnt.text);
		fitDisplay(_o.disp.width,_o.disp.height);
		_o.fitWidth=_o.width;
		_o.fitHeight=_o.height;
		initCanvas();
	}
	function playerLoad(file,title,sub){
		var e=typeof($o.flash.externalplay.mediaLoad);
		if (e=="function"){
		$o.flash.externalplay.mediaLoad(file, title, sub);
		} else {
		setTimeout(function(){playerLoad(file, title, sub);},300);
		}
	}
	function setImageWithDir(topCoinId,w,h,filename,options,callback){
		_o.player.div.hide();
		setImageWithEffect(topCoinId,w,h,filename,options,callback);
	}
	function setImageForContent(topCoinId,w,h,filename,options,callback){
		setImageWithEffect(topCoinId,w,h,$o.imgDir+filename,options,callback);
	}
	function setImageWithEffect(topCoinId,w,h,filename,options,callback){
	/*
		if ((options)&&(image!=null)) {
		_o.target.div.fadeOut(20);
		clearTarget();
		_o.inFrame.div.fadeOut(300,function(){
			setImage(topCoinId,w,h,{filename:filename},callback)
		});
		} else setImage(topCoinId,w,h,{filename:filename},callback);
	*/
	setImage(topCoinId,w,h,{filename:filename},callback);
		function setImage(topCoinId, w, h, file, callback){
		_o.topCoinId = Number(topCoinId);
		_o.loaded = false;
		setGrid(w, h);
		_o.callback = callback;
		if ($o) $o.jQLd.oAjaxMon($o._.loading,true);
		if ((file.filename=="")||(file.filename==null)) file.filename="img/spacer.gif";
		//if (_o.mode=="print") printImgLoad(file.filename); else imgLoad(file.filename);
		imgLoad(file.filename);
		_o.cursor.div.hide();
		if (file.filename.substr(-3) == "swf") onLoadImage();
		}
	}

	// image loader
	function imgLoad(src){
		var delay   = 20;
		var timeout = 15000;
		var tick = 0;
		delete _o.img;
		_o.img=(_o.mode=="print")?_o.print[0]:new Image();
		_o.img.onerror =_o.img.onabort = function() {
		_o.img.finish = true;
		if (tick > timeout) onErrorImage1(); else imgLoad(src);
		};
		_o.img.onload  = function() {
		_o.img.finish = true;
		if (($j.browser.opera) && (!_o.img.complete)) {onErrorImage();return;}
		onLoadImage();
		};
		_o.img.src=src;//+"?"+new Date().getTime();
	/*
		if (!_o.img.finish) {
		setTimeout(function() {
			if (_o.img.finish) return;
			if (_o.img.complete) {
			_o.img.finish = true;
			if (!$j.browser.msie) return;
			if (_o.img.width) onLoadImage();
			onErrorImage();
			return;
			}
			if ((tick += delay) > timeout) {
			_o.img.finish = true;
			onLoadImage();
			return;
			}
			setTimeout(arguments.callee, delay);
		}, 0);
		}
	*/
	}
	/*
	function imgReady(fn){
		var delay=100,timeout =15000,tick = 0;
		var i=setTimeout(function() {
			if (($j("img:not([complete])").length<2)||((tick += delay) > timeout)){
				clearTimeout(i);
				fn();
			}else i=setTimeout(arguments.callee, delay);
			}, 0);
		}
	*/
		function drawCells(){
		if ((_o.contents.contentType>2)||($o.cellCount==0)||(_o.mode=="cover")) return;
		if (_o.oneCell) {
			if (_o.history) drawCheck({cellCode:0,cellNo:1,x:0,y:0});return;
		}
		if ($o.filter.length>0){
			_o.grid.layer.fillStyle="rgba(0,0,0,0.7)";
			_o.grid.layer.fillRect(0, 0, _o.width, _o.height);
		}
		var f=function(c,i){_o.grid.layer.fillRect(c.x,c.y,c.width,c.height);};
		_o.grid.layer.fillStyle=$o.rgba2css(_o.grid.cellColor);
		_o.grid.layer.strokeStyle=_o.grid.color;
		_o.grid.layer.lineWidth=1;
		if (_o.free) f=(_o.grid.cellColor=="#000000")?freeCell:cell3d;
		if (_o.grid.lineStyle==0) f=cell3d;
		_o.grid.overflows=0;
		for (var i in $o.cells) {
			i=Number(i);
			if ($o.filter.length>0) {if (!$o.filter.cell[i]) continue; else if (!$o.cells[i]) continue;}
			if ($o.cells[i].modified&4) continue;
			var gc=cellCode2cell({cellCode:i});
			if (gc.cellCode==null){_o.grid.overflows++;continue;}
			if ($o.filter.length>0) {
				if (!_o.coins.abone)_o.grid.layer.drawImage(_o.img, gc.x/_o.scale,gc.y/_o.scale,gc.cellW,gc.cellH,gc.x,gc.y,gc.width,gc.height);
				else _o.grid.layer.clearRect(gc.x/_o.scale,gc.y/_o.scale,gc.cellW,gc.cellH,gc.x,gc.y,gc.width,gc.height);
			}
			f(gc,i);
			if (_o.history) drawCheck(gc);
		}
		function freeCell(c,i){
			if ($o.cells[i].hasInfo) _o.grid.layer.fillRect(c.x,c.y,c.width,c.height);
			_o.grid.layer.strokeRect(c.x,c.y,c.width,c.height);
		}
		function cell3d(c,i){
			var x=c.x+1,y=c.y+1,rx=x+c.width-1,ry=y+c.height-1;
			_o.grid.layer.lineWidth=2;
			if ($o.cells[i].hasInfo) _o.grid.layer.fillRect(x,y,c.width-1,c.height-1);
			_o.grid.layer.strokeStyle="rgba(230,230,230,0.9)";
			_o.grid.layer.beginPath();
			_o.grid.layer.moveTo(rx,y);
			_o.grid.layer.lineTo(x,y);
			_o.grid.layer.lineTo(x,ry);
			_o.grid.layer.stroke();
			_o.grid.layer.beginPath();
			_o.grid.layer.strokeStyle="rgba(24,24,24,0.9)";
			_o.grid.layer.moveTo(x,ry);
			_o.grid.layer.lineTo(rx,ry);
			_o.grid.layer.stroke();
			_o.grid.layer.strokeStyle="rgba(96,96,96,0.9)";
			_o.grid.layer.beginPath();
			_o.grid.layer.moveTo(rx,ry);
			_o.grid.layer.lineTo(rx,y);
			_o.grid.layer.stroke();
		}
		}
		function drawCheck(cl){
		if (!_o.history) return;
		if (!$o.history[$o.o.coinId]) return;
		if (!$o.history[$o.o.coinId][cl.cellCode]) return;
		if (!cl.x) cl=cellCode2cell(cl);
		var sx=_o.zoom<<2,sy=_o.zoom<<2;
		var cx=cl.x+(cl.width>>1)-sx,cy=cl.y+(cl.height>>1);
		_o.grid.layer.lineWidth=2;
		_o.grid.layer.strokeStyle=_o.grid.color;
		_o.grid.layer.beginPath();
		_o.grid.layer.moveTo(cx,cy);
		_o.grid.layer.lineTo(cx+sx,cy+sy);
		_o.grid.layer.lineTo(cx+sx+sx+(sx>>1),cy-sy);
		_o.grid.layer.stroke();
		}
		function setGrid(w,h){
		if (w==0) w=_o.recommend.w;
		if (h==0) h=_o.recommend.h;
		_o.grid.countW=w;
		_o.grid.countH=h;
		var ww,hh;
		if (_o.img){
			ww=_o.imgWidth/_o.grid.countW;
			hh=_o.imgHeight/_o.grid.countH;
		}else{
			ww=_o.disp.width/_o.grid.countW;
			hh=_o.disp.height/_o.grid.countH;
		}
		if (_o.free){
			_o.oneCell=_o.cell.cellW=_o.cell.cellH=_o.cell.width=_o.cell.height=null;
		}else{
			_o.grid.cellW=_o.cell.cellW=ww;
			_o.grid.cellH=_o.cell.cellH=hh;
			_o.grid.width=_o.cell.width=_o.cell.cellW*_o.scale;
			_o.grid.height=_o.cell.height=_o.cell.cellH*_o.scale;
		}
		getOneCell();
		}
		function gridRecommendSize(w,h,cellSize){
		var size={},sc=1;
		if (!cellSize) cellSize=32;
		if (w==null) w=(_o.img)?_o.imgWidth:_o.disp.width;
		if (h==null) h=(_o.img)?_o.imgHeight:_o.disp.height;
		if ((w>_o.disp.width)||(h>_o.disp.height)) sc=Math.min((_o.disp.width/w), (_o.disp.height/h));
		var cw=cellSize/sc;
		size.size=Math.floor(cw);
		size.w=Math.floor(w/cw);
		size.h=Math.floor(h/cw);
		return size;
		}
		function setHistory(mode){
		_o.history=mode;
		}
		function setGridColor(color,refresh){
		_o.grid.color=color;
		if (refresh) drawGrid();
		}
		function setGridCellColor(color,refresh){
		_o.grid.cellColor=color;
		if (refresh) drawGrid();
		}
		function setLineStyle(style){
		_o.grid.lineStyle=style;
		}
		function setCellStyle(style){
		_o.grid.cellStyle=style;
		}
		function toggleGrid(sw){
		(!sw)?_o.grid.visible = !(_o.grid.visible):_o.grid.visible=sw;
		toggleCursor(_o.grid.visible);
		drawGrid();
		return _o.grid.visible;
		}
		function toggleTarget(sw){
		(!sw)?_o.target.visible = !(_o.target.visible):_o.target.visible=sw;
		var cl=cellCode2cell({cellCode:_o.cellCode});
		drawTarget(cl);
		return _o.target.visible;
		}
		function setCellCode(cellCode){
		if (cellCode==null) cellCode = _o.cellCode;
		if (($o.cellCount==0)||(_o.mode=="view")||(_o.mode=="adjust")||(_o.mode=="cover")) cellCode=-1;
		if (_o.oneCell) cellCode=0;
		if (cellCode==-2) cellCode=minimumCellCode();
		_o.cellCode = (setCursorCellCode(cellCode))?cellCode:-1;
		drawCursor();
		return _o.cellCode;
		}
		function cellNo2Code(cellNo){
		if ((cellNo==-1)||(cellNo==null)) return cellNo;
		cellNo=Math.floor(cellNo)-1;
		if (_o.free) {
			if ($o.cellNo[cellNo]) return $o.cellNo[cellNo].cellCode;
			return -1;
		}
		if ((cellNo<0)||(cellNo>=(_o.grid.countW * _o.grid.countH))) {
			return -1;
		}else{
			return ((cellNo%_o.grid.countW))+(Math.floor(cellNo/_o.grid.countW)<<16);
		} ;
		}
		function minimumCellCode(){
		var min=Number.MAX_VALUE;
		if ($o.root.no==0) return;
		if (_o.free){
			return cellNo2Code(1);
		}else{
			for (var i in $o.cells) min=Math.min(i,min);
			if (min==Number.MAX_VALUE) min=-1;
		}
		return min;
		}
		function jumpCellNo(cellNo){
		var cellCode=cellNo2Code(cellNo);
		if (!setCellCode(cellCode)) return -1;
		$o.drawInfo(cellCode);
		return cellCode;
		}
		function jumpCellCode(cellCode){
		if (!setCellCode(cellCode)) return -1;
		$o.drawInfo(cellCode);
		return cellCode;
		}
		function drawGrid(){
		if ((!_o.loaded)||(_o.contents.contentType>2)) return;
		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		var cv=_o.grid.layer;
		var w=_o.width,h=_o.height,tp=1,x,xx,y,yy;
		if (!_o.coins.abone) cv.drawImage(_o.img, 0, 0, w, h); else cv.clearRect(0, 0, w, h);
		if (_o.grid.visible) {
			drawCells();
			if ((_o.grid.cellStyle!=1)&&(!_o.free)){
			cv.lineWidth=4;
			if ($o.filter.length == 0) cv.strokeStyle=_o.grid.color; else cv.strokeStyle="rgba(0,0,0,0.3)";
			if (_o.grid.lineStyle!=0) cv.strokeRect(0,0,w,h);
			cv.lineWidth=1;
			if (_o.grid.lineStyle==2) drawBreakGrid(); else if (_o.grid.lineStyle!=0) drawSolidGrid();
			}
		}
		if (_o.inFrame.div.css("display")=="none")  _o.inFrame.div.fadeIn(400,function(){_o.target.div.show();});
		_o.inFrame.div.show();
		function drawSolidGrid(){
			for (x=_o.grid.width;x<=w;x+=_o.grid.width) {
				cv.beginPath();
				cv.moveTo(Math.floor(x), 0);
				cv.lineTo(Math.floor(x), h);
				cv.stroke();
			}
			for (y=_o.grid.height; y<=h;y+=_o.grid.height) {
				cv.beginPath();
				cv.moveTo(0, Math.floor(y));
				cv.lineTo(w, Math.floor(y));
				cv.stroke();
			}
		}
		function drawBreakGrid(){
			for (x=_o.grid.width;x<=w;x+=_o.grid.width){
			cv.beginPath();
			xx=Math.floor(x);
			for (yy=0; yy<= h;yy+=4) {cv.moveTo(xx, yy);cv.lineTo(xx+1, yy);}
			cv.stroke();
			}
			for (y=_o.grid.height;y<=h;y+=_o.grid.height) {
			cv.beginPath();
			yy=Math.floor(y);
			for (xx=0; xx <= w; xx += 4) {cv.moveTo(xx, yy);cv.lineTo(xx, yy+1);}
			cv.stroke();
			}
		}
		}
		function setZoom(x){
			if ((x<=0)||(_o.oneCell)&&(_o.contents.contentType>2)) return false;
			_o.zoom=x;
			var w=_o.fitWidth,h=_o.fitHeight,dw=_o.disp.width,dh=_o.disp.height;
			w=Math.floor(w*x);
			h=Math.floor(h*x);
			if (w>dw) w=dw;
			if (h>dh) h=dh;
			if (((w>=dw)&&(_o.width>=dw))||((h>=dh)&&(_o.height>=dh))) return false;
			fitDisplay(w,h,true);
			return true;
		}
		function moveDisplay(o){
		//	  var x=o.left+(_o.disp.div.width()>>1)-(_o.disp.width>>1),y=o.top+(_o.disp.div.height()>>1)-(_o.disp.height>>1),old=_o.disp.div.offset();
			var x=o.left,y=o.top,old=_o.disp.div.offset();
			if ((old.left!=o.left)||(old.top!=o.top)) _o.disp.div.css({left:o.left, top:o.top});
			$j("#oTitlebar,#oRoot_panel,#oFilter_panel,#oIF_panel").hide();
			_o.area.div.css({left:x,top:y,width:_o.disp.width,height:_o.disp.height}).show();
			var t=$o.cnt.contentType,v="#oTitlebar,#oRoot_panel,#oFilter_panel,#oIF_panel";
			v+=($o.enquetes[_o.cellCode])?",#oEnq_panel":"";
			$j(v).fadeIn('fast');
			if ((t==3)||(t==4)) $j("#oPlay_Panel").fadeIn('fast');
			if (_o.enquete){ $j("#oEnq_Panel").fadeIn('fast');_o.enquete=false;}
		}
		function openUI(){
			if (_o.isOpened) return;
			_o.isOpened=true;
			$j("#oFilter_panel").show("slide",{direction:"right"}, 150);
			$j("#oRoot_panel").show("slide",{direction:"up"}, 150,function(){
				$o.jQIP.show("slide",{direction:"left"}, 400,function(){
					if (!_o.disp.div.is(".ui-draggable")){
						_o.disp.div.draggable({
							snapMode:"outer",
							delay:50,
							distance:16,
							start:function(e,ui){
								_o.dragging=true;
								_o.enquete=($j("#oEnq_panel").css("display")!="none");
								$j("#oTitlebar,#oRoot_panel,#oFilter_panel,#oIF_panel,#oPlay_Panel,#oEnq_panel,#oMsg_panel").hide();
							},
							stop:function(e,ui){
								moveDisplay(_o.disp.div.offset());
							}
						}).removeClass("ui-draggable-disabled");
					}
				});
			});
		}


		if (typeof $o != 'undefined')  pushCache($o.o);
		if (typeof $j.o == 'undefined') $j.o={};
		if (typeof _o != 'undefined'&&($o.id)) $o.elements[$o.id]=_o;

		_o=$j.extend({
			left:0,
			top:0,
			print:{},
			dragging:false,
			switching:false,
			edgeRight:0,
			topCoinId:0,
			width:640,
			height:480,
			free:false,
			contents:null,
			coins:null,
			fitWidth:640,
			fitHeight:480,
			coinId:-1,
			bookmark:false,
			zoom:100,
			scale:1,
			cellCode:-1,
			initCellCode:null,
			cellNo:-1,
			focus:null,
			viewReady:null,
			enquete:false,
			parent:null,
			home:{},
			swf:{},
			title:{p:null},
			inFrame:{div:{},left:0,top:0},
			player:{
				div:null,
				a:null,
				link:null
			},
			blind:{
				div:null
			},
			cursor:{
				div:null,
				x:0,
				y:0,
				visible:true,
				modal:false
				},
			rect:{
				div:null,
				cell:null,
				last:null,
				multi:null,
				visible:true
			},
			aim:{
				div:null,
				cell:null,
				visible:false
			},
			cell:{
				oneCell:false,
				cellW:0,
				cellH:0,
				width:0,
				height:0,
				history:false
			},
			grid:{
				canvas:null,
				layer:null,
				square:{},
				color:"#EEEEEE",
				cellColor:"#FF0000",
				cellStyle:0,
				lineStyle:null,
				visible:true,
				history:false,
				overflows:0,
				countW:0,
				countH:0,
				recommend:{}
			},
			target:{
				canvas:null,
				layer:null,
				visible: false
			},
			img:null,
			filename:null,
			loaded:false,
			disp:{div:{},left:0,top:0,width:640,height:480},
			area:{div:{}},
			callback:null
			}, _opt);

			if (_o.mode!="url"){

			if (!_o.topCoinId){
				if (typeof _o.id != 'undefined') _o.topCoinId=_o.id;
				else{
				var t=$j(this).get(0).tagName,id=null;
				if (t=="DIV") id=$j(this).find("IMG").attr("id");
					else id=((t=="IMG")||(t=="SPAN"))?$j(this).get(0).id:0;
				_o.topCoinId=_o.id=id;
				}
			}
		}

		$j.extend($j.fn.o,{
		opt:_o,
		fit:false,
		fitRect:function(r){
		fitRect(r);
			return r;
		},
		homePosition:function(mode){
			if (mode=="move") moveDisplay(_o.home);
			return _o.home;
		},
		cell2CellCode:function(cl){
			return cell2CellCode(cl);
		},
		getOneCell:function(){
			return getOneCell();
		},
		setFocus:function(fid,id,refresh){
			focusDiv(fid);
			initCanvas();
			if (id) popCache(id);
			if (refresh) draw();
		},
		setMode:function(md){
			_o.mode=md;
			setCursorCellCode(-1);
			drawCursor();
			if ((_o.mode=="adjust")||(_o.mode=="edit")) _o.disp.div.draggable("disable").removeClass("ui-state-disabled"); else _o.disp.div.draggable("enable");
			return md;
		},
		push:function(coins,ex){
			pushCache(coins,ex);
		},
		isPop:function(coins){
			popCache(coins);
		},
		removeCache:function(id){
			removeCache(id);
		},
		zoom:function(x){
			var ok=setZoom(x);
			drawGrid();
			drawCursor();
			drawRect();
			return ok;
		},
		image:{
			load:function( filename,callback){
			setImageWithDir(0,0,0, filename,options,callback);
			},
			loadFromCoin:function(coins,options,callback){
			setImageFromCoin(coins,options,callback);
			}
		},
		setHistory:function(mode,refresh){
			setHistory(mode);
			if (refresh) drawGrid();
		},
		showCheck:function(cellCode){
			if (!_o.history) return;
			var cl={cellCode:cellCode};
			cl=cellCode2cell(cl);
			drawCheck(cl);
		},
		show:function(){
			draw();
		},
		showPDF:function(coins,mode){
			showPDF(coins,mode);
		},
		grid:{
			set:function(w,h){
			setGrid(w,h);
			drawGrid();
			},
			setFromCoin:function(coins){
			setFromCoin(coins);
			setGrid(coins.cellW,coins.cellH);
			drawGrid();
			},
			getCellNo:function(cellCode){
			if (cellCode) {return cellCode2No(cellCode);}else{return cellCode2No(_o.cellCode);}
			},
			show:function(){
			drawGrid();
			},
			hide:function(){
			_o.grid.div.hide();
			},
			toggle:function(sw){
			sw=toggleGrid(sw);
			return sw;
			},
			setColor:function(color,refresh){
			setGridColor(color,refresh);
			},
			setCellColor:function(color,refresh){
			setGridCellColor(color,refresh);
			},
			setCellStyle:function(styleNo){
			setLineStyle(1);
			setCellStyle(styleNo);
			drawGrid();
			},
			setRecommend:function(){
			setGrid(_o.recommend.w,_o.recommend.h);
			drawGrid();
			},
			getRecommend:function(w,h,sz){
			return gridRecommendSize(w,h,sz);
			},
			setLineStyle:function(lineStyle){
			setCellStyle(0);
			setLineStyle(lineStyle);
			drawGrid();
			},
			click:function(fn){
			if (!fn) delete _o.grid.click; else _o.grid.click=fn;
			},
			mouseover:function(fn){
			if (!fn) {_o.click.unbind('mousemove').unbind('mouseover').unbind('mouseout');return;}
			_o.click.mousemove(function(e){var cl=mouse2screen(e);fn(e,cl);});
			_o.click.mouseover(function(e){toggleAimRect(true);});
			_o.click.mouseout(function(e){toggleAimRect(false);});
			}
		},
		target:{
			toggle:function(onoff){return toggleTarget(onoff);},
			show:function(){drawTarget();}
		},
		cursor:{
			toggle:function(sw){
			return toggleCursor(sw);
			},
			modal:function(sw){
			return modalCursor(sw);
			},
			initCellCode:function(){
			if ((_o.mode=="view")||(_o.mode=="print")|(_o.mode=="cover")) return;
			jumpCellCode((_o.initCellCode)?_o.initCellCode:setCellCode("min"));
			_o.initCellCode = null;
			},
			jumpCellNo:function(cellNo){
			return jumpCellNo(cellNo);
			},
			jumpCellCode:function(cellCode){
			return jumpCellCode(cellCode);
			},
			setCellCode:function(cellCode){
			return setCellCode(cellCode);
			},
			reset:function(){
			resetCursor();
			}
		},
		rect:{
			enable:function(md,ml){
			_o.rect.visible=md;
			_o.rect.multi=ml;
			toggleRect(md);
			},
			reset:function(){
			resetRect();
			},
			toggle:function(md){
			if (_o.cellCode) toggleRect(md);
			},
			get:function(){
			return _o.rect.cell;
			},
			set:function(cl){
			if (typeof cl.cell != 'undefined') var cl=cl.cell;
			cl=setRect(cl);
			drawRect();
			return cl;
			},
			resize:function(cl,callback){
			if (cl) redefineCell(cl);
			if (callback) _o.rect.resizeCallback=callback;
			},
			hit:function(cl){
			return checkHit(cl);
			}
		},
		aim:{
			toggle:function(mode){
			toggleAimRect(mode);
			},
			set:function(cl){
			cl=setAimRect(cl);
			drawAimRect();
			return cl;
			}
		}
		});

		_o.area.div=$j("#oArea");
		if (_o.area.div.length == 0) {
		$j("body").append("<div id='oArea' class='oBody'></div><div id='oDisplay' class='oBody' onSelectStart = 'return false;'></div><div id='oWizard'  class='oBody'></div><div id='oDocViewer'></div>");
		_o.area.div=$j("#oArea");
		}
		if (typeof $o == 'undefined'||(!_o.mode)) new coIn();
		_o.disp.div= $j("#oDisplay");
		var jQv=$j(this),p=jQv.offset();
		_o.parent=jQv;
		if ((_o.mode=="cover")||(_o.mode=="adjust")||(_o.mode=="edit")||(_o.mode=="print")) dp=jQv; else dp=_o.disp.div;
		if (!$j.isUndef(p)) _o.top=p.top;_o.left=p.left;

		dp.html($o.jTmp._templates.display.get({},[],document.body));
		if (_o.mode == "print") $j("#oCover",dp).show();

		_o.inFrame.div=$j(".oInFrame",dp);
		_o.rect.frame=$j("#oRectFrame",dp);
		_o.cursor.div=$j("#oCursor",_o.inFrame.div);
		_o.rect.div=$j("#oRect",dp);
		_o.aim.div=$j("#oAimRect",dp);
		_o.target.div=$j("#oTarget",dp);
		_o.target.canvas=$j("canvas",_o.target.div);
		_o.grid.canvas=$j("canvas",_o.inFrame.div);
		_o.print=$j("#oPrint",dp);
		_o.player.div=$j("#oPlayer");
		_o.disp.width=_o.disp.div.width();
		_o.disp.height=_o.disp.div.height();
		var dpW=_o.disp.width, dpH=_o.disp.height;

		if (_o.mode == "cover") {
			$j("#oCover",dp).html($o.jTmp._templates.cover.get({}, [], document.body)).height(_o.disp.height).show()
			.hover(function(){$j(this).css({backgroundcolor: "#FFF"});if (_o.loaded) $j(this).find(".oCoverDiv").show();},
						function(){$j(this).css({backgroundcolor: "#000"}).find(".oCoverDiv").hide();})
			.find(".oCoverDiv").height(_o.disp.height).click(function(){location.href = _o.cover + "#o=" + $o.tp.coinCd;});
		}
		if (_o.mode!="print"){
		_o.target.canvas.css({position:"absolute",left:0, top:0, width:dpW, height:dpH}).attr({width:dpW, height:dpH});
		_o.grid.canvas.css({position:"absolute",left:0, top:0, width:dpW, height:dpH}).attr({width:dpW, height:dpH});
		if (typeof(uuCanvas)!="undefined"){
			_o.target.layer = uuCanvas.init(_o.target.canvas[0]).getContext("2d");
			_o.grid.layer=uuCanvas.init(_o.grid.canvas[0]).getContext("2d");
			if (_o.mode != "cover") {
					_o.isSL = (_o.grid.layer.canvas.innerHTML.match('silverlight')!=null);
					var cl = $j("#oClick",dp).ifShow(_o.isSL);
					_o.click =_o.isSL?cl:dp;
					_o.click.click(function(e){onClick(e);});
					$j("#oCover",dp).hide();
			}
		}

		//if ($o.isIE()) {
		//  _o.target.canvas.find("div").css({width:dpW,height:dpH});
		//}
		_o.target.div.css({position:"absolute",left:0, top:0, width:dpW, height:dpH});
		_o.player.swf=new SWFObject($o.imgDir+"coinplayer.swf", "externalplay", "100%", "100%", "8", "#222222");
		_o.player.swf.useExpressInstall($o.cntDir+"expressInstall.swf");
		_o.player.swf.addParam('swLiveConnect', 'true');
		_o.player.swf.addParam('wmode', 'opaque');
		_o.player.swf.addParam('allowScriptAccess', 'always');
		_o.player.swf.id="oPlayer";
		_o.player.div=$j("#"+_o.player.swf.id,dp);
		_o.rect.div
		.draggable({
			containment:'parent',
			snap:_o.rect.frame,
			snapMode:"outer",
			start:function(e,ui){
			_o.dragging=true;
			},
			stop:function(e,ui){
			var cl={cellCode:_o.cellCode,x:ui.position.left,y:ui.position.top,width:ui.helper.width(),height:ui.helper.height()};
			screen2cell(cl);
			if (checkHit(cl)) _o.rect.div.animate({left:_o.rect.cell.x,top:_o.rect.cell.y},100); else redefineCell(cl);
			}
		})
		.resizable({
			containment:'parent',snap:_o.rect.frame,snapMode:"outer",minHeight:32, minWidth:32,handles:"all",
			stop:function(e,ui){
			var r=_o.rect.div.offset(),cl={cellCode:_o.cellCode,x:r.left,y:r.top,width:_o.rect.div.width(),height:_o.rect.div.height()};
			if (screen2cell(point2screen(cl))) _o.rect.div.animate({left:_o.rect.cell.x,top:_o.rect.cell.y,width:_o.rect.cell.width,height:_o.rect.cell.height},100);
				else redefineCell(cl);
			drawRect(cl);
			if (_o.rect.resizeCallback) _o.rect.resizeCallback(cl);
			}
		});
		}

		_o.edgeRight=$j(window).width()-$o.jQIP.width()-Number($o._.marginRight);

		$o.copyright="©2008 InfoPlayer.jp. All Rights Reserved/concept design ID-G";
		$o.id=jQv[0].id;
		$o.jQme=$j("#"+$o.id);
		$o.referer=(_o.mode=="url")?parent.document.referrer:"";
		_o.bookmark=((_o.mode=="url")||(_o.trigger=="hide")||(_o.trigger=="on"));
		if (_o.mode=="instance") return jQv;
		if ((!_o.mode)||(_o.bookmark)){
			if ($j.browser.msie){
				$j("iframe").css({visibility:"hidden"});
				if ($j(".oFlash").length==0) $o.swfControl();
			}
			if (($o.nowTop.topCoinId>0)&&(_o.disp.div.css("display")!="none")) CoinApi.closeCoin($o.o.coinId,(_o.cellCode>=0)?$o.cells[_o.cellCode].coinCellId:-1,-1);
			var o=$j(this).offset(),x=o.left+($j(this).width()>>1)-(_o.disp.width>>1),y=o.top+($j(this).height()>>1)-(_o.disp.height>>1);
			_o.home=o;
			$j("#oIF_message",$o.jQIF).html($o.jTmp._templates.splash.get({},[],document.body));
			$j("#oTitlebar,#oRoot_panel,#oFilter_panel,#oIF_panel,#oPlay_Panel,#oMsg_panel,#oEnq_panel").hide();
			_o.area.div.css({left:x,top:y,width:_o.disp.width,height:_o.disp.height}).show();
			if(y<$j("#oTitlebar").height()) y=$j("#oTitlebar").height();
			if((x+_o.disp.width)>_o.edgeRight) x=_o.edgeRight-_o.disp.width;
			if(x<$j("#oFilter_panel").width()) x=$j("#oFilter_panel").width();
			//resetCursor();
			$o.jQRV.empty();
			$o.jQIV.empty();
			$j("#oFilter_icons").empty();
			_o.area.div.css({left:x,top:y}).show();
			_o.disp.div.hide().css({left:x,top:y}).show();
			$j("#oTitlebar").show("slide",{direction:"down"}, 120);
			_o.isOpened=false;
			_o.switching=true;
			if (_o.mode=="chgTop") $o.refreshInterfaces(true);
			if ($j.browser.msie){
				if (_o.bookmark) $o.loadCoinFromBookmark(); else $o.TopCoinLoad(_o.id);
			}else{
				if (_o.bookmark){
					if (_o.mode=="chgTop") {$j.historyLoad(_o.id);_o.mode="url";}
					$o.loadCoinFromBookmark();
				} else $o.TopCoinLoad(_o.id);
			}
		} else if (typeof(_o.id)=="string") {
			$o.TopCoinLoad(_o.id);
		}
		if (_o.trigger=="hide") _o.parent.hide();
		return jQv;
	};
})($j);
$j.event.special.ready.setup();

$j(function(){
	if (typeof $o == 'undefined'){
		$j(".imgCourt,.imgHover").hover(function(){
		$j(this).css({
			filter:"alpha(opacity=50)",
			opacity:0.5,
			border:"solid 2px #888888",
			margin:0,
			padding:0,
			cursor:"pointer",
			backgroundColor:"#FFFFFF",
			textDecoration:"none"
		});}, function(){
			$j(this).css({
			filter:"alpha(opacity=100)",
			opacity:1,
			border:"none",
			margin:2,
			padding:0,
			backgroundColor:"#FFFFFF",
			cursor:"pointer",
			textDecoration:"none"
		});}).css({
			filter:"alpha(opacity=100)",
			opacity:1,
			border:"none",
			margin:2,
			padding:0,
			backgroundColor:"#FFFFFF",
			cursor:"pointer",
			textDecoration:"none"
		});
	}
});