//-----------------------------------------------------------------------
//	ロールオーバーで画像を変更
//-----------------------------------------------------------------------
function initRollOverImages($button) {
	var image_cache = new Object();
 	$($button).each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var img_ov_or_not = imgsrc.match("\_ov");
		if(img_ov_or_not == null){
			var imgsrc_on = ovImg(imgsrc);
		}else{
			var imgsrc_on = imgsrc;
		}
		
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;

		$(this).hover(
			function() { this.src = imgsrc_on; },
			function() { this.src = imgsrc; });
		});
}

function ovImg(imgsrc){
	if(imgsrc != null) {
		var dot = imgsrc.lastIndexOf('.');
		return imgsrc_on = imgsrc.substr(0, dot) + '_ov' + imgsrc.substr(dot, 4);
	}
}

$(function(){
	initRollOverImages(".nav > li > a > img");
	initRollOverImages(".nav > li > .sub > li > a > img");
	initRollOverImages(".share > li > a > img");
	
	$("#middle").hover(function(){
		$(this).css("cursor","pointer");
	},function(){
		$(this).css("cursor","default");
	});
	
	$("#large").hover(function(){
		$(this).css("cursor","pointer");
	},function(){
		$(this).css("cursor","default");
	});
});

//-----------------------------------------------------------------------
//	ポップアップウィンドウ用スクリプト
//-----------------------------------------------------------------------
var popUpWin=0;
function popUpWindow(URLStr, width, height){
  if(popUpWin){
	  	if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = window.open(URLStr, 'popUpWin', "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width="+width+",height="+height);
}


//-----------------------------------------------------------------------
//	要素の最後を変更
//-----------------------------------------------------------------------
$(document).ready(function(){
    $(".footerNav li:last").addClass("last");
    $(".news dd:last").addClass("last");
    $(".spContents img:last").addClass("last");
});


//-----------------------------------------------------------------------
//	要素の最後を変更
//-----------------------------------------------------------------------
$(function() {
	//ページ内スクロール
	$(".btn_scroll").click(function () {
		var i = $(".btn_scroll").index(this)
		var p = $("#sp").eq(i).offset().top;
		$('html,body').animate({ scrollTop: p }, '3000');
		return false;
	});
	//ページ上部へ戻る
	$(".btn_top").click(function () {
		$('html,body').animate({ scrollTop: 0 }, '3000');
		return false;
	});

});

//-----------------------------------------------------------------------
//	mainContantsを大きくする
//-----------------------------------------------------------------------
/*
jQuery(document).ready(function(){
  var winHeight = jQuery(window).height();
  var headHeight = jQuery('.header').height();
  var mainHeight = jQuery('.mainContents').height();
  var footHeight = jQuery('.footer').height();
 
  var fullHeight=mainHeight+headHeight+footHeight;
 
  if (fullHeight <= winHeight) {
   var wrapHeight = winHeight-headHeight-footHeight-96;
   jQuery(function() {
    jQuery('.mainContents').height(wrapHeight);
   });
  }
});
*/
jQuery(function(){
　　var winHeight = jQuery(window).height();
　　var headHeight = jQuery(".header").outerHeight({margin: true});
　　var mainHeight = jQuery(".mainContents").outerHeight({margin: true});
　　var footHeight = jQuery(".footer").outerHeight({margin: true});

　　var spaceHeight = mainHeight - jQuery(".mainContents").height();
　　var fullHeight = mainHeight + headHeight + footHeight;
 
　　if (fullHeight < winHeight) {
　　　　var wrapHeight = winHeight - headHeight - footHeight - spaceHeight;
　　　　jQuery(".mainContents").height(wrapHeight);
　　}
});
