// Created By		:	N Pattman	19 Apr 2001
// Change History	:	N Pattman	20-Jun-2001 Shelled from old browsers with HTML comments
//					:	J Goodall	21 Apr 2004 general tarting-up
//					:	J Goodall	13 Sep 2005	Removed references to CSSs, inline styles used instead
//					:	J Goodall	28 Sep 2005 Fixed so that scrollbars appear (to accommodate larger images)
//					:	D Walker	21 Dec 2006 Company Rename
//
// Purpose			:   Opens a window and displays an image in it
//
// Tested on IE 4 and NN 3.02 - Stylesheet doesn't work on NN3.02
//



function Preview(pstrImagePath, pstrAltTag, pstrHeading, pstrDescription) 
{
		
		var strHTML = '<html><head><title>Preview Image</title></head>'; 
		
		//Open the window
		writeWin = window.open('','aWin','toolbar=0,location=0,directories=0,status=1,menubar=0,top=0,left=0,scrollbars=1,resizable=1,width=450,height=450'); 
				
		//Declare the document - Note - this has to be done after the above line
		var wd = writeWin.document;

		//Write Header
		strHTML += '<body style="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 80%; background-color: #FFFFFF; color: #000000; margin: 0px"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" style="border-left: 1px solid #3A5A7A; border-right: 1px solid #3A5A7A"><tr><td style="background-color: #235099; border-right: 1px solid #2C5CA3; border-bottom: 1px solid #2C5CA3; height: 42px; background-image: url(/_RMVirtual/Images/image_preview_header.png); background-repeat: no-repeat">&#160;</td></tr>';

		//Check for heading
		if (pstrHeading != null)
		{
			if (pstrHeading.length > 0)
			{
				strHTML += '<tr><td style="text-align: center; padding: 10px; font-size: 85%; color: #5D76B1; font-weight: bold">' + pstrHeading + '</td></tr>';
			}
		}
		
		// if we have an image path add in image- otherwise display Error Message
		if (pstrImagePath.length > 0)
		{
			// Make sure that we have an ALT tag - otherwise default to below text
			
			if (pstrAltTag != null)
			{
				if (pstrAltTag.length < 1) 
				{//have an empty string
					pstrAltTag = 'Here is an enlarged version of the image';
				}
			}
			else
			{//have a null string
					pstrAltTag = 'Here is an enlarged version of the image';
			}
			
			
			strHTML += '<tr><td style="text-align: center; padding-top: 14px"><img src=' + pstrImagePath + ' alt="' + pstrAltTag + '"></td></tr>';
		
		}
		
		else
		
		{
			strHTML += '<tr><td align="center" style="text-align: center; padding-bottom: 10px; font-size: 85%; color: #5D76B1; font-weight: bold">Error - No image found</td></tr>';
		}
		
		// If we have a description add it below the image
		if (pstrDescription != null)
		{
			if (pstrDescription.length > 0)
			{
				strHTML += '<tr><td style="text-align: center; padding: 10px; font-size: 85%; font-weight: bold">' + pstrDescription + '</td></tr>';
			}
		}

		
		strHTML += '<tr><td valign="top" style="text-align: center; padding-top: 20px"><form action="Javascript:window.close();"><input type="submit" value="Close Window" style="width: 90px; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #000000; background-color: #C2C6DA; padding-left: 2px; padding-right: 2px; border: 1px solid #003C73; font-weight: normal; height: 20px; cursor: pointer; cursor: hand; background-image: url(/_RMVirtual/Images/button_bg.gif)" /></form></td></tr>';

		strHTML += '<tr><td style="font-size: 80%; height: 25px" valign="bottom"><div style="font-size: 85%; text-align: center; padding-bottom: 3px; padding-top: 3px; background-color: #DDE6F6; background-image:url(/_RMVirtual/Images/footer/corporate_footer_bg.gif); background-repeat: repeat-x; border-top: 1px solid #3A5A7A; border-bottom: 1px solid #3A5A7A; ">&copy; Copyright RM Education plc<!--, 1997 - <%=Year(Date)%>-->. All rights reserved.</div></td></tr>';

		strHTML += '</table></body></html>';
		
		// plonk the HTML into the window and we're done
		
		wd.open();
		wd.write(strHTML);
		wd.close();
}