function trim(str)
{
	return str.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}
String.prototype.trim = function()
{
	return this.replace(/(^[\s　]*)|([\s　]*$)/g, '');
}
//Byte Counter
function len(str)
{
	var bytes = 0;
	for(i=0; i<str.length; i++)
	{
		ascii = str.charCodeAt(i);
		bytes += (ascii < 255 ? 1 : 2);
	}
	return bytes;
}
function switch_nav(dis)
{
	document.getElementById('navigation').style.visibility=dis;
}
function switch_nav_style(obj,className)
{
	obj.className=className;
}
function close_ads()
{
	if (document.getElementById("pkmDuiLian1"))
		document.getElementById("pkmDuiLian1").style.display='none';
	if (document.getElementById("pkmDuiLian2"))
		document.getElementById("pkmDuiLian2").style.display='none';
	if (document.getElementById("pkm_float_ad"))
		document.getElementById("pkm_float_ad").style.display='none';
	if (document.getElementById("pkmBootADS"))
		document.getElementById("pkmBootADS").style.display='none';
}
//检测各种数值型数据
function CheckNumeric (ChekType,strNumber)
{
	var newPar;
	switch (ChekType) {
		case "isNumeric":
			//实数
			newPar=/^(\+|-)?(0|[1-9]\d*)(\.\d*[1-9])?$/
		break;
		case "isUnsignedNumeric":
			//正数
			newPar=/^\d+(\.\d+)?$/
		break;
		case "isInteger":
			//整数
			newPar=/^(-|\+)?\d+$/
		break;
		case "isUnsignedInteger":
			//正整数
			newPar=/^\d+$/
		break;
		default:
			newPar=/^(\+|-)?(0|[1-9]\d*)(\.\d*[1-9])?$/
		break;
	}
	return newPar.test(strNumber);
}

//下拉页码的选择性跳转
function go_button_jump(url,QueryString,MaxPageIndex)
{
	obj=document.getElementById("PageIndex");
	var selectedValue;
	if (obj.type.toLowerCase().indexOf('text')==-1)
	{
		selectedValue = obj.options[obj.selectedIndex].value;
	}
	else
	{
		selectedValue = obj.value;
	}
	//正整数验证
	if (CheckNumeric("isUnsignedInteger",selectedValue)==false)
	{
		alert("请输入正整数以进入目标页码");
		return false;
	}
	if (selectedValue>MaxPageIndex)
	{
		alert('最大页码是： '+ MaxPageIndex +'\n您输入的 ' + selectedValue + ' 过大，请重新输入');
		return false;
	}
    window.location=url+"?PageIndex="+selectedValue+QueryString;
}
//Submit Once
function submitonce(f)
{
	if (document.all || document.getElementById)
	{
		for (i=0; i<f.elements.length; i++)
		{
			var ctl = f.elements[i];
			var ctlType = ctl.type.toLowerCase();
			if (ctlType == 'submit' || ctlType == 'button' || ctlType == 'reset')
			{
				ctl.disabled = true;
			}
		}
	}
}
//登录系统
function LoginSystem() { 
	Window_width=screen.availWidth-10;
	Window_height=screen.availHeight-50;
	Window_top=0;
	Window_left=0;

	var aimFile;
	var cUrl=window.location.toString().toLowerCase();
	if (cUrl.indexOf('pkmsuite')>-1)
		aimFile="manage_frame.aspx";
	else
		aimFile="pkmSuite/manage_frame.aspx";
	window.open(aimFile,'','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width='+Window_width+',height='+Window_height+',left='+Window_left+',top='+Window_top+'');
	return true;
}
//登录系统
function LoginConsole() { 
	Window_width=screen.availWidth-10;
	Window_height=screen.availHeight-50;
	Window_top=0;
	Window_left=0;

	var aimFile;
	var cUrl=window.location.toString().toLowerCase();
	if (cUrl.indexOf('console')>-1)
		aimFile="manage_frame.aspx";
	else
		aimFile="Console/manage_frame.aspx";
	window.open(aimFile,'','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width='+Window_width+',height='+Window_height+',left='+Window_left+',top='+Window_top+'');
	return true;
}
//投稿窗口
function TougaoForm(aimFile)
{
	Window_width=550;
	Window_height=540;
	Window_left=(screen.Width-Window_width)/2;
	Window_top=(screen.Height-Window_height)/2;
	window.open(aimFile,"",'toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width='+Window_width+',height='+Window_height+',left='+Window_left+',top='+Window_top+'');
}
//投稿表单验证
function checkTougaoForm()
{
	if (document.getElementById("Title").value=="")
	{
		alert("请正确输入标题");
		document.getElementById("Title").focus();
		return false;
	}
	if (document.getElementById("ValidatePic").value=="")
	{
		alert("请正确输入验证码");
		document.getElementById("ValidatePic").focus();
		return false;
	}
	document.getElementById("editor").submit();
}
//验证码的切换，失去焦点
function swapValidatePic(picID,cObj)
{
	if (!picID || picID=="")
	{
		alert("请定义出切换的验证码的ID名称！");
		return false;
	}
	var pic=document.getElementById(picID);
	pic.style.visibility="visible";
	if (cObj.value.length!=4)
	{
		//刷新验证码，避免同一页面的猜测
		pic.src='tools/validate_pic.aspx';
	}
}
function msover(obj)
{
}
function msout(obj)
{
}

