$(document).ready(function() {	
	
	//標題flash光澤特效
	$("#flash a").media({
		bgColor: 'transparent',
		width:573, 
		height:124, 
		autoplay: true,
		params:    {quality: 'high', wmode: 'transparent'}
	});
		
	//播放影片
	$(".media").media({
		bgColor: '#e1f1ff',
		width:180, 
		height:200, 
		autoplay: true,
		params:    {ShowStatusBar: 'true', ShowPositionControls: 'false', Volume: '-2000'}
	});
	
	$(".large_media").media({
		bgColor: '#ffffff',
		width:400, 
		height:360, 
		autoplay: true,
		params:    {ShowStatusBar: 'true', ShowPositionControls: 'false'}
	});
	
	//homepage sidebar h1 patch
	$("#sidebar h1").eq(1).css("margin-top", "1em");
	
	//homepage welcome img patch
	$("#welcome img").eq(0).css("margin-left", "3px");
		
	//homepage #menu li:first patch
	$("#menu li:first").css("margin-left", "40px");
	
	//content table control
	$("#content table").removeAttr("style");
	$("#content table td").removeAttr("style");
	$("#content table").css("margin-left", "50px");
	$("#content p table").parent("p").css("margin-left", "0");
	$("#content table tr:odd").addClass("odd");
	
	//history back
	$("a.back").click(function(){
		window.history.go(-1);		
		return false;
	});
	
	//連結檔案圖示
	$("a[href]").each(function(){
		if ($(this).attr("href").indexOf(".pdf") !== -1) {$(this).after(" <img src='img/icon_pdf.gif' align='absmiddle' />"); $(this).attr("rel", "external")};
		if ($(this).attr("href").indexOf(".doc") !== -1) {$(this).after(" <img src='img/icon_doc.gif' align='absmiddle' />"); $(this).attr("rel", "external")};
		if ($(this).attr("href").indexOf(".zip") !== -1) {$(this).after(" <img src='img/icon_zip.gif' align='absmiddle' />"); $(this).attr("rel", "external")};
		if ($(this).attr("href").indexOf(".ppt") !== -1) {$(this).after(" <img src='img/icon_ppt.gif' align='absmiddle' />"); $(this).attr("rel", "external")};
		if ($(this).attr("href").indexOf(".xls") !== -1) {$(this).after(" <img src='img/icon_xls.gif' align='absmiddle' />"); $(this).attr("rel", "external")};
	});

	//設定將外部連結開啟在新視窗
	$("a[rel='external']").click(function(){
		window.open(this.href);
		return false;
	});
});