//====================================
// DDL Rotate
//
//
// Version: 1.01
//
// Author:   Dawson Cowals
// Created:  04-04-2001
// Modified: 01-22-2004
//
// Requires: ddl_browser.js
//====================================

////instantiate our object
//var ddlRollover = new DDLRolloverObj();

//initialize our options: secondsBetweenSwap, rotateStyle {"ordinal"|"random"}
//ddlRotate.initRotation(10,"ordinal");

//ddlRotate.addImage(0, "images/home_0_t.jpg", "");

//============================================================================
// DO NOT CHANGE ANYTHING BELOW THIS LINE...
//============================================================================


//DDLRotateObj type constructor
function DDLRotateObj() {
	//images needed for rotations
	this.imageThumbName         = new Array();
	this.imageThumbSrc          = new Array();
	this.imageFullURL           = new Array();

	//property values
	this.rotateStyle            = "ordinal";
	this.imageCount             = 0;
	this.imageIndex             = 0;
	this.numSeconds             = 10;
	this.numMiliseconds         = 10000;

	//member functions
	this.initRotation           = initRotation;
	this.addImage               = addImage;
	this.nextImage              = nextImage;
}

function initRotation(numSeconds, rotateStyle) {
	this.numSeconds     = numSeconds;
	this.numMiliseconds = numSeconds * 1000;

	//rotate: "ordinal" or "random"
	this.rotateStyle    = rotateStyle;
}

function addImage(imgIndex,imgThumbSrc,imgFullURL) {

    //img thumb name
    this.imageThumbName[imgIndex]    = imgThumbSrc;
    //img thumb source
    this.imageThumbSrc[imgIndex]     = new Image();
    this.imageThumbSrc[imgIndex].src = imgThumbSrc;
    //img full URL
    this.imageFullURL[imgIndex]      = imgFullURL;

    //update image count
    this.imageCount                  = this.imageThumbName.length;

}

function nextImage(ddlRotateObj,imgLayer,imgName) {
	var imgIndex        = 0;
	var callRecursively = "";

	//if we're configured to rotate randomly...
	if (this.rotateStyle == "random") {
		imgIndex = Math.floor(Math.random() * (this.imageCount - 1)) + 0;

		if (imgIndex < 1) {
			imgIndex = 0;
		} else if (imgIndex > this.imageCount - 1) {
			imgIndex = this.imageCount - 1;
		}
	//otherwise simply increment our counter and move to the next image...
	} else {
		this.imageIndex = this.imageIndex + 1;

		if (this.imageIndex > this.imageCount - 1) {
			this.imageIndex = 0;
		}

		imgIndex = this.imageIndex;

	}

	if (document.images) {
		//if we are using a newer browser
		if (is_nav6up || is_ie6up || is_gecko || is_opera5up) {
		   changeSrc = eval('document.getElementById(imgName).setAttribute("src",this.imageThumbName['+imgIndex+'])');
		//if we are dealing with NS4 and we are inside a layer
		//we have to call the div name first
		} else if (is_nav4up && imgLayer!=null) {
		   changeSrc = eval('document.layers["'+imgLayer+'"].document.images["'+imgName+'"].src=this.imageThumbSrc['+imgIndex+'].src');
		//otherwise if we are using IE5 or not accessing an image inside a layer
		} else {
		   document.images[imgName].src = this.imageThumbSrc[imgIndex].src;
		}

	}

	//build our recursive call and initiate it...
	callRecursively = ddlRotateObj + ".nextImage('"+ddlRotateObj+"', '"+imgLayer+"', '"+imgName+"')";
	setTimeout(callRecursively, this.numMiliseconds);

}
