
var count = 0;
var timeoutid;
var aktLayer;
var go = 1;		

var imgcounter = 0;
var imgarr = new Array();

function setimg(obj)
{
	imgarr[imgcounter] = obj;
	imgcounter++;
}

function setimgsize()
{
	for(i=0;i<imgarr.length;i++)
	{
		if(parseInt(imgarr[i].width) >= 700)
			imgarr[i].width = 700;
			
		if(parseInt(imgarr[i].height) >= 400)
			imgarr[i].height = 400;
	}
}

function setimagesize(obj)
{
	if(parseInt(obj.width) >= 700)
		obj.width = 700;
		
	if(parseInt(obj.height) >= 400)
		obj.height = 400;
}

function changeimg()
{
	document.getElementById("pnlFolie").style.display = "block";
	document.getElementById("pnlInfo1").style.display = "none";
	document.getElementById("pnlInfo2").style.display = "none";
	document.getElementById("pnlInfo3").style.display = "none";
	document.getElementById("pnlInfo4").style.display = "none";
	document.getElementById("pnlInfo5").style.display = "none";
	
	if(folienid.length > 0)
	{
		if (document.layers){
			//Netscape 4 specific code
			pre = 'document.';
			post = '';
			post1 = '';		
		}
		if (document.getElementById){
			//Netscape 6 specific code
			pre = 'document.getElementById("';
			post = '").style';
			post1 = '")';		

		}
		if (document.all){
			//IE4+ specific code
			pre = 'document.all.';
			post = '.style';
			post1 = '';		
		}
		if(aktLayer != null)
			aktLayer.display = "none";
		
		aktLayer = eval(pre + folienid[count] + post);		
		aktLayer.display = "block";
			
			
		fill(count);
	
				
		if(go == 1)
		{
			
			window.clearTimeout(timeoutid);
			if (count == 0)
			{
				// show startpage only 3 seconds
				timeoutid = window.setTimeout("changeimg()",3000);
			}
			else
			{
				// show 12 seconds
				if (folienid[count].substring(0,1)=="T") {
					timeoutid = window.setTimeout("changeimg()",12000);
				}else
				{
				// others show 8 secs
					timeoutid = window.setTimeout("changeimg()",8000);
				}
			}
		}	
		
		count++;
		setimgsize();
							
		if(count == folienid.length)
			count = 0;
	}
}

function gotoimage(i)
{
	if(i<folienid.length && i>=0)
	{
		count = i;
		changeimg();										
	}
	window.top.focus();
}

function left()
{
	count -= 2;
	if(count < 0)
		count = folienid.length + count;
				
	changeimg();								
}

function right()
{	
	changeimg();
}

function imggo()
{			
	document.getElementById("imgstop").style.display = "block";
	document.getElementById("btimggo").style.display = "none";
	go = 1;
	changeimg();
}

function stoppic()
{
	document.getElementById("imgstop").style.display = "none";
	document.getElementById("btimggo").style.display = "block";
	go = 0;
	if(timeoutid != null)
	{
		window.clearTimeout(timeoutid);
		timeoutid = null;
	}
}	

function fill(i)
{

if (document.layers){
			//Netscape 4 specific code
			pre = 'document.';
			post = '';
			post1 = '';		
		}
		if (document.getElementById){
			//Netscape 6 specific code
			pre = 'document.getElementById("';
			post = '").style';
			post1 = '")';		

		}
		if (document.all){
			//IE4+ specific code
			pre = 'document.all.';
			post = '.style';
			post1 = '';		
		}
		
		for (j=0;j<folienid.length;j++)
		{
			if (i==j) 
			{
				if(eval(pre + "marker"+(j) + post1) != null)
				{
					m = eval(pre + "marker"+(j) + post);		
					m.backgroundColor = "#D2D3D5";
				}
			} else 
			{
				if(eval(pre + "marker"+(j) + post1) != null)
				{
					m = eval(pre + "marker"+(j) + post);		
					m.backgroundColor = "transparent";
				}
			}
		}
	
}	

function startfromsearch(id)
{
		if (document.layers){
			//Netscape 4 specific code
			pre = 'document.';
			post = '';
			post1 = '';		
		}
		if (document.getElementById){
			//Netscape 6 specific code
			pre = 'document.getElementById("';
			post = '").style';
			post1 = '")';		

		}
		if (document.all){
			//IE4+ specific code
			pre = 'document.all.';
			post = '.style';
			post1 = '';		
		}
		
		if(folienid.length > id)
		{
			aktLayer = eval(pre + "previewdiv0" + post);		
			aktLayer.display = "block";
			searched = id;
			gotoimage(searched);
			stoppic();
			fill(searched);
			if(document.getElementById("marker"+(searched))!=null)
			{
				m = eval(pre + "marker"+(searched) + post);		
				m.display="block";									
			}
		}
		
		else imggo();
		setimgsize();
		
		
}

function showHelp(infoval) {
	stoppic();
	document.getElementById("pnlFolie").style.display = "none";
	document.getElementById("pnlInfo1").style.display = "none";
	document.getElementById("pnlInfo2").style.display = "none";
	document.getElementById("pnlInfo3").style.display = "none";
	document.getElementById("pnlInfo4").style.display = "none";
	document.getElementById("pnlInfo5").style.display = "none";
	
	document.getElementById("pnlInfo"+infoval).style.display = "block";
}
