<!--

/*****************************************************************************
                                  翔宇用到的js脚本
*****************************************************************************/

//是否按期显示日历
var verifyPage = 1;
//是否利用日期服务
var useService = 1;

//报纸的首版节点id
//对于不同的报，把该值改成对应的第一版的nodeid
var firstPageid = 0;


function checkDate()
{
	var yyyy, mon, day;
	var newUrl;
	yyyy = document.all("yearfield").value;
	if(fucCheckNUM(yyyy) == 0 || yyyy < 1000 || yyyy > 9999)
	{
		alert("请输出四位数字表示的年！");
		return false;
	}
	mon = document.all("monfield").value;
	if(fucCheckNUM(mon) == 0 || mon >12 || mon <1)
	{
		alert("请输入正确的月份！");
		return false;
	}
	
	day = document.all("dayfield").value;
	if(fucCheckNUM(day) == 0 || day > 31 || day < 1)
	{
		alert("请输入正确的日期！");
		return false;
	}
	//由于总是计算有误，不加那个来算了
	//但只对于静态页面的算法
	
	 curUrl = window.location.href;
	 pos1=curUrl.indexOf("enp.web.Publish");
	 if(pos1<0)
	 {
		 hh = "/"+yyyy+"-";
		 if(mon.length < 2)
		 	hh += "0";
		 hh += mon + "/";
		 if(day.length < 2)
		 	hh+="0";
		 hh += day;
		 ///////////////////
		 pos1 = curUrl.lastIndexOf('/');
		 curFile = curUrl.substring(pos1);
		 pos1 = curUrl.lastIndexOf('/',pos1-1);
		 pos1 = curUrl.lastIndexOf('/',pos1-1);
		 curBase = curUrl.substring(0,pos1);
		 newUrl = curBase + hh + curFile;
	 
	 	 if(verifyHttpHref(newUrl))
	 	 	window.open(newUrl);
	 	 else
	 	 	alert("你要查看的日期没有该版的页面，请从日历中跳转");
	}
	return false;
}


function fucCheckNUM(NUM)
{
	var i,j,strTemp;
	strTemp="0123456789";
	if ( NUM.length== 0)
		return 0
	for (i=0;i<NUM.length;i++)
	{
		j=strTemp.indexOf(NUM.charAt(i)); 
		if (j==-1)
		{
			//说明有字符不是数字
			return 0;
		}
	}
	//说明是数字
	return 1;
}


function buildXML(yy,mm)
{
 	var hh;
	var pos1,pos2;
	var curBase,curUrl,curFile;
	
	var nodeid,nodedate;
	var xmlurl;
	
        curUrl = window.location.href;
	pos1=curUrl.indexOf("enp.web.Publish");
	if(pos1>0)
	{
		curBase = curUrl.substring(0,pos1);
		//对于动态页面的算法
	 	hh = yy+"-";
	        if(mm+1 < 10)
	        	hh += "0";
	        hh += (mm+1);

	        ///////////////////
	        pos1 = curUrl.indexOf("&id=");
		if(pos1 > 0)
		{
					        
			pos2 = curUrl.indexOf('&',pos1+1);
			nodeid = curUrl.substring(pos1+4,pos2);
		}
		else
		{
			alert("预览url未找到&id");
			return false;
		}
		nodedate = hh;
		xmlurl = "/servlet/enp.service.NodeDateXMLService?id="+nodeid+"&date="+nodedate;
	}
	else
	{
	
		//对于静态页面的算法
	 	hh = "/"+yy+"-";
	        if(mm+1 < 10)
	        	hh += "0";
	        hh += (mm+1) + "/";

	        pos1 = curUrl.lastIndexOf('/');
	        pos1 = curUrl.lastIndexOf('/',pos1-1);
	        pos1 = curUrl.lastIndexOf('/',pos1-1);
	        curBase = curUrl.substring(0,pos1);
	         
		xmlurl = curBase + hh + "paper_existed.xml";

	
	/**
		//alert("1");
		//对于静态页面的算法
	 	hh = yy+"-";
	        if(mm+1 < 10)
	        	hh += "0";
	        hh += (mm+1);
	        nodedate = hh;
	        
	        
	        ///////////////////
	        //alert("3");
	        pos1 = curUrl.lastIndexOf('/');
	        //alert("pos1 = "+pos1);
	        curFile = curUrl.substring(pos1+1);
	        //alert(curFile);
	        pos1 = curFile.lastIndexOf('node_');
	        //alert("2");
	        if(pos1>=0)
	        {
	        	//alert("pos1 = "+pos1);
	        	pos2 = curFile.lastIndexOf('.');
	        	//alert("pos2 = "+pos2);
	        	nodeid = curFile.substring(pos1+5,pos2);
	        	xmlurl = "/NodeDateXMLService?date="+nodedate+"&id="+nodeid;
	        }
		else
		{
			xmlurl = "/NodeDateXMLService?date="+nodedate+"&file="+curFile;
		}
		//alert(xmlurl);
		
		*/
		
	        
	}
	
	try
	{

		
		var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
		xmlDoc.async = false;
		xmlDoc.resolveExternals = true;
		xmlDoc.load(xmlurl);
		//alert(xmlDoc.xml);
		//alert(xmlDoc.childNodes.length);
		
		if(typeof xmlDoc == "object")
     		{
     			var pagepath = "//node/dates[@pageid='"+firstPageid+"']/date";
     			//alert(pagepath);
     			var ret = xmlDoc.selectNodes(pagepath);
     			//alert(ret.length);
     			return ret;
     		}
     		else
     			return null;

		
		/**
		var xhr = new ActiveXObject("Msxml2.XMLHTTP");
	     	xhr.open("GET",xmlurl,false);
	     	xhr.send();
	     	
	     	//alert(xhr.status);
	     	
	     	if(xhr.status == 404)
	     	{
	     		//if(useService == 1)
	     			//alert("日期服务不存在");
	     		return null;
	     	}
     		//alert(xhr.status);
     		//alert(xhr.responseText);
     		var doc = xhr.responseXML;
     		//alert(doc.childNodes.length);
     		if(typeof doc == "object")
     		{
     			var pagepath = "//node/dates[@pageid='"+firstPageid+"']/date";
     			//alert(pagepath);
     			var ret = doc.selectNodes(pagepath);
     			//alert(ret.length);
     			return ret;
     		}
     		else
     			return null;
     		*/

     	}
   	catch (e) {
     		alert(e.description);
     		return null;
   	}
}

function nodeUrl(yy,mm,dd)
{
 	var hh;
	var pos1;
	var curBase,curUrl,curFile;
	
        curUrl = window.location.href;
	pos1=curUrl.indexOf("enp.web.Publish");
	if(pos1>0)
	{
		//对于动态页面的算法
	 	hh = yy+"-";
	        if(mm+1 < 10)
	        	hh