function Request(name)
{	
	var str=window.location.search;
	if (str.indexOf(name)!=-1)
	{
		var pos_start=str.indexOf(name)+name.length+1;
		var pos_end=str.indexOf("&",pos_start);
		if (pos_end==-1)
		{
			return str.substring(pos_start);
		}
		else
		{
			return str.substring(pos_start,pos_end)
		}
	}
	else
	{
		return 0;
	}
	
}

function initPage(dt,pageNo)
{
	//获取容器，并清空内容
	var divBox = document.getElementById("pageBox");
	
	if(divBox.childNodes.length>0)
	{
		for (var i = divBox.childNodes.length-1; i>=0;i--)
		{
			divBox.removeChild(divBox.childNodes[i]);	
		}
	}
	
	if ( dt.Rows.length > 0 )
	{
		for (var i = 0 ; i < dt.Rows.length; i++)			
		{
			var newsDataId = dt.Rows[i].NewsDataId;
			var newsTitle = dt.Rows[i].NewsTitle;
			var newsPicture = dt.Rows[i].NewsPicture;
			var igmWidth;
			var imgHeight;
			if (navigator.appName=="Microsoft Internet Explorer")
			{
				imgWidth = 180;
				imgHeight = 135;
			}
			else
			{
				imgWidth = 180;
				imgHeight = 115;
			}			
			showPaper(divBox,i,newsDataId,newsTitle,newsPicture,imgWidth,imgHeight);
		}
	}
	
	var divCurrentPage = document.getElementById("currentPage");
	divCurrentPage.innerHTML = pageNo;
			
}



			
function showPaper(divBox,i,newsDataId,newsTitle,newsPicture,imgWidth,imgHeight)
{	
	var div_bg = "div_"+newsDataId;
	var div_img = "img_"+newsDataId;
	var div_box = "box_"+newsDataId;
	var div_info = "info_"+newsDataId;
	//行	
	var row = (i-i%2)/2;
	//列
	var col = i%2;
	
	
	if (!document.getElementById(div_bg))
	{
		var newNode = document.createElement("div");
		newNode.setAttribute("id", div_bg);
		divBox.appendChild(newNode);
	}

	//设置样式
	// titleDiv设置为div的引用		
	var bgDiv = document.getElementById(div_bg);	
	//获取容器,根据容器设置显示的相对位置
	bgDiv.style.backgroundColor = "#F7CBAD";
	bgDiv.style.border = "1px solid #F7CBAD";
	//bgDiv.style.backgroundColor = "#ffffff";
	//bgDiv.style.border = "1px solid #0ddf20";
	bgDiv.style.width = imgWidth + 10;
	bgDiv.style.height = imgHeight + 10;
	var left = (document.body.clientWidth - 1004)/2 + col * 196 + 25;
	var top = 382 + row * 210;
	bgDiv.style.left = left;
	bgDiv.style.top = top;
	bgDiv.style.position = "absolute";	
	bgDiv.style.visibility = "visible";
	//bgDiv.style.zIndex = 100;	
	bgDiv.style.textAlign = "center";
	bgDiv.style.cursor = "pointer";			
	bgDiv.onclick = function(){showNews(newsDataId);}
	//bgDiv.onmousemove = followcursor;
	//bgDiv.onmouseout = dismissmessage;	
	//如果层divName中有内容, 则删除	
	if(bgDiv.childNodes.length>0)
	{
		for (var i = bgDiv.childNodes.length-1; i>=0;i--)
		{
			bgDiv.removeChild(bgDiv.childNodes[i]);	
		}
	}
	//加内容	
	var spanImg = document.createElement("span"); 
	var id = Request("id");			
	var strImg ="<img src="+ newsPicture +" alt="+ newsTitle +" width="+ imgWidth +" height="+ imgHeight +" border=0>";	
	spanImg.innerHTML = strImg;			
	bgDiv.appendChild(spanImg);
	//上下居中
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		bgDiv.style.paddingTop = (bgDiv.offsetHeight-spanImg.offsetHeight)/2;
	}
	else
	{
		bgDiv.style.paddingTop = 10;
	}
	
	
	//加标题
	if (!document.getElementById(div_info))
	{
		var newNode = document.createElement("div");
		newNode.setAttribute("id", div_info);
		divBox.appendChild(newNode);
	}
	
	//设置样式
	// titleDiv设置为div的引用		
	var infoDiv = document.getElementById(div_info);
	//获取容器,根据容器设置显示的相对位置
	infoDiv.style.backgroundColor = "#FFFBEC";
	//infoDiv.style.border = "1px solid #0B6440";
	infoDiv.style.border = "0px none";		
	infoDiv.style.width = bgDiv.offsetWidth;
	infoDiv.style.height = 35;	
	infoDiv.style.left = bgDiv.offsetLeft;
	infoDiv.style.top = bgDiv.offsetTop + bgDiv.offsetHeight + 10;
	infoDiv.style.position = "absolute";	
	infoDiv.style.visibility = "visible";
	//infoDiv.style.zIndex = 100;	
	infoDiv.style.fontSize = 14;
	infoDiv.style.textAlign = "center";
	infoDiv.style.cursor = "pointer";
	infoDiv.onclick = function(){showNews(newsDataId)};
	
	//如果层divName中有内容, 则删除	
	
	if(infoDiv.childNodes.length>0)
	{
		for (var i = infoDiv.childNodes.length-1; i>=0;i--)
		{
			infoDiv.removeChild(infoDiv.childNodes[i]);	
		}
	}
	//加内容	
	var spanInfo = document.createElement("span"); 	
	spanInfo.innerHTML = newsTitle;			
	infoDiv.appendChild(spanInfo);
	//上下居中
	infoDiv.style.paddingTop = (infoDiv.offsetHeight-spanInfo.offsetHeight)/2;		
}

function showPageNews(dt,newsCataId,pageRows,pageNo,pageCount)
{
	//alert(pageNo);
	
	var boxWidth = 580;
	var boxHeight = 25;
	//alert(pageNo);
	var div = document.getElementById("divLineNews");
	//如果层divBox中有内容, 则删除	
	if(div.childNodes.length>0)
	{
		for (var i = div.childNodes.length-1; i>=0;i--)
		{
			div.removeChild(div.childNodes[i]);	
		}
	}
	
	var divRight = document.createElement("div");	
	divRight.style.backgroundColor = "#FFFBEC";
	//divRight.style.border = "1px solid #7FABDC";
	divRight.style.textAlign = "left";
	divRight.style.border = "0px none";
	divRight.style.fontSize = "16px";
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		divRight.style.width = boxWidth;
		divRight.style.height = boxHeight;		
	}
	else
	{
		divRight.style.width = boxWidth - 10;
		divRight.style.height = boxHeight - 10;
	}
	
	divRight.style.position = "relative";			
	//divRight.style.left = divBox.offsetLeft + divBox.offsetWidth - (boxWidth/2 + 60)- divBox.offsetLeft;
	//divLeft.style.top = divBox.offsetTop+1;		
	div.appendChild(divRight);
		
	//var spanUL = document.createElement("UL");	
	for ( var i = 0; i < dt.Rows.length; i++ )		
	{
	
		var spanLi = document.createElement("div");
		var newsTitle = dt.Rows[i].NewsTitle;		
		var str ="<a href=show.aspx?id="+ dt.Rows[i].NewsDataId +" target=_blank title="+ dt.Rows[i].NewsTitle +"><font color="+ dt.Rows[i].Color +">"+ newsTitle +"</font></a>";
		spanLi.innerHTML = str;			
		//spanUL.appendChild(spanLi);			
		divRight.appendChild(spanLi);
	}	
	divRight.style.paddingTop = 8;		
	
}

