// Based on JavaScript provided by Peter Curtis at www.pcurtis.com
// This JavaScript Document positions the popup at 
// a fixed spot on the birds searchpages
// Do not change without thought!
var newwindow;
var wheight = 0;
var wwidth = 0;
var type = 'x'

function popdick(type, url, title, iwidth, iheight) {
var pwidth, pheight;
if (title == '') var title='Popup';
if (iwidth > 500) {iwidth = 4/5*iwidth; iheight=4/5*iheight;}
if ( !newwindow || newwindow.closed ) {
	pwidth=iwidth+10;
	pheight=iheight+10;
	newwindow=window.open('','htmlname','width='+pwidth+',height='+pheight+',scrollbars=0,resizable=1,menubar=0,linkbar=0,status=0,toolbar=0,location=0,top=125,left=695');
	wheight=iheight;
	wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
	pwidth=iwidth+20;
	pheight=iheight+80;
	newwindow.resizeTo(pwidth, pheight);
	wheight=iheight;
	wwidth=iwidth;
}
// if (type=="txt") {alert(type);}
//newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title>');
newwindow.document.writeln('<link href=\"'+root+'required/css/popup.css\" rel=\"stylesheet\" type=\"text/css\" /> ')
newwindow.document.writeln('<\/head><body onblur=\"self.close()\" onload=\"self.focus()\">');
newwindow.document.writeln('<div id=\"preview\"><img oncontextmenu=\"return false\" src=..\/'+url+' title=\"'+title+'\" alt=\"'+title+'\" width=\"'+iwidth+'\" height=\"'+iheight+'\" ><\/div>');
if (type=='but') {
newwindow.document.writeln('<div id=\"winclose\"><input class=\"button\" type=\"submit\" value=\"Close\" onclick=\"javascript: self.close ()\"\/></div>');}
else if (type=='txt') {
newwindow.document.writeln('<div id=\"winclose\"><a href=\"javascript: self.close ()\">Close this window</a></div>');}
else {
newwindow.document.writeln('<div id=\"winclose\"><a href=\"javascript: self.close ()\"><img src=\"..\/required\/images\/close2.png\" alt=\"close popup\"></a></div>');}
newwindow.document.writeln('<\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}

// Routines to tidy up popup windows when page is left
// Call with an onUnload="cleanup()" in body tag

function cleanup() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

