/*********************************************************/
/* This source code copyright (c) 1991-2001, Aaron Giles */
/* See the Read Me file for licensing information.       */
/* Contact email: mac@aarongiles.com                     */
/*********************************************************/

#if THINK_C
#include "THINK.Header"
#elif applec
#pragma load ":Headers:MPW.Header"
#elif __MWERKS__
//#include "MW.Header"
#else
#include "JPEGView.h"
#endif

/*
 * HandleWindowChoice(theItem)
 *
 *     Purpose: Accepts menu events from the Window menu
 *      Inputs: theItem = the menu item number
 *     Returns: nothing
 *
 */
 
void HandleWindowChoice(short theItem) 
{
	ImageHandle theImage;
	
	switch (theItem) {
		case windowStatItem:
			if (GetStatWindow()) SendCloseWindow(GetStatWindow());
			else SendCreateWindow(kStatWindowID);
			break;
		case windowCommentsItem:
			if (GetCommentsWindow()) 
				gCommentsOpen = false, SendCloseWindow(GetCommentsWindow());
			else gCommentsOpen = true, SendCreateWindow(kCommentsWindowID);
			break;
		case windowColorsItem:
			if (GetColorsWindow()) SendCloseWindow(GetColorsWindow());
			else SendCreateWindow(kColorsWindowID);
			break;
		case windowPreviousItem:
			theImage = FrontImage();
			if (theImage) theImage = PreviousImage(theImage);
			if (!theImage) theImage = LastImage();
			SendMoveToFront((*theImage)->window);
			break;
		case windowNextItem:
			theImage = FrontImage();
			if (theImage) theImage = (*theImage)->next;
			if (!theImage) theImage = gImageRoot;
			SendMoveToFront((*theImage)->window);
			break;
		default:
			SendMoveToFront(IndexedDocument(theItem - windowFirstItem + 1));
			break;
	}
}
