[Main.Init]
SetVariable(cgfVar_SharePrinter,false);

RunSection(GetOSCode);
RunSection(GetCountryCode);
RunSection(FormatLexURLs);
SetVariable(OEM,%OEM%);

#Path for OEM Rewards
SetVariable(cgfVar_RewardsDLL,$DRIVER_MULTI_OS_DIR$\%ModelCode%lnks.dll);
SetVariable(cgfVar_RewardsINI,$SYSTEM_DIR$\%ModelCode%rwrd.ini);

#Read the latest printer object name
if RegExists(HKLM,%CustomInstallKey%\%ModelCode%,LatestPrinterObject,cgfVar_PtrNameValue)
{
	FormatString(System\CurrentControlSet\Control\Print\Printers\printerName\PrinterDriverData,printerName,!cgfVar_PtrNameValue,cgfVar_OrigFNameKey);
}
#Read OFN Name for the latest printer object created.
RunSection(GetOFNName);

#Check if this installation is preload; i.e., PLC.INI exists in system directory.
RunSection(BEWPreLoadCheck);
RunSection(RunPrinterSharingOnly);

#Register CATS service prior to 398 call
RunProgram($DRIVER_MULTI_OS_DIR$\%ModelCode%serv.exe,NOWAIT,/register);

# Check the Internet Explorer version for web toolbar.
if RegExists(HKLM,%REG_IE%,Version,cgfVar_IEVersion)
{
	RunSection(CheckIEVersion);
}
if CheckVariable(App4R,eq,true)
{
	if CheckOS(9x)
	{
		SetVariable(Var_App4R,false);
	} else
	{
		if CheckVariable(App4RFlag,eq,NotInstalled)		
		{
			SetVariable(Var_App4R,false);
		} else
		{
			SetVariable(Var_App4R,true);
		}
	}
} else
{
	SetVariable(Var_App4R,false);
}

# Copy help file on temp directory, uncompressing it.
if CheckOS(9x)
{
        FormatString($CD_ROOT_DIR$\Drivers\HELPDIR\%LANG%\%MODELCODE%help.ch_,HELPDIR,Win_9X,HelpFileAndAddress);	
} else
{
        FormatString($CD_ROOT_DIR$\Drivers\HELPDIR\%LANG%\%MODELCODE%help.ch_,HELPDIR,Win_XP2K\common,HelpFileAndAddress);
}
RunInstallAction(cgfVar_CopyHelp,File,Copy,!HelpFileAndAddress,$TEMP_DIR$\%MODELCODE%\);

# Copy ThankYou Page on temp directory also.
FormatString($CD_ROOT_DIR$\Drivers\BMPFILE,BMPFILE,thankyoupage.bmp,ThankYouPageLocation);
RunInstallAction(cgfVar_CopyTYPage,File,Copy,!ThankYouPageLocation,$TEMP_DIR$\%MODELCODE%\);

#Sets registry Xfiles values
#FormatString(System\CurrentControlSet\Control\Print\Printers\%OEM% %ModelName%\PDData,PDData,PrinterDriverData,cgfVar_RegXFileName);
#RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegXFileName,JSWX PATH,STR, %MODELCODE%JSWX.EXE);
#RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegXFileName,JSWX TITLE,STR, %MODELCODE%JSWX - );
#RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegXFileName,PSWX PATH,STR, %MODELCODE%PSWX.EXE);
#RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegXFileName,PSWX TITLE,STR, %MODELCODE%PSWX - );

#Run program to silently define CATS settings.
FormatString(/T=398 /F=printerName,printerName,!cgfVar_PtrNameValue,cgfVar_pswx398Parms);
RunProgram($DRIVER_MULTI_OS_DIR$\%ModelCode%pswx.exe,WAIT,!cgfVar_pswx398Parms);

#Run program to Check Cartridge Information and Print Alignment Page with Topic ID 399
FormatString(/T=399 /F=printerName,printerName,!cgfVar_PtrNameValue,cgfVar_pswx399Parms);
RunProgram($DRIVER_MULTI_OS_DIR$\%ModelCode%pswx.exe,WAIT,!cgfVar_pswx399Parms);
RunSection(RunDeviceMon);

#Copy defs.xml to cats folder for CATS
FormatString($CD_ROOT_DIR$\PUBSDIR\%MODELCODE%defs.xml,PUBSDIR,pubs,DefsFileAndAddress);
RunInstallAction(cgfVar_CopyDefs,File,Copy,!DefsFileAndAddress,$PROGRAMFILES_DIR$\%OEM_CODE%_cats\);

#set variables once for all.
if CheckOS(x64)
{
	#FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%lpxName,lpxName,lpx.exe,cgfVar_lpxName);
	#FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%aioxName,aioxName,aiox.exe,cgfVar_aioxName);
	FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\4RName,4RName,app4r.exe,cgfVar_App4R);
	FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%CRPARM,CRPARM,amon.exe,cgfVar_CardMon);
	#FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\EZPrint,EZPrint,ezprint.exe,cgfVar_EzPrint);

} else
{
	#FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%lpxName,lpxName,lpx.exe,cgfVar_lpxName);
	#FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%aioxName,aioxName,aiox.exe,cgfVar_aioxName);
	FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\4RName,4RName,app4r.exe,cgfVar_App4R);
	FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%CRPARM,CRPARM,amon.exe,cgfVar_CardMon);
	#FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\EZPrint,EZPrint,ezprint.exe,cgfVar_EzPrint);
	
}

#
# if RunEzPrintLater = true, run ezprint.exe from bewtasks.cgf 
#

if CheckVariable(RunEzPrintLater,eq,true)
{
        if CheckOS(x64)
        {
		if CheckOS(VISTA)
		{
			#RunProgramAsUser($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\ezprint.exe,NOWAIT,100);
		} else
		{
			#RunProgram($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\ezprint.exe,NOWAIT,100);
		}
        } else
        {
		if CheckOS(VISTA)
		{
			#RunProgramAsUser($PROGRAMFILES_DIR$\%OEM% %ModelName%\ezprint.exe,NOWAIT,100);
		} else
		{
			#RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\ezprint.exe,NOWAIT,100);
		}
        }
}

if CheckVariable(VistaNoToolbarCDFEMenu,eq,false)
{
	ChangeWindow(SoftwareSetup,mainSplitter.top,capture);
} else
{
	if CheckVariable(InstallPath,eq,local)
	{
		ChangeWindow(PrinterSharing,mainSplitter.top,capture);
	} else
	{
		ChangeWindow(PrintOpportunity,mainSplitter.top,capture);
	}
}
ChangeWindow(Navigation,mainSplitter.bottom,capture);

######################
# Navigation Dialog
######################
[Navigation.Init]
ShowWindow(Back,false);
ShowWindow(Cancel,false);
ShowWindow(Install,false);
ShowWindow(Done,false);
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
ShowWindow(Exit,true);
ShowWindow(Continue,true);
ShowWindow(BigExit,false);
SetFocus(Continue);

[Navigation.Exit.ButtonClick]
if CheckVariable(cgfVar_InstallPathAuxiliar,eq,PreLoad)
{
	#PreLoad runs its own actions and exit.
	RunSection(FinalPreloadActions);
}

if IsWindowActive(Rewards,mainSplitter.top)
{
	if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,SerialNumber,cgfVar_SerialNumber)
	{
		FormatString(%Install_Reg%\Rewards\SerialNumber,SerialNumber,!cgfVar_SerialNumber,cgfVar_RewardsKey);
	}
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RewardsKey,ShowRegistrationReminder,NUM,1);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RewardsKey,InstallTime,STR,$CURRENT_DATE$);
}

if CheckVariable(cgfVar_InstallToolbar,eq,true)
{
	if CheckOS(VISTA)
	{
	} else
	{
		RunProgram($CD_ROOT_DIR$\%AppFolder%\Toolbar\setup.exe,WAIT,%LANG% "$PROGRAMFILES_DIR$\%OEM% Toolbar");
	}
}
if CheckVariable(cgfVar_SharePrinter,eq,true)
{
	#Get Shared name and update the current printer object to be shared.
	SharePrinter(!cgfVar_PtrNameValue,#ShareNameEdit);
	if CheckValue(FirewallChecked,eq,true)
	{
		if CheckOS(x64)
		{
			FormatString($CD_ROOT_DIR$\Install\x64\dllName,dllName,NetSupp.dll,cgf_NetSuppDll);
		} else
		{
			FormatString($CD_ROOT_DIR$\Install\x86\dllName,dllName,NetSupp.dll,cgf_NetSuppDll);
		}
		RunInstallAction(cgf_ReturnCode,RunLibFunction,!cgf_NetSuppDll,AddFirewallException,P2P);
	}
}
#CATS - Set Registry
if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,ShowCustomConnectReminder,cgfVar_SCCRValue)
{
	if CheckVariable(cgfVar_SCCRValue,eq,0)
	{
		#The CustomerConnectInstallTime key is removed from the registry.
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime);
	}
} else
{
	#The CustomerConnectInstallTime key is added to the registry.
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime,STR,$CURRENT_DATE$);
}
#CATS - Set data retriever participation level to FALSE
FormatString($PROGRAMFILES_DIR$\%OEM_CODE%_cats\%ModelCode%iniName,iniName,cats.ini,cgfVar_IniFileName);
RunInstallAction(cgfVar_IniActionReturn,IniFile,Update,!cgfVar_IniFileName,CATS Control,CATSParticipation,0);
#Registration - Set Registry
if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,ShowRegistrationReminder,cgfVar_SRRValue)
{
	if CheckVariable(cgfVar_SRRValue,eq,0)
	{
		#The InstallTime key is removed from the registry.
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,!cgfVar_IJPrtSettingsKey,InstallTime);
	}
} else
{
	#The InstallTime key is added to the registry.
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,InstallTime,STR,$CURRENT_DATE$);
}

#Create shortcut and run the LaunchPad App.

if CheckVariable(Var_App4R,ne,true)
{
	# RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_lpxName,%COMPONENTS.LaunchPad_ShortCut%);
} else
{
	RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_App4R,%COMPONENTS.App4r_ShortCut%);
}
#RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_EzPrint,%Components.EzPrint%,,-h204 /%OEM% %ModelName%);
HideMainFrame();
if CheckVariable(Var_App4R,eq,true)
{
	RunProgram(!cgfVar_CardMon,WAIT,-Register);
	RunProgram(!cgfVar_App4R,NoWAIT);
	
} else
{
	# RunProgram(!cgfVar_aioxName,WAIT,/m=3);
	# RunProgram(!cgfVar_lpxName,NoWAIT);
}
#Cleanup the help file from the temp directory.
if CheckVariable(cgfVar_CopyHelp,eq,true)
{
        RunSection(RemoveHelpFile);
}

#Set InstallRunning Key to 0.
if CheckOS(9x)
{
	FormatString(System\CurrentControlSet\Control\Print\Printers\OFN_PATH\GUI\LPA,OFN_PATH,!cgfVar_PtrNameValue,cgfVar_RegOFNGUI);
} else
{
	FormatString(OFN_PATH\GUI\LPA,OFN_PATH,!cgfVar_IJPrtSettingsKey,cgfVar_RegOFNGUI);
}
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegOFNGUI,Install Running,NUM,0);

ExitApp(NoPrompt);


[Navigation.Done.ButtonClick]
if CheckVariable(cgfVar_InstallPathAuxiliar,eq,PreLoad)
{
	#PreLoad runs its own actions and exit.
	RunSection(FinalPreloadActions);
	Break();
}

if CheckVariable(cgfVar_InstallToolbar,eq,true)
{
	if CheckOS(VISTA)
	{
	} else
	{
		RunProgram($CD_ROOT_DIR$\%AppFolder%\Toolbar\setup.exe,WAIT,%LANG% "$PROGRAMFILES_DIR$\%OEM% Toolbar");
	}
}
if CheckVariable(cgfVar_SharePrinter,eq,true)
{
	#Get Shared name and update the current printer object to be shared.
	SharePrinter(!cgfVar_PtrNameValue,#ShareNameEdit);
	if CheckValue(FirewallChecked,eq,true)
	{
		if CheckOS(x64)
		{
			FormatString($CD_ROOT_DIR$\Install\x64\dllName,dllName,NetSupp.dll,cgf_NetSuppDll);
		} else
		{
			FormatString($CD_ROOT_DIR$\Install\x86\dllName,dllName,NetSupp.dll,cgf_NetSuppDll);
		}
		RunInstallAction(cgf_ReturnCode,RunLibFunction,!cgf_NetSuppDll,AddFirewallException,P2P);
	}
}
#Create shortcut and run the LaunchPad App.
if CheckValue(CongratsShortcut,eq,true)
{
	if CheckVariable(Var_App4R,ne,true)
	{
		# RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_lpxName,%COMPONENTS.LaunchPad_ShortCut%);
	} else
	{
		RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_App4R,%COMPONENTS.App4r_ShortCut%);
	}
	#RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_EzPrint,%Components.EzPrint%,,-h204 /%OEM% %ModelName%);
}
if CheckValue(CongratsOpenLaunchPad,eq,true)
{

	HideMainFrame();
	#RunProgram(!cgfVar_aioxName,WAIT,/m=3);
	#RunProgram(!cgfVar_lpxName,NoWAIT);
}
if CheckValue(CongratsOpenLaunchPad4R,eq,true)
{
	HideMainFrame();
	RunProgram(!cgfVar_CardMon,WAIT,-register);
	RunProgram(!cgfVar_App4R,NoWAIT);
}



#Cleanup the help file from the temp directory.
if CheckVariable(cgfVar_CopyHelp,eq,true)
{
        RunSection(RemoveHelpFile);
}

#Set InstallRunning Key to 0.
if CheckOS(9x)
{
	FormatString(System\CurrentControlSet\Control\Print\Printers\OFN_PATH\GUI\LPA,OFN_PATH,!cgfVar_PtrNameValue,cgfVar_RegOFNGUI);
} else
{
	FormatString(OFN_PATH\GUI\LPA,OFN_PATH,!cgfVar_IJPrtSettingsKey,cgfVar_RegOFNGUI);
}
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegOFNGUI,Install Running,NUM,0);

ExitApp(NoPrompt);


[Navigation.Continue.ButtonClick]
if IsWindowActive(SoftwareSetup,mainSplitter.top)
{
	if CheckValue(SoftwareSetupFax,eq,true)
	{
		HideMainFrame();
		if CheckOS(x64)
		{
			RunProgram($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%fax.exe,WAIT,InvokeFSU);
		} else
		{
			RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%fax.exe,WAIT,InvokeFSU);
		}
		ShowMainFrame();
	}
	if CheckVariable(InstallPath,eq,local)
	{
		ChangeWindow(PrinterSharing,mainSplitter.top,capture);
	} else
	{
		ChangeWindow(PrintOpportunity,mainSplitter.top,capture);
	}
} else if IsWindowActive(PrinterSharing,mainSplitter.top) 
{
	if CheckValue(PrinterShared,eq,true)
	{
		ChangeWindow(PrinterSharingSetup,mainSplitter.top,capture);
	} else if CheckVariable(cgfVar_PreLoadType,eq,PtrSharingOnly)
	{
		RunSection(FinalPreloadActions);
	} else
	{
		ChangeWindow(PrintOpportunity,mainSplitter.top,capture);
	}
} else if IsWindowActive(PrinterSharingSetup,mainSplitter.top)
{
	if CheckValue(ShareNameEdit,eq,empty)
	{
		ShowMessage(%PrinterSharingSetup.InvalidShareNameMsg%,%PrinterSharingSetup.Error_Title%,error);
	} else
	{
		#Check if it is a valid name.
		if IsSharedNameValid(#ShareNameEdit)
		{
			SetVariable(cgfVar_SharePrinter,true);

			# Check if File/Print sharing is enabled. Call interface from LCS.
			#RunSection(P2PPromptDialog);

			if CheckVariable(cgfVar_PreLoadType,eq,PtrSharingOnly)
			{
				RunSection(FinalPreloadActions);
			} else
			{
				ChangeWindow(PrintOpportunity,mainSplitter.top,capture);
			}
		} else
		{
			ShowMessage(%PrinterSharingSetup.InvalidShareNameMsg%,%PrinterSharingSetup.Error_Title%,error);
		}
	}
} else if IsWindowActive(PrintOpportunity,mainSplitter.top)
{
	RunSection(CheckRewardsSupport);

} else if IsWindowActive(Rewards,mainSplitter.top)
{
	if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,SerialNumber,cgfVar_SerialNumber)
	{
		FormatString(%Install_Reg%\Rewards\SerialNumber,SerialNumber,!cgfVar_SerialNumber,cgfVar_RewardsKey);
	}
	#SetVariable(cgfVar_RewardsKey,%Install_Reg%\Rewards\%ModelCode%);
        if CheckValue(RewardsOption,eq,true)
	{
		if IniSectionKeyExists(!cgfVar_RewardsINI,Options,RegistrationURL,cgfVar_RewardsRegistrationURL)
		{
			RunSection(CheckRewardsURL);
		} else
		{
			RunSection(RewardsURLWithPSID);
		}
                RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RewardsKey,ShowRegistrationReminder,NUM,1);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RewardsKey,InstallTime,STR,$CURRENT_DATE$);

		# CCB 992: Set the expected parameters for CATS.
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowCustomConnectReminder,NUM,1);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime,STR,$CURRENT_DATE$);
		FormatString($PROGRAMFILES_DIR$\%OEM_CODE%_cats\%ModelCode%iniName,iniName,cats.ini,cgfVar_IniFileName);
		RunInstallAction(cgfVar_IniActionReturn,IniFile,Update,!cgfVar_IniFileName,CATS Control,CATSParticipation,0);

                ChangeWindow(Congratulations,mainSplitter.top,capture);
	} else
	{
                RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RewardsKey,ShowRegistrationReminder,NUM,1);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RewardsKey,InstallTime,STR,$CURRENT_DATE$);
		ChangeWindow(Registration,mainSplitter.top,capture);
	}
} else if IsWindowActive(Registration,mainSplitter.top)
{
	if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,SerialNumber,cgfVar_SerialNumber)
	{
	}
	if CheckValue(OpenWebBrowser,eq,true)
	{
		RunSection(RegistrationURLWithPSID);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowRegistrationReminder,NUM,0);
	}
	if CheckValue(ConnectProgram,eq,true)
	{
		#Set data retriever participation level to TRUE
		FormatString($PROGRAMFILES_DIR$\%OEM_CODE%_cats\%ModelCode%iniName,iniName,cats.ini,cgfVar_IniFileName);
		RunInstallAction(cgfVar_IniActionReturn,IniFile,Update,!cgfVar_IniFileName,CATS Control,CATSParticipation,1);
		#The CustomerConnectInstallTime key is removed from the registry.
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime);
	} else
	{
		#Set data retriever participation level to FALSE
		FormatString($PROGRAMFILES_DIR$\%OEM_CODE%_cats\%ModelCode%iniName,iniName,cats.ini,cgfVar_IniFileName);
		RunInstallAction(cgfVar_IniActionReturn,IniFile,Update,!cgfVar_IniFileName,CATS Control,CATSParticipation,0);
		if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,ShowCustomConnectReminder,cgfVar_SCCRValue)
		{
			if CheckVariable(cgfVar_SCCRValue,eq,0)
			{
				#The CustomerConnectInstallTime key is removed from the registry.
				RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime);
			} else if CheckVariable(cgfVar_SCCRValue,eq,1)
			{
				#The CustomerConnectInstallTime key is added to the registry.
				RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime,STR,$CURRENT_DATE$);
			}
		}		
	}
	ChangeWindow(Congratulations,mainSplitter.top,capture);
}

[Navigation.Back.ButtonClick]
if IsWindowActive(PrintOpportunity,mainSplitter.top)
{
	if CheckVariable(InstallPath,ne,local)
	{
		ShowWindow(Back,false);
	}
} else if IsWindowActive(PrinterSharing,mainSplitter.top)
{
	ShowWindow(Back,false);
}
GoBack();

#############################
#SoftwareSetup Dialog
#############################
[SoftwareSetup.Init]
ShowWindow(Back,false);
ShowWindow(Done,false);
ShowWindow(Exit,true);
ShowWindow(Continue,true);
SetFocus(Continue);
SetValue(SoftwareSetupToolbar,true);
SetValue(SoftwareSetupFax,true);
SetVariable(cgfVar_InstallToolbar,true);

[SoftwareSetup.EnableControls]
ShowWindow(Exit,true);
ShowWindow(Back,false);
ShowWindow(Done,false);
ShowWindow(Continue,true);
if CheckVariable(cgfVar_WebToolBar,ne,true)
{
	SetVariable(cgfVar_InstallToolbar,false);
	SetValue(SoftwareSetupToolbar,false);
	EnableWindow(SoftwareSetupToolbar,false);
}
if CheckVariable(RunFaxSetupUtility,eq,true)
{
	ShowWindow(SoftwareSetupFax,true);
	ShowWindow(SoftwareSetupFaxInfo,true);
} else
{
	ShowWindow(SoftwareSetupFax,false);
	ShowWindow(SoftwareSetupFaxInfo,false);
	SetValue(SoftwareSetupFax,false);
}

[SoftwareSetup.SoftwareSetupToolbar.CheckBoxCheck]
if CheckValue(SoftwareSetupToolbar,eq,true)
{
	SetVariable(cgfVar_InstallToolbar,true);
} else
{
	SetVariable(cgfVar_InstallToolbar,false);
}

[SoftwareSetup.TBLearnMore.ButtonClick]
#not sure what ID should be used on this case
#OpenHelpFile($TEMP_DIR$\%MODELCODE%\%MODELCODE%help.hlp,1,701);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 532 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

############################
#PrinterSharing Dialog
############################
[PrinterSharing.Init]
SetValue(PrinterNotShared,true);
SetFocus(PrinterNotShared);

[PrinterSharing.EnableControls]
ShowWindow(Back,false);

############################
#PrinterSharingSetup Dialog
############################
[PrinterSharingSetup.Init]
if CheckOS(XP)
{
	SetValue(FirewallChecked,true);
	ShowWindow(FirewallChecked,false);
	ShowWindow(AllowShare,false);
} else if CheckOS(x64)
{
	SetValue(FirewallChecked,true);
	ShowWindow(FirewallChecked,false);
	ShowWindow(AllowShare,false);
} else if CheckOS(VISTA)
{
	SetValue(FirewallChecked,true);
	ShowWindow(FirewallChecked,false);
	ShowWindow(AllowShare,false);
} else
{
	SetValue(FirewallChecked,false);
	ShowWindow(FirewallChecked,false);
	ShowWindow(FirewallNotice,false);
	ShowWindow(AllowShare,false);
}
MakeShareName(!cgfVar_PtrNameValue,cgfVar_PtrShareName,useInstalled);
SetValue(ShareNameEdit,!cgfVar_PtrShareName);
SetFocus(ShareNameEdit);

[PrinterSharingSetup.EnableControls]
ShowWindow(Back,true);

############################
Rewards Dialog
############################
[Rewards.Init]
SetFocus(RewardsOption);
SetValue(RewardsOption,true);
RunSection(GetPercentOff);

#############################
#PrintOpportunity Dialog
#############################
[PrintOpportunity.Init]
ShowWindow(Back,false);
ShowWindow(PrintOpportunityButtonOffers,false);
ShowWindow(PrintOpportunityButtonOffersInfo1,false);
ShowWindow(PrintOpportunityButtonOffersInfo2,false);
SetVariable(cgfVar_ISOLanguage,$OS_ISOLANG$);
RunSection(CHECK_ISOLANG);

[PrintOpportunity.PrintOpportunityButtonTestPage.ButtonClick]
if CheckVariable(cgfVar_CopyTYPage,eq,true)
{
	PrintTestPage(!cgfVar_PtrNameValue,$TEMP_DIR$\%MODELCODE%\thankyoupage.bmp);
}

[PrintOpportunity.PrintOpportunityButtonOffers.ButtonClick]
RunShell(!WebOffer);

[CHECK_ISOLANG]
if CheckVariable(CurrentLanguage,eq,en)
{
	if CheckVariable(cgfVar_ISOLanguage,eq,en_US)
	{
		ShowWindow(PrintOpportunityButtonOffers,true);
		ShowWindow(PrintOpportunityButtonOffersInfo1,true);
		ShowWindow(PrintOpportunityButtonOffersInfo2,true);

	} 
} 

#############################
#Registration Dialog
#############################
[Registration.Init]
SetValue(OpenWebBrowser,true);
SetValue(ConnectProgram,true);


[Registration.OpenWebBrowser.CheckBoxCheck]
if CheckValue(OpenWebBrowser,eq,false)
{
	PopupWindow(RegisterLater);
}

[Registration.ConnectProgram.CheckBoxCheck]
if CheckValue(ConnectProgram,eq,false)
{
	PopupWindow(CustomerConnect);
}

[Registration.LearnMore.ButtonClick]
#OpenHelpFile($TEMP_DIR$\%MODELCODE%\%MODELCODE%help.hlp,1,701);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 701 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);


#############################
#Congratulations Dialog
#############################
[Congratulations.Init]
ShowWindow(Back,false);
ShowWindow(Continue,false);
ShowWindow(Done,true);
ShowWindow(Exit,false);
EnableWindow(Done,true);
if CheckVariable(Var_App4R,eq,true)
{
	SetValue(CongratsOpenLaunchPad,false);
	ShowWindow(CongratsOpenLaunchPad,false);
	EnableWindow(CongratsOpenLaunchPad,false);
	ShowWindow(CongratsText,false);
	ShowWindow(CongratsImage,false);
	ShowWindow(CongratsImageText,false);

	ShowWindow(CongratsOpenLaunchPad4R,true);
	EnableWindow(CongratsOpenLaunchPad4R,true);
	ShowWindow(CongratsText4R,true);
	ShowWindow(CongratsImage4R,true);
	ShowWindow(CongratsImageText4R,true);

	if CheckVariable(cgfVar_InstallPathAuxiliar,eq,PreLoad)
	{
		if CheckVariable(cgfVar_DesktopIconLP,eq,1)
		{
			SetValue(CongratsShortcut,true);
		} else
		{
			SetValue(CongratsShortcut,false);
		}
		if CheckVariable(cgfVar_LaunchLaunchPad,eq,1)
		{
			SetValue(CongratsOpenLaunchPad4R,true);
		} else
		{
			SetValue(CongratsOpenLaunchPad4R,false);
		}
	} else
	{
		SetValue(CongratsShortcut,true);
		SetValue(CongratsOpenLaunchPad4R,true);
	}
} else
{
	SetValue(CongratsOpenLaunchPad4R,false);
	ShowWindow(CongratsOpenLaunchPad4R,false);
	EnableWindow(CongratsOpenLaunchPad4R,false);
	ShowWindow(CongratsText4R,false);
	ShowWindow(CongratsImage4R,false);
	ShowWindow(CongratsImageText4R,false);

	EnableWindow(CongratsShortcut,false);
	ShowWindow(CongratsOpenLaunchPad,true);
	EnableWindow(CongratsOpenLaunchPad,false);
	ShowWindow(CongratsText,true);
	ShowWindow(CongratsImage,true);
	ShowWindow(CongratsImageText,true);

	if CheckVariable(cgfVar_InstallPathAuxiliar,eq,PreLoad)
	{
		if CheckVariable(cgfVar_DesktopIconLP,eq,1)
		{
			SetValue(CongratsShortcut,true);
		} else
		{
			SetValue(CongratsShortcut,false);
		}
		if CheckVariable(cgfVar_LaunchLaunchPad,eq,1)
		{
			SetValue(CongratsOpenLaunchPad,true);
		} else
		{
			SetValue(CongratsOpenLaunchPad,false);
		}
	} else
	{
		SetValue(CongratsShortcut,false);
		SetValue(CongratsOpenLaunchPad,false);
	}
}

[Congratulations.CongratsShortcut.CheckBoxCheck]
if CheckValue(CongratsShortcut,eq,true)
{
	if CheckVariable(Var_App4R,eq,true)
	{
		SetValue(CongratsImage4R,%CongratsImage_4R%);
		SetValue(CongratsImageText4R,%Congratulations.CongratsImageText_4R%);		
	} else
	{
		SetValue(CongratsImage,%CongratsImageOn%);
		SetValue(CongratsImageText,%Congratulations.CongratsImageText%);
	}
} else
{
	SetValue(CongratsImage,%CongratsImageOff%);
	SetValue(CongratsImage4R,%CongratsImageOff%);
	SetValue(CongratsImageText,<body bgcolor=#2D85AF></body>);
	SetValue(CongratsImageText4R,<body bgcolor=#2D85AF></body>);
}


#############################
#RegisterLater PopupDialog
#############################
[RegisterLater.Init]
SetValue(RemindMeAgain,true);


[RegisterLater.RegisterClose.ButtonClick]
if CheckValue(RemindMeAgain,eq,true)
{
	#Set flag and date for Registration reminder under %Install_Reg%\IJPrtSettings\OFNValue
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowRegistrationReminder,NUM,1);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,InstallTime,STR,$CURRENT_DATE$);
} else
{
	#Set flag for Registration reminder under %Install_Reg%\IJPrtSettings\OFNValue
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowRegistrationReminder,NUM,0);	
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,!cgfVar_IJPrtSettingsKey,InstallTime);
}
ShowWindow(RegisterLaterPopup,false);

[RegisterLater.LearnLexmarkConnect.ButtonClick]
#OpenHelpFile($TEMP_DIR$\%MODELCODE%\%MODELCODE%help.hlp,1,701);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 701 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

#############################
#CustomerConnect Dialog
#############################
[CustomerConnect.Init]
SetValue(AskMeAgain,true);
SetFocus(AskMeAgain);

[CustomerConnect.Close.ButtonClick]
if CheckValue(AskMeAgain,eq,true)
{
	#Set flag and date for Customer Connect reminder under %Install_Reg%\IJPrtSettings\OFNValue
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowCustomConnectReminder,NUM,1);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime,STR,$CURRENT_DATE$);
} else
{
	#Set flag for Customer Connect reminder under %Install_Reg%\IJPrtSettings\OFNValue
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowCustomConnectReminder,NUM,0);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,!cgfVar_IJPrtSettingsKey,CustomerConnectInstallTime);
}
ShowWindow(CustomerConnectPopup,false);

[CustomerConnect.LearnLexmarkConnect.ButtonClick]
#OpenHelpFile($TEMP_DIR$\%MODELCODE%\%MODELCODE%help.hlp,1,701);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 701 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

#############################
# P2PPrompt PopupDialog
#############################
[P2PPrompt.Init]
if CheckOS(2K_XP)
{
	SetValue(PONoSharedText,%P2PPrompt.PONoSharedText_2KXP%);
	SetValue(PONoSharedAsk,%P2PPrompt.PONoSharedAsk_2KXP%);

} else
{
	SetValue(PONoSharedText,%P2PPrompt.PONoSharedText_Vista%);
	SetValue(PONoSharedAsk,%P2PPrompt.PONoSharedAsk_Vista%);
}
SetFocus(P2PPromptYes);

[P2PPrompt.P2PPromptHelp.ButtonClick]
# Placeholder help. Topic ID to be inserted later.
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 701 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

[P2PPrompt.P2PPromptYes.ButtonClick]
ShowWindow(P2PPromptPopup,false);
RunProgram($SYSTEM_DIR$\rundll32.exe,WAIT,%NetworkSetupWizardParms%);
ShowMainFrame();

[P2PPrompt.P2PPromptNo.ButtonClick]
ShowWindow(P2PPromptPopup,false);
SetVariable(cgfVar_SharePrinter,false);
ShowMainFrame();

######################
# GOTO Section
######################
[RemoveHelpFile]
#At the end of install, we need to remove the decompressed help.hlp file which we located for temporary use for installer.
RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);
RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\thankyoupage.bmp);
RunInstallAction(cgfVar_RemoveFile,File,DeleteDir,$TEMP_DIR$\%MODELCODE%\);

[RunDeviceMon]
if CheckOS(x64)
{	
	# RunProgram($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%mon.exe,WAIT,-u);
	# RunProgram($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%mon.exe,NOWAIT);

	# RunProgram($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%amon.exe,WAIT,-unregister);
	# RunProgram($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%amon.exe,NOWAIT);
} else
{	
	# RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%mon.exe,WAIT,-u);
	# RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%mon.exe,NOWAIT);

	# RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%amon.exe,-unregister);
	# RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%amon.exe,NOWAIT);

}

[GetOFNName]
#Find registry for the current PrinterObject to get OFN value - This value will be used throughout the BEW tasks.
if RegExists(HKLM,!cgfVar_OrigFNameKey,OriginalFriendlyName,cgfVar_OFNValue)
{
	FormatString(%Install_Reg%\IJPrtSettings\OFNValue,OFNValue,!cgfVar_OFNValue,cgfVar_IJPrtSettingsKey);
}

[CheckIEVersion]
if CheckVariable(cgfVar_IEVersion,gt,5.5)
{
	SetVariable(cgfVar_WebToolBar,true); 
} else
{
	SetVariable(cgfVar_WebToolBar,false);
}
if CheckOS(VISTA)
{
	SetVariable(cgfVar_WebToolBar,false);
}

[BEWPreLoadCheck]
#Check for PreLoad path.
if DoesFileExists($SYSTEM_DIR$\%MODELCODE%PLC.ini)
{
	SetVariable(cgfVar_InstallPathAuxiliar,PreLoad);
	#BEWTasks is running for a PreLoad path: (1) no dialog, but SharePrinter or (2) display all dialogs, but sharing printer.
	#Read a few keys from this file...
	#(1) - DesktopIconAIOC
	if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,DesktopIconAIOC,cgfVar_DesktopIconAIOC)
	{
	}
	#(2) - DesktopIconLP
	if CheckVariable(NewPreloadSpec,eq,true)
	{
		if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,DesktopIconIS,cgfVar_DesktopIconLP)
		{
		} else
		{
			SetVariable(cgfVar_DesktopIconLP,1);
		}
	} else
	{
		if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,DesktopIconLP,cgfVar_DesktopIconLP)
		{
		} else
		{
			SetVariable(cgfVar_DesktopIconLP,1);
		}
	}
	#(3) - DesktopIconFastPics
	if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,DesktopIconFastPics,cgfVar_DesktopIconFastPics)
	{
	}
	#(4) - LaunchAIOCenter
	if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,LaunchAIOCenter,cgfVar_LaunchAIOCenter)
	{
	}
	#(5) - LaunchLaunchPad
	if CheckVariable(NewPreloadSpec,eq,true)
	{
		if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,LaunchImagingStudio,cgfVar_LaunchLaunchPad)
		{
		}
	} else
	{
		if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,LaunchLaunchPad,cgfVar_LaunchLaunchPad)
		{
		}
	}
	#(6) - MinimizeStatusInfo
	if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,MinimizeStatusInfo,cgfVar_MinimizeStatusInfo)
	{
	}
	#(7) - SetVoiceNotification
	if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,SetVoiceNotification,cgfVar_SetVoiceNotification)
	{
	} else if CheckVariable(IsSMB,ne,true)
	{
		FormatString(%Install_Reg%\IJPrtSettings\OFNValue\GUI\LPA,OFNValue,!cgfVar_OFNValue,cgfVar_IJPrtSettingsLPAKey);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsLPAKey,Sound,NUM,1);
	}
	#(8) - ShowOneWeekRegistrationReminder
	if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OPTIONS,ShowOneWeekRegistrationReminder,cgfVar_RegReminderValue)
	{
	} else
	{
		SetVariable(cgfVar_RegReminderValue,1);
	}
	#... and decide what to do.
	
	if CheckVariable(InstallPath,eq,PreLoadAllDlg)
	{
		#It will have all the dialogs, so make it run as Local
		SetVariable(InstallPath,Local);
	} else if CheckVariable(InstallPath,eq,PreLoadShareOnly)
	{
		SetVariable(cgfVar_PreLoadType,PtrSharingOnly);		
	}

	RunSection(FixDefaultPreloadParameters);
}

[FixDefaultPreloadParameters]
if CheckVariable(cgfVar_DesktopIconLP,eq,empty)
{
	SetVariable(cgfVar_DesktopIconLP,1);
}
if CheckVariable(cgfVar_MinimizeStatusInfo,eq,1)
{
	FormatString(%Install_Reg%\IJPrtSettings\OFNValue\GUI\JSW,OFNValue,!cgfVar_OFNValue,cgfVar_IJPrtSettingsJSWKey);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsJSWKey,Job Progress Minimized,NUM,1);
}
if CheckVariable(cgfVar_SetVoiceNotification,eq,empty)
{
	if CheckVariable(IsSMB,ne,true)
	{
		FormatString(%Install_Reg%\IJPrtSettings\OFNValue\GUI\LPA,OFNValue,!cgfVar_OFNValue,cgfVar_IJPrtSettingsLPAKey);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsLPAKey,Sound,NUM,1);
	}
} else if CheckVariable(cgfVar_SetVoiceNotification,eq,1)
{
	FormatString(%Install_Reg%\IJPrtSettings\OFNValue\GUI\LPA,OFNValue,!cgfVar_OFNValue,cgfVar_IJPrtSettingsLPAKey);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsLPAKey,Sound,NUM,1);
}
if CheckVariable(cgfVar_RegReminderValue,eq,empty)
{
	SetVariable(cgfVar_RegReminderValue,1);
}

[FinalPreloadActions]
if CheckVariable(cgfVar_SharePrinter,eq,true)
{
	#Get Shared name and update the current printer object to be shared.
	SharePrinter(!cgfVar_PtrNameValue,#ShareNameEdit);
	if CheckValue(FirewallChecked,eq,true)
	{
		if CheckOS(x64)
		{
			FormatString($CD_ROOT_DIR$\Install\x64\dllName,dllName,NetSupp.dll,cgf_NetSuppDll);
		} else
		{
			FormatString($CD_ROOT_DIR$\Install\x86\dllName,dllName,NetSupp.dll,cgf_NetSuppDll);
		}
		RunInstallAction(cgf_ReturnCode,RunLibFunction,!cgf_NetSuppDll,AddFirewallException,P2P);
	}
}

#Create shortcut and run the LaunchPad App.
if CheckOS(x64)
{
	FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\4RName,4RName,app4r.exe,cgfVar_lpxName);
	FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%CRPARM,CRPARM,amon.exe,cgfVar_CardMon);
	#FormatString($PROGRAMFILES_DIR$ (x86)\%OEM% %ModelName%\%ModelCode%aioxName,aioxName,aiox.exe,cgfVar_aioxName);
} else
{
	FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\4RName,4RName,app4r.exe,cgfVar_lpxName);
	FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%CRPARM,CRPARM,amon.exe,cgfVar_CardMon);
	#FormatString($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%aioxName,aioxName,aiox.exe,cgfVar_aioxName);
}

#Cleanup the help file from the temp directory.
if CheckVariable(cgfVar_CopyHelp,eq,true)
{
       	RunSection(RemoveHelpFile);
}

if CheckVariable(cgfVar_PreLoadType,ne,PtrSharingOnly)
{
	if CheckVariable(cgfVar_InstallToolbar,eq,true)
	{
		if CheckOS(VISTA)
		{
		} else
		{
			RunProgram($CD_ROOT_DIR$\%AppFolder%\Toolbar\setup.exe,WAIT,%LANG% "$PROGRAMFILES_DIR$\%OEM% Toolbar");
		}
	}
	if CheckValue(CongratsShortcut,eq,true)
	{
		RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_lpxName,%COMPONENTS.App4r_ShortCut%);
	}
	if CheckValue(CongratsOpenLaunchPad,eq,true)
	{
		HideMainFrame();
		#RunProgram(!cgfVar_aioxName,WAIT,/m=3);
		#RunProgram(!cgfVar_lpxName,NoWait);
	}
	if CheckValue(CongratsOpenLaunchPad4R,eq,true)
	{
		HideMainFrame();
		RunProgram(!cgfVar_CardMon,WAIT,-register);
		RunProgram(!cgfVar_lpxName,NoWAIT);
	}
} else
{
	HideMainFrame();
	if CheckVariable(cgfVar_DesktopIconLP,eq,1)
	{
		RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_lpxName,%COMPONENTS.App4r_ShortCut%);
	}
	if CheckVariable(cgfVar_DesktopIconAIOC,eq,1)
	{
		# RunInstallAction(cgfVar_ShortcutActionReturn,Shortcut,Add,Desktop,AllUsers,!cgfVar_aioxName,%COMPONENTS.AIO_CENTER%);
	}
	if CheckVariable(cgfVar_LaunchAIOCenter,eq,1)
	{
		# RunProgram(!cgfVar_aioxName,NOWAIT);
	}
	if CheckVariable(cgfVar_LaunchLaunchPad,eq,1)
	{
		RunProgram(!cgfVar_CardMon,WAIT,-register);
		RunProgram(!cgfVar_lpxName,NoWAIT);	
	}
	if checkVariable(cgfVar_RegReminderValue,eq,1)
	{
		#Set flag and date for Registration reminder under %Install_Reg%\IJPrtSettings\OFNValue
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,ShowRegistrationReminder,NUM,1);
		RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_IJPrtSettingsKey,InstallTime,STR,$CURRENT_DATE$);
	}
}

#Set InstallRunning Key to 0.
FormatString(OFN_PATH\GUI\LPA,OFN_PATH,!cgfVar_IJPrtSettingsKey,cgfVar_RegOFNGUI);
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,!cgfVar_RegOFNGUI,Install Running,NUM,0);

#Read [OtherInstalls] Section to see if there is any additional app installer to run.
#We are assuming no parameters exist for those programs. If parameter necessary, ProgramParms1 key should be added
#to the ini file. We should read it and pass it as a 3rd parameter to RunProgram call.
if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OtherInstalls,Program1,cgfVar_Program1)
{
	RunProgram(!cgfVar_Program1,NOWAIT);
}
if IniSectionKeyExists($SYSTEM_DIR$\%MODELCODE%PLC.ini,OtherInstalls,Program2,cgfVar_Program2)
{
	RunProgram(!cgfVar_Program2,NOWAIT);
}

ExitApp(NoPrompt);

[P2PPromptDialog]
# Do the LCS call here.
# if Error Code = ERROR_NETWORK_ACCESS_DENIED...
HideMainFrame();
PopupWindow(P2PPrompt);

[CheckRewardsSupport]
if CheckVariable(CurrentLanguage,eq,en)
{
	if CheckVariable(cgfVar_ISOLanguage,eq,en_US)
	{
		if DoesFileExists(!cgfVar_RewardsDLL)
		{
			RunInstallAction(cgfVar_RewardsDLLValue,RunLibFunction,!cgfVar_RewardsDLL,GetSupport,%MODELCODE%);
			RunSection(CheckRewardsDLLValue);
		} 
	} 
} 
ChangeWindow(Registration,mainSplitter.top,capture);

[CheckRewardsDLLValue]
if CheckVariable(cgfVar_RewardsDLLValue,eq,true)
{
	if DoesFileExists(!cgfVar_RewardsINI)
	{	
		if IniSectionKeyExists(!cgfVar_RewardsINI,Options,RewardsSupported,cgfVar_RewardsINIValue)
		{
			RunSection(CheckRewardsINIValue);
		} 
	} 
}
ChangeWindow(Registration,mainSplitter.top,capture);

[CheckRewardsINIValue]
if CheckVariable(cgfVar_RewardsINIValue,eq,1)
{
	if RegExists(HKLM,!cgfVar_IJPrtSettingsKey,SerialNumber,USBSerialID)
	{
	} else
	{
		# Default value is printer Device ID, just in case.
		SetVariable(USBSerialID,%PtrDeviceID%);
	}
	# check if already registered
	SetVariable(cgfvar_showRewardsDlg,true);
	RunSection(CheckRewardsRegistration);
	RunSection(ShowRewardsDlg);
} else
{
	ChangeWindow(Registration,mainSplitter.top,capture);
}

[CheckRewardsRegistration]
SetVariable(cgfvar_RwdCliDll,$DRIVER_MULTI_OS_DIR$\LxRwdCli.dll);
if DoesFileExists($DRIVER_MULTI_OS_DIR$\LxRwdCli.dll)
{
	# check if printer is already registered for Rewards
	RunInstallAction(cgfVar_isReg,RunLibFunction,!cgfvar_RwdCliDll,IsDeviceInRewards,!USBSerialID);
	RunSection(CheckRewardsRegValue);
}

[CheckRewardsRegValue]
if CheckVariable(cgfVar_isReg,eq,true)
{
	SetVariable(cgfvar_showRewardsDlg,false);
}

[ShowRewardsDlg]
if CheckVariable(cgfvar_showRewardsDlg,eq,true)
{
	ChangeWindow(Rewards,mainSplitter.top,capture);
	Break();
} else
{
	ChangeWindow(Congratulations,mainSplitter.top,capture);
	Break();
}


[CheckRewardsURL]
if CheckVariable(cgfVar_RewardsRegistrationURL,ne,empty)
{
	RunShell(!cgfVar_RewardsRegistrationURL);
} else
{
	RunSection(RewardsURLWithPSID);
}

[RegistrationURLWithPSID]
SetVariable(cgfVar_RegistrationURL,!WebRegistration); 

if CheckVariable(OEM,eq,Lexmark)
{
	if CheckVariable(cgfVar_SerialNumber,ne,empty)
	{
		FormatStringEx(%s&psi=%s,!cgfVar_RegistrationURL,!cgfVar_SerialNumber,cgfVar_RegistrationURL);
	}
	# CCB 1091: Add lcopt in WWW link.
	if CheckValue(ConnectProgram,eq,true)
	{
		FormatStringEx(%s&lcopt=1,!cgfVar_RegistrationURL,cgfVar_RegistrationURL);
	} else
	{
		FormatStringEx(%s&lcopt=0,!cgfVar_RegistrationURL,cgfVar_RegistrationURL);
	}
}
RunShell(!cgfVar_RegistrationURL);

[RewardsURLWithPSID]
SetVariable(cgfVar_RewardsURL,!WebRewards); 

if CheckVariable(cgfVar_SerialNumber,ne,empty)
{
	FormatStringEx(%s&psi=%s,!cgfVar_RewardsURL,!cgfVar_SerialNumber,cgfVar_RewardsURL);
}
# CCB 1091: Add lcopt in WWW link.
FormatStringEx(%s&lcopt=0,!cgfVar_RewardsURL,cgfVar_RewardsURL);
RunShell(!cgfVar_RewardsURL);

[GetPercentOff]
if DoesFileExists(!cgfVar_RewardsINI)
{
	if IniSectionKeyExists(!cgfVar_RewardsINI,Options,PercentOff,cgfVar_RewardsPctOffValue)
	{			
		FormatString(%Rewards.RewardsPctOff%,PercentValue,!cgfVar_RewardsPctOffValue,cgfVar_PercentOffStr);				
	} 
	if CheckVariable(cgfVar_RewardsPctOffValue,ne,empty)
	{
		SetValue(RewardsAd1,!cgfVar_PercentOffStr);			
	}

}

[GetOSCode]
if CheckOS(VISTA)
{
	if CheckOS(x64)
	{
		#Vista 64 bit
		SetVariable(cgfVar_OS,11);
	} else
	{
		#Vista 32 bit
		SetVariable(cgfVar_OS,10);
	}
} else if CheckOS(XP)
{
	if CheckOS(X64)
	{
		#XP 64 bit
		SetVariable(cgfVar_OS,9);
	} else
	{
		#XP 32 bit
		SetVariable(cgfVar_OS,5);
	}
} else if CheckOS(2K)
{
	if CheckOS(X64)
	{
		#XP 64 bit has 5.0 as Major and Minor versions.
		SetVariable(cgfVar_OS,9);
	} else
	{
		#Win2k 32bit
		SetVariable(cgfVar_OS,3);
	}
} else if CheckOS(NT)
{
	SetVariable(cgfVar_OS,2);
} else
{
	#Win9X
	SetVariable(cgfVar_OS,1);
}

[GetCountryCode]
if RegExists(HKCU,Control Panel\International,Locale,cgfVar_RegistryLocale)
{
} else
{
	SetVariable(cgfVar_RegistryLocale,%COUNTRY_CODE%);
}
RunSection(VerifyCountryCode);

[VerifyCountryCode]
if IsLangSupported($OS_LANG$)
{
	SetVariable(cgfVar_LanguageCode,%LANGUAGE_CODE%);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000436)
{
	SetVariable(cgfVar_LanguageCode,44);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000041C)
{
	SetVariable(cgfVar_LanguageCode,43);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000042D)
{
	SetVariable(cgfVar_LanguageCode,42);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000423)
{
	SetVariable(cgfVar_LanguageCode,41);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000041A)
{
	SetVariable(cgfVar_LanguageCode,38);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000425)
{
	SetVariable(cgfVar_LanguageCode,37);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000438)
{
	SetVariable(cgfVar_LanguageCode,36);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000040F)
{
	SetVariable(cgfVar_LanguageCode,18);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000426)
{
	SetVariable(cgfVar_LanguageCode,34);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000427)
{
	SetVariable(cgfVar_LanguageCode,33);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000C1A)
{
	SetVariable(cgfVar_LanguageCode,31);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000081A)
{
	SetVariable(cgfVar_LanguageCode,30);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000041B)
{
	SetVariable(cgfVar_LanguageCode,23);

} else if CheckVariable(cgfVar_RegistryLocale,eq,00000422)
{
	SetVariable(cgfVar_LanguageCode,26);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000042A)
{
	SetVariable(cgfVar_LanguageCode,25);

} else if CheckVariable(cgfVar_RegistryLocale,eq,042F)
{
	SetVariable(cgfVar_LanguageCode,48);

} else if CheckVariable(cgfVar_RegistryLocale,eq,0000042F)
{
	SetVariable(cgfVar_LanguageCode,48);

} else
{
	SetVariable(cgfVar_LanguageCode,0);
	SetVariable(cgfVar_RegistryLocale,00000409);
}

[FormatLexURLs]
if CheckVariable(OEM,eq,Lexmark)
{
	FormatString(%CDFE_MENU_URLS.WebRegistration%,OCODE,!cgfVar_OS,WebRegistration);
	FormatString(!WebRegistration,LCODE,!cgfVar_LanguageCode,WebRegistration);
	FormatString(!WebRegistration,CCODE,!cgfVar_RegistryLocale,WebRegistration);

	FormatString(%CDFE_MENU_URLS.WebRewards%,OCODE,!cgfVar_OS,WebRewards);
	FormatString(!WebRewards,LCODE,!cgfVar_LanguageCode,WebRewards);
	FormatString(!WebRewards,CCODE,!cgfVar_RegistryLocale,WebRewards);

	FormatString(%CDFE_MENU_URLS.WebOffer%,OCODE,!cgfVar_OS,WebOffer);
	FormatString(!WebOffer,LCODE,!cgfVar_LanguageCode,WebOffer);
	FormatString(!WebOffer,CCODE,!cgfVar_RegistryLocale,WebOffer);
} else
{
	SetVariable(WebRegistration,%CDFE_MENU_URLS.WebRegistration%);
	SetVariable(WebRewards,%CDFE_MENU_URLS.WebRewards%);
	SetVariable(WebOffer,%CDFE_MENU_URLS.WebOffer%);
}

[RunPrinterSharingOnly]
if CheckVariable(cgfVar_PreLoadType,eq,PtrSharingOnly)
{
	ChangeWindow(PrinterSharing,mainSplitter.top,capture);
	ChangeWindow(Navigation,mainSplitter.bottom,capture);
	Break();
}
