addEvent(window, "load", addRotation);

function addRotation(){
	var myImages = window.rotImages;
	var misc = window.misc;
	var iflag = window.iflag;
	var idx = misc.curPhoto - 1;

	var jsCode = '';

	if(iflag){
		jsCode += '<a href="javascript:step(1);"><img id="Foto_img" src="' + myImages[idx].file +'" alt="'+ myImages[idx].info.Titel + '" title="' +  myImages[idx].info.Titel + '" style="margin-top:0px;" /></a><br/>';
		jsCode += '<div class="autor" id="Foto_autor" style="display: '+ misc.css + '">'+ misc.photoName +':&nbsp;'+ myImages[idx].info.Autor +'</div>';
		jsCode += '<div class="info" id="Foto_InfoDiv" style="margin-top: '+ misc.css2 +'">';
		jsCode += '<strong><a href="javascript:step(-1);"  class="noprint">&lt;&lt;</a></strong>&nbsp;';
		jsCode += '<strong><span id="Foto_Info" title="'+ misc.curPhoto +'/'+misc.numPhotos+'">'+  myImages[idx].info.Titel +'</span></strong>&nbsp;';
		jsCode += '<strong><a href="javascript:step(1);" class="noprint">&gt;&gt;</a></strong>&nbsp;<br/>';
		jsCode += '<span id="Foto_InfoLang">'+ myImages[idx].info.Info +'</span>';
		jsCode += ' <a id="Foto_InfoLink" href="'+ myImages[idx].info.Link +'" class="noprint" '+ (myImages[idx].info.Link ? '' : 'style="display: none;"') +'>'+(misc.lang ? 'more...' : 'mehr...') +'</a>';
		jsCode += '</div>';
	}
	else{
		jsCode += '<a href="javascript:step(1);"><img id="Foto_img" src="' + myImages[idx].file +'" style="margin-top:0px;" /></a>';
	}

	var rotation = document.getElementById("rotation");
	rotation.innerHTML = jsCode;
}

function step(move){
	var myImages = window.rotImages;
	var misc = window.misc;

	var newPhoto = misc.curPhoto + move;

	if(newPhoto < 1 ) newPhoto = misc.numPhotos;
	else if(newPhoto > misc.numPhotos) newPhoto = 1;

	var idx = newPhoto - 1;
	misc.curPhoto = newPhoto;

	var imgElem = document.getElementById("Foto_img");
	imgElem.src = myImages[idx].file;

	if(iflag){

		imgElem.alt = myImages[idx].info.Titel;
		imgElem.title = myImages[idx].info.Titel;

		var css, css2;

		if(myImages[idx].info.Autor){
			css = 'block';
			css2 = '0px';
		}
		else{
			css = 'none';
			css2 = '12px';
		}


		var autor = document.getElementById("Foto_autor");
		autor.style.display = css;
		autor.innerHTML = misc.photoName + ': ' + myImages[idx].info.Autor;

		document.getElementById("Foto_InfoDiv").style.marginTop = css2;

		var titel = document.getElementById("Foto_Info");
		titel.innerHTML = myImages[idx].info.Titel;
		titel.title = newPhoto +'/'+ misc.numPhotos;

		document.getElementById("Foto_InfoLang").innerHTML = myImages[idx].info.Info;

		var link = document.getElementById("Foto_InfoLink");
		link.style.display = (myImages[idx].info.Link ? 'inline' : 'none');
		link.href = myImages[idx].info.Link;
	}
}



