
function popup(width, height) {
	if (typeof(popup_win)=="object" && !popup_win.closed) {
		popup_win.focus();
	} else {
		popup_win=window.open("", "popup", "width="+width+",height="+height+",resizable=yes");
	}
}

//---------------------------------

function GalerieBilderNavi(bilderAnzahl) {
	this.bilderAnzahl=bilderAnzahl;
	this._init();
	this._createNavi();
}

GalerieBilderNavi.prototype._init = function () {
	this.firstVisibleBild=1;
	
	if (this.bilderAnzahl>4) {
		for (i=5; i<=this.bilderAnzahl; i++) {
			document.getElementById("bild"+i).style.display="none";
		}
	}
	
	document.getElementById("galerie_bilder_hider").style.display="";
}

GalerieBilderNavi.prototype.scroll = function (num) {
	if (num>0) {
		for (j=0; j<num; j++)	{
			document.getElementById("bild"+(this.firstVisibleBild+j)).style.display="none";
			document.getElementById("bild"+(this.firstVisibleBild+4+j)).style.display="";
		}
	} else if (num<0) {
		for (j=num; j<0; j++)	{
			document.getElementById("bild"+(this.firstVisibleBild+j)).style.display="";
			document.getElementById("bild"+(this.firstVisibleBild+4+j)).style.display="none";
		}
	}

	document.getElementById("bild"+this.firstVisibleBild).className="";
	this.firstVisibleBild+=num;
	document.getElementById("bild"+this.firstVisibleBild).className="first";
	
	this._updateNavi();
}

GalerieBilderNavi.prototype.prev = function () {
	if (this.firstVisibleBild>1)
		this.scroll(-1);
}

GalerieBilderNavi.prototype.next = function () {
	if (this.firstVisibleBild<=this.bilderAnzahl-4)
		this.scroll(1);
}

GalerieBilderNavi.prototype.fastBackwards = function () {
	i=this.firstVisibleBild-4;
	if (i<1) i=1;
	this.scroll(i-this.firstVisibleBild);
}

GalerieBilderNavi.prototype.fastForwards = function () {
	i=this.firstVisibleBild+4;
	if (i>this.bilderAnzahl-4) i=this.bilderAnzahl-3;
	this.scroll(i-this.firstVisibleBild);
}

GalerieBilderNavi.prototype._createLink = function (id, text, command) {
	var aTag=document.createElement("a");
	aTag.setAttribute("id", id);
	aTag.setAttribute("href", "javascript:"+command);
	aTag.appendChild(document.createTextNode(text));
	return aTag;
}

GalerieBilderNavi.prototype._createNavi = function () {
	var elem=document.getElementById("galerie_bilder_navi");
	while (elem.firstChild) {
		elem.removeChild(elem.lastChild);
	}
	if (this.bilderAnzahl>4) {
		elem.appendChild(this._createLink("navi_fastBackwards", "<<", "bilderNavi.fastBackwards();"));
		elem.appendChild(this._createLink("navi_prev", "< zurück", "bilderNavi.prev();"));
		elem.appendChild(document.createTextNode(" - "));
		elem.appendChild(this._createLink("navi_next", "weiter >", "bilderNavi.next();"));
		elem.appendChild(this._createLink("navi_fastForwards", ">>", "bilderNavi.fastForwards();"));

		this._updateNavi();
	}
}

GalerieBilderNavi.prototype._updateNavi = function () {
	document.getElementById("navi_fastBackwards").style.visibility=(this.firstVisibleBild==1 ? "hidden" : "visible");
	document.getElementById("navi_prev").style.visibility=(this.firstVisibleBild==1 ? "hidden" : "visible");
	
	document.getElementById("navi_next").style.visibility=(this.firstVisibleBild==this.bilderAnzahl-3 ? "hidden" : "visible");
	document.getElementById("navi_fastForwards").style.visibility=(this.firstVisibleBild==this.bilderAnzahl-3 ? "hidden" : "visible");
}

