﻿// JavaScript Document
//圖片自適用高寬
function DrawImage(ImgD,FitWidth,FitHeight){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		if(image.width/image.height>= FitWidth/FitHeight){ 
			if(image.width>FitWidth){ 
				ImgD.width=FitWidth; 
				ImgD.height=(image.height*FitWidth)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			}
		}else{ 
			if(image.height>FitHeight){ 
				ImgD.height=FitHeight; 
				ImgD.width=(image.width*FitHeight)/image.height; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			}         
		}     
	} 
}

$(document).ready(function(){
	$("a").focus(function(){this.blur();});			   
});

//當前時間函數
var timr;
function showdate(c){
	clearTimeout(timr);
	var date=new Date();
	var Y=date.getFullYear();
	var M=date.getMonth()+1;if(M<10)M="0"+M
	var D=date.getDate();if(D<10)D="0"+D
	var H=date.getHours();if(H<10)H="0"+H
	var Min=date.getMinutes();if(Min<10)Min="0"+Min
	var S=date.getSeconds();if(S<10)S="0"+S
	var Week=date.getDay();
	var w;
	switch(Week){
		case 1:
			w="一";
			break;
		case 2:
			w="二";
			break;
		case 3:
			w="三";
			break;
		case 4:
			w="四";
			break;
		case 5:
			w="五";
			break;
		case 6:
			w="六";
			break;
		case 7:
			w="日";
			break;
	}
	$("."+c).html(Y+"-"+M+"-"+D+"&nbsp;星期"+w+"&nbsp;"+H+":"+Min+":"+S);
	timr=setTimeout("showdate('"+c+"')",1000);
}

//数字转换成汉字函数
function num2chinese(num)  {  
var chinese=['〇','一','二','三','四','五','六','七','八','九'];  
var num=""+num+"";
var numLen=num.length;
var result="";  
	for(var i=0;i<numLen;i++)  {  
   		result+=chinese[num.slice(i,i+1)];
	}  
return result
}