	function function_exists_f_gallery(fName)
	{
		pObj = window;
		return (typeof pObj[fName] == 'function') ? true : false;
	}
	// überprüfen, ob wichtige functionen existiren. wenn nicht, dann werder sie erstellt
	// start ->
	
	if(!function_exists_f_gallery("$"))
	{
		function $(id) { return document.getElementById(id); }
	}
	if(!function_exists_f_gallery("in_array"))
	{
		function in_array(str, arr)
		{
			for(a in arr)
			{
				if(str == arr[a]) return true;
			}
			return false;
		}
	}
	if(!function_exists_f_gallery("array_key"))
	{
		function array_key(str, arr)
		{
			for(b in arr)
			{
				if(str == arr[b]) return b;
			}
			return false;
		}
	}
	if(!function_exists_f_gallery("strrchr"))
	{
		function strrchr(chr ,stri)
		{
			return stri.substr(stri.lastIndexOf(chr));
		}
	}
	if(!function_exists_f_gallery("galleryConfigIncluded")) alert("Die Galerie kann nicht geladen werden, da die Config Datei 'va_js_gallery.config.js' nichtg eingbunden ist!");
	
	// ...
	// <- ende
	
	function popup_fade2black()
	{
		var bg=$('fade2black');
		var opacity;
		if(bg)
		{
			if(bg.style.opacity)
			{
				opacity=bg.style.opacity*100;
				// alert("opacity");
			}
			if(bg.filters)
			{
				opacity=bg.filters['alpha'].opacity;
				// alert("alpha");
			}
			if(opacity<60)
			{
				var new_opacity=opacity+20;
				if(bg.style.opacity)	bg.style.opacity=new_opacity/100;
				if(bg.filters)			bg.filters['alpha'].opacity=new_opacity;
				window.setTimeout('popup_fade2black()',5);
			}
			else
			{
				popup_2_show.style.display='';
			}
		}
	}	
	
	function popup_fade2white()
	{
		var bg=$('fade2black');
		var opacity;
		if(bg)
		{
			if(bg.style.opacity) opacity=bg.style.opacity*100;
			if(bg.filters) 		 opacity=bg.filters['alpha'].opacity;
			if(opacity>0) 
			{
				var new_opacity=opacity-20;
				if(bg.style.opacity)	bg.style.opacity=new_opacity/100;
				if(bg.filters)			bg.filters['alpha'].opacity=new_opacity;
				window.setTimeout('popup_fade2white()',5);
			}
			else 
			{
				bg.style.display='none';
			}
		}
	}
	var scrolledY = false;
	var gallery_images = new Array();
	function getGalleryImages(images)
	{
		// images = document.images;
		
		for(i=0; i<images.length; i++)
		{
			if(images[i].tagName.toUpperCase() == "IMG" || images[i].tagName.toUpperCase() == "A")
			{
				startsearchat = 0;
				if(images[i].tagName.toUpperCase() == "IMG")
				{
					xrel = images[i].alt;
					startsearchat_pre = xrel.indexOf("[");
					if(startsearchat_pre != -1) startsearchat = startsearchat_pre -7;
				}
				else xrel = images[i].rel;
				if(xrel && xrel.substr(startsearchat, 7) == "gallery")
				{
					// alert("7,1: "+xrel.substr(7, 1)+" | -1:"+xrel.substr(xrel.length-1, 1));
					if(xrel.substr(startsearchat+7, 1) == "[" && xrel.substr(xrel.length-1, 1) == "]")
					{
						xgallery = xrel.substring(startsearchat+8, parseInt(xrel.length)-1);
						// alert(xgallery);
						if(!gallery_images[xgallery]) gallery_images[xgallery] = new Array();
						xcnt = gallery_images[xgallery].length;
						gallery_images[xgallery][xcnt] = images[i];
						gallery_images[xgallery][xcnt].imgnr = xcnt;
						gallery_images[xgallery][xcnt].gallery = xgallery;
						images[i].onclick = new Function("show_image(gallery_images['"+xgallery+"']["+xcnt+"]); this.blur(); return false;");
						if(images[i].tagName.toUpperCase() == "IMG")
						{
							gallery_images[xgallery][xcnt].imgurl = images[i].src;
							images[i].alt = images[i].alt.substr(0, (images[i].alt.length - (9+xgallery.length)));
							// images[i].src="/image.php?src="+images[i].src.replace("http://"+window.location.host+"/", "")+"&w=150&h=150";
							// images[i].src="/image.php?src="+images[i].src+"&w=150&h=150";
							images[i].src=path_thumbnail.replace(/{image}/, images[i].src);
							images[i].style.cursor = "pointer";
						}
						else
						{
							gallery_images[xgallery][xcnt].imgurl = images[i].href;
						}
					}
					else
					{
						if(!gallery_images["no_rel"]) gallery_images["no_rel"] = new Array();
						xcnt = gallery_images["no_rel"].length;
						gallery_images["no_rel"][xcnt] = images[i];
						gallery_images["no_rel"][xcnt].imgnr = 0;
						gallery_images["no_rel"][xcnt].gallery = false;
						
						images[i].onclick = new Function("show_image(gallery_images['no_rel']["+xcnt+"]); this.blur(); return false;");
						if(images[i].tagName.toUpperCase() == "IMG")
						{
							gallery_images["no_rel"][xcnt].imgurl = images[i].src;
							images[i].alt = images[i].alt.substr(0, (images[i].alt.length-15));
							// images[i].src="/image.php?src="+images[i].src.replace("http://"+window.location.host+"/", "")+"&w=150&h=150";
							// images[i].src="/image.php?src="+images[i].src+"&w=150&h=150";
							images[i].src=path_thumbnail.replace(/{image}/, images[i].src);
							images[i].style.cursor = "pointer";
						}
						else
						{
							gallery_images["no_rel"][xcnt].imgurl = images[i].href;
						}
					}
				}
			}
		}
		// alert(gallery_images);
	}
	function show_image(ximage)
	{
		img_src = ximage.imgurl;
		prev = "";
		next_i = "";
		xgal = ximage.gallery;
		if(xgal != false && xgal != 0)
		{
			img_key = ximage.imgnr;
			if(parseInt(img_key) > 0 && img_key != false)
			{
				prev = '<a href="#" onclick="show_image(gallery_images[\''+xgal+'\']['+(parseInt(img_key)-1)+']); return false;"><img src="/development/cybertronics/VAImageBox/vorheriges_bild.gif" alt="'+text_Zurueck+'"></a>';
			}
			if(parseInt(img_key) < parseInt(gallery_images[xgal].length)-1 && (img_key != false || img_key == "0"))
			{
				next_i = '<a href="#" onclick="show_image(gallery_images[\''+xgal+'\']['+(parseInt(img_key)+1)+']); return false;"><img src="/development/cybertronics/VAImageBox/naechstes_bild.gif" alt="'+text_Weiter+'"></a>';
			}
			// if(prev != "" && next_i != "") prev += '|';
		}
		$("fade2black").style.display = "";
		
		if(scrolledY == false)
		{
			if(window.pageYOffset) scrolledY = window.pageYOffset;
			else if(document.body.scrollTop) scrolledY = document.body.scrollTop;
			else if(document.documentElement.scrollTop) scrolledY = document.documentElement.scrollTop;
			else scrolledY = 0;
			// alert(scrolledY);
		}
		else window.scrollTo(0, scrolledY);
		
		xhtml = "";
		xhtml += '<table id="popup2show" class="'+innerCSSclass+'" cellpadding="0" cellspacing="10" border="0"';
		xhtml += ' style="margin-top:' + (parseInt(scrolledY)+100) + 'px;"'
		xhtml += '>';
		xhtml += '<tr>';
		xhtml += '<td style="padding:10px; background-color:#FFFFFF;">';
		
		xhtml += '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="'+innerCSSclass+'"><tr><td align="right"><img src="/development/cybertronics/VAImageBox/close.gif" alt="Schlie&szlig;en" title="Schlie&szlig;en" style="cursor:pointer;height:20px;width:20px;border:0px;" type="image" onClick="close_gallery(); return false;"><br>&nbsp;</td></tr></table>';
		xhtml += '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="'+innerCSSclass+'"><tr>';
		xhtml += '<td width="100%" align="center"><img src="" border="0" id="gallery_image" title="'+ximage.title+'"></td>';
		xhtml += '<td width="140" style="padding:6px; background-color:#f5f5f5;" valign="top">';
		xhtml += (ximage.title != "") ? ''+ximage.title :'';
		xhtml += '</td>';
		xhtml += '</table>';
		xhtml += '<br><a href="'+ximage.imgurl+'" target="_blank">'+strrchr("/", ximage.imgurl).substr(1)+'</a><br>';
		xhtml += '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="'+innerCSSclass+'"><tr>'
		xhtml += '<td width="33%" align="left">&nbsp;'+prev+'</td>';
		xhtml += '<td width="34%" align="center">';
		xhtml += (xgal) ? text_Bild+' '+(ximage.imgnr + 1)+" "+text_von+"blub3 "+(gallery_images[xgal].length) : '';
		xhtml += '</td>'
		xhtml += '<td align="right" width="33%">'+next_i+'</td></tr></table>';
		
		xhtml += '</td>';
		
		xhtml += '</tr>';
		xhtml += '</table>';
		$("blocker").innerHTML = xhtml;
		// $("gallery_image").src="/image.php?src="+img_src;
		$("gallery_image").src=path_image.replace(/{image}/, img_src);
		
		if($("info")) $("info").style.visibility = "hidden";
		
		popup_2_show = $('blocker');
		popup_fade2black();
	}
	function close_gallery()
	{
		$("blocker").innerHTML = "";
		$("blocker").style.display = "none";
		popup_fade2white();
		if($("info")) $("info").style.visibility = "visible";
		window.scrollTo(0, scrolledY);
		scrolledY = false;
	}
	var blind_gallery_images = new Array();
	function addBlindImage(imgsrc, title, xgallery)
	{
		if(!blind_gallery_images[xgallery]) blind_gallery_images[xgallery] = new Array();
		xcnt = blind_gallery_images[xgallery].length;
		blind_gallery_images[xgallery][xcnt] = new Object();
		blind_gallery_images[xgallery][xcnt].imgurl = imgsrc;
		// blind_gallery_images[xgallery][xcnt].imgnr = xcnt; // FEHLER DARF ERST BEI initGallery() REIN
		blind_gallery_images[xgallery][xcnt].gallery = xgallery;
		blind_gallery_images[xgallery][xcnt].title = title;
	}
	
	function initGallery()
	{
		body_el = document.getElementsByTagName("body")[0];
		//
		body_el.appendChild(fade2black);
		//
		body_el.appendChild(blocker);
		//
		imgs = document.getElementsByTagName("img");
		lnks = document.getElementsByTagName("a");
		getGalleryImages(imgs);
		getGalleryImages(lnks);
		//
		//if(blind_gallery_images.length > 0)
		// {
			// alert("blind");
			for(g in blind_gallery_images)
			{
				for(i in blind_gallery_images[g])
				{
					if(!gallery_images[g]) gallery_images[g] = new Array();
					xcnt = gallery_images[g].length;
					// alert(blind_gallery_images[g][i]);
					gallery_images[g][parseInt(xcnt)] = blind_gallery_images[g][i];
					gallery_images[g][xcnt].imgnr = xcnt;
					// alert(gallery_images[g][xcnt].imgurl + " ?= " + blind_gallery_images[g][i].imgurl);
				}
			}
		// }
		
	}