function BannerScroll() {
    this.name = "BannerScroll";
    this.item = new Array();
    this.currentspeed = 0;
    this.scrollspeed = 20;
    this.pausedelay = 1000;
    this.width = 100;
    this.height = 100;
    this.itemcount = 0;
    this.targetDiv = "";
    this.scrolltype = 1; //1 Horizontal, 2 Vertical
    this.rowCount = 1;
    this.colCount = 1;
    this.stop = false;
    this.pause = true;
    this.pausemouseover = true;
    this.setTime = null;
    
    this.addItem = function () {
        this.item[this.itemcount] = arguments[0];
        this.itemcount ++;
    };
 
    this.start = function () 
    {
        document.getElementById(this.targetDiv).innerHTML = this.htmImageDiv();
        this.currentspeed = this.scrollspeed;
        if(this.itemcount > 1) {
	        setTimeout(this.name+'.scroll()',this.currentspeed);
	    }
	    window.setTimeout(this.name+".stop = false", this.pausedelay);
    };
    
    this.htmImageDiv = function()
    {
        var strTemp = '<div id="'+this.name+'" style="overflow:hidden; position:relative; height:'+this.height+'px; width:'+(this.width *this.colCount) +'px;" >';
        for(var i = 0; i < this.itemcount; i++) 
        {
	        if(this.scrolltype == 1)
	            strTemp += '<div id="'+this.name+'item'+i+'" style="left:'+(this.width*i)+'px; width:'+this.width+'px; position:absolute; top:0px; ">';
	        else
	            strTemp += '<div id="'+this.name+'item'+i+'" style="left:0px; width:'+this.width+'px; position:absolute; top:'+((this.height/this.rowCount)*i)+'px; ">';
	            
	        strTemp += this.item[i] + '</div>';
        }
        strTemp += '</div>';
        return strTemp;
    };
    
    this.rolling = function () {
	    if ( this.stop == false  ) {
		    this.next();
	    }
	    clearTimeout(this.setTime);
	    this.setTime = window.setTimeout(this.name+".next()",this.scrollspeed * 2);
    }
    
    this.scroll = function () 
    {
        if (this.pause) {
	        window.setTimeout(this.name+".scroll()",this.pausedelay);
	        this.pause = false;
        }
        else
        {
	        this.currentspeed = this.scrollspeed;
	        if ( !this.stop ) {
                for (i = 0; i < this.itemcount; i++) {
	                obj = document.getElementById(this.name+'item'+i).style;
	                if(this.scrolltype == 1) {
	                    obj.left = (parseInt(obj.left) - 5).toString() + "px";
	                    if ( parseInt(obj.left) <= this.width * (-1) ) obj.left = (this.width * (this.itemcount-1)).toString() + "px";
	                    if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
	                }
	                else {
	                    obj.top = (parseInt(obj.top) - 5).toString() + "px";
				        if ( parseInt(obj.top) <= this.height/this.rowCount * (-1) ) obj.top = (this.height/this.rowCount * (this.itemcount-1)).toString() + "px";
				        if ( parseInt(obj.top) == 0 ) this.currentspeed = this.pausedelay;
	                }
                }
            }
            this.setTime = window.setTimeout(this.name+".scroll()",this.currentspeed);
        }
        
    };
    
    this.scrollnext = function() {
        clearTimeout(this.setTime);
	    this.currentspeed = this.scrollspeed;
	    if ( !this.stop ) {
            for (i = 0; i < this.itemcount; i++) 
            {
                obj = document.getElementById(this.name+'item'+i).style;
                obj.left = (parseInt(obj.left) - 5).toString() + "px";
                if ( parseInt(obj.left) <= this.width * (-1) ) obj.left = (this.width * (this.itemcount-1)).toString() + "px";
                if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
            }
        }
        this.setTime = window.setTimeout(this.name+".scrollnext()",this.currentspeed);
    }
    
    this.scrollprev = function() {
        clearTimeout(this.setTime);
	    this.currentspeed = this.scrollspeed;
        
        if ( !this.stop ) {
            for (i = 0; i < this.itemcount; i++) 
            {
                obj = document.getElementById(this.name+'item'+i).style;
                obj.left = (parseInt(obj.left) + 5).toString() + "px";
                if ( parseInt(obj.left) >= this.width * (this.itemcount-1)) obj.left = (this.width * (-1)).toString() + "px";
                if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
            }
        }
        this.setTime = window.setTimeout(this.name+".scrollprev()",this.currentspeed);
    }
    
    this.next = function() {
	    for (i = 0; i < this.itemcount; i++) {
		    obj = document.getElementById(this.name+'item'+i).style;
		    if ( parseInt(obj.left) < 1 ) { 
			    width = (this.width + parseInt(obj.left)).toString() + "px";
			    break;
		    }
	    }
	    for (i = 0; i < this.itemcount; i++) {
		    obj = document.getElementById(this.name+'item'+i).style;
		    if ( parseInt(obj.left) < 1 ) { 
			    obj.left = (this.width * (this.itemcount-1)).toString() + "px";
		    } else {
			    obj.left = (parseInt(obj.left) - width).toString() + "px";
		    }
	    }
    }
    
    
 
    this.prev = function() {
	    for (i = 0; i < this.itemcount; i++) {
		    obj = document.getElementById(this.name+'item'+i).style;
		    if ( parseInt(obj.left) < 1 ) { 
			    width = (parseInt(obj.left) * (-1)).toString() + "px";
			    break;
		    }
	    }
	    if ( width == 0 ) {
		    total_width = this.width * (this.itemcount-1);
		    for (i = 0; i < this.itemcount; i++) {
			    obj = document.getElementById(this.name+'item'+i).style;
			    if ( parseInt(obj.left) + 1 > total_width ) { 
				    obj.left = "0px";
			    } else {
				    obj.left = (parseInt(obj.left) + this.width).toString() + "px";
			    }
		    }
	    } else {
		    for (i = 0; i < this.itemcount; i++) {
			    obj = document.getElementById(this.name+'item'+i).style;
			    if ( parseInt(obj.left) < 1 ) { 
				    obj.left = "0px";
			    } else {
				    obj.left = (parseInt(obj.left) + width).toString() + "px";
			    }
		    }
	    }
    }
    
    this.onmouseover = function () 
    {
	    if (this.pausemouseover){
		   this.stop = true;
		   }
    };
    
    this.onmouseout = function () {
	    if (this.pausemouseover) {
		    this.stop = false;
	    }
    };
}
 

