$(document).ready(function(){

	//選單換圖效果
	//參考來源：Mika Tuupola - http://www.appelsiini.net/2007/6/sequentially-preloading-images
    $("img.current").each(function() {
		s = $(this).attr("src").replace(/\.(gif)$/i, "_h.$1");
        $(this).attr("src", s);
	});
    $("img.hover").hover(function() {
        s = $(this).attr("src").replace(/\.(gif)$/i, "_h.$1");
        $(this).attr("src", s);
    }, function() {
        s = $(this).attr("src").replace(/_h\.(gif)$/i, ".$1");
        $(this).attr("src", s);
    });
	
	//same height
	if ($("#nav").height()<$("#content").height()){
		h = $("#content").height();
		if (h <450) {
			$("#nav").height(450);
			$("#content").height(450);
		} else{
			$("#content").height(h+20);
			$("#nav").height(h+20);
		}
	} else{
		h = $("#nav").height();
		if (h<450){
			$("#nav").height(450);
			$("#content").height(450);
		} else
		$("#content").height(h);
	}
	
	//判斷檔案類型顯示不同圖示，並將檔案開啟在新視窗（word、pdf）
	$("#content table.table1 a").each(function(){
		if ($(this).attr("href").indexOf(".pdf") !== -1) {$(this).after(" <img src='img/ic_pdf.png' align='absmiddle' />")};
		if ($(this).attr("href").indexOf(".doc") !== -1) {$(this).after(" <img src='img/ic_word.png' align='absmiddle' />")};
	});
	
	//相關辦法表格樣式（換行變色）
	$(".table1 tbody tr:odd").addClass("alt");
	$(".table1 tbody tr").each(function(){
		$(this).children("td:last").addClass("last");
	});
});