var BdScrollImage={};
BdScrollImage.Navigator=function(c,b){
	this.domObj=c;this.observers=[];
	this.curIndex=0;
	this.curBtn=null;
	var e=c.getElementsByTagName("a");
	this.btnObjs=[];
	if(b){
		for(var d=0,a=e.length;d<a;d++){
			this.btnObjs.push(e[a-1-d])
		}
	}else{
		for(var d=0,a=e.length;d<a;d++){
			this.btnObjs.push(e[d])
		}
	}
};
BdScrollImage.Navigator.prototype.registerEvent=function(){
	var a=this;
	(function(){
		function b(f){
			f=f||window.event;
			var d=f.target||f.srcElement,c=1;
			if(d.tagName&&d.tagName.toUpperCase()=="A"){
				c=d.getAttribute("index");
				if(c!=a.curIndex){a.notify({type:"STOP"});
				a.curBtn.className="navbtn";
				d.className="navbtn curbtn";
				a.curIndex=c;
				a.curBtn=d;
				a.notify({type:"SCROLL",param:a.curIndex});
				a.notify({type:"START"});
			}
		}
	}
	if(window.attachEvent){
		a.domObj.attachEvent("onclick",b)
	}else{
			a.domObj.addEventListener("click",b,false);
	}
    })()};
BdScrollImage.Navigator.prototype.setCurrent=function(a){
	if(this.curBtn){
		this.curBtn.className="navbtn"}
		this.curIndex=a;
		this.curBtn=this.btnObjs[a-1];
		this.curBtn.className="navbtn curbtn";
		this.notify({type:"SCROLL",param:a})
	};
	BdScrollImage.Navigator.prototype.handleMessage=function(e){
		var d=e.type;
		switch(d){
			case"SCROLL":var a=this.btnObjs.length,c=this.curIndex,b=c%a+1;
			this.setCurrent(b);
			break;
			default:break}};
			BdScrollImage.Controller=function(a){
				this.timer=0;
				this.interval=a||5000;
				this.scrollFuncName=Math.random();
				this.observers=[];
				var b=this;
				window[this.scrollFuncName]=function(){
					b.notify({type:"SCROLL"})
			}
		};
		BdScrollImage.Controller.prototype.start=function(){
				this.timer=window.setInterval(window[this.scrollFuncName],this.interval)
			};
			BdScrollImage.Controller.prototype.stop=function(){
				window.clearInterval(this.timer)};
				BdScrollImage.Controller.prototype.handleMessage=function(a){
					switch(a.type){
						case"START":this.start(this.interval);break;
						case"STOP":this.stop();break;
						case"RESTART":this.stop();this.start(this.interval);break;
						default:break
					}
			};
			BdScrollImage.Controller.prototype.registerEvent=function(){
					var b=Math.random(),a=this;window[b]=function(){
						a.start()
					};
					if(window.attachEvent){
						window.attachEvent("onload",window[b])
					}else{window.addEventListener("load",window[b],false)}
				};
				BdScrollImage.View=function(a,b){
					this.domObj=a;
					this.dataSource=b;
					this.curIndex=1;
					this.imgLink=a.getElementsByTagName("a")[0];
					this.imgObj=a.getElementsByTagName("img")[0];
					this.observers=[]
				};
				BdScrollImage.View.prototype.handleMessage=function(d){
						var a=this.dataSource,c=d.type;
						switch(c){
							case"SCROLL":
								var b=d.param;
							    this.imgLink.href=a[b-1]["url"];
								this.imgObj.src=a[b-1]["imgUrl"];
								this.imgLink.setAttribute("mon","ct=1&a=20&pn="+b+"&col=4");break;
							default:break
						}
				};
				BdScrollImage.View.prototype.registerEvent=function(){
						var a=this;
						(function(){
							function b(c){
								c=c||window.event;
								switch(c.type){
									case"mouseover":a.notify({type:"STOP"});return;
									case"mouseout":a.notify({type:"START"});return;
									default:return}
								}
								if(window.attachEvent){
									a.imgObj.attachEvent("onmouseover",b);
									a.imgObj.attachEvent("onmouseout",b)
								}else{a.imgObj.addEventListener("mouseover",b,false);
									a.imgObj.addEventListener("mouseout",b,false)
								}
							})()
				};
				BdScrollImage.Title=function(a,b){
						this.domObj=a;
						this.dataSource=b;
						this.curIndex=1;
						this.linkObj=a.getElementsByTagName("a")[0];
						this.observers=[]
				};
				BdScrollImage.Title.prototype.handleMessage=function(d){
						var a=this.dataSource,c=d.type;
						switch(c){
								case"SCROLL":
									var b=d.param;
									this.linkObj.href=a[b-1]["url"];
									this.linkObj.innerHTML=a[b-1]["title"];
									this.linkObj.setAttribute("mon","ct=1&a=20&pn="+b+"&col=4");break;
								default:break
						}
				};
				BdScrollImage.Title.prototype.registerEvent=function(){
							var a=this;
							(function(){
								function b(c){c=c||window.event;
								switch(c.type){
									case"mouseover":a.notify({type:"STOP"});return;
									case"mouseout":a.notify({type:"START"});return;
									default:return
								}
							}
								if(window.attachEvent){
									a.linkObj.attachEvent("onmouseover",b);
									a.linkObj.attachEvent("onmouseout",b)}
								else{
									a.linkObj.addEventListener("mouseover",b,false);
									a.linkObj.addEventListener("mouseout",b,false)
								}
							})()
				};
				BdScrollImage.ImageList=function(a){this.iL=a};
				BdScrollImage.ImageList.prototype.init=function(){
							var a=this.iL,c,d=new Date();
							window[d.getTime()]=[];
							if(a){for(var b=0;b<a.length;b++){
								window[d.getTime()][b]=new Image();
								window[d.getTime()][b].src=a[b]["imgUrl"]
							}
						}
				};
				function implement(a,c){
						for(var b in a){c[b]=a[b]}
				}
				var Observable=(function(){
					function a(c){
						if(c&&typeof c=="object"&&c.handleMessage){
							this.observers.push(c)
						}
					}
					function b(d){
						var e=this.observers;
						for(var c=0;c<e.length;c++){e[c].handleMessage(d)
					}
				}
				return{addObserver:a,notify:b}
			})();
		implement(Observable,BdScrollImage.Navigator.prototype);
		implement(Observable,BdScrollImage.View.prototype);
		implement(Observable,BdScrollImage.Title.prototype);
		implement(Observable,BdScrollImage.Controller.prototype);