function RotateInformatiion () {
	var instance = {
		id             : "",
		list           : new Array(),
		fadeTimer      : 50,
		rotateTimer    : 3000,
		fadeInterval   : 0,
		scrollTextInterval : 0,
		mouseTimeout   : 0,
		fadeTimeout    : 0,
		width          : 0,
		height         : 0,
		current        : null,
		old            : null,
		xml            : null,
		parent         : null,
		element        : null,
		contentDOM     : null,
		panelDOM       : null,
		idle           : false,
		
		setTimer : function (p) {
			this.rotateTimer = p;
		},
		
		getObjByIndex : function (pIndex) {
			var i=0;
			var obj = null;
			for(id in this.list) {
				obj = this.list[id];
				if(pIndex == i)
					return obj;
				i++;
			}

			return null;
		},
		
		getListLength : function () {
			var i=0;
			for(id in this.list)
				i++;

			return i;
		},
		
		reset : function (pId) {
			for(id in this.list) {
				obj = this.list[id];
				if(pId == id)
					continue;
				
				obj.imageDOM.style.opacity = "";
				obj.imageDOM.style.filter = "";
				obj.textDOM.style.bottom = (obj.textDOM.offsetHeight*-1)+"px";
			}
			
		},
		
		controlIdle : function (p) {
			this.idle = p;
		},
		
		changeInfo : function (pId) {
			if(this.current && (pId == this.current.id))
				return;
				
			this.updateState(this.list[pId]);
			//this.stopFade();
			this.startFade();
			this.startScrollText('ScrollUp');			
		},
		
		updateState : function (pObj) {
			this.current = pObj;
			this.current.blockDOM.style.zIndex = 1;
			this.current.buttonDOM.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "buttons button_hl");
			if(this.old)
				this.old.buttonDOM.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "buttons");
		},
		
		loadNext : function () {
			if(this.idle)
				return;
				
			var obj = this.current;
			if(obj == null)
				obj = this.getObjByIndex(0);
			else
				obj = this.current.next;
			
			this.changeInfo(obj.id);
		},		
		
		start : function () {
			this.loadNext();
		},
		
		stop : function () {
				
		},
		
		stopAll : function () {
			this.stopFade();
			this.stopScrollText();
		},
		
		startFade : function () {
			if(this.fadeInterval == 0)
				this.fadeInterval = setInterval(function(){instance.updateFade()}, this.fadeTimer);
		},
		
		stopFade : function () {
			clearInterval(this.fadeInterval);
			this.fadeInterval = 0;
		},
		
		startScrollText : function (pDir) {
			var scrollTextTimer = 1;
			if(this.scrollTextInterval == 0)
				this.scrollTextInterval = setInterval(function(){eval('instance.update'+pDir+'Text()')}, scrollTextTimer);
		},
		
		stopScrollText : function () {
			clearInterval(this.scrollTextInterval);
			this.scrollTextInterval = 0;
		},		
				
		updateScrollUpText : function () {
			var c = parseInt(this.current.textDOM.style.bottom, 10);
			if(c >= 0) {
				this.stopScrollText();
				this.current.textDOM.style.bottom = "0px";
				return;
			}
			var calc = c += 3;
			this.current.textDOM.style.bottom = calc+'px';
		},
		
		updateScrollDownText : function () {
			if(this.getListLength() == 1) {
				this.stopAll();
				return;
			}		
			
			if(this.idle) {
				this.stopAll();
				this.startScrollText('ScrollUp');
				return;
			}			
			var c = parseInt(this.current.textDOM.style.bottom, 10);
			if(c <= (this.current.textDOM.offsetHeight*-1)) {
				this.stopScrollText();
				this.current.textDOM.style.bottom = (this.current.textDOM.offsetHeight*-1)+"px";

				this.loadNext();
				return;
			}
			
			var calc = c -= 3;	
			this.current.textDOM.style.bottom = calc+"px";
		},
		
		updateFade : function () {
			var opacity = Number(this.current.imageDOM.style.opacity);
			if(isNaN(opacity))
				opacity = 0;
				
			this.current.imageDOM.style.opacity = (opacity+0.2);
			this.current.imageDOM.style.filter = "alpha(Opacity="+((opacity+0.2)*100)+")";
			
			if(this.current.blockDOM.style.display == 'none')
				this.current.blockDOM.style.display = '';
				
			if(opacity >= 1) {
				this.stopFade();
				this.current.imageDOM.style.opacity = "";
				this.current.imageDOM.style.filter = "";
				this.current.blockDOM.style.zIndex = "";
				if(this.old)
					this.old.blockDOM.style.display = 'none';
					
				this.old = this.current;
				clearTimeout(this.fadeTimeout);
				this.fadeTimeout = 0;				
				this.fadeTimeout = setTimeout(function(){instance.startScrollText('ScrollDown')}, this.rotateTimer);
			}
		},		
		
		toHTML : function () {
			this.id = mKey(10, 'ALNUMUC');
			
			var html = '';
			html += '<div class="content" id="RotationInfo('+this.id+')(content)">';
			html += '</div>';
			html += '<div class="panel" id="RotationInfo('+this.id+')(panel)"></div>';
			
            var element = document.createElement("div");
            element.extend = this;
            element.setAttribute("id", "RotationInfo("+this.id+")");
			element.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "RotationInfo");
			element.style.width = this.width+"px";
			element.style.height = this.height+"px";
			element.style.overflow = "hidden";
            element.innerHTML = html;
            
            attachObjectInDOMTree(element, this);
			
			return element;
		},

		mouseOutControl : function () {
			this.controlIdle(false);
			clearTimeout(this.mouseTimeout);
			this.mouseTimeout = 0;
			this.mouseTimeout = setTimeout(function () {instance.startScrollText('ScrollDown')}, instance.rotateTimer);
		},
				
		load : function (pXML, pParent, pWidth, pHeight) {
			this.xml    = pXML;
			this.parent = $(pParent);
			this.width  = pWidth;
			this.height = pHeight;
			if(!this.parent)
				return;
			
			this.parent.innerHTML = '';
			this.parent.appendChild(this.toHTML());
			
			this.element    = $("RotationInfo("+this.id+")");
			this.contentDOM = $("RotationInfo("+this.id+")(content)");
			this.panelDOM   = $("RotationInfo("+this.id+")(panel)");
			
			this.contentDOM.style.position = 'relative';
			this.contentDOM.style.overflow = 'hidden';
			this.contentDOM.style.height = (this.element.offsetHeight - this.panelDOM.offsetHeight)+'px';
			if(this.getListLength > 0) {
				this.contentDOM.onmouseover = function () { instance.controlIdle(true) };
				this.contentDOM.onmouseout = function () { instance.mouseOutControl() };
			}
			this.request();
		},
		
		request : function () {
			Ajax.loadXMLDoc(this.xml, '', 'GET', {fn : instance.response, params : this}, true, null);
		},
		
		response : function (pXML, pText, pStatus, pSelf) {
			//alert(pXML)
			//alert(pText)
			//alert(pStatus)
			if(!pXML || pStatus != 200)
				return;
			
			var responses = pXML.getElementsByTagName('response');
			var y = 1;
			for(var i=0; i<=responses.length; i++) {
				var child = responses[i];
				if(child) {
					var image = child.getElementsByTagName('image')[0];
					var s_image = {
						src    : image.getAttribute('src'),
						width  : image.getAttribute('width'),
						height : image.getAttribute('height')
					}
					
					var link = child.getElementsByTagName('link')[0];
					var text = child.getElementsByTagName('text')[0];
					var id   = child.getAttribute('id');
					
					var struct = {
						id    : id, 
						delay : child.getAttribute('delay'),
						image : s_image,
						link  : link.getAttribute('href'),
						text  : text.firstChild.data
					}
					
					pSelf.list[id] = struct;
					pSelf.attachDOM(id, y++);
				}

				if(typeof tempId !== 'undefined') {
					if(i == responses.length)
						pSelf.list[id].next = pSelf.getObjByIndex(0);
					else
						pSelf.list[tempId].next = pSelf.list[id];
				}
				var tempId = id;		
				
				image   = null;
				s_image = null;
				struct  = null;
				link    = null;
				text    = null;
			}
			
			if(responses.length > 0)
				pSelf.start();
		},

		attachDOM : function (pId, pI) {
			var info = this.list[pId];
			var blockDOM   = document.createElement('div');
			var imageDOM   = document.createElement('div');
			var textDOM    = document.createElement('div');
			var textbgDOM  = document.createElement('div');
			var buttonDOM  = document.createElement('div');
			
			
			blockDOM.setAttribute('id', "RotationInfo('+this.id+')(block)("+info.id+")");
			blockDOM.style.display = 'none';
			blockDOM.style.position = 'absolute';
			
			blockDOM.style.height = (parseInt(this.contentDOM.style.height, 10)+(isBrowserVersion('msie') ? 1 : 0))+"px";
			blockDOM.style.width = '100%';
			
			imageDOM.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "image");
			imageDOM.style.backgroundImage = 'url('+info.image.src+')';
			buttonDOM.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "buttons");
			
			buttonDOM.innerHTML = pI;
			buttonDOM.onclick = function () {
				if(instance.fadeInterval > 0 || instance.scrollTextInterval > 0)
					return;

				instance.stopAll();
				instance.reset(info.id);
				instance.changeInfo(info.id);
			};

			this.panelDOM.appendChild(buttonDOM);

			textDOM.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "text");
			textbgDOM.setAttribute(isBrowserVersion('msie') ? 'className' : 'class', "textbg");
			var text = info.text;
			if(info.link != "")
				text = '<a href="'+info.link+'">'+text+'</a>';
			
			textDOM.innerHTML = '<div class="textphrase" style="position:absolute;">'+text+'</div>';
			
			imageDOM.style.width = '100%';
			imageDOM.style.height = this.contentDOM.style.height;
			textbgDOM.style.width = '100%';
			textDOM.style.width = '100%';
			textDOM.style.overflow = 'hidden';
			textDOM.style.height = (this.contentDOM.offsetHeight / 4)+'px';
			textbgDOM.style.height = textDOM.style.height;
			textDOM.style.position = 'absolute';
			
			textDOM.style.bottom = (parseInt(textDOM.style.height, 10)*-1)+'px';
			textDOM.appendChild(textbgDOM);
			blockDOM.appendChild(imageDOM);
			blockDOM.appendChild(textDOM);
			this.contentDOM.appendChild(blockDOM);
			
			info.blockDOM  = blockDOM;
			info.imageDOM  = imageDOM;
			info.textDOM   = textDOM;
			info.buttonDOM = buttonDOM;			
			
			blockDOM = null;
			imageDOM = null;
			textDOM  = null;			
		}
	};

	return instance;
}
