//to call the script, use this syntax:
//picWin('image.ext', 'image name')

//detect browser type
var isIE = (navigator.appName == "Microsoft Internet Explorer"
	&& parseInt(navigator.appVersion) >= 4) ? true : false;
var isNS = (navigator.appName == "Netscape" && 
	parseInt(navigator.appVersion) >= 4) ? true : false;
	
function openpicture(url)
{
	//this is just a dumby function, to make it seem this code does more than it really does
}

function picWin(url, alt)
{
	//set parameters for the image's window and open the window
	var winParms = 'copyhistory=no,directories=no,location=no,' +
		'menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=300,height=100';
	var pop = window.open('', 'fierypopup', winParms);

	//increment i if i is not equal to the max number of windows
	
	//create html to write to the new window
	var popString = '';
	
	popString += '<html>\r';	
	popString += '<head>\r';
	popString += '<title>Please wait for image to load...</title>\r';
	popString += '<script language="Javascript">\r';
	popString += 'var alt = "' + alt + '";\r';
	//popString += 'var alt = \'' + alt + '\';\r';
	popString += 'function winResize() {\r';
	if (isIE)
	{
		//get the height and width of the image
		popString += 'imgHeight = document.images[0].offsetHeight;\r'
		popString += 'imgWidth = document.images[0].offsetWidth;\r'

		//resize document body to dimensions of the image
		popString += 'document.body.height = Math.ceil(imgHeight);\r'
		popString += 'document.body.width  = Math.ceil(imgWidth);\r'

		//resize window to dimensions of the image
		popString += 'window.resizeTo(0, 0);\r'
		popString += 'window.resizeBy(Math.ceil(imgWidth)-91, Math.ceil(imgHeight)-71);\r'
		
		//center the image window on the screen and give it focus
		popString += 'var globalLeft = (screen.width - imgWidth) / 2;\r'
		popString += 'var globalTop  = (screen.height - imgHeight) / 2;\r'
		popString += 'window.moveTo(globalLeft, globalTop);\r'
		popString += 'window.focus();\r'

	}
	else if (isNS && parseInt(navigator.appVersion) >= 5)
	{
		popString += '\twindow.innerHeight = document.images[0].height;\r';
		popString += '\twindow.innerWidth = document.images[0].width;\r';
		popString += '\twindow.moveTo((screen.width - window.innerWidth) / 2, ';
		popString += '(screen.height - window.innerHeight) / 2);\r';
		popString += '}\r';
	}	

	else if (isNS)
	{
		//get the height and width of the image
		popString += 'imgHeight = document.images[0].height;\r'
		popString += 'imgWidth = document.images[0].width;\r'
		
		//resize window to dimensions of the image
		popString += 'window.innerHeight = imgHeight;\r'
		popString += 'window.innerWidth = imgWidth;\r'
		
		//center the image window on the screen and give it focus
		popString += 'var globalLeft = (screen.width - imgWidth) / 2;\r'
		popString += 'var globalTop  = (screen.height - imgHeight) / 2;\r'
		popString += 'window.moveTo(globalLeft, globalTop);\r'
		popString += 'window.focus();\r'

	}
	else
		alert("Please use a browser that is compatible with this script.");
	popString += 'document.title = alt;'

	popString += '}\r'	
	popString += '</script>\r';

	popString += '</head>\r';
	popString += '\r';
	popString += '<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" margin="0" onload="winResize()">\r';
	popString += '<img alt="' + alt + '" src="' + url + '">\r';
	popString += '</body>';

	//open the document in the window and write the image to it
	pop.document.open();
	pop.document.write(popString);
	pop.document.close();
}

