//////////////////////////////////////////////////////////////////////////
// This is a clean prefpage with a treeoption control
// I avoided unnecessary code obfuscation as good as possible
#include "stdafx.h"
#include "emule.h"
#include "SharkX/PPgSharkX.h"
#include "AntiLeech/Modname.h"
#include "UserMsgs.h"
#include "otherfunctions.h"

// By Taz - VQB: fullChunk
#include "UploadQueue.h" // VQB: fullChunk
// <------- VQB: fullChunk

#include "Preferences.h"
#include "opcodes.h"

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
#include "PartFile.h"
#include "DownloadQueue.h"
//<<< WiZaRd::AutoHL
// <------- AUtoHL

// By Taz - EMF Link
#include "emuleDlg.h"
#include "MenuCmds.h"
// <------- EMF Link

#include "EMF/IP2Country.h"	//>>> shadow2004::IP2Country [EastShare]

// By Taz - Multi CS
//MORPH START - Added by SiRoB, reduce a little CPU usage for ratio count
#include "ClientCredits.h"
//MORPH END   - Added by SiRoB, reduce a little CPU usage for ratio count
// <------- Multi CS

// By Taz - Advanced official preferences
#include "langids.h"
// <------- Advanced official preferences

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

///////////////////////////////////////////////////////////////////////////////
// CPPgSharkX dialog

IMPLEMENT_DYNAMIC(CPPgSharkX, CPropertyPage)
BEGIN_MESSAGE_MAP(CPPgSharkX, CPropertyPage)
	ON_WM_DESTROY()
	ON_MESSAGE(UM_TREEOPTSCTRL_NOTIFY, OnTreeOptsCtrlNotify)
	ON_WM_HELPINFO()
END_MESSAGE_MAP()

CPPgSharkX::CPPgSharkX()
: CPropertyPage(CPPgSharkX::IDD)
, m_ctrlTreeOptions(theApp.m_iDfltImageListColorFlags)
{
	m_bInitializedTreeOpts = false;
	Nullify();

}

CPPgSharkX::~CPPgSharkX()
{
}

void CPPgSharkX::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_SharkX_OPTS, m_ctrlTreeOptions);
	CString buffer;
	if (!m_bInitializedTreeOpts)
	{

// By Taz - Mod Options arangement
		int iImgUM = 8; // default icon
		int iImgDM = 8;
// <------- Mod Options arangement

		int iImgConnection = 8;
		int iImgEmulate = 8;

// By Taz - EMF
		int iImgDisplay = 8;	//>>> shadow2004::Toolbar
// <------- EMF
		int	iImgI2C = 8;		//>>> shadow2004::IP2Country [EastShare]
		int	iImgSLS = 8;		//>>> JvA::SLS [enkeyDEV]
//>>> WiZaRd::IntelliFlush
		int iImgSystem = 8;
		int iImgFileBuffer = 8;
//<<< WiZaRd::IntelliFlush

// By Taz - Multi CS
		int iImgCS = 8; //EastShare Added by linekin, CreditSystem
// <------- Multi CS

// By Taz - drop sources
		int iImgDropDefaults = 8;
// <------- drop sources

// By Taz - SCC
		int iImgSCC = 8;
		int iImgDlMode = 8;
// <------- SCC

// By Taz - Extended control download priority
		int iImgAutoDownPrio = 8;
		int iImgPriority = 8;
		int	iImgAutoDown_start_Prio = 8;
		int	iImgAutoDown_end_Prio = 8;
// <------- Extended control download priority

// By Taz - AutoHL
		int iImgDynup = 8;
		int iImgAutoHL = 8;
// <------- AutoHL

// By Taz - taz dynamic ratio
		int iImgTaz = 8;
// <------- taz dynamic ratio

		CImageList* piml = m_ctrlTreeOptions.GetImageList(TVSIL_NORMAL);
		if (piml)
		{

// By Taz - Mod Options arangement
			iImgUM = piml->Add(CTempIconLoader(_T("UPLOAD")));
			iImgDM = piml->Add(CTempIconLoader(_T("DOWNLOAD")));
// <------- Mod Options arangement

			iImgConnection	=	piml->Add(CTempIconLoader(_T("connection")));
			iImgEmulate		=	piml->Add(CTempIconLoader(_T("EMULATE")));

// By Taz - EMF
			iImgDisplay		=	piml->Add(CTempIconLoader(_T("DISPLAY"))); //>>> shadow2004::Toolbar
// <------- EMF

			iImgI2C			=	piml->Add(CTempIconLoader(_T("SEARCHMETHOD_GLOBAL"))); //>>> shadow2004::IP2Country [EastShare]
			iImgSLS			=	piml->Add(CTempIconLoader(_T("SLS")));	//>>> JvA::SLS [enkeyDEV]
//>>> WiZaRd::IntelliFlush
			iImgSystem		=	piml->Add(CTempIconLoader(_T("TWEAK")));
			iImgFileBuffer	=	piml->Add(CTempIconLoader(_T("HARDDISK")));
//<<< WiZaRd::IntelliFlush

// By Taz - Multi CS
			iImgCS = piml->Add(CTempIconLoader(_T("STATSCLIENTS"))); // EastShare START - Added by Pretender, CS icon
// <------- Multi CS

// By Taz - drop sources
			iImgDropDefaults = piml->Add(CTempIconLoader(_T("DROPDEFAULTS")));
// <------- drop sources

// By Taz - SCC
			iImgSCC = piml->Add(CTempIconLoader(_T("CATEGORY")));
			iImgDlMode = piml->Add(CTempIconLoader(_T("DLMODE")));
// <------- SCC

// By Taz - Extended control download priority
			iImgAutoDownPrio = piml->Add(CTempIconLoader(_T("PRIORITY")));
			iImgPriority = piml->Add(CTempIconLoader(_T("FILEPRIORITY")));
			iImgAutoDown_start_Prio = piml->Add(CTempIconLoader(_T("PRIO_LOW")));
			iImgAutoDown_end_Prio = piml->Add(CTempIconLoader(_T("PRIO_HIGH")));
// <------- Extended control download priority

// By Taz - AutoHL
			iImgDynup		=	piml->Add(CTempIconLoader(_T("UPLOAD")));
			iImgAutoHL		=	piml->Add(CTempIconLoader(_T("PRIO_AUTO")));
// <------- AutoHL

// By Taz - taz dynamic ratio
			iImgTaz = piml->Add(CTempIconLoader(_T("TAZ")));
// <------- taz dynamic ratio
		}

		//////////////////////////////////////////////////////////////////////////
		// System tweaks
		//
		m_htiSystemGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_SYSTEM), iImgSystem, TVI_ROOT);
		m_htiMultipleInstances = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_MULTIPLE_INSTANCES), m_htiSystemGroup, m_bMultipleInstances);

// By Taz - emule Priority
		//MORPH START - Added by IceCream, high process priority
		m_htiHighProcess = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_HIGHPROCESS), m_htiSystemGroup, m_bHighProcess);
		//MORPH END   - Added by IceCream, high process priority
// <------- emule Priority

		/////////////////////////////////////////////////////////////////////////////
		// Download Management group
		//

// By Taz - Mod Options arangement
		m_htiDM = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_DM), iImgDM, TVI_ROOT);
// <------- Mod Options arangement

// By Taz - retry connection attempts
		m_htiRetryConnectionAttempts = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_RETRYCONNECTIONATTEMPTS), m_htiDM, m_bRetryConnectionAttempts);
// <------- retry connection attempts

//>>> WiZaRd::IntelliFlush
		m_htiFileBufferGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_FILEBUFFER), iImgFileBuffer, m_htiDM);
		buffer.Format(_T("%s [%s]"), GetResString(IDS_FILEBUFFERSIZE), GetResString(IDS_KBYTES));
		m_htiFileBufferSize = m_ctrlTreeOptions.InsertItem(buffer, TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiFileBufferGroup);
		m_ctrlTreeOptions.AddEditBox(m_htiFileBufferSize, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiFileBufferTime = m_ctrlTreeOptions.InsertItem(GetResString(IDS_FILEBUFFER_TIME), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiFileBufferGroup);
		m_ctrlTreeOptions.AddEditBox(m_htiFileBufferTime, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiIntelliFlushCheck = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_FILEBUFFER_INTELLI), m_htiFileBufferGroup, m_bIntelliFlush || m_iFileBufferTime < 1 || m_iFileBufferTime > 5);
//		m_ctrlTreeOptions.Expand(m_htiFileBufferGroup, TVE_EXPAND);
		m_ctrlTreeOptions.SetItemState(m_htiFileBufferGroup, TVIS_BOLD, TVIS_BOLD);
//<<< WiZaRd::IntelliFlush

//>>> Spike2::Emulate other
		m_htiEmulateGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_EMULATE), iImgEmulate, m_htiDM);
		m_htiEmulateEdonkey = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_EMU_EDONKEY), m_htiEmulateGroup, m_bEmulateEdonkey);
		m_htiEmulateEdonkeyHybrid = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_EMU_EDONKEYHYBRID), m_htiEmulateGroup, m_bEmulateEdonkeyHybrid);
		m_htiEmulateMLdonkey = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_EMU_MLDONKEY), m_htiEmulateGroup, m_bEmulateMLdonkey);
		m_htiEmulateShareaza = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_EMU_SHAREAZA), m_htiEmulateGroup, m_bEmulateShareaza);
		m_htiEmulateLphant = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_EMU_LPHANT), m_htiEmulateGroup, m_bEmulateLphant);
//		m_ctrlTreeOptions.Expand(m_htiEmulateGroup, TVE_EXPAND);
		m_ctrlTreeOptions.SetItemState(m_htiEmulateGroup, TVIS_BOLD, TVIS_BOLD);
//<<< Spike2::Emulate other

//>>> JvA::SLS [enkeyDEV]
		m_htiSLSGroup		= m_ctrlTreeOptions.InsertGroup(GetResString(IDS_SLSLABEL), iImgSLS, m_htiDM);
		m_htiSLSCheck		= m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_SLSCHECKLABEL), m_htiSLSGroup, m_bSLSCheck);
		m_htiSLSActivationLimit = m_ctrlTreeOptions.InsertItem(GetResString(IDS_SLSACTIVATIONLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiSLSGroup);
		m_ctrlTreeOptions.AddEditBox(m_htiSLSActivationLimit, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiSLSSaveValue	= m_ctrlTreeOptions.InsertItem(GetResString(IDS_SLSSAVEVALUE), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiSLSGroup);
		m_ctrlTreeOptions.AddEditBox(m_htiSLSSaveValue, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.SetItemState(m_htiSLSGroup, TVIS_BOLD, TVIS_BOLD);
//<<< JvA::SLS [enkeyDEV]

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
		m_htiAutoHL = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_AUTOHL), iImgAutoHL, m_htiDM);
		m_htiUseAutoHLRadio = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_USE_AUTOHL), iImgDynup, m_htiAutoHL);
		m_htiUseAutoHLPerFile = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PER_FILE), m_htiUseAutoHLRadio, m_iUseAutoHL == 0);
		m_htiUseAutoHLOn = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_OFF), m_htiUseAutoHLRadio, m_iUseAutoHL == 1);
		m_htiUseAutoHLOff = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_ON), m_htiUseAutoHLRadio, m_iUseAutoHL == 2);
		m_htiMaxSources = m_ctrlTreeOptions.InsertItem(GetResString(IDS_MAX_SOURCES), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoHL);
		m_ctrlTreeOptions.AddEditBox(m_htiMaxSources, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiMaxPerFileSources = m_ctrlTreeOptions.InsertItem(GetResString(IDS_MAX_PERFILESOURCES), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoHL);
		m_ctrlTreeOptions.AddEditBox(m_htiMaxPerFileSources, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiMinPerFileSources = m_ctrlTreeOptions.InsertItem(GetResString(IDS_MIN_PERFILESOURCES), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoHL);
		m_ctrlTreeOptions.AddEditBox(m_htiMinPerFileSources, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiAHLUpdate = m_ctrlTreeOptions.InsertItem(GetResString(IDS_AHL_UPDATETIME), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoHL);
		m_ctrlTreeOptions.AddEditBox(m_htiAHLUpdate, RUNTIME_CLASS(CNumTreeOptionsEdit));

//		m_ctrlTreeOptions.Expand(m_htiAutoHL, TVE_EXPAND);
		m_ctrlTreeOptions.SetItemState(m_htiAutoHL, TVIS_BOLD, TVIS_BOLD);
		m_ctrlTreeOptions.Expand(m_htiUseAutoHLRadio, TVE_EXPAND);
		m_ctrlTreeOptions.SetItemState(m_htiUseAutoHLRadio, TVIS_BOLD, TVIS_BOLD);
//<<< WiZaRd::AutoHL
// <------- AutoHL

// By Taz - drop sources
		// ==> drop sources - Stulle
		m_htiDropDefaults = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_DROP_DEFAULTS), iImgDropDefaults, m_htiDM);
		m_htiAutoNNS = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_AUTO_NNS), m_htiDropDefaults, m_bEnableAutoDropNNSDefault);
		m_htiAutoNNSTimer = m_ctrlTreeOptions.InsertItem(GetResString(IDS_NNS_TIMERLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoNNS);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoNNSTimer, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiAutoNNSLimit = m_ctrlTreeOptions.InsertItem(GetResString(IDS_REMOVENNSLIMITLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoNNS);
		m_ctrlTreeOptions.Expand(m_htiAutoNNS, TVE_EXPAND);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoNNSLimit, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiAutoFQS = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_AUTO_FQS), m_htiDropDefaults, m_bEnableAutoDropFQSDefault);
		m_htiAutoFQSTimer = m_ctrlTreeOptions.InsertItem(GetResString(IDS_FQS_TIMERLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoFQS);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoFQSTimer, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiAutoFQSLimit = m_ctrlTreeOptions.InsertItem(GetResString(IDS_REMOVEFQSLIMITLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoFQS);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoFQSLimit, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.Expand(m_htiAutoFQS, TVE_EXPAND);
		m_htiAutoQRS = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_AUTO_QRS), m_htiDropDefaults, m_bEnableAutoDropQRSDefault);
		m_htiAutoQRSTimer = m_ctrlTreeOptions.InsertItem(GetResString(IDS_HQRS_TIMERLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoQRS);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoQRSTimer, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiAutoQRSMax = m_ctrlTreeOptions.InsertItem(GetResString(IDS_REMOVEQRSLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoQRS);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoQRSMax, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiAutoQRSLimit = m_ctrlTreeOptions.InsertItem(GetResString(IDS_REMOVEQRSLIMITLABEL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoQRS);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoQRSLimit, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.Expand(m_htiAutoQRS, TVE_EXPAND);
		// <== drop sources - Stulle
// <------- drop sources

// By Taz - SCC
		// ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
		m_htiSCC = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_SCC), iImgSCC, m_htiDM);
		m_htiDlMode = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_DL_MODE_DEFAULT), iImgDlMode, m_htiSCC);
		m_htiDlNone = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_DL_NONE), m_htiDlMode, m_iDlMode == 0);
		m_htiDlAlph = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_DOWNLOAD_ALPHABETICAL), m_htiDlMode, m_iDlMode == 1);
		m_htiDlLP = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_LP), m_htiDlMode, m_iDlMode == 2);
		m_htiShowCatNames = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_CAT_SHOWCATNAME), m_htiSCC, m_bShowCatNames);
		m_htiSelectCat = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_CAT_SHOWSELCATDLG), m_htiSCC, m_bSelectCat);
		m_htiUseAutoCat = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_CAT_USEAUTOCAT), m_htiSCC, m_bUseAutoCat);
		m_htiUseActiveCat = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_CAT_USEACTIVE), m_htiSCC, m_bUseActiveCat);
		m_htiAutoSetResOrder = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_CAT_AUTORESUMEORD), m_htiSCC, m_bAutoSetResOrder);
		m_htiSmallFileDLPush = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_CAT_SMALLFILEDLPUSH), m_htiSCC, m_bSmallFileDLPush);
		m_htiResumeFileInNewCat = m_ctrlTreeOptions.InsertItem(GetResString(IDS_CAT_STARTFILESONADD), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiSCC);
		m_ctrlTreeOptions.AddEditBox(m_htiResumeFileInNewCat, RUNTIME_CLASS(CNumTreeOptionsEdit));
		// <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
// <------- SCC

// By Taz - Extended control download priority
		m_htiAutoDownPrioGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_AUTO_DOWN_GROUP), iImgAutoDownPrio, m_htiDM);
		m_htiAutoDown_start_PrioGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_AUTO_START_GROUP), iImgAutoDown_start_Prio, m_htiAutoDownPrioGroup);
		m_htiAutoDown_start_PrioOff = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_DISABLED), m_htiAutoDown_start_PrioGroup, m_iAutoDown_start_Prio == 0);
		m_htiAutoDown_start_PrioPerc = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_AUTO_DOWN_PERC), m_htiAutoDown_start_PrioGroup, m_iAutoDown_start_Prio == 1);
		m_htiAutoDown_start_PrioPercVal = m_ctrlTreeOptions.InsertItem(GetResString(IDS_AUTO_DOWN_PERC_VAL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoDown_start_PrioPerc);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoDown_start_PrioPercVal, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.Expand(m_htiAutoDown_start_PrioPerc, TVE_EXPAND);
		m_htiAutoDown_start_PrioSize = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_AUTO_DOWNLOADED_SIZE), m_htiAutoDown_start_PrioGroup, m_iAutoDown_start_Prio == 2);
		m_htiAutoDown_start_PrioSizeVal = m_ctrlTreeOptions.InsertItem(GetResString(IDS_AUTO_DOWNLOADED_SIZE_VAL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoDown_start_PrioSize);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoDown_start_PrioSizeVal, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.Expand(m_htiAutoDown_start_PrioSize, TVE_EXPAND);
		m_htiAutoDown_start_PrioValGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_AUTO_DOWN_PRIO), iImgPriority, m_htiAutoDown_start_PrioGroup);
		m_htiAutoDown_start_PrioLow = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PRIOLOW), m_htiAutoDown_start_PrioValGroup, m_iAutoDown_start_PrioVal == 0);
		m_htiAutoDown_start_PrioNormal = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PRIONORMAL), m_htiAutoDown_start_PrioValGroup, m_iAutoDown_start_PrioVal == 1);
		m_htiAutoDown_start_PrioHigh = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PRIOHIGH), m_htiAutoDown_start_PrioValGroup, m_iAutoDown_start_PrioVal == 2);
		m_ctrlTreeOptions.Expand(m_htiAutoDown_start_PrioValGroup, TVE_EXPAND);
		// ==> Control download priority [tommy_gun/iONiX] - Stulle
		m_htiAutoDown_end_PrioGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_AUTO_END_GROUP), iImgAutoDown_end_Prio, m_htiAutoDownPrioGroup);
		m_htiAutoDownPrioOff = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_DISABLED), m_htiAutoDown_end_PrioGroup, m_iAutoDownPrio == 0);
		m_htiAutoDownPrioPerc = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_AUTO_DOWN_PERC), m_htiAutoDown_end_PrioGroup, m_iAutoDownPrio == 1);
		m_htiAutoDownPrioPercVal = m_ctrlTreeOptions.InsertItem(GetResString(IDS_AUTO_DOWN_PERC_VAL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoDownPrioPerc);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoDownPrioPercVal, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.Expand(m_htiAutoDownPrioPerc, TVE_EXPAND);
		m_htiAutoDownPrioSize = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_AUTO_DOWN_SIZE), m_htiAutoDown_end_PrioGroup, m_iAutoDownPrio == 2);
		m_htiAutoDownPrioSizeVal = m_ctrlTreeOptions.InsertItem(GetResString(IDS_AUTO_DOWN_SIZE_VAL), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiAutoDownPrioSize);
		m_ctrlTreeOptions.AddEditBox(m_htiAutoDownPrioSizeVal, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_ctrlTreeOptions.Expand(m_htiAutoDownPrioSize, TVE_EXPAND);
		m_htiAutoDownPrioValGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_AUTO_DOWN_PRIO), iImgPriority, m_htiAutoDown_end_PrioGroup);
		m_htiAutoDownPrioLow = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PRIOLOW), m_htiAutoDownPrioValGroup, m_iAutoDownPrioVal == 0);
		m_htiAutoDownPrioNormal = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PRIONORMAL), m_htiAutoDownPrioValGroup, m_iAutoDownPrioVal == 1);
		m_htiAutoDownPrioHigh = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PRIOHIGH), m_htiAutoDownPrioValGroup, m_iAutoDownPrioVal == 2);
		m_ctrlTreeOptions.Expand(m_htiAutoDownPrioValGroup, TVE_EXPAND);
		// <== Control download priority [tommy_gun/iONiX] - Stulle
// <------- Extended control download priority

// By Taz - taz dynamic ratio
		m_htiDynamicRatio = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_TAZDynamicRatio), iImgTaz, m_htiDM);
		m_htiMaxDLULRatio = m_ctrlTreeOptions.InsertItem(GetResString(IDS_MaxDLULRatio), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiDynamicRatio);
		m_ctrlTreeOptions.AddEditBox(m_htiMaxDLULRatio, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiMaxDLSpeed = m_ctrlTreeOptions.InsertItem(GetResString(IDS_MaxDLSpeed), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiDynamicRatio);
		m_ctrlTreeOptions.AddEditBox(m_htiMaxDLSpeed, RUNTIME_CLASS(CNumTreeOptionsEdit));
// <------- tar dynamic ratio

		/////////////////////////////////////////////////////////////////////////////
		// Upload Management group
		//

// By Taz - Mod Options arangement
		m_htiUM = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_UM), iImgUM, TVI_ROOT);
// <------- Mod Options arangement

// By Taz - Anti Upload Protection
		// ==> Anti Upload Protection - sFrQlXeRt
		m_htiAntiUploadProtection = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_ANTI_UP_PROTECTION), m_htiUM, m_bAntiUploadProtection);
		// <== Anti Upload Protection - sFrQlXeRt
// <------- Anti Upload Protection

		m_htiClientDataRate = m_ctrlTreeOptions.InsertItem(GetResString(IDS_DATARATE_ADJUST), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiUM);
		m_ctrlTreeOptions.AddEditBox(m_htiClientDataRate, RUNTIME_CLASS(CNumTreeOptionsEdit));
		m_htiFUChunks = m_ctrlTreeOptions.InsertItem(GetResString(IDS_FUCHUNKS), TREEOPTSCTRLIMG_EDIT, TREEOPTSCTRLIMG_EDIT, m_htiUM);
		m_ctrlTreeOptions.AddEditBox(m_htiFUChunks, RUNTIME_CLASS(CNumTreeOptionsEdit));

// By Taz - Multi CS
		// EastShare START - Added by linekin, new creditsystem by [lovelace]  // Modified by Pretender
		m_htiCreditSystem = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_CREDIT_SYSTEM), iImgCS, m_htiUM);
		//EastShare Start - CreditSystemSelection
		// ==> new credit system - Stulle
		m_htiOfficialCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_CS_OFFI), m_htiCreditSystem, m_iCreditSystem == CS_OFFICIAL);
/*		m_htiRatioCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_RATIO_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_RATIO);
		m_htiSivkaCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_SIVKA_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_SIVKA);
		m_htiSwatCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_SWAT_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_SWAT);
		m_htiTk4Credit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_TK4_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_TK4);
		m_htiZzulCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_ZZUL_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_ZZUL);
*/		m_htiXtremeCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_XTREME_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_XTREME);
		// <== new credit system - Stulle
		//EastShare End - CreditSystemSelection
		// EastShare END - Added by linekin, new creditsystem by [lovelace]

// By Taz - MagicAngel CS
		m_htiMagicAngelCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_MAGICANGEL_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_MAGICANGEL);
//		m_htiMagicAngelPlusCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_MAGICANGELPLUS_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_MAGICANGELPLUS);
// <------- MagicAngel CS

		m_htiLovelaceCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_LOVELACE_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_LOVELACE);
		m_htiPawcioCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_PAWCIO_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_PAWCIO);
		m_htiESCredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_EASTSHARE_CREDIT), m_htiCreditSystem, m_iCreditSystem == CS_EASTSHARE);

// By Taz - ClientAnalyzer
#ifdef CLIENTANALYZER
		m_htiCACredit = m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_CS_ANALYZER), m_htiCreditSystem, m_iCreditSystem == CS_CA);
#endif
// <------- ClientAnalyzer

		m_ctrlTreeOptions.Expand(m_htiCreditSystem, TVE_EXPAND);//EastShare

// By Taz - Fine CS
		m_htiFineCredit = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_FINE_CREDIT), m_htiUM, m_bFineCS);//EastShare - added by Pretender, modified Fine Credit System
// <------- Fine CS

// <------- Multi CS

		/////////////////////////////////////////////////////////////////////////////
		// Display group
		//

// By Taz - EMF
		m_htiDisplayGroup	= m_ctrlTreeOptions.InsertGroup(GetResString(IDS_PW_DISPLAY), iImgDisplay, TVI_ROOT);
// <------- EMF

//>>> WiZaRd::minRQR [WiZaRd]
		m_htiMinRQR			= m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_MINRQR_ENABLE), m_htiDisplayGroup, m_bUseMinRQR);
//<<< WiZaRd::minRQR [WiZaRd]

// By Taz - folder ICONS
		m_htiFolderIcons = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_FOLDERICONS),m_htiDisplayGroup, m_bFolderIcons);
// <------- folder ICONS

// By Taz - show SRC totals
		m_htiShowSrcTotals = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_ShowSrcTotals), m_htiDisplayGroup, m_bShowSrcTotals);
// <------- show SRC totals

//>>> shadow2004::IP2Country [EastShare]
		m_htiI2CGroup		= m_ctrlTreeOptions.InsertGroup(GetResString(IDS_IP2COUNTRY), iImgI2C, m_htiDisplayGroup);
		m_htiI2C2Letter		= m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_IP2COUNTRY_2LETTERS), m_htiI2CGroup, m_iI2CCaption == 0);
		m_htiI2C3Letter		= m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_IP2COUNTRY_3LETTERS), m_htiI2CGroup, m_iI2CCaption == 1);
		m_htiI2CFullCaption	= m_ctrlTreeOptions.InsertRadioButton(GetResString(IDS_IP2COUNTRY_FULLCAPTION), m_htiI2CGroup, m_iI2CCaption == 2);
		m_htiI2CShowFlag	= m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_IP2COUNTRY_SHOWFLAGS), m_htiI2CGroup, m_bI2CShowFlag);
		m_ctrlTreeOptions.SetItemState(m_htiI2CGroup, TVIS_BOLD, TVIS_BOLD);
//<<< shadow2004::IP2Country [EastShare]

// By Taz - Advanced official preferences
		if (thePrefs.GetLanguageID() == LANGID_HE_IL)
			m_hti_m_bRTLWindowsLayout=m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_RTLWINDOWSLAYOUT),m_htiDisplayGroup,m_bRTLWindowsLayout);
// <------- Advanced official preferences

		/////////////////////////////////////////////////////////////////////////////
		// Misc group
		//

		m_htiMoreTweaksGroup = m_ctrlTreeOptions.InsertGroup(GetResString(IDS_PW_MISC), iImgConnection, TVI_ROOT);

// By Taz - startup sound
		m_htiStartupSound = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_PW_STARTUPSOUND), m_htiMoreTweaksGroup, m_bStartupSound);
// <------- startup sound

		m_ctrlTreeOptions.SetItemState(m_htiSystemGroup, TVIS_BOLD, TVIS_BOLD);
		m_ctrlTreeOptions.Expand(m_htiSystemGroup, TVE_EXPAND);

// By Taz - Mod Options arangement
		m_ctrlTreeOptions.Expand(m_htiDM, TVE_EXPAND);
		m_ctrlTreeOptions.Expand(m_htiUM, TVE_EXPAND);
// <------- Mod Options arangement

// By Taz - taz dynamic ratio
		m_ctrlTreeOptions.SetItemState(m_htiDynamicRatio, TVIS_BOLD, TVIS_BOLD);
		m_ctrlTreeOptions.Expand(m_htiDynamicRatio, TVE_EXPAND);
// <------- taz dynamic ratio

		m_ctrlTreeOptions.SetItemState(m_htiDisplayGroup, TVIS_BOLD, TVIS_BOLD);
		m_ctrlTreeOptions.Expand(m_htiDisplayGroup, TVE_EXPAND);

		m_ctrlTreeOptions.SetItemState(m_htiMoreTweaksGroup, TVIS_BOLD, TVIS_BOLD);
		m_ctrlTreeOptions.Expand(m_htiMoreTweaksGroup, TVE_EXPAND);

		m_ctrlTreeOptions.SendMessage(WM_VSCROLL, SB_TOP);
		m_bInitializedTreeOpts = true;
	}

	//////////////////////////////////////////////////////////////////////////
	// System tweaks
	//

	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiMultipleInstances, m_bMultipleInstances);

// By Taz - emule Priority
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiHighProcess, m_bHighProcess); //MORPH - Added by IceCream, high process priority
// <------- emule Priority

	/////////////////////////////////////////////////////////////////////////////
	// Download Management group
	//

// By Taz - retry connection attempts
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiRetryConnectionAttempts, m_bRetryConnectionAttempts);
// <------- retry connection attempts

//>>> WiZaRd::IntelliFlush
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiFileBufferSize, m_iFileBufferSize);
	DDV_MinMaxInt(pDX, m_iFileBufferSize, 256, 30*1024); //kB!
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiFileBufferTime, m_iFileBufferTime);
	DDV_MinMaxInt(pDX, m_iFileBufferTime, 0, 60); //minutes!
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiIntelliFlushCheck, m_bIntelliFlush);
	//hmmm doesn't work - damn those trees!
	if(m_iFileBufferTime < 1 || m_iFileBufferTime > 5)
	{
		m_ctrlTreeOptions.SetCheckBoxEnable(m_htiIntelliFlushCheck, FALSE);
		m_ctrlTreeOptions.SetCheckBox(m_htiIntelliFlushCheck, TRUE);
	}
	else
	{
		m_ctrlTreeOptions.SetCheckBoxEnable(m_htiIntelliFlushCheck, TRUE);
		m_ctrlTreeOptions.SetCheckBox(m_htiIntelliFlushCheck, m_bIntelliFlush);
	}
//<<< WiZaRd::IntelliFlush

//>>> Spike2::Emulate other
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiEmulateEdonkey, m_bEmulateEdonkey);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiEmulateEdonkeyHybrid, m_bEmulateEdonkeyHybrid);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiEmulateMLdonkey, m_bEmulateMLdonkey);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiEmulateShareaza, m_bEmulateShareaza);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiEmulateLphant, m_bEmulateLphant);
//<<< Spike2::Emulate other

//>>> JvA::SLS [enkeyDEV]
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiSLSCheck, m_bSLSCheck);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiSLSActivationLimit, m_iSLSActivationLimit);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiSLSSaveValue, m_iSLSSaveValue);
	DDV_MinMaxInt(pDX, m_iSLSActivationLimit, 0, 100);
	DDV_MinMaxInt(pDX, m_iSLSSaveValue, 0, 50);
//<<< JvA::SLS [enkeyDEV]

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiUseAutoHLRadio, m_iUseAutoHL);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiMaxSources, m_iMaxSources);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiMaxPerFileSources, m_iMaxPerFileSources);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiMinPerFileSources, m_iMinPerFileSources);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAHLUpdate, m_iAHLUpdate);
	DDV_MinMaxInt(pDX, m_iMaxSources, 1500, _UI16_MAX);
	DDV_MinMaxInt(pDX, m_iMaxPerFileSources, 150, _UI16_MAX);
	DDV_MinMaxInt(pDX, m_iMinPerFileSources, 25, _UI16_MAX);
	DDV_MinMaxInt(pDX, m_iAHLUpdate, 10, 600);
//<<< WiZaRd::AutoHL
// <------- AutoHL

// By Taz - drop sources
	// ==> drop sources - Stulle
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiAutoNNS, m_bEnableAutoDropNNSDefault);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoNNSTimer, m_iAutoNNS_TimerDefault);
	DDV_MinMaxInt(pDX, m_iAutoNNS_TimerDefault, 0, 60);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoNNSLimit, m_iMaxRemoveNNSLimitDefault);
	DDV_MinMaxInt(pDX, m_iMaxRemoveNNSLimitDefault, 50, 100);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiAutoFQS, m_bEnableAutoDropFQSDefault);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoFQSTimer, m_iAutoFQS_TimerDefault);
	DDV_MinMaxInt(pDX, m_iAutoFQS_TimerDefault, 0, 60);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoFQSLimit, m_iMaxRemoveFQSLimitDefault);
	DDV_MinMaxInt(pDX, m_iMaxRemoveFQSLimitDefault, 50, 100);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiAutoQRS, m_bEnableAutoDropQRSDefault);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoQRSTimer, m_iAutoHQRS_TimerDefault);
	DDV_MinMaxInt(pDX, m_iAutoHQRS_TimerDefault, 0, 60);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoQRSMax, m_iMaxRemoveQRSDefault);
	DDV_MinMaxInt(pDX, m_iMaxRemoveQRSDefault, 2500, 10000);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoQRSLimit, m_iMaxRemoveQRSLimitDefault);
	DDV_MinMaxInt(pDX, m_iMaxRemoveQRSLimitDefault, 50, 100);
	// <== drop sources - Stulle
// <------- drop sources

// By Taz - SCC
	// ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiDlMode, (int &)m_iDlMode);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiResumeFileInNewCat, m_iResumeFileInNewCat);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiShowCatNames, m_bShowCatNames);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiSelectCat, m_bSelectCat);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiUseActiveCat, m_bUseActiveCat);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiAutoSetResOrder, m_bAutoSetResOrder);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiSmallFileDLPush, m_bSmallFileDLPush);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiUseAutoCat, m_bUseAutoCat);
	// <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
// <------- SCC

// By Taz - Extended control download priority
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiAutoDown_start_PrioGroup, m_iAutoDown_start_Prio);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoDown_start_PrioPercVal, m_iAutoDown_start_PrioPerc);
	DDV_MinMaxInt(pDX, m_iAutoDown_start_PrioPerc, 1, 100);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoDown_start_PrioSizeVal, m_iAutoDown_start_PrioSize);
	DDV_MinMaxInt(pDX, m_iAutoDown_start_PrioSize, 1, 1024);
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiAutoDown_start_PrioValGroup, m_iAutoDown_start_PrioVal);
	// ==> Control download priority [tommy_gun/iONiX] - Stulle
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiAutoDown_end_PrioGroup, m_iAutoDownPrio);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoDownPrioPercVal, m_iAutoDownPrioPerc);
	DDV_MinMaxInt(pDX, m_iAutoDownPrioPerc, 1, 100);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiAutoDownPrioSizeVal, m_iAutoDownPrioSize);
	DDV_MinMaxInt(pDX, m_iAutoDownPrioSize, 1, 1024);
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiAutoDownPrioValGroup, m_iAutoDownPrioVal);
	// <== Control download priority [tommy_gun/iONiX] - Stulle
// <------- Extended control download priority

// By Taz - taz dynamic ratio
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiMaxDLULRatio, m_iMaxDLULRatio);
	DDV_MinMaxInt(pDX, m_iMaxDLULRatio, 0, 9);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiMaxDLSpeed, m_iMaxDLSpeed);
	if (m_iMaxDLSpeed > thePrefs.maxGraphDownloadRate * 9 / 10)
		m_iMaxDLSpeed = thePrefs.maxGraphDownloadRate * 9 / 10;
	DDV_MinMaxInt(pDX, m_iMaxDLSpeed, 0, thePrefs.maxGraphDownloadRate);
// <------- taz dynamic ratio

	/////////////////////////////////////////////////////////////////////////////
	// Upload Management group
	//

// By Taz - Anti Upload Protection
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiAntiUploadProtection, m_bAntiUploadProtection); // => Anti Upload Protection - sFrQlXeRt
// <------- Anti Upload Protection

	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiClientDataRate, m_uiClientDataRate);
	DDV_MinMaxInt(pDX, m_uiClientDataRate, 0, thePrefs.GetMaxUpload()/2);
	DDX_TreeEdit(pDX, IDC_SharkX_OPTS, m_htiFUChunks, m_uiFUChunks);
	DDV_MinMaxInt(pDX, m_uiFUChunks, 1, _UI8_MAX);

// By Taz - Multi CS
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiCreditSystem, m_iCreditSystem); //EastShare - added by linekin , CreditSystem

// By Taz - Fine CS
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiFineCredit, m_bFineCS);//EastShare - added by Pretender, modified Fine Credit System
// <------- Fine CS

// <------- Multi CS

	/////////////////////////////////////////////////////////////////////////////
	// Display group
	//

//>>> WiZaRd::minRQR [WiZaRd]
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiMinRQR, m_bUseMinRQR);
//<<< WiZaRd::minRQR [WiZaRd]

// By Taz - folder ICONS
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiFolderIcons, m_bFolderIcons);
// <------- folder ICONS

// By Taz - show SRC totals
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiShowSrcTotals, m_bShowSrcTotals);
// <------- show SRC totals

//>>> shadow2004::IP2Country [EastShare]
	DDX_TreeRadio(pDX, IDC_SharkX_OPTS, m_htiI2CGroup, m_iI2CCaption);
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiI2CShowFlag, m_bI2CShowFlag);
//<<< shadow2004::IP2Country [EastShare]

// By Taz - Advanced official preferences
	if (thePrefs.GetLanguageID() == LANGID_HE_IL)
		DDX_TreeCheck(pDX,IDC_SharkX_OPTS,m_hti_m_bRTLWindowsLayout,m_bRTLWindowsLayout);
// <------- Advanced official preferences

	/////////////////////////////////////////////////////////////////////////////
	// Misc group
	//

// By Taz - startup sound
	DDX_TreeCheck(pDX, IDC_SharkX_OPTS, m_htiStartupSound, m_bStartupSound);
// <------- startup sound

}

BOOL CPPgSharkX::OnInitDialog()
{
	m_bMultipleInstances = theApp.GetProfileInt(_T("eMule"), _T("IgnoreInstances"), 0) != 0;

// By Taz - emule Priority
	//MORPH START - Added by IceCream, high process priority
	m_bHighProcess = thePrefs.GetEnableHighProcess();
	//MORPH END   - Added by IceCream, high process priority
// <------- emule Priority

// By Taz - retry connection attempts
	m_bRetryConnectionAttempts = thePrefs.retryconnectionattempts;
// <------- retry connection attempts

//>>> WiZaRd::IntelliFlush
	m_iFileBufferSize = thePrefs.GetFileBufferSize()/1024; //kB!
	m_iFileBufferTime = thePrefs.GetFileBufferFlushTime()/60/1000; //minutes!
	m_bIntelliFlush = m_iFileBufferTime < 1 || m_iFileBufferTime > 5 || thePrefs.IsUseIntelliFlush();
//<<< WiZaRd::IntelliFlush

//>>> Spike2::Emulate other
	m_bEmulateEdonkey = thePrefs.IsEmueDonkey();
	m_bEmulateEdonkeyHybrid = thePrefs.IsEmueDonkeyHybrid();
	m_bEmulateMLdonkey = thePrefs.IsEmuMLDonkey();
	m_bEmulateShareaza = thePrefs.IsEmuShareaza();
	m_bEmulateLphant = thePrefs.IsEmuLphant();
//<<< Spike2::Emulate other

//>>> JvA::SLS [enkeyDEV]
	m_bSLSCheck = thePrefs.UseSaveLoadSources();
	m_iSLSActivationLimit = thePrefs.GetActivationLimitSLS();
	m_iSLSSaveValue = thePrefs.GetSourcesToSaveSLS();
//<<< JvA::SLS [enkeyDEV]

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
	m_iUseAutoHL = thePrefs.IsUseAutoHL()+1;
	m_iMaxSources = thePrefs.GetMaxSourcesHL();
	m_iMaxPerFileSources = thePrefs.GetMaxAutoHL();
	m_iMinPerFileSources = thePrefs.GetMinAutoHL();
	m_iAHLUpdate = thePrefs.GetAutoHLUpdateTimer();
//<<< WiZaRd::AutoHL
// <------- AutoHL

// By Taz - drop sources
	// ==> drop sources - Stulle
	m_bEnableAutoDropNNSDefault = thePrefs.m_EnableAutoDropNNSDefault;
	m_iAutoNNS_TimerDefault = (thePrefs.m_AutoNNS_TimerDefault/1000);
	m_iMaxRemoveNNSLimitDefault = thePrefs.m_MaxRemoveNNSLimitDefault;
	m_bEnableAutoDropFQSDefault = thePrefs.m_EnableAutoDropFQSDefault;
	m_iAutoFQS_TimerDefault = (thePrefs.m_AutoFQS_TimerDefault/1000);
	m_iMaxRemoveFQSLimitDefault = thePrefs.m_MaxRemoveFQSLimitDefault;
	m_bEnableAutoDropQRSDefault = thePrefs.m_EnableAutoDropQRSDefault;
	m_iAutoHQRS_TimerDefault = (thePrefs.m_AutoHQRS_TimerDefault/1000);
	m_iMaxRemoveQRSDefault = thePrefs.m_MaxRemoveQRSDefault;
	m_iMaxRemoveQRSLimitDefault = thePrefs.m_MaxRemoveQRSLimitDefault;
	// <== drop sources - Stulle
// <------- drop sources

// By Taz - SCC
	// ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
	m_iDlMode = thePrefs.GetDlMode();
	m_bShowCatNames = thePrefs.ShowCatNameInDownList();
	m_bSelectCat = thePrefs.SelectCatForNewDL();
	m_bUseActiveCat = thePrefs.UseActiveCatForLinks();
	m_bAutoSetResOrder = thePrefs.AutoSetResumeOrder();
	m_bSmallFileDLPush = thePrefs.SmallFileDLPush();
	m_iResumeFileInNewCat = thePrefs.StartDLInEmptyCats();
	m_bUseAutoCat = thePrefs.UseAutoCat();
	// <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
// <------- SCC

// By Taz - Extended control download priority
	m_iAutoDown_start_Prio = thePrefs.GetStartAutoPrioMode();
	m_iAutoDown_start_PrioPerc = thePrefs.GetStartAutoPrioPercentValue();
	m_iAutoDown_start_PrioSize = thePrefs.GetStartAutoPrioSizeValue();
	m_iAutoDown_start_PrioVal = thePrefs.GetStartAutoPrioNewValue();
	// ==> Control download priority [tommy_gun/iONiX] - Stulle
	m_iAutoDownPrio = thePrefs.GetEndAutoPrioMode();
	m_iAutoDownPrioPerc = thePrefs.GetEndAutoPrioPercentValue();
	m_iAutoDownPrioSize = thePrefs.GetEndAutoPrioSizeValue();
	m_iAutoDownPrioVal = thePrefs.GetEndAutoPrioNewValue();
	// <== Control download priority [tommy_gun/iONiX] - Stulle
// <------- Extended control download priority

// By Taz - taz dynamic ratio
	m_iMaxDLULRatio = thePrefs.GetMaxDLULRatio();
	m_iMaxDLSpeed = thePrefs.GetMaxSessionDownload();
// <------- taz dynamic ratio

// By Taz - Anti Upload Protection
	// ==> Anti Upload Protection - sFrQlXeRt
	m_bAntiUploadProtection = thePrefs.IsAntiUploadProtection();
	// <== Anti Upload Protection - sFrQlXeRt
// <------- Anti Upload Protection

	m_uiClientDataRate = thePrefs.GetClientDataRate()/1024;
	m_uiFUChunks = thePrefs.GetFUChunks();

// By Taz - Multi CS
	m_iCreditSystem = thePrefs.GetCreditSystem(); //EastShare - Added by linekin , CreditSystem

// BY Taz - Fine CS
	m_bFineCS = thePrefs.FineCS();//EastShare - added by Pretender, modified Fine Credit System
// <------- Fine CS

// <------- Multi CS

//>>> WiZaRd::minRQR [WiZaRd
	m_bUseMinRQR = thePrefs.ShowMinRQR();
//<<< WiZaRd::minRQR [WiZaRd]

// By Taz - folder ICONS
	m_bFolderIcons = thePrefs.m_bShowFolderIcons;
// <------- folder ICONS

// By Taz - show SRC totals
	m_bShowSrcTotals = thePrefs.GetShowSrcTotals();
// <------- show SRC totals

//>>> shadow2004::IP2Country [EastShare]
	m_iI2CCaption = thePrefs.GetIP2CountryNameMode();
	m_bI2CShowFlag = thePrefs.IsIP2CountryShowFlag();
//<<< shadow2004::IP2Country [EastShare]

// By Taz - Advanced official preferences
	if (thePrefs.GetLanguageID() == LANGID_HE_IL)
		m_bRTLWindowsLayout=thePrefs.m_bRTLWindowsLayout;
// <------- Advanced official preferences

// By Taz - startup sound
	m_bStartupSound = thePrefs.StartupSound();
// <------- startup sound

	CPropertyPage::OnInitDialog();
	InitWindowStyles(this);
	m_ctrlTreeOptions.SetItemHeight(m_ctrlTreeOptions.GetItemHeight() + 2);

	Localize();

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CPPgSharkX::OnKillActive()
{
	// if prop page is closed by pressing ENTER we have to explicitly commit any possibly pending
	// data from an open edit control
	m_ctrlTreeOptions.HandleChildControlLosingFocus();
	return CPropertyPage::OnKillActive();
}

BOOL CPPgSharkX::OnApply()
{
	// if prop page is closed by pressing ENTER we have to explicitly commit any possibly pending
	// data from an open edit control
	m_ctrlTreeOptions.HandleChildControlLosingFocus();

	if (!UpdateData())
		return FALSE;

    SetModified(FALSE);

	theApp.WriteProfileInt(_T("eMule"), _T("IgnoreInstances"), m_bMultipleInstances ? 1 : 0);

// By Taz - emule Priority
	//MORPH START - Added by IceCream, high process priority
	thePrefs.SetEnableHighProcess(m_bHighProcess);
	//MORPH END   - Added by IceCream, high process priority
// <------- emule Priority

// By Taz - retry connection attempts
	thePrefs.retryconnectionattempts = m_bRetryConnectionAttempts;
// <------- retry connection attempts

//>>> WiZaRd::IntelliFlush
	thePrefs.SetFileBufferSize(m_iFileBufferSize*1024);
	thePrefs.SetFileBufferFlushTime(m_iFileBufferTime*60*1000);
	thePrefs.SetUseIntelliFlush(m_bIntelliFlush || m_iFileBufferTime < 1 || m_iFileBufferTime > 5);
//<<< WiZaRd::IntelliFlush

//>>> Spike2::Emulate other
	thePrefs.SetEmueDonkey(m_bEmulateEdonkey);
	thePrefs.SetEmueDonkeyHybrid(m_bEmulateEdonkeyHybrid);
	thePrefs.SetEmuMLDonkey(m_bEmulateMLdonkey);
	thePrefs.SetEmuShareaza(m_bEmulateShareaza);
	thePrefs.SetEmuLphant(m_bEmulateLphant);
//<<< Spike2::Emulate other

//>>> JvA::SLS [enkeyDEV]
	thePrefs.SetSaveLoadSource(m_bSLSCheck);
	thePrefs.SetActivationLimitSLS((uint8)m_iSLSActivationLimit);
	thePrefs.SetSourcesToSaveSLS((uint8)m_iSLSSaveValue);
//<<< JvA::SLS [enkeyDEV]

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
	if(thePrefs.IsUseAutoHL() != m_iUseAutoHL-1)
	{
		thePrefs.SetUseAutoHL((sint8)m_iUseAutoHL-1);
		if(thePrefs.IsUseAutoHL() == 0) //globally disabled
		{
			for(UINT i = 0; i < (UINT)theApp.downloadqueue->GetFileCount(); i++)
				theApp.downloadqueue->GetFileByIndex(i)->SetPrivateMaxSources(thePrefs.GetMaxSourcePerFileDefault());
		}
	}
	thePrefs.SetMaxSourcesHL((uint16)m_iMaxSources);
	thePrefs.SetMaxAutoHL((uint16)m_iMaxPerFileSources);
	thePrefs.SetMinAutoHL((uint16)m_iMinPerFileSources);
	thePrefs.SetAutoHLUpdateTimer((uint16)m_iAHLUpdate);
//<<< WiZaRd::AutoHL
// <------- AutoHL

// By Taz - drop sources
	// ==> drop sources - Stulle
	thePrefs.m_EnableAutoDropNNSDefault = m_bEnableAutoDropNNSDefault;
	thePrefs.m_AutoNNS_TimerDefault = (m_iAutoNNS_TimerDefault*1000);
	thePrefs.m_MaxRemoveNNSLimitDefault = (uint16)m_iMaxRemoveNNSLimitDefault;
	thePrefs.m_EnableAutoDropFQSDefault = m_bEnableAutoDropFQSDefault;
	thePrefs.m_AutoFQS_TimerDefault = (m_iAutoFQS_TimerDefault*1000);
	thePrefs.m_MaxRemoveFQSLimitDefault = (uint16)m_iMaxRemoveFQSLimitDefault;
	thePrefs.m_EnableAutoDropQRSDefault = m_bEnableAutoDropQRSDefault;
	thePrefs.m_AutoHQRS_TimerDefault = (m_iAutoHQRS_TimerDefault*1000);
	thePrefs.m_MaxRemoveQRSDefault = (uint16)m_iMaxRemoveQRSDefault;
	thePrefs.m_MaxRemoveQRSLimitDefault = (uint16)m_iMaxRemoveQRSLimitDefault;
	// <== drop sources - Stulle
// <------- drop sources

// By Taz - SCC
	// ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
	thePrefs.dlMode = (uint8)m_iDlMode;
	thePrefs.m_bShowCatNames = m_bShowCatNames;
	thePrefs.m_bSelCatOnAdd = m_bSelectCat;
	thePrefs.m_bActiveCatDefault = m_bUseActiveCat;
	thePrefs.m_bAutoSetResumeOrder = m_bAutoSetResOrder;
	thePrefs.m_bSmallFileDLPush = m_bSmallFileDLPush;
	thePrefs.m_iStartDLInEmptyCats = (uint8)m_iResumeFileInNewCat;
	thePrefs.m_bUseAutoCat = m_bUseAutoCat;
	// <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
// <------- SCC

// By Taz - Extended control download priority
	thePrefs.m_uiStartAutoPrioMode = (uint8)m_iAutoDown_start_Prio;
	thePrefs.m_nStartAutoPrioPercentValue = (uint8)m_iAutoDown_start_PrioPerc;
	thePrefs.m_nStartAutoPrioSizeValue = (uint16)m_iAutoDown_start_PrioSize;
	thePrefs.m_nStartAutoPrioNewValue = (uint8)m_iAutoDown_start_PrioVal;
	// ==> Control download priority [tommy_gun/iONiX] - Stulle
	thePrefs.m_uiEndAutoPrioMode = (uint8)m_iAutoDownPrio;
	thePrefs.m_nEndAutoPrioPercentValue = (uint8)m_iAutoDownPrioPerc;
	thePrefs.m_nEndAutoPrioSizeValue = (uint16)m_iAutoDownPrioSize;
	thePrefs.m_nEndAutoPrioNewValue = (uint8)m_iAutoDownPrioVal;
	// <== Control download priority [tommy_gun/iONiX] - Stulle
// <------- Extended control download priority

// By Taz - taz dynamic ratio
	thePrefs.SetMaxDLULRatio(m_iMaxDLULRatio);
	thePrefs.SetMaxSessionDownload(m_iMaxDLSpeed);
// <------- taz dynamic ratio

// By Taz - Anti Upload Protection
	// ==> Anti Upload Protection - sFrQlXeRt
	thePrefs.m_bAntiUploadProtection = m_bAntiUploadProtection;
	// <== Anti Upload Protection - sFrQlXeRt
// <------- Anti Upload Protection

	if(m_uiClientDataRate != 0)
		m_uiClientDataRate = max(m_uiClientDataRate, 3);
	thePrefs.SetClientDataRate((uint16)(m_uiClientDataRate*1024));
	if(thePrefs.GetFUChunks() != (uint8)m_uiFUChunks)
	{
		thePrefs.SetFUChunks((uint8)m_uiFUChunks);
		theApp.uploadqueue->UpdateRemainingUp(); // VQB: fullChunk
	}

// By Taz - Multi CS
	//MORPH START - Changed by SiRoB, reduce a little CPU usage for ratio count
	if(thePrefs.creditSystemMode != m_iCreditSystem || thePrefs.m_bAntiUploadProtection != m_bAntiUploadProtection){
		theApp.clientcredits->ReCheckRatio();
	}
	//MORPH END - Changed by SiRoB, reduce a little CPU usage for ratio count
	thePrefs.creditSystemMode = m_iCreditSystem; //EastShare - Added by linekin , CreditSystem

// By Taz - Fine CS
	thePrefs.m_bFineCS = m_bFineCS;//EastShare - added by Pretender, modified Fine Credit System
// <------- Fine CS

// <------- Multi CS

//>>> WiZaRd::minRQR [WiZaRd]
	thePrefs.SetMinRQR(m_bUseMinRQR);
//<<< WiZaRd::minRQR [WiZaRd]

// By Taz - folder ICONS
	if(thePrefs.m_bShowFolderIcons != (m_bFolderIcons == 1))
	{
		if(m_bFolderIcons)
		{
			theApp.AddIncomingFolderIcon();
//			theApp.AddTempFolderIcon(); // by taz - for now
		}
		else
		{
			theApp.RemoveIncomingFolderIcon();
//			theApp.RemoveTempFolderIcon(); // by taz - for now
		}
	}
	thePrefs.m_bShowFolderIcons = m_bFolderIcons;
// <------- folder ICONS

// By Taz - show SRC totals
	thePrefs.SetShowSrcTotals(m_bShowSrcTotals);
// <------- show SRC totals

//>>> shadow2004::IP2Country [EastShare]
	//Check if ip2country is loaded at this point
	if (!theApp.ip2country->IsIP2Country())
		theApp.ip2country->Load();
	thePrefs.SetIP2CountryNameMode((uint8)m_iI2CCaption);
	thePrefs.SetIP2CountryShowFlag(m_bI2CShowFlag);
	theApp.ip2country->Refresh();//refresh passive windows
//<<< shadow2004::IP2Country [EastShare]

// By Taz - Advanced official preferences
	if (thePrefs.GetLanguageID() == LANGID_HE_IL && thePrefs.m_bRTLWindowsLayout != m_bRTLWindowsLayout){
		thePrefs.m_bRTLWindowsLayout=m_bRTLWindowsLayout;
		AfxMessageBox(GetResString(IDS_SETTINGCHANGED_RESTART));
	}
// <------- Advanced official preferences

// By Taz - startup sound
	thePrefs.SetStartupSound(m_bStartupSound);
// <------- startup sound

	return CPropertyPage::OnApply();
}

void CPPgSharkX::Localize(void)
{
	if(m_hWnd)
	{
		CString buffer;
		SetWindowText(MOD_VERSION);

		if (m_htiSystemGroup) m_ctrlTreeOptions.SetItemText(m_htiSystemGroup, GetResString(IDS_SYSTEM));

		if (m_htiMultipleInstances) m_ctrlTreeOptions.SetItemText(m_htiMultipleInstances, GetResString(IDS_MULTIPLE_INSTANCES));

// By Taz - emule Priority
		//MORPH START - Added by IceCream, high process priority
		if (m_htiHighProcess) {m_ctrlTreeOptions.SetItemText(m_htiHighProcess, GetResString(IDS_HIGHPROCESS));
//							   SetTool(m_htiHighProcess,IDS_HIGHPROCESS_TIP);
		}
		//MORPH END   - Added by IceCream, high process priority
// <------- emule Priority

// By Taz - Mod Options arangement
		if (m_htiDM) m_ctrlTreeOptions.SetItemText(m_htiDM, GetResString(IDS_DM));
// <------- Mod Options arangement

// By Taz - retry connection attempts
		if(m_htiRetryConnectionAttempts) m_ctrlTreeOptions.SetItemText(m_htiRetryConnectionAttempts, GetResString(IDS_RETRYCONNECTIONATTEMPTS));
// <------- retry connection attempts

//>>> WiZaRd::IntelliFlush
		if (m_htiFileBufferGroup) m_ctrlTreeOptions.SetItemText(m_htiFileBufferGroup, GetResString(IDS_FILEBUFFER));
		if (m_htiFileBufferSize)
		{
			buffer.Format(_T("%s [%s]"), GetResString(IDS_FILEBUFFERSIZE), GetResString(IDS_KBYTES));
			m_ctrlTreeOptions.SetEditLabel(m_htiFileBufferSize, buffer);
		}
		if (m_htiFileBufferTime)	m_ctrlTreeOptions.SetEditLabel(m_htiFileBufferTime, GetResString(IDS_FILEBUFFER_TIME));
		if (m_htiIntelliFlushCheck) m_ctrlTreeOptions.SetItemText(m_htiIntelliFlushCheck, GetResString(IDS_FILEBUFFER_INTELLI));
//<<< WiZaRd::IntelliFlush

//>>> Spike2::Emulate other
		if (m_htiEmulateGroup) m_ctrlTreeOptions.SetItemText(m_htiEmulateGroup, GetResString(IDS_EMULATE));
		if (m_htiEmulateEdonkey) m_ctrlTreeOptions.SetItemText(m_htiEmulateEdonkey, GetResString(IDS_EMU_EDONKEY));
		if (m_htiEmulateEdonkeyHybrid) m_ctrlTreeOptions.SetItemText(m_htiEmulateEdonkeyHybrid, GetResString(IDS_EMU_EDONKEYHYBRID));
		if (m_htiEmulateMLdonkey) m_ctrlTreeOptions.SetItemText(m_htiEmulateMLdonkey, GetResString(IDS_EMU_MLDONKEY));
		if (m_htiEmulateShareaza) m_ctrlTreeOptions.SetItemText(m_htiEmulateShareaza, GetResString(IDS_EMU_SHAREAZA));
		if (m_htiEmulateLphant) m_ctrlTreeOptions.SetItemText(m_htiEmulateLphant, GetResString(IDS_EMU_LPHANT));
//<<< Spike2::Emulate other

//>>> JvA::SLS [enkeyDEV]
		if(m_htiSLSGroup) m_ctrlTreeOptions.SetItemText(m_htiSLSGroup, GetResString(IDS_SLSLABEL));
		if(m_htiSLSCheck) m_ctrlTreeOptions.SetItemText(m_htiSLSCheck, GetResString(IDS_SLSCHECKLABEL));
		if(m_htiSLSActivationLimit) m_ctrlTreeOptions.SetEditLabel(m_htiSLSActivationLimit, GetResString(IDS_SLSACTIVATIONLABEL));
		if(m_htiSLSSaveValue) m_ctrlTreeOptions.SetEditLabel(m_htiSLSSaveValue, GetResString(IDS_SLSSAVEVALUE));
//<<< JvA::SLS [enkeyDEV]

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
		if (m_htiAutoHL) m_ctrlTreeOptions.SetItemText(m_htiAutoHL, GetResString(IDS_AUTOHL));
		if (m_htiUseAutoHLRadio) m_ctrlTreeOptions.SetItemText(m_htiUseAutoHLRadio, GetResString(IDS_USE_AUTOHL));
		if (m_htiUseAutoHLPerFile) m_ctrlTreeOptions.SetItemText(m_htiUseAutoHLPerFile, GetResString(IDS_PER_FILE));
		if (m_htiUseAutoHLOn) m_ctrlTreeOptions.SetItemText(m_htiUseAutoHLOn, GetResString(IDS_OFF));
		if (m_htiUseAutoHLOff) m_ctrlTreeOptions.SetItemText(m_htiUseAutoHLOff, GetResString(IDS_ON));
		if (m_htiMaxSources) m_ctrlTreeOptions.SetEditLabel(m_htiMaxSources, GetResString(IDS_MAX_SOURCES));
		if (m_htiMaxPerFileSources) m_ctrlTreeOptions.SetEditLabel(m_htiMaxPerFileSources, GetResString(IDS_MAX_PERFILESOURCES));
		if (m_htiMinPerFileSources) m_ctrlTreeOptions.SetEditLabel(m_htiMinPerFileSources, GetResString(IDS_MIN_PERFILESOURCES));
		if (m_htiAHLUpdate) m_ctrlTreeOptions.SetEditLabel(m_htiAHLUpdate, GetResString(IDS_AHL_UPDATETIME));
//<<< WiZaRd::AutoHL
// <------- AutoHL

// By Taz - drop sources
		// ==> drop sources - Stulle
		if (m_htiAutoNNS) m_ctrlTreeOptions.SetItemText(m_htiAutoNNS, GetResString(IDS_AUTO_NNS));
		if (m_htiAutoNNSTimer) m_ctrlTreeOptions.SetEditLabel(m_htiAutoNNSTimer, GetResString(IDS_NNS_TIMERLABEL));
		if (m_htiAutoNNSLimit) m_ctrlTreeOptions.SetEditLabel(m_htiAutoNNSLimit, GetResString(IDS_REMOVENNSLIMITLABEL));
		if (m_htiAutoFQS) m_ctrlTreeOptions.SetItemText(m_htiAutoFQS, GetResString(IDS_AUTO_FQS));
		if (m_htiAutoFQSTimer) m_ctrlTreeOptions.SetEditLabel(m_htiAutoFQSTimer, GetResString(IDS_FQS_TIMERLABEL));
		if (m_htiAutoFQSLimit) m_ctrlTreeOptions.SetEditLabel(m_htiAutoFQSLimit, GetResString(IDS_REMOVEFQSLIMITLABEL));
		if (m_htiAutoQRS) m_ctrlTreeOptions.SetItemText(m_htiAutoQRS, GetResString(IDS_AUTO_QRS));
		if (m_htiAutoQRSTimer) m_ctrlTreeOptions.SetEditLabel(m_htiAutoQRSTimer, GetResString(IDS_HQRS_TIMERLABEL));
		if (m_htiAutoQRSMax) m_ctrlTreeOptions.SetEditLabel(m_htiAutoQRSMax, GetResString(IDS_REMOVEQRSLABEL));
		if (m_htiAutoQRSLimit) m_ctrlTreeOptions.SetEditLabel(m_htiAutoQRSLimit, GetResString(IDS_REMOVEQRSLIMITLABEL));
		// <== drop sources - Stulle
// <------- drop sources

// By Taz - SCC
		// ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
		if (m_htiShowCatNames) m_ctrlTreeOptions.SetItemText(m_htiShowCatNames, GetResString(IDS_CAT_SHOWCATNAME));
		if (m_htiSelectCat) m_ctrlTreeOptions.SetItemText(m_htiSelectCat, GetResString(IDS_CAT_SHOWSELCATDLG));
		if (m_htiUseAutoCat) m_ctrlTreeOptions.SetItemText(m_htiUseAutoCat, GetResString(IDS_CAT_USEAUTOCAT));
        if (m_htiUseActiveCat) m_ctrlTreeOptions.SetItemText(m_htiUseActiveCat, GetResString(IDS_CAT_USEACTIVE));
		if (m_htiAutoSetResOrder) m_ctrlTreeOptions.SetItemText(m_htiAutoSetResOrder, GetResString(IDS_CAT_AUTORESUMEORD));
		if (m_htiSmallFileDLPush) m_ctrlTreeOptions.SetItemText(m_htiSmallFileDLPush, GetResString(IDS_CAT_SMALLFILEDLPUSH));
		if (m_htiResumeFileInNewCat) m_ctrlTreeOptions.SetEditLabel(m_htiResumeFileInNewCat, GetResString(IDS_CAT_STARTFILESONADD));
		// <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
// <------- SCC

// By Taz - taz dynamic ratio
		if (m_htiDynamicRatio) m_ctrlTreeOptions.SetItemText(m_htiDynamicRatio, GetResString(IDS_TAZDynamicRatio));
		if (m_htiMaxDLULRatio) m_ctrlTreeOptions.SetEditLabel(m_htiMaxDLULRatio, GetResString(IDS_MaxDLULRatio));
		if (m_htiMaxDLSpeed) m_ctrlTreeOptions.SetEditLabel(m_htiMaxDLSpeed, GetResString(IDS_MaxDLSpeed));
// <------- taz dynamic ratio

// By Taz - Mod Options arangement
		if (m_htiUM) m_ctrlTreeOptions.SetItemText(m_htiUM, GetResString(IDS_UM));
// <------- Mod Options arangement

// By Taz - Fine CS
		if (m_htiFineCredit) m_ctrlTreeOptions.SetItemText(m_htiFineCredit, GetResString(IDS_FINE_CREDIT));//EastShare - added by Pretender, modified Fine Credit System
// <------- Fine CS

// By Taz - Anti Upload Protection
		if (m_htiAntiUploadProtection) m_ctrlTreeOptions.SetItemText(m_htiAntiUploadProtection, GetResString(IDS_ANTI_UP_PROTECTION)); // => Anti Upload Protection - sFrQlXeRt
// <------- Anti Upload Protection

		if (m_htiClientDataRate) m_ctrlTreeOptions.SetEditLabel(m_htiClientDataRate, GetResString(IDS_DATARATE_ADJUST));
		if (m_htiFUChunks) m_ctrlTreeOptions.SetEditLabel(m_htiFUChunks, GetResString(IDS_FUCHUNKS));

// By Taz - EMF
		if(m_htiDisplayGroup) m_ctrlTreeOptions.SetItemText(m_htiDisplayGroup, GetResString(IDS_PW_DISPLAY));
// <------- EMF

//>>> WiZaRd::minRQR [WiZaRd]
		if(m_htiMinRQR) m_ctrlTreeOptions.SetItemText(m_htiMinRQR, GetResString(IDS_MINRQR_ENABLE));
//<<< WiZaRd::minRQR [WiZaRd]

// By Taz - folder ICONS
		if (m_htiFolderIcons) m_ctrlTreeOptions.SetItemText(m_htiFolderIcons, GetResString(IDS_FOLDERICONS));
// <------- folder ICONS

// By Taz - show SRC totals
		if(m_htiShowSrcTotals) m_ctrlTreeOptions.SetItemText(m_htiShowSrcTotals, GetResString(IDS_ShowSrcTotals));
// <------- show SRC totals

//>>> shadow2004::IP2Country [EastShare]
		if(m_htiI2CGroup) m_ctrlTreeOptions.SetItemText(m_htiI2CGroup, GetResString(IDS_IP2COUNTRY));
		if(m_htiI2C2Letter) m_ctrlTreeOptions.SetItemText(m_htiI2C2Letter, GetResString(IDS_IP2COUNTRY_2LETTERS));
		if(m_htiI2C3Letter) m_ctrlTreeOptions.SetItemText(m_htiI2C3Letter, GetResString(IDS_IP2COUNTRY_3LETTERS));
		if(m_htiI2CFullCaption) m_ctrlTreeOptions.SetItemText(m_htiI2CFullCaption, GetResString(IDS_IP2COUNTRY_FULLCAPTION));
		if(m_htiI2CShowFlag) m_ctrlTreeOptions.SetItemText(m_htiI2CShowFlag, GetResString(IDS_IP2COUNTRY_SHOWFLAGS));
//<<< shadow2004::IP2Country [EastShare]

// By Taz - Advanced official preferences
		if (thePrefs.GetLanguageID() == LANGID_HE_IL && m_hti_m_bRTLWindowsLayout)
			m_ctrlTreeOptions.SetItemText(m_hti_m_bRTLWindowsLayout, GetResString(IDS_RTLWINDOWSLAYOUT));
// <------- Advanced official preferences

		if(m_htiMoreTweaksGroup) m_ctrlTreeOptions.SetItemText(m_htiMoreTweaksGroup, GetResString(IDS_PW_MISC));

// By Taz - startup sound
		if(m_htiStartupSound) m_ctrlTreeOptions.SetItemText(m_htiStartupSound, GetResString(IDS_PW_STARTUPSOUND));
// <------- startup sound

	}
}

void CPPgSharkX::OnDestroy()
{
	m_ctrlTreeOptions.DeleteAllItems();
	m_ctrlTreeOptions.DestroyWindow();
	m_bInitializedTreeOpts = false;

	Nullify();

	CPropertyPage::OnDestroy();
}

LRESULT CPPgSharkX::OnTreeOptsCtrlNotify(WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	if (wParam == IDC_SharkX_OPTS)
	{
		//TREEOPTSCTRLNOTIFY* pton = (TREEOPTSCTRLNOTIFY*)lParam;
		//(void*) pton;

		SetModified();
	}
	return 0;
}

void CPPgSharkX::OnHelp()
{
//>>> WiZaRd:EMF Link
	theApp.emuledlg->SendMessage(WM_COMMAND, MP_HM_LINK4, 0);
//<<< WiZaRd:EMF Link
}

BOOL CPPgSharkX::OnCommand(WPARAM wParam, LPARAM lParam)
{
	if (wParam == ID_HELP)
	{
		OnHelp();
		return TRUE;
	}
	return __super::OnCommand(wParam, lParam);
}

BOOL CPPgSharkX::OnHelpInfo(HELPINFO* /*pHelpInfo*/)
{
	OnHelp();
	return TRUE;
}

//all variables are to be reset in here
void	CPPgSharkX::Nullify()
{

	m_htiSystemGroup = NULL;

	m_htiMultipleInstances = NULL;
	m_bMultipleInstances = false;

// By Taz - emule Priority
	m_htiHighProcess = NULL; //MORPH - Added by IceCream, high process priority
// <------- emule Priority

// By Taz - Mod Options arangement
	m_htiDM = NULL;
// <------- Mod Options arangement

// By Taz - retry connection attempts
	m_htiRetryConnectionAttempts = NULL;
	m_bRetryConnectionAttempts = false;
// <------- retry connection attempts

//>>> WiZaRd::IntelliFlush
	m_htiFileBufferGroup = NULL;
	m_htiFileBufferSize = NULL;
	m_htiFileBufferTime = NULL;
	m_htiIntelliFlushCheck = NULL;
	m_iFileBufferSize = 0;
	m_iFileBufferTime = 0;
	m_bIntelliFlush = false;
//<<< WiZaRd::IntelliFlush

//>>> Spike2::Emulate other
	m_htiEmulateGroup = NULL;

	m_htiEmulateEdonkey = NULL;
	m_htiEmulateEdonkeyHybrid = NULL;
	m_htiEmulateMLdonkey = NULL;
	m_htiEmulateShareaza = NULL;
	m_htiEmulateLphant = NULL;
//<<< Spike2::Emulate other

//>>> JvA::SLS [enkeyDEV]
	m_htiSLSGroup = NULL;
	m_htiSLSCheck = NULL;
	m_htiSLSActivationLimit = NULL;
	m_htiSLSSaveValue = NULL;
	m_bSLSCheck = false;
	m_iSLSActivationLimit = 0;
	m_iSLSSaveValue = 0;
//<<< JvA::SLS [enkeyDEV]

// By Taz - AutoHL
//>>> WiZaRd::AutoHL
	m_htiAutoHL = NULL;

	m_htiUseAutoHLRadio = NULL;
	m_htiUseAutoHLPerFile = NULL;
	m_htiUseAutoHLOn = NULL;
	m_htiUseAutoHLOff = NULL;
	m_iUseAutoHL = 0;

	m_htiMaxSources = NULL;
	m_iMaxSources = 0;

	m_htiMaxPerFileSources = NULL;
	m_iMaxPerFileSources = 0;

	m_htiMinPerFileSources = NULL;
	m_iMinPerFileSources = 0;

	m_htiAHLUpdate = NULL;
	m_iAHLUpdate = 0;
//<<< WiZaRd::AutoHL
// <------- AutoHL

// By Taz - drop sources
	// ==> drop sources - Stulle
	m_htiDropDefaults = NULL;
	m_htiAutoNNS = NULL;
	m_htiAutoNNSTimer = NULL;
	m_htiAutoNNSLimit = NULL;
	m_htiAutoFQS = NULL;
	m_htiAutoFQSTimer = NULL;
	m_htiAutoFQSLimit = NULL;
	m_htiAutoQRS = NULL;
	m_htiAutoQRSTimer = NULL;
	m_htiAutoQRSMax = NULL;
	m_htiAutoQRSLimit = NULL;
	// <== drop sources - Stulle
// <------- drop sources

// By Taz - taz dynamic ratio
		m_htiDynamicRatio = NULL;
		m_htiMaxDLULRatio = NULL;
		m_htiMaxDLSpeed = NULL;
		m_iMaxDLULRatio = 0;
		m_iMaxDLSpeed = 0;
// <------- taz dynamic ratio

// By Taz - Mod Options arangement
	m_htiUM = NULL;
// <------- Mod Options arangement

// By Taz - Anti Upload Protection
	// ==> Anti Upload Protection - sFrQlXeRt
	m_htiAntiUploadProtection = NULL;
	// <== Anti Upload Protection - sFrQlXeRt
// <------- Anti Upload Protection

	m_htiClientDataRate = NULL;
	m_uiClientDataRate = 0;

	m_htiFUChunks = NULL;
	m_uiFUChunks = 0;

// By Taz - Multi CS
	//EastShare START - Added by Pretender
	m_htiCreditSystem = NULL;
	m_htiOfficialCredit = NULL;
/*	m_htiRatioCredit = NULL;
	// ==> new credit system - Stulle
	m_htiSivkaCredit = NULL;
	m_htiSwatCredit = NULL;
	m_htiTk4Credit = NULL;
	m_htiZzulCredit = NULL;
*/	m_htiXtremeCredit = NULL;
	// <== new credit system - Stulle
	//EastShare END - Added by Pretender

// By Taz - MagicAngel CS
	m_htiMagicAngelCredit = NULL;
//	m_htiMagicAngelPlusCredit = NULL;
// <------- MagicANgel CS

	m_htiLovelaceCredit = NULL;
	m_htiPawcioCredit = NULL;
	m_htiESCredit = NULL;

// By Taz - ClientAnalyzer
#ifdef CLIENTANALYZER
	m_htiCACredit = NULL;
#endif
// <------- ClientAnalyzer

// By Taz - Fine CS
	m_bFineCS = false;
	m_htiFineCredit = NULL;
// <------- Fine CS

// <------- Multi CS
// By Taz - EMF
	m_htiDisplayGroup = NULL;
// <------- EMF

//>>> WiZaRd::minRQR [WiZaRd]
	m_htiMinRQR = NULL;
	m_bUseMinRQR = false;
//<<< WiZaRd::minRQR [WiZaRd]

// By Taz - folder ICONS
	m_htiFolderIcons = NULL;
	m_bFolderIcons = false;
// <------- folder ICONS

// By Taz - show SRC totals
	m_htiShowSrcTotals = NULL;
	m_bShowSrcTotals = false;
// <------- show SRC totals

//>>> shadow2004::IP2Country [EastShare]
	m_htiI2CGroup = NULL;
	m_htiI2C2Letter = NULL;
	m_htiI2C3Letter = NULL;
	m_htiI2CFullCaption = NULL;
	m_htiI2CShowFlag = NULL;
	m_iI2CCaption = 0;
	m_bI2CShowFlag = false;
//<<< shadow2004::IP2Country [EastShare]

// By Taz - Advanced official preferences
	m_hti_m_bRTLWindowsLayout=NULL;
	m_bRTLWindowsLayout=false;
// <------- Advanced official preferences

	m_htiMoreTweaksGroup = NULL;

// By Taz - startup sound
	m_htiStartupSound = NULL;
	m_bStartupSound = false;
// <------- startup sound

// By Taz - SCC
	// ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
	m_htiSCC = NULL;
	m_htiDlMode = NULL;
	m_htiDlNone = NULL;
	m_htiDlAlph = NULL;
	m_htiDlLP = NULL;
	m_htiShowCatNames = NULL;
	m_htiSelectCat = NULL;
	m_htiUseActiveCat = NULL;
	m_htiAutoSetResOrder = NULL;
	m_htiSmallFileDLPush = NULL;
	m_htiResumeFileInNewCat = NULL;
	m_htiUseAutoCat = NULL;
	// <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle
// <------- SCC

// By Taz - Extended control download priority
	m_htiAutoDownPrioGroup = NULL;
	m_htiAutoDown_start_PrioGroup = NULL;
	m_htiAutoDown_start_PrioOff = NULL;
	m_htiAutoDown_start_PrioPerc = NULL;
	m_htiAutoDown_start_PrioPercVal = NULL;
	m_htiAutoDown_start_PrioSize = NULL;
	m_htiAutoDown_start_PrioSizeVal = NULL;
	m_htiAutoDown_start_PrioValGroup = NULL;
	m_htiAutoDown_start_PrioLow = NULL;
	m_htiAutoDown_start_PrioNormal = NULL;
	m_htiAutoDown_start_PrioHigh = NULL;
	// ==> Control download priority [tommy_gun/iONiX] - Stulle
	m_htiAutoDown_end_PrioGroup = NULL;
	m_htiAutoDownPrioOff = NULL;
	m_htiAutoDownPrioPerc = NULL;
	m_htiAutoDownPrioPercVal = NULL;
	m_htiAutoDownPrioSize = NULL;
	m_htiAutoDownPrioSizeVal = NULL;
	m_htiAutoDownPrioValGroup = NULL;
	m_htiAutoDownPrioLow = NULL;
	m_htiAutoDownPrioNormal = NULL;
	m_htiAutoDownPrioHigh = NULL;
	// <== Control download priority [tommy_gun/iONiX] - Stulle
// <------- Extended control download priority

}