// JavaScript Document
var __speed 		= 30;
var __movingInt 	= null;

function createMovingPics(resp, panelid, newsUrlBase, uploadPathBase, themePathBase) {
	
	var panel 	= $(panelid + "_panel");
	var panel1 	= $(panelid + "_panel1");
	var panel2 	= $(panelid + "_panel2");
	
	if(!panel || !panel1 || !panel2) return ;

	//获取XML数据
	var data = resp.responseXML;
	
	//获取链接结点数组
	var docs = data.getElementsByTagName("row");

	var buf = new Array();
	buf.push("<table width='100%' cellspacing='0' cellpadding='0' ><tr>");

	//循环显示每条记录
	for(var i=0 ; i<docs.length ; i++) {
		
		var mainpic = getValue(docs[i], "mainpic");
			
		if(mainpic.length == 0)  continue ;  		
		
		var id 				= getValue(docs[i],"id");
		var fullTitle 		= getValue(docs[i],"title");
		var title 			= getValue(docs[i],"title");
		var contentType		= getValue(docs[i],"contenttype");
		var contentURL		= getValue(docs[i],"contenturl");
		var createdDate		= getValue(docs[i],"createddate");
		var row_next		= getValue(docs[i],"row_next");
		var hits			= getValue(docs[i],"hits");
		
		if(row_next == "") row_next = 0;
		row_next = parseInt(row_next);
		
		if(this.length >0 && title.length > this.length) title = title.substring(0, this.length) + "...";
		
		if(createdDate.length > 10) createdDate = createdDate.substring(0,10);
		
		var url = "#" ;
		contentType = parseInt(contentType);
		
		switch(contentType) {
			case 1:
				url = newsUrlBase + id;
				break;
			case 2:
				url = "getFile.jsp?ID=" + id + "&file=" + contentURL;
				break;
			case 3:
				url = "getFile.jsp?ID=" + id + "&file=" + uploadPathBase + contentURL;
				break;
		}

		buf.push("<td align='center'><a href='" + url + "' title='" + fullTitle + "' target='_blank' >");
		buf.push("<img src='" + DOCINFO_UPLOADPATH + mainpic + "' alt='" + fullTitle + "' align='absmiddle' hspace='2' height='110' border='0' />");
		buf.push("</a></td>");

	}
	
	buf.push("</tr></table>");
	
	panel1.innerHTML = buf.join("");
	panel2.innerHTML = buf.join("");

	var movingFun = function() {
		
		if(panel2.offsetWidth - panel.scrollLeft <= 0) {
		
			panel.scrollLeft -= panel1.offsetWidth;
			
		} else {
			panel.scrollLeft++;
		}
	}

	panel.onmouseover = function() { 
		if(__movingInt) clearInterval(__movingInt);
	}
	
	panel.onmouseout = function() {
		__movingInt = setInterval(movingFun, __speed);
	}
	
	panel.onmouseout();
}

