//author Aono

/*@cc_on
  if (@_jscript_version <= 5.6){
	_d=document;eval('var document=_d')
	_w=setTimeout;eval('var setTimeout=_w')
}
@*/


/**************************
*修正
*extendのfxから
*2010/5/2 高さ調整
*
***************************/
(function($){

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

//t: current time, b: begInnIng value, c: change In value, d: duration
$.easing['jswing'] = $.easing['swing'];

$.extend( jQuery.easing,
		{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
	//alert(jQuery.easing.default);
	return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
},
easeInQuad: function (x, t, b, c, d) {
	return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
	return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
},
easeInCubic: function (x, t, b, c, d) {
	return c*(t/=d)*t*t + b;
},
easeOutCubic: function (x, t, b, c, d) {
	return c*((t=t/d-1)*t*t + 1) + b;
},
easeInOutCubic: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t + b;
	return c/2*((t-=2)*t*t + 2) + b;
},
easeInQuart: function (x, t, b, c, d) {
	return c*(t/=d)*t*t*t + b;
},
easeOutQuart: function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
},
easeInOutQuart: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
	return -c/2 * ((t-=2)*t*t*t - 2) + b;
},
easeInQuint: function (x, t, b, c, d) {
	return c*(t/=d)*t*t*t*t + b;
},
easeOutQuint: function (x, t, b, c, d) {
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
},
easeInOutQuint: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
	return c/2*((t-=2)*t*t*t*t + 2) + b;
},
easeInSine: function (x, t, b, c, d) {
	return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
},
easeOutSine: function (x, t, b, c, d) {
	return c * Math.sin(t/d * (Math.PI/2)) + b;
},
easeInOutSine: function (x, t, b, c, d) {
	return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
},
easeInExpo: function (x, t, b, c, d) {
	return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
	return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
	if (t==0) return b;
	if (t==d) return b+c;
	if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
	return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInCirc: function (x, t, b, c, d) {
	return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
},
easeOutCirc: function (x, t, b, c, d) {
	return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
},
easeInOutCirc: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
	return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
},
easeInElastic: function (x, t, b, c, d) {
	var s=1.70158;var p=0;var a=c;
	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	if (a < Math.abs(c)) { a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
},
easeOutElastic: function (x, t, b, c, d) {
	var s=1.70158;var p=0;var a=c;
	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	if (a < Math.abs(c)) { a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
},
easeInOutElastic: function (x, t, b, c, d) {
	var s=1.70158;var p=0;var a=c;
	if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
	if (a < Math.abs(c)) { a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
},
easeInBack: function (x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
},
easeOutBack: function (x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
},
easeInOutBack: function (x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
},
easeInBounce: function (x, t, b, c, d) {
	return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
},
easeOutBounce: function (x, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
},
easeInOutBounce: function (x, t, b, c, d) {
	if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
	return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
}
		});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

/*ユーティリティクラス*/
var util=function(){
	function init(){
		this._count=0;
		this._activation;
		this._junk=new Array;
		this.ini;
		this.flag=false;
		this.__iter__=0;
	}
	/*メモリリーク対策*/
	init.prototype.createLeakFreeClosure=function(closure) {
		var count = this._count++;
		init.prototype.createLeakFreeClosure[count] = closure;
		if(count>0)delete init.prototype.createLeakFreeClosure[count-1];
		closure = null;
		return function() { 
			return init.prototype.createLeakFreeClosure[count].apply(this, arguments);
		};
	}
	init.prototype.iterater={
		next:function(){
			util.__iter__++
			return util.__iter__
		},
		reset:function(){
			util.__iter__=0;
		}
	}
	/*グローバルタイマーと疑似マルチスレッド*/
	init.prototype.worker={
		set:function(f,active,time){
			if(active)this._activation=setTimeout(function(){f()},time);
			else var timer=setTimeout(function(){f()},300);
		},
		release:function(){
			if(this._activation)clearTimeout(this._activation)
		},
		thread:function(){
			for(var i=0,len=arguments.length;i<len;i++)setTimeout(function(){arguments[i]},10)
		}
	}
	init.prototype.deleter=function(){
		for(var i=0,len=arguments.length;i<len;i++)
			for(var m in arguments[i])
				delete arguments[i][m];
	}
	/*externalInterface呼び出し*/
	init.prototype.callExternalInterface=function(type,box){
		try{
			if(type=="run")(document.all) ? window["external_"+box.attr("id")].runFlv() : document["external_"+box.attr("id")].runFlv();
			else(document.all) ? window["external_"+box.attr("id")].Close2() : document["external_"+box.attr("id")].Close();
		}catch(e){return false}
	},
	init.prototype.saveSettings=function(ini){
		this.ini=ini;
	}
	init.prototype.flagManager=function(flag){
		this.flag=flag;
	}
	init.prototype.ie=(navigator.userAgent.indexOf("MSIE")>-1)?true:false;
	init.prototype.ie6=(navigator.userAgent.indexOf("IE 6")>-1)?true:false;
	return new init();
}
var util=new util();

var lightbox_param={
	
	reg						:						/(lb\d+)/i,
	mask					:						"#mask",
	close					:						"a.close"

},
ID_CACHE={},
IMG_REG=/(\.jpg|\.png|\.gif)/;




var lightboxInit=function(caller){
	$.imgChanger().set();
	//メンバ変数(プロパティ)定義
	this._mask=$(lightbox_param.mask);
	this._mask.css("opacity",0.8)
	this._close=$(lightbox_param.close);
	this._link=$("#right_column a[href^=lb]");
	if(this._link.size()<1)this._link=$("#contents a[href^=lb]");
	if(this._link.size()<1)this._link=$("a[href^=lb]");
	this._reg=lightbox_param.reg;
	this._disp=$(window);
	this._size=0;
	this._caller=(caller)?caller:"anonymous"
	this._autoplay=false;
	this.load="complete";
	this._ini={
		fx:"fade",
		time:500
	};
	this._ua=navigator.userAgent;
	this.mask_color;
	this._url=location.href
	this._ie6_flag=util.ie6
	this.sync.init();
	if(this._mask.size()<1){
		var mask=document.createElement("div");
		mask.id="mask"
		$("body").append(mask);
		this._mask=$(mask).css("opacity",0.8);
	}
}
var lb=lightboxInit
lb.special={
	changeSys:{
		changeTriggerCondition:function(reg,f){
			if(arguments.length>1)f(lightbox_param.reg);
			else lightbox_param.reg=reg;
		}
	}
}

function pngToGif(){

		if(util.ie6){
		for(var i=0,l=$("a.close"),len=l.size();i<len;i++){
			var img=$("img",l.eq(i))
			img.attr("src",img.attr("src").replace(".png",".gif"));
		}
		for(var i=0,node=$("a.lightbox_auto"),len=node.size();i<len;i++){
			var img=$("img",$(node[i]))
			img.attr("src",img.attr("src").replace(".png",".gif"));
		}
		for(var i=0,node=$("a.lightbox_next"),len=node.size();i<len;i++){
			var img=$("img",$(node[i]))
			img.attr("src",img.attr("src").replace(".png",".gif"));
		}
		for(var i=0,node=$("a.lightbox_prev"),len=node.size();i<len;i++){
			var img=$("img",$(node[i]))
			img.attr("src",img.attr("src").replace(".png",".gif"));
		}
	}
}

$(function(){
	pngToGif();
});
lightboxInit.prototype={
	/*iniの読み込みメソッド
	 *設定項目
	 *fx:<fade>||<scale>アニメーションのタイプ(現在fadeとscaleのみ)
	 *time:<number>アニメーション時間
	 *ease:<ease>イージング関数
	 *debug:<boolean>デバッグ設定
	 */
	ini:function(ini){
		this._ini=ini
	},
	one:function(n,w,c,b){
		var fx=this.extend.fx,box=w,wrapper=null,mask=this._mask,disp=this._disp,expand=null,ini=this._ini,sync=this.sync,
		open=function(node,window,callback){
			node.bind("click",function(e){
				e.preventDefault()
				sync.notify(window)
				util.createLeakFreeClosure(fx.init(box,wrapper,mask,disp,expand,ini))
				if(callback)callback(this);
			})
		},
		close=function(node,window,callback){
			node.bind("click",function(e){
				e.preventDefault()
				window.fadeOut(400)
					mask.fadeOut(400)
				if(callback)callback(this);
			})
		},
		nd=n,wi=w,ca=(c)?c:function(){};
		(b)?open(nd,wi,ca):close(nd,wi,ca)
	},
	trigger:function(w,type,c){
		var fx=this.extend.fx,box=w,wrapper=null,mask=this._mask,disp=this._disp,expand=null,ini=this._ini,sync=this.sync,
		open=function(window,callback){
				sync.notify(window)
				util.createLeakFreeClosure(fx.init(window,wrapper,mask,disp,expand,ini))
				if(callback)callback(this);
		},
		close=function(window,callback){
				window.fadeOut(400)
					mask.fadeOut(400)
				if(callback)callback(this);
		},
		wi=w,ca=(c)?c:function(){};
		(type=="open")?open(wi,ca):close(wi,ca)
	},
	getLightboxObj:function(){
		if(/#lb\d+/.test(this._url)){
			var last_slash_pos=this._url.lastIndexOf("#"),
			lightbox_id=this._url.substring(last_slash_pos,this._url.length),
			lb=$(lightbox_id)
			if(lb.size()>0){
				return lb
			}else if(/-/.test(lightbox_id)){
				return lightbox_id;
			}else{
				return null;
			}
		}
	},
	createDirectUrl:function(box){
			//location.hash=box.attr("id");
	},
	closeUrl:function(){
			//location.href=location.href.replace(/#.+/,"");
	},
	nodeTraversal:function(node){//すべての<a>要素にイベントをバインドする。
		var iter=-1,tm,fx=this.extend.fx,sync=this.sync,ini=this._ini,len=this._link.size()
		if(node)this._link=node
		if(ini && ini.ajax){
			while((tm=this._link[++iter])){
				var box=$(ini.box)
				$(tm).bind("click",function(){
					if(ini.callback)ini.callback(this);
					sync.notify(box)
					fx.init(box,null,$("#mask"),$(document),false,util.ini);
				})
			}
		}else{
			while((tm=this._link[++iter])){
				this.bind($(tm))
			}
		}
		for(var i=0,lb=$("div.lightbox_window"),len=lb.size();i<len;i++){
			if(!ID_CACHE[lb[i].id]){
				this.bind(lb[i])
			}
		}
			var mask=this._mask,sync=this.sync;
			function end(e){
				var parent=sync.getActiveBox();
				if(!parent)parent=$("#lightbox_area div.lightbox_window:visible");
				if(parent.hasClass("window_flv") && util.ie){
					(document.all) ? window["external_"+parent.attr("id")].Close2() : document["external_"+parent.attr("id")].Close();
				}
		
				parent.stop(true,true).fadeOut(500,function(){
				if(util.ini.ajax)	parent.css({"overflow":"hidden"})
				if(util.ie && (parent.hasClass("window_swf") || parent.hasClass("window_swf_big")))
					$("div.st_swf_big",parent).html("");	
				mask.fadeOut(500);
				});
			};
			util.createLeakFreeClosure(this._close.bind("click",end))
			var _close=this._close
			util.createLeakFreeClosure(this._mask.bind("click",function(){
				util.worker.release();
				_close.triggerHandler("click");
			}))
		if(util.ini.ajax){
			loader='<div id="lb_load" style="height:100px;width:100px;position:absolute;top:35px;left:0px;text-align:center;"><img style="margin:35px 0 0 0;" src="/common/img/lightbox/ajax-loader.gif" /></div>';
			
			box.prepend(loader)
		}
	},
	//ライトボックスにギャラリ－、あるいはスライドショーがある場合設定
	lightboxTraversal:function(){
		
	var allbox=$("div.lightbox_window"),
		
		gal=$("div.lb_slide_start"),
		
		gal_e=$("div.lb_slide_end"),
		
		flag=0,
		
		f_indexs=[],
		
		e_indexs=[],
		iter=-1,
		rc=-1,
		rc_l=-1,
		tm;
		
		if(gal.size()>0){
			
			
			
			$("#mask").bind("click",function(){
					$("#lightbox_area").hide();
					$("#lightbox_area div.lightbox_window").stop(true,true).hide()
					util.worker.release();
					var bt=$("a.lightbox_auto img")
					if(bt[0])bt.attr("src",bt.attr("src").replace(/.+(png|gif)/,"/GENERAL/BPARTS/IMAGES/lightbox_auto_off.$1"))
					$("#lightbox_area a.lightbox_auto").unbind("click.stop")
					util.flagManager(false);
						util.iterater.reset()
			});
			
			if(gal.size()>gal_e.size() && this._ini.debug)throw new Error("Missing the end of the lightbox gallery. Check lightbox class name.\nMissing : 'lb_slide_end'")
			else if(gal.size()<gal_e.size() && this._ini.debug)throw new Error("Missing the start of the lightbox gallery. Check lightbox class name.\nMissing : 'lb_slide_start'")
			
			if(gal.size()!=gal_e.size() && this._ini.debug)throw new Error("Missing the end of lightbox gallery. Check lightbox class name.\nMissing : 'lb_slide_end'")
			while((tm=allbox[++iter])){
				if($(tm).hasClass("lb_slide_start")){
					f_indexs[++rc]=iter
				}else if($(tm).hasClass("lb_slide_end")){
					e_indexs[++rc_l]=iter+1;
				}
			}
			
			for(var i=0,len=f_indexs.length;i<len;i++){
				var next=allbox.slice(f_indexs[i],e_indexs[i]);
				if((" "+gal[i].className+" ").indexOf(" lb_slide_end ")>-1)continue;
				
				for(var l=0,len2=next.size();l<len2;l++){
					
					var n=$("div.lb_btn_area",next[l]).show(),
					
					m=$("a.lightbox_next",n[0]),
	
					o=$("a.lightbox_prev",n[0]);
					
					flag=($(next).hasClass("lb_gallery"))?1:0;
					
					var pre=(next[l-1] && (" "+next[l].className+" ").indexOf(" lb_slide_start ")<0)?$(next[l-1]):$(gal_e[i]),
					Self=$(next[l]);
					
					if(next[l+1] && (" "+next[l].className+" ").indexOf(" lb_slide_end ")<0){
						var nex=$(next[l+1]);
						
						if(flag===1){
							this.autoPlay(Self,Self.outerHeight(),o,pre,pre.outerHeight(),m,nex,nex.outerHeight(),nex.hasClass("window_flv"))
						}
						this.slideEvent(Self,Self.outerHeight(),o,pre,pre.outerHeight(),m,nex,nex.outerHeight(),nex.hasClass("window_flv"))
	
						//next=$(next).next().get(0)
						delete nex,pre,m,o,n
	
					}else{
						var nex=$(next[l+1]),gali=$(gal[i]);
						if(flag===1){
							this.autoPlay(Self,Self.outerHeight(),o,pre,pre.outerHeight(),m,gali,gali.outerHeight(),gali.hasClass("window_flv"))
						}
	
						this.slideEvent(Self,Self.outerHeight(),o,pre,pre.outerHeight(),m,gali,gali.outerHeight(),gali.hasClass("window_flv"))
						delete nex,pre,gali,m,o,n;
						break;
					}
				}
			}//end loop
		}
	},
	//nodeTraversalから呼び出されイベントをバインドする。
	bind:function(node){
		var box=(node[0])?$("#"+node.attr("href").match(this._reg)[1]).show():$(node).show(),
		mask=this._mask,
		disp=this._disp,
		ini=this._ini,
		make=this.extend.makeSwf,
		fx=this.extend.fx,
		wrapper=$("div.lightbox_wrapper",box),
		expand=false,
		count=0,reg=IMG_REG,
		mcn=$("input.maskColor",box);
		
		ID_CACHE[box.attr("id")]=true;
		
		this.mask_color=(mcn.size()>0 && mcn.val().length>0)?mcn.val():"000000";
		var mc=this.mask_color
		if(box.hasClass("window_img")){
			this._node=$("div.lightbox_wt",box);
			//box.show()
			//var cache={node:this._node,extend:this._extend},
			var img_node=$("div.lightbox_static img",box),d_height=img_node.height();
			
			function ok(ttnode,extend){
				ttnode.height(478)
				$("div.lightbox_static",box).height(360)
			}
				ok(this._node,this.extend);
		}else if(box.hasClass("window_flv")){
			this._node=$("div.lightbox_swf",box);
			this.extend.makeFlv(box);
		}else if(box.hasClass("window_swf")){
			this._node=$("div.lightbox_swf_s",box);
			if(util.ie==false)this.extend.makeSwf(box,"div.st_swf","600","360",mc);
			this._node.width(600)
			this._node.height(360)
		}else if(box.hasClass("window_swf_big")){
			var val=$("div.swf_size",box).html().split(",")
			this._node=$("div.lightbox_swf_big_s",box);
				if(util.ie==false)this.extend.makeSwf(box,"div.st_swf_big",val[0],val[1],mc);
					this._node.width(parseInt(val[0]))
			this._node.height(val[1])
			expand=true;
		}else if(box.hasClass("window_img_big")){
			expand=false;
			this._node=$("div.lightbox_wt_big img",box);
		}else if(box.hasClass("window_hl")){
			box.height(501)
			this._node=$("div.lightbox_hl",box).height(466),
			img=$(".ig2_big_img img",box)
			if(img.size()>0 &&　reg.test(img.attr("src"))){
					$(".lb_right",box).css({"width":"452px"});
			}else{
				$(".lb_left",box).width(0);
				$(".lb_right",box).css({"width":"97%","left":"10px"});
			}
		}
		if(!this._node && ini &&ini.debug==true)throw new Error("Can't find Lightbox <div> element or innerWrapper. Check Lightbox structure  \n(lightbox type : "+box.attr("class")+", caller : "+this._caller+", error point : "+node.attr("href")+" ,elementName : "+node[0].nodeName+" ,parentNode : "+node.parent()[0].nodeName)
		if(this._node){
			if(expand)box.width(this._node.width())
			var count=0;
			if(this._node.height()<1)(function(node){ if(node && node.height()<1 && count<5){count++;arguments.callee()} })(this._node)
			box.height(this._node.height()+35);
			if(this._ie6_flag)$("div.dummy_bg",box).height(this._node.height());
		}
		box.hide();
		var	sync=this.sync
		if(node[0]){
			node.bind("click",function(e){
				e.preventDefault();
				sync.notify(box);
				fx.init(box,wrapper,mask,disp,expand,ini,make,mc)
			});
		}
	},
	//lightboxTraversalから呼び出されイベントをバインドする
	slideEvent:function(Self,sh,o,pre,h,m,nex,h2,flv){
		var disp=this._disp,wrapper=$("div.lightbox_wrapper",Self),sync=this.sync,bt_area=$("div.lb_btn_area",Self),make=this.extend.makeSwf;
		if(o){
			util.createLeakFreeClosure(o.bind("click",function(e){
				if(util.flag==true){
					var btn=$("#lightbox_area a.lightbox_auto"),img=$("img",btn)
					img.attr("src",img.attr("src").replace(/stop_btn/,"lightbox_auto_off"))
					btn.toggleClass("sliding",false)
					util.worker.release();
					util.flagManager(false)
					util.iterater.reset()
				}
			}))
			util.createLeakFreeClosure(o.bind("click.prev",function(e){
				e.preventDefault();
				
				var top =  (disp.scrollTop()<39)?39:disp.scrollTop(), left = disp.width() / 2 - pre.width() / 2;
				util.worker.thread(
					//wrapper.hide(),
						pre.css({"top":top,"left":left})
				)
				if(top!=Self.position().top)
					Self.animate({"top":top},800,"easeInOutExpo",fade)
				else fade();
				function fade(){
					if(Self.hasClass("window_flv"))util.callExternalInterface("close",Self)
					if(sh-h<-20 || sh-h>20){
						wrapper.hide();
						bt_area.hide();
					Self.animate({"height":h},500,function(){
						sync.notify(pre)
						util.worker.thread(	
							Self.hide().height(sh),
							wrapper.show(),
							bt_area.show(),
							pre.show()
						)
						if(util.ie && (Self.hasClass("window_swf") || Self.hasClass("window_swf_big")))
							$("div.st_swf_big",Self).html("");
						if(pre.hasClass("window_swf_big") && util.ie==true){
							var val=$("div.swf_size",pre).html().split(",")
							make(pre,"div.st_swf_big",val[0],val[1])
						}else if(pre.hasClass("window_swf") && util.ie==true){
							make(pre,"div.st_swf",600,360)
						}
						util.worker.set(function(){
							if(pre.hasClass("window_flv"))util.callExternalInterface("run",pre)
						});
					});
					}
					else util.worker.set(function(){
						Self.css("z-index",9998);
						pre.fadeIn(500,function(){
							sync.notify(pre)
							util.worker.thread(
							Self.hide(),
							Self.css("z-index",9999)
							//wrapper.show()
						)
						if(util.ie && (Self.hasClass("window_swf") || Self.hasClass("window_swf_big")))
								$("div.st_swf_big",Self).html("");
						if(pre.hasClass("window_swf_big") && util.ie==true){
							var val=$("div.swf_size",pre).html().split(",")
							make(pre,"div.st_swf_big",val[0],val[1])
						}else if(pre.hasClass("window_swf") && util.ie==true){
							make(pre,"div.st_swf",600,360)
						}
						util.worker.set(function(){
							if(pre.hasClass("window_flv"))util.callExternalInterface("run",pre)
						});
					})
					})
				}
			}
				))
		}
		if(m){
			util.createLeakFreeClosure(m.bind("click",function(e){
				if(util.flag==true){
					var btn=$("#lightbox_area a.lightbox_auto"),img=$("img",btn)
					img.attr("src",img.attr("src").replace(/stop_btn/,"lightbox_auto_off"))
					util.worker.release();
					util.flagManager(false)
					util.iterater.reset()
				}
			}))
			util.createLeakFreeClosure(m.bind("click.next",function(e){
				e.preventDefault();
				
				var top = (disp.scrollTop()<39)?39:disp.scrollTop(), left = disp.width() / 2 - nex.width() / 2;
				util.worker.thread(
					//wrapper.hide(),
						nex.css({"top":top,"left":left})
				)
				
				if(top!=Self.position().top)
					Self.animate({"top":top},800,"easeInOutExpo",fade)
				else fade();
				function fade(){
					if(Self.hasClass("window_flv"))util.callExternalInterface("close",Self);
					if((sh-h2)<-20 || (sh-h2)>20){
						wrapper.hide()
						bt_area.hide()
						Self.animate({"height":h2},500,function(){
						sync.notify(nex)
						util.worker.thread( Self.hide().height(sh),
								wrapper.show(),
								bt_area.show(),
								nex.show()
						)
						if(util.ie && (Self.hasClass("window_swf") || Self.hasClass("window_swf_big")))
							$("div.st_swf_big",Self).html("");
						if(nex.hasClass("window_swf_big") && util.ie==true){
							var val=$("div.swf_size",nex).html().split(",")
							make(nex,"div.st_swf_big",val[0],val[1])
						}else if(nex.hasClass("window_swf") && util.ie==true){
							make(nex,"div.st_swf",600,360)
						}
						util.worker.set(function(){
							if(nex.hasClass("window_flv"))util.callExternalInterface("run",nex)
						});
					});
					}
					else util.worker.set(function(){
						Self.css("z-index",9998);
						nex.fadeIn(500,function(){
							sync.notify(nex)
							util.worker.thread(
								function(){
									if(util.ie && (Self.hasClass("window_swf") || Self.hasClass("window_swf_big")))
										$("div.st_swf_big",Self).html("");
								},
								Self.hide(),
								Self.css("z-index",9999)
								//wrapper.show()
						)
						if(util.ie && (Self.hasClass("window_swf") || Self.hasClass("window_swf_big")))
								$("div.st_swf_big",Self).html("");
						if(nex.hasClass("window_swf_big") && util.ie==true){
							var val=$("div.swf_size",nex).html().split(",")
							make(nex,"div.st_swf_big",val[0],val[1])
						}else if(nex.hasClass("window_swf") && util.ie==true){
							make(nex,"div.st_swf",600,360)
						}
						util.worker.set(function(){
							if(nex.hasClass("window_flv"))util.callExternalInterface("run",pre)
						});
					})})
				}
				}
				))
				$("a.close",Self).bind("click",function(){
					$("#lightbox_area").hide();
					$("#lightbox_area div.lightbox_window").stop(true,true).css("display","none");
					util.worker.release();
				});
		}
	},
	//自動再生の設定
	autoPlay:function(Self,sh,o,pre,h,m,nex,h2,flv){
		var disp=this._disp,wrapper=$("div.lightbox_wrapper",Self),
		img= $("#lightbox_area a.lightbox_auto img"),
		src=img.attr("src"),
		stop=src.replace(/.+?(.gif|.png)/,"/GENERAL/BPARTS/IMAGES/stop_btn$1"),
		autoBtn=src.replace(/.+?(.gif|.png)/,"/GENERAL/BPARTS/IMAGES/lightbox_auto_off$1"),
		flag=0
		util.createLeakFreeClosure($("a.lightbox_auto",Self).show().bind("click.first",function(e){
			e.preventDefault();
			if(util.__iter__==0 && util.flag==false){
				img.attr("src",stop)
			}
		}));
		$("a.lightbox_auto",Self).bind("click",function(){
				if(util.__iter__>0){
						util.worker.release();
						img.attr("src",autoBtn);
						util.flagManager(false)
				}
		})
		util.createLeakFreeClosure($("a.lightbox_auto",Self).show().bind("click.loop",function(e){
			if(util.__iter__==0 || util.flag==true){
				util.iterater.next();
				var btn=$(this);
				util.flagManager(true);
				util.worker.set(function(){
					m.triggerHandler("click.next")
					util.worker.set(function(){
						$("a.lightbox_auto",$("div.lightbox_window:visible")).triggerHandler("click.loop")
					},true,2500);
	
				},true,2000);
			}else{
					util.flagManager(false);
					util.iterater.reset()
			}
		}));
		util.createLeakFreeClosure($("a.close",Self).bind("click",function(){
			var btn=$("#lightbox_area a.lightbox_auto");
			img.attr("src",autoBtn)
			btn.unbind("click.stop")
			btn.toggleClass("sliding",false)
			util.worker.release();
			util.flagManager(false);
			util.iterater.reset()
		})
		)
		util.createLeakFreeClosure($(window).bind("unload",function(){
			$("a.lightbox_auto",$(Self[0])).unbind("click")
			$("a.close",$(Self[0])).unbind("click")
		})
		);
	},
	sync:{
		init:function(){
			this._activeBox;
		},
		notify:function(box){
			this._activeBox=box;	
		},
		getActiveBox:function(){
			return this._activeBox;
		}
	},
	//拡張メソッド アニメーション設定など
	extend:{
		fx:{
			init:function(box,wrapper,mask,disp,expand,ini,make,mc){
				
				$("#lightbox_area").show();
				$("#lightbox_area div.lightbox_window").hide();
				this._mask=mask;
				var ww=$("body").width(),cw=$("#contents").width();
				this._mask.css({
					"width": (ww<cw)?cw+10:ww,
					"height": $(document).height(),
					"background-color":"#"+mc
				}).fadeIn(300,function(){
					$("body").width($("body").width())
				});
				
				this._box=box;
				this._make=make;
				this._disp=disp;
				this._wrapper=wrapper
				this._dummy=$("div.dummy_bg",$(box[0]));
				this._ini=ini;
				this._expand=expand;
				this._ease=ini.ease || "swing";
				this._mc=mc;
				(ini.ajax)?this.ajaxScale():this[ini.fx]();
			},
		fade:function(){
			var top = this._disp.scrollTop()+30, left = this._disp.width() / 2 - this._box.width() / 2
			if (top < 0) 
				top = 30;
			this._box.css({
				"left": left,
				"top": top
			}).fadeIn(this._ini.time);
		},
		ajaxScale:function(){
			var ini=util.ini,_success=ini.ajax.success,reg=/(\.png)|(\.jpg)|(\.gif)/,box=$(ini.box),
			d=this._disp,wrapper=$("div.lightbox_wrapper",box),dummy=$("div.dummy_bg",box),count=0,area=$("#lb_ajax_area"),
			loader=$("#lb_load"),height=0;
			
				loader.css({"visibility":"visible","z-index":1});
				wrapper.hide();
					box.css({"height":"135px","width":"100px"})
					dummy.height(100)
					var dw=d.width(),
					dt=d.scrollTop(),
					top = dt, left = dw / 2 - 50
					
					if (top < 39) 
						top = 39;
					
					
					box.css({
						"left": left,
						"top": top
					}).show();
		
			ini.ajax.success=function(html){
				_success(html);
				(function(){
					count=0;
						wrapper.show().css("visibility","hidden");
					(function(){
						count++
							if(count>5)ok2();
							else if(area.height()<1)setTimeout(arguments.callee,500);
							else if(area.height()>=100){height=area.height()+35;setTimeout(ok2,500)}
							
						})()
				})()
			}
			
			function ok2(){
						wrapper.hide().css("visibility","visible");
					var node=$("div.lightbox_hl",box),img=$(".ig2_big_img img",box);
						if(img.height()<3 && !reg.test(img.attr("src"))){
							$(".lb_left",box).width(0);
							$(".lb_right",box).css({"width":"97%","left":"10px"});
						}
						var end_top = d.scrollTop(), end_left =  dw / 2 - 964 / 2;
	
						var ease=ini.ease,
					
						w="964px";
						
						dummy.height(height-35);
						
						if(end_top<39)
							end_top=39;
						loader.css({"visibility":"hidden","z-index":-1});
						box.stop(true,false).animate({
							"width":w,
							"height":height,
							"left": end_left,
							"top": end_top
						},ini.time,ease,function(){
							wrapper.fadeIn(300)
						})
					}
			
			$.ajax(ini.ajax)
		},
		scale:function(){
			var dw=this._disp.width(),
			
			val=($("div.swf_size",this._box).size()>0)?$("div.swf_size",this._box).html().split(","):null,
			
			dt=this._disp.scrollTop(),
		
			end_top = dt, end_left =  dw / 2 - this._box.width() / 2,
		
			height=this._box.height(),
		
			wrapper=this._wrapper,
		
			ease=this._ease,
			
			mc=this._mc,
		
			w=(this._expand)?this._box.width():"964px";
			
			if(val){
				w=val[0];
				height=val[1]
			}
			
			if(end_left<0)end_left=0;
			
			this._box.css({"height":"40px","width":"40px"})
			this._dummy.height(height-35);
			var top = dt, left = dw / 2 - 20,
			box=this._box,
			make=this._make;
			if (top < 39) 
				top = 39;
			if(end_top<39)
				end_top=39;
			wrapper.hide();
			box.css({
				"left": left,
				"top": top,
				"display":"block"
			}).animate({
				"width":w,
				"height":height,
				"left": end_left,
				"top": end_top
			},this._ini.time,ease,function(){
				util.createLeakFreeClosure(wrapper.fadeIn(800,function(){
				if(box.hasClass("window_swf_big") && util.ie==true){
						var val=$("div.swf_size",box).html().split(",")
					make(box,"div.st_swf_big",val[0],val[1],mc)
				}else if(box.hasClass("window_swf") && util.ie==true){
					make(box,"div.st_swf",600,360,mc)
				}
					util.worker.set(function(){
						if(box.hasClass("window_flv"))util.callExternalInterface("run",box)
					});
				}))
			})
		}
		},
		stateCheck:function(state){
			if(state)this.load=state
			else return this.load;
		},
		grabble:{
			init:function(box){
				box.css({"display":"block","visibility":"hidden"})
				this._img=$(".lightbox_static img",$(box[0]));
				if(this._img.width()>600)
					this.bind(this._img);
				box.css({"display":"none","visibility":"visible"})
			},
			bind:function(img){
				img.css({"cursor":"move","position":"absolute"});
				var flag=0,_x=0;
				util.createLeakFreeClosure(
						(function(){
							img.bind("mousedown",function(e){
								e.preventDefault();
								_x=e.pageX-$(this).position().left;
								flag=1;
							})
							img.bind("mousemove",function(e){
								e.preventDefault();
								if(flag==1){
									if(e.pageX-_x>=(600-$(this).width()) && e.pageX-_x<=0){
										$(this).css("left",e.pageX-_x);
									}
								}
							})
						})()
				)
				img.bind("mouseup",function(){
					flag=0;
				})
			}
		},
		makeFlv:function(box){
			if(SWFObject){
				var swf=$("div.swf",$(box[0])),ob=$("div.flv_path",$(box[0])),so = new SWFObject("/GENERAL/SWF/flv.swf", "external_"+box.attr("id"), "525", "455", "9","#cccccc");
				so.addParam("allowScriptAccess","always")
				so.addVariable("url", ob.text());
				so.addParam("wmode","transparent")
				so.write(swf.attr("id"));
				so=ob=swf=null;
			}
		},
		makeSwf:function(box,n,w,h,mc){
			if(SWFObject){
				var swf=$(n,box),path=$("div.swf_path",box).text(),so = new SWFObject(path, "external_"+box.attr("id"), w, h, "9", "#"+mc);
				so.addParam("base", ".");
				so.addParam("wmode","transparent")
				so.write(swf.attr("id"));
				so=swf=path=null
			}
		}
}
}

/*
 *画像めくり機能
 */

$.extend({
	imgChanger:function(){
		var init=function(){
			this._parent=$("div.img_gallery2");
			this._big_img=$("div.ig2_big_img");
			this._thumb_img=$("a.ig_thumb_a");
		//	this._exp=$("div.lb_exp");
			this._big_img.hide();
		//	this.grabble=lightboxInit.prototype.extend.grabble;
		}
		init.prototype.set=function(){
			for(var m=0,leng=this._big_img.length;m<leng;m++) {
				var img=$("img",$(this._big_img[m]));
				//for(var i=0,len=img.length;i<len;i++)this.grabble.bind($(img[i]))
			}
			for(var m=0,leng=this._parent.length;m<leng;m++) $("div.ig2_big_img",$(this._parent[m])).eq(0).show();
		for(var m=0,leng=this._parent.length;m<leng;m++) {
				var list=$("ul.img_gallery2_thumb li:first",this._parent.eq(m)),
				node=$("div.lb_exp",list);
				if(node.size()>0)
					node.show();
			}
			var ob=true;
			for(var i=0,len=this._parent.size();i<len;i++)
				for(var x=0,len2=$("a.ig_thumb_a",this._parent.eq(i)).size();x<len2;x++){
				util.createLeakFreeClosure((function(node,big){
					if(x==0)node.css("border","1px solid #c71444").addClass("stay_")
					if(!/\.jpg|\.png|\.gif/.test(node.children("img").attr("src"))){
						node.remove();
						return false;
					}
					node.bind("click",function(e){
						e.preventDefault();
						var lb_w=$(this).parents(".window_hl"),v=$("div.ig2_big_img:visible",lb_w),t=$("div.lb_exp:visible",lb_w),text=$(this).next();
						if(v[0]!==big[0] && ob==true){
							ob=false;
							$("a.stay_",lb_w).css("border","1px solid #cccccc").toggleClass("stay_",false)
							$(this).css("border","1px solid #c71444").addClass("stay_")
							t.hide()
							v.hide()
							if(text.size()>0)text.show()
							big.show();
							ob=true
						}
					});
				})($("a.ig_thumb_a",this._parent.eq(i)).eq(x),$("div.ig2_big_img",this._parent.eq(i)).eq(x)))
			}
		}
	return new init();
},
lightboxResizer:function(){
	$(window).bind("resize",function(){
		var vl=$("div.lightbox_window:visible"),mask=$("#mask,#mask_op")
		ww=$(window).width(),cw=$("#contents").width()
		if(vl.size()>0)
			if(ww-vl.width()>1){
				vl.css("left",$(window).width()/2-vl.width()/2)
				mask.width((ww<cw)?cw+10:ww)
				mask.height($(document).height())
			}
			else{ 
				vl.css("left",0)
				mask.width((ww<cw)?cw+10:ww)
				mask.height($(document).height())
			}
	})
}
})


//実行部分
window.lightbox=function(ini){
	var lightBox=new lightboxInit("core");
	if(ini){
		lightBox.ini(ini)
		util.saveSettings(ini);
	}
	lightBox.nodeTraversal();
	if(!ini.ajax)lightBox.lightboxTraversal();
	if(ini.ajax || lightBox.extend.stateCheck()=="complete")
	util.deleter(
		//deconcept,
		lightBox,
		//FlashObject,
		//SWFObject,
		util.createLeakFreeClosure
	)
}
lightbox.subset={
	live:function(node,b){
		var lightBox=new lightboxInit("subset.live");
			if(util.ini)lightBox.ini(util.ini);
			lightBox.nodeTraversal(node);
			pngToGif();
			if(b){
				lightBox.sync.notify($(lightbox.special.openID))
				lightbox.subset.trigger($(lightbox.special.openID));
				lightbox.special.openID=undefined;
			}
			util.deleter(
				//deconcept,
				lightBox,
				//FlashObject,
			//	SWFObject,
				util.createLeakFreeClosure
			)
	},
	one:function(node,lb_window,ca,bool){
		if(typeof(node)=="string")node=$(node)
		if(typeof(lb_window)=="string")lb_window=$(lb_window)
		var lightBox=new lightboxInit("subset.one");
		lightBox.one(node,lb_window,ca,bool)
		util.deleter(
				//deconcept,
				lightBox,
				//FlashObject,
			//	SWFObject,
				util.createLeakFreeClosure
		)
	},
	trigger:function(w,c,t,m){
		if($("#lightbox_area").size()>0)$("#lightbox_area").show();
		if(typeof(w)=="string")w=$(w)
		var ini={fx:"fade",time:500} 
		obj={
			_box:w,
			_mask:(m)?m:$("#mask"),
			_disp:$(document),
			_wrapper:$("div.lightbox_wrapper",w),
			_dummy:$("div.dummy_bg",w.eq(0)),
			_ini:ini,
			_make:lightboxInit.prototype.extend.makeSwf,
			_expand:false,
			_ease:ini.ease || "swing"
		}
		obj._mask.css({
			"width": $("window").width(),
			"height": $(document).height()
		}).fadeIn(300);
		lightboxInit.prototype.extend.fx.scale.call(obj);
	},
	autoOpen:function(){
			var obj={_url:location.hash};
			id=lightboxInit.prototype.getLightboxObj.call(obj)
			if(id){
				var open_type=(typeof id=="string")?id.split("-"):[];
				if(open_type[1]){
					lightbox.special.firstCategory=open_type[1];
					lightbox.special.openID=open_type[0];
				}else{
					lightbox.subset.trigger(id)
				}
			}
	}
}
lightbox.special={
	changeTriggerCondition:function(){
		(arguments.length>1)?
			lb.special.changeSys.changeTriggerCondition(arguments[0],arguments[1]) :
			lb.special.changeSys.changeTriggerCondition(arguments[0]);
	},
	getSettings:function(){
		return util.ini
	},
	firstCategory:"",
	openID:undefined,
	wrapperInitilizer:function(){
		if($("#lightbox_area").size()<1){	
			var lb=$("div.lightbox_window"),clone=lb.clone();

			if($("#right_column").size()<1)
				$("#contents").append("<div id=\"lightbox_area\"></div>");
			else 
				$("#right_column").append("<div id=\"lightbox_area\"></div>");
				
			$("#lightbox_area").append(clone);
			
			lb.remove();
		}
	}
}

$(function(){
	lightbox.special.wrapperInitilizer();
	$.lightboxResizer();
	$(window).bind("unload",function(){
		//	delete util,lightboxInit,lightbox,jQuery,$;
		//	if(typeof(SWFObject)=="function")delete SWFObject
	})
})
})(jQuery)
