//---------------------------------------------------------------
// Opacity Displayer, Version 1.0
// Copyright Michael Lovitt, 6/2002.
// Distribute freely, but please leave this notice intact.
//---------------------------------------------------------------

//---------------------------------------------------------------
// OPACITY DISPLAY FUNCTION
// Outputs the image as an inline-block with the AlphaImageLoader, or with
// a standard image tag.
// Modifications:	13-Sep-2007	Image is now contained in an inline-block (instead of a div).
//					29-Nov-2007 Bottom offset correction added to "filter" displayed images, to line up with "normal" displayed images.
//					30-Nov-2007 Function input parameter added to transfer specific img attributes, like e.g. usemap.
//					26-Jan-2008 SizingMethod changed for cases where image width and height are not specified.
//								(but without success for IAIN logo: images are only displayed when size is specified)

function displayImage(strId, strPath, intWidth, intHeight, strClass, strAlt, strImgAtt)
{

	//Eliminate width and height properties from the div and img tag when image width and height are not specified.
	if (intWidth =="")	
		{widthStyle = ''; imgWidth = ''; sizing = ', sizingMethod=\'image\' '}
	else				
		{widthStyle = 'width:' + intWidth + 'px; '; imgWidth = 'width="' + intWidth + '" '; sizing = ', sizingMethod=\'scale\' ' }
	if (intHeight=="")
		{heightStyle = ''; imgHeight = ''; sizing = ', sizingMethod=\'image\' '}
	else
		{heightStyle = 'height:' + intHeight + 'px; '; imgHeight = 'height="' + intHeight + '" '; sizing = ', sizingMethod=\'scale\' '}

	if (pngAlpha) 
	{	string = '<span ' +
				    'style="' +
						'display:inline-block; ' +
				 		widthStyle +
				 		heightStyle +
				 		'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader ' +
				 			'(src=\'' + strPath + '.png\' ' +
							sizing + '); ' +
						'margin-bottom:3px; ' +				//To correct mismatch with normal png display
					'" ' +
//				 	'name="' + strId + '" ' +
//				 	'class="' + strClass + '" ' +
//				 	'alt="" ' +
				 	strImgAtt + ' ' +
				 '>' +
				 '<\/span>';
	}
	else if (pngNormal)
	{	string = '<img ' +
				 	'src="' + strPath+'.png" ' +
				 	imgWidth +
				 	imgHeight +
				 	'name="' + strId + '" ' +
				 	'border="0" ' +
				 	'class="' + strClass+ '" ' +
				 	'alt="' + strAlt + '" ' +
				 	strImgAtt +
				 	'>';
	}
	else
	{	string = '<img ' +
				 	'src="' + strPath + '.gif" ' +
					imgWidth +
					imgHeight +
					'name="' + strId + '" '+
					'border="0" ' +
					'class="' + strClass + '" ' +
					'alt="' + strAlt + '"' +
					strImgAtt +
					'>';
	}

//D	window.alert('Function displayImage:' +
//D			'\nHTML string: ' + string)

	document.write(string);
}
//---------------------------------------------------------------

//---------------------------------------------------------------
// Set global variables
if ((browser.isIE55 || browser.isIE6up) && browser.isWin32)
{	// If IE5.5+ on win32, then display PNGs with Microsoft's AlphaImageLoader
	var pngAlpha = true;

//D	window.alert('Function Opacity: ' +
//D		'\nBrowser can display PNGs when using AlphaImageLoader')
}
else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast))
{	// Else, if the browser can display PNGs normally, then do that. That list includes:
	//     -Gecko Engine: Netscape 6 or Mozilla, Mac or PC
	//     -IE5+ Mac (OpacityObject applies the background image at 100% opacity)
	//     -Opera 6+ PC
	//     -Opera 5+ Mac (Doesn't support dynamically-set background images)
	//     -Opera 6+ Linux
	//     -Omniweb 3.1+
	//     -Icab 1.9+
	//     -WebTV
	//     -Sega Dreamcast

	var pngNormal = true;

//D	window.alert('Function Opacity: ' +
//D		'\nBrowser can display PNGs')
}
else
{	// Otherwise, use plain old GIFs

//D	window.alert('Function Opacity: ' +
//D		'\nBrowser cannot display PNGs, switch-over to GIFs')
}
