﻿	$(document).ready(function() {
		/* JQuery LightBox 0.5 init */
		$("'a[rel='lightbox']").lightBox();
		/* JQuery Dialog Message */
		$("#uPopupMessage").dialog({
			autoOpen: false,
			width: 400,
			resizable: false,
			modal: true,
			draggable: false,
			buttons: {
				"確定": function() { $(this).dialog("close"); }
			}
		});
		/* Read cookie & Set Webpages Default Font Size */
		var cRootPath = "/cht/index.aspx,/eng/index.aspx,/eng/index.aspx";
		if(cRootPath.indexOf(window.location.pathname) == -1) {
			if ($.cookie('webpageDefaultFontSize') == 'big')
				setFontSize("big", false);	//如果不是各語系首頁且cookie裡有值為big，就呼叫轉大型字體，且不寫入 cookie
		} else {
			setFontSize("small", false);	//設定成小字型，但不寫入 cookie
		}
		/* Set Table Color Style */
		setTableColor();
	});
	
	/* Set Table Color Style */
	function setTableColor(){
		$("table.tableColorStyle tbody tr:visible:even").addClass("even");
		$("table.tableColorStyle tbody tr:visible:odd").addClass("odd");
	}

	/* Set Webpages Default Font Size */
	function setFontSize(jFontSize, writeCookie){
		var jDiv = $("#mainFrameRightContent div");
		if(jFontSize == "big"){
			$("#fontTypeSmall").css("background-position","-16px 0");
			$("#fontTypeBig").css("background-position","0 -16px");
			$(jDiv[1]).css("font-size","1.2em");
		}else{
			$("#fontTypeSmall").css("background-position","-16px -16px");
			$("#fontTypeBig").css("background-position","0 0");
			$(jDiv[1]).css("font-size","1em");
		}
		/* 是否將字型狀態寫入 cookie */
		if (writeCookie) {
			var cookieOptions = {expires: 365, path: '/'};	//Cookie Expires Date
			if(jFontSize == "big")
				$.cookie('webpageDefaultFontSize', 'big', cookieOptions);	//寫入 cookie
			else
				$.cookie('webpageDefaultFontSize', null, cookieOptions);	//砍掉 cookie
		}
	}
	
	/* Reset Table Color Style (somtimes for AJAX reload in page block But not all page initial) */
	function resetTableColor(cObjID){
		cObjID = "#" + cObjID + " tbody tr:visible";
		$(cObjID+":even").removeClass().addClass("even");
		$(cObjID+":odd").removeClass().addClass("odd");
	}