//Specify gap between each image (use HTML):
var imagegap="<span class=\"newsticker\">&nbsp;&nbsp;&nbsp;+++&nbsp;&nbsp;&nbsp;</span>";
var newsticker = document.getElementById('newsticker');

//Specify pixels gap between each slideshow rotation (use integer):
var slidespeed = speed;
var sliderwidth = parseInt(newsticker.getAttribute("width"));
var slideshowgap= sliderwidth*2.0;
var copyspeed = slidespeed;

var htmlCode = "";


if (news.length > 0)
{
	news = '<nobr>' + news.join(imagegap) + '</nobr>';

	var actualwidth='', actualheight='';
	var cross_slide, ns_slide;

	if (window.addEventListener){ 
		window.addEventListener('load', fillup, false); 
	}
	else if (window.attachEvent) {
		var r = window.attachEvent("onload", fillup); 
	}
	else { 
		window.onload = fillup;
	} 

	var lefttime = null;

	htmlCode = '<div>';
	htmlCode = htmlCode +   '<span style=\"font-size:'+fontsize+';">';
	htmlCode = htmlCode +   '<div id=\"tickercontainer1\" style=\"position:relative; width:'+sliderwidth+'; height:1px; overflow:hidden\">' + 
							'<div id=\"tickercontainer2\" style=\"position:absolute; width:'+sliderwidth+'; height:1px;\" onMouseover=\"copyspeed=0;\" onMouseout=\"copyspeed=slidespeed;\">' +
							'<div id=\"test2\" style=\"position:absolute; left:'+sliderwidth+'px; top:0px\"></div>' +
							'<div id=\"test3\" style=\"position:absolute; left:-1000px; top:0px\"></div>' +
							'</div></div>' +
							'</span></div><span id=\"temp\" style=\"visibility:hidden;position:absolute;top:-100px;left:-3000px;font-size:'+fontsize+';color:'+fontcolor+'\">'+news+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';

	newsticker.innerHTML = htmlCode;
}	 

function fillup(){
		cross_slide = document.getElementById? document.getElementById("test2") : document.all.test2;
		cross_slide2 = document.getElementById? document.getElementById("test3") : document.all.test3;
		cross_slide.innerHTML = cross_slide2.innerHTML = news;

		actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth;
		actualheight=document.all? cross_slide.offsetHeight : document.getElementById("temp").offsetHeight;
		cross_slide2.style.left=actualwidth+slideshowgap+"px";
		
		
		ticker_container_1=document.getElementById? document.getElementById("tickercontainer1") : document.all.tickercontainer1;
		ticker_container_2=document.getElementById? document.getElementById("tickercontainer2") : document.all.tickercontainer2;
		if (document.all) {
			ticker_container_1.style.height = parseInt(actualheight) + 2 + 'px';
			ticker_container_2.style.height = parseInt(actualheight) + 2 +'px';
		}
		else {
			document.getElementById('tickercontainer1').style.height = parseInt(actualheight) + 2 + 'px';
			document.getElementById('tickercontainer2').style.height = parseInt(actualheight) + 2 + 'px';
		}

	slideleft();
}

function slideleft(){
	if (lefttime != null) {
		clearTimeout(lefttime);
		lefttime = null;
	}

		if (parseInt(cross_slide.style.left) > (actualwidth*(-1)+8))
			cross_slide.style.left = parseInt(cross_slide.style.left) - copyspeed+"px";
		else
			cross_slide.style.left = parseInt(cross_slide2.style.left) + actualwidth + parseInt(slideshowgap/2) +"px";
		// cross_slide.style.left = parseInt(cross_slide2.style.left) + actualwidth + slideshowgap +"px";

		if (parseInt(cross_slide2.style.left) > (actualwidth*(-1)+8))
			cross_slide2.style.left = parseInt(cross_slide2.style.left) - copyspeed+"px";
		else
			cross_slide2.style.left = parseInt(cross_slide.style.left) + actualwidth + parseInt(slideshowgap/2) +"px";
		// cross_slide2.style.left = parseInt(cross_slide.style.left) + actualwidth + slideshowgap +"px";

	lefttime = setTimeout("slideleft()",30);
}