$(function(){
	var layer = $('#box_layer')
	,win =$('#box_window')
	,swf = $('#box_inner')
	,swf_02 = $('#box_inner_02')
	,boxlink = $("#movie")
	,boxlink_02 = $("#cm")
	,clo =$("#box_inner em")
	,clo_02 =$("#box_inner_02 em")
	,spd = 200
	,w = 720
	,wh = 360
	,p = 'px'
	,bd = $("body")
	,css_01 = {"opacity":0.6}
	,css_02 = {"opacity":1};
	layer.css(css_01);



	/*=======================================================
	mouse-event
	=======================================================*/

	boxlink.click(function(e){
		swf.show();
		swf_02.hide();
		swf.show();
		e.preventDefault();
		layer.fadeIn(spd,layerPos)
	})

	boxlink_02.click(function(e){
		swf.hide()
		swf_02.show();
		e.preventDefault();
		layer.fadeIn(spd,layerPos)
	})

	//closeボタン　ホバー
	clo.hover(hove,hove2);
	function hove(){clo.css(css_01);}
	function hove2(){clo.css(css_02);}
	
	clo_02.hover(hove3,hove4);
	function hove3(){clo_02.css(css_01);}
	function hove4(){clo_02.css(css_02);}
	
	//closeボタン　クリック
	layer.click(close);
	clo.click(close);
	function close(){win.fadeOut(spd);layer.fadeOut(spd);}

	layer.click(close);
	clo_02.click(close);
	function close(){win.fadeOut(spd);layer.fadeOut(spd);}
	
	
	/*=======================================================
	box-position
	=======================================================*/
	function layerPos(){
		var bodyW = bd.width(),
		bodyH = bd.height(),
		left = (w < bodyW)?-wh:-(bodyW>>1),
		top = (w< bodyH)?-wh:-(bodyH>>1);		
		win.css({marginLeft:left+p,marginTop:top+p}).fadeIn(spd);
	}

	
})
