var mainW = 960;
var mainH = 758;
var windowW;
var windowH;
var mainX;
var mainY;
var tmpW;
var tmpH;

$(document).ready(function(){
	//リサイズ設定
	onWindowResize();
	$(window).resize(function(ev){
		onWindowResize();
	});
	//ロールオーバー系設定
	var postfix = '_over';
	$("img.rollover").not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});
});

function onWindowResize(){
	windowW = $(window).width();
	windowH = $(window).height();
	mainX = Math.max(0, ((windowW - mainW) / 2));
	mainY = Math.ceil(Math.max(0, ((windowH - mainH) / 2)));
	tmpW = Math.max(windowW, mainW);
	tmpH = Math.max(windowH, mainH);

	if(navigator.userAgent.toLowerCase().indexOf("msie") > -1){
		$('div#wrapper').css('background-position', "center "+mainY);
	}else{
		$('div#wrapper').css('background-position', "center center");
	}

	$('div#container').css('width', tmpW);
	$('div#container').css('height', tmpH);
	$('div#main').css({
		"left":mainX,
		"top":mainY
	});
}


