var SCT_LEFT			= 0;							// left coordinate of ticker
var SCT_TOP				= 0;							// left coordinate of ticker
var SCT_WIDTH			= 0;							// width of ticker
var SCT_HEIGHT			= 10;							// height of ticker;
var SCT_CONTENT_DIR		= '';							// directory with files containing the articles
var SCT_LINK_PREFIX		= 'http://www.dia-schau.com/';	// default prefix for links ?
var SCT_LINK_SUFFIX		= '" target="_top';			// default suffix for links ?
var SMM_URL				= location.href
var SCT_TICKER_TEXT		= '';							// ticker text
var SCT_POSITION		= 0;							// position counter of ticker text
var SCT_TICKER_OBJECT	= null;							// ticker reference
var SCT_TICKER_INTERVAL	= null;							// interval handle for stopping ticker
var SCT_INITIALIZED		= 0;
var SCT_HTTP_ROOT		= 'http://www.dia-schau.com/sys/scripts/';	// prefix string for inclusion of scripts
var SCT_RANDOM			= new String (Math.random());				// random string
var SCT_INITIALIZED		= false;

if(typeof(SCN_HEADLINES_LOCATION) == "undefined") {
	SCN_HEADLINES_LOCATION = '';
}
//if(SMM_URL.indexOf('sportbild') != -1 || SCN_HEADLINES_LOCATION == 'sportbild') {
//	SCT_LINK_PREFIX = 'http://www.sportbild.de/';
//}
//if(SMM_URL.indexOf('handball') != -1 || SCN_HEADLINES_LOCATION == 'handball') {
//	SCT_LINK_PREFIX = 'http://www.handballwoche.de/';
//}
//if (typeof SCT_TICKER_RESSORT == "undefined") {
	var SCT_TICKER_RESSORT = '';
//}

if(SCT_TICKER_RESSORT == '') {
	document.writeln('<script src="' + SCT_HTTP_ROOT + 'ticker_text.js?' + SCT_RANDOM + '" type="text/javascript"></script>');
} else {
	document.writeln('<script src="' + SCT_HTTP_ROOT + 'content/ticker_text_' + SCT_TICKER_RESSORT + '.js?' + SCT_RANDOM +'" type="text/javascript"></script>');
}

SCT_styleSheet();

SCT_TICKER_OBJECT_STRING	= '<div id="SCT_TICKER_PARENT" class="SCT_TICKER_PARENT_STYLE">';
SCT_TICKER_OBJECT_STRING	+= '<div id="SCT_OBJ_TICKER_TEXT" class="SCT_LIVE_TICKER_STYLE"></div>';
SCT_TICKER_OBJECT_STRING	+= '</div>';
document.write(SCT_TICKER_OBJECT_STRING);

// initialize headlines after 0.1 seconds
window.setTimeout("SCT_tickerInit()", 100);
window.setTimeout("SCT_tickerInit()", 1000);
window.setTimeout("SCT_tickerInit()", 2000);
window.setTimeout("SCT_tickerInit()", 5000);
window.setTimeout("SCT_tickerInit()", 10000);

function SCT_makeWindow(URL, width, height) {
	window.open(URL, "SCT_POPUP", "height=" + height + ",width=" + width + ",left=150,top=100,scrollbars=1,resizable=0");
}

// initialize ticker
function SCT_tickerInit() {
	if(SCT_INITIALIZED == true || SCT_TICKER_TEXT == '') {
		return;
	}

	SCT_TICKER_OBJECT	= document.getElementById("SCT_OBJ_TICKER_TEXT");
	if(!SCT_TICKER_OBJECT) {
		window.setTimeout("SCT_tickerInit()", 1000);
		return;
	}

	SCT_RIGHT							= SCT_TICKER_WIDTH + SCT_LEFT;
	SCT_POSITION						= SCT_RIGHT - SCT_TICKER_WIDTH / 5;
	SCT_TICKER_OBJECT.innerHTML			= SCT_TICKER_TEXT;
	SCT_TICKER_OBJECT.style.left		= SCT_TICKER_WIDTH;
	SCT_TICKER_OBJECT.style.visibility	= "visible";

	SCT_startTicker();
	SCT_INITIALIZED	= true;
}

function SCT_startTicker() {
	if(!parseInt(SCT_TICKER_INTERVAL) || SCT_TICKER_HOVER_STOP)
		SCT_TICKER_INTERVAL = setTimeout('SCT_tickerTick()', 20);
}

function SCT_stopTicker() {
	if(parseInt(SCT_TICKER_INTERVAL) && SCT_TICKER_HOVER_STOP) {
		clearTimeout(SCT_TICKER_INTERVAL);
		SCT_TICKER_INTERVAL = 0;
	}
}

function SCT_tickerTick() {
	SCT_POSITION		= SCT_POSITION - 0.1 * SCT_TICKER_SPEED;
	SCT_POSITION_END	= SCT_TICKER_OBJECT.offsetWidth;
	if(SCT_POSITION_END < 1000) {
		SCT_POSITION_END = 4000;
	}
	if (SCT_POSITION < -SCT_POSITION_END) {
		SCT_POSITION	= SCT_RIGHT;
	}
	SCT_TICKER_OBJECT.style.left	= Math.round(SCT_POSITION);
	SCT_TICKER_INTERVAL				= setTimeout('SCT_tickerTick()', 10);
}

function SCT_styleSheet() {
	if(SCT_TICKER_TRANSPARENT == 0) {
		SCT_TICKER_BG_COLOR = 'background-color:' + SCT_TICKER_BG_COLOR;
	}
	var TICKER_CSS	= '.SCT_LIVE_TICKER_STYLE {' +
						'white-space:nowrap;' +
						'position:relative;' +
						'visibility:hidden;' +
						'line-height:'	+ SCT_TICKER_HEIGHT + 'px;' +
						'font-size:'	+ SCT_TICKER_FONT_SIZE + 'pt;' +
						'font-family:'	+ SCT_TICKER_FONT + ';' +
						'font-weight:'	+ SCT_TICKER_FONTBOLD + ';' +
						'color:'		+ SCT_TICKER_FONT_COLOR + ';' +
						SCT_TICKER_BG_COLOR + ';}';
	var PARENT_CSS	= '.SCT_TICKER_PARENT_STYLE {'+
						'overflow:hidden;' +
						'width:'		+ SCT_TICKER_WIDTH + 'px;' +
						'height:'		+ SCT_TICKER_HEIGHT + 'px;' +
						SCT_TICKER_BG_COLOR + ';}';
	var TIME_CSS	= '.SCT_TICKER_TIME {' +
						'white-space:nowrap;' +
						'line-height:'	+ SCT_TICKER_HEIGHT + 'px;' +
						'font-size:'	+ SCT_TICKER_FONT_SIZE + 'pt;' +
						'font-family:'	+ SCT_TICKER_FONT + ';' +
						'font-weight:'	+ SCT_TICKER_FONTBOLD + ';' +
						'color:'		+ SCT_TICKER_FONT_COLOR + ';}';
	var LINK_CSS	= 'A.SCT_LIVE_TICKER_LINK {' +
						'text-decoration:'	+ SCT_TICKER_LINK_UNDERLINE + ';' +
						'color:'			+ SCT_TICKER_LINK_COLOR + ';}';
	var VISITED_CSS	= 'A.SCT_LIVE_TICKER_LINK:visited {' +
						'text-decoration:'	+ SCT_TICKER_LINK_UNDERLINE + ';' +
						'color:'			+ SCT_TICKER_VLINK_COLOR + ';}';
	var HOVER_CSS	= 'A.SCT_LIVE_TICKER_LINK:hover {' +
						'text-decoration:'	+ SCT_TICKER_HOVER_UNDERLINE + ';' +
						'color:'			+ SCT_TICKER_HOVER_COLOR + ';}';

	document.write("\n\n<STYLE>");
	document.write(TICKER_CSS);
	document.write(TIME_CSS);
	document.write(PARENT_CSS);
	document.write(LINK_CSS);
	document.write(VISITED_CSS);
	document.write(HOVER_CSS);
	document.write("</STYLE>\n\n");
}
