// JavaScript Document movieBox

$(function(){
	$(".lead_r p").hover(function(){
		$(this).css("cursor","pointer");
	});
		$(".lead_r p").click(function(){
			$("#container").before('<div class="movieBox"></div>');	
			$(".movieBox").css("width",$(document).width());
			$(".movieBox").css("height",$(document).height());
			$(".movieBox").css("top",0);
			$(".movieBox").hide();
			$(".movieBox").fadeTo(500,0.8);
			$(".movieBox").after('<div class="movie"></div>');
			
			var loadFile = null;
			switch($(this).attr("id")){
				case "foodMovie":
				loadFile = "food.html"
				break;
				case "petMovie":
				loadFile = "pet.html"
				break;
				case "wedMovie":
				loadFile = "wed.html"
				break;
			}
			
			$(".movie").load(loadFile,loadComp);
		})
		
		function loadComp(){
			bgClick();
			var w =0;
			var h =0;
			
				/*if (navigator.platform.indexOf("Win") != -1) {
					// windows
					h =  $('html,body').scrollTop()+50;
					//($(window).height()*0.5)-(510*0.5);
					w = ($(window).width()*0.5)-(840*0.5);
				}
				else {
					// other
					h =  $('html,body').scrollTop()+50;
					//(window.innerHeight*0.5)-(510*0.5);
					w = ($(window).width()*0.5)-(840*0.5);
				}*/

	//alert($(".movieBox").width());
	
	/*2011 10/24　yagi　*/
			var obj = new Object();
			obj.x = document.documentElement.scrollLeft || document.body.scrollLeft;
			obj.y = document.documentElement.scrollTop || document.body.scrollTop;
			obj.w =document.documentElement.clientWidth;
			obj.h =document.documentElement.clientHeight;

			x=obj.x;
			y=obj.y;
			w=obj.w;
			h=obj.h;			
			
			//動画のサイズ　840ｘ510
			$(".movie").css("top",(y+h/2) - (510*0.5));
			$(".movie").css("left",(w/2)-(840*0.5));
			
		}
		
		function bgClick(){
			$(".movieBox").click(function(){
				$(".movie").remove();
			//	$(".movieBox").remove();
				$(".movieBox").fadeOut(300,removeFunc);
			})
		}
		
		function removeFunc(){
			$(".movieBox").remove();
		}
		
})
