var dtSettings = {
		"bSortClasses" : true,
		"bJQueryUI" : true,
		"bPaginate" : false,
		"bFilter" : false,
		"bSort" : true,
		"aaSorting": [[ 0, "asc" ]],
		"iDisplayLength": 25,
		"aLengthMenu": [[25, 50, -1], [25, 50, "All"]],
		"bInfo" : false,
		"bAutoWidth" : true,
		"sDom":'fT<"clear">rtpi',
		"oLanguage": {
			"sSearch":"篩選", 
			"sLengthMenu": "Display _MENU_ records per page",
			"sZeroRecords": "<font color=#2B65EC>無資料</font>",
			"sInfo": "共  _TOTAL_ 筆資料",
			"sInfoEmpty": "顯示0筆資料",
			"sInfoFiltered": "(從 _MAX_ 筆資料中篩選 )"
		}
};

function beautifyButton(){
	$("input:button").button();
}

function backToMain() {
	location.href = "/thb";
}

function getWeatherInfo(){
	$.ajax({
		url:"weather.do",
		data:{"urlPrefix":weatherUrlPrefix,"urlSuffix":weatherUrlSuffix,"counties":"keelung city%taipei city%new taipei city%taoyuan county%hsinchu county%miaoli county%taichung city%changhua county%nantou county%yunlin county%chiayi county%tainan city%kaohsiung city%pingtung county%yilan county%hualien county%taitung county"},
		type:"post",
		dataType:"json",
		error:function(err,status){
			//alert("error when getWeatherInfo"+status);
		},
		success:function(res){
			$.each(res,function(index,item){
				weatherMap.put(item.county,item);
			});
		}
	});
}

function showWeatherInfo(addr){
	var county = "";
	var countyEngName = "";
	if (addr.indexOf("基隆市") > -1){
		county = "基隆";
		countyEngName = "keelung city";
	}else if (addr.indexOf("台北市") > -1 ) {
		county = "台北市";
		countyEngName = "taipei city";
	}else if (addr.indexOf("新北市") > -1) {
		county = "新北市";
		countyEngName = "new taipei city";
	}else if (addr.indexOf("桃園縣") > -1) {
		county = "桃園";
		countyEngName = "taoyuan county";
	}else if (addr.indexOf("新竹縣") > -1) {
		county = "新竹";
		countyEngName = "hsinchu county";
	}else if (addr.indexOf("苗栗縣") > -1) {
		county = "苗栗";
		countyEngName = "miaoli county";
	}else if (addr.indexOf("台中市") > -1) {
		county = "台中";
		countyEngName = "taichung city";
	}else if (addr.indexOf("彰化縣") > -1) {
		county = "彰化";
		countyEngName = "changhua county";
	}else if (addr.indexOf("南投縣") > -1) {
		county = "南投";
		countyEngName = "nantou county";
	}else if (addr.indexOf("雲林縣") > -1  ) {
			county = "雲林";
			countyEngName = "yunlin county";
	}else if (addr.indexOf("嘉義縣") > -1  ) {
		county = "嘉義";
		countyEngName = "chiayi county";
	}else if (addr.indexOf("台南市") > -1) {
		county = "台南";
		countyEngName = "tainan city";
	}else if (addr.indexOf("高雄市") > -1) {
		county = "高雄";
		countyEngName = "kaohsiung city";
	}else if (addr.indexOf("屏東縣") > -1) {
		county = "屏東";
		countyEngName = "pingtung county";
	}else if (addr.indexOf("宜蘭縣") > -1) {
		county = "宜蘭";
		countyEngName = "yilan county";
	}else if (addr.indexOf("花蓮縣") > -1) {
		county = "花蓮";
		countyEngName = "hualien county";
	}else if (addr.indexOf("台東縣") > -1) {
		county = "台東";
		countyEngName = "taitung county";
	}
	
	var weatherItem = weatherMap.get(countyEngName);
	if (weatherItem != null) {
		var info = "<font size=2 color=blue>"+county+" "+weatherItem.condition+" "+weatherItem.temperature+"℃ "+weatherItem.humidity+"</font>";
		if (weatherItem.icon != ""){
			info = "<img src='http://www.google.com/"+weatherItem.icon+"' width=24px height=24px />&nbsp;&nbsp;"+info;
		}
		$("#weatherTd").html(info);
	}
}











































