/*
	'---------------------------------------------------------------------------------------------------
	' PAGE:			FUNCTIONS.JS
	' PROGRAMMER:	MARK FLURY
	' DESCRIPTION:	THE FUNCTIONS PAGE CONTAINS COMMONLY USED JAVASCRIPT FUNCTIONS
	'---------------------------------------------------------------------------------------------------
*/

	// DECLARE VARIABLES
	var myWindow;


/*
	'---------------------------------------------------------------------------------------------------
	'
	' OPEN WINDOW IN THE CENTER OF THE SCREEN
	'
	'---------------------------------------------------------------------------------------------------
*/

	function doOpenWindow(sURL, sTitle, sWidth, sHeight, sScroll)
	{
		// OBTAIN THE LEFT AND RIGHT COORDINATES SO THE WINDOW CAN BE CENTERED
		var sLeft = (screen.width / 2) - (sWidth / 2);
		var sTop  = (screen.height / 2) - (sHeight / 2);

		// OPEN THE WINDOW
		myWindow = window.open(sURL,sTitle,'width='+sWidth+',height='+sHeight+',top='+sTop+',left='+sLeft+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+sScroll+',resizable=0,screenX='+sTop+',screenY='+sLeft);

		// SET THE WINDOW IN FOCUS
		myWindow.focus();
	}


/*
	'---------------------------------------------------------------------------------------------------
	'
	' OPEN IMAGE IN A POPUP WINDOW
	'
	'---------------------------------------------------------------------------------------------------
*/

	function doOpenImage(sImage)
	{
		// OPEN THE WINDOW		
		myWindow = window.open('','Image','width=100,height=100,top=0,left=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,screenX=100,screenY=100');
		
		// WRITE THE IMAGE TO THE WINDOW
		myWindow.document.write ("<html><head><title>Mark Flury - Pictures</title>");		
		myWindow.document.write ("<script language='JavaScript'>");
		myWindow.document.write ("function doResize(){");		
		myWindow.document.write ("var sWidth = document.imgPicture.width;");		
		myWindow.document.write ("var sHeight = document.imgPicture.height;");
		myWindow.document.write ("var sLeft = (screen.width / 2) - (sWidth / 2);");
		myWindow.document.write ("var sTop = (screen.height / 2) - (sHeight / 2);");		
		myWindow.document.write ("window.resizeTo(sWidth + 10, sHeight + 59);");
		myWindow.document.write ("window.moveTo(sLeft, sTop);");
		myWindow.document.write ("self.defaultStatus = 'MarkFlury.com - Pictures';}");		
		myWindow.document.write ("</script></head>");
		myWindow.document.write ("<body topmargin='0' leftmargin='0' bgcolor='#FFFFFF'>");
		myWindow.document.write ("<img src='"+sImage+"' name='imgPicture' onLoad='doResize()'>");
		myWindow.document.write ("</body></html>");
		myWindow.document.close();
		myWindow.focus();
	}


/*
	'---------------------------------------------------------------------------------------------------
	'
	' CLOSE ALL OPEN WINDOWS
	'
	'---------------------------------------------------------------------------------------------------
*/

	function doCloseWindow()
	{
		if(myWindow != null && !myWindow.closed)
			myWindow.close();		
	}