/*
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 10000; //set delay between message change (in miliseconds)
var maxsteps=20; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(0,0,0); // start color (red, green, blue)
var endcolor=new Array(255,204,102); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div style="font: bold 14px Tahoma; padding: 5px;">'; //set opening tag, such as font declarations
fcontent[0]="<a href='http://www.jesus-teachings.com/de/Teach/study.php?studyid=35' title='Furcht vor Armut'>Die Armut ist ein Raufbold. Laß ihn dich herumkommandieren, und du wirst dein ganzes Leben vor ihm weglaufen. Doch schau ihm absichtlich in seiner schlimmsten Form ins Auge, und es wird unwahrscheinlich sein, daß er dir jemals wieder Furcht einflößt.</a>";
fcontent[1]="<a href='http://www.jesus-teachings.com/de/Teach/study.php?studyid=7' title='Weisheit'>Sie hören den Lehren Jesu zu, doch ziehen sie es niemals in Betracht, ihnen zu gehorchen. Dummköpfe!</a>";
fcontent[2]="<a href='http://www.jesus-teachings.com/de/Teach/study.php?studyid=23' title='Das Alles-Aufgeben-Prinzip'>Gott spart das Allerbeste für jene auf, die die Wahl Ihm überlassen.</a>";
closetag='</div>';
fcontent[3]="<a href='http://www.jesus-teachings.com/de/Teach/study.php?studyid=99' title='Körperschaftliches Wachstum'>Meine es ernst mit Gott, oder verschwinde!</a>";
closetag='</div>';
fcontent[4]="<a href='http://www.jesus-teachings.com/de/Teach/study.php?studyid=33' title='Das Problem mit den Armen'>Geistlich arm zu sein bedeutet, sich mit wenig zufriedenzugeben und zu versuchen, mit weniger auszukommen, anstatt mehr zu kriegen.</a>";
closetag='</div>';

var fwidth='500px'; //set scroller width
var fheight='80px'; //set scroller height

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////


var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;

// Random array sort function (copied from: http://sedition.com/perl/javascript-fy.html)
function fisherYates ( myArray ) {
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}

fisherYates(fcontent);

function goBack (){
    clearTimeout(fadecounter);
    clearTimeout(rotate);
    if (index>1){
		index-=2;
	} else {
		index=(fcontent.length - 1);
	}
	changecontent();
}

function goForward (){
    clearTimeout(fadecounter);
    clearTimeout(rotate);
	changecontent();
}

/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
  if (index>=fcontent.length)
    index=0
  if (DOM2){
    document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("fscroller").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
    clearTimeout(fadecounter);
    document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    rotate=setTimeout("changecontent()", delay);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2) {
 
	// ALL: Widen top header, and change padding/margins
	var arrHImg = getElementsByClassName(document, "div", "headerimage");
	arrHImg[0].style.height = "200px";
	var arrLinkLine = getElementsByClassName(document, "div", "linksline");
	arrLinkLine[0].style.padding = "2px";
	// ALL: Change linksline 'clear' property to none.
	var arrLinkLine = getElementsByClassName(document, "div", "linksline");
	arrLinkLine[0].style.clear = "none";
	// ALL: Write in language bar, quote fader and prev/next quotes
	document.getElementById("languages").innerHTML = '<div class="languageselect"><form id="language" name="language" action="" class="breakafter"><label for="language-select">Bevorzugte Sprache:</label><br /><select id="language-select" name="languagesel" onchange="gotoFunction();"><option value="http://www.jesus-teachings.com/JC/de/">Deutsch</option><option value="http://www.jesuschristians.com/">English</option><option value="http://www.jesus-teachings.com/JC/es/">Español</option><option value="http://www.jesus-teachings.com/JC/fr/">François</option><option value="http://www.comcen.com.au/%7Efold/Polish/Polish%20index.html">Po Polsku</option><option value="http://cust.idl.net.au/fold/ee_studies.html" >Easy English Studies</option></select></form><a class="qnav" href="javascript:goBack()">&lt;</a> Vorhergehender | Folgender <a class="qnav" href="javascript:goForward()">&gt;</a></div><div class="quotespace">Klicken sie auf das Zitat unten, um den Kontext lesen zu können:<div id="fscroller" style="border:0px; width:'+fwidth+';height:'+fheight+'">ladende Anführungsstriche...</div></div>&nbsp;';
	document.write('');	
}
  

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent