/**
@prefix : <http://purl.org/net/ns/doas#> .
<http://www.mfv.co.jp/common/js/base.js> a :JavaScript;
 :shortdesc "Base JavaScript";
 :created "2009-09-10";
 :license <http://www.mfv.co.jp/>;
 :dependencies "jQeryに依存します。" .
*/

// ロールオーバー
function rolloverImages() {
    var image_cache = new Object();
    $("img.rollover").not("[src*='_on.']").each(function(i) {
        var imgsrc = this.src;
        var dot = this.src.lastIndexOf('.');
        var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
        image_cache[this.src] = new Image();
        image_cache[this.src].src = imgsrc_on;
        $(this).hover(
            function() { this.src = imgsrc_on; },
            function() { this.src = imgsrc; }
        );
    });
}
$(document).ready(rolloverImages);

// ページ先頭へ
function smoothScroll(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
		var $target = $(this.hash);
		$target = $target.length && $target
		|| $('[name=' + this.hash.slice(1) +']');
		if ($target.length) {
		var targetOffset = $target.offset().top;	
		$('html,body')
		.animate({scrollTop: targetOffset}, 500);
		return false;
		}
	}
});
}
$(document).ready(smoothScroll);

// css3のクラスを追加
function css3Class() {  
	//:first-child, :last-childをクラスとして追加
	$('body :first-child').addClass('firstChild');
	$('body :last-child').addClass('lastChild');
}
$(document).ready(css3Class);
