/*
	Titel:			ScrollText
	Autor:			Andreas Zierhut
	Datum:			10.07.2000
	Homepage:		http://www.dhtml-now.de/
	Script:			http://www.dhtml-now.de/dhtml/textg/scrolltext.asp
	E-Mail:			Andreas.Zierhut@gmx.de
	Beschreibung:	Das Script blendet einen Text in einem Layer von unten nach oben ein.
					Wahlweise kann ein schِner Ein-/Ausblendeffekt verwendet werden.

	(c) Copyright 2000 by Andreas Zierhut. Alle Rechte vorbehalten.
	Das Script darf in unverنnderter Form, einschlieكlich aller Kommentare, kostenlos
	weiterverwendet werden. Der Vertrieb des Scriptes ist nicht erlaubt.
*/

var nn4=document.layers?1:0;
var ie4=document.all?1:0;
var dom=document.implementation?1:0;
var HexReihe='0123456789ABCDEF';

function ScrollText_Options() {

	this.text='<center><b><h1>بريد العرب</h1>صفحة كل عربي يعيش في المانيا<br>شاركوا بمقالات وآراء بكل جرأة<br>القصةالقصيرة<br>مراسلات<br>سياسه<br>الجامعات الألمانية <br>Politik<br>Service<br>Studieren in Deutschland<br>Tipps & Tricks<br><br>webmaster@arabmail.de<br><b><h1>Arabm@il</h1>';  
              this.speed=(ie4 ? 1 : 100);

	this.width='24%';
	this.height='24%';
	this.padding=10;

	this.useEffect=true;
	this.effectHeight=2;
	this.effectCount=15;
	this.stop='never';
	this.startColor='#000066';

	this.borderStyle=new Object();s=this.borderStyle;
	s.borderWidth='2px';
	s.borderStyle='outset';
	

	this.style=new Object();s=this.style;
	s.backgroundColor='#cccccc';
	s.color='#FF6633';
	s.fontFamily='Arial,Helvetica,Sans-Serif';
	s.fontSize='80%';

	if (!this.useEffect)
		this.effectCount=2;
	this.fv=FarbVerlauf(this.startColor.substring(1),this.style.color.substring(1),this.effectCount+1).split(',');
}

so=new ScrollText_Options();
var soIv=null;
var soOldLoad=null;
if (self.onload)
	soOldLoad=self.onload;
self.onload=ScrollText_Init;

function ScrollText_Init() {

	if (soOldLoad)
		soOldLoad();

	if (nn4) {
		so.x=document.soPos.x;
		so.y=document.soPos.y;
		with(document.soBgLayer) {
			pageX=so.x;
			pageY=so.y;
			visibility='visible';
		}
		so.x+=document.soBgPos.x;
		so.y+=document.soBgPos.y;
		so.h=document.soLayer0.document.height;
	}
	else if (ie4) {
		so.x=getLeft(document.all.soPos);
		so.y=getTop(document.all.soPos);
		var l=document.all.soBgLayer.style;
		for (j in so.borderStyle)
			l[j]=so.borderStyle[j];
		l.posLeft=so.x;
		l.posTop=so.y;
		l.visibility='visible';
		so.x=getLeft(document.all.soBgPos)+1;
		so.y=getTop(document.all.soBgPos);
		for (var i=0; i<so.effectCount; i++) {
			var s=document.all['soText'+i].style;
			for (j in so.style)
				s[j]=so.style[j];
			s.color=so.fv[i+1];
		}
		so.h=document.all.soLayer0.offsetHeight;
	}

	soIv=setInterval('doScroll()',so.speed);
}

var pixCount=0;
function doScroll() {

	if (pixCount>=so.h+so.height && so.stop != 'after')
		pixCount=0;
	else if (pixCount>=so.h+so.height) {
		clearInterval(soIv);
		return;
	}

	var lId=pixCount/so.effectHeight;
	if (lId > so.effectCount)
		lId=so.effectCount;
	var posX=so.x;
	var posY=so.y+so.height-pixCount;

	if (posY == so.y && so.stop == 'top') {
		clearInterval(soIv);
		return;
	}

	for (var i=0; i<lId; i++) {

		if (nn4) {
			var l=document['soLayer'+i];
			l.pageX=posX;
			l.pageY=posY;
			l.clip.left=0;
			l.clip.top=0;
			l.clip.width=so.width;
			l.clip.height=pixCount-(i-1)*so.effectHeight;
			if (posY<so.y+i*so.effectHeight)
				l.clip.top=so.y+i*so.effectHeight-posY;
			l.visibility='visible';
		}
		else if (ie4) {
			var l=document.all['soLayer'+i].style;
			l.posLeft=posX;
			l.posTop=posY;
			var clipT=0,clipH=pixCount-(i-1)*so.effectHeight;
			l.clip='rect('+clipT+'px '+so.width+'px '+(clipH)+'px auto)';
			if (posY<so.y+i*so.effectHeight) {
				clipT=so.y+i*so.effectHeight-posY;
				l.clip='rect('+clipT+'px '+so.width+'px '+(clipH)+'px auto)';
			}
			l.visibility='visible';
		}
	}

	pixCount+=so.effectHeight;

}

function mark(reserve) {

	var w=1,h=1;
	if (reserve) {
		w=so.width;
		h=so.height;
	}
	document.write('<table border=0 cellspacing=0 cellpadding=0 width="'+w+'" height="'+h+'"><tr><td valign=top><img src="spacer.gif" width=1 height=1 name="soPos" id="soPos" alt=""></td></tr></table>');

	if (String(so.width).indexOf('%') != -1) {
		if (nn4) {
			so.width=parseInt(so.width.substring(0,so.width.length-1))/100*self.innerWidth;
			so.height=parseInt(so.height.substring(0,so.height.length-1))/100*self.innerHeight;
		}
		else if (ie4) {
			so.width=parseInt(so.width.substring(0,so.width.length-1))/100*document.body.clientWidth;
			so.height=parseInt(so.height.substring(0,so.height.length-1))/100*document.body.clientHeight;
		}
	}
	var txt=so.text;
	var bgC=(so.borderStyle.backgroundImage ? '' : ' bgColor="'+so.style.backgroundColor+'"');

	for (var i=0; i<so.effectCount; i++) {

		if (nn4) {
			var cl=document.classes['soLay'+i].all;
			cl.position='absolute';cl.left=0;cl.top=0;cl.visibility='hidden';cl.zIndex=i+2;
			for (j in so.style)
				document.classes['soText'+i].all[j]=so.style[j];
			document.classes['soText'+i].all.color=so.fv[i+1];
		}

		document.write('<div id="soLayer'+i+'" class="soLay'+i+'"'+(ie4||dom?' style="position: absolute; left: 0; top: 0; visibility: hidden; z-Index: '+(i+2)+'"':'')+'>\n'+
					   '	<table border=0 cellspacing=0 cellpadding='+so.padding+bgC+' width="'+so.width+'" height="'+so.height+'">\n'+
					   '		<tr>\n'+
					   '			<td valign=top class="soText'+i+'" id="soText'+i+'">'+txt+'</td>\n'+
					   '		</tr>\n'+
					   '	</table>\n'+
					   '</div>\n');
	}

	if (nn4) {
		var cl=document.classes.hidden.all;
		cl.position='absolute';cl.left=0;cl.top=0;cl.visibility='hidden';cl.zIndex=2;
		for (j in so.borderStyle)
			cl[j]=so.borderStyle[j];
	}
	document.write('<div id="soBgLayer" class="hidden"'+(ie4||dom?' style="position: absolute;left: 0; top: 0; visibility: hidden; z-Index: 2"':'')+'>\n'+
				   '	<table border=0 cellspacing=0 cellpadding=0'+bgC+' width="'+so.width+'" height="'+so.height+'">\n'+
				   '		<tr>\n'+
				   '			<td valign=top><img src="spacer.gif" width=1 height=1 name="soBgPos" id="soBgPos" alt=""></td>\n'+
				   '		</tr>\n'+
				   '	</table>\n'+
				   '</div>\n');
}

function FarbVerlauf(FarbeVon, FarbeBis, Ebenen)
{
	var RotVon = HexDez(FarbeVon.substring(0,2));
	var BlauVon = HexDez(FarbeVon.substring(2,4));
	var GruenVon = HexDez(FarbeVon.substring(4,6));

	var RotBis = HexDez(FarbeBis.substring(0,2));
	var BlauBis = HexDez(FarbeBis.substring(2,4));
	var GruenBis = HexDez(FarbeBis.substring(4,6));

	var ReturnValue = '';

	for (var i=0; i < Ebenen; i++) {

		if (RotBis >= RotVon)
			ReturnValue += '#' + DezHex(Math.round(RotVon + i * (RotBis - RotVon) / (Ebenen - 1)));
		else
			ReturnValue += '#' + DezHex(Math.round(RotVon - i * (RotVon - RotBis) / (Ebenen - 1)));

		if (BlauBis >= BlauVon)
			ReturnValue += DezHex(Math.round(BlauVon + i * (BlauBis - BlauVon) / (Ebenen - 1)));
		else
			ReturnValue += DezHex(Math.round(BlauVon - i * (BlauVon - BlauBis) / (Ebenen - 1)));

		if (GruenBis >= GruenVon)
			ReturnValue += DezHex(Math.round(GruenVon + i * (GruenBis - GruenVon) / (Ebenen - 1))) + ',';
		else
			ReturnValue += DezHex(Math.round(GruenVon - i * (GruenVon - GruenBis) / (Ebenen - 1))) + ',';

	}

	return (ReturnValue.substring(0, ReturnValue.length-1));
}

function HexDez(Zahl)
{
	var ErsteStelle = HexReihe.indexOf(Zahl.charAt(0)) * 16;
	var ZweiteStelle = HexReihe.indexOf(Zahl.charAt(1));
	return (ErsteStelle + ZweiteStelle);
}
function DezHex(Zahl)
{
	var ErsteStelle = HexReihe.charAt(parseInt(Zahl / 16));
	var ZweiteStelle = HexReihe.charAt(Zahl % 16);
	return (ErsteStelle + ZweiteStelle);
}
function getTop(l)
{ if(l.offsetParent&&l.offsetParent.tagName!='HTML')return(l.offsetTop+getTop(l.offsetParent));
  else return(l.offsetTop);
}
function getLeft(l)
{ if(l.offsetParent&&l.offsetParent.tagName!='HTML')return(l.offsetLeft+getLeft(l.offsetParent));
  else return(l.offsetLeft);
}