﻿var prepareTimeFontSize = function(){
	var width = window.innerWidth ? window.innerWidth : document.getElementsByTagName("body")[0].offsetWidth;
	var height = window.innerHeight ? window.innerHeight : document.getElementsByTagName("body")[0].offsetHeight;
	var size = height;
	if (width < height) {
		size = width;
		var fontsize = size * 0.18;
		var fontsize_info = size * 0.05;
		var fontsize_next = size * 0.05;
	} else {
		var fontsize = size * 0.25;
		var fontsize_info = size * 0.08;
		var fontsize_next = size * 0.06;
	}
	if (fontsize < 14) { fontsize = 14; }
	if (fontsize_info < 11) { fontsize_info = 11; }
	if (fontsize_next < 11) { fontsize_next = 11; }
	$("info").style.fontSize = fontsize_info + "px";
	$("nextinfo").style.fontSize = fontsize_next + "px";
	$("time").style.fontSize = fontsize + "px";
	var time_top = ((height - fontsize) / 3);
	var info_height = Element.getHeight($("info"));
	if (time_top < info_height) {
		time_top = info_height;
	}
	$("time").style.top = time_top + "px";
}

var getTasks = function() {
	var url = api_url;
	var now = new nowDateTime();
	var msec = now.getTime();
	var updatestr = "";
	if (last_update != null) {
		updatestr = last_update;
	}
	var dateFormat = new DateFormat("yyyy/MM/dd");
	var reqdate = dateFormat.format(now);
	if (setdate != null) {
		reqdate = setdate;
	}
	$("busy").src = this_url + "/images/loader.gif";

	new Ajax.Request(url, {
		method: "get",
		parameters: "cache="+msec+"&update="+encodeURI(updatestr)+"&timeoffset="+encodeURI(time_offset)+"&timezone="+encodeURI(time_zone)+"&reqdate="+encodeURI(reqdate)+"&xmlurl="+encodeURI(xmlurl),
		onSuccess:function(httpObj) {
			var res = httpObj.responseText;
			loadSuccess(res);
		},
		onFailure:function(httpObj) {
			//window.alert('サーバーとの通信でエラーが発生しました。');
			$("busy").src = this_url + "/images/spacer.gif";
		}
	});
}


