
function myXMLGet(src)
{
var myText;
var myAjax = new Ajax.Request(
	src, 
	{
		method: 'get', 
		asynchronous: false, 
		onComplete: function (originalRequest) {
			myText = originalRequest.responseText;
		}

	});

return myText;
}


var gallery;
function InjectGallery(
		title, topic,
		img1,text1,
		img2,text2,
		img3,text3,
		img4,text4,
		img5,text5,
		img6,text6,
		img7,text7,
		img8,text8		
		)
{
// document.observe('contextmenu', respondToClick);
function respondToClick(event) {
var element = event.element();
alert('(c) copyright Nils Dunkel');
event.stop();
return false;

}

	document.title=title;

	var g;
	g=myXMLGet("template.html");

	g=g.replace(/<!--@IMAGE1-->/,
		"<img id=\"STARTIMG\" src=\""+img1+"\" onmouseover=\"Zoom(this);\" alt=\""+text1+"\">\n");
	if (img2) {
		g=g.replace(/<!--@IMAGE2-->/,
		"<img class=\"ZIMAGE\" src=\""+img2+"\" onmouseover=\"Zoom(this);\" alt=\""+text2+"\">\n");
	}
	if (img3) {
		g=g.replace(/<!--@IMAGE3-->/,
		"<img class=\"ZIMAGE\" src=\""+img3+"\" onmouseover=\"Zoom(this);\" alt=\""+text3+"\">\n");
	}
	if (img4) {
		g=g.replace(/<!--@IMAGE4-->/,
		"<img class=\"ZIMAGE\" src=\""+img4+"\" onmouseover=\"Zoom(this);\" alt=\""+text4+"\">\n");
	}
	if (img5) {
		g=g.replace(/<!--@IMAGE5-->/,
		"<img class=\"ZIMAGE\" src=\""+img5+"\" onmouseover=\"Zoom(this);\" alt=\""+text5+"\">\n");
	}
	if (img6) {
		g=g.replace(/<!--@IMAGE6-->/,
		"<img class=\"ZIMAGE\" src=\""+img6+"\" onmouseover=\"Zoom(this);\" alt=\""+text6+"\">\n");
	}
	if (img7) {
		g=g.replace(/<!--@IMAGE7-->/,
		"<img class=\"ZIMAGE\" src=\""+img7+"\" onmouseover=\"Zoom(this);\" alt=\""+text7+"\">\n");
	}
	if (img8) {
		g=g.replace(/<!--@IMAGE8-->/,
		"<img class=\"ZIMAGE\" src=\""+img8+"\" onmouseover=\"Zoom(this);\" alt=\""+text8+"\">\n");
	}

	g=g.replace(/<td><!--@IMAGE[1-9]--><\/td>/g,"");

	$("GALLERY").innerHTML=g;
	$("galleryTopic").innerHTML=topic;
	

  	var startimg=$("STARTIMG"); 
	Zoom(startimg);
	Zoom(startimg);

}

var imgs=new Array();


var activeImage;


function Zoom(x)
{
	var zoomdiv=document.getElementById("ZOOM");
	if (zoomdiv && x) {
		zoomdiv.style.display='inline';
		var zoomimg=document.getElementById("ZOOMIMG");
		var tmp=x.src;
		tmp=tmp.replace(/\.jpg$/,"_b.jpg");
		zoomimg.src=tmp;
		activeImage=x;
//		alert(zoomim.height);
		zoomimg.height=$('THEIMAGE').height*0.88;
		//console.log($('THEIMAGE').height);
		//console.log(zoomimg.height);
		//zoomimg.width=350*scale;
		var ztext=document.getElementById("ZTEXT");
		ztext.innerHTML=x.alt;
	} else {
		// alert('no zoomdiv or x');
	}
}



function ResizeGallery()
{
	if (activeImage) {
		Zoom(activeImage);
	}
}

