// DHTML Laufschrift © Hofa Soft 2003
// Beschreibung:
// Dieser Code dient zur Darstellung einer Laufschrift
// die mit 3 Ebenen arbeitet
var bStop = false;
var LS_BACK;
var LS_01;
var LS_02;
var txtWidth;
var left1 = 0;
var left2 = 0;
var delay = 50;
var step  = 1;
var  m_strLayers = '<div id=\"laufBACK\" style=\"position:absolute; z-index:1; overflow: hidden;\">' +
                   ' <div id=\"lauf1\" style="\position:absolute; height:24px; left:0px; top:0px; z-index:2\">' +
				      '<table id=\"tableLauf1\" cellpadding=\"0\" cellspacing=\"0\"><tr><td nowrap name=\"laufTxt1\" id=\"laufTxt1\">&nbsp;</td></tr></table></div>&nbsp;' +
				   ' <div id=\"lauf2\" style="\position:absolute; left:0px; top:0px; z-index:3\">' +
				      '<table cellpadding=\"0\" cellspacing=\"0\"><tr><td nowrap name=\"laufTxt2\" id=\"laufTxt2\">&nbsp;</td></tr></table></div>&nbsp;' +
				   '</div>';
var m_font; 				   

m_font = {
			fontSize:12,
			fontWeight:500,
			fontName:"Arial",
			fontColor:"#ffffff"
		 }
//******************************************			
function StartStop_Lauf( Stop )
//******************************************
{
	var LS;
	
	LS = _GetElement("laufBACK");

	if ( bStop == Stop ) // nothing to do
	     return;

	if ( Stop == true || Stop == false )
	    bStop = Stop;
    else
	{
	    alert( "StartStop_Lauf: Parameter nicht vom Typ boolean!");
		return;
	}

	
   	
	if ( document.layers )
	    LS.visibility = bStop ? "hide" : "show";
	else
		LS.style.visibility = bStop ? "hidden" : "visible";

	if ( bStop )
	    left2 = -50000;
	else
	{		
	    DoLaufschrift();
	}

	
	return;	    
}
//***************************************
function _GetElement( strID )
//***************************************
{
	var obj = null;

	
	if ( document.all )
	{
		//alert( "document ALL" );
		obj = document.all[strID];
	}
	else if ( document.layers )
	{
		//alert( "document Layers" );
		obj = document.layers[strID];
	}
	else if ( document.getElementById )
	{
		//alert( "document GetElementById()" );
	    obj = document.getElementById( strID );
	}
	
	
	//alert ( obj.id );
	
	return obj;
	
}
//************************
function SetFont( Elem )
//************************
{

	if ( Elem.style )
	    Elem = Elem.style;	
    Elem.fontFamily  = m_font.fontName;
	Elem.fontWeight  = m_font.fontWeight;
	Elem.color        = m_font.fontColor;
	Elem.fontSize    = m_font.fontSize+"px";
}
//*****************************************
function SetLaufText( strHTMLText )
//*****************************************
{
    var Text1  = _GetElement("laufTxt1");
	var Text2  = _GetElement("laufTxt2");
	var Table1 = _GetElement("tableLauf1");
	if ( !LS_01 || !LS_02 )
	{
		alert( "Bitte zuerst die Funktion: Lauf_Init( strID ) aufrufen!" );
		return;
	}
	    
	Text1.innerHTML = strHTMLText;
	Text2.innerHTML = strHTMLText;
    
	SetFont( Text1 );
	SetFont( Text2 );
	
	if ( !Text1.clientWidth || Text1.clientWidth == 0 )
	    txtWidth = Text1.scrollWidth;
	else
	    txtWidth = Text1.clientWidth;
	
}
//*************************************
function DoLaufschrift()
//*************************************
{
	if ( !LS_01 || !LS_02 || !LS_BACK )
	{
	     return;
	}
	var left, width

	if ( left2 == -50000 )
	{
		if ( txtWidth > parseInt(LS_BACK.width) )
		     left2 = txtWidth + 10;
		else	 
 	         left2  = parseInt(LS_BACK.width);
		left1 = 0;
	}
	
	
	left1 -= step; 
	left2 -= step;
	LS_01.left = left1;

	
	LS_02.left = left2;
	left  = parseInt(LS_01.left);
	width = parseInt(LS_01.width);
	if ( (left + txtWidth) < 0 )
	{		
		if ( txtWidth > parseInt(LS_BACK.width) )
		     left1 = parseInt(LS_02.left) + txtWidth + 10;
		else
		     left1 = parseInt(LS_02.left) + parseInt(LS_BACK.width);
	}
	left  = parseInt(LS_02.left);
	width = parseInt(LS_02.width);
	if ( (left + txtWidth) < 0 )
	{
		if ( txtWidth > parseInt(LS_BACK.width) )
		     left2 = parseInt(LS_01.left) + txtWidth + 10;
		else		
		     left2 = parseInt(LS_01.left) + parseInt(LS_BACK.width);
		//LS_01.left = width;
	}
    
	if ( bStop )
	{		
	    return; 
	}
	setTimeout("DoLaufschrift()", delay);	 
		 
		 
}
//**********************************************************
function Lauf_Init( strID, strLaufText, speed  )
//**********************************************************
{
	// Laufschrift Initialisieren 
	// Parameter: strID = die ID des Elements in dem die Laufschrift dargestellt werden soll
	// Am besten eignet sich hierfür ein <td> element
	
	var Elem;
	bStop = false;
	
	Elem = _GetElement( strID );
	
	if ( !Elem )  // should not happen
	     return;
	Elem.innerHTML = m_strLayers;
	
	
	
	LS_BACK = _GetElement("laufBACK");
	LS_01   = _GetElement("lauf1");
	LS_02   = _GetElement("lauf2");
	
	if ( !document.layers )
	{
		LS_01   = LS_01.style;
		LS_02   = LS_02.style;
		LS_BACK = LS_BACK.style;
	}
	
	if ( !Elem.clientWidth || parseInt(Elem.clientWidth) == 0 )
	{
		LS_BACK.width  = parseInt(Elem.scrollWidth);
		LS_BACK.height = parseInt(Elem.height);
		LS_01.height   = parseInt(Elem.height);
	}
	else
	{
	LS_BACK.width  = parseInt(Elem.clientWidth);
	LS_BACK.height = parseInt(Elem.clientHeight);
	}
		
	if ( strLaufText == "" || !strLaufText )
	     strLaufText = 'Laufschrift Text...';
	if ( speed )
	    delay = speed;	 
	left2 = -50000;	 

	SetLaufText( strLaufText );
	DoLaufschrift();		 
	
}