window.onload=function(){
getIndex();
//indexPr();
//
}
function getIndex() {
	xmlhttp = createXMLHttp();
	if (xmlhttp){
		xmlhttp.onreadystatechange = check;
		xmlhttp.open('GET', './blog/?feed=rss2');
		xmlhttp.send(null);
	}else{
		//alert("error");
	}
}

function createXMLHttp(){
	try {
		return new ActiveXObject ("Microsoft.XMLHTTP");
	}catch(e){
	try {
		return new XMLHttpRequest();
	}catch(e) {
		return null;
	}
	}
	return null;
}

function check(){
	
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
		
		var target=document.getElementById("indexNews");
		var targetULtarget=target.getElementsByTagName("UL")[0];
		xmlDoc = xmlhttp.responseXML;
		var itemName=xmlDoc.getElementsByTagName("item");
		targetNum=itemName.length;
		if(targetNum>8){
			targetNum=8;
		}
		var code="";
	for(i=0;i<targetNum;i++){
		var itemNameRoot=xmlDoc.getElementsByTagName('item')[i];
		var itemName=itemNameRoot.getElementsByTagName('title')[0].firstChild.nodeValue;
		var itemAnc=itemNameRoot.getElementsByTagName('link')[0].firstChild.nodeValue;
		var itemDay=itemNameRoot.getElementsByTagName('pubDate')[0].firstChild.nodeValue;
		var tempDay=new Date(itemDay);
		yy = tempDay.getYear();
		mm = tempDay.getMonth() + 1;
		dd = tempDay.getDate();
		if (yy < 2000) { yy += 1900; }
		if (mm < 10) { mm = "0" + mm; }
		if (dd < 10) { dd = "0" + dd; }
		code+='<li><a href="'+itemAnc+'">'+yy + '.'+mm+'.'+dd+' : '+itemName+'</a></li>';
		}
		
		targetULtarget.innerHTML=code;
	}
}

function indexPr(){
var indexPr=document.getElementById('indexPr');
code='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="450" id="indexPr" align="middle">';
code+='<param name="movie" value="./js/indexPr.swf" />';
code+='<param name="menu" value="false" />';
code+='<param name="quality" value="high" />';
code+='<param name="scale" value="noscale" />';
code+='<param name="bgcolor" value="#ffffff" />';
code+='<embed src="./js/indexPr.swf" menu="false" quality="high" scale="noscale" bgcolor="#ffffff" width="800" height="450" name="indexPr" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
code+='</object>';
indexPr.innerHTML=code;
}
