var JPSCROLL_pagepixelcount;
var JPSCROLL_pagecount=1;

function pause(millisekunden) {
    var now = new Date();
    var exitTime = now.getTime() + millisekunden;
 
    while(true) {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}


function JPscrollStart() {
	if (JPSCROLL_speed<10) {
		JPSCROLL_speed = 10;
	}

	JPSCROLL_td=document.getElementById('JPSCROLL_testwidth');
	JPSCROLL_td.innerHTML=JPSCROLL_message;
	
	JPSCROLL_outerdiv=document.getElementById('JPSCROLL_outer');
	JPSCROLL_outerdiv.style.height = JPSCROLL_height+'px';
	JPSCROLL_outerdiv.style.width = JPSCROLL_width+'px';
	
	JPSCROLL_outerdiv.style.border = JPSCROLL_bordercolor+' '+JPSCROLL_borderstyle+' '+JPSCROLL_borderwidth+'px';
	//JPSCROLL_outerdiv.style.clip = 'rect(0 '+JPSCROLL_innerwidth+' '+JPSCROLL_innerheight+' 0)';
	JPSCROLL_outerdiv.style.backgroundColor = JPSCROLL_bgcolor;
	JPSCROLL_style = 'position:relative;overflow:hidden;height:'+(JPSCROLL_height-2*JPSCROLL_borderwidth)+'px; width: '+(JPSCROLL_width-2*JPSCROLL_borderwidth)+'px; border: '+JPSCROLL_bgcolor+' solid '+JPSCROLL_bordergap+'px; background-color:'+JPSCROLL_bgcolor+'; ' + 'color: '+JPSCROLL_textcolor+';' + 'font-size: '+JPSCROLL_fontsize+'px; '+ 'font-family: '+JPSCROLL_fontfamily+'; '+ 'font-style: '+JPSCROLL_fontstyle+'; '+ 'font-weight: '+JPSCROLL_fontweight+'; '+ 'z-index: 60; ';
	JPSCROLL_outerdiv.innerHTML='<div style="'+JPSCROLL_style+'"> <div id="JPSCROLL_area1" style="position:relative; width:'+JPSCROLL_td.offsetWidth+'px; height:'+JPSCROLL_innerheight+'px;text-align: '+JPSCROLL_alignment+';"></div><div id="JPSCROLL_area2" style="position:relative; width:'+JPSCROLL_td.offsetWidth+'px; height:'+JPSCROLL_innerheight+'px;text-align: '+JPSCROLL_alignment+';"></div></div>';
	JPSCROLL_div1=document.getElementById('JPSCROLL_area1');
	JPSCROLL_div1.style.top='-2px';//-1
	//Ticker läuft von rechts los
	//JPSCROLL_div1.style.left=JPSCROLL_width+'px';

	//Ticker ist schon fast 'ganz' zu sehen
	JPSCROLL_div1.style.left='40px';
	JPSCROLL_div1.innerHTML=JPSCROLL_message;
	JPSCROLL_hsize1=JPSCROLL_div1.offsetWidth;

	JPSCROLL_div2=document.getElementById('JPSCROLL_area2');
	JPSCROLL_div2.style.top='-19px';//-17
	//Ticker läuft von rechts los
	//JPSCROLL_div2.style.left=JPSCROLL_width+'px';
	
	//Ticker ist schon fast 'ganz' zu sehen
	JPSCROLL_div2.style.left='40px';
	JPSCROLL_div2.innerHTML=JPSCROLL_message;
	JPSCROLL_hsize2=JPSCROLL_div2.offsetWidth;

	JPscroll();
}

function JPscroll() {
	JPSCROLL_pagepixelcount++;
	
	JPSCROLL_speed_temp = JPSCROLL_speed;
	JPSCROLL_pagepause_temp = JPSCROLL_pagepause;

	if(parseInt(JPSCROLL_div1.style.left) >= JPSCROLL_hsize1*(-1)) {
		JPSCROLL_div1.style.left=(parseInt(JPSCROLL_div1.style.left)-JPSCROLL_sspeed)+'px';
		if(parseInt(JPSCROLL_div1.style.left) >= (JPSCROLL_hsize1*(-1) + JPSCROLL_width)) {
			JPSCROLL_div2.style.left=JPSCROLL_width+'px';
		} else {
			JPSCROLL_div2.style.left=(parseInt(JPSCROLL_div2.style.left)-JPSCROLL_sspeed)+'px';
		}
		
		if(JPSCROLL_sspeed == 0) JPSCROLL_pagepixelcount--;
			setTimeout("JPscroll()",JPSCROLL_speed_temp);
		} else {
			JPSCROLL_div1.style.left='0px';
			JPSCROLL_pagepixelcount = 0;
			JPscroll();
		}
}

