/*
 *   data = [{img:"img.jpg",text:"文字",link:"http://www.opendb.com.cn"}
 *           ,{img:"img.jpg",text:"文字",link:"http://www.opendb.com.cn"}]
 */

/**
 * 基于jQuery的焦点新闻Flash显示组件
 * @param {Object} dataArray  数据数组
 * @param {Object} options    选项
 */
var Focus = function(dataArray, options){
	this.data = dataArray;
	this.options = {
		id : 'focus'  //显示元素ID
		,width : 400  // 显示宽度
		,height : 200  //显示高度
		,textHeight : 0  //文字高度
		,swfUrl : '/moneditor/cs/image/flash/focus2.swf'  // flash文件路径
		,bgColor : '#F0F0F0' //背景颜色
	};
	$.extend(this.options, options);
	this.init();
};

Focus.prototype = {
	init : function(){
		var swfHight = this.options.height + this.options.textHeight;
		var pics=[],links=[],texts=[];
		for(var i=0; i<this.data.length; i++){
			pics.push(this.data[i].img);
			links.push(this.data[i].link);
			texts.push(this.data[i].text);
		};
		var strPic = pics.join('|');
		var strLink = links.join('|');
		var strText = texts.join('|');
		var flashCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/hotdeploy/flash/swflash.cab#version=6,0,0,0" width="' + this.options.width + '" height="' + swfHight + '">';
		flashCode = flashCode + '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="' + this.options.swfUrl + '"><param name="quality" value="high"><param name="bgcolor" value="'+this.options.bgColor+'"><param name="wmode" value="transparent" />';
		flashCode = flashCode + '<param name="menu" value="false"><param name=wmode value="opaque">';
		flashCode = flashCode + '<param name="FlashVars" value="pics=' + strPic + '&links=' + strLink + '&texts=' + strText + '&borderwidth=' + this.options.width + '&borderheight=' + this.options.height + '&textheight=' + this.options.textHeight + '">';
		flashCode = flashCode + '<embed src="'+this.options.swfUrl+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + this.options.width + '" height="' + swfHight + '" FlashVars="pics=' + strPic + '&links=' + strLink + '&texts=' + strText + '&borderwidth=' + this.options.width + '&borderheight=' + this.options.height + '&textheight=' + this.options.textHeight + '" wmode="transparent"></embed>';
		flashCode = flashCode + '</object>';
		$('#'+this.options.id).css({'background-color':this.options.bgColor, width:this.options.width+'px',height:swfHight+'px'});
		$('#'+this.options.id).html(flashCode);
	
	}
};


