String.prototype.Trim = function(){
   return this.replace(/(^\s*)|(\s*$)/g, "");
}


/*
function myform_onsubmit(theForm){
	if (theForm.WebSiteName.value.replace(/^\s*(\S*\s*\S*)\s*$/g,'$1')==""){
		alert ("请输入网站名称！");
		theForm.WebSiteName.focus();
		return false;
	}
	if (theForm.WebSiteURL.value.replace(/^\s*(\S*\s*\S*)\s*$/g,'$1')==""){
		alert ("请输入网站地址！");
		theForm.WebSiteURL.focus();
		return false;
	}
	if (theForm.WebSiteLogoURL.value.replace(/^\s*(\S*\s*\S*)\s*$/g,'$1')==""){
		alert ("请输入图标地址！");
		theForm.WebSiteLogoURL.focus();
		return false;
	}
	if (theForm.WebSiteReadMe.value.replace(/^\s*(\S*\s*\S*)\s*$/g,'$1')==""){
		alert ("请输入网站说明！");
		theForm.WebSiteReadMe.focus();
		return false;
	}
	if (theForm.UnitsName.value.replace(/^\s*(\S*\s*\S*)\s*$/g,'$1')==""){
		alert ("请输入单位名称！");
		theForm.UnitsName.focus();
		return false;
	}
	return true;
}
*/


function AutoSubmitForm(theForm){
	theForm.submit();
	return true;	
}

function chkDel(){
	if	(confirm("您确定删除吗?此操作将不能恢复!")){
		return true;
	}
	return false;
}


function GotoPage(theForm,nPageNo){
	theForm.Page.value=nPageNo;
	theForm.submit();
}

//全选
function CA(theForm){
  for(var i=0;i<theForm.elements.length;i++){
    var e=theForm.elements[i];
    if(e.name!='allbox') e.checked=theForm.allbox.checked;
  }
}


function DelProduct(theForm,oValue){
	var ProductIDStr = document.getElementsByName("RegLinkID");
	var L = ProductIDStr.length;
	var isSelected = false;
	var i = 0;
	for (i=0;i< L; i++){
		if (ProductIDStr[i].checked==true){
			isSelected = true;
			break;
		}
	}
	if (!isSelected){
		alert("请选择要操作的链接！")
		return false;
	}
	if	(confirm("您确定要这样做吗")){
		theForm.action = "Manage_RegLink_Do.asp";
		theForm.DataAction.value = oValue;
		//alert(theForm.DataAction.value);
		theForm.submit();
		return true;
	}
	return false;
}

function ChkOpenWin(){
	var RegLinkID
	var ProductIDStr = document.getElementsByName("RegLinkID");
	var L = ProductIDStr.length;
	var isSelected = false;
	var f = ''; 
	var i = 0;
	var k = 0
	for (i=0;i< L; i++){
		if (ProductIDStr[i].checked==true){
			isSelected = true;
			k = k + 1
			if(k==1){
				RegLinkID =  ProductIDStr[i].value
			}else{
				RegLinkID = RegLinkID + ','+ ProductIDStr[i].value
			}
		}
	}
	if (!isSelected){
		alert("请选择要操作的链接！")
		return false;
	}
	var f = 'Manage_RegLink_Set.asp?RegLinkID=' + RegLinkID;
	//alert(f)
	window.open(f,'myWindows1',"toolbar=no,menubar=no,directories=no,status=yes,"
	+"left=40,top=20,width=400,height=200,scrollbars=no,resizable=no");
	return true;
}

function OpenWin(f){
	
	//alert(f)
	window.open(f,'myWindows2',"toolbar=no,menubar=no,directories=no,status=yes,"
	+"left=40,top=20,width=400,height=290,scrollbars=no,resizable=no");
}


//跳转页面显示
function ShowPage(TotalPage,PageIndex,url){
	document.write("<a>"+PageIndex+"/"+TotalPage+"</a>");
	if (PageIndex<6) {
		PageLong=11-PageIndex;
	}
	else
		if (TotalPage-PageIndex<6) {
			PageLong=10-(TotalPage-PageIndex)
		}
		else {
			PageLong=5;
		}
	for (var i=1; i <= TotalPage; i++) {
		if (i < PageIndex+PageLong && i > PageIndex-PageLong || i==1 || i==TotalPage){
			if (PageIndex==i) {
				document.write("<span class='current'>"+ i +"</span>");
			}
			else {
				document.write("<a class=PageNum href=?PageIndex="+i+"&"+url+">"+ i +"</a>");
			}
		}
	}
	//document.write("<input onkeydown=if((event.keyCode==13)&&(this.value!=''))window.location='?PageIndex='+this.value+'&"+url+"'; onkeyup=if(isNaN(this.value))this.value='' class=PageInput></td></tr></table>");
}
