//==========================================================
//WINDOW 1 - SYSTEM MENU
//==========================================================

//----------------------------------------------------------
//Window Addresse's
//----------------------------------------------------------
Fl_Double_Window*									men1;
	Fl_Value_Input*									men1_company_no;
	Fl_Button*											men1_company_spinner_up;
	Fl_Button*											men1_company_spinner_down;
	Fl_Output*											men1_company_desc;
	
	Fl_Box*													men1_decoration;
	Fl_Output*											men1_title;
		Fl_Radio_Round_Button*				men1_but1;
		Fl_Radio_Round_Button*				men1_but2;
		Fl_Radio_Round_Button*				men1_but3;
		Fl_Button*										men1_exit;

//----------------------------------------------------------
//Callbacks
//----------------------------------------------------------
void fmen1_SPINNER1_CALLBACK(Fl_Widget* w, void* data);
void fmen1_but1_callback(Fl_Widget* w, void* data);
void fmen1_but2_callback(Fl_Widget* w, void* data);

//----------------------------------------------------------
//WINDOW Menu1
//----------------------------------------------------------
void window1(){

	men1 = new Fl_Double_Window(20,40,300,250,"Systems Menu");

		x=70; y=10;

			men1_company_no = new Fl_Value_Input(x,y,30,20,"Company");

			men1_company_spinner_up = new Fl_Button(x+30,y,13,10,"@-38>");
				men1_company_spinner_up->callback(fmen1_SPINNER1_CALLBACK,(char*)"1");
			men1_company_spinner_down = new Fl_Button(x+30,y+10,13,10,"@-38<");
				men1_company_spinner_down->callback(fmen1_SPINNER1_CALLBACK,(char*)"-1");

			men1_company_desc = new Fl_Output(x+50,y,160,20);
				men1_company_desc->deactivate();

		x=20; y=50;

			men1_decoration = new Fl_Box(x, y, 260, 150);

			men1_decoration->box(FL_ENGRAVED_BOX);
			men1_decoration->color(0xE1E1E100);

			men1_title = new Fl_Output(x+5,y-10,80,20);
				men1_title->box(FL_FLAT_BOX);
				men1_title->color(0xE1E1E100);
				men1_title->value(w_Title.c_str());

				men1_but1 = new Fl_Radio_Round_Button(x+15, y+1*20, 70, 15, "SYSTEM");
				men1_but1->down_box(FL_ROUND_DOWN_BOX);
				men1_but1->callback(fmen1_but1_callback);
				men1_but2 = new Fl_Radio_Round_Button(x+15, y+3*20, 70, 15, "General Ledger");
				men1_but2->down_box(FL_ROUND_DOWN_BOX);
					men1_but2->labelcolor(FL_BLUE);
				men1_but2->callback(fmen1_but2_callback);
				men1_but3 = new Fl_Radio_Round_Button(x+15, y+4*20, 70, 15, "Asset/Investment");
				men1_but3->down_box(FL_ROUND_DOWN_BOX);

				lButton(men1_exit,x+90,y+6*20,"Exit",_windowExit_callback);

	men1->end();

	men1->callback(_windowExit_callback);

	men1_company_no->value(A01_Parameter);
	str="";	for (i=0; i<30; i++) {str = str + A01_Description[i];}
	men1_company_desc->value(str.c_str());

	a01_system_recno=A01_Record_NO;
	men1_company_no->value(A01_Parameter);

}

//----------------------------------------------------------
//Window 1 fmen1_SPINNER1_CALLBACK
//----------------------------------------------------------
void fmen1_SPINNER1_CALLBACK(Fl_Widget* w, void* data){

//	----------------
//	Get the Field Id
//	----------------
		string z=(char*)data; int y=stoi(z);

//	-----------------
//	Set the direction
//	-----------------
		if (y>0) {direction=+1;}
		else	{direction=-1;}

//	-----------------------------
//	Find the Next/Previous record
//	-----------------------------
		L1_CALL(c_A01,c_Read,a01_system_recno,0,0);
		L1_CALL(c_A01,c_PreviousNext,direction,0,0);
		a01_system_recno = A01_Record_NO;

//	-------------------------
//	string up the description
//	-------------------------
		str="";for (i=0; i<30; i++) {str = str + A01_Description[i];}

	//---------------------------------------
	//Grab the return values & display them
	//---------------------------------------
		men1_company_no->value(A01_Parameter);
		men1_company_desc->value(str.c_str());
		men1->redraw();

}

//----------------------------------------------------------
//Window 1 button 1 callback -> System Parameters
//----------------------------------------------------------
void fmen1_but1_callback(Fl_Widget* w, void* data){

		men1_but1->clear();

	//---------------------
	//Grab the transactions
	//---------------------
		WIN3_SYS_TRANSACTIONS();

	//---------------
	//Open the window
	//---------------
		win3_sys_key->activate();
		win3_sys_details->deactivate();
		win3_sys_list->activate();
		fromWindowNo=1; windowNo=3; win3_sys->show();

}

//----------------------------------------------------------
//Window 1 button 2 callback - General Ledger Menu
//----------------------------------------------------------
void fmen1_but2_callback(Fl_Widget* w, void* data){

		L1_CALL(c_A01,c_Read,a01_system_recno,0,0);
		i = men1_company_no->value();
		if (!l1_findCompany(i))
		{
			fl_alert("Unknown Comapny No");
			men1_but2->clear();
			return;
		}

		if (A01_ParameterNo==3)
		{
			men2_but2->hide();
			men2_but5->hide();
			men2_but6->hide();
		}
		else
		{
			men2_but2->show();
			men2_but5->show();
			men2_but6->show();
		}

		men1_but2->clear();
		fromWindowNo=1; windowNo=2; men2->show();

}
