/**
 * js广告类
 */
function veryAds(width,height,bgcolor,sign,timeout){
	timeout = timeout>0?timeout:2;
	var _pics,_links,_titles;
	var index = 0;
	var count = 0;
	var obj = {
		'params' : {'pic':'','link':'','title':'','width':940,'Height':265,'bgcolor':'#fff'},
		'index'	 : 0,//当前显示的图片
		'html'	 : '',

		//设置属性值
		'setVal' : function(name,value){
			if(value){
				if(name=='pic'||name=='link'||name=='title'){
					this.params[name] = value.split('|');
				}else
					this.params[name] = value;
			}
		},

		//获取属性值
		'getVal' : function(name){
			if(this.params[name])
				return this.params[name];
			else
				return '';
		},

		//组装
		'createHtml' : function(){
			var pics = _pics = this.getVal('pic');
			count = pics.length;
			var html = '';
			if(count>0){
				var link = _links = this.getVal('link');
				var title = _titles = this.getVal('title');
				link = link[this.index]?link[this.index]:'';
				title = title[this.index]?title[this.index]:'';
				html = "<div id='veryAdsJQueryDivDRTGH"+sign+"' style='position:absolute;width:"+this.getVal('width')+"px;height:"+this.getVal('height')+"px;background-color:"+this.getVal('bgcolor')+";'>";
				html += "<a href='"+link+"' title='"+title+"'>";
				html += "<img src='"+pics[this.index]+"' border=0 width='"+this.getVal('width')+"' height='"+this.getVal('height')+"' />";
				html += "</a></div>";
			}
			return html;
		},

		'write' : function(container){
			$(container).attr('innerHTML',this.createHtml());
			var time = this.getVal('timeout');
			if(count>1)setTimeout(function(){show();},timeout*1000);
		}
	};
	var show = function(){
		$('#veryAdsJQueryDivDRTGH'+sign).fadeOut("slow",function(){
			index += 1;
			index = index>=count?0:index;
			var link = _links[this.index]?_links[this.index]:'';
			var title = _titles[this.index]?_titles[this.index]:'';
			var html = "<a href='"+link+"' title='"+title+"'>";
			html += "<img src='"+_pics[index]+"' border=0 width='"+width+"' height='"+height+"' />"
			html += "</a>";
			$('#veryAdsJQueryDivDRTGH'+sign).attr('innerHTML',html);
			$('#veryAdsJQueryDivDRTGH'+sign).fadeIn("slow");
		});
		if(count>1)setTimeout(function(){show();},timeout*1000);
	};
	obj.setVal('width',width);
	obj.setVal('height',height);
	obj.setVal('bgcolor',bgcolor);
	return obj;
}

function focusAdFunc(pics,title,link,id){
	var links = link?link:'#|#|#|#';
	var texts = title?title:'|||';
	var focus_width=404
    var focus_height=324
    var text_height=0
    var swf_height = focus_height+text_height;
	 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="'+ focus_width +'" height="'+ swf_height +'">';
     flashCode = flashCode + '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="js/focus2.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">';
     flashCode = flashCode + '<param name="menu" value="false"><param name=wmode value="transparent">';
     flashCode = flashCode + '<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">';
     flashCode = flashCode + '<embed wmode="transparent" src="js/focus2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ focus_width +'" height="'+ swf_height +'" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"></embed>';
     flashCode = flashCode + '</object>';
     $(id).attr('innerHTML',flashCode);
}
