/*
	init.js
	require jQuery
*/

var $j = jQuery;
//var $j = jQuery.noConflict();

// テーブルカラーストライプ
$j(function(){
	$("table.list-data tr:even, table#univ-data tr:even, table#vocational-data tr:even, table#highschool-data tr:even").addClass("even");
});

// フラットハイツ
$j(function(){
	$("#contents-nav > div.item").flatHeights();
	$("#academy-detail > div.program").flatHeights();
	$("#meal-detail > div.contents-section").flatHeights();
})

// ナビゲーションのアクティブ化
$j(function(){
	var path = location.pathname.split("/")[1];
	var filename = (location.pathname.match(".+/(.+?)$")) ? location.pathname.match(".+/(.+?)$")[1] : "/";
	if(filename == "menu.html") {
		filename = "information.html";
	}
	//console.log("directory:"+path+", filename:"+filename);
	if(path.match("index")) {
		path = "";
	}
	$j("div#message-nav ul li a, div#global-nav ul li a").each(function(){
		var link1 = $j(this).attr("href").split("/");
		var directory1;
		if(link1[0] == "http:" || link1[0] == "https:") {
			directory1 = link1[3];
		}else {
			directory1 = link1[1];
		}
		if(path == directory1) {
			$j(this).find("img").attr("src",$j(this).find("img").attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"));
		}else {
			$j(this).find("img").addClass("rollover");
		}
	});
	$j("#local-nav ul li a").each(function(){
		var link2 = ($j(this).attr("href").match(".+/(.+?)$")) ? $j(this).attr("href").match(".+/(.+?)$")[1] : $j(this).attr("href").match(".+/$");
		if(filename == link2) {
			$j(this).parent().addClass("current");
		}
	});
})

// ロールオーバー
$j(function(){
	// rolloverクラス
	$j("img.rollover, .action-nav ul li a img, #info-nav ul li a img, #assist-nav ul li a img, #lang-nav ul li a img").mouseover(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$j(this).attr("src",$j(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
	}).each(function(){
		$j("<img>").attr("src",$j(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	});
})

// 外部リンクを新規ウィンドウで開く
$j(function() {
	$j(".extlink").click(function(){
		window.open(this.href,'_blank')
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight);
		return false;
	})
});

