function wmxImageRotator()
{
	//Private variables
	var _image = null;
	var _colorname = null;
	var _imageCount = 0;
	var _imageIndex = 0;
	var _initialized = false;
	var _timer = 0;
	var _cmxElement = new cmxElement();
	var _cmxColorElement = new cmxElement();	
	var _width = 820;
	var _height = 625;
	var _pageNumber = 0;
	var _imagesPerPage = 0;

	//Public properties
	this.clientId = ''
	this.effect = "progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)";
	this.imageArray = new Array();
	this.colorArray = new Array();
	this.colorName = "_ColorRotator";
	this.imageName = '_ImageRotator';
	this.interval = 3000;

	//Public functions
	this.initialize = function()
	{
		_imageCount = this.imageArray.length;
		_image = _cmxElement.getElementById(this.clientId + this.imageName);
		_colorname = _cmxColorElement.getElementById(this.clientId + this.colorName);
		
		if (_image != null && this.imageArray.length == 0)
		{
			_image.onclick = function()
				{
					var popUp = new wmxPopupWindow();
					popUp.name = "imageRotator";
					popUp.url = _image.src;
					popUp.width = GetNaturalWidth(_image) + 40;
					popUp.height = GetNaturalHeight(_image) + 40;
					popUp.open();
				};
		}
		else
		{
			if (cmxbrowser.ie && _image != null)
				_image.style.filter = this.effect;

			_timer = window.setInterval(this.clientId + ".animate()", this.interval);
		}
	};

	this.start = function()
	{
		if (!_initialized)
		{
			this.initialize();
			_initialized = true;
		}
	};
	
	this.animate = function()
	{
		window.clearInterval(_timer);

		if (_image != null)
		{
			var index = _imageIndex;
			if (cmxbrowser.ie)
				_image.filters[0].apply();
			
			_imageIndex++;
			
			if ((_pageNumber > 0) && (_imagesPerPage > 0))
			{
				if ((_imageIndex > (_imagesPerPage * _pageNumber)-1)
					|| (_imageIndex < (_imagesPerPage * (_pageNumber-1)))
					|| (_imageIndex > _imageCount-1))
				{
					_imageIndex = (_imagesPerPage * (_pageNumber-1));
				}
			}
			else if (_imageIndex > _imageCount-1)
			{
				_imageIndex = 0;
			}

			var color = '';
			if(_colorname != null)
			{
				color = new String(this.colorArray[index]);					
				_colorname.innerText = color;
			}
			
			var img = new String(this.imageArray[index]);
			var imgSplit = new Array();

			imgSplit = img.split('|');

			_image.src = imgSplit[0];

			if (imgSplit[1] != undefined && imgSplit[1] != '')
			{
				_image.onclick = function()
					{
						var popUp = new wmxPopupWindow();
						popUp.name = "imageRotator";
						popUp.url = _image.src;
						popUp.width = GetNaturalWidth(_image) + 40;
						popUp.height = GetNaturalHeight(_image) + 40;
						popUp.open();
					};
			}
			
			if (cmxbrowser.ie)
				_image.filters[0].play();

			_timer = window.setInterval(this.clientId + ".animate()", this.interval);
		}
	};

	this.changeImage = function(index)
	{
		if (index >= 0 && _imageCount > 1)
		{
			_imageIndex = index;
			window.clearInterval(_timer);
			this.animate();
		}
		
	};
	this.getWidth = function(width)
	{
		if(width > 0)
		{
			_width = width;
		}
	};
	this.getHeight = function(height)
	{
		if(height > 0)
		{
			_height = height;
		}
	};
	this.setPageInfo = function(currentPage, imageCount)
	{
		_pageNumber = currentPage;
		_imagesPerPage = imageCount;
	};

}

function wmxImageRotatorSaved()
{
	//Private variables
	var _image = null;
	var _colorname = null;
	var _imageCount = 0;
	var _imageIndex = 0;
	var _initialized = false;
	var _timer = 0;
	var _cmxElement = new cmxElement();
	var _cmxColorElement = new cmxElement();	

	//Public properties
	this.clientId = ''
	this.effect = "progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)";
	this.imageArray = new Array();
	this.colorArray = new Array();
	this.colorName = "_ColorRotator";
	this.imageName = '_ImageRotator';
	this.interval = 3000;

	//Public functions
	this.initialize = function()
	{
		_imageCount = this.imageArray.length;		
		_image = _cmxElement.getElementById(this.clientId + this.imageName);
		_colorname = _cmxColorElement.getElementById(this.clientId + this.colorName);
		

		if (_image != null && this.imageArray.length == 0)
		{
			_image.onclick = function()
			{
				var popUp = new wmxPopupWindow();
				popUp.width = GetNaturalWidth(_image) + 40;
				popUp.height = GetNaturalHeight(_image) + 40;
				popUp.name = "imageRotator";
				popUp.url = _image.src;
				popUp.open();
			};
		}
		else
		{
			if (cmxbrowser.ie && _image != null)
				_image.style.filter = this.effect;

			_timer = window.setInterval(this.clientId + ".animate()", this.interval);
		}
	};

	this.start = function()
	{
		if (!_initialized)
		{
			this.initialize();
			_initialized = true;
		}
	};
	
	this.animate = function()
	{
		window.clearInterval(_timer);

		if (_image != null)
		{
			var index = _imageIndex;
			if (cmxbrowser.ie)
				_image.filters[0].apply();			
			
			_imageIndex++;
			
			if (_imageIndex >= _imageCount-1)
			{
				_imageIndex = 0;
			}							
				
			var color = '';
			if(_colorname != null)
			{
				color = new String(this.colorArray[index]);					
				_colorname.innerText = color;
			}
			
			
			var img = new String(this.imageArray[index]);
			var imgSplit = new Array();

			imgSplit = img.split('|');

			_image.src = imgSplit[0];
			
			if (imgSplit[1] != undefined && imgSplit[1] != '')
				_image.onclick = function()
				{
					var popUp = new wmxPopupWindow();
					popUp.width = GetNaturalWidth(_image) + 40;
					popUp.height = GetNaturalHeight(_image) + 40;
					popUp.name = "imageRotator";
					popUp.url = imgSplit[1];
					popUp.open();
				};			

			if (cmxbrowser.ie)
				_image.filters[0].play();

			_timer = window.setInterval(this.clientId + ".animate()", this.interval);
		}
	};

	this.changeImage = function(index)
	{
		if (index >= 0)
		{
			_imageIndex = index;
			window.clearInterval(_timer);
			this.animate();
		}
		
	};
}

function GetNaturalHeight(image)
{
	if (image.naturalHeight)
	{
		return image.naturalHeight;
	}
	else
	{
		var tempImage = new Image();
		tempImage.src = image.src;
		return tempImage.height;
	}
}

function GetNaturalWidth(image)
{
	if (image.naturalWidth)
	{
		return image.naturalWidth;
	}
	else
	{
		var tempImage = new Image();
		tempImage.src = image.src;
		return tempImage.width;
	}
}