ns4Text = "No Newsticker on Netscape 4";  // Alternative text to display in Netscape 4.

ns4URL = "#";            // URL of link in NS4.

ns4Target = "_top";     



//Don't forget to use String and "px" for all coordinates to make it work on xhtml strict page

//Browser Sniffer

var dmnt_isIE = (document.getElementById && document.all) ? true : false;

var dmnt_isNS4 = (document.layers) ? true : false;

var dmnt_isNS6 = (document.getElementById && !document.all) ? true : false;

var dmnt_isLoaded = false;



// Build the objScroll and place it on the page

function buildScroller() {

	//Create element in which the Ticker is placed

	tickerspace = '<div name="tickerspace" id="tickerspace" style="position:relative"></div>';

	document.writeln(tickerspace);

}



function loadScroller(){

	if(dmnt_isNS4){

		//Only show Message that it does not work on NS 4

		objScroll = '<table border="0" cellpadding="0" cellspacing="0" width="' + objScrollWidth + '" bgcolor="' + borderColour + '"><tr><td>'

		objScroll += '<table border="0" cellpadding="0" cellspacing="0" width="100%" height="' + objScrollHeight + '" bgcolor="' + backColour + '"><tr><td align="center" nowrap><p class="dmnt_par" style="text-align:' + textAlignment + ';">';

		

//		if(ns4URL.toLowerCase() != "none"){

//			objScroll += '<a href="' + ns4URL + '" class="' + link_cssClass + '" target="' + ns4Target + '">' + ns4Text + '</a>';

//		}


		if(ns4URL.toLowerCase() != "none"){

			objScroll += ns4Text;

		}

		else{

			objScroll += ns4Text;

		} 

		objScroll += '</p></td></tr></table></td></tr></table>'   

	}

	else{

		//Works if Browser detected is not NS 4

		objScroll = '<table border="0" cellpadding="0" cellspacing="0" style=" width:' + objScrollWidth + 'px;height:' + objScrollHeight + 'px;border:' + borderWidth + 'px solid ' + borderColour + ';background-color:' + backColour + '; background-image:url(' + bg_image + ')">';

		objScroll += '<tr valign="middle"><td><div id="tickerdiv" style="';

		

		if(orientation.toLowerCase() == "vertical"){

			objScroll += 'height:' + objScrollHeight + 'px;';

		}

	

		objScroll += 'width:' + objScrollWidth + 'px; position:relative; background-color:' + backColour + '; background-image:url(' + bg_image + '); overflow:hidden">';

		objScroll += '<div id="div1" style="position:relative; left:0px; margin-left:-20px; z-index:1">';

		objScroll += '<table border="0" name="table" id="ticker_table"';

		

		if(orientation.toLowerCase() == "vertical"){

			objScroll += 'style="width:' + objScrollWidth + 'px"';

		}

	

		objScroll += '><tr>';

		y = 0;

		

		while (y < 4){

			//joins 3 News into one object

			for (x = 0; x < (Article.length); x++){

				if(orientation.toLowerCase() == "vertical"){

					//Only for vertical setting a new line for each news.

					objScroll += '<tr>';

				}

				

				objScroll += '<td ';

			   

				if(orientation.toLowerCase() == "horizontal"){

					objScroll += 'nowrap';

				}

				

				if(stopScroll == 1){

					objScroll += ' onMouseOver="stopscroller();" onMouseOut="setWidth()"';

				}

				

				//Close table cell and start Paragraph

				objScroll += '><p class="dmnt_par" style="text-align:' + textAlignment + ';">';

				

				if(Article[x][1].toLowerCase() != "none"){

					//If a link is applied (which is always the case by now in Typo3)

					// objScroll += '<a class="' + link_cssClass + '" href="' + Article[x][1] + '" target="' + Article[x][2] + '" >' + Article[x][0] + '<\/a>';
					
					objScroll += Article[x][0];

				}

				else{

					objScroll += Article[x][0];

				}

				

				//End paragraph and table cell

				objScroll += '</p><\/td>';

				

				if(orientation.toLowerCase() == "vertical"){

					//If vertical also close table line

					objScroll += '<\/tr>';

				}

					  

				if(objScrollDivider.toLowerCase() != "none"){

					//Insert divider if set in config

					objScroll += '<td nowrap><p class="dmnt_par" style="text-align:' + textAlignment + ';">' + objScrollDivider + '<\/p><\/td>';

				}

			} //End For each article

			

			y++

		} //End While

		

		objScroll += '<\/tr><\/table><\/div><\/div><\/td><\/tr><\/table>';  

	} // End is not NS4

	

	document.getElementById("tickerspace").innerHTML = objScroll;

	setWidth();

} //End function loadScroller





// Moving is more smooth if width / height (on vertical) is dividable by 2.

function setWidth() { 

	tableObj = (dmnt_isIE) ? document.all("ticker_table") : document.getElementById("ticker_table"); 

	obj = (dmnt_isIE) ? document.all.div1 : document.getElementById("div1");   

	objWidth = (orientation.toLowerCase() == "horizontal") ? getOffset(tableObj, "width") : getOffset(tableObj, "height");

	

	HalfWidth = Math.floor(objWidth / 2);

	

	if (orientation.toLowerCase() == "horizontal") {

		newWidth = (HalfWidth * 2) + 2;

	}

	else {

		//Bei vertikaler Anordnung nicht durch 2 teilen, damit es an jeder Stelle halten kann.

		newWidth = (HalfWidth) + 4;

	}

	

	//alert (objWidth);

	//alert (newWidth);

	obj.style.width = newWidth + "px";

	moveObject(obj, newWidth);  

}





// Move the layer by one pixel to the left

function moveObject(obj, width) {  

	maxLeft = (0 - (width / 2) + 2) / 2;

	

	if(orientation.toLowerCase() == "horizontal"){

		if (parseInt(obj.style.left) <= maxLeft) {

			obj.style.left =  "0px";

		}

		else {

			obj.style.left = (parseInt(obj.style.left) - 1) + "px";	

		}

	}

	else{		

		if(obj.style.top == ""){

			obj.style.top = 0 + "px";

		}

		

		if (parseInt(obj.style.top) < (0 - (width / 2) + 6)){

			obj.style.top = 0 + "px";

		}

		else{

			obj.style.top = (parseInt(obj.style.top) - 1) + "px";

		}

	}

	

	if (obj.style.left == "-1px" || obj.style.top == "-1px") {

		//Am Beginn jeder News die definierte Pause  

		timer = setTimeout ("moveObject(obj, " + width + ");", ticker_pause); 

	}

	else {

		//Normaler move ohne große Pause 

		timer = setTimeout ("moveObject(obj, " + width + ");", 100 - speed); 

	}

}





// Get width and height of layer

function getOffset(obj, dim) {

	if(dim == "width"){

		oWidth = obj.offsetWidth;

		return oWidth;

	}  

	else if(dim == "height"){

		oHeight = obj.offsetHeight;

		return oHeight;

	}    

}





function stopscroller() {

	clearTimeout(timer);

}

