/*
Cross browser Marquee script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

/*
some changes for use with layers made by - 
www.pintat-emanuel.de
*/


//Specify the marquee's width (in pixels)
var marqueewidth=300
//Specify the marquee's height
var marqueeheight=25
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=3
//configure background color:
var marqueebgcolor="#EAEAEA"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1

//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='<nobr>Neue Seite des TSV auf <a href="http://www.tsv-sprintcup.de">www.Sprintcup.de</a></nobr>'


////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
	document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
var actualwidth=''
var cross_marquee, ns_marquee

var lefttime = 0;

// added vars for positioning by a given layer
var destLayerName = '';
var originalLayer = '';
var marqueetop = 0;
var marqueeleft = 0;
var marqueeheight = 0;
var marqueewidth = 0;

function initTicker(pLayerName,pSlidetext,pSpeed,pClass) {
	destLayerName = pLayerName;
	if (pSlidetext != null && pSlidetext.length > 0) {
		marqueecontent = '<nobr>'+pSlidetext+'</nobr>';
		if (pClass != null) {
			marqueecontent = '<span class="'+pClass+'">'+marqueecontent+'</span>';
		}
		marqueespeed = pSpeed;
		copyspeed = marqueespeed;
	
		initValues();
		positionLayers();
		populate();
	}
}

function initValues() {
	if (iedom) {
		if (destLayerName)
			originalLayer=document.getElementById? document.getElementById(destLayerName) : document.all[destLayerName]
		if(originalLayer) {
			actualwidth = originalLayer.offsetWidth
			marqueewidth = actualwidth;
			marqueeheight = originalLayer.offsetHeight;
			marqueetop = originalLayer.offsetTop;
			marqueeleft = originalLayer.offsetLeft;
		}
		else {
			actualwidth = windowWidth();
			marqueewidth = actualwidth;
			marqueeheight = windowHeight();
		}
		
	}
	else if (document.layers) {
	
		if (destLayerName)
			originalLayer=document[destLayerName]
		if(originalLayer) {
			actualwidth=originalLayer.document.width
			marqueewidth = actualwidth;
			marqueeheight = originalLayer.document.offsetHeight;
			marqueetop = originalLayer.document.offsetTop;
			marqueeleft = originalLayer.document.offsetLeft;
		}		
	}
}

function populate() {
	if (iedom) {
		cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
		cross_marquee.style.left=marqueewidth+8
		cross_marquee.innerHTML=marqueecontent
		if (document.all) {
			actualwidth = cross_marquee.offsetWidth;
		}
		else {
			actualwidth = cross_marquee.offsetWidth;			
		}
	}
	else if (document.layers) {
		ns_marquee=document.ns_marquee.document.ns_marquee2
		ns_marquee.left=marqueewidth+8
		ns_marquee.document.write(marqueecontent)
		ns_marquee.document.close()
		actualwidth=ns_marquee.document.width

	}
	if (lefttime != null) {
		clearInterval(lefttime);
	}
	lefttime=setInterval("scrollmarquee()",20)
}

//window.onload=populate

function scrollmarquee() {
	if (iedom) {
		left = parseInt(cross_marquee.style.left);
		width = (actualwidth*(-1)+8);
		if (left > width) {
			cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
		}
		else {
			cross_marquee.style.left=marqueewidth+8
		}

	}
	else if (document.layers) {
		if (ns_marquee.left>(actualwidth*(-1)+8))
			ns_marquee.left-=copyspeed
		else
			ns_marquee.left=marqueewidth+8
	}
}

function positionLayers() {
	if (iedom) {
		tomoveLayer=document.getElementById? document.getElementById("newsticker") : document.all.newsticker
		if(tomoveLayer) {
			tomoveLayer.style.top = marqueetop
			tomoveLayer.style.left = marqueeleft
			tomoveLayer.style.width = marqueewidth
			tomoveLayer.style.height = marqueeheight
		}
	}
	else if (document.layers) {
		tomoveLayer=document.newsticker
		if(tomoveLayer) {
			actualwidth=tomoveLayer.document.width
			tomoveLayer.style.top = marqueetop
			tomoveLayer.style.left = marqueeleft
			tomoveLayer.style.width = marqueewidth
			tomoveLayer.style.height = marqueeheight
		}
	}
}

if (iedom || document.layers) {

	with (document) {
		document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
		if (iedom) {
			write('<div id="newsticker" style="position:relative;top:'+marqueetop+';left:'+marqueeleft+';width:'+marqueewidth+';overflow:hidden;z-index: 1000">')
		    //write('<div style="position:absolute;height:'+marqueeheight+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
			write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
			write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
			write('</div>')
		}
		else if (document.layers) {
			write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
			write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
			write('</ilayer>')
		}
		document.write('</td></table>')
	}

}

function windowWidth() {
	
	if (window.innerWidth) {
		return window.innerWidth;
	}
 	else if (document.body && document.body.offsetWidth) {
		return document.body.offsetWidth;
 	}
 	else {
 		return alternativeParamForWidth;
 	}

}

function windowHeight() {
	if (window.innerHeight) return window.innerWidth;
 	else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 	else return alternativeParamForHeight;
}

function parseArray(pArray) {
	marqueecontent = '<nobr>';
	someAdded = false;
	for (var i=0; i < pArray.length; i++) {
 		sub = pArray[i];
 		numContent = sub.length;
  		if (numContent > 0) {
 			if (someAdded == true) {
 				marqueecontent += ' +++ '
 			}
 			if (sub[0] != null && sub[0].length > 0) {
 				marqueecontent += sub[0];
	 			someAdded = true;
 			}
 			if ( numContent > 2 && (sub[2] != null && sub[2].length > 0) && (sub[1] != null && sub[1].length > 0)){
 				marqueecontent += '<a href='+sub[1]+'>'+sub[2]+'</a>';
	 			someAdded = true;
 			}
 			if (numContent > 3 && (sub[3] != null && sub[3].length > 0)) {
	 			marqueecontent += sub[3];
 				someAdded = true;
 			}
 		}
	}
	marqueecontent += '</nobr>';
}
