<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="/cms4j" prefix="cms4j" %>

<%@ page import = "cn.com.dekn.cms.util.*,cn.com.dekn.common.util.*" %>
<script>
function searchManage(searchStr,operType,name,value){
	var searchArray = new Array();
	var returnStr = "";		
	if (searchStr != ""){
		searchArray = searchStr.split("&");	
		
		for(var i = 0 ; i < searchArray.length ; i ++){
			if (searchArray[i] != ""){
				var paramArray = new Array();
				paramArray = searchArray[i].split("=");		
				if (paramArray[0] == name){
					searchArray.splice(i,1);
					i--;
				}
			}
		}
	}
	
	if (operType == "add"){
		returnStr = name +  "=" + value;
	}
	
	if (operType == "remove"){
	}
	
	
	for(var j = 0; j < searchArray.length; j++){
		if (searchArray[j] != ""){
			returnStr += "&" + searchArray[j];
		}
	}

	return returnStr;
	
}


function addSearch(searchStr,name,value){
	if (searchStr == "URL"){
		return searchManage(this.location.search.substr(1),"add",name,value);
	}
	return searchManage(searchStr,"add",name,value);	
}




function removeSearch(searchStr,name){
	if (searchStr == "URL"){
		return searchManage(this.location.search.substr(1),"remove",name,"");	
	}
	return searchManage(searchStr,"remove",name,"");	
}

function getSearchValue(searchStrParam,name){
	if (searchStrParam == "URL"){
		searchStr = this.location.search.substr(1);
	}else{
		searchStr = searchStrParam;
	}
	
	
	var searchArray = new Array();
	var returnStr = "";		
	if (searchStr != ""){
		searchArray = searchStr.split("&");	
		
		for(var i = 0 ; i < searchArray.length ; i ++){
			if (searchArray[i] != ""){
				var paramArray = new Array();
				paramArray = searchArray[i].split("=");		
				if (paramArray[0] == name){
					returnStr = paramArray[1];
					return returnStr;
				}
			}
		}
	}
	
	return "";
}
</script>
<% 
/***********************************
* TAG参数初始化
***********************************/
//要显示栏目的ID
String ARTICLE_ID = ParamUtil.getStrParam(request,"ARTICLE_ID","0"); 
%>



	<% int picIndex = 0; %>

	<cms4j:article_image article_id="<%=ARTICLE_ID%>">
		<% if(++picIndex == 1){ %>
		
			<script>
			var picURL = "";	//所有图片地址
			var picTITLE = "";	//所有图片标题
		  
			var picURLArray,picTITLEArray;
		  
			var fristPicURL = "";		//第一张图片的地址
			var fristPicTITLE = "";	//第一张图片的标题
		  
			var picCount = 0;	//图片数
	
			picURL = "<%=article_image_info.getIMG_URL()%>";
			picTITLE = "<%=article_image_info.getTITLE()%>";
			fristPicURL = "<%=article_image_info.getIMG_URL()%>";
			fristPicTITLE = "<%=article_image_info.getTITLE()%>";
			
		<% }else{ %>
		
			picURL = picURL + "|" + "<%=article_image_info.getIMG_URL()%>";
			picTITLE = picTITLE + "|" + "<%=article_image_info.getTITLE()%>";
		
		<% } %>
	
		picCount++;
		
  	</cms4j:article_image>
  
		

  	<% if(picIndex > 0){ %>
	
		picURLArray = picURL.split("|");
		picTITLEArray = picTITLE.split("|");
	
		var currIndex = getSearchValue("URL","ipn");
		if(currIndex < 1){
			currIndex = 1;
		}
		</script>
	
	
	<table border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
	  <tr>
		<td align="center" bgcolor="#FFFFFF"><img src="" border="0" class="img_border" id="articlePicImg" onClick="next();" style="cursor:pointer" alt="点击查看下一张"></td>
	  </tr>
  </table>
  
	<table width="94%" border="0" cellspacing="10" cellpadding="0">
	  <tr>
		<td align="center" class="pptimg_title" id="articlePicTitle">loading...</td>
	  </tr>
	  <tr>
		<td align="center"><a href="javascript:perv()">
	<img src="images/btn_perv.gif" width="32" height="25" border="0"></a> 　<span class="pptimg_page" id="currIndexSpan">1</span><span class="pptimg_page"> of <span id="picCountSpan">2</span></span> 　<a href="javascript:next()"><img src="images/btn_next.gif" width="32" height="25" border="0"></a></td>
	  </tr>
	  <tr>
		<td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr height="2">
			<td bgcolor="#D1D0C3"></td>
		  </tr>
		</table></td>
	  </tr>
	</table>

	<script>
	document.getElementById("currIndexSpan").innerHTML = currIndex;
	document.getElementById("picCountSpan").innerHTML = picCount;
	document.getElementById("articlePicImg").src = picURLArray[currIndex-1];
	document.getElementById("articlePicTitle").innerHTML = picTITLEArray[currIndex-1];
	
	function perv(){
		if(currIndex > 1){
			removeSearch("URL","ipn");
			this.location.search = addSearch("URL","ipn",--currIndex);
		}
	}
	
	
	function next(){
		if(currIndex < picCount){
			removeSearch("URL","ipn");
			this.location.search = addSearch("URL","ipn",++currIndex);
		}
	}
	</script>	
		
	<% } %>		