// JavaScript Document

function gallery_swapImage(bildnr, gal) {
	var bildCon = document.getElementById('galleryPic');
	
	if (bildnr < 10) {
		bildCon.src = '../galerie/'+gal+'/'+gal+'_00'+bildnr+'.jpg';
	}
	else if (bildnr < 100) {
		bildCon.src = '../galerie/'+gal+'/'+gal+'_0'+bildnr+'.jpg';
	}
	else {
		bildCon.src = '../galerie/'+gal+'/'+gal+'_'+bildnr+'.jpg';
	}
}

function gallery_swapPreview(seite, anzahl, gal) {
	if (seite == 1) {
		document.getElementById('galLess').innerHTML = "";
	}
	else {
		document.getElementById('galLess').innerHTML = "<a href=\"javascript:gallery_swapPreview("+(seite-1)+", "+anzahl+", "+gal+");\"><img src=\"../imgs/media/lessBtn.gif\" width=\"15\" height=\"14\" border=\"0\" />";
	}
	
	var code = "";
	
	var erstesBild = (seite-1)*6+1;
	var letztesBild = seite*6;
	
	if (letztesBild > anzahl) {
		letztesBild = anzahl;
	}
	
	for (var n=erstesBild; n<=letztesBild; n++) {
		if (n<10) {
			var bildnr = '_00'+n;
		}
		else if (n<100) {
			var bildnr = '_0'+n;
		}
		else {
			var bildnr = '_'+n;
		}
		
		code += "<a href=\"javascript:gallery_swapImage("+n+", "+gal+");\" style=\"position:relative; display:block; width:124px; height:122px; margin-left:8px; margin-right:8px; float:left; text-decoration:none;\"><img src=\"../galerie/"+gal+"/thumbs/"+gal+bildnr+".jpg\" width=\"124\" height=\"83\" border=\"0\" /><p class=\"text\">"+gal+bildnr+"</p></a>";
	}
	
	document.getElementById('galPreview').innerHTML = code;
	//alert (code);
	
	if (seite == Math.ceil(anzahl/6)) {
		document.getElementById('galMore').innerHTML = "";
	}
	else {
		document.getElementById('galMore').innerHTML = "<a href=\"javascript:gallery_swapPreview("+(seite+1)+", "+anzahl+", "+gal+");\"><img src=\"../imgs/media/moreBtn.gif\" width=\"15\" height=\"14\" border=\"0\" />";
	}
}