﻿//js分页代码 edit by guoyl 2008-05-06
function createPageHTML(_nPageCount, _nCurrIndex, _sPageName, _sPageExt){
	if(_nPageCount == null || _nPageCount<=1 || _nCurrIndex>=_nPageCount){
	return;
	}
	var nCurrIndex = _nCurrIndex || 0;
	var firstPage = "<a href=\""+_sPageName+"."+_sPageExt+"\" class=s1 target=_self>首 页</a>&nbsp;&nbsp;";
	var nextPage = "<a href=\""+_sPageName+"_"+(nCurrIndex+1)+"."+_sPageExt+"\" class=s1 target=_self>下一页</a>&nbsp;&nbsp;";
	var prePage = "<a href=\""+_sPageName+"."+_sPageExt+"\" class=s1 target=_self>上 页</a>&nbsp;&nbsp;";
	var prePage_1 = "<a href=\""+_sPageName+"_"+(nCurrIndex-1)+"."+_sPageExt+"\" class=s1 target=_self>上一页</a>&nbsp;&nbsp;";
	var lastPage = "<a href=\""+_sPageName+"_" +(_nPageCount-1)+"."+_sPageExt+"\" class=s1 target=_self>尾 页</a>&nbsp;&nbsp;";
	var firstPage_off = "<a href='javascript:void(0)' class=s2>首 页</a>&nbsp;&nbsp;";
	var nextPage_off = "<a href='javascript:void(0)' class=s2>下一页</a>&nbsp;&nbsp;";
	var prePage_off = "<a href='javascript:void(0)' class=s2>上一页</a>&nbsp;&nbsp;";
	var lastPage_off = "<a href='javascript:void(0)' class=s2>尾 页</a>&nbsp;&nbsp;";
	
	document.write("当前第<span class=font_red>"+(nCurrIndex+1)+"</span>页　总共<span class=font_red>"+_nPageCount+"</span>页 ");
	if(nCurrIndex == 0)
	{
		document.write(firstPage_off);
		document.write(prePage_off);
		document.write(nextPage);	
		document.write(lastPage);
		
	}
	else
		if(nCurrIndex==(_nPageCount-1))
		{
			document.write(firstPage);
			if(_nPageCount==2)
			{document.write(prePage);}
			else
			{document.write(prePage_1);}
			document.write(nextPage_off);
			document.write(lastPage_off);
		}
		else
		{
			document.write(firstPage);
				if(nCurrIndex==1)
				{document.write(prePage);}
				else
				{document.write(prePage_1);}
			document.write(nextPage);
			document.write(lastPage);
			
			document.write("<select name=\"select\" style=\"margin-bottom:-3px;\" onchange=\"location.replace(this.value)\">");
			document.write("<option selected >转到</option>");
			for(var i=0; i<_nPageCount; i++)
			{
			if(i==0)
			document.write("<option value=\""+_sPageName+"."+_sPageExt+"\">第1页</option>");
			else
			document.write("<option value=\""+_sPageName+"_" + i + "."+_sPageExt+"\">第"+(i+1)+"页</option>");
			}
			document.write("</select>");
			
	}
}

//导航定位函数 20100920 add by guoyl
function curNav(id) {
		$("#headerNav > li a").addClass("nav_off");
		$("#headerNav > li a").removeClass("nav_on");
		$("#mynav"+id).addClass("nav_on");
	}

String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}


function IsURL(str_url){
  var strRegex = "^((https|http)+://)";
	var re=new RegExp(strRegex); 
	if (re.test(str_url)){
		return (true); 
	}else{ 
		return (false); 
	}
}

function ow(obj,w,h,t,l) { 
	URL=obj.href; 
	window.open(URL,'','width='+ w +',height='+ h + ',top='+t+',left='+l+',resizable=no,scrollbars=no,toolbars=no,status=no'); 
	return false; 
} 

function showRelDocs(_istable,istableurl,_absurl,desc){
	var istable = _istable || "";
	var istableurl = istableurl || "";
	if(istable!=""){
		document.writeln("<span>|</span>");
		document.writeln('<a onclick="return ow(this,450,300,200,300)" href="/cn/js2008/relBg.htm?from='+_absurl+'"  target="_blank">'+desc+'</a>');
	}else if (istableurl!="" && IsURL(istableurl)){
		document.writeln("<span>|</span>");
		document.writeln('<a href="'+istableurl+'" target="_blank">'+desc+'</a>');
	}
}

