function wmxAutoScrollingSpecial()
{
	//Private variables
	var _actualHeight = '';
	var _actualWidth = '';
	var _element0 = null;
	var _element1 = null;
	var _element2 = null;
	var _initialized = false;
	var _tempSpeed = 0;
	var _timer = 0;
	var _currentPos = new Number(0);
	
	//Public properties
	this.content = '';
	this.height = '';
	this.name = '';
	this.gridHeight = 180;
	this.photoType = /\.jpg/i;
	this.gridWidth = 131;
	this.specialId = 0;
	this.speed = 1;
	this.width = '';

	//Public functions
	this.initialize = function()
	{
		var imageArray = this.content.split(this.photoType);
		var count = imageArray.length - 1;
		
		var code = "<table><tr><td>";
		code += "<div id='" + this.name + "_Special' class='ScrollingSpecialContainer' style='position:relative;overflow:hidden'>";
		code += "<div id='" + this.name + "_Element0' class='ScrollingSpecialElement' style='left:0;position:absolute;top:0;width:100%;z-index:3' onmouseover='" + this.name + ".stop()' onmouseout='" + this.name + ".start()'>";
		code += "<div id='" + this.name + "_Element1' class='ScrollingSpecialElement' style='left:0;z-index:2;overflow:hidden;position:absolute;'></div>";
		code += "<div id='" + this.name + "_Element2' class='ScrollingSpecialElement' style='left:0;z-index:1;overflow:hidden;position:absolute;'></div>";
		code += "</div></div>";
		code += "</td></tr></table>";
		$('Scrolling_' + this.specialId).innerHTML = code;

		_element0 = new cmxElement();
		_element0.setId(this.name + "_Element0");
		_element1 = new cmxElement();
		_element1.setId(this.name + "_Element1");
		_element2 = new cmxElement();
		_element2.setId(this.name + "_Element2");

		var containerHeight = 0;
		var containerWidth = 0;

		_actualHeight = this.gridHeight;
		_actualWidth = (this.gridWidth * count) - 5;
		containerHeight = this.gridHeight;
		this.content = "<nobr>" + this.content + "</nobr>";
		_element2.style.left = _actualWidth + "px";
		
		Special = new cmxElement();
		Special.setId(this.name + "_Special");
		Special.style.height = (this.height != '' ? this.height : containerHeight != 0 ? containerHeight : this.gridHeight) + "px";
		Special.style.width = this.width != '' ? this.width + "px" : containerWidth != 0 ? containerWidth + "px" : "100%";

		_element1.element.innerHTML = _element2.element.innerHTML = this.content;

		_tempSpeed = this.speed;
		_timer = setInterval(this.name + ".scroll();", 30);
	};

	this.scroll = function()
	{
		if (cmxbrowser.supportsDOM)
		{			
			_currentPos = (_currentPos - this.speed) % _actualWidth;
			_element0.style.left = _currentPos + "px";
		}
	};

	this.start = function()
	{
		if (!_initialized)
		{
			this.initialize();
			_initialized = true;
		}

		_actualWidth = _actualWidth + 5;

		this.speed = _tempSpeed;
	};

	this.stop = function()
	{
		_actualWidth = _actualWidth - 5;
	
		_tempSpeed = this.speed;
		this.speed = 0;
	};
}

function wmxClickScrollingSpecial()
{
	//Private variables
	var _count = 0;
	var _Left = null;
	var _element = null;
	var _Right = null;
	var _initialized = false;
	var _page = 1;
	
	//Public properties
	this.content = '';
	this.height = '';
	this.name = '';
	this.gridHeight = 195;
	this.photoType = /\.jpg/i;
	this.gridWidth = 135;
	this.specialId = 0;
	this.width = '';

	//Public functions
	this.initialize = function()
	{
		var imageArray = this.content.split(this.photoType);
		_count = imageArray.length - 1;
		
		var specialWidth = 0;
		specialWidth = $('Special_' + this.specialId).getWidth();
		specialWidth = specialWidth - 45;
		
		var code = "<table><tr><td>";
		code += "<div id='" + this.name + "_Special' class='ScrollingSpecialContainer' style='position:relative;overflow:hidden'>";
		code += "<div id='" + this.name + "_Left' class='ScrollingSpecialLeft' style='z-index:2;'></div>";
		code += "<div id='" + this.name + "_Wrapper' class='ScrollingSpecialWrapper' style='width:" + specialWidth + "px;'>";
		code += "<div id='" + this.name + "_Element' class='ScrollingSpecialElement' style='z-index:1'></div></div>";
		code += "<div id='" + this.name + "_Right' class='ScrollingSpecialRight' style='z-index:2;'></div>";
		code += "</div>";
		code += "</td></tr></table>";
		$('Scrolling_' + this.specialId).innerHTML = code;

		with (document)
		{
			write("<script type='text/javascript'>");
			write("$('" + this.name + "_Left').observe('click', function(event){");
			write(this.name + ".previous();");
			write("event.stop();");
			write("});");
			write("$('" + this.name + "_Right').observe('click', function(event){");
			write(this.name + ".next();");
			write("event.stop();");
			write("});");
			write("</script>");
		}		

		_element = new cmxElement();
		_element.setId(this.name + "_Element");

		var containerHeight = 0;
		var containerWidth = 0;
		containerHeight = this.gridHeight;

		Special = new cmxElement();
		Special.setId(this.name + "_Special");
		Special.style.height = (this.height != '' ? this.height : containerHeight != 0 ? containerHeight : this.gridHeight) + "px";
		Special.style.width = this.width != '' ? this.width + "px" : containerWidth != 0 ? containerWidth + "px" : "100%";
		
		this.changePage();
	};
	
	this.next = function()
	{
		if (_page < _count)
		{
			_page++;
		}
		else
		{
			_page = 1;
		}
		this.changePage();
	};
	
	this.previous = function()
	{
		if (_page > 1)
		{
			_page--;
		}
		else
		{
			_page = _count;
		}
		this.changePage();
	};
	
	this.addContent = function(firstItem, index)
	{
		if (firstItem == false)
		{
			this.content += '<div class="ScrollingDivider"></div>';
		}
		this.content += '<dd class="ClickItem">';
		this.content += $('Special_' + this.specialId + '_' + index).innerHTML;
		this.content += '</dd>';
	};
	
	this.changePage = function()
	{
		this.content = '<div class="ScrollingSpecial">';
		var firstItem = true;
		
		for (var index = _page; index <= _count; ++index) 
		{
			this.addContent(firstItem, index);
			firstItem = false;
		}
		for (var index = 1; index < _page; ++index) 
		{
			this.addContent(firstItem, index);
		}
		this.content += '</div>';
		_element.element.innerHTML = this.content;
	};
}
