
dw_RandRotator.prototype=new dw_Rotator();
function dw_RandRotator(sp,pt,bClickable,bMouse,tgt){
	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);
	this.custcurrimg = 0;
};

dw_RandRotator.prototype.setUpImage=function(imgAr,w,h,bTrans,txtAr){
	this.trans=bTrans;
	//this.ctr=Math.floor(Math.random()*imgAr.length);
	this.ctr=this.custcurrimg;

	var img=imgAr[this.ctr];
	var txt=txtAr[this.ctr];
	var imgStr='<img border=1 style="border:1px solid #FFFFFF;" name="'+this.name+'" src="'+this.path+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><div id="txtdiv">' + txt + '</div>';
	}else{
		str=imgStr;
	}
	document.write(str);
	document.close();
	for(var i=0;imgAr[i];i++)this.addImages(imgAr[i]);
	for(var i=0;txtAr[i];i++)this.addTxt(txtAr[i]);
};
dw_RandRotator.prototype.rotate=function(){
	clearTimeout(this.timer);
	this.timer=null;
	
	// run in order
	this.custcurrimg=this.custcurrimg + 1;
	if (this.custcurrimg == this.imgs.length) { this.custcurrimg = 0; }
	var ctr=this.custcurrimg;

	// run randomly
	//var ctr=Math.floor(Math.random()*this.imgs.length);
	//var i=0;
	//while(ctr==this.ctr&&i<6){
	//	ctr=Math.floor(Math.random()*this.imgs.length);
	//	i++;
	//}
	
	this.ctr=ctr;
	
	var imgObj=document.images[this.name];
	var txtObj=document.getElementById("txtdiv"); //.innerHTML
	if(!imgObj||!dw_Rotator.ready)return;
	if(!txtObj||!dw_Rotator.ready)return;
	if(this.trans&&typeof imgObj.filters!="undefined"){
		imgObj.style.filter='blendTrans(duration=1)';
		if(imgObj.filters.blendTrans)imgObj.filters.blendTrans.Apply();
	}
	if(this.trans&&typeof txtObj.filters!="undefined"){
		txtObj.style.filter='blendTrans(duration=1)';
		if(txtObj.filters.blendTrans)txtObj.filters.blendTrans.Apply();
	}
	imgObj.src=this.imgs[this.ctr].src;
	txtObj.innerHTML = this.txts[this.ctr];
	
	if(this.trans&&typeof imgObj.filters!="undefined"&&imgObj.filters.blendTrans) imgObj.filters.blendTrans.Play();
	if(this.trans&&typeof imgObj.filters!="undefined"&&txtObj.filters.blendTrans) txtObj.filters.blendTrans.Play();
	this.timer=setTimeout(this.animString+".rotate()",this.speed);
};
