// JavaScript Document



var wH;

var wW = 850;



$(function(){

	wH = $("#container").height();	

	moviebox();
	
	/* setTimeout(function(){
		
	}, 22000); */

	$("#mb1").click(function(){

		moviebox();

	});



	$("#bg").click(function(){

		

		$(this).next().slideUp(500, function(){

			$(this).parent().css({

				"display": "none"

			});

			$("#artistPlayer").remove();

			$(this).append("<div id='artistPlayer'>動画を再生するには最新のFlash Playerが必要です。</div>");

		});

		

		$(window).unbind("resize");

	});

	

	$("p#close").click(function(){

		$(this).parent().slideUp(500, function(){

			$(this).parent().css({

				"display": "none"

			});

			$("#artistPlayer").remove();

			$(this).append("<div id='artistPlayer'>動画を再生するには最新のFlash Playerが必要です。</div>");

		});

		$(window).unbind("resize");

	});


})



function moviebox(){

	

	var flashvars3 = {};



	var attributes3 = {

		id: "artistPlayer",

		name: "artistPlayer"

	};

	

	var params3 = {

		allowScriptAccess: "always",

		allowFullScreen: "false",

		quality: "high",

		wmode: "transparent"

	};



	swfobject.embedSWF("swf/artistPlayer.swf", "artistPlayer", "496", "413", "10.0.22.87", "", flashvars3, params3, attributes3, function(){

		$("#movie").css({"display": "block"});

		sizeSet("#movie");

		$("#movie").children(".popcontents").slideDown(500);

	});



	

	$(window).bind("resize", function(){

		sizeSet("#movie");

	});

}

function moviebox_off(){
	$("#bg").next().slideUp(500, function(){

			$(this).parent().css({

				"display": "none"

			});

			$("#artistPlayer").remove();

			$(this).append("<div id='artistPlayer'>動画を再生するには最新のFlash Playerが必要です。</div>");

		});

		$(window).unbind("resize");
}

function sizeSet(id){

	var h = $(window).height();

	var w = $(window).width();

	

	h = (h > wH) ? h : wH;

	w = (w > wW) ? w : wW;

	

	$(id).css({

		"width": w,

		"height": h

	});

	

	$(id).children(".bg").css({

		"width": w,

		"height": h

	});

	

	var cH = 423;

	var cW = 496;

	

	var mt = (($(window).height()-cH)/2 > 0) ? ($(window).height()-cH)/2: 0;

	var ml = (($(window).width()-cW)/2 > 0) ? ($(window).width()-cW)/2: 0;

	

	$(id).children(".popcontents").css({

		"top": mt,

		"left": ml

	});

}
