var newWindow;
var isOpen;
var imgHeight;
var imgWidth;

var newImage;
var imgurl1;
var img1;
var newName;
var newSchool;
var newTitle;
var newTeacher;

var xdim;
var ydim
var locx;
var locy; 

function createWindow(imgurl,name,school,title,teacher)
{
	//alert (imgurl+", "+name+", "+school+", "+title+", "+teacher);
  var browser=navigator.appName;  
 
  if (browser=="Netscape")
  {
     netscapeWindow(imgurl,name,school,title,teacher);
  }
  else
  {
      explorerWindow(imgurl,name,school,title,teacher);
  }
}

//-----------------------------------------------------------------
//NETSCAPE - RUN THIS SCRIPT
//-----------------------------------------------------------------
function netscapeWindow(image,name,school,title,teacher)
{
	if(isOpen==1)
	{
		isOpen=0;
		newWindow.close();
	}
	
	newImage=new Image();
	newImage.src=image;
	newName=name;
	newSchool=school;
	newTitle=title;
	newTeacher=teacher;	
	
	fromLeft=(screen.width/2)-125;
	fromTop=((screen.height)/2)-100;
	loadWindow = window.open("/loader.htm","loader","height=200,width=250,top=" + fromTop + ",left=" + fromLeft + ",screenY=" + fromTop + ",screenX=" + fromLeft);
}

function getImageSize()
{
	loadWindow.close();
			
	imgHeight=newImage.height + 135;
	imgWidth=newImage.width + 34;
	fromLeft=((screen.width - imgWidth)/2)+100;
	fromTop=((screen.height - imgHeight)/2);
	openWindow();	
}

function openWindow()
{
	newWindow = window.open("","", "height=" + imgHeight + ",width=" + imgWidth + ",top=" + fromTop + ",left=" + fromLeft + ",screenY=" + fromTop + ",screenX=" + fromLeft + ",location=0,menubar=0,resizable=0,scrollbars=0,status=0")
	
	isOpen=1;

	newWindow.document.write("<body bgcolor='#ffffff' link='#647779' alink='647779' vlink='#a1a1a1' leftmargin=5 topmargin=5 marginwidth=5 marginheight=5>");
	newWindow.document.write("<html><title>")
	newWindow.document.write(newName)
	newWindow.document.write(" - \"")
	newWindow.document.write(newTitle)
	newWindow.document.write("\"")
	newWindow.document.write("</title>")
	newWindow.document.write("<table width=100% cellspacing=0 cellpadding=4 border=0>")
	newWindow.document.write("<tr><td align=center>")
	newWindow.document.write("<img src=" + newImage.src + " border=2>")
	newWindow.document.write("</td></tr>")
	newWindow.document.write("<tr><td align=center>")
	newWindow.document.write("<font face=arial,helvetica,sans-serif size=2><b>")
	newWindow.document.write(newName)
	newWindow.document.write("</b><br>")
	newWindow.document.write(newSchool)
	newWindow.document.write("<br>")
	newWindow.document.write("\"")
	newWindow.document.write(newTitle)
	newWindow.document.write("\"<br>")
	newWindow.document.write(newTeacher)
	newWindow.document.write("<br><br>");
 newWindow.document.write("<a href='javascript: parent.focus(); self.close();' target='_self'>Close</a>");
 newWindow.document.write("</font>")
	newWindow.document.write("</td></tr>")
	newWindow.document.write("</table></body></html>")	
}

//-----------------------------------------------------------------
//EXPLORER - RUN THIS SCRIPT
//-----------------------------------------------------------------

function explorerWindow(imgurl,name,school,title,teacher)
{
  locx=screen.width*0.5-125;
  locy=screen.height*0.5-100;

  loadWindow = window.open("/loader.htm","loader","height=200,width=250,top=" + locy + ",left=" + locx + ",screenY=" + locy + ",screenX=" + locx + "scrollbars=0,resizeable=0");

   newName=name;
   newSchool=school;
   newTitle=title;
   newTeacher=teacher;  
  
   imgurl1 = imgurl;
   var img = document.createElement('IMG'); 
 
   img.onload = loadPopup;
  

   //alert('got here');
   img1 = document.createElement('IMG');
   img1 = img;
   img.src = imgurl;
 }

function loadPopup() {	
	
loadWindow.close();

xdim = img1.width;
ydim = img1.height;	
	 
locx = ((screen.width - xdim)*0.5)+100;
locy = ((screen.height - ydim)*0.5)-100;

	if(locx <= 0){
		locx = 0;
	}
	if(locy <= 0){
		locy = 0;
	}
  	xdim=xdim+20; 
	ydim = ydim + 145;
	
	var winprops = 'height='+ydim+',width='+xdim+',top='+locy+',left='+locx+',location=0,menubar=0,resizable=0,scrollbars=0,status=0';
 	var OpenWindow=window.open("", "" ,winprops);
	
	OpenWindow.name  = imgurl1;
    
	OpenWindow.document.write("<html><title>" + newName + " - \"" + newTitle + "\"</title>"); 
    OpenWindow.document.write("<body bgcolor='#ffffff' link='#647779' alink='647779' vlink='#a1a1a1' leftmargin=5 topmargin=5 marginwidth=5 marginheight=5>");
    OpenWindow.document.write("<center>");
    OpenWindow.document.write("<img src="+ imgurl1+ " border=2>");
    OpenWindow.document.write("<br><br>");
    OpenWindow.document.write("<font face='arial,helvetica,sans-serif' size=2>");   
    OpenWindow.document.write("<b>" + newName + "</b>");
    OpenWindow.document.write("<br>");
    OpenWindow.document.write(newSchool);
    OpenWindow.document.write("<br>");
    OpenWindow.document.write("\"" + newTitle + "\"");
    OpenWindow.document.write("<br>");
    OpenWindow.document.write(newTeacher);
    OpenWindow.document.write("<br><br>");  
    OpenWindow.document.write("<a href='javascript:self.close()' target='_self'>Close</a>");
    OpenWindow.document.write("</font>"); 
    OpenWindow.document.write("</center></body></html>");
    var xdim = img1.width + 20;
    var ydim = img1.height;
    
    //alert(this.width + 'x' + this.height);
  }
