// JavaScript Document

function getElemStyle(divid){
	if( document.getElementById ){ // this is the way the standards work
	elem = document.getElementById( divid );
	}else if( document.all ){ // this is the way old msie versions work
	elem = document.all[divid];
	}else if( document.layers ){ // this is the way nn4 works
elem = document.layers[divid];
}
return elem.style;
}

function toggle(divid) {
	var vis = getElemStyle(divid);
	// if the style.display value is blank we try to figure it out here
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined){
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	}
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function toggle_team(divid){
	if (divid == visible){
		divid = 'team0';
	}
	toggle(visible);
	toggle(divid);
	visible = divid;
}

function start_gallery(){
	guide = true;
	gallery(1);
}

function gallery(dir){
	clearTimeout(guide_action);	// bestehende action löschen, da sonst mit jeden click auf weiter/zurück eine neue gallerie gestartet wird
	var new_pos = gallery_pos + dir;// neue position berechnen
	if (new_pos > 6){		// falls ende+1 erreicht, von vorne weiter
		new_pos = 1;
	} else if (new_pos == 0){	// falls anfang-1, von hinten weiter
		new_pos = 6;
	}
	if (gallery_pos == -1){
		toggle ('content');	// beim start content ausschalten
		toggle ('gallery1');	// beim start gallery einschalten
	}
	
	var vis = getElemStyle('gallery1');
	vis.backgroundImage = 'url(img/im'+new_pos+'.jpg)';
	
	gallery_pos = new_pos;		// position speichern

	if (guide == true){
		guide_action = setTimeout('gallery('+ dir +')', 5000);
	}
}

function close_gallery (){
	clearTimeout(guide_action);
	guide = false;
	toggle ('gallery1');
	toggle ('content');
	gallery_pos = -1;
}

function clear_timeouts(){
	clearTimeout(guide_action);
}

var visible = 'team0';
var gallery_pos = -1;
var guide = false;
var guide_action;

