// jQuery Document

$(function() {
	
	// 慣例的な first-child クラス指定
	$("h2:first").addClass("first-child");
	$("h3:first-child").addClass("first-child");
	$("h4:first-child").addClass("first-child");
	$("h5:first-child").addClass("first-child");
	
	// 偶数のテーブルセルに even クラスをつける（色付用）
	$("table tr:even").addClass("even");
	
	// afterclear
	$(".afterclear").append("<span class='afterclearElem'></span>");
	
	// パンくずリストのスタイルを生成
	$("#pathlist li:last-child").addClass("last-child").wrapInner("<span></span>");
	
	// 外部リンクに target="_blank" をつける
	$("a[href^='http://']").attr("target","_blank");
	$("a[href^='https://']").attr("target","_blank");
	
	// img要素を内包しない外部リンクに.externalLinkクラスをつける
	$("a[href^='http://']:not(:has(img))").addClass("externalLink");
	$("a[href^='https://']:not(:has(img))").addClass("externalLink");
	
	// img要素を内包しないPDFへのリンクに.pdfクラスをつける
	// 外部pdfへの直リンクの場合はexternalLinkクラスを外す など
	$("a[href$='.pdf']").attr("target","_blank");
	$("a[href$='.pdf']:not(:has(img))").addClass("pdf").removeClass("externalLink");
	$("a[href$='.txt']:not(:has(img))").addClass("txt").attr("target","_blank").removeClass("externalLink");
	$("a[href$='.doc']:not(:has(img))").addClass("word").removeClass("externalLink");
	$("a[href$='.xls']:not(:has(img))").addClass("xls").removeClass("externalLink");
	$("a[href$='.ppt']:not(:has(img))").addClass("ppt").removeClass("externalLink");
	
   	// スムーススクロール
	$('a[href^=#]').click(function(){
    	var speed = 200; // ミリ秒
    	var href= $(this).attr("href");
    	var target = $(href == "#" || href == "" ? 'html' : href);
    	var position = target.offset().top;
    	$($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
    	return false;
   	});
	
	// 連続するテーブルに even クラスをつける（色付用）
	$(".res-documents:even").addClass("even");
	
	// オールドブラウザに対してアラートを表示
	$("#oldbrowser").load("../oldbrowser.html");

});

// 閉じるボタンでインフォメーションボックスを消す
function setRead(){
	$("#imp-info").attr("class","");
	$("#imp-info").hide("slow", function(){
		$(this).addClass("none");
	});
	$.cookie("alrRead","none",{expires:14});
}
