/**
 * 灵活的flash焦点图轮换
 * @param width 宽带
 * @param height 高度
 * @param bgcolor 背景颜色
 * @return
 */
function adsFlash(width,height,bgcolor){
	var jsObj = {
		/**
		 * 动画相关属性
		 * pic：图片地址，多个用“|”隔开
		 * link：每张图对应的地址，多个用“|”隔开
		 * title：每张图对对应的标题，多个用“|”隔开
		 * pos：按扭位置 1左 2右 3上 4下
		 * timeout：图片停留时间
		 * show_text：是否显示文字描述，0关闭，1开启
		 * color：文字颜色
		 */
		'params' : {'pic':'','link':'','title':'','pos':4,'timeout':3000,'show_text':0,'color':'000'},
		
		/**
		 * flash高度
		 */
		'swfHeight' : '',
		
		/**
		 * 设置动画相关属性
		 */
		'setVal' : function(name,value){
			this.params[name] = value;
		},
		
		/**
		 * 获取动画的想属性值
		 */
		'getVal' : function(name){
			if(this.params[name])
				return this.params[name];
			else
				return ;
		},
		
		/**
		 * 初始化动画
		 */
		'init' : function(){
			this.swfHeight = this.getVal('show_text')==1?height+20:height;
			bgcolor = bgcolor?bgcolor:"fff";
		},
		
		/**
		 * 创建动画
		 */
		'createHtml' : function(){
			var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="'+ width +'" height="'+ this.swfHeight +'">';
			html += '<param name="movie" value="flash/focus.swf">';
			html += '<param name="quality" value="high"><param name="wmode" value="opaque">';
			html += '<param name="FlashVars" value="pics='+this.getVal('pic')+'&links='+this.getVal('link')+'&texts='+this.getVal('title')+'&pic_width='+width+'&pic_height='+height+'&show_text='+this.getVal('show_text')+'&txtcolor='+this.getVal('color')+'&bgcolor='+bgcolor+'&button_pos='+this.getVal('pos')+'&stop_time='+this.getVal('timeout')+'">';
			html += '<embed src="flash/focus.swf" FlashVars="pics='+this.getVal('pic')+'&links='+this.getVal('link')+'&texts='+this.getVal('title')+'&pic_width='+width+'&pic_height='+height+'&show_text='+this.getVal('show_text')+'&txtcolor='+this.getVal('color')+'&bgcolor='+bgcolor+'&button_pos='+this.getVal('pos')+'&stop_time='+this.getVal('timeout')+'" quality="high" width="'+ width +'" height="'+ this.swfHeight +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			html += '</object>';
			return html;
		},
		
		/**
		 * 将动画写入指定的容器中
		 */
		'write' : function(container){
			this.init();
			if(!this.getVal('pic')) return;
			var html = this.createHtml();
			$(container).append(html);
		}
	};
	
	return jsObj;
}
