
function openWindow(theURL, width, height, features, winName) { //v2.0
	if(typeof(width) == "undefined" || width == 0){
		width = 500;
	}
	
	if(typeof(height) == "undefined" || height == 0){
		height = 500;
	}
	
	if(typeof(features) == "undefined" || features == ""){
		features = "status=yes,menubar=no,scrollbars=yes,resizable=yes";
	}
	
	features = features + ', width = ' + width + ', height = ' + height;
	
  window.open(theURL,winName,features);
}


function moveEpisode(epiId){
	currentVol(epiId);
	
	var nextLeft =  -1 * epiId * 830 + 830;
	$('#box_inner').animate({left:nextLeft}, "fast");
	
	//nextなどの設定
	$('#box_frame ul.nextback li.back').unbind('click').click(function(){
		moveEpisode(epiId - 1);																																 
	});
	$('#box_frame ul.nextback li.next').unbind('click').click(function(){
		moveEpisode(epiId + 1);																																 
	});
	
	//ボタンを消したり出したり
	if(epiId == 1){
		$('#box_frame ul.nextback li.back').hide();
	}else{
		$('#box_frame ul.nextback li.back').show();
		
	}
	
	if(epiId == 34){
		$('#box_frame ul.nextback li.next').hide();
	}else{
		$('#box_frame ul.nextback li.next').show();
	}

}

function currentVol(epiId){
	//epiIdに併せてカレント表示を切り替える
	$('ul#epi-nav li a').removeClass('on');
	if(epiId<vol2key[2]){
		$('ul#epi-nav li:eq(0) a').addClass('on');
	}else if(epiId<vol2key[3]){
		$('ul#epi-nav li:eq(1) a').addClass('on');
	}else if(epiId<vol2key[4]){
		$('ul#epi-nav li:eq(2) a').addClass('on');
	}else if(epiId<vol2key[5]){
		$('ul#epi-nav li:eq(3) a').addClass('on');
	}else if(epiId<vol2key[6]){
		$('ul#epi-nav li:eq(4) a').addClass('on');
	}else if(vol2key[6] <= epiId){
		//do nothing
	}
}

//各volの最初を記録
var vol2key = [null, 1, 4, 9, 17, 24, 34];

$(function() {

// gnav
$('img#menuopen').click(function() {
			$('#gnav').animate({
				top: 0
			});
			$('img#menuopen').hide();
			$('img#menuclose').show();
});

$('img#menuclose').click(function() {
			$('#gnav').animate({
				top: '-210px'
			});
			$('img#menuclose').hide();
			$('img#menuopen').show();
});

//
$.scrollTo.defaults.easing = 'easeFixedBounce';
$.easing.easeFixedBounce = 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;
	}
}



	
//ナビゲーション作成
$('ul#epi-nav li').each(function(){
	//クリックされたliを取得
	var liObj = $(this);
														 
	$('a', $(this)).click(function(){
		//該当するepisodeをload
		//loadEpisode(vol2key[liObj.attr('id').replace('vol','')]);
		
		//boxを表示
		moveEpisode(vol2key[liObj.attr('id').replace('vol','')]);
		$('#box_frame').slideDown();
		
	});
});


// staff intro
$('.box_shoukai li').hover(
	function(){
		var liElement = $(this);
		$('div', $(this)).animate({width: "show"});
	},
	function(){
		$('div', $(this)).animate({width: "hide"});
	}
	
);

//アメーバ
$('#movie div.box').html("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='320' height='259' id='aa' align='middle'><param name='allowScriptAccess' value='always' /><param name='movie' value='http://vm1-1.vision.ameba.jp/mcb.swf?id=TQs52qg75nW:bhad:Oh:bh:yn5X.B/eMxPGHf7/xmLajaYVWhgKJUd:Dx/O:yH:NV:WAEcaUhOgNRFJhckOmiMq/&width=320&height=240&skin=gra' /><param value='transparent' name='wmode' /><embed src='http://vm1-1.vision.ameba.jp/mcb.swf?id=TQs52qg75nW:bhad:Oh:bh:yn5X.B/eMxPGHf7/xmLajaYVWhgKJUd:Dx/O:yH:NV:WAEcaUhOgNRFJhckOmiMq/&width=320&height=240&skin=gra' quality='high' bgcolor='#ffffff' name='FlashMovie' wmode='transparent' align='middle' width='320' height='259' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>");


$('div.box_shoukai li').each(function(){

	if($(this).attr('id').length > 0){
		$(this).click(function(){
			var thisOffset = $(this).offset();
			$('.staff-detail').css('top', (thisOffset.top - 100) + 'px');
			var staffId = $(this).attr('id').replace(/^thum_/i,'');	
			$('.staff-detail').load('/special/xmas08/personal/'+ staffId +'.html').fadeIn();
			
		});
	}
});


});


$(function(){

// accordion(toujitu)
$(".photo").each(function(){
		$("li > a", this).each(function(index){
				var $this = $(this);

				if(index > 0) $this.next().hide();

				$this.click(function(){
						var params = {height:"toggle", opacity:"toggle"};
						$(this).next().animate(params).parent().siblings()
						.children("ul:visible").animate(params);

						return false;
				});
		});
});

// sakubun
$(".sakubun").each(function(){
		$("li > a", this).each(function(index){
				var $this = $(this);

				if(index > 0) $this.next().hide();

				$this.click(function(){
						var params = {height:"toggle", opacity:"toggle"};
						$(this).next().animate(params).parent().siblings()
						.children("p:visible").animate(params);

						return false;
				});
		});
});

});


$(function() {
		$('.photo ul#gal_pre li a').lightBox();
		$('.photo ul#gal_fh li a').lightBox();
		$('.photo ul#gal_sh li a').lightBox();
		$('.photo ul#gal_present li a').lightBox();
		$('.photo ul#gal_omake li a').lightBox();
});

