var loadimg;
var preloadimg;

function glinit(){
	loadimg=new Image();
	preloadimg=new Image();
	loadimg.src="img/loading.gif";
	if(curkat>0)
		glgo(curkat,curnum);
}
function showfoot(i){
	hidefoot();
	document.getElementById("foot"+i).style.display="block";
	return(false);
}
function hidefoot(){
	for(i=1;i<=numfoot;i++){
		document.getElementById("foot"+i).style.display="none";
	}
}
function showother(num){
	closeSeries();
	closeKats();
	lowlightkat();
	highlightother(num);
	document.getElementById("theimage").src="bilder/other_"+num+".jpg";
	document.getElementById("titlediv").innerHTML="&nbsp;";
}
function highlightother(num){
	lowlightother();
	document.getElementById("other_"+num).className="otherlinka";
}
function lowlightother(){
	for(i=1;i<=2;i++){
		document.getElementById("other_"+i).className="otherlink";
	}
}
function glgo(kat,num){
	closeSeries();
	showKat(kat);
	showImg(kat,num);
	highlight(kat,num);
	if(serarr[kat][num]>0){
		showSerie(serarr[kat][num]);
	}
	preload(kat,num);
}
function showSerie(ser){
	closeSeries();
	document.getElementById("serie_"+ser).style.display="inline";
	document.getElementById("link_serie_"+ser).className="imglinka";
}
function closeSeries(){
	for(i=1;i<=numserien;i++){
		document.getElementById("serie_"+i).style.display="none";
		document.getElementById("link_serie_"+i).className="imglink";
	}
}
function showKat(kat){
	closeKats();
	if(document.getElementById("kategorie_"+kat))
		document.getElementById("kategorie_"+kat).style.display="block";
	highlightkat(kat)
}
function closeKats(){
	for(i=1;i<=numkats;i++){
		if(document.getElementById("kategorie_"+i))
			document.getElementById("kategorie_"+i).style.display="none";
	}
}
function showImg(kat,num){
	curnum=num;
	curkat=kat;
	if(document.getElementById("kategorie_"+kat)){
		document.getElementById("theimage").src=loadimg.src;
		document.getElementById("theimage").src="bilder/"+idarr[kat][num]+".jpg";
		document.getElementById("titlediv").innerHTML=titlearr[kat][num];
	}
}
function highlightkat(kat){
	lowlightother();
	lowlightkat();
	document.getElementById("katlink_"+kat).className="katlinka";
}
function lowlightkat(){
	for(i=1;i<=numkats;i++){
		document.getElementById("katlink_"+i).className="katlink";
	}
}

function highlight(kat,num){
	lowlight(kat);
	document.getElementById("imglink_"+kat+"_"+num).className="imglinka";
}
function lowlight(kat){
	for(i=1;i<idarr[kat].length;i++){
		document.getElementById("imglink_"+kat+"_"+i).className="imglink";
	}
}
//---------todo
function goNext(){
	nkat=curkat;
	nnum=curnum+1;
	if(nnum>=idarr[curkat].length){//next kat
		nnum=1;
		nkat=curkat+1;
		if(nkat>numkats)
			nkat=1;
	}
	glgo(nkat,nnum);
}
function goPrevieous(){
	nkat=curkat;
	nnum=curnum-1;
	if(nnum<=0){//next kat
		nkat=curkat-1;
		if(nkat<1)
			nkat=numkats;
		nnum=idarr[nkat].length-1;
	}
	glgo(nkat,nnum);
}
function preload(kat,num){
	nkat=kat;
	nnum=num+1;
	if(nnum>=idarr[kat].length){//next kat
		nnum=1;
		nkat=kat+1;
		if(nkat>numkats)
			nkat=1;
	}
	preloadimg.src="bilder/"+idarr[nkat][nnum]+".jpg";
}

