/*  
    dw_random.js - random image rotation - version date: May 2005
    requires dw_rotator.js 
*/

/*************************************************************************
    This code is from Dynamic Web Coding at dyn-web.com
    Copyright 2001-5 by Sharon Paine 
    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_RandRotator.prototype=new dw_Rotator();
function dw_RandRotator(sp,pt,bClickable,bMouse,tgt)
{
	this.ctr = 0;
	this.num=dw_Rotator.col.length;
	this.name="RandRotateImg"+this.num;
	this.mouseEvs=bMouse;
	this.clickable=bClickable;
	this.rObj=dw_Rotator;
	this.rObj(this.name,sp,pt,tgt);
};
dw_RandRotator.prototype.setUpImage=function(imgAr,w,h,bTrans)
{
	this.trans=bTrans;
	//this.ctr=Math.floor(Math.random()*imgAr.length);
	this.ctr = 0;
	var img=imgAr[this.ctr];
	var imgStr='<img name="'+this.name+'" id="'+this.name+'" src="'+img+'"';
	imgStr+=(typeof w=="number")?' width="'+w+'"':'';
	imgStr+=(typeof h=="number")?' height="'+h+'"':'';
	imgStr+=' alt="">';
	var str="";
	if(this.clickable)
	{
		str+='<a href="" onclick="return dw_Rotator.doClick('+this.num+')"';
		if(this.mouseEvs)
		{
			str+=' onmouseover="dw_Rotator.pause('+this.num+')"';
			str+=' onmouseout="dw_Rotator.resume('+this.num+')"';
		}
		str+=' onfocus="this.blur()">'+imgStr+'</a>';
	}
	else
	{
		str=imgStr;
	}
	document.write(str);
	document.close();
	for(var i=0;imgAr[i];i++)
		this.addImages(imgAr[i]);
};
var ImgCount=0;
dw_RandRotator.prototype.rotate=function()
{
	this.ctr++;
	
	if(this.ctr >= this.imgs.length)
		this.ctr = 0;
	
	var imgObj = document.getElementById(this.name);
	var transApplied = false;
	
	if(!imgObj)
		return;
	
	if(this.trans&&typeof imgObj.filters!="undefined")
	{
		transApplied = true;
		imgObj.style.filter='blendTrans(duration=1)';
		if(imgObj.filters.blendTrans)
			imgObj.filters.blendTrans.Apply();
	}
	
	imgObj.src=this.imgs[this.ctr].src;

	if(transApplied) {
		imgObj.filters.blendTrans.Play();
	}
};