// DYNAMIC IMAGE OBJECT CONSTRUCTOR
function DynamicImage (imgDir, imgName, imgOff, imgOn)
{
	this.name = imgName;
	this.imgOff = loadImage(imgOff, imgDir);
	this.imgOn = loadImage(imgOn, imgDir);
	this.on = on;
	this.off = off;
}

// RANDOM IMAGE OBJECT CONSTRUCTOR
function RandomImage (imgName, arrayOff, arrayOn, width, height)
{
	this.name = imgName;
	this.num = getRandNum(arrayOff.length);
	this.imgOff = loadRandImage(arrayOff, this.num, width, height);
	this.imgOn = loadRandImage(arrayOn, this.num, width, height);
	this.on = on;
	this.off = off;
	this.printTag = printTag;
}

// MEMBER
function on ()
{
	document[this.name].src = this.imgOn.src;
}

// MEMBER
function off ()
{
	document[this.name].src = this.imgOff.src;
}

// MEMBER
function printTag ()
{
	document.write('<IMG NAME="' + this.name + '" SRC="' + this.imgOff.src + '" WIDTH=' + this.imgOff.width + ' HEIGHT=' + this.imgOff.height + ' BORDER=0 ALT="">');
}

// CREATE IMAGE
function loadImage (img, imgDir)
{
	//imgDir = "<?php echo $imUrl;?>images/"
	imgObject = new Image()
	imgObject.src = imgDir + img;
	return imgObject;
}

// CREATE IMAGE FROM ARRAY
function loadRandImage (imgDir, arr, i, x, y)
{
	//imgDir = "<?php echo $imUrl;?>images/";
	imgObject = new Image(x, y)
	imgObject.src = imgDir + arr[i];
	return imgObject;
}

// RETURNS RANDOM NUMBER
function getRandNum (len)
{
	randNum = parseInt(Math.random() * len);
	if (isNaN(randNum))
		randNum = 0;
	return randNum;
}

