﻿var popupvideoStatus = 0;
var popupvideoStatus2 = 0;

function loadpopupvideo() {
	if(popupvideoStatus==0){
		$("#backgroundpopupvideo").css({
			"opacity": "0.5"
		});
		$("#backgroundpopupvideo").fadeIn("slow");
		$(".popup-wrap").fadeIn("slow");
		popupvideoStatus = 1;
	}
}

function disablepopupvideo() {
	if(popupvideoStatus==1){
		$("#backgroundpopupvideo").fadeOut("slow");
		$(".popup-wrap").fadeOut("slow");
		popupvideoStatus = 0;
		popupvideoStatus2 = 0;
	}
}

function centerpopupvideo() {
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupvideoHeight = $(".popup-wrap").height();
	var popupvideoWidth = $(".popup-wrap").width();
	$(".popup-wrap").css({
		"position": "absolute",
		"top": "60px",
		"left": windowWidth/2-popupvideoWidth/2
	});
	
	$("#backgroundpopupvideo").css({
		"height": $(document).height()
	});
}

$(document).ready(function(){
	$(".buttonpopupvideo").click(function(){
		var dvd = $(this).attr("class").substr(23);
		if ( popupvideoStatus2 != 1 ) {
			popupvideoStatus2 = 1;
			centerpopupvideo();
			loadpopupvideo();
			$('html,body').stop().animate({scrollTop: 25}, 500);
			$(".popup-close").click(function(){
				disablepopupvideo();
			});
			return false;
		}
	});
});

function login() {
	$("#backgroundpopupvideo").css({
		"height": $(document).height(),
		"opacity": "0.5"
	}).fadeIn("slow");
	$.get("/login_allopass.html", function(datas) {
		var windowWidth = document.documentElement.clientWidth;
		var popupvideoWidth = $("#allopass_div").width();
		$("#allopass_div").html(datas).css({
			"background":"#FFF",
			"top": "140px",
			"left": windowWidth/2-popupvideoWidth/2
		}).fadeIn();
	});
}
