DECLARE CONSTANT CHK_SHOW_ORDER_ENTRY		AS QUANTITY 703
DECLARE CONSTANT CHK_SHOW_QUOTES_ENTRY		AS QUANTITY 704
DECLARE CONSTANT CHK_SHOW_RFQ_ENTRY			AS QUANTITY	705
DECLARE CONSTANT CHK_SHOW_UDS_ENTRY			AS QUANTITY	706

DECLARE CONSTANT OPT_DEFAULT_MODE_ORDERS		AS QUANTITY	1051
DECLARE CONSTANT OPT_DEFAULT_MODE_QUOTES		AS QUANTITY	1052

DECLARE CONSTANT CMB_SELECTED_MARKET			AS QUANTITY	714
# Message box icons
DECLARE CONSTANT MSG_BOX_ICON_Critical	AS QUANTITY 0
DECLARE CONSTANT MSG_BOX_ICON_Question	AS QUANTITY 1
DECLARE CONSTANT MSG_BOX_ICON_Exclaim	AS QUANTITY 2
DECLARE CONSTANT MSG_BOX_ICON_Info		AS QUANTITY 3

# Message box types
DECLARE CONSTANT MSG_BOX_TYPE_AbortRetryIgnore		AS QUANTITY 0
DECLARE CONSTANT MSG_BOX_TYPE_Ok		AS QUANTITY 1
DECLARE CONSTANT MSG_BOX_TYPE_OkCancel	AS QUANTITY 2
DECLARE CONSTANT MSG_BOX_TYPE_RetryCancel	AS QUANTITY 3
DECLARE CONSTANT MSG_BOX_TYPE_YesNo		AS QUANTITY 4

DECLARE CONSTANT FLD_AccountType 		AS QUANTITY 40505
DECLARE CONSTANT FLD_Capacity			AS QUANTITY	2233

DECLARE VARIABLE i_DEFAULT_ORDER_MODE	AS QUANTITY

#Object Pools
DECLARE CONSTANT Datapool_Markets				AS QUANTITY 17

PROCEDURE OnInitForm DO
{
   [i_DEFAULT_ORDER_MODE] := 1 ; 
	AddListEntry1(FLD_AccountType, " ", "");
	SetControlPool(FLD_AccountType, FLD_AccountType);
	
	AddListEntry1(FLD_Capacity, " ", "");
	SetControlPool(FLD_Capacity, FLD_Capacity);
	
	#134834
	RemoveListEntry2(FLD_Capacity, "ALL_CAPACITIES");
}

PROCEDURE CheckPanelVisibility RETURNS QUANTITY DO
{
	DECLARE VARIABLE nCumilativeValue	AS QUANTITY
	[nCumilativeValue] := (GetCheck(CHK_SHOW_ORDER_ENTRY) + GetCheck(CHK_SHOW_QUOTES_ENTRY) +
							GetCheck(CHK_SHOW_RFQ_ENTRY) + GetCheck(CHK_SHOW_UDS_ENTRY)) ;
	RETURN 	[nCumilativeValue] ; 
	
}

PROCEDURE OnCheck
        DECLARE PARAMETER nControlID as QUANTITY
        DECLARE PARAMETER sName as TEXT
        DECLARE PARAMETER nValue as QUANTITY DO
{
	IF (([nControlID] = CHK_SHOW_ORDER_ENTRY) OR ([nControlID] = CHK_SHOW_QUOTES_ENTRY)
			OR ([nControlID] = CHK_SHOW_RFQ_ENTRY) OR ([nControlID] = CHK_SHOW_UDS_ENTRY)) DO
	{
		IF ([nValue] = 1) DO
		{
			RETURN
			#No Use of validating if a order type is checkes as opposed to unchecked 
		}
		
		DECLARE VARIABLE nCumilativeValue	AS QUANTITY
		[nCumilativeValue] := CheckPanelVisibility() ;
		
		IF ( [nCumilativeValue] < 1 ) THEN
		{
			MessageBox("At least one of the Entry Panels should be enabled","Panel Visibility Validation",MSG_BOX_TYPE_Ok,MSG_BOX_ICON_Critical);
			SetCheck([nControlID], 1);
		} ELSE 
		{
			IF (([nControlID] = CHK_SHOW_ORDER_ENTRY) AND ([i_DEFAULT_ORDER_MODE] = 1)) THEN
			{
				MessageBox("Cant Disable Order Panel While having it as the default Panel","Panel Visibility Validation",MSG_BOX_TYPE_Ok,MSG_BOX_ICON_Critical);
				SetCheck([nControlID], 1);
			} ELSE IF (([nControlID] = CHK_SHOW_QUOTES_ENTRY) AND ([i_DEFAULT_ORDER_MODE] = 0)) DO
			{
				MessageBox("Cant Disable Quote Panel While having it as the default Panel","Panel Visibility Validation",MSG_BOX_TYPE_Ok,MSG_BOX_ICON_Critical);
				SetCheck([nControlID], 1);
			}
		}
	}
}

PROCEDURE OnRadioCheck
        DECLARE PARAMETER nControlID as QUANTITY
        DECLARE PARAMETER sName as TEXT
        DECLARE PARAMETER nValue as QUANTITY DO
{
	IF (([nControlID] = OPT_DEFAULT_MODE_ORDERS) OR ([nControlID] = OPT_DEFAULT_MODE_QUOTES)) DO
	{
		IF ( ([nControlID] = OPT_DEFAULT_MODE_ORDERS)  AND ( [nValue] = 1 ) ) THEN
		{
			[i_DEFAULT_ORDER_MODE] := 1 ; 
			IF (GetCheck(CHK_SHOW_ORDER_ENTRY) = 0) DO
			{
				SetCheck(CHK_SHOW_ORDER_ENTRY, 1);
			}
		} ELSE 
		{
			[i_DEFAULT_ORDER_MODE] := 0 ; 
			IF (GetCheck(CHK_SHOW_QUOTES_ENTRY) = 0) DO
			{
				SetCheck(CHK_SHOW_QUOTES_ENTRY, 1);
			}
		}
	}
	
}

PROCEDURE InitializePreferenceWnd DO
{
	CALL SetMarkets ;
}

#################################################################################
PROCEDURE SetMarkets	DO
{
	DECLARE VARIABLE nCount AS QUANTITY
	DECLARE VARIABLE nIndex AS QUANTITY
	DECLARE VARIABLE sMarket 			AS TEXT		100 
	
	RemoveListEntry2(CMB_SELECTED_MARKET, "");
	[nCount] := GetObjPoolItemCount(Datapool_Markets);	
	[nIndex] := 0;
	[sMarket] := "";
	
	WHILE ( [nIndex] < [nCount] ) DO
	{		
		
		[sMarket] := GetObjPoolItemKey( Datapool_Markets, [nIndex] );
		AddListEntry1(CMB_SELECTED_MARKET, [sMarket],"");
				
		[nIndex] := ( [nIndex] + 1 );	
	}		

}


PROCEDURE OnChangeCombo
        DECLARE PARAMETER sGroupName as TEXT
        DECLARE PARAMETER sFieldName as TEXT
        DECLARE PARAMETER sVal as TEXT
        DECLARE PARAMETER nCurSel as QUANTITY
        DECLARE PARAMETER nControlID as QUANTITY DO
{
	IF ([nControlID] = 5500) DO
	{
		IF ([sVal] = "Static") THEN
		{
			SetLock(5513 ,0,0);
			SetLock(5514 ,0,0);
			SetLock(5515 ,0,0);
		}
		ELSE
		{
			SetLock(5513 ,1,0);
			SetLock(5514 ,1,0);
			SetLock(5515 ,1,0);
		}
	} 
}

PROCEDURE OnCompleteLoadPreferences DO
{
	DECLARE VARIABLE sMode		AS TEXT		20
	[sMode] := GetFieldValue1(5500);
	
	CALL OnChangeCombo "", "", [sMode], 0, 5500;
}



#################################################################################
PROCEDURE SetPreferenceMode	
	DECLARE PARAMETER sType as TEXT DO
{
}


PROCEDURE OnTabChange
        DECLARE PARAMETER sTabName as TEXT
        DECLARE PARAMETER nTabNO as QUANTITY
        DECLARE PARAMETER sOldTab as TEXT DO
{
}
