/* ****************************************************************** 

File:        	popup.js
Created on:  	01.06.2007
Changed on:		
Created by:  	Jochen Schneider                                
Description:	open a browser window align center by width and height

TODO:	
- Fenster mittig ausrichten
- gesamter Test auf Firefox
- Fenster schon geöffnet? Ja -> Aktualisieren und fokussieren, wenn nein öffnen
- popup schliessen onblur->closeWindow() in Header einbauen, wenn Vorlage soweit fertig

****************************************************************** */

var windowHandle	=	null;

function openWindow(fileName, _width, _height, _description, alt, title)
{
	if (!fileName) 
		return(false); 

	picture											=	null;
	tableLeftRightColumnWidth		=	10;
	tableTopBottomRowHeight			=	10;
	tableDescriptionHeight			=	40;
	windowScreenOffset					=	120;
	
	//	original picture width larger then screen width?
	if (((2*tableLeftRightColumnWidth) + _width) > screen.width) {
		_origWidth	=	_width;
		_width			=	screen.width - (2*tableLeftRightColumnWidth) - windowScreenOffset;
		_height			=	_width * (_height/_origWidth);
	}
	
	//	original picture height larger then screen height?
	if (((2*tableTopBottomRowHeight) + tableDescriptionHeight + _height) > screen.Height) {
		_origHeight	=	_height;
		_height			=	screen.Height - (2*tableTopBottomRowHeight) - tableDescriptionHeight - windowScreenOffset;
		_width			=	_height * (_width/_origHeight);
	}
	
	tableWidth							=	2*tableLeftRightColumnWidth + _width;
	windowWidth							=	tableWidth;//2*tableLeftRightColumnWidth + _width;
	windowHeight						=	2*tableTopBottomRowHeight + _height + tableDescriptionHeight;
	windowPositionX					=	(screen.width - windowWidth) / 2;
	windowPositionY					=	(screen.Height - windowHeight) / 2;

	//alert(windowWidth);
	//alert(windowPositionX);
	//alert(_width);
	//alert(_height);
	
	
	if (!windowHandle || windowHandle.closed)	{
		windowHandle	=	window.open('','_blank',"resizable=yes,toolbar=no,menubar=no,top="+windowPositionY+",left="+windowPositionX+",width="+windowWidth+",height="+windowHeight);
	
		windowHandle.document.write(	'<html><head><title>DKFZ</title></head>'
   																	+'<body  style="margin:0px;padding:0px" bgcolor=white onLoad="self.focus()">'
   																	+'<table border="0" cellspacing="0" cellpadding="0" width="'+tableWidth+'">'
   																	+'<tr><td colspan="3" height="'+tableTopBottomRowHeight+'"><img src="/global/images/spacer.gif" width="1" height="'+tableTopBottomRowHeight+'"></tr>'
   																	+'<tr><td width="'+tableLeftRightColumnWidth+'"><img src="/global/images/spacer.gif" width="'+tableLeftRightColumnWidth+'" height="1"></td><td><img src="'+fileName+'" width="'+_width+'" height="'+_height+'"></td><td width="'+tableLeftRightColumnWidth+'"><img src="/global/images/spacer.gif" width="'+tableLeftRightColumnWidth+'" height="1"></td></tr>'
   																	+'<tr><td colspan="3" height="'+tableTopBottomRowHeight+'"><img src="/global/images/spacer.gif" width="1" height="'+tableTopBottomRowHeight+'"></tr>'
   																	+'<tr><td></td><td><span style="font-family: Verdana;font-size:0.7em;">'+_description+'</span></td><td></td></tr>'
   																	+'</table>'
   																	+'</body></html>');
		windowHandle.document.close();
  	return(true);
  }
	else {
		windowHandle.focus();
		windowHandle.document.write('<a href="javascript:Wechsel()">Noch steh ich hier</a>');

	}
}

function closeWindow()
{ 
	if (windowHandle && !windowHandle.closed) { 
		windowHandle.close(); 
		windowHandle = null; 
	}
}


