/*----------------------------------------+
|  Bildlaufleiste                         |
|                                         |
|  Nach einer Idee von Timo Kohlweyer     |
|                                         |
|  (c) 2008                               |
|  Autor:  Matthias Peters                |
|  v 2.0; 30.06.2008                      |
+-----------------------------------------*/

var LimitLinks=115;
var LeisteLeft=130;
var RollInterval;
var LimitRechts;
var BremseRechts;
var BremseLinks;
var Schritt=0;
var tmpStep=2;
var opa=50;
var FadeInterval;
var aktThumb="Thumb0";

function adaptieren() {
if (!document.getElementById('CurtonLeft')) {
return
}
	if (document.all) {
	document.getElementById('CurtonLeft').setAttribute("onclick",function anonymous() {Verschieben('Zeitleiste','left')});
	document.getElementById('CurtonRight').setAttribute("onclick",function anonymous() {Verschieben('Zeitleiste','right')});
//	document.getElementById('CurtonLeft').setAttribute("onmouseup",function anonymous() {Ende('Zeitleiste','left')});
//	document.getElementById('CurtonRight').setAttribute("onmouseup",function anonymous() {Ende('Zeitleiste','right')});
	}
	else {
	document.getElementById('CurtonLeft').firstChild.setAttribute("onclick","Verschieben('Zeitleiste','left')");
	document.getElementById('CurtonRight').firstChild.setAttribute("onclick","Verschieben('Zeitleiste','right')");
//	document.getElementById('CurtonLeft').setAttribute("onmouseup","Ende('Zeitleiste','left')");
//	document.getElementById('CurtonRight').setAttribute("onmouseup","Ende('Zeitleiste','right')");
	}

var TimoScreens=document.getElementById("Zeitleiste").getElementsByTagName("DL");
LimitRechts=-eval(TimoScreens.length*105);
BremseRechts=LimitRechts+60;
BremseLinks=LimitLinks-20;
var Thumbs=document.getElementById("Zeitleiste").getElementsByTagName("IMG");
	for (var i=0;i<Thumbs.length;i++)
	{
	if(i>0){
	Thumbs[i].style.filter = "alpha(opacity=30)";
	Thumbs[i].style.opacity = 30/100;
	}
		Thumbs[i].setAttribute("id","Thumb"+i);
		if (document.all) {
		Thumbs[i].setAttribute("onmouseover",function anonymous() {FadeIn(this,'in')});
		Thumbs[i].setAttribute("onmouseout",function anonymous() {FadeIn(this,'out')});
		Thumbs[i].setAttribute("onclick",function anonymous() {AktivesPic(this)});
		} else {
		Thumbs[i].setAttribute("onmouseover","FadeIn(this,'in')");
		Thumbs[i].setAttribute("onmouseout","FadeIn(this,'out')");
		Thumbs[i].setAttribute("onclick","AktivesPic(this)");
		}
	}
}

function Verschieben(wasDenn,wohin) {
if(RollInterval);
window.clearInterval(RollInterval);
//alert(document.getElementById(wasDenn).style.width)
RollInterval = window.setInterval("RollOut('"+wasDenn+"','"+wohin+"')",20);
}

function RollOut(n,dir){
Schritt++;
//document.getElementById("TextBox").innerHTML=LeisteLeft+" TimoPixel";
if(Schritt > 3)
tmpStep=5;
if(Schritt > 5)
tmpStep=8;
if(Schritt > 6)
tmpStep=12;
if(Schritt > 7)
tmpStep=15;
if(Schritt > 8)
tmpStep=18;
if(Schritt > 9)
tmpStep=20;
if(Schritt > 10)
tmpStep=21;
if(Schritt > 11)
tmpStep=20;
if(Schritt > 12)
tmpStep=18;
if(Schritt > 13)
tmpStep=15;
if(Schritt > 14)
tmpStep=10;
if(Schritt > 15)
tmpStep=8;
if(Schritt > 17)
tmpStep=5;
if(Schritt > 18)
tmpStep=4;
if(Schritt > 19)
tmpStep=3;
if(Schritt > 20)
tmpStep=2;
if(Schritt > 23)
tmpStep=1;

if(LeisteLeft<BremseRechts)
if(dir!="left")
tmpStep=3;

if(LeisteLeft>BremseLinks)
if(dir=="left")
tmpStep=3;

if(LeisteLeft>90)
if(dir=="left")
tmpStep=3;

	if(dir=="left") 
		if(LeisteLeft < LimitLinks) {
		LeisteLeft+=tmpStep;
		document.getElementById(n).style.left=LeisteLeft+"px";
		}
	if(dir!="left")
		if(LeisteLeft > LimitRechts) {
		LeisteLeft-=tmpStep;
		document.getElementById(n).style.left=LeisteLeft+"px";
		}
	if(Schritt>26) {
	window.clearInterval(RollInterval);
	Schritt=0;
	}
//document.getElementById("TextBox").innerHTML=LeisteLeft;
}


function Ende(wasDenn,wohin) {
LeisteLeft+=0;
window.clearInterval(RollInterval);
document.getElementById(wasDenn).style.left=LeisteLeft+"px";
}

function FillBox(item) {
document.getElementById("TextBox").innerHTML="Inhalt wird geladen...";
getTxt(item.href);
}



function AktivesPic(pic) {
document.getElementById(aktThumb).style.filter = "alpha(opacity=30)";
document.getElementById(aktThumb).style.opacity = 30/100;
document.getElementById(pic.id).style.filter = "alpha(opacity=100)";
document.getElementById(pic.id).style.opacity = 100/100;
aktThumb=pic.id;
}

function FadeIn(pic,gang) {
if(aktThumb==pic.id)
return;
opa=30;
if(FadeInterval)
window.clearInterval(FadeInterval);
FadeInterval=window.setInterval("opac('"+pic.id+"','"+gang+"')",10);
}

function opac(p,gang) {
gang=="in" ? opa++ : opa--;
if(opa==29)
window.clearInterval(FadeInterval);
document.getElementById(p).style.filter = "alpha(opacity="+opa+")";
document.getElementById(p).style.opacity = opa/100;
if(opa==100)
window.clearInterval(FadeInterval);
}




function getTxt(url) {
url=url.replace("https","http");
zwischentext="";
http_request = false;
    if (window.XMLHttpRequest) { // Gecko u.a.
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/plain');
        }
    } else if (window.ActiveXObject) { // ie...
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert("Es ist ein Fehler aufgetreten.");
		neuwin.close();
        return false;
    }
http_request.onreadystatechange = InhaltExtrahieren;
http_request.open('GET', url, true);
http_request.send(null);
}

function InhaltExtrahieren() {
var LadeStr="";
var reqStr="";
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
		reqStr=http_request.responseText;
	} else	{
	alert(http_request.status);
			}
	}
	if (http_request.readyState == 4) {
	reqStr = reqStr.substring( reqStr.indexOf("<!-- infotext -->"), reqStr.indexOf("<!-- /infotext -->") );
	document.getElementById("TextBox").innerHTML=reqStr;
	}
}

window.onload=adaptieren;


