// JavaScript Document

var W = 0;
var H = 0;
var windowW = 0;
var windowH = 0;

$(document).ready(function() {
	$('body').setMain({});
});

(function($){
	var setMain;
	
	$.fn.setMain = setMain = function(options) {

		var settings = {
		};
		
		return this.each(function() {
			if ( options ) { 
				$.extend( settings, options );
			}
			setMain.prototype.create(settings,this);
		});
	};
	
	setMain.prototype = {		
		
		create: function(settings,elem) {
			this.element = $(elem);
			this.options = settings;
			this.init();
		},
		
		
		init: function() {
			var self = this;
			
			self.resize();
			$(window).bind("resize", function(){
				self.resize();
			});
		},
		
		resize: function() {
			var self = this;
			
			windowW = windowSizeW(W);
			windowH = windowSizeH(H);
			
			$('#wrapper').css('margin-top', (windowH-154)/2 +'px');
			
		}
		
	};
})(jQuery);

function windowSizeW(w){
	//ステージサイズを取得
	if(navigator.userAgent.indexOf("Opera") != -1){ // 文字列に「Opera」が含まれている場合
		var windowW = document.body.clientWidth;
	}
	else if(navigator.userAgent.indexOf("MSIE") != -1){ // 文字列に「MSIE」が含まれている場合
		var windowW = document.documentElement.clientWidth;
	}
	else if(navigator.userAgent.indexOf("Firefox") != -1){ // 文字列に「Firefox」が含まれている場合
		var windowW = $(window).width();
	}
	else if(navigator.userAgent.indexOf("Netscape") != -1){ // 文字列に「Netscape」が含まれている場合
		var windowW = $(window).width();
	}
	else if(navigator.userAgent.indexOf("Safari") != -1){ // 文字列に「Safari」が含まれている場合
		var windowW = $(window).width();
	}
	else{
		var windowW = $(window).width();
	}
	var w = windowW;
	
	return(w);
}
function windowSizeH(h){
	//ステージサイズを取得
	if(navigator.userAgent.indexOf("Opera") != -1){ // 文字列に「Opera」が含まれている場合
		var windowH = document.body.clientHeight;
	}
	else if(navigator.userAgent.indexOf("MSIE") != -1){ // 文字列に「MSIE」が含まれている場合
		var windowH = document.documentElement.clientHeight;
	}
	else if(navigator.userAgent.indexOf("Firefox") != -1){ // 文字列に「Firefox」が含まれている場合
		var windowH = $(window).height();
	}
	else if(navigator.userAgent.indexOf("Netscape") != -1){ // 文字列に「Netscape」が含まれている場合
		var windowH = $(window).height();
	}
	else if(navigator.userAgent.indexOf("Safari") != -1){ // 文字列に「Safari」が含まれている場合
		var windowH = $(window).height();
	}
	else{
		var windowH = $(window).height();
	}
	var h = windowH;
	
	return(h);
}
