image_data = new Array();
image_data_idx = -1;

/**
*
*/
function addImageData(filename_str, title_str, htmltext_str) {
	htmltext_str = (htmltext_str=='') ? title_str : htmltext_str;
	image_data.push(new Array(filename_str, title_str, htmltext_str));
}

/**
*
*/
function switchLocation(idx) {
	if (!idx) { alert("id is missing!");	return }
	image_data_idx = idx -= 1;
	
	idata = image_data[idx];
	if (!idata) { alert("no data!"); return; }
	
	hideAllLocMarks();
	showLocMark(idx+1);
	
	loadImage(idata[0]);
	setTitle (idata[1]);
	setText  (idata[2]);
	
	dehighlightAllThumbs();
	highlightThumb(idx+1);
}

/**
*
*/
function showImage(dir) {
	idx = image_data_idx + dir;
	if ( idx <= 0 ) {
		//first time called or image_data_idx is getting bigger than size of array
		idx = 1;
	} else if (idx >= image_data.length) {
		idx = image_data.length;
	} else {
		idx++;
	}
	switchLocation(idx);
}

/**
*
*/
function loadImage(src_str) {
	htmlobj = document.getElementById('loc-stagephoto');
	if (!htmlobj) { alert("no htmlobj"); return; }
	htmlobj.innerHTML = '<img src="/images/content/produktion/images/'+src_str+'" border="0"/>';
}

/**
*
*/
function setTitle(title_str) {
	htmlobj = document.getElementById('pagetitle');
	if (!htmlobj) { alert("no htmlobj"); return; }
	htmlobj.innerHTML = title_str;
}

/**
*
*/
function setText(htmltext_str) {
	htmlobj = document.getElementById('loc-stagetext');
	if (!htmlobj) { alert("no htmlobj"); return; }
	htmlobj.innerHTML = '<p>'+htmltext_str+'</p>';	
}

/**
*
*/
function showLocMark(idx) {
	htmlobj = document.getElementById('loc'+idx);
	if (!htmlobj) { alert("no htmlobj"); return; }
	htmlobj.style.display = 'block';
	if (idx == image_data_idx+1) {
		htmlobj.style.zIndex = '5';
	} else {
		htmlobj.style.zIndex = '6';
	}
}

/**
*
*/
function hideLocMark(idx) {
	if (idx == image_data_idx+1) { return; }
	htmlobj = document.getElementById('loc'+idx);
	if (!htmlobj) { alert("no htmlobj"); return; }
	htmlobj.style.display = 'none';
}

/**
*
*/
function hideAllLocMarks() {
	for (i = 1; i <= image_data.length; i++) {
		htmlobj = document.getElementById('loc'+i);
		if (!htmlobj) { alert("no htmlobj"); return; }
		htmlobj.style.display = 'none';
	}
}


/**
*
*/
function dehighlightAllThumbs() {
	for (i = 1; i <= image_data.length; i++) {
		htmlobj = document.getElementById('tnlink'+i);
		if (!htmlobj) { alert("no htmlobj"); return; }
		htmlobj.className = 'tnlink-off';
	}
}
	
/**
*
*/
function highlightThumb(idx) {
	htmlobj = document.getElementById('tnlink'+idx);
	if (!htmlobj) { alert("no htmlobj"); return; }
	htmlobj.className = 'tnlink-on';
}