var xmlHttp;
function createHttpRequest(){
if(window.ActiveXObject){ // Internet Explorer
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest){ // Mozilla,Safari,...
		xmlHttp = new XMLHttpRequest();
	}
}

function startRequest(){
	createHttpRequest();
	xmlHttp.onreadystatechange=handleResponse;
	xmlHttp.open("GET","datas/sale/xml_php.php",true);
	xmlHttp.send(null);
}

function handleResponse(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
			var xmldoc = xmlHttp.responseXML;
			var posts = xmldoc.getElementsByTagName("sale");
			var contents='';
			var loopIndex;
			for(loopIndex = 0; loopIndex <posts.length; loopIndex++){
				var id = posts[loopIndex].getElementsByTagName("id")[0].firstChild.nodeValue;
				var item1 = posts[loopIndex].getElementsByTagName("item1")[0].firstChild.nodeValue;
				var item2 = posts[loopIndex].getElementsByTagName("item2")[0].firstChild.nodeValue;
				var item3 = posts[loopIndex].getElementsByTagName("item3")[0].firstChild.nodeValue;
				var year = posts[loopIndex].getElementsByTagName("year")[0].firstChild.nodeValue;
				var month = posts[loopIndex].getElementsByTagName("month")[0].firstChild.nodeValue;
				var date = posts[loopIndex].getElementsByTagName("date")[0].firstChild.nodeValue;
				var sonota = posts[loopIndex].getElementsByTagName("sonota")[0].firstChild.nodeValue;
				var month2 = posts[loopIndex].getElementsByTagName("month2")[0].firstChild.nodeValue;
				var date2 = posts[loopIndex].getElementsByTagName("date2")[0].firstChild.nodeValue;
				var time = posts[loopIndex].getElementsByTagName("time")[0].firstChild.nodeValue;
				var minit = posts[loopIndex].getElementsByTagName("minit")[0].firstChild.nodeValue;
				var time2 = posts[loopIndex].getElementsByTagName("time2")[0].firstChild.nodeValue;
				var minit2 = posts[loopIndex].getElementsByTagName("minit2")[0].firstChild.nodeValue;
				var nichizi = posts[loopIndex].getElementsByTagName("nichizi")[0].firstChild.nodeValue;
				var item5 = posts[loopIndex].getElementsByTagName("item5")[0].firstChild.nodeValue;
				var item6 = posts[loopIndex].getElementsByTagName("item6")[0].firstChild.nodeValue;
				var image = posts[loopIndex].getElementsByTagName("image")[0].firstChild.nodeValue;
				var kind = posts[loopIndex].getElementsByTagName("kind")[0].firstChild.nodeValue;
				var kind2 = posts[loopIndex].getElementsByTagName("kind2")[0].firstChild.nodeValue;
				var news = posts[loopIndex].getElementsByTagName("new")[0].firstChild.nodeValue;
				var day = posts[loopIndex].getElementsByTagName("day")[0].firstChild.nodeValue;
				
				contents= contents+'<dl class="prices"><dt>'+item2+' <span class="new_home">'+news+'</span></dt><dd class="photos"><img src="datas/'+kind+'/photo/th/'+image+'" width="80%" height="80%" alt="photo" /></dd><dd class="dates"><span class="st">日時/</span>'+year+month+date+sonota+month2+date2+'<br />'+time+minit+time2+minit2+' '+nichizi+'</dd><dd><span class="st">住所/</span>'+item1+'</dd><dd><span class="st">価格/</span>'+item3+'万円</dd><dd><span class="st">担当者名/</span>'+item5+'</dd><dd class="details"><a href="datas/'+kind+'/detail.php?id='+item6+'&kind='+kind2+'" target="_blank">詳細情報</a></dd><dd class="update">追加：'+day+'</dd></dl>';

				}
			document.getElementById('myDiv').innerHTML = contents;
		}
	}
}
