function GunDongPic(pic,width,id,speed) {
	this.Width = width;
	this.Id = id;
	this.Directon = 'left';
	this.Action = 1;
	this.Speed = speed;
	this.pex =   1;
	this.Pic = pic;
	this.I = 1;
	this.Index = 0;
	var that=this;
	this.Action = 1;
	this.construct = function(){
		this.Id = '#'+this.Id;
		this.Width += parseInt( $(this.Id + ' div:eq(1)').css('margin-left').replace(/px/ig,''));
		this.Pic = $(this.Id + ' img');
		this.Font = this.Width - 10;
		this.PicNum = $(this.Id + ' div').length;
		$('#LeftArr').bind('click',function(){that.goLeft()});
		$('#RightArr').bind('click',function(){that.goRight()});
		$(this.Id).bind('mouseover',function(){that.stop()});
		$(this.Id).bind('mouseout',function(){that.start()});
		this.add = 0;
	}
	this.play = function() {
	
		if (this.Action) {
			if (this.I < this.Width) {
				if (this.I == 1) {
					if (this.Directon == "left") {
						this.add==0?this.s = 9:this.s=7;
						for(i=0;i<=this.s-$(this.Id + ' div').length;i++){
							this.Index == this.PicNum-1?this.Index = 0:this.Index++;
							 $(this.Id).append('<div  class=box><a  href=\"'+
									 this.Pic[this.Index].id
									 +'\" target=_blank><img height=54 alt=\"北京电视台\" src=\"'  
			                    		+ this.Pic[this.Index].src
													+ '\"width=94 border=0 /></a></div>');
								
						}
						this.add++;
					} else {
						$('.index').attr('class', '');
						this.Index == this.PicNum-1?this.Index = 0:this.Index++;
						$(this.Id + ' div:eq(0)').before('<div class=box><a class=imgBorder href=\"#\" target=_blank><img height=54 alt=\"北京电视台\" src=\"'  
	                    		+ this.Pic[this.Index].src
								+ '\"width=94 border=0 /></a></div>');
					}
				}
				if (this.I >= 30)this.pex = 10;
				if (this.I < this.Width-4) {
					if (this.Directon == "left") {
						$(this.Id).css('margin-left',
								"-" + (this.I + this.Font) + 'px');
					} else {
						$(this.Id).css('margin-left',
								"-" + (this.Font -4- this.I) + 'px');
					}
					this.I += this.pex;
				} else {
					if (this.Directon == "left") {
						$(this.Id + ' div:eq(0)').remove();
						$(this.Id + ' div:eq(0)').attr('class', 'index');
						$(this.Id).css('margin-' + this.Directon,
								'-' + (this.Font-1) + 'px');
					} else {
						$(this.Id + ' div:eq('
										+ ($(this.Id + ' div').length-1) + ')')
								.remove();
						$(this.Id).css('margin-left','2px');
					}
					
					this.I = this.Width+100;
				}
				this.Mov1 = window.setTimeout(function(){that.play()}, 50);
			} else {
				this.pex = this.Speed ;
				if (this.Index == this.PicNum)this.Index = 0;
				this.I = 1;
				this.Mov2 = window.setTimeout(function(){that.play()},3000);
			}
		}
	}
	this.stop = function(){
		clearTimeout(that.Mov1);
    	clearTimeout(that.Mov2);	
    	this.Action = 0;
		this.play();
	}
	this.goLeft= function(){
		clearTimeout(that.Mov1);
    	clearTimeout(that.Mov2);
    	this.Directon = 'left';
    	this.pex = 30; 	
    	this.play(1);	
	}
	this.goRight= function(){
		clearTimeout(that.Mov1);
    	clearTimeout(that.Mov2);
    	this.Directon = 'right';
    	this.pex = 30; 	
    	this.play();
	}
	this.start= function(){
		this.Action = 1;
    	this.play();	
	}
}

