/*------------------------------------------------------*/
/* loading box.js */
/*------------------------------------------------------*/
/*
2011.02.11
version: 1.1
--------------------------------------------------------*/
var loadingbox = function(args){
	this.box;
	this.box_inner;
	this.box_content;
}

loadingbox.prototype = {
	init: function(){
		//load event handler
		this.event_init();
	},
	
	event_init: function(){
		var winheight = $(window).height();
		//div
		self.box = $("#loadingbox");
		self.box_inner = $("#loadingbox_inner");
		self.box_content = $("#loadingbox_content");
		
		//bind functions
		$(".close").bind("click",function(){ close(); });
		//Click Function
		$(".loadingbox a").bind("click",function(){
			hiddenselect();
			$(self.box).css("opacity", "0.8");
			var loadingurl = "index/prettyphoto.html";
			$(self.box_content).load(loadingurl,null,function(){
				box_pos();
				//$("#country").css("display","none");
				$(self.box).fadeIn("slow");
				$(self.box_inner).fadeIn("slow");
			});
			//each function
			
		});
		$("#loadingbox").click(function(){
			//$("#country").css("display", "block");
			$(self.box).fadeOut("fast");
			$(self.box_inner).fadeOut("fast");
			showselect();
		});
		//close btn
		function close(){
			//$("#country").css("display","block");
			$(self.box).fadeOut("fast");
			$(self.box_inner).fadeOut("fast");
			showselect();
		}
		
	}	
}
function hiddenselect(){
	if (typeof document.body.style.maxHeight != "undefined") {
	} else {
    // IE6, older browsers
	   $("#country").css("display", "none");
	}
}
function showselect(){
	if (typeof document.body.style.maxHeight != "undefined") {
	} else {
    // IE6, older browsers
	   $("#country").css("display", "block");
	}
}
function box_pos(){
	var box = $("#loadingbox_inner");
	var winW = $(window).width();
	var winH = $(window).height();
	var boxW = box.width();
	var boxH = box.height();
	var headerheight = 185 / 2;
	
	var posX = (winW - boxW) / 2;
	var posY = (winH - boxH) / 2;
	
	var btnposY = winH / 2 - 22;
	var btnposX_left = winW/2 - (boxW / 2) - 83;
	var btnposX_right = winW / 2+ (boxW / 2) + 45;
	box.css("left",posX + "px");
	box.css("top",posY + "px");
	
	var docheight = $(document).height();
	$("#loadingbox").css("height",docheight + "px");
}
$(window).resize(function(){
    box_pos();
});

/*初期化、実行*/
$(function(){
	box_pos();
	$(".close").mouseover(function(){ $(this).addClass("over");});
	$(".close").mouseout(function(){ $(this).removeClass("over");});
	$("#region").mouseover(function(){ $(this).addClass("region_hover");});
	$("#region").mouseout(function(){ $(this).removeClass("region_hover");});
	var loadbox = new loadingbox();
	loadbox.init();
});
