
function banerRotator ( objName, imgId, linkId, delay )
{
	this.objName = objName
	this.linkId = linkId ;
	this.imgId = imgId ;
	this.delay = delay * 1000;
	this.imagesArray = new Array();
	this.linksArray = new Array();
	this.banerCount = 0;
	this.active = -1;
	
	this.addBaner = function ( imgPath, link )
	{
		this.imagesArray[ this.banerCount ] = imgPath;
		this.linksArray[ this.banerCount ] = link;
		this.banerCount++;
	}
	
	this.run = function ( )
	{
		
		if( this.banerCount > 0 )
		{
			if( this.active == this.banerCount - 1 )
				var next = 0;
			else
				var next = this.active + 1;
		
			if( typeof( this.imagesArray[ next ] ) == 'string' )
			{
				var path = this.imagesArray[ next ];
				this.imagesArray[ next ] = new Image( );
				this.imagesArray[ next ].src =  path;
				
			}
			
			if( typeof( this.imagesArray[ next ] ) == 'object' )
			{
			
				if( document.getElementById( this.imgId ) )
				{
					document.getElementById( this.imgId ).src = this.imagesArray[ next ].src;
					document.getElementById( this.linkId ).href = this.linksArray[ next ];
					this.active = next;
				}
			}
			setTimeout( this.objName+".run()", this.delay );
		}		
	}
	
	

}

