function getGuestXmlUrl(p_strInfoType, p_strId)
{
	var iSubDir = (p_strId - (p_strId % 1000)) / 1000 + 1;
	var strXmlPath = "/xmlGuest/" +p_strInfoType+ "/"+iSubDir+"/"+p_strId+".xml";
	return strXmlPath;
}

function gSend(p_strInfoType, p_strId)
{
	var objUserID = document.getElementById("gUserID");
	var objUserPassword = document.getElementById("gUserPassword");
	var objComment = document.getElementById("gComment");
	

var strValue = Pet67.Web.AppServices.GuestServices.Send(
					objUserID.value,
					objUserPassword.value,
					objComment.value.substring(0, 250),
//					objComment.value,
					p_strInfoType,
					p_strId
					).value;
 if (strValue=="OK")
 {
	 alert("提示：提交成功！！！");
	 bindGuestList(1, true);
 }
 else
 {
	 alert(strValue);
 }
}


var objXmlDoc;



function bindGuestList(p_iPageIndex, p_iReloadSign)
{
	if (p_iReloadSign)
	{
	 strDateString = "x=" + Date.parse(new Date());
	}
	objXml = CreateXMLHttp();
	iPageIndex = p_iPageIndex;
	objXml.onreadystatechange = bindGuestListAction;
	objXml.open('GET', strXmlPath + "?" + strDateString, true);
	objXml.send(null);
	
	function bindGuestListAction()
	{
		if (objXml.readyState == 4)
		{
			if (objXml.status == 200)
			{
				// 初始化
				var strHtml = "";
				var iStartItem = 0, iEndItem = 0;
				// 提取模版
//				var strItemTemplate = document.getElementById("idItemTemplate").innerHTML;
				var strItemTemplate = '<div class="t">$index$楼　网友:$uid$　IP:$ip$　$date$</div><div class="c">$comment$</div>';
//				var strListBlockTemplate = document.getElementById("idListTemplateBlock").innerHTML;
				
				// 读取数据
				var objXmlHttpDom = objXml.responseXML;
				var	objXmlDoc = objXmlHttpDom.getElementsByTagName("root")[0];
				if (objXmlDoc!=null)
				{
					//
					// 绑定行
					//
					var objNodes = objXmlDoc.getElementsByTagName("item");
		
					// 计算记录开始和结束的位置
					iStartItem = (iPageIndex-1)*iPageSize
					iEndItem = iStartItem + iPageSize
					// 总记录数
					iRecordCount = objNodes.length;
					iEndItem = (iEndItem>iRecordCount) ? iRecordCount : iEndItem;
		
					for(var i=iStartItem; i<iEndItem; i++)
					{
						var strItem = strItemTemplate;
						strItem = strItem.replace(/\$index\$/g, i+1);
						strItem = strItem.replace(/\$uid\$/g, objNodes.item(i).getAttribute("uid"));
						strItem = strItem.replace(/\$ip\$/g, objNodes.item(i).getAttribute("ip"));
						strItem = strItem.replace(/\$date\$/g, objNodes.item(i).getAttribute("date"));
						strItem = strItem.replace(/\$comment\$/g, objNodes.item(i).getAttribute("comment"));
						strHtml += strItem;
					}

					//
					// 分页
					//
					var iPageCount = (iRecordCount - iRecordCount % iPageSize) / iPageSize;
					if (iRecordCount % iPageSize != 0)
					{
						iPageCount++;
					}
				}
				else
				{
					strHtml = "";
					iPageCount = 0;
				}
	
				// 绑定显示
				document.getElementById("idGuestListBlock").innerHTML = strHtml;
				// 绑定分页
				pg.pageCount = iPageCount;  // 定义总页数(必要)
				pg.bindPagerFunction = "bindGuestList";
				document.getElementById("idGuestPagerBlock").innerHTML = pg.printHtml(2);
				// 隐藏loading
//				operLoadingBar("hidden");
				// 调整操作框
//				reszieFrame('iframeList');
			}
		}
	}
}

function commentLengthCheck()
{
	var obj = document.getElementById("gComments");
	alert("帖子内容长度: "+ obj.value.length+" 个字，\n\n最多允许"+c_Comments_Length+"字");
}