#ifndef included_common
#define included_common
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <vector>
#include "moreString.h"
#include "movie.h"
#include "time.h"
#include <assert.h>
#include "forest.h"

using namespace std;
 
enum colors
{
	black,	 blue,   green,   cyan,   red,   purple,   yellow,   white, 
	BRblack, BRblue, BRgreen, BRcyan, BRred, BRpurple, BRyellow, BRwhite
};
enum keys
{	KEY_UP=72,	KEY_DOWN=80,	KEY_LEFT=75,	KEY_RIGHT=77 };
enum direction
{	DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT };

struct position
{
	int row;
	int col;
};

class sysConfig
{
	private:
	string managerPassword;
	string myConfigFile;
	bool shutdownFlag;

	public:
	sysConfig(string configFile="system.cfg");
	bool isManagerPassword(string tryPassword);
	bool saveNewPassword(string newPass);
	bool getShutdownFlag();
	void setShutdownFlag();
};

const int SCREEN_WIDTH=80;
const int SCREEN_HEIGHT=23;
const int MIN_PASSWORD_LENGTH=5;

// max limitations set to be able to use binary files
const long MAX_CUSTOMERS=100000;//   100,000
const long MAX_MOVIES=1000000;	// 1,000,000

const char MOVIES_FILE[]="movies.dat";
const char NOTIFY_FILE[]="notifications.dat";

void setScreenPos(int row, int col);
void setScreenPos(position pos);
void setColor(int foreground, int background);
void drawBorder(position topLeft, unsigned int width, unsigned int height, string header="");
void removeBorder(position topLeft, unsigned int width, unsigned int height);
void setStatus(string statusText);

void alert(string message, int FGcolor=BRyellow, int BGcolor=BRred, string header="ALERT");
string passwordPrompt(char echoCharacter=NULL, unsigned int maxLength=0);
string standardPrompt(int foreColor=BRgreen, int backColor=black, unsigned int maxLength=0);
bool safeFilename(string filename);
bool doesFileExist(string filename);

time_t makeTimestamp(int month, int day, int year, int hour=12, int minute=0, int second=0);
string makeDate(time_t timeStamp, bool includeTime=false);
time_t add100Years(time_t);

void listMovies(forest &, customer *, bool managerAccess=false);

#endif