// need jQuery 1.3.2 or later
/*  ================================================================================
menu Active
================================================================================  */

$(document).ready(function(){
var href = location.href.split('#')[0];
var href2 = href.replace(/\/\/(.*)\/(.*)\/(.*)\/(.*)\/(.*)/,'//$1/$2/$3/');
{
$('#nav h2 a').each(function(){
if(href == this.href)$(this).parent().parent().addClass('active');
if(href == this.href)$(this).parent().addClass('active');
if(href == this.href)$(this).addClass('active');
if(href2 == this.href)$(this).parent().parent().addClass('active');
if(href2 == this.href)$(this).parent().addClass('active');
if(href2 == this.href)$(this).addClass('active');
});
}});

$(document).ready(function() {
	if(location.pathname != "/") {
		$('#globalNav li a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
	} else $('#globalNav li a:eq(0)').addClass('');
});

jQuery(document).ready(function() {
	if(location.pathname != "/") {
		var now = location.href.split('/');
		var endDir = now.slice(now.length-2,now.length-1);
		jQuery('#nav h2 a[href$="'+endDir+'/"]').addClass('active');
	}
});

/* ================================================================================
blank
================================================================================  */
$(document).ready( function () {
    $('.blank').click(function(){
        window.open(this.href, '_blank');
        return false;
    });
});

/*  ================================================================================
wordBreak
================================================================================  */
$(function(){
    var $targetElement = '.wordBreak';
    if($.browser.msie) {
        $($targetElement).css('word-break', 'break-all');
    } else {
        $($targetElement).each(function(){
            if(navigator.userAgent.indexOf('Firefox/2') != -1) {
                $(this).html($(this).text().split('').join('<wbr />'));
            } else {
                $(this).html($(this).text().split('').join(String.fromCharCode(8203)));
            }
        });
    }
});


/*  ================================================================================
IE クリックライン消
================================================================================  */
$(function(){$("a").focus(function(){ $(this).blur() })});

/*  ================================================================================
イメージロールオーバー
================================================================================  */
/* フィールター版　*/
$(document).ready(function(){
  $('')//ここにフィルタをかけるものを定義
    .mouseover(function(){
        $(this).animate({opacity: 0.5}, 'fast');
    })
    .mouseout(function(){
        $(this).animate({opacity: 1.0}, 'fast');
    });
});

/* スワップ版 */ 
jQuery.fn.rollover = function(suffix) {
	suffix = suffix || '_ov';
	var check = new RegExp(suffix + '\\.\\w+$');
	return this.each(function() {
		var img = jQuery(this);
		var src = img.attr('src');
		if (check.test(src)) return;
		var _ov = src.replace(/\.\w+/, suffix + '$&');
		jQuery('<img>').attr('src', _ov);
		img.hover(
			function() { img.attr('src', _ov); },
			function() { img.attr('src', src); }
		);
	});
};
jQuery(function($) {
	// 基本
	$('#global-nav ul li a img').rollover();

	// input
	//$('form input:image').rollover();

	// 複数指定
	//$('#nav a img, form input:image').rollover();

	// 引数で _on の部分を指定する
	$('#nav a img').rollover('_ov');
});

/*  ================================================================================
擬似クラスをクラスに
================================================================================  */
$(function(){
$(".section.life02 div.dailyEntry:last-child").addClass("last-child");
$(".section.facl15 div.pulndEntry:last-child").addClass("last-child");
$(".section.enroll01 div.photoEntry:last-child").addClass("last-child");
//$("body :first-child").addClass("first-child");
//$("body :last-child").addClass("last-child");
//$("li:nth-child(even)").addClass("even");
//$("dt:even").addClass("even");
//$("dd:even").addClass("even");
//$("body :only-child").removeClass("first-child").removeClass("last-child");
});
/*  ================================================================================
scroll easing
================================================================================  */
$(document).ready(function(){
  $('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;
   }
 }
  });
});
