/** einstellungen **/
var lineTime = 15000;
var scrollTime = 40;
var scrollWidth = 5;
var height = 60;
/** work **/
var oldline = 0;
var line = 0;
var lineposx = 0;
var lineTimer = null;
var scrollTimer = null;


var ix = 1;
var oix = -1;
var maxx = 12;
var fadeOut = 100;
var fadeIn  = 0;
var theTimer = null;
var fadeInt = 5;




function startAnimation(){
	lineTimer = setTimeout('startLine()', lineTime);
	var fs = document.getElementById("files");
	if(fs){
		var as = fs.getElementsByTagName("a");
		if(as){
			for(i = 0; i < as.length; ++i)
				as[i].target = "new";
		}
	}
}

function startLine(){
	clearTimeout(lineTimer);
	oldline = line;
	line++;
	if(!document.getElementById("b"+line+"1"))
		line = 0;
	lineposx = 0;
	scrollTimer = setTimeout('scrollLine()', scrollTime);
}

function scrollLine(){
	clearTimeout(scrollTimer);
	lineposx += scrollWidth;
	// ended
	if(lineposx > height){
		xline = line+1;
		xtop = height;
		if(!document.getElementById("b"+xline+"1"))
			xline = 0;

		while(xline != line){
			x1 = document.getElementById("b"+xline+"1");
			x2 = document.getElementById("b"+xline+"2");
			x3 = document.getElementById("b"+xline+"3");
			x1.style.top = xtop+'px';
			x2.style.top = xtop+'px';
			x3.style.top = xtop+'px';
				xtop += height;
				xline = xline+1;
				if(!document.getElementById("b"+xline+"1"))
					xline = 0;
		}
		startAnimation();
	}
	else{
		x1 = document.getElementById("b"+oldline+"1");
		x2 = document.getElementById("b"+oldline+"2");
		x3 = document.getElementById("b"+oldline+"3");
		y1 = document.getElementById("b"+line+"1");
		y2 = document.getElementById("b"+line+"2");
		y3 = document.getElementById("b"+line+"3");
		xtop = x1.style.top.replace(/px/,'') - 0;
		xtop = xtop - scrollWidth;
		ytop = y1.style.top.replace(/px/,'') - 0;
		ytop = ytop - scrollWidth;
		x1.style.top = xtop+'px';
		x2.style.top = xtop+'px';
		x3.style.top = xtop+'px';
		y1.style.top = ytop+'px';
		y2.style.top = ytop+'px';
		y3.style.top = ytop+'px';
		scrollTimer = setTimeout('scrollLine()',scrollTime);
	}
}

function openAd(url, img){
	if (url.substring(0,4)!='http') {
		window.open(url,"_self");
	}
	else {
		win= window.open(url);
		win.focus();
	}
	var http = getRequest();
	if(http){
		http.open("POST", 'http://www.horse-events.at/horse-events/stat', false);
		http.send('<stats><url>' + url + '</url><img>' + img + '</img></stats>');
	}
	else
		alert("couldn't create http request!");
}

function toggleBlockDisplay(div){
	div.style.display = div.style.display == 'block' ? 'none' : 'block';
}





               function photoVor() {
               	oix=ix;
               	ix++;
               	if (ix > maxx)
               		ix=1;
               	startFading();
               }
               function photoZurueck() {
               	oix=ix;
               	ix--;
               	if (ix <= 0)
               		ix=maxx;
               	startFading();
               }
               function startFading(){
               	fadeOut = 100;
               	theTimer = window.setInterval("doFading();",5);
               	document.getElementById("photoNr").innerHTML=ix+" von " + maxx;
               }
               function doFading() {
               	if (fadeOut > 0) {
               		fadeOut-=fadeInt;
               		if (fadeOut < 0) fadeOut=0;

               		document.getElementById("P"+oix).style.filter = "Alpha(opacity=" + fadeOut + ")";
               		document.getElementById("P"+oix).style.MozOpacity = fadeOut/100;
               		document.getElementById("P"+oix).style.opacity = fadeOut/100;
               		document.getElementById("PT"+oix).style.filter = "Alpha(opacity=" + fadeOut + ")";
               		document.getElementById("PT"+oix).style.MozOpacity = fadeOut/100;
               		document.getElementById("PT"+oix).style.opacity = fadeOut/100;
               		
               		if (fadeOut == 0) {
		               	document.getElementById("P"+oix).style.visibility="hidden";
               			fadeIn = 0;
	               		document.getElementById("P"+ix).style.filter = "Alpha(opacity=" + fadeIn + ")";
	               		document.getElementById("P"+ix).style.MozOpacity = fadeIn/100;
	               		document.getElementById("P"+ix).style.opacity = fadeIn/100;
		               	document.getElementById("P"+ix).style.visibility="visible";
	               		document.getElementById("PT"+ix).style.filter = "Alpha(opacity=" + fadeIn + ")";
	               		document.getElementById("PT"+ix).style.MozOpacity = fadeIn/100;
	               		document.getElementById("PT"+ix).style.opacity = fadeIn/100;
		               	document.getElementById("PT"+ix).style.visibility="visible";
               			}
               	}
               	else {
               		fadeIn+=fadeInt;
               		if (fadeIn>100) fadeIn=100;

               		document.getElementById("P"+ix).style.filter = "Alpha(opacity=" + fadeIn + ")";
               		document.getElementById("P"+ix).style.MozOpacity = fadeIn/100;
               		document.getElementById("P"+ix).style.opacity = fadeIn/100;
               		document.getElementById("PT"+ix).style.filter = "Alpha(opacity=" + fadeIn + ")";
               		document.getElementById("PT"+ix).style.MozOpacity = fadeIn/100;
               		document.getElementById("PT"+ix).style.opacity = fadeIn/100;
               	
               		if (fadeIn==100) {
               			document.getElementById("photoNr").innerHTML=ix+" von " + maxx;
               			window.clearInterval(theTimer);
               			}
               	} 
               	
               }


