﻿function scrollT(id,span,a){
	this.id=id;
	this.obj=$("#"+id);
	this.a=a;
	this.div=$("<div id=\"fmc_"+id+"\"></div>");
	this.cid=$("<ul></ul>");
	this.lid=$("<ul id=\"fmcli_"+id+"\"></ul>");
	this.time=span+250;
	this.stime=250;
	this.ot=null;
	this.i=1;
	this.count=0;
	this.start=false;
}
scrollT.prototype.bind = function(){
	var to=this;
	//to.obj[0].innerHTML="&nbsp;";
	//to.obj.html("");
	to.obj.append(to.div);
	to.bindCss();
	if(to.a){
		to.count=to.a.length;
		var x=1;
		for(var i=0;i<to.count;i++){
			if(""!=to.a[i]){
				var o1 = $("<li>"+to.a[i]+"</li>");
				var o2 = $("<li>"+x+"</li>");
				to.cid.append(o1)
				to.lid.append(o2);
				o2.mouseover(function(){
					to.Play(this.innerHTML);
					clearTimeout(to.ot);
				}).mouseout(function(){to.s();});
				x++;
			}
		}
		to.count=x-1;
		to.div.append(to.lid).append(to.cid);
		to.lid.find("li:first").attr("class","s");
		to.cid.find("li").mouseover(function(){
			clearTimeout(to.ot);
		}).mouseout(function(){
			to.s();
		});
		to.s();
	}
}
scrollT.prototype.Play = function(i){
	var to=this;if(to.start)return;
	to.start=true;
	var ti=parseInt(i);
	to.lid.find("li").removeClass();
	to.lid.find("li").eq(ti-1).attr("class","s");
	var height=to.cid.find("li").eq(0).height();
	this.cid.animate({marginTop:-1*(ti-1)*height+"px"},this.stime,function(){
		to.i=ti;
		to.start=false;
	});
}
scrollT.prototype.s = function(){
	var to=this;
	var ii=to.i;
	ii++;
	if(ii>to.count)ii=1;
	to.ot = setTimeout(function(){to.Play(ii);to.s()},to.time);
}
scrollT.prototype.bindCss=function(){
var css="<style type=\"text/css\">#fmc_"+this.id+" ul{margin:0;padding:0;list-style:none;}";
css+="#fmc_"+this.id+" img{border:0;}";
css+="#fmc_"+this.id+"{width:365px;height:220px;overflow:hidden;}";
css+="#fmc_"+this.id+" #fmcli_"+this.id+"{position:absolute;margin:196px 0 0 0;*margin:188px 0 0 0;text-align:right;width:358px;height:30px;}";
css+="#fmc_"+this.id+" #fmcli_"+this.id+" li{display:inline-block;border:solid 1px #74A8ED;background:#fff;padding:1px 4px;margin:8px 0 0 5px;font-size:12px;cursor:pointer;font-family:Arial;color:#74A8ED;}";
css+="#fmc_"+this.id+" #fmcli_"+this.id+" li.s{padding:2px 6px;margin-top:0;font-size:15px;font-weight:bold;background:#74A8ED;color:#fff;border:solid 1px #CCDEF7;}";
css+="*#fmc_"+this.id+" #fmcli_"+this.id+" li{display:inline;}</style>";
$("head").append(css);
}

var s = new scrollT("focus",2000,["<a href=\"http://www.2e5e.com/go/click?http://www.sccpoland.pl/\" target=\"_blank\"><img src=\"http://img.2e5e.com/UploadFile/Recommend/2010/0308/20100308053304TeKcbdZ9-_1.gif\" border=\"0\" alt=\"波兰国际贸易中心\" /></a>","<a href=\"http://www.2e5e.com/go/click?id=3&url=http://active.2e5e.com/stcf_13\" target=\"_blank\"><img src=\"http://img.2e5e.com/UploadFile/Recommend/2010/0112/201001120410260FcIZzbq-_3.jpg\" border=\"0\" alt=\"2010海峡两岸纺织服装博览会\" /></a>",""]);
s.bind();