var cnt = 0;
var length = 0;
var entries;
function init(str) {
	$.ajax({
		dataType: "text",
		data: {},
		url: str,
		success: function (res) {
			var xotree = new XML.ObjTree();
			var tree = xotree.parseXML(res);
			if(typeof tree.entries != "object") return;
			length = tree.entries.entry.length;
			entries = tree.entries.entry;
			$(window).scroll(function(){
				this.st = $(document).scrollTop();
				this.wh = $(window).height();
				this.bh = $('body').height();
				this.num = 100;
				this.inst = res;
				if(this.st+this.wh+this.num > this.bh){
					for(var i = 0; i < 5; i++){
						if(cnt < length){
							this.obj = document.createElement('li');
							this.obj
							$(this.obj)
								.addClass("entry")
								.html('<p class="entryDate">'+entries[cnt].date+'</p><h2 class="entryTitle"><a href="'+entries[cnt].permalink+'" title="'+entries[cnt].title+'を読む">'+entries[cnt].title+'</a></h2><div class="entryImage"><img src="http://www.4digit.jp/works/archives_imgs/300x200/'+entries[cnt].imgKey+'.jpg" alt ="'+entries[cnt].title+'" width="300" height="200" /></div><div class="entryBody">'+entries[cnt].body+'<div class="bt-permalink"><a href="'+entries[cnt].permalink+'" title="'+entries[cnt].title+'を読む"><img src="http://www.4digit.jp/works/imgs/bt-permalink.gif" alt="permalink" width="180" height="20" class="ahover" /></a></div></div>');
							$(this.obj).appendTo('#entries');
							cnt++;
						}
					}
				}
				initRollOvers();
			})
		}
	});
}

