function nsNewsSlider(id, width, height, title, titleOnClick, cycle, pause, displayMoreButton, moreText, align, path, skin)
{
	var debug = false;
	var CSS = new Object(
		{
			control:String('ns_slidecontrol'),
			linkOn:String('ns_slidelink_on'),
			linkOff:String('ns_slidelink_off'),
			linkSelected:String('ns_slidelink_selected'),
			titleOn:String('ns_slidetitle_on'),
			titleOff:String('ns_slidetitle_off'),
			moreOn:String('ns_slidemore_on'),
			moreOff:String('ns_slidemore_off'),
			bodyOn:String('ns_slidebody_on'),
			bodyOff:String('ns_slidebody_off'),
			content:String('ns_slidcontent')
		});
		
		
	if (id != undefined)
	{
		this.id = id;
		this.width = (width != undefined) ? width : '400px';
		this.height = (height != undefined) ? height : '100px';
		this.title = (title != undefined) ? title : '';
		this.titleOnClick = (titleOnClick != undefined) ? titleOnClick : '';
		this.cycle = (cycle != undefined) ? Boolean(cycle) : true;
		this.pause = (pause != undefined) ? pause : 5000;
		this.displayMoreButton = (displayMoreButton != undefined) ? Boolean(displayMoreButton) : true;
		this.moreText = (moreText != undefined) ? String(moreText) : '...';
		this.align = (align != undefined && (align=='left' || align=='center' || align=='right')) ? String(align) : 'left';
		this.path = (path != undefined) ? path : 'nsNewsSlider/skins/';
		this.skin = (skin != undefined) ? skin : 'default';
		
		this.selected_index = 0;
		this.slides = new Array();
		
		this.add = add;
		this.getControl = getControl;
		this.render = render;
		this.setSelectedSlide = setSelectedSlide;
		this.getSelectedSlideId = getSelectedSlideId;
		this.changeSlide = changeSlide;
		this.stop = stop;
		this.start = start;
		
		if (debug)
		{
			var msg = '';
			msg += 'TabControl.id = ' + this.id + '\r\n';
			msg += 'TabControl.width = ' + this.width + '\r\n';
			msg += 'TabControl.height = ' + this.height + '\r\n';
			msg += 'TabControl.title = ' + this.title + '\r\n';
			msg += 'TabControl.titleOnClick = ' + this.titleOnClick + '\r\n';
			msg += 'TabControl.cycle = ' + this.cycle + '\r\n';
			msg += 'TabControl.pause = ' + this.pause + '\r\n';
			msg += 'TabControl.displayMoreButton = ' + this.displayMoreButton + '\r\n';
			msg += 'TabControl.moreText = ' + this.moreText + '\r\n';
			msg += 'TabControl.align = ' + this.align + '\r\n';
			msg += 'TabControl.path = ' + this.path + '\r\n';
			msg += 'TabControl.skin = ' + this.skin + '\r\n';
			window.alert(msg)
		}
	}
	
	function getSelectedSlideId()
	{
		return (this.slides.length > 0) ? this.slides[this.selected_index].id : '';
	}
	
	function setSelectedSlide(id)
	{
		for (i=0 ; i<this.slides.length ; i++)
		{
			if (this.slides[i].id == id)
			{
				this.selected_index = i;
				this.render();
				break;
			}
		}
	}
	
	function changeSlide(num)
	{
		this.selected_index += Number(num);
		if (this.selected_index < 0)
		{
			this.selected_index = this.slides.length-1;
		}
		else if (this.selected_index >= this.slides.length)
		{
			this.selected_index = 0;
		}
		this.render();
	}
	
	function start()
	{
		this.stop();
		this.interval = window.setInterval(this.id + '.changeSlide(1)', this.pause);
	}
	function stop()
	{
		window.clearInterval(this.interval);
	}
	
	function render()
	{
		var slider = document.getElementById(this.id);
		slider.innerHTML = '';
		slider.appendChild(this.getControl());
		slider.innerHTML = slider.innerHTML;
	}
	
	function add(slide)
	{
		if (this.slides != null && typeof(this.slides) == 'object' && this.slides.constructor == Array)
		{
			this.slides.push(slide);
		}
	}
	
	function getControl()
	{
		var table = document.createElement('table');
		table.setAttribute('onSelectStart','return false;');
		table.setAttribute('class','tab_table');
		table.setAttribute('cellpadding', '0px');
		table.setAttribute('cellspacing', '0px');
		table.setAttribute('border', '0px');
		table.className = CSS.control;
		
		if (this.cycle)
		{
			var mouseover = this.id + '.stop();'
			var mouseout = this.id + '.start();'
			table.setAttribute('onmouseover', mouseover);
			table.setAttribute('onmouseout', mouseout);
		}
		
		var trLinks = document.createElement('tr');
		trLinks.setAttribute('height', '1px');
		
		var tdLinks = document.createElement('td');
		tdLinks.setAttribute('align', this.align);
		tdLinks.setAttribute('valign', 'top');
		tdLinks.appendChild(getLinkTable(this.id, this.slides, this.title, this.titleOnClick, this.selected_index, this.displayMoreButton, this.moreText));
		
		var trBody = document.createElement('tr');
		trBody.setAttribute('height', '*');
		
		var tdBody = document.createElement('td');
		tdBody.setAttribute('align', this.align);
		tdBody.setAttribute('valign', 'top');
		tdBody.style.padding = '0px 1px 1px 1px';
		tdBody.style.width = '100%';
		tdBody.appendChild(getSlideTable(this.id, this.width, this.height, this.slides[this.selected_index], this.cycle));
		
		trLinks.appendChild(tdLinks);
		trBody.appendChild(tdBody);
		table.appendChild(trLinks);
		table.appendChild(tdBody);
		
		if (debug)
		{
			window.prompt('code:',table.innerHTML);
		}
		return table;
	}
	
	function getLinkTable(id, arrSlides, strTitle, strTitleOnClick, numSelectedIndex, displayMoreButton, strMore)
	{
		var table = document.createElement('table');
		table.setAttribute('onSelectStart','return false;');
		table.setAttribute('class','tab_table');
		table.setAttribute('cellpadding', '1px');
		table.setAttribute('cellspacing', '3px');
		table.setAttribute('border', '0px');
		
		var tr = document.createElement('tr');
		
		if (strTitle != undefined && strTitle != '')
		{
			var td = document.createElement('td');
			td.setAttribute('align', 'left');
			td.setAttribute('valign', 'top');
			td.className = CSS.titleOff;
			var mouseover = 'this.className=\'' + CSS.titleOn + '\';';
			mouseover += id + '.stop();'
			var mouseout = 'this.className=\'' + CSS.titleOff + '\';';
			mouseover += id + '.start();'
			td.setAttribute('onmouseover', mouseover);
			td.setAttribute('onmouseout', mouseout);
			td.setAttribute('onClick', strTitleOnClick);
			
			td.innerHTML = strTitle;
			
			tr.appendChild(td);
		}
		
		if (arrSlides != undefined)
		{
			for (i=0 ; i<arrSlides.length ; i++)
			{
				var td = document.createElement('td');
				td.setAttribute('align', 'center');
				td.setAttribute('valign', 'middle');
				td.setAttribute('title',arrSlides[i].alt);
				
				var tableLink = document.createElement('table');
				tableLink.setAttribute('cellpadding', '0px');
				tableLink.setAttribute('cellspacing', '0px');
				tableLink.setAttribute('border', '0px');
				
				var trLink = document.createElement('tr');
				var tdLink = document.createElement('td');
				
				if (i == numSelectedIndex)
				{
					tdLink.className = CSS.linkSelected;
				}
				else
				{
					tdLink.className = CSS.linkOff;
					var mouseover = 'this.className=\'' + CSS.linkOn + '\';';
					mouseover += id + '.stop();'
					var mouseout = 'this.className=\'' + CSS.linkOff + '\';';
					mouseover += id + '.start();'
					var click = id + '.setSelectedSlide(\'' + arrSlides[i].id + '\');';
					tdLink.setAttribute('onMouseOver', mouseover);
					tdLink.setAttribute('onMouseOut', mouseout);
					tdLink.setAttribute('onClick', click);
				}
				
				tdLink.innerHTML = '&nbsp;';
				
				trLink.appendChild(tdLink);
				tableLink.appendChild(trLink);
				td.appendChild(tableLink);
				tr.appendChild(td);
			}
		}
		/*
		if (arrSlides != undefined)
		{
			for (i=0 ; i<arrSlides.length ; i++)
			{
				var td = document.createElement('td');
				td.setAttribute('align', 'left');
				td.setAttribute('valign', 'top');
				td.setAttribute('title',arrSlides[i].alt);
				
				if (i == numSelectedIndex)
				{
					td.className = CSS.linkSelected;
				}
				else
				{
					td.className = CSS.linkOff;
					var mouseover = 'this.className=\'' + CSS.linkOn + '\';';
					var mouseout = 'this.className=\'' + CSS.linkOff + '\';';
					var click = id + '.setSelectedSlide(\'' + arrSlides[i].id + '\');';
					td.setAttribute('onMouseOver', mouseover);
					td.setAttribute('onMouseOut', mouseout);
					td.setAttribute('onClick', click);
				}
				
				td.innerHTML = String(i+1);
				
				tr.appendChild(td);
			}
		}
		*/
		
		if (displayMoreButton && strMore != undefined && strMore != '')
		{
			var td = document.createElement('td');
			td.setAttribute('align', 'left');
			td.setAttribute('valign', 'top');
			td.className = CSS.moreOff;
			var mouseover = 'this.className=\'' + CSS.moreOn + '\';';
			mouseover += id + '.stop();'
			var mouseout = 'this.className=\'' + CSS.moreOff + '\';';
			mouseover += id + '.start();'
			td.setAttribute('onmouseover', mouseover);
			td.setAttribute('onmouseout', mouseout);
			td.setAttribute('title', 'More...');
			td.setAttribute('onClick', strTitleOnClick);
			
			td.innerHTML = strMore;
			
			tr.appendChild(td);
		}
		
		table.appendChild(tr);
		return table;
	}
	
	function getSlideTable(id, width, height, objSlide, cycle)
	{
		if (objSlide != undefined)
		{
			var table = document.createElement('table');
			table.setAttribute('cellpadding', '1px');
			table.setAttribute('cellspacing', '0px');
			table.setAttribute('border', '0px');
			table.setAttribute('width', width);
			table.setAttribute('height', height);
			
			var tr = document.createElement('tr');
			
			var td = document.createElement('td');
			td.setAttribute('align', 'left');
			td.setAttribute('valign', 'top');
			td.setAttribute('title', objSlide.alt);
			td.className = CSS.bodyOff;
			var mouseover = 'this.className=\'' + CSS.bodyOn + '\';';
			var mouseout = 'this.className=\'' + CSS.bodyOff + '\';';
			if (cycle)
			{
				mouseover += id + '.stop();'
				mouseout += id + '.start();'
			}
			td.setAttribute('onmouseover', mouseover);
			td.setAttribute('onmouseout', mouseout);
			td.setAttribute('onClick', objSlide.onclick);
			
			var tableContent = document.createElement('table');
			tableContent.setAttribute('cellpadding', '1px');
			tableContent.setAttribute('cellspacing', '0px');
			tableContent.setAttribute('border', '0px');
			tableContent.setAttribute('width', width);
			tableContent.setAttribute('height', height);
			
			var trContent = document.createElement('tr');
			
			var tdContent = document.createElement('td');
			tdContent.setAttribute('align', 'left');
			tdContent.setAttribute('valign', 'top');
			tdContent.setAttribute('title', objSlide.alt);
			tdContent.className = CSS.content;
			tdContent.innerHTML = objSlide.innerHTML;
			
			trContent.appendChild(tdContent);
			tableContent.appendChild(trContent);
			td.appendChild(tableContent);
			
			tr.appendChild(td);
			table.appendChild(tr);
			return table;
		}
		return false;
	}
}

function nsNewsSlide(id, innerHTML, onclick, alt)
{
	if (id != undefined)
	{
		this.id = id;
		this.innerHTML = (innerHTML != undefined) ? innerHTML : '';
		this.onclick = (onclick != undefined) ? onclick : '';
		this.alt = (alt != undefined) ? alt : '';
	}
}

