/**
* written by Johannes Fitz
* you can copy and reuse this code without my knowledge
**/

function openModal(url, name, x, y, width, height)
{
		params = "left=" + x + ",top=" + y + ",width=" + width + ",height=" + height 
		 + ",toolbar=no,resizable=no, scrollbars=no, status=no";
		window1 = window.open(url, name, params);
		window1.focus();
}

function viewPhoto(sURL)
{
    var oPhotoWindow = window.open(sURL, "Photos", "width=520,height=520,menubar=no,scrollbar=no,locationbar=no");
	oPhotoWindow.focus();
}
  
function viewPhoto2(thumb)
{
	var path = null;
	var index = null;
	var imageName = null;
	var eventName = null;
	var photo = null;
	var width = 0;
	var height = 0;
	var factor = 0;

	// get the path for the photo from the thumb-object
	path = thumb.src;
	index = path.lastIndexOf("/");
	imageName = path.substring(index+1);
	path = path.substring(0, index);
	index = path.lastIndexOf("/");
	eventName = path.substring(index+1);
	photo = "../../photos/" + eventName + "/" + imageName; 

	// calculate width and height of the window	
	if (thumb.width > thumb.height)
		factor = 500.0 / thumb.width;	
	else	                                
		factor = 500.0 / thumb.height;	
		
	width = Math.ceil(thumb.width*factor)+18;
	height = Math.ceil(thumb.height*factor)+38;

	// open the window and resize it to the proper size
	var photoWindow = window.open("", "Photos", "width=" +width+",height="+height+",menubar=no,scrollbar=no,locationbar=no");
	photoWindow.resizeTo(width, height);

	// Write new document
	photoWindow.document.close();
	photoWindow.document.writeln("<html><head><title>Musikverein Baumgartenberg - Photos</title></head>");
	photoWindow.document.writeln("<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>");
	photoWindow.document.writeln("<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0'>");
	photoWindow.document.writeln("<tr valign='bottom'><td align='center'>");
	photoWindow.document.writeln("<img name=photo src='"+photo+"'>");
	photoWindow.document.writeln("</td></tr></table>");
	photoWindow.document.writeln("</body></html>");

	// Focus the window
	photoWindow.focus();
}
