	function HSMarquee(id, height, width, scrollAmount, scrollDelay, direction, behavior, html)	{
		this.id= id;
		this.scrollAmount= scrollAmount ? scrollAmount : 6;
		this.scrollDelay = scrollDelay ? scrollDelay : 85;
		this.direction = direction ? direction.toLowerCase() : 'left';
		this.behavior= behavior ? behavior.toLowerCase() : 'scroll';
		this.name= 'HSMarquee_' + (++HSMarquee._name);
		this.runId = null;
		this.html= html;

		if (typeof(height) == 'number'){
			this.height = height;
			this.heightUnit = 'px';
		}else if (typeof(height) == 'string'){
			this.height = parseInt('0' + height, 10);
			this.heightUnit = height.toLowerCase().replace(/^[0-9]+/, '');
		}else{
			this.height = 100;
			this.heightUnit = 'px';
		}

		if (typeof(width) == 'number'){
			this.width = width;
			this.widthUnit = 'px';
		}else if (typeof(width) == 'string'){
			this.width = parseInt('0' + width, 10);
			this.widthUnit = width.toLowerCase().replace(/^[0-9]+/, '');
		}else{
			this.width = 100;
			this.widthUnit = 'px';
		}

		// HSMarquee UI events
		this.onmouseover = null;
		this.onmouseout= null;
		this.onclick = null;

		// HSMarquee state events
		this.onstart = null;
		this.onbounce= null;

		var markup = '';

		if (document.layers){
			markup += '<ilayer id="' + this.id + 'container" name="' + this.id + 'container" height="' + height + '" width="' + width + '"clip="' + width + ', ' + height + '">';
			markup += '<\/ilayer>';
		}else{
			var isHorizontal = ('up,down'.indexOf(this.direction) == -1);
			markup += '<div id="' + this.id + 'container" name="' + this.id + 'container" style="overflow: hidden; ';
			if (this.heightUnit != '%')
				markup += 'height: ' + this.height + this.heightUnit + '; ';

			if (this.widthUnit != '%')
				markup += 'width: ' + this.width + this.widthUnit + '; ';

			markup += '">';
			markup += '<\/div>';
		}
		document.write(markup);

		window[this.name] = this;
	};

	HSMarquee._name = -1;

	HSMarquee.prototype.start = function (){
		var markup = '';

		this.stop();

		if (!this.dirsign){
			if (document.getElementById || document.all){
				var isHorizontal = ('up,down'.indexOf(this.direction) == -1);
				if (document.getElementById)
					this.containerDiv = document.getElementById(this.id + 'container');
				else
					this.containerDiv = document.all[this.id + 'container'];

				markup += '<div id="' + this.id + '" name="' + this.id + '" style="position:relative; visibility: hidden;';
				if (!document.all && isHorizontal)
					markup += 'white-space:nowrap;';

				markup += '" ';
				markup += 'onmouseover="HSMarqueeDispatchUIEvent(event, \'' + this.name + '\', \'mouseover\')" ';
				markup += 'onmouseout="HSMarqueeDispatchUIEvent(event, \'' + this.name + '\', \'mouseout\')" ';
				markup += 'onclick="HSMarqueeDispatchUIEvent(event, \'' + this.name + '\', \'click\')" ';
				markup += '>';
				if (document.all && isHorizontal)
					markup += '<nobr>';

				markup += this.html;
				if (document.all && isHorizontal)
					markup += '<\/nobr>';

				markup += '<\/div>';

				this.containerDiv.innerHTML = markup;
				if (document.getElementById)
					this.div= document.getElementById(this.id);
				else
					this.div= document.all[this.id];

				this.styleObj = this.div.style;
				var parentNode= null;
				if (this.containerDiv.parentNode)
					parentNode = this.containerDiv.parentNode;
				else if (this.containerDiv.parentElement)
					parentNode = this.containerDiv.parentElement;

				if (this.heightUnit == '%' && parentNode && typeof(parentNode.offsetHeight) == 'number')
					this.containerDiv.style.height = parentNode.offsetHeight * (this.height/100) + 'px';

				if (this.widthUnit == '%' && parentNode && typeof(parentNode.offsetWidth) == 'number')
					this.containerDiv.style.width = parentNode.offsetWidth * (this.width/100) + 'px';
			}else if (document.layers){
				this.containerDiv = document.layers[this.id + 'container'];
				markup = '';
				markup += '<layer id="' + this.id + '" name="' + this.id + '" top="0" left="0" ';
				markup += 'onmouseover="HSMarqueeDispatchUIEvent(event, \'' + this.name + '\', \'mouseover\')" ';
				markup += 'onmouseout="HSMarqueeDispatchUIEvent(event, \'' + this.name + '\', \'mouseout\')" ';
				markup += 'onclick="HSMarqueeDispatchUIEvent(event, \'' + this.name + '\', \'click\')" ';
				markup += '>';
				if ('left,right'.indexOf(this.direction) != -1)
					markup += '<nobr>';

				markup += this.html;
				if ('left,right'.indexOf(this.direction) != -1)
					markup += '<\/nobr>';

				markup += '<\/layer>';
				this.containerDiv.document.write(markup);
				this.containerDiv.document.close();
				this.div= this.containerDiv.document.layers[this.id];
				this.styleObj = this.div;
			}

			// Start must not run until the page load event has fired
			// due to Internet Explorer not setting the height and width of 
			// the dynamically written content until then
			switch (this.direction){
				case 'down':
					this.dirsign = 1;
					this.startAt = this.styleObj.top = -1 * this._getInnerSize('height');
					this.stopAt= this.height;
					break;
				case 'up':
					this.dirsign = -1;
					this.startAt = this.styleObj.top = this.height;
					this.stopAt= -this._getInnerSize('height');
					break;
				case 'right':
					this.dirsign = 1;
					this.startAt = this.styleObj.left = -1 *this._getInnerSize('width');
					this.stopAt= this.width;
					break;
				case 'left':
				default:
					this.dirsign = -1;
					this.startAt = this.width
					this.stopAt= -this._getInnerSize('width');
					break;
			}
			this.newPosition= this.startAt;
			this.styleObj.visibility = 'visible'; 
		}

		this.newPosition += this.dirsign * this.scrollAmount;

		if ( (this.dirsign == 1&& this.newPosition > this.stopAt) ||
		 (this.dirsign == -1 && this.newPosition < this.stopAt) ){
			if (this.behavior == 'alternate'){
				if (this.onbounce){
					// fire bounce when alternate changes directions
					this.onbounce();
				}
				this.dirsign = -1 * this.dirsign;
				var temp = this.stopAt;
				this.stopAt= this.startAt;
				this.startAt = temp;
			}else{
				// fire start when position is a start
				if (this.onstart)
					this.onstart();

				this.newPosition = this.startAt;
			}
		}

		switch(this.direction){
			case 'up': 
			case 'down':
				this.styleObj.top = this.newPosition;
				break;
			case 'left': 
			case 'right':
			default:
				this.styleObj.left = this.newPosition;
				break;
		}

		this.runId = setTimeout(this.name + '.start()', this.scrollDelay);
	};

	HSMarquee.prototype.stop = function (){
		if (this.runId)
			clearTimeout(this.runId);

		this.runId = null;
	};

	HSMarquee.prototype.setInnerHTML = function (html){
		if (typeof(this.div.innerHTML) != 'string')
		return;

		var running = false;
		if (this.runId){
			running = true;
			this.stop();
			this.dirsign = null;
		}
		this.html = this.div.innerHTML = html;
		if (running)
			this.start();
	};

	HSMarquee.prototype._getInnerSize = function (propName){
		var val = 0;

		if (document.layers){
			// navigator 4
			val = this.styleObj.document[propName];
		}else if (typeof(this.styleObj[propName]) == 'number'){
			// opera
			// bug in Opera 6 width/offsetWidth. Use clientWidth
			if (propName == 'width' && typeof(this.div.clientWidth) == 'number')
				val = this.div.clientWidth;
			else
				val =this.styleObj[propName];
		}else{
			//mozilla and IE
			switch (propName){
				case 'height':
					if (typeof(this.div.offsetHeight) == 'number')
						 val =this.div.offsetHeight;

					if (val == 0)
						 val =this.height;

					break;
				case 'width':
					if (typeof(this.div.offsetWidth) == 'number')
						val = this.div.offsetWidth;

					if (val == 0)
						val =this.width;

					break;
			}
		}
		return val;
	};

	HSMarqueeDispatchUIEvent = function (event, marqueeName, eventName){
		var marquee = window[marqueeName];
		var eventAttr = 'on' + eventName;
		if (!marquee)
			return false;

		if (!event && window.event)
			event = window.event;

		switch (eventName){
			case 'mouseover':
				marquee.stop();
				break;
			case 'mouseout':
				marquee.start();
				break;
			case 'click':
				if (marquee[eventAttr])
					return marquee['on' + eventName](event);
		}

		return false;
	};