<!-- // begin
/*
©2002 M.Fridholm, scatcat@passagen.se, 
this script is free for use and modification as long as you keep this message...
*/

// maximum sizes for the picture width and height
var widthLimit = 600;
var heightLimit = 900;

// functions for testing the height and width of the current invoking element
function heightTest(h){
var test = heightLimit-h;
if (test >= 0) { test = 1; }
else { test = heightLimit/h; }
return test;
}

function widthTest(w){
var test = widthLimit-w;
if (test >= 0) { test = 1; }
else { test = widthLimit/w; }
return test;
}

// function to open new window with a title, url for a picture, width and height
function newWin( myTitle,myURL,myWidth,myHeight ){

// the testing of current width and height
var wProp = widthTest(myWidth);
var hProp = heightTest(myHeight);
var prop = hProp - wProp;

// scaling if necessary
if (prop <= 0){
myHeight = parseInt(myHeight*hProp);
myWidth = parseInt(myWidth*hProp);
}
else {
myHeight = parseInt(myHeight*wProp);
myWidth = parseInt(myWidth*wProp);
}

// the opener sequence, first the standard attributes
var winAttribBasic = "width=100,height=100,";
winAttribBasic += "fullscreen=0,scrollbars=0,toolbar=0,menubar=0,status=0,resizable=1,";

// then Netscape attributes to kill directories and dependencies
var winAttribExtend = "directories=0,dependent=0,";

// lastly opening the window with the current attributes
var winRef = window.open('','winRef',winAttribBasic + winAttribExtend); 

// moving the window to the center of the available screen
var winPosX = parseInt(screen.availWidth/2 - myWidth/2);
var winPosY = parseInt(screen.availHeight/2 - myHeight/2 - 30);
winRef.moveTo( winPosX, winPosY );

// setting the window size to accomodate the picture
winRef.resizeTo( myWidth, myHeight );

// adding to height to accomodate for "window.close"-link and the window-bar
winRef.resizeBy( 0, 60 );

// the source for the new window
mySource = "<html>\n<head>\n<title>"+myTitle+"</title>\n</head>\n";
mySource += "<body style=\'margin: 0px; background-color: #999;\'>\n";
mySource += "<img src=\'"+myURL+"\' width=\'"+myWidth+"\' height=\'"+myHeight+"\'>\n";
mySource += "<div align=\'right\' style=\'margin-right: 5px\'>\n";
mySource += "<a href=\'javascript:self.close\(\)\' style=\'color: #fff; font-size: xx-small; ";
mySource += "font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;";
mySource += " text-decoration: none;\'>\n";
mySource += "Stäng Fönster\n</font></a>";
mySource += "</div>\n</body></html>";

// appending the source to the child-window
	with (winRef.document) {
	open("text/html", "replace");
	write(mySource);
	close();
	}

// focusing the child window
winRef.focus();
}

// end -->