// PopUpWindow Scripts


function openWindow(url, name, width, height) {
	win = window.open(url, name, 'width=' + width + ',height=' + height + 
		              ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	win.focus();
}

function openScrollWindow(url, name, width, height) {
  	win = window.open(url, name, 'width=' + width + ',height=' + height + 
  		              ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0');
	win.focus();
}

function closeWindow() {
	window.close();
}

function openImgWindow(name, imgLoc, imgWidth, imgHeight, caption) {
	headCode = "<html>" +
		       "<head>" +
		       "<title>kappa alpha theta</title>" +
		       "<link rel='stylesheet' type='text/css' href='CSS/theta_popup.css' />" +
			   "<script language='javascript' src='Javascript/PopUpWindow.js'></script>" +
		       "</head>";
			   
	bodyCode = "<body>" +
			   "<div align='center'>" +
			   "<table width='" + (imgWidth+12) + "' border='0' cellspacing='0' cellpadding='0'>" +
			   "<tr>" +
			   "<td>" +
			   "<table width='" + (imgWidth+12) + "' height='" + (imgHeight+12) + "' border='0' cellpadding='0' cellspacing='0' bgcolor='#000000'>" +
			   "<tr> " +
			   "<td align='center' valign='middle'><table width='" + (imgWidth+8) + "' height='" + (imgHeight+8) + "' border='0' align='center' cellpadding='2' cellspacing='0' bgcolor='#EFEFEF'>" +
		       "<tr>" +
	           "<td><table width='" + (imgWidth+4) + "' height='" + (imgHeight+4) + "' border='0' cellpadding='2' cellspacing='0' bgcolor='#000000'>" +
               "<tr> " +
               "<td><img src='" + imgLoc + "' width='" + imgWidth + "' height='" + imgHeight + "'></td>" +
               "</tr>" +
               "</table></td>" +
     		   "</tr>" +
        	   "</table></td>" +
			   "</tr>" +
			   "</table>" +
			   "</td>" +
			   "</tr>";
			   
	if (caption) {
		capCode = "<tr>" +
      		   	  "<td height='20' class='CaptionText'><div align='center'><strong>" + caption + "</strong></div></td>" +
			      "</tr>" +
				  "<tr>" +
			      "<td class='ERSubCategoryTextOnBlack'><div align='center'><a href='javascript:closeWindow()'>close window</a></div></td>" +      		   
			      "</tr>";
	} else {
		capCode = "<tr>" +
			      "<td height ='20' class='ERSubCategoryTextOnBlack'><div align='center'><a href='javascript:closeWindow()'>close window</a></div></td>" +      		   
			      "</tr>";
	}
	
	
	bottCode = "</table>" +
			   "</div>" +
			   "</body>" +
			   "</html>";
			   
	code = headCode + bodyCode + capCode + bottCode;
	
	winWidth = imgWidth + 50;
	if (caption)
		winHeight = imgHeight + 70;
	else
		winHeight = imgHeight + 54;
	
	if (screen.width < winWidth || (screen.height-60) < winHeight) {
		if (screen.width < winWidth)
			winWidth = screen.width - 20;
		if ((screen.height - 60) < winHeight)
			winHeight = screen.height - 75;
			
		capWindow = window.open('', name, 'width=' + winWidth + ',height=' + winHeight +',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
	} else {
		capWindow = window.open('', name, 'width=' + winWidth + ',height=' + winHeight +',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	}
	capWindow.document.open();
	capWindow.document.write(code);
	capWindow.document.close();
	capWindow.focus();
}