// Version:	5.1.0
// Build:	8
// Date:	2009-11-15
// Author:	Dietrich Roland Pehlke
// Client:	Haddewig-Design

var d = document;

d.k_max_picts = 0;

var button_states = [0,1,1];
var nowImage = 1;
var zoomIconStatus = 1; // 1 = on, 0 = off
var no_navigation = 0;
// Safari-Bugfix
var is_zoom =0;
d.can_zoom =0;

d.basePictName = "";
d.f_suffix = ".gif";

function set_str(str) {window.status=str;return true;}

function next_image(prev_or_next) {
	if (no_navigation ==1 ) return 1;
	switch(prev_or_next) {
		case 0: // prev
			if (button_states[0] == 0) return 0;
			
			if (button_states[1] == 0) {
				changeId('next_dis', 'next');
				button_states[1] = 1;
			}
			
			nowImage--;
			
			if (nowImage == 1) {
				changeId('prev', 'prev_dis');
				button_states[0] = 0;
			}
			break;
		case 1: // next
			if (button_states[1] == 0) return 0;
			
			if (button_states[0] == 0) {
				changeId('prev_dis', 'prev');
				button_states[0] = 1;
			}
			
			nowImage++;
			
			if (nowImage ==d.k_maxPicts) {
				changeId('next', 'next_dis');
				button_states[1] = 0;
			}
			break;
	}
	setImage();
}

function changeId (old_id, new_id) {
	ref = d.getElementById(old_id);
	if (ref) ref.setAttribute('id', new_id);
	
	return true;
}

function images_load() {
	// Safari-Bug-Fix
	
	if (d.z_array[nowImage-1]==0) {
		changeId( "zoom", "zoom_dis");
		is_zoom =0;
		zoomIconStatus = 0;
	}
	if (d.k_maxPicts < 2) {
		d.getElementById("next").style.visibility="hidden";
		d.getElementById("prev_dis").style.visibility="hidden";
		no_navigation = 1;
	}
	if (d.can_zoom == 0) {
		changeId("zoom", "zoom_dis");
	} else {
		
		if (no_navigation == 1) {
			
			(d.getElementById("zoom")).style.visibility="hidden";
			(d.getElementById("zoom")).setAttribute("id", "zoom_old");
			
			ref_a = d.getElementById("prev_dis");
			ref_a.setAttribute("id", "zoom_moved");
			ref_a.setAttribute("onclick", "do_zoom()");
			ref_a.style.visibility="visible";
		}
	}
	
}

function setImage () {
	d.images['Anzeige'].src = d.imageArray[nowImage-1].src;
	if (d.z_array[nowImage-1] == 0 ) {
		// keine Zoom-Image
		changeId( (
			(is_zoom ==1) ? 
				(no_navigation==1? "zoom_plus_moved":"zoom_plus") : 
				(no_navigation==1 ? "zoom_moved": "zoom") ), "zoom_dis" );
		is_zoom =0;
		zoomIconStatus = 0;
	} else {
		if (zoomIconStatus == 0) {
			// Element is hidden
			changeId("zoom_dis", (no_navigation==1 ? "zoom_moved": "zoom"));
			zoomIconStatus = 1;
			is_zoom = 0;
		} else {
			if (is_zoom==1) {
				changeId(
					(no_navigation == 1 ? "zoom_plus_moved":"zoom_plus"), 
					(no_navigation == 1 ? "zoom_moved": "zoom")
				);
				is_zoom = 0;
			}
		}
	}
}

function do_zoom(){

	if (d.can_zoom) {
		// alert ("Test: "+ d.zoomListe[0].src);
		if (d.z_array[nowImage-1] == 1) {
					
			if (zoomIconStatus == 0) {
				changeId("zoom_dis", (no_navigation==1 ? "zoom_moved": "zoom") );
			}
			id_name= (is_zoom==1) ? (no_navigation==1? "zoom_plus_moved":"zoom_plus") : (no_navigation==1 ? "zoom_moved": "zoom") ;
			new_id_name = (is_zoom==1) ? (no_navigation==1 ? "zoom_moved": "zoom")  : (no_navigation==1? "zoom_plus_moved":"zoom_plus");
			ref =document.getElementById(id_name);
			ref.setAttribute('id', new_id_name);
	
			is_zoom = (is_zoom == 0) ? 1 : 0;
			document.images['Anzeige'].src = (is_zoom == 1)? d.zoomListe[nowImage-1].src : d.imageArray[nowImage-1].src;

		} else {
			changeId( (no_navigation==1 ? "zoom_moved": "zoom"), "zoom_dis");
			zoomIconStatus = 0;
		}
	}
}