/*************************************************************************
    This code is from Dynamic Web Coding at dyn-web.com
    Copyright 2001-5 
    Edited by Vinay Naik 
    See Terms of Use at www.dyn-web.com/bus/terms.html
    regarding conditions under which you may use this code.
    This notice must be retained in the code as is!
*************************************************************************/

dw_Rotator.restartDelay = 100; // delay onmouseout before call to rotate
dw_Rotator.col	=	[];

function dw_Rotator(name,speed,path,tgt,alt)
{
	this.name		=	name;
	this.speed		=	speed||6500;
	this.path		=	path||"";
	this.tgt		=	tgt;
	this.ctr		=	0;
	this.ctr1		=	0;
	this.timer		=	0;
	this.imgs		=	[];
	this.imgsAlt	=	[];
	this.actions	=	[];
	this.imgsTarget =   [];
	this.index		=	dw_Rotator.col.length;
	
	dw_Rotator.col[this.index]	=	this;
	this.animString	=	"dw_Rotator.col["+this.index+"]";
};

dw_Rotator.prototype.addImages	=	function()
{
	var img;
	for(var i = 0; arguments[i]; i++)
	{
		img		=	new Image();
		img.src	=	this.path + arguments[i];
		this.imgs[this.imgs.length]	=	img;
	}
};

dw_Rotator.prototype.addImagesAlt	=	function()
{
	var img;
	for(var i = 0; arguments[i]; i++)
	{
		img			=	new Image();
		img.alt		=	arguments[i];
		this.imgsAlt[this.imgsAlt.length]	=	img;
		//alert(img.alt);
		
	}
};

dw_Rotator.prototype.addActions=function()
{
var len=arguments.length;
	for(var i=0;i<len;i++)
	{
		this.actions[this.actions.length]=arguments[i];
	}
	//alert(this.actions);
};




dw_Rotator.prototype.addFileTarget	=	function()
{
	var len = arguments.length;
	var obj = dw_Rotator.col[len];
	
	for(var i = 0; i < len; i++)
	{
		this.imgsTarget[this.imgsTarget.length] = arguments[i];			
	}
};

dw_Rotator.prototype.rotate	=	function()
{
	clearTimeout(this.timer);
	this.timer	=	null;
	
	if(this.ctr<this.imgs.length-1)
		this.ctr++;
	else 
		this.ctr=0;
		var imgObj=document.images[this.name];
		if(imgObj&&dw_Rotator.ready)
		{
			imgObj.src=this.imgs[this.ctr].src;
			imgObj.alt=this.imgsAlt[this.ctr].alt;
			this.timer=setTimeout(this.animString+".rotate()",this.speed);
		}
};
	
dw_Rotator.start=function()
{
	var len=dw_Rotator.col.length,obj;
	for(var i=0;i<len;i++)
	{
		obj=dw_Rotator.col[i];
		if(obj&&obj.name)obj.timer=setTimeout(obj.animString+".rotate()",obj.speed);
	}
};

//- TARGET WINDOW-  
	dw_Rotator.doClick=function(n)
	{
		var obj=dw_Rotator.col[n];
		if(!document.images||!obj)return true;
		if(obj.actions&&obj.actions[obj.ctr])
		{
			if(typeof obj.actions[obj.ctr]=="string")
			{
				//alert(obj.imgsTarget[obj.ctr]);
				if(obj.imgsTarget[obj.ctr]== "_self")
				{
					window.location=obj.actions[obj.ctr];
					
				}
				else
				{
					var win=window.open(obj.actions[obj.ctr],obj.tgt);
					if(win&&!win.closed)win.focus();
				}
			}
			else
			{
				obj.actions[obj.ctr]();
			}
		}
		return false;
	};
	
	dw_Rotator.pause=function(n)
	{
		dw_Rotator.clearTimers(n);
	};
	
	dw_Rotator.clearTimers=function(n)
	{
		var obj=dw_Rotator.col[n];
		if(obj)
		{
			clearTimeout(obj.timer);
			obj.timer=null;
		}
	};
	
	dw_Rotator.resume=function(n)
	{
		dw_Rotator.clearTimers(n);
		var obj=dw_Rotator.col[n];
		if(obj)
		{
			obj.timer=setTimeout(obj.animString+".rotate()",dw_Rotator.restartDelay);
		}
	};
	dw_Rotator.ready=true;
	
	
