var activeDetailImageDiv=1;
var ImagesPrevOrNext_t=false;
var activeDetailImageDiv=1;
var ImageFading_t=false;
var autoSlideShowRunning=true;
var ImagesSlideShow_t=false;
var ImageHideLayerVorne_t=false;
var fadingIsActive=false;
var fadingwert=0;
function c_getElement(m){
	if (document.getElementById){
		var obj = document.getElementById(m);
	} else if (document.all){
		var obj = document.all[m];
	} else if (document.layers){
		var obj = document.layers[m];
	}
	return obj;
}
function ImagesSlideShow(){
	if(bildersrcarray){
		if(bildersrcarray.length>2){
			if(autoSlideShowRunning){
				clearTimeout(ImagesSlideShow_t);
				clearTimeout(ImagesPrevOrNext_t);
				var zeit1=2000;
				var zeit2=3000;
				if(page=="home"){
					if(currentDetailImage==1){
						var zeit1=5000;
						var zeit2=6000;
					}
				}
				ImagesPrevOrNext_t=setTimeout('ImagesPrevOrNext("next")',zeit1);
				ImagesSlideShow_t=setTimeout('ImagesSlideShow()',zeit2);
			}
		}
	}
}
function ImagesPrevOrNextMan(prevornext){
	ImageHideLayerVorne();
	clearTimeout(ImagesSlideShow_t);
	autoSlideShowRunning=false;
	ImagesPrevOrNext(prevornext);
}
function SlideShowClickDecider(){
	if(bilderonlynextarray[currentDetailImage]){
		ImagesPrevOrNextMan('next');
	}else{
		document.location.href=bilderlinkarray[currentDetailImage];
	}
}
function ImagesPrevOrNext(prevornext){
	if(ImageFading_t){
		upcomingimage=currentDetailImage;
		clearTimeout(ImageFading_t);
		ImageFading_t=false;
		ImageHideLayerVorne();
		var wert=c_getElement("bgimagesvorne").style.backgroundImage;
		//wert=wert.replace("url(","url("+fromCharCode(39));	
		//wert=wert.replace(")",""+fromCharCode(39)+")");	
		c_getElement("bgimgeshinten").style.backgroundImage=wert;
	}else{
		if(prevornext=="prev"){
			var upcomingimage=currentDetailImage-1;
			if(bildersrcarray[upcomingimage]){
			}else{
				upcomingimage=bildersrcarray.length-1;
			}
		}else{
			var upcomingimage=currentDetailImage+1;
			if(bildersrcarray[upcomingimage]){
			}else{
				upcomingimage=1;
			}
		}
		/*SETZEN DES AC FÜR DEN THUMBNAIL WENN VORHANDEN*/
		if(c_getElement("thumbnailcontainer"+upcomingimage)){
			var tempclassName=c_getElement("thumbnailcontainer"+currentDetailImage).className;
			tempclassName=tempclassName.replace("imagethumbcontainerAC","imagethumbcontainerPA");
			c_getElement("thumbnailcontainer"+currentDetailImage).className=tempclassName;

			var tempclassName=c_getElement("thumbnailcontainer"+upcomingimage).className;
			tempclassName=tempclassName.replace("imagethumbcontainerPA","imagethumbcontainerAC");
			c_getElement("thumbnailcontainer"+upcomingimage).className=tempclassName;
		}
		if(bilderonlynextarray[upcomingimage]){
			if(c_getElement("slideshowlink")){
				c_getElement("slideshowlink").href="javascript:ImagesPrevOrNextMan('next');";
			}
			if(c_getElement("slideshowborder")){
				//c_getElement("slideshowborder").title=weiterLabel;
			}
		}else{
			if(c_getElement("slideshowlink")){
				c_getElement("slideshowlink").href="javascript:document.location.href='"+bilderlinkarray[upcomingimage]+"';";
			}
			if(c_getElement("slideshowborder")){
				//c_getElement("slideshowborder").title=bildertxtarray[upcomingimage];
			}
		}
		if(c_getElement("bgimagesvorne")){
			c_getElement("bgimagesvorne").style.backgroundImage="url('"+bildersrcarray[upcomingimage]+"')";
		}
		if(c_getElement("detailimage_text")){
			c_getElement("detailimage_text").innerHTML=bildertxtarray[upcomingimage];
		}
		if(c_getElement("detailimage_amount")){
			c_getElement("detailimage_amount").innerHTML=upcomingimage;
		}		
		fadeImages(upcomingimage);		
	}
}
function fadeImages(upcomingimage){
	fadingwert=0;
	fadingIsActive=setTimeout("ImageFading("+fadingwert+")", 50);
	currentDetailImage=upcomingimage;
}
function ImageHideLayerVorne(){
	if(c_getElement("bgimagesvorne")){
		if(document.all){
			c_getElement("bgimagesvorne").style.filter="Alpha(opacity=0)";
		}else{
			var inwert2=fadingwert/100;
			if(c_getElement("bgimagesvorne").style.opacity){
				c_getElement("bgimagesvorne").style.opacity=0;
			}
		}
	}
}
function ImageFading(fadingwert){
	fadingwert=fadingwert+10;
	if(fadingwert<100){
		if(document.all){
			c_getElement("bgimagesvorne").style.filter="Alpha(opacity="+fadingwert+")";
		}else{
			var inwert2=fadingwert/100;
			if(c_getElement("bgimagesvorne").style.opacity){
				c_getElement("bgimagesvorne").style.opacity=inwert2;
			}
		}
		ImageFading_t=setTimeout("ImageFading("+fadingwert+")", 50);
	}else{
		if(ImageFading_t){
			ImageFading_t=false;
			clearTimeout(ImageFading_t);
			clearTimeout(ImageHideLayerVorne_t);
			var wert=c_getElement("bgimagesvorne").style.backgroundImage;
			//wert=wert.replace("url(","url("+fromCharCode(39));	
			//wert=wert.replace(")",""+fromCharCode(39)+")");	
			c_getElement("bgimgeshinten").style.backgroundImage=wert;
			ImageHideLayerVorne_t=setTimeout("ImageHideLayerVorne()", 300);
		}
	}
}
function jumpToImage(imageid){
	autoSlideShowRunning=false;	
	clearTimeout(ImagesPrevOrNext_t);
	clearTimeout(ImagesSlideShow_t);
	var tempclassName=c_getElement("thumbnailcontainer"+currentDetailImage).className;
	tempclassName=tempclassName.replace("imagethumbcontainerAC","imagethumbcontainerPA");
	c_getElement("thumbnailcontainer"+currentDetailImage).className=tempclassName;	
	currentDetailImage=imageid-1;	
	if(currentDetailImage==0){
		currentDetailImage=bildersrcarray.length-1;
	}
	ImagesPrevOrNext("next");
}
if(doimageslideshowauto){
	ImagesSlideShow();
}
