images = new Array();
function createGallery(images, objektId)
{
	var image_links = "";
	for(var i=0; i < images.length; i++){
		//image_links += "<a href='javascript: pImage(\"" + images[i] + "\");' class='redButtonGallery'>[" + (i +1 ) +"]</a> \n\r";
		image_links += "<a href='javascript: pImage(\"" + images[i] + "\","+objektId+");' ><img src='images/cache/" + images[i] +"'  width='80' height='52'></a> \n\r";
	}
	
	var newDiv = document.createElement('div');
	newDiv.setAttribute("id","imageHolder");
	var mainDivStyle = "";
	if(navigator.appName == "Microsoft Internet Explorer"){
		mainDivStyle = "position: relative;  background-color: #999999; ";
		mainDivStyle += " padding: 50px; overflow: hidden; z-index: 1;  top: 2px; top: 5%; left: 5%; width: 90%; height: 90%;";
	} else {
		mainDivStyle = "position: absolute;  background-color: #999999; ";
		mainDivStyle += " padding: 5px; overflow: hidden; z-index: 1;  top: 2px; top: 5%; left: 5%; width: 90%; height: 90%;";
	}
	
	newDiv.setAttribute("style",mainDivStyle);
	newDiv.innerHTML = "<div style='color: #FFFFFF; position: relative; margin-top: 5px;'><a href='javascript: stopGallery()' class='redButtonGallery'>zur&uuml;ck</a> &nbsp; <span id='imgPrint'> <a href='javascript: printImage(\"images/cache/" + images[0] + "\"," + objektId +");' class='redButtonGallery'>Bild drucken</a> </span></div> \n\r"
	newDiv.innerHTML += "<div class='redButtonGalleryTh'>" + image_links + "</div> <br /> \n\r ";
	newDiv.innerHTML += '<div id="imageDisplay"><img src="images/cache/' + images[0] + '" height="400"  onclick="javascript: this.style.height = \'550px\';"> </div> <br /><br /><br /> \n\r';
	
	
	document.getElementById('galMainWin').style.visibility = "visible";
	document.getElementById('galMainWin').appendChild(newDiv);
}
function pImage(image, objektId)
{
	document.getElementById("imageDisplay").innerHTML = " <img src='images/cache/" + image +"' height='400' onclick='javascript: this.style.height = \"550px\";'>";
	document.getElementById("imgPrint").innerHTML = "<a href='javascript: printImage(\"images/cache/" + image + "\"," + objektId +");' class='redButtonGallery'>Bild drucken </a>";
	//document.getElementById("imgPrint").innerHTML = null;
}
function stopGallery()
{
	document.getElementById("galMainWin").removeChild(document.getElementById("imageHolder"));
	document.getElementById("galMainWin").style.visibility = "hidden";
}

function printImage(image, objektId){
	window2 = window.open("","window2", "width=600, height=600, left=150, top=150, dependent=yes, resizable=yes");
	with(window2.document){
		open("text/html", "replace");
		writeln("<body style='font-family: arial;' onload='javascript: print(); window.close();'>");
		writeln("<span style='font-weight: bold;'>Objekt Nummer: "+ objektId +"</span><br />");
		writeln("BEST-SELECT Immobilienverwertungs GmbH, Schweglerstrasse 53, 1150 Wien");
		writeln("<br>T: +43/1/942 77 00 F: +43/1/942 77 00 E-Mail: office@best-select.at");
		writeln("<img src='" + image + "'>");
		writeln("</body>");
		close();
	}
}
