// This module on PenguinBlog3.
// Created by Orikasa,Tomohiro.
var pb_posts = {
	// create posts
//	template_head: "",
	template_body: "",
//	template_foot: "",
//	loadingHTML: '<p style="text-align:center;"><img src="/image/loading.gif" alt="○" /><br />Now Loading...</p>',
	loadingHTML: '<p style="text-align:center;"><object data="/image/loading.swf" type="application/x-shockwave-flash" width="32" height="32" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="/image/loading.swf" /><param name="quality" value="high" /><param name="wmode" value="opaque" /></object></p>',
	wait: 300,
	top : 1,
	size : 10,
	length : 0,
	indexies : new Array() ,
	entries : new Object() ,
	reloadTimer: undefined ,
	node : new Object() ,
	textPrevLink : "" , nodePrevLinks : new Array() ,
	textNextLink : "" , nodeNextLinks : new Array() ,
	categories : new Object() ,
	authors : new Object() ,
	x : 0 ,
	y : 0 ,
	bookmark : '<a href="http://b.hatena.ne.jp/append?#url#" rel="nofollow" title="Hatena"><img src="/image/bookmark/hatena.gif" width="16" height="16" alt="Hatena" /></a><a href="http://del.icio.us/post?url=#url2#&amp;title=#title#" rel="nofollow" title="del.icio.us"><img src="/image/bookmark/delicious.gif" width="16" height="16" alt="del.icio.us" /></a><a href="http://pookmark.jp/post?url=#url2#&amp;title=#title#" rel="nofollow" title="POOKMARK Airlines"><img src="/image/bookmark/pookmark.gif" width="18" height="16" alt="POOKMARK Airlines" /></a><a href="http://clip.livedoor.com/redirect?link=#url2#&amp;title=#title#" rel="nofollow" title="Livedoor clip"><img src="/image/bookmark/livedoor_clip.gif" width="16" height="16" alt="Livedoor clip" /></a><a href="http://clip.nifty.com/create?url=#url#&amp;title=#title#" rel="nofollow" title="Nifty Clip"><img src="/image/bookmark/nifty_clip.gif" width="16" height="16" alt="Nifty Clip" /></a><a href="http://bm.saaf.jp/bm/add?url=#url2#" rel="nofollow" title="Saaf Bookmark"><img src="/image/bookmark/saaf.gif" width="16" height="16" alt="Saaf Bookmark" /></a><a href="http://newsing.jp/nbutton?title=#title#&amp;url=#url#" rel="nofollow" title="newsing"><img src="/image/bookmark/newsing.gif" width="16" height="16" alt="newsing" /></a><a href="http://www.choix.jp/bloglink/#url#" rel="nofollow" title="Choix"><img src="/image/bookmark/choix.gif" width="16" height="16" alt="Choix" /></a><a href="http://www.furl.net/storeIt.jsp?t=#title#&amp;u=#url#" rel="nofollow" title="Furl"><img src="/image/bookmark/furl.gif" width="16" height="16" alt="Furl" /></a><a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=#url#&amp;Title=#title#" rel="nofollow" title="Blinklist"><img src="/image/bookmark/blinklist.gif" width="16" height="16" alt="Blinklist" /></a><a href="http://reddit.com/submit?url=#url#&amp;title=#title#" rel="nofollow" title="Reddit"><img src="/image/bookmark/reddit.gif" width="16" height="16" alt="Reddit" /></a>' ,
	setHTML : function () {

		pb_posts.node = document.getElementById('posts');
		if (!pb_posts.node) throw id+" isn't found";

		document.onmousemove = pb_posts.getMouse;
//			cell = cell.replace(/#cell#/g,'<img src=\"/image/blue.gif\" width=\"'+pb_counter.cellWidth+'\" height=\"'+height+'\" title=\"'+alt+'\" alt=\"'+alt+'\" />');
//			&#92;
//		pb_posts.template_head = pb_posts.template_head.replace(/&#92;/g,'"')
//		pb_posts.template_head = pb_posts.template_head.replace(/\\n/g,"\n")

		pb_posts.template_body = pb_posts.template_body.replace(/&#92;/g,'"')
		pb_posts.template_body = pb_posts.template_body.replace(/\\n/g,"\n")

//		pb_posts.template_foot = pb_posts.template_foot.replace(/&#92;/g,'"')
//		pb_posts.template_foot = pb_posts.template_foot.replace(/\\n/g,"\n")

		// load categories
		categoriesXML = new JKL.ParseXML.JSON("/categories.json");
		categoriesDATA = categoriesXML.parse();
		var setCategories = function(row) {
			var id = row['id'];
			pb_posts.categories[id] = row['name'];
		}
		categoriesDATA['category'].each(setCategories);

		// load authors
		authorsXML = new JKL.ParseXML.JSON("/authors.json");
		authorsDATA = authorsXML.parse();
		var setAuthors = function(row) {
			var id = row['id'];
			pb_posts.authors[id] = new Array(row['name'],row['count']);
		}
		authorsDATA['author'].each(setAuthors);

		var params = Object();
		if (location.search.length > 1) {
			var arr = location.search.substr(1).split("&");
			for (var i in arr) {
				if (i==0) {
					var param = arr[i].split("=");
					params[param[0]]= param[1];
				}
			}
		}

		if (isHTTPreq) {
			var back_url = getCookie("posts_url");
			var back_top = parseInt(getCookie("posts_top"),10);

			if (back_url!="" && back_url!=undefined) {
				var url = back_url;
//				if (!isNaN(back_top) && back_top>0) {
					pb_posts.top = back_top;
//				}
			} else {
				if (params["d"]==undefined) {
					var url = "/all.json";
				} else {
					var url = params["d"];
				}
			}

			if (params["p"]!=undefined && !isNaN(params["p"]) && params["p"]>0) {
				pb_posts.top = params["p"];
			}

			pb_posts.indexies.clear();
			pb_posts.loadList(url);

			if (back_url!="" && back_url!=undefined) {
				setCookie("posts_url","",null);
				setCookie("posts_top",-1,null);
			}
		} else {
		}

	},
	reloadList : function (url) {
		pb_posts.node.innerHTML = pb_posts.loadingHTML;
		pb_posts.top = 1;
		pb_posts.indexies.clear();
		pb_posts.loadList(url);
		return false;
	},
	loadList : function(url) {

		setCookie("posts_url",url,null);
		setCookie("posts_top",pb_posts.top,null);

		var xml = new JKL.ParseXML.JSON(url);
		var func = function (data) {
			var arrStr = '';
			var c = 0;

			var func2 = function (row) {
				if (row==undefined) { return; } 

				arrStr += "pb_posts.indexies["+c+"] = new Array();";
				arrStr += "pb_posts.indexies["+c+"][0] = '"+row["seqno"]+"';";
				if (row["pageid"]!=undefined) {
					arrStr += "pb_posts.indexies["+c+"][1] = '"+row["id"]+"';";
				}
				c++;
			}
			data['entry'].each(func2);
			eval(arrStr);

			pb_posts.length = c;
			pb_posts.drawHTML();
		}
		xml.async(func);
		xml.parse();
	},
	previousPage : function() {
		if (pb_posts.top - pb_posts.size >= 1) {
			pb_posts.node.innerHTML = pb_posts.loadingHTML;
			pb_posts.top = pb_posts.top - pb_posts.size;
		} else {
			pb_posts.top = 1;
		}
		pb_posts.reloadTimer = setTimeout('pb_posts.drawHTML()',pb_posts.wait);
	},
	nextPage : function() {
		if (pb_posts.length > pb_posts.top + pb_posts.size - 1) {
			pb_posts.node.innerHTML = pb_posts.loadingHTML;
			pb_posts.top = pb_posts.top + pb_posts.size;
			pb_posts.reloadTimer = setTimeout('pb_posts.drawHTML()',pb_posts.wait);
		}
	},
	setLinkPrevious : function(id,linkTitle) {
		if (linkTitle=='') { pb_posts.textPrevLink = "Previous"; } else { pb_posts.textPrevLink = linkTitle; }
		pb_posts.nodePrevLinks[pb_posts.nodePrevLinks.length] = document.getElementById(id);
	},
	setLinkNext : function(id,linkTitle) {
		if (linkTitle=='') { pb_posts.textNextLink = "Next"; } else { pb_posts.textNextLink = linkTitle; }
		pb_posts.nodeNextLinks[pb_posts.nodeNextLinks.length] = document.getElementById(id);
	},
	drawLink : function() {
		// Link(prev)
		var linkText = '';
		if (pb_posts.nodePrevLinks.length>0) {
			if (pb_posts.top>1) {
				linkText = '<a href="#" onclick="pb_posts.previousPage();return false;">'+pb_posts.textPrevLink+'</a>';
			} else {
				linkText = pb_posts.textPrevLink;
//				linkText = '';
			}
			for (var i = 0; i < pb_posts.nodePrevLinks.length; i ++) {
				pb_posts.nodePrevLinks[i].innerHTML = linkText;
			}
		}
		// Link(next)
		if (pb_posts.nodeNextLinks.length>0) {
			if (pb_posts.top+pb_posts.size-1<pb_posts.length) {
				linkText = '<a href="#" onclick="pb_posts.nextPage();return false;">'+pb_posts.textNextLink+'</a>';
			} else {
				linkText = pb_posts.textNextLink;
//				linkText = '';
			}
			for (var i = 0; i < pb_posts.nodeNextLinks.length; i ++) {
				pb_posts.nodeNextLinks[i].innerHTML = linkText;
			}
		}
	},
	drawHTML : function() {
		if (pb_posts.reloadTimer!=undefined) { clearTimeout(pb_posts.reloadTimer); }
		if (pb_posts.indexies==null) return;
		var html = '';

		setCookie("posts_top",pb_posts.top,null);

		var drawed = false;
		var old_date = "";
		for (var i=pb_posts.top;i<pb_posts.top+pb_posts.size;i++) {
			if (pb_posts.indexies[i-1]!=undefined) {
				drawed = true;
				var seqno = pb_posts.indexies[i-1][0];
				if (pb_posts.entries[seqno]==undefined) {
					var xml = new JKL.ParseXML.JSON('/'+seqno+'.json');
					var _data = xml.parse();
					if (_data["entry"]!=undefined && _data["entry"].length>0) {
						pb_posts.entries[seqno] = _data["entry"][0];
						if (pb_posts.entries[seqno]['date']!=undefined && setDateTime(pb_posts.entries[seqno]['date'])>time()){
							pb_posts.indexies[i-1] = undefined;
						}
					} else {
						continue;
					}
				}

				var line = pb_posts.template_body;

				// id
				if (pb_posts.entries[seqno]["id"]!=undefined) {
					var entryID = pb_posts.entries[seqno]["id"];
				} else {
					var entryID = pb_posts.entries[seqno]["seqno"];
				}
				line = line.replace(/{entry_id\((.*?)\)}/g,entryID);
				// title
//				line = line.replace(/{entry_title\((.*?)\)}/g,pb_posts.entries[seqno]["title"].replace("&quot;",'"').replace("&amp;","&"));
				line = line.replace(/{entry_title\((.*?)\)}/g,pb_posts.entries[seqno]["title"].replace(/&quot;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&"));
				// link
				line = line.replace(/{entry_permalink\(.*?\)}/g,pb_posts.entries[seqno]["link"]);
				// BookMark
				if (line.match(/{entry_bookmark\(.*?\)}/)) {
					var bookmarkHTML = pb_posts.bookmark;
					bookmarkHTML = bookmarkHTML.replace(/#url#/g,blog["url"]+entryID+".html");
					bookmarkHTML = bookmarkHTML.replace(/#url2#/g,blog["url"]+entryID+".html");
					bookmarkHTML = bookmarkHTML.replace(/#title#/g,pb_posts.entries[seqno]["title"].replace(/&quot;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&"));
					line = line.replace(/{entry_bookmark\((.*?)\)}/g,bookmarkHTML);
				}


				// category
				var categoryID = pb_posts.entries[seqno]["category"];
				var categoryLink = "<a href=\"#\" onclick=\"pb_posts.reloadList('/category_"+categoryID+".json');return false;\">#categoryLinkTitle#</a>";
;
				if (line.match(/{entry_category\(.*?\)}/)) {
					if (categoryID==undefined || pb_posts.categories[categoryID]==undefined) {
						var categoryLinkTitle = message["category.wonbelong"];
					} else {
						var categoryLinkTitle = pb_posts.categories[categoryID];
					}
					categoryLink = categoryLink.replace("#categoryLinkTitle#",categoryLinkTitle);
				}
				line = line.replace(/{entry_category_id\(.*?\)}/g,categoryID);
				line = line.replace(/{entry_category_name\(.*?\)}/g,categoryLinkTitle);
				line = line.replace(/{entry_category\(.*?\)}/g,categoryLink);

				// location
				if (line.match(/{entry_location_lon\(.*?\)}/)) {
					if (pb_posts.entries[seqno]["lon"]==undefined) {
						line = line.replace(/{entry_location_lon\(.*?\)}/g,"");
					} else {
						line = line.replace(/{entry_location_lon\(.*?\)}/g,pb_posts.entries[seqno]["lon"]);
					}
				}
				if (line.match(/{entry_location_lat\(.*?\)}/)) {
					if (pb_posts.entries[seqno]["lat"]==undefined) {
						line = line.replace(/{entry_location_lat\(.*?\)}/g,"");
					} else {
						line = line.replace(/{entry_location_lat\(.*?\)}/g,pb_posts.entries[seqno]["lat"]);
					}
				}
				if (line.match(/{entry_location_url\(.*?\)}/)) {
					if (pb_posts.entries[seqno]["lon"]==undefined || pb_posts.entries[seqno]["lat"]==undefined) {
						line = line.replace(/{entry_location_url\(.*?\)}/g,'');
					} else {
						var location_url = blog["mapurl"].replace("#lon#",pb_posts.entries[seqno]["lon"]).replace("#lat#",pb_posts.entries[seqno]["lat"]);
						line = line.replace(/{entry_location_url\(.*?\)}/g,'<span class="map_botton"><button type="button" onclick="popWindow(\''+location_url+'\',\'mapview\', \'600\', \'650\',\'座標表示\');">&nbsp;MAP&nbsp;</button></span>');
					}
				}

				// author
				var authorID = pb_posts.entries[seqno]["author"];
				if (pb_posts.authors[authorID]==undefined) {
					var authorName = message["author.wonbelong"];
					var authorPosts = 0;
				} else {
					var authorName = pb_posts.authors[authorID][0];
					var authorPosts = pb_posts.authors[authorID][1];
				}
				var authorLink = "<a href=\"#\" onclick=\"pb_posts.reloadList('/author_"+authorID+".json');return false;\">#authorLinkTitle#</a>";
;
				if (line.match(/{entry_author_posts_link\(.*?\)}/)) {
					if (authorID==undefined || pb_posts.authors[authorID]==undefined) {
						var authorLinkTitle = message["author.wonbelong"];
					} else {
						var authorLinkTitle = pb_posts.authors[authorID][0];
					}
					authorLink = authorLink.replace("#authorLinkTitle#",authorLinkTitle);
				}
				line = line.replace(/{entry_author_id\(.*?\)}/gi,authorID);
				line = line.replace(/{entry_author\(.*?\)}/gi,authorName);
				line = line.replace(/{entry_author_firstname\(.*?\)}/gi,authorName);
				line = line.replace(/{entry_author_lastname\(.*?\)}/gi,authorName);
				line = line.replace(/{entry_author_nickname\(.*?\)}/gi,authorName);
				line = line.replace(/{entry_author_posts\(.*?\)}/gi,authorPosts);
				line = line.replace(/{entry_author_posts_link\(.*?\)}/g,authorLink);

				// description
				var description = pb_posts.entries[seqno]["description"].replace(/<\!\[CDATA\[/,"").replace(/\]\]>/,"").replace(/\\n/g,"\n").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&");

				var morepos = description.indexOf("<!-- more -->");
				if (morepos>=0) {
					if (pb_posts.entries[seqno]["id"]!=undefined) {
						description = description.substr(0,morepos) + "<a href=\"/"+pb_posts.entries[seqno]["id"]+".html\">" + message["more"] + "</a>";
					} else {
						description = description.substr(0,morepos) + "<a href=\"/"+pb_posts.entries[seqno]["seqno"]+".html\">" + message["more"] + "</a>";
					}
				}
				if (pb_posts.entries[seqno]["enclosure"]!=undefined) {
					var addimage = false;
//					var imageurl = function (row) {
						var row = pb_posts.entries[seqno]["enclosure"];
						if (addimage) { return; }
						if (row["type"].match(/image\//)) {
							description = '<img class="thumbsnail" src="'+row["thumbsnamilurl"]+'" alt="'+row["width"]+row["height"]+'" style="float:left" />' + description;
						} // thumbsへ変更、他にmovieやsound対応も
						addimage = true;
//					}
//					pb_posts.entries[seqno]["enclosure"].each(imageurl);
					if (addimage) {
						description += '<br clear="all" style="clear:both">';
					}
				}

				line = line.replace(/{entry_content\((.*?)\)}/,description);

				// date/time
				setDateTime(pb_posts.entries[seqno]['date']);
				res = ""; date_str = "Ymd"; date_format = date_str.split(""); date_format.each(makeDateString);
				if (old_date!=res) {
					old_date = res;
					var reg = new RegExp("{entry_date\((.*?)\)}","g");
					if (line.match(reg)) {
						date_str = '';
						if (RegExp.$1!=undefined) {
							date_str = RegExp.$1; date_str = date_str.substring(2); date_str = date_str.substr(0,date_str.length-2);
						}
						if (date_str=="") { date_str = message["date.date_format"]; }
						date_format = date_str.split(""); res = "";
						date_format.each(makeDateString);
						line = line.replace(/{entry_date\((.*?)\)}/g,res);
					}
				} else {
					line = line.replace(/{entry_date\(.*?\)}/g,"");
				}
				var reg = new RegExp("{entry_time\((.*?)\)}","g");
				if (line.match(reg)) {
					date_str = '';
					if (RegExp.$1!=undefined) {
						date_str = RegExp.$1; date_str = date_str.substring(2); date_str = date_str.substr(0,date_str.length-2);
					}
					if (date_str=='') { date_str = message["date.time_format"]; }
					date_format = date_str.split(""); res = "";
					date_format.each(makeDateString);
					line = line.replace(/{entry_time\((.*?)\)}/g,res);
				}

				// update/uptime
				setDateTime(pb_posts.entries[seqno]['update']);
				res = ""; date_str = "Ymd"; date_format = date_str.split(""); date_format.each(makeDateString);
				if (old_date!=res) {
					old_date = res;
					var reg = new RegExp("{entry_update\((.*?)\)}","g");
					if (line.match(reg)) {
						date_str = '';
						if (RegExp.$1!=undefined) {
							date_str = RegExp.$1; date_str = date_str.substring(2); date_str = date_str.substr(0,date_str.length-2);
						}
						if (date_str=="") { date_str = message["date.date_format"]; }
						date_format = date_str.split(""); res = "";
						date_format.each(makeDateString);
						line = line.replace(/{entry_date\((.*?)\)}/g,res);
					}
				} else {
					line = line.replace(/{entry_date\(.*?\)}/g,"");
				}
				var reg = new RegExp("{entry_uptime\((.*?)\)}","g");
				if (line.match(reg)) {
					date_str = '';
					if (RegExp.$1!=undefined) {
						date_str = RegExp.$1; date_str = date_str.substring(2); date_str = date_str.substr(0,date_str.length-2);
					}
					if (date_str=='') { date_str = message["date.time_format"]; }
					date_format = date_str.split(""); res = "";
					date_format.each(makeDateString);
					line = line.replace(/{entry_time\((.*?)\)}/g,res);
				}

				// link of comments
				if (pb_posts.entries[seqno]["commentType"]=="no") {
					var commentLink = "";
					var commentLinkTitle = "";
				} else {
//					var commentLink = '<a href="#" onclick="popupWindow(\'comment\',500,500,\''+htmlentities(addslashes(pb_posts.entries[seqno]["title"])).replace(/&/,'&amp;')+'へのコメント\',\'/comments_'+seqno+'.html\');return false;">#linkTitle#</a>';
					var commentLink = '<a href="#" onclick="popupWindow(\'comment'+seqno+'\',500,500,\'Comments\',\'/comments_'+seqno+'.html\');return false;">#linkTitle#</a>';
					var commentLinkTitle = "";
				}
				var params;
				var reg = new RegExp("{comment_link\((.*?)\)}","g");
				if (line.match(reg)) {
					if(RegExp.$1!=undefined) {
						params = pb_posts.splitCSV(RegExp.$1);
						commentLinkTitle = pb_posts.setCommentLinkTitle(params,pb_posts.entries[seqno]["commentCount"]);
					} else {
						commentLinkTitle = "コメント("+pb_posts.entries[seqno]["commentCount"]+")";
					}
					commentLink = commentLink.replace("#linkTitle#",commentLinkTitle);
					line = line.replace(/{comment_link\((.*?)\)}/g,commentLink);
				}
				var reg = new RegExp("{comments_number}","g");
				if (line.match(reg)) {
					line = line.replace(/{comments_number}/g,pb_posts.entries[seqno]["commentCount"]);
				}

				// link of trackbacks
//				var trackbackLink = '<a href="#" onclick="popupWindow(\'trackback\',500,500,\''+htmlentities(pb_posts.entries[seqno]["title"]).replace(/&/,'&amp;')+'へのトラックバック\',\'/tracks_'+seqno+'.html\');return false;">#linkTitle#</a>';
				var trackbackLink = '<a href="#" onclick="popupWindow(\'trackback\',500,500,\'Trackbacks\',\'/tracks_'+seqno+'.html\');return false;">#linkTitle#</a>';
				if (!pb_posts.entries[seqno]["trackbackFlag"]==1) {
//					var trackbackLink = "";
					var trackbackURL = '';
					var trackbackRDF = '';
				} else {
//					var trackbackLink = '<a href="#" onclick="popupWindow(\'trackback\',500,500,\''+pb_posts.entries[seqno]["title"]+'へのトラックバック\',\'/tracks_'+seqno+'.html\');return false;">#linkTitle#</a>';
					var trackbackURL = blog['url']+'tb/?'+seqno;
					var trackbackRDF  = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
					    trackbackRDF += "	xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
					    trackbackRDF += "	xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">\n";
					    trackbackRDF += "<rdf:Description\n";
					    trackbackRDF += "	rdf:about=\""+blog['url']+seqno+".html\"\n";
					    trackbackRDF += "	dc:identifier=\""+blog['url']+seqno+".html\"\n";
					    trackbackRDF += "	dc:title=\""+blog['title']+"\"\n";
					    trackbackRDF += "	trackback:ping=\""+blog['url']+"tb/?"+seqno+"\"\n";
					    trackbackRDF += "</rdf:RDF>";
				}

				var trackbackLinkTitle = "";
				var params;
				var reg = new RegExp("{trackback_link\((.*?)\)}","g");
				if (line.match(reg)) {
					if(RegExp.$1!=undefined) {
						params = pb_posts.splitCSV(RegExp.$1);
						trackbackLinkTitle = pb_posts.setTrackbackLinkTitle(params,pb_posts.entries[seqno]["trackbackCount"]);
					} else {
						trackbackLinkTitle = "トラックバック("+pb_posts.entries[seqno]["trackbackCount"]+")";
					}
					trackbackLink = trackbackLink.replace("#linkTitle#",trackbackLinkTitle);
					line = line.replace(/{trackback_link\((.*?)\)}/g,trackbackLink);
				}
				line = line.replace(/{trackback_url}/g,trackbackURL);
				line = line.replace(/{trackback_rdf}/g,trackbackRDF);

				var reg = new RegExp("{trackbacks_number}","g");
				if (line.match(reg)) {
					line = line.replace(/{trackbacks_number}/g,pb_posts.entries[seqno]["trackbackCount"]);
				}

				// out
				html += line;

			}
		}

		pb_posts.drawLink();
/*
		var foot = pb_posts.template_foot;

		if (foot.match(/{link_previous\((.*?)\)}/g)) {
			foot = foot.replace(/{link_previous\((.*?)\)}/g,prevLink);
		}
		if (foot.match(/{link_next\((.*?)\)}/g)) {
			foot = foot.replace(/{link_next\((.*?)\)}/g,nextLink);
		}
*/
	
//		html += foot;

		if (!drawed) {
			alert(message["err.nodata"]);
			pb_posts.node.innerHTML = "";
			return false;
		} else {
			pb_posts.node.innerHTML = html;
		}
	},

	setCommentLinkTitle : function(params,number) {
		if (number==0) {
			if (params[0]==undefined) { params[0] = "コメント(%)"; }
			return params[0].replace("%","0");
		} else if (number==1) {
			if (params[1]==undefined) { params[1] = "コメント(%)"; }
			return params[1].replace("%","1");
		} else {
			if (params[2]==undefined) { params[2] = "コメント(%)"; }
			return params[2].replace("%",number);
		}
	},
	setTrackbackLinkTitle : function(params,number) {
		if (number==0) {
			if (params[0]==undefined) { params[0] = "トラックバック(%)"; }
			return params[0].replace("%","0");
		} else if (number==1) {
			if (params[1]==undefined) { params[1] = "トラックバック(%)"; }
			return params[1].replace("%","1");
		} else {
			if (params[2]==undefined) { params[2] = "トラックバック(%)"; }
			return params[2].replace("%",number);
		}
	},

	splitCSV : function(s) {
		s = s.replace(/^\s+/,"");
		s = s.replace(/\s+$/,"");
		if (s.substr(0,1)=="(" && s.substr(s.length-1,1)==")") {
			s = s.substr(1,s.length-2);
		}
		s = s.replace(/((?:'[.\n]*?[^']')[ \t]*|(?:[.\n]*?)),/g, "\t");
		s = s.replace(/((?:\"[.\n]*?[^\"]\")[ \t]*|(?:[.\n]*?)),/g, "\t");
		var arr = s.split("\t");
		for(var i=0;i<arr.length;i++) {
			arr[i] = arr[i].replace(/^\s+|\s+$/g, '');
			if (arr[i].substr(0,1)=="'" && arr[i].substr(arr[i].length-1,1)=="'") {
				arr[i] = arr[i].substr(1,arr[i].length-2);
			} else if (arr[i].substr(0,1)=='"' && arr[i].substr(arr[i].length-1,1)=='"') {
				arr[i] = arr[i].substr(1,arr[i].length-2);
			}
		}
		return arr;
	},

	getMouse : function(e) {
		if(document.all) { //o6,e4,e5,e6
			pb_posts.x = window.event.screenX;
			pb_posts.y = window.event.screenY;
		} else if(document.layers || document.getElementById ) { //n4,n6,m1
			pb_posts.x = e.screenX;
			pb_posts.y = e.screenY;
		}
	}
}

