/**
 * 设置滚动图片信息
 * @param {} data
 * @param {} width图片宽度
 * @param {} height 图片高度
 * @param {} button_pos按扭位置 1左 2右 3上 4下
 * @param {} stop_time图片停留时间(1000为1秒钟)
 * @param {} show_text是否显示文字标签 1显示 0不显示
 * @param {} txtcolor文字色
 * @param {} bgcolor背景色
 * @return {} 返回html字符
 */
function setScrollPhoto(data, pic_width, pic_height, button_pos, stop_time, show_text, txtcolor, bgcolor) {

	var image = new Array();
	var link = new Array();
	var text = new Array();	
	
	// 可编辑内容结束
	var swf_height = show_text == 1 ? pic_height + 20 : pic_height;
	var pics = "", links = "", texts = "";
	for(var i = 0; i<data.length; i++){
		pics = pics + ("|" + data[i].url);
		links = links + ("|" + data[i].link);
		texts = texts + ("|" + data[i].name);
	}
	
	pics = pics.substring(1);
	//alert(pics);
	links = links.substring(1);
	texts = texts.substring(1);
	
	var htmlStr = "";
	htmlStr = htmlStr
			+ '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="'
			+ pic_width + '" height="' + swf_height + '">';
	htmlStr = htmlStr + '<param name="movie" value="flash/focus.swf">';
	htmlStr = htmlStr
			+ '<param name="quality" value="high"><param name="wmode" value="opaque">';
	htmlStr = htmlStr + '<param name="FlashVars" value="pics=' + pics
			+ '&links=' + links + '&texts=' + texts + '&pic_width=' + pic_width
			+ '&pic_height=' + pic_height + '&show_text=' + show_text
			+ '&txtcolor=' + txtcolor + '&bgcolor=' + bgcolor + '&button_pos='
			+ button_pos + '&stop_time=' + stop_time + '">';
	htmlStr = htmlStr
			+ '<embed src="flash/focus.swf" FlashVars="pics='
			+ pics
			+ '&links='
			+ links
			+ '&texts='
			+ texts
			+ '&pic_width='
			+ pic_width
			+ '&pic_height='
			+ pic_height
			+ '&show_text='
			+ show_text
			+ '&txtcolor='
			+ txtcolor
			+ '&bgcolor='
			+ bgcolor
			+ '&button_pos='
			+ button_pos
			+ '&stop_time='
			+ stop_time
			+ '" quality="high" width="'
			+ pic_width
			+ '" height="'
			+ swf_height
			+ '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	htmlStr = htmlStr + '</object>';
	return htmlStr;
}



function setPic(obj) {
	$("#content_1_pic").html(setScrollPhoto(obj, 316, 269, 4, 6000, 0,
			'000000', 'dddddd'));
}

/*
<div id="content_1_pic" class="magin_right_5"><img src="${pageContext.request.contextPath}/images/loading.gif"/></div>
*/

//以下为异步请求滚动图片
var req;

function ajaxReqRollPic() {
	var url="listRollPicForIndex.do";
	initReq();
	req.open("GET", url, true);
	req.onreadystatechange = callback;
	req.send(null);
}

function callback() {
	if (req.readyState==4){
	    if(req.status==200){
	    	//得到json字符串
	    	//alert(req.responseText);
	    	var data = eval('(' + req.responseText + ')');
	    	//alert(data[0].url);
	    	setPic(data);
		}
	 }
}

function initReq() {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
}


