//==================================================================
//font change [jQuery]
//==================================================================
//$(document).ready(function() {
//	if($.cookie("css")) {
//		$("#fontcahge").attr("href",$.cookie("css"));
//	}
//	$("#fontChList li a").click(function() {
//		$("#fontcahge").attr("href",$(this).attr('rel'));
//		$.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});
//		return false;
//	});
//});

//==================================================================
//font change [jQuery]
//==================================================================

jQuery(function($){
    //変数にクッキー名を入れる
    var history = $.cookie('fontSize');
	
    //適用する箇所を指定。今回は部分的に#test内のpに
    var elm = $('body');
	
    //変数が空ならfontMを、空でなければクッキーに保存しておいたものを適用
    (!history)? elm.addClass('pageFont_n'):elm.addClass(history);
	
    //クリックしたら実行
    $('li','#fontChList').click(function(){
	
        //クリックした要素のID名を変数にセット
        var setFontSize = this.id;
	    
        //クッキーに変数を保存
				//$.cookie('fontSize', setFontSize);
				
				// 調整　パス：：：クッキーに変数を保存
	    $.cookie('fontSize', setFontSize,{expires: 365, path: '/'});
	
        //一度classを除去して、変数をclassとして追加
        elm.removeClass().addClass(setFontSize);
    });
});


//==================================================================
//:first-child, :last-child [jQuery]
//==================================================================
$(function(){
    $('body :first-child').addClass('firstChild');
    $('body :last-child').addClass('lastChild');
});


//==================================================================
//Equal Height Columns with jQuery [jQuery]
//==================================================================

function equalHeight(group) {
 tallest = 0;
 group.each(function() {
 thisHeight = $(this).height();
 if(thisHeight > tallest)
 {
 tallest = thisHeight;
 }
 });
 group.height(tallest);
}

// Footer の高さを。
$(document).ready(function() {
    equalHeight($("#footerML,#footerMenuContent"));
				equalHeight($("div.footerBCset"));
});


/*
Usage:
$(document).ready(function() {
    equalHeight($(".recent-article"));
    equalHeight($(".footer-col"));
});

//.hogeの中にあるdivの高さを全て同じにする  
        equalHeight($("div.hoge > div"));  
  
        //.hoge-singleを付与された要素同士の高さを揃える  
        equalHeight($("div.hoge-single"));  
  
        //.hoge-Lと.hoge-Rの高さを揃える  
        equalHeight($("div.hoge-L,div.hoge-R")); 
								
*/

//==================================================================

//==================================================================
//rollover.js
//==================================================================

function initRollOvers() {
	if (!document.getElementById){
		return;
	}
	
	var preLoads = new Array();
	var allImages = document.getElementsByTagName('img');

	for (var i = 0; i < allImages.length; i++) {		
		if (allImages[i].className == 'imgover') {
			var src = allImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var oSrc = src.replace(ftype, '_over'+ftype);

			//-- 
			allImages[i].setAttribute('pSrc', src);
			allImages[i].setAttribute('oSrc', oSrc);

			//-- 
			preLoads[i] = new Image();
			preLoads[i].src = oSrc;

			//-- 
			allImages[i].onmouseover = function() {
				this.setAttribute('src', this.getAttribute('oSrc'));
			}
			allImages[i].onmouseout = function() {
				this.setAttribute('src', this.getAttribute('pSrc'));
			}
		}
	}
}

function addOnload(func){
	if ( typeof window.addEventListener != "undefined" ){
		window.addEventListener( "load", func, false );
	}else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", func );
	}else{
		if ( window.onload != null ){
			var oldOnload = window.onload;
			window.onload = function ( e ) {
			oldOnload( e );
			window[func]();
		};
	}else
		window.onload = func;
	}
}
addOnload(initRollOvers);
