function nextNewsImg(){
	if(currentImageID+1 <= lastMedia){
		currentImageID++;
	}else{
		currentImageID = 0;
	}
	document.getElementById('newsImg').src = arrImages[currentImageID]["path"];
}
function previousNewsImg(){
	if(currentImageID-1 >= 0){
		currentImageID--;
	}else{
		currentImageID = lastMedia;
	}
	document.getElementById('newsImg').src = arrImages[currentImageID]["path"];
}
function changePartnerBox(boxID){
	document.getElementById(currentPartnerBoxID).style.display = 'none';
	document.getElementById(boxID).style.display = 'block';
	currentPartnerBoxID = boxID;
}
function changeBoxVisibility(boxID){
	if(activatedBox != ''){
		document.getElementById('furnisherTxt'+activatedBox).style.display = 'none';
		document.getElementById('furnisherImg'+activatedBox).src = './images/elements/empty.gif';
		document.getElementById('furnisherTitle'+activatedBox).className = 'furnisherTitle';
		activatedBox = '';
	}
	document.getElementById('furnisherTxt'+boxID).style.display = 'block';
	document.getElementById('furnisherTitle'+boxID).className = 'furnisherTitleActive';
	document.getElementById('furnisherImg'+boxID).src = './images/elements/dot_sitemap.gif';
	activatedBox = boxID;
}
function changePdfImages(pdfID,status){
	if(status == 'hover'){
		document.getElementById('pdf'+pdfID).src = './images/buttons/btn_map_pdf_hover.gif';
		document.getElementById('img'+pdfID).src = './images/buttons/btn_map_dblarrow_hover.gif';
	}else{
		document.getElementById('pdf'+pdfID).src = './images/buttons/btn_map_pdf.gif';
		document.getElementById('img'+pdfID).src = './images/buttons/btn_map_dblarrow.gif';
	}
}

function showGalleryImage(imgId,action){
	if(action == 'last'){
		imgId = lastImgId;
	}else if(action == 'first'){
		imgId = firstImgId;
	}else if(action == 'next'){
		imgId = nextImgId;
	}else if(action == 'previous'){
		imgId = previousImgId;
	}
	
	if(imgId != currentImgId){
		changeOpac(30,'preview'+currentImgId);
		var firstPreviewImgPos = 1;
		for(var i = 0; i < arrActiveImages.length; i++){
			document.getElementById('imgBox'+arrActiveImages[i]).style.display = 'none';
		}
		if(imgId == lastImgId){
			for(var i = 0; i < arrActiveImages.length; i++){
				var tmpImgPos = imgId - i;
				if(tmpImgPos >= firstImgId)
					firstPreviewImgPos = tmpImgPos;
			}
		}else if(imgId != lastImgId && imgId != firstImgId){
			var imageFactor = arrActiveImages.length / 2;
			var factor = Math.ceil(imageFactor);
			if(factor != imageFactor)
				factor = factor - 1;
			var countImages = arrActiveImages.length - 1;
			for(var i = 0; i < factor; i++){
				tmpPos = imgId + ( factor - i );
				if(tmpPos <= lastImgId)
					countImages = countImages - 1;
			}
			var tmpImagePos = imgId - countImages;
			if(tmpImagePos > firstImgId)
				firstPreviewImgPos = tmpImagePos;
		}
		for(var i = 0; i < arrActiveImages.length; i++){
			var tmpImgPos = firstPreviewImgPos + i;
			if(tmpImgPos >= firstImgId && tmpImgPos <= lastImgId){
				arrActiveImages[i] = firstPreviewImgPos + i;
			}
		}
		document.getElementById('galImg'+currentImgId).className = lnkNormal;
		document.getElementById('galImg'+imgId).className = lnkActive;
		
		if(imgId > lastActiveBox && action != 'last'){
			for(var i = 1; i <= lastImgId; i++){
				document.getElementById('galImg'+i).style.display = 'none';
			}
			for(var i = 0; i < 32; i++){
				var tmpId = imgId - i;
				document.getElementById('galImg'+tmpId).style.display = 'block';
			}
			firstActiveBox = imgId - 31;
			lastActiveBox = imgId;
		}else if(imgId < firstActiveBox && action != 'first'){
			for(var i = 1; i <= lastImgId; i++){
				document.getElementById('galImg'+i).style.display = 'none';
			}
			for(var i = 0; i < 32; i++){
				var tmpId = imgId + i;
				document.getElementById('galImg'+tmpId).style.display = 'block';
			}
			firstActiveBox = imgId;
			lastActiveBox = imgId + 31;
		}else if(imgId > lastActiveBox && action == 'last'){
			for(var i = 1; i <= lastImgId; i++){
				document.getElementById('galImg'+i).style.display = 'none';
			}
			for(var i = 0; i < 32; i++){
				var tmpId = lastImgId - i;
				document.getElementById('galImg'+tmpId).style.display = 'block';
			}
			firstActiveBox = lastImgId - 31;
			lastActiveBox = lastImgId;
		}else if(imgId < firstActiveBox && action == 'first'){
			for(var i = 1; i <= lastImgId; i++){
				document.getElementById('galImg'+i).style.display = 'none';
			}
			for(var i = 1; i <= 32; i++){
				document.getElementById('galImg'+i).style.display = 'block';
			}
			firstActiveBox = 1;
			lastActiveBox = 32;
		}
		
		currentImgId = imgId;
		changeOpac(100,'preview'+imgId);
		rootBigImage = arrGallery[imgId]['image'];
		changeImage('galBigImg',rootBigImage);
		window.setTimeout("setHiddenRotation(0)", 5000);
		
		if(currentImgId > firstImgId){
			previousImgId = currentImgId - 1;
		}else{
			previousImgId = lastImgId;
		}
		if(currentImgId < lastImgId){
			nextImgId = currentImgId + 1;
		}else{
			nextImgId = firstImgId;
		}
		
		for(var i = 0; i < arrActiveImages.length; i++){
			document.getElementById('imgBox'+arrActiveImages[i]).style.display = 'block';
		}
	}
}

function changeActivatedBoxes(activateBox,deactivateBox){
	document.getElementById(deactivateBox).style.display = 'none';
	document.getElementById(activateBox).style.display = 'block';
}

function changeImage(imgName,img){
	if(img == ''){
		hiddenRotationImg = 0;
		document.getElementById(imgName).src = rootBigImage;
	}else{
		hiddenRotationImg = 1;
		document.getElementById(imgName).src = img;
	}
}

function changeImageWithoutThumbChange(imgName,img,imgId){
	if(img == ''){
		hiddenRotationImg = 0;
		document.getElementById(imgName).src = rootBigImage;
	}else{
		hiddenRotationImg = 1;
		document.getElementById(imgName).src = img;
	}
	document.getElementById('galImg'+currentImgId).className = lnkNormal;
	document.getElementById('galImg'+imgId).className = lnkActive;
	changeOpac(30,'preview' + currentImgId);
	changeOpac(100,'preview' + imgId);
	currentImgId = imgId;
	if(currentImgId > firstImgId){
		previousImgId = ( currentImgId * 1 ) - 1;
	}
	if(currentImgId < lastImgId){
		nextImgId = ( currentImgId * 1 ) + 1;
	}
}

function setHiddenRotation(delay){
	hiddenRotationImg = 0;
}

function swfComm(target,action) {
	movie.TCallLabel('/'+target, action);
}
function loadNewFamilyMovie(flashMovie){
	familyMovie.SetVariable("/:param_source",flashMovie);
	familyMovie.TCallLabel('/', "neuesVideo");
}
function swfUpdateNavi(imgId){
	if(activeMainNaviId != 0){
		document.getElementById('naviImg'+activeMainNaviId).src = arrNavi[activeMainNaviId]['glowOut'];
	}
	document.getElementById('naviImg'+imgId).src = arrNavi[imgId]['glowIn'];
	activeMainNaviId = imgId;
}
function opacity(id, opacStart, opacEnd, millisec) { 
	var speed = Math.round(millisec / 100);
	var timer = 0;
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++){
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function activateMovie(movieId){
	document.getElementById('movie'+activeMovie).style.display = 'none';
	document.getElementById('movie'+movieId).style.display = 'block';
	activeMovie = movieId;
}
function changeBigGalleryImage(){
	if(hiddenRotationImg == 0){
		/*
		if(currentBigImgId < lastImgId){
			newBigImgId = currentBigImgId + 1;
		}else{
			newBigImgId = 1;
		}
		document.getElementById('galBigImg').src = arrGallery[newBigImgId]["image"];
		currentBigImgId = newBigImgId;
		*/
		if(nextImgId < lastImgId){
			showGalleryImage('','next');
		}else if(imgRotationLast == 1){
			imgRotationLast = 0;
			showGalleryImage('','first');
		}else{
			imgRotationLast = 1;
			showGalleryImage('','next');
		}
	}
	window.setTimeout("changeBigGalleryImage()", 3000);
}
