// JavaScript Document
var requestObj;
var isActiveX;

function initialize() {
	if(window.ActiveXObject) {
		requestObj = new ActiveXObject("Msxml2.XMLHTTP");
		if(requestObj != null)
			isActiveX = true;
	} else if(window.XMLHttpRequest) {
		requestObj = new XMLHttpRequest();
	} else {
		alert('このブラウザでは更新情報が正しく表示できません');
	}
	sendRequest('notify.xml');
}

function response() {
	if(requestObj.readyState == 4 && requestObj.status == 200) {
		var notifyDOM = requestObj.responseXML;
		var notifyItems = notifyDOM.getElementsByTagName('notify_item');
		var notifyDiv = document.getElementById('notification_mid');
		var notifyHTML = '<ul id=\"notify_list\">';
		for(i=0;i<notifyItems.length;i++) {
			var childs = notifyItems[i].childNodes;
			var dateIndex = 1;
			var increase = 2;
			if(isActiveX) {
				dateIndex = 0;
				increase = 1;
			}
			if(childs[dateIndex].tagName == 'date') {
				var date = childs[dateIndex].firstChild.nodeValue;
				var linkURL;
				var linkText;
				var notifyItem = '<li><span class=\"crosshead\">' + date + '</span><br />';
				for(n=dateIndex+increase;n<childs.length;n=n+increase*2) {
					if(childs[n].tagName == 'link_url' && childs[n+increase].tagName == 'link_text') {
						linkURL = childs[n].firstChild.nodeValue;
						linkText = childs[n+increase].firstChild.nodeValue;
						notifyItem = notifyItem + '<a href=\"' + linkURL + '\" />';
						notifyItem = notifyItem + linkText + '</a><br />';
					}
					else
						break;
				}
				notifyHTML = notifyHTML + notifyItem + '</li>';
			}
		}
		notifyDiv.innerHTML = notifyHTML + '</ul>';
	}
}

function sendRequest(url) {
	if(isActiveX)
		requestObj = new ActiveXObject("Msxml2.XMLHTTP");
	if(requestObj) {
		requestObj.onreadystatechange = response;
		requestObj.open("GET", encodeURI(url), true);
		requestObj.send(null);
	}
}
