function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')e.checked = document.getElementById("chkAll").checked; 
   }
}
function getHref()
{
	var fullhref = document.location.href;
	var fullpath = document.location.pathname;
	var path = fullpath.substr(fullpath.lastIndexOf("/")+1);
	return (fullhref.substr(fullhref.lastIndexOf(path)));
}
function getPage(p)
{
	if(p == ""){return false;}
	var getUrl;
	if(getHref().lastIndexOf("?") < 1){
		getUrl = getHref() + "?page=" + p;}
	else{
		if(getHref().lastIndexOf("page=") < 1){
			getUrl = getHref() + "&page=" + p;}
		else{
			getUrl = getHref().substr(0,getHref().lastIndexOf("page=")) + "page=" + p;
		}
	}
	return (getUrl);
}
function showpage(p,pCount,r)
{
	if(r == 0 || pCount == 0){
		return false;}
	document.write ('<table border="0" width="98%" cellspacing="0" cellpadding="0" align="center"><tr><td width="50%" height="25">');
	document.write ('AllRecord ：<span style="font-weight:bold;color:#CC0000">' + r + '</span> Page：<span style="font-weight:bold;color:#336699">' + p + '</span>/<b>' + pCount + '</b></td>');
	document.write ('<td align="right">&nbsp;');
	if(pCount > 1){
		if (p <= 1)
		{
			document.write ('<font color="#808080">Home Back</font>');
		}else{
			document.write ('<a href="' + getPage(1) + '">Home</a><a href="' + getPage(p-1) + '">Back</a>');
		}
		if (p == pCount)
		{
			document.write ('<font color="#808080">Next End</font>');
		}else{
			document.write ('<a href="' + getPage(p+1) + '">Next</a><a href="' + getPage(pCount) + '">End</a>');
		}
		document.write (' <input type="text" value="' + p + '" style="width:20px;border:1px solid #CCCCCC;height:18px" title="输入页码后按回车跳转" onKeyUp="if(event.keyCode==13 && (!isNaN(this.value) && this.value<=' + pCount + ' && this.value != ' + p + ' && this.value != \'\')){window.open(getPage(this.value),\'_self\');}else{return false;}">');
	}
	document.write ('</td></tr></table>');
}
// 显示无模式对话框
function showWin(url, width, height) {
	var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
}
function openScript(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,menubar=no,status=yes,location=no,toolbar=no' );
}
function getStrLen(mys)
{
	var ts=0;
	var n_strlen=mys.length;
	for(i=0;i<n_strlen;i++)
	{
		nUnc = mys.charCodeAt(i);
		if(nUnc < 1000)
		{
			ts += 1;
		}
		else
		{
			ts += 2;
		}
	}
	return ts;
}
//截取指定长度的字符串
function strvalue(mys,lennum)
{
	var x=0;
	var p_num=0;
	var myasc;
	var i=0;
	if (getStrLen(mys)<lennum)
	{
		return (mys);
	}
	else
	{
		while (i<lennum-1)
		{
			x=x+1;
			myasc=mys.charCodeAt(i);
			if (myasc<1000)
			{
				i=i+1;
			}
			else
			{
				i=i+2;
			}
		}
		return (mys.substring(0,x)+"..");
	}
}
function parameEncode(str)
{
	if (str!='')
	{	
		str=str.replace(/>/gi,"&#62;")
		str=str.replace(/</gi,"&#60;")
		//str=str.replace("/","&#47;")
		str=str.replace(/\r/gi,"")
		str=str.replace(/\n/gi,"<br>")
		str=str.replace(/\'/gi,"&#39;")
		str=str.replace(/\"/gi,'&#34;')
		str=str.replace(/'/gi,"&#39;")
		str=str.replace(/"/gi,'&#34;')
		str=str.replace(/ /gi,"&nbsp;")
	}
	else
	{
		str='';
	}
	return(str);
}
function loadPage(ino,url)
{
	var objImg =document.getElementById('followImg' + ino);
	var objtd =document.getElementById('follow' + ino);
	if (objtd.style.display!='block')
	{
		objtd.style.display="block";
		objImg.src="images/nofollow.gif";
		if(objImg.loaded=="no")
		{
			document.frames["hiddenframe"].location.replace(url + "&id=" + ino);
		}
	}
	else
	{
		objtd.style.display="none";
		objImg.src="images/plus.gif";
	}
}
document.write("<iframe height=0 width=0 name=hiddenframe></iframe>")
function doSize(px)
{
	document.getElementById("content").style.fontSize = "" + px + "px";
	document.getElementById("content").style.lineHeight = "" + (px*1.5) + "px";
}
function showimg(img,w,h){
	var iw = img.width;
	var ih = img.height;
	w = (w>iw) ? iw : w;
	h = (h>ih) ? ih : h;
	if (iw*w>ih*h)
	{
		h = Math.floor(ih*w/iw);
	}else{
		w = Math.floor(iw*h/ih);
	}
	img.width = w;
	img.height = h;
}
