[App.Init]
if CheckVariable(MediaType,eq,BBS)
{
} else
{
	if IsLangSupported($OS_LANG$)
	{
		SetVariable(cfgVar_ReplaceLanguage,false);
	} else
	{
		SetVariable(cfgVar_ReplaceLanguage,true);
	}
}

[Main.Init]
SetVariable(cgfvar_App4R_NotInstall,false);
SetVariable(cgfVar_OSRequireRunOnce,true);
SetVariable(cgfVar_alreadyInst,false);
SetVariable(cgfVar_RPSupportINI,$CD_ROOT_DIR$\%ModelCode%rtlr.ini);
SetVariable(OEM,%OEM%);
if CheckVariable(cfgVar_ReplaceLanguage,eq,true)
{
	PopupWindow(LangPicker);
}

RunSection(GetOSCode);
RunSection(GetCountryCode);
RunSection(FormatLexURLs);

#Check for the Windows Update case
if CheckOS(2K_VISTA)
{
	if RegExists(HKLM,%CustomInstallKey%\%Modelcode%,WUInstall,cgfVar_WUInstallValue)
	{	
		RunSection(WindowsUpdate);
	}
}
# Create the language window so we can see if there is a mismatch issue later.
ChangeWindow(LanguageMismatch,mainSplitter.top);
ChangeWindow(CDFE,mainSplitter.top);
ChangeWindow(Navigation,mainSplitter.bottom,capture);
if CheckOS(9X)
{
	ShowWindow(InstallTitle,false);
	ShowWindow(InstallTitleNT,false);
	ShowWindow(InstallTitle95,true);
	ShowWindow(Paragraph2,false);
	ShowWindow(Paragraph2_NoSupport,true);
	ShowWindow(UserGuide,false);
	ShowWindow(UserGuideText,false);
	ShowWindow(AntiVirusMessage,false);
	SetValue(LicenseAgreeText,%CDFE.Front_NoOSSupportOptionsText%);
} else if CheckOS(NT)
{
	ShowWindow(InstallTitle,false);
	ShowWindow(InstallTitleNT,true);
	ShowWindow(InstallTitle95,false);
	ShowWindow(Paragraph2,false);
	ShowWindow(Paragraph2_NoSupport,true);
	ShowWindow(UserGuide,false);
	ShowWindow(UserGuideText,false);
	ShowWindow(AntiVirusMessage,false);
	SetValue(LicenseAgreeText,%CDFE.Front_NoOSSupportOptionsText%);
} else
{
	ShowWindow(InstallTitle,true);
	ShowWindow(InstallTitleNT,false);
	ShowWindow(InstallTitle95,false);
	ShowWindow(Paragraph2_NoSupport,false);
	ShowWindow(AntiVirusMessage,true);
	if IsAdmin()
	{
		ShowWindow(Paragraph2,true);		
	} else
	{
		ShowWindow(UserGuide,false);
		ShowWindow(UserGuideText,false);
		ShowWindow(Paragraph2,false);
	}
}

#Setup NetSupp.dll
if CheckOS(x64)
{
	SetVariable(cgfVar_NetSuppDLL,$CD_ROOT_DIR$\Install\x64\NetSupp.dll);
} else 
{
	SetVariable(cgfVar_NetSuppDLL,$CD_ROOT_DIR$\Install\x86\NetSupp.dll);
}

# Copy help file on temp directory
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%\);

######################
# CDFE Dialog
######################
[CDFE.Init]
ShowWindow(Paragraph1,false);
if CheckVariable(VistaNoToolbarCDFEMenu,eq,true)
{
	SetValue(LicenseAgreeText,%CDFE.Front_OptionsTextNoTbar%);
}

[CDFE.EnableControls]
if CheckVariable(CurrentLanguage,eq,bg)
{
	SetVariable(cgfVar_ShowAltLangPicker,true);
} else if CheckVariable(CurrentLanguage,eq,ca)
{
	SetVariable(cgfVar_ShowAltLangPicker,true);
} else if CheckVariable(CurrentLanguage,eq,id_id)
{
	SetVariable(cgfVar_ShowAltLangPicker,true);
} else if CheckVariable(CurrentLanguage,eq,ro)
{
	SetVariable(cgfVar_ShowAltLangPicker,true);
} else if CheckVariable(CurrentLanguage,eq,sl)
{
	SetVariable(cgfVar_ShowAltLangPicker,true);
} else if CheckVariable(CurrentLanguage,eq,th)
{
	SetVariable(cgfVar_ShowAltLangPicker,true);
} else
{
	SetVariable(cgfVar_ShowAltLangPicker,false);
}

[CDFE.UserGuide.ButtonClick]
SetVariable(UserGuideDesktop,false);
if IsAdmin()
{
       	GetDesktop(cgfVar,AllUsers);
} else
{
	GetDesktop(cgfVar,CurrentUser);
}
FormatString(Desktop_path\%CDFE.UserGuideShortcut%,Desktop_path,!cgfVar,UserGuideDesktopPath);
RunSection(CheckUserGuideDesktop);
RunSection(CopyUserGuideDesktop);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,$CD_ROOT_DIR$\Pubs\%LANG%\%MODELCODE%user.chm); 

[CDFE.LicenseAgree.ButtonClick]
if CheckOS(9X)
{
	RunShell(!WebSupportPage);
} else if CheckOS(NT)
{
	RunShell(!WebSupportPage);
} else
{
	if CheckVariable(MediaType,eq,BBS)
	{
		if CheckVariable(VistaNoToolbarCDFEMenu,eq,true)
		{
			ShowMenu(DropdownMenuWebPackNoToolbar);
		} else
		{
			ShowMenu(DropdownMenuWebPack);
		}
	} else
	{
		if CheckVariable(VistaNoToolbarCDFEMenu,eq,true)
		{
			ShowMenu(DropdownMenuNoToolbar);
		} else
		{
			ShowMenu(DropdownMenu);
		}
	}
}

[CDFE.DropdownMenu.MenuClick]
SetVariable(cgfVar_MenuOption,#DropdownMenu);
RunSection(CDFEMenuOptions);

[CDFE.DropdownMenuNoToolbar.MenuClick]
SetVariable(cgfVar_MenuOption,#DropdownMenuNoToolbar);
RunSection(CDFEMenuOptions);

[CDFE.DropdownMenuWebPack.MenuClick]
SetVariable(cgfVar_MenuOption,#DropdownMenuWebPack);
RunSection(CDFEMenuOptions);

[CDFE.DropdownMenuWebPackNoToolbar.MenuClick]
SetVariable(cgfVar_MenuOption,#DropdownMenuWebPackNoToolbar);
RunSection(CDFEMenuOptions);

######################
# License Dialog
######################
[License.Init]
ShowWindow(Cancel,false);
ShowWindow(Install,false);
RunSection(CheckRPSupport);

[License.EnableControls]
ShowWindow(Cancel,false);
ShowWindow(Install,false);
ShowWindow(Agree,true);
ShowWindow(Disagree,true);

######################
# LicenseEx Dialog
######################
[LicenseEx.Init]
RunSection(CheckRPSupport);

[LicenseEx.Close.ButtonClick]
ShowWindow(LicenseExPopup,false);

###########################
# FirewallException Dialog
###########################
[FirewallException.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
ShowWindow(Exit,true);
ShowWindow(Continue,true);
ShowWindow(FWAppsList,false);
ShowWindow(AddInfo,false);

SetVariable(cgfVar_IsNull,#:0:FWAppsList);
TimerCheck(Start,true,100,RunSection,CheckForFirewallApps,cgfvar_FWListDelay);

[FirewallException.AddInfo.ButtonClick]
#ShowMessage(test, Addinfo, OK);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,$CD_ROOT_DIR$\Pubs\%LANG%\%MODELCODE%user.chm);

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

If IsAdmin()
{
	if CheckOS(9X)
	{
		ShowWindow(Install,false);
		ShowWindow(Cancel,false);
		ShowWindow(Exit,true);
		SetFocus(Exit);
	} else if CheckOS(NT)
	{
		ShowWindow(Install,false);
		ShowWindow(Cancel,false);
		ShowWindow(Exit,true);
		SetFocus(Exit);
	} else
	{
		ShowWindow(Install,true);
		SetFocus(Install);
	}
} else
{
	ShowMessage(%CDFE.NotAdmin%,%CDFE.ERROR%,OK);
	ShowWindow(Install,false);
	SetFocus(Cancel);
}

[WarsawRemove]
if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
{
	if CheckVariable(cgfVar_WarsawInstalled,eq,true)
	{
		if CheckOS(x64)
		{
			RunProgram($CD_ROOT_DIR$\Install\x64\uninst.exe,NOWAIT,/R:Uninst SkipConfirm=true Unst_Warsaw=true);
		} else
		{
			RunProgram($CD_ROOT_DIR$\Install\x86\uninst.exe,NOWAIT,/R:Uninst SkipConfirm=true Unst_Warsaw=true);
		}
	}
}


[Navigation.Cancel.ButtonClick]
# Remove Help file...
if CheckVariable(cgfVar_CopyHelp,eq,true)
{
        RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);
        RunInstallAction(cgfVar_RemoveFile,File,DeleteDir,$TEMP_DIR$\%MODELCODE%\);
}
if PromptMessage(%CancelRusure%,%CancelRusureTitle%,YesNo)
{
	FNHWThread(Stop);
	ExitApp(NoPrompt);
	RunSection(WarsawRemove);
}


[Navigation.Exit.ButtonClick]
# Remove Help file...
if CheckVariable(cgfVar_CopyHelp,eq,true)
{
        RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);
        RunInstallAction(cgfVar_RemoveFile,File,DeleteDir,$TEMP_DIR$\%MODELCODE%\);
}
if PromptMessage(%CancelRusure%,%CancelRusureTitle%,YesNo)
{
	FNHWThread(Stop);
	ExitApp(NoPrompt);
	RunSection(WarsawRemove);
}

[Navigation.BigExit.ButtonClick]
RunSection(Navigation.Exit.ButtonClick);

[Navigation.Done.ButtonClick]
FNHWThread(Stop);
if IsWindowActive(RebootScreen,InstallationComplete)
{
	if CheckValue(RebootYes,eq,true)
	{
		ExitApp(noPrompt,reboot);
	}
}
ExitApp(NoPrompt);

[Navigation.Disagree.ButtonClick]
ShowWindow(Cancel,true);
ShowWindow(Install,true);
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
GoBack();

[Navigation.Back.ButtonClick]
if IsWindowActive(PeerToPeerSetup,mainSplitter.top)
{
	if CheckVariable(NetAttached,eq,false)
	{
		if CheckVariable(cgfVar_alreadyInst,eq,false)
		{
			TimerCheck(Start,true,1000,RunSection,StopWaiting,cgfVar_timerId);
		}
	}
} else if IsWindowActive(NetworkingSetup,mainSplitter.top)
{
	if CheckVariable(cgfVar_alreadyInst,eq,false)
	{
		TimerCheck(Start,true,1000,RunSection,StopWaiting,cgfVar_timerId);
	}
} else if IsWindowActive(OSRequirements,mainSplitter.top)
{
	SetVariable(cgfVar_OSRequireRunOnce,true);
}
GoBack();

[WarsawInstall]
if RegExists(HKLM,!cgfvar_WarsawInstalledKey)
{
	SetVariable(cgfVar_WarsawInstalled,false);	
} else
{
	SetVariable(cgfVar_WarsawInstalled,true);	
	SetVariable(cgfVar_InstallPath,firstInstall);
	InstallComponent(Warsaw);	
}
EnableWindow(Continue,true);

[Navigation.Agree.ButtonClick]
if CheckVariable(cgfVar_ShowAltLangPicker,eq,true)
{
	PopupWindow(AltLangPicker);
	Break();
}

#Reset APWInstall key
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,%CustomInstallKey%\%ModelCode%,APWInstall,NUM,0);

if CheckOS(XP|X64|VISTA)
{
	ChangeWindow(FirewallException,mainSplitter.top);
} else
{
	RunSection(Navigation.Continue.ButtonClick);
}

	 


[Navigation.Continue.ButtonClick]
if IsWindowActive(LanguageMismatch,mainSplitter.top)
{
	RunSection(Navigation.Install.ButtonClick);
} else if IsWindowActive(SystemRequirements,mainSplitter.top)
{
	RunSection(LookingForDriverAndPO);
} else if IsWindowActive(AlreadyInstalled,mainSplitter.top)
{
	if CheckValue(InstallPrtObject,eq,true)
	{	
		ChangeWindow(LocalNetwork,mainSplitter.top,capture);
	} else 
	{
		RunSection(WriteWhatToInstall);	
		RunSection(StartInstallation);			
	}
} else if IsWindowActive(LocalNetwork,mainSplitter.top)
{
	if CheckValue(Local,eq,true)
	{
		if CheckVariable(cgfVar_FirstTime,eq,true)
		{
			SetVariable(cgfVar_InstallPath,firstInstall);
		} else if CheckVariable(cgfVar_InstallPath,eq,2ndCopy)
		{
			if IsDeviceConnected(4)
			{
			} else
			{
				Break();
			}
		}
		#Check for Language Mismatch
		if CheckSize(LanguageGrid,gt,0)
		{
			ChangeWindow(LanguageMismatch,mainSplitter.top);
		} else
		{
			#Ready to start installation
			RunSection(WriteWhatToInstall);
			RunSection(StartInstallation);
		}
	} else if CheckValue(Network,eq,true)
	{
		ChangeWindow(NetworkingSetup,mainSplitter.top,capture);
	} else if CheckValue(NetworkP2P,eq,true)
	{
		ChangeWindow(PeerToPeerSetup,mainSplitter.top,capture);
		SetVariable(cgfVar_InstallPath,P2PInstall);
	}
} else if IsWindowActive(NetworkingSetup,mainSplitter.top)
{
	if CheckValue(RB_PeerToPeer,eq,true)
	{
		ChangeWindow(PeerToPeerSetup,mainSplitter.top,capture);
		SetVariable(cgfVar_InstallPath,P2PInstall);
	} else
	{
		ChangeWindow(SelectNetPrinter,mainSplitter.top,capture);
		SetVariable(cgfVar_InstallPath,NAInstall);	
	}
} else if IsWindowActive(SelectNetPrinter,mainSplitter.top)
{
	#Save the selected port on the listbox
	SetVariable(cgfVar_SelectedPort,#:2:CompactNetPrinterList);
	if CheckVariable(NetScan,eq,true)
	{
		ChangeWindow(ConnectedToNetworkAIO,mainSplitter.top,capture);
	} else
	{
		if CheckVariable(cgfVar_ShowLangMismatch,eq,true)
		{
			ChangeWindow(LanguageMismatch,mainSplitter.top);
		} else
		{
			RunSection(Navigation.Install.ButtonClick);
		}
	}
} else if IsWindowActive(ConfigureNetPrinters,mainSplitter.top)
{
	#Save the selected port on the listbox
	SetVariable(cgfVar_SelectedPort,#NetPrinterList);
	if CheckVariable(NetScan,eq,true)
	{
		#Do not capture the current dialog (ConfigureNetPrinters),
		#because the 'Back' button from ConnectedToNetworkAIO dialog should go to SelectNetPrinter.
		ChangeWindow(ConnectedToNetworkAIO,mainSplitter.top);
	} else
	{
		if CheckVariable(cgfVar_ShowLangMismatch,eq,true)
		{
			ChangeWindow(LanguageMismatch,mainSplitter.top);
		} else
		{
			RunSection(Navigation.Install.ButtonClick);
		}
	}
} else if IsWindowActive(ConnectedToNetworkAIO,mainSplitter.top)
{
	#Check hostname is not blank.
	if CheckValue(EB_ComputerName,ne,empty)
	{			
		#Check if the user wishes a pin number and it is not blank.
		if CheckValue(CB_WishPin,eq,true)
		{			
			if CheckValue(EB_Pin,eq,empty)
			{
				ShowMessage(%NetworkAIO.Error_PinText%,%NetConfiguration.Title%,error);
				Break();
			} else if CheckSize(EB_Pin,lt,4)
			{
				ShowMessage(%NetworkAIO.Error_PinText4Digits%,%NetConfiguration.Title%,error);
				Break();
			}
		} 

		if CheckLength(EB_ComputerName,gt,14)
		{
			ShowMessage(%NetworkAIO.Error_Text%,%NetConfiguration.Title%,error);
			SetFocus(EB_ComputerName);
			Break();
		}
		
		if CheckVariable(cgfVar_ShowLangMismatch,eq,true)
		{			
			RunSection(VerifyHostNameAndLanguageGrid);
		} else
		{
			RunSection(Navigation.Install.ButtonClick);
		}
	} else
	{
		ShowMessage(%NetworkAIO.Error_Text%,%NetworkAIO.Error_Title%,error);
	}
} else if IsWindowActive(PeerToPeerSetup,mainSplitter.top)
{
	#Check if hostname/shareName are correct.
	RunSection(BuildP2PInfo);
	RunSection(DoInstallP2PClient);	
} else 
{
	if IsWindowActive(FirewallException,mainSplitter.top)
	{
		EnableWindow(Continue,false);
	}

	if IsWindowActive(OSRequirements,mainSplitter.top)
	{
		if CheckVariable(cgfvar_App4Roption,eq,Exit)
		{
			RunSection(Navigation.Exit.ButtonClick);
			Break();
		}
		EnableWindow(Continue,false);
	}

	if CheckVariable(cgfVar_OSRequireRunOnce,eq,true)
	{	
		RunSection(CheckOSRequirement);
	}
	
	# In case of 9X, we don't have system requirement check.
	# Just launch the installer, and the rest will be done in InstallShield (network install).
	if CheckOS(9X)
	{
	        RunProgram($CD_ROOT_DIR$\Drivers\Win_9X\%LANG%\%MODELCODE%stph.EXE,NOWAIT,nolicense);
		ExitApp(NoPrompt);
	} else
	{
		#Install LCS if is not installed already
		if CheckOS(x64)
		{
			SetVariable(cgfvar_WarsawInstalledKey,Software\Wow6432Node\%OEM%InkJet\LCS\local\%MODELCODE%\runtime);		
		} else
		{
			SetVariable(cgfvar_WarsawInstalledKey,Software\%OEM%InkJet\LCS\local\%MODELCODE%\runtime);
		}
		RunSection(WarsawInstall);

		FNHWThread(Start,KillFNHW);
		#Check for any system requirements
		if IsReqSatisfied()
		{
			RunSection(LookingForDriverAndPO);
		} else
		{
			ChangeWindow(SystemRequirements,mainSplitter.top);	
		}
	}
} 


[Navigation.Install.ButtonClick]
if IsWindowActive(CDFE,mainSplitter.top)
{
	if RegExists(HKLM,Software\Microsoft\Windows\CurrentVersion\RunOnce,lvdcUninstallRan,cgfVar_Reboot)
	{
		ShowMessage(%REBOOT_MESG%,%REBOOT_CAPTION%,ok);
		ExitApp(noPrompt);
	} else
	{
		ChangeWindow(License,mainSplitter.top,capture);
		SetFocus(LicenseText);
	}
} else
{
	# Add Additional Subnets so that LCS can discover it.
	if CheckVariable(IPAddListData,eq,empty)
	{	 
	} else
	{
		RunInstallAction(cgfVar_RegisterNetwork,RunLibFunction,!cgfVar_NetSuppDLL,RegisterNetworkSubnets,!IPAddListData);
	}	

	if IsWindowActive(LanguageMismatch,mainSplitter.top)
	{
		WriteGridLangToScript(LanguageGrid);
		RunSection(WriteWhatToInstall);
	} else if IsWindowActive(PeerToPeerSetup,mainSplitter.top)
	{
		#Check if hostname/shareName are correct.
	        RunSection(BuildP2PInfo);
		RunSection(CheckP2PInfo);
	} else if IsWindowActive(ConnectedToNetworkAIO,mainSplitter.top)
	{
		#Check hostname is not blank.
		if CheckValue(EB_ComputerName,ne,empty)
		{
			#Check if the user wishes a pin number and it is not blank.
			if CheckValue(CB_WishPin,eq,true)
			{
				if CheckValue(EB_Pin,eq,empty)
				{
					ShowMessage(%NetworkAIO.Error_PinText%,%NetConfiguration.Title%,error);
					Break();
				} else if CheckSize(EB_Pin,lt,4)
				{
					ShowMessage(%NetworkAIO.Error_PinText4Digits%,%NetConfiguration.Title%,error);
					Break();
				}
			}
	
			if CheckLength(EB_ComputerName,gt,14)
			{	
				ShowMessage(%NetworkAIO.Error_Text%,%NetConfiguration.Title%,error);
				SetFocus(EB_ComputerName);
				Break();
			}	 
 			
			RunSection(VerifyHostNameAndInstall);
			Break();						
		} else
		{
			ShowMessage(%NetworkAIO.Error_Text%,%NetworkAIO.Error_Title%,error);
			SetFocus(EB_ComputerName);
			Break();
		}
	} else
	{
		RunSection(WriteWhatToInstall);	
		RunSection(StartInstallation);	
	}
	
	# Add Additional Subnets so that LCS can discover it.
	if CheckVariable(IPAddListData,eq,empty)
	{	 
	} else
	{
		RunInstallAction(cgfVar_RegisterNetwork,RunLibFunction,!cgfVar_NetSuppDLL,RegisterNetworkSubnets,!IPAddListData);
	}	
	RunSection(StartInstallation);
}

########################
# SystemRequirements
########################
[SystemRequirements.Init]
ShowWindow(Install,false);
ShowWindow(Continue,true);
ShowWindow(Cancel,true);
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
if IsReqSatisfied(DiskSpace,cgfVar_Space)
{
	#Use success icon and string.
	SetValue(StatusIcon_SR4,%SystemRequirementsCheckIcon%);
	SetValue(ST_DiskSpaceStatus,%SystemRequirements.DiskSpace%);
} else
{
	#Change icon and string based on level.
	RunSection(StringLevel);
}
if IsReqSatisfied(ProcessorSpeed,cgfVar_Speed)
{
	#Use success icon and string.
	SetValue(StatusIcon_SR2,%SystemRequirementsCheckIcon%);
	SetValue(ST_ProcessorSpeedStatus,%SystemRequirements.ProcessorSpeed%);
} else
{
	#Change icon and string based on level.
	RunSection(StringLevel);
}
if IsReqSatisfied(Memory,cgfVar_Memory)
{
	#Use success icon and string
	SetValue(StatusIcon_SR3,%SystemRequirementsCheckIcon%);
	SetValue(ST_MemoryStatus,%SystemRequirements.Memory%);
} else
{
	#Change icon and string based on level.
	RunSection(StringLevel);	
}
if IsReqSatisfied(AdminRights,cgfVar_Admin)
{
	#Use success icon and string
	SetValue(StatusIcon_SR1,%SystemRequirementsCheckIcon%);
	SetValue(ST_AdminRightsStatus,%SystemRequirements.AdminRights%);
} else
{
	#Change icon and string based on level.
	RunSection(StringLevel);
}


[SystemRequirements.RB_AdminRights.ButtonClick]
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 210 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

[SystemRequirements.RB_DiskSpace.ButtonClick]
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 215 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

[SystemRequirements.RB_ProcessorSpeed.ButtonClick]
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 213 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

[SystemRequirements.RB_Memory.ButtonClick]
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 214 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

########################
# OSRequirements
########################
[OSRequirements.Init]
EnableWindow(Continue,true);
SetVariable(cgfvar_App4Roption,Exit);
SetValue(RB_OSReqExit_XP,true);

ShowWindow(Back,false);
ShowWindow(Cancel,true);
ShowWindow(Exit,false);
#ShowWindow(ExitBig,true);
ShowWindow(Continue,true);

[OSRequirements.RB_OSReqExit_XP.RadioSelect]
SetVariable(cgfvar_App4Roption,Exit);
#ShowWindow(Continue,false);
#ShowWindow(BigExit,true);

[OSRequirements.RB_OSReqContinue.RadioSelect]
SetVariable(cgfvar_App4Roption,Continue);
#SetVariable(cgfvar_App4R_NotInstall,true);
#ShowWindow(Continue,true);
#ShowWindow(BigExit,false);

########################
# SelectNetPrinter
########################
[SelectNetPrinter.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
EnableWindow(Back,true);
if CheckValue(CompactNetPrinterList,eq,empty)
{
	SetFocus(FirstAddPrinter);
} else
{
	SetFocus(CompactNetPrinterList);
}

[SelectNetPrinter.EnableControls]
EnableWindow(Back,true);
if CheckVariable(NetScan,eq,true)
{
	if CheckValue(CompactNetPrinterList,eq,empty)
	{
		EnableWindow(Continue,false);
	} else
	{
		EnableWindow(Continue,true);	
	}
} else
{
	if CheckSize(LanguageGrid,gt,0)
	{
		SetVariable(cgfVar_ShowLangMismatch,true);
		if CheckValue(CompactNetPrinterList,eq,empty)
		{
			EnableWindow(Continue,false);
		} else
		{
			EnableWindow(Continue,true);
		}
	} else
	{
		SetVariable(cgfVar_ShowLangMismatch,false);
		if CheckValue(CompactNetPrinterList,eq,empty)
		{
			EnableWindow(Continue,false);
		} else
		{
			EnableWindow(Continue,true);
		}
	}
}

[SelectNetPrinter.FirstAddPrinter.ButtonClick]
ChangeWindow(ConfigureNetPrinters,mainSplitter.top,capture);


########################
# ConfigureNetPrinters
########################
[ConfigureNetPrinters.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
EnableWindow(Back,true);
if CheckValue(NetPrinterList,eq,empty)
{
	SetFocus(AddPrinter);
} else
{
	SetFocus(NetPrinterList);
}


[ConfigureNetPrinters.EnableControls]
EnableWindow(Back,true);
if CheckVariable(NetScan,eq,true)
{
	#ShowWindow(Install,false);
	#ShowWindow(Continue,true);
	if CheckValue(NetPrinterList,eq,empty)
	{
		EnableWindow(Continue,false);
		EnableWindow(Configure,false);
	} else
	{
		EnableWindow(Continue,true);	
		EnableWindow(Configure,true);
	}
} else
{
	if CheckSize(LanguageGrid,gt,0)
	{
		#ShowWindow(Install,false);
		#ShowWindow(Continue,true);
		SetVariable(cgfVar_ShowLangMismatch,true);
		if CheckValue(NetPrinterList,eq,empty)
		{
			EnableWindow(Continue,false);
		} else
		{
			EnableWindow(Continue,true);
		}
	} else
	{
		#ShowWindow(Continue,false);
		#ShowWindow(Install,true);
		SetVariable(cgfVar_ShowLangMismatch,false);
		if CheckValue(NetPrinterList,eq,empty)
		{
			#EnableWindow(Install,false);
			EnableWindow(Continue,false);
		} else
		{
			#EnableWindow(Install,true);	
			EnableWindow(Continue,true);
		}
	}
}


[ConfigureNetPrinters.Configure.ButtonClick]
if CheckValue(NetPrinterList,eq,empty)
{
	ShowMessage(%ConfigNetPrinter.Error_Text%,%ConfigNetPrinter.Error_Title%,OK);
} else
{
	PopupWindow(NetworkConfiguration);
}

[ConfigureNetPrinters.AddPrinter.ButtonClick]
PopupWindow(AddNetPrinter);


[ConfigureNetPrinters.Refresh.ButtonClick]
#Refresh the list considering the latest filter.
if CheckVariable(parms,eq,empty)
{
	SetBoxParameters(NetPrinterList,%DEVICEID%|LexmarkPrintersNetwork||INKJET,refresh);
} else
{
	SetBoxParameters(NetPrinterList,!parms,refresh);
}

[ConfigureNetPrinters.HelpConf.ButtonClick]
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 525 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);


#############################
#NetworkingSetup Dialog
#############################
[NetworkingSetup.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
EnableWindow(Back,true);
SetValue(RB_PeerToPeer,true);
SetFocus(RB_PeerToPeer);
if CheckOS(XP)
{
	EnableWindow(NetworkSetupFirewallChecked,false);
	SetValue(NetworkSetupFirewallChecked,true);
} else if CheckOS(x64)
{
	EnableWindow(NetworkSetupFirewallChecked,false);
	SetValue(NetworkSetupFirewallChecked,true);
} else if CheckOS(VISTA)
{
	EnableWindow(NetworkSetupFirewallChecked,false);
	SetValue(NetworkSetupFirewallChecked,true);
} else
{
	SetValue(NetworkSetupFirewallChecked,false);
	ShowWindow(NetworkSetupFirewallChecked,false);
}

[NetworkingSetup.EnableControls]
ShowWindow(Back,true);
ShowWindow(Cancel,true);
ShowWindow(Install,false);
ShowWindow(Continue,true);
EnableWindow(Back,true);
EnableWindow(Continue,true);
if CheckValue(RB_DirNetAttached,eq,true)
{
	EnableWindow(NetworkSetupFirewallChecked,true);
} else
{
	EnableWindow(NetworkSetupFirewallChecked,false);
}

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

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

#############################
#LocalNetwork Dialog
#############################
[LocalNetwork.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
ShowWindow(Cancel,true);
Showwindow(Exit,false);
SetValue(Local,true);
SetFocus(Local);
ShowWindow(Cancel,true);
ShowWindow(Continue,true);
if CheckVariable(cgfVar_alreadyInst,eq,true)
{
	#User trying to install a second copy.
	EnableWindow(Continue,true);
	ShowWindow(Note,false);
} else
{
	#Clean system and user does not have a printer connected.
	EnableWindow(Continue,false);
	ShowWindow(Note,true);
	TimerCheck(Start,true,100,RunSection,StopWaiting,cgfVar_timerId);
}
if CheckVariable(NetAttached,eq,true)
{
	ShowWindow(NetworkP2P,false);
	EnableWindow(NetworkP2P,false);
} else
{
	ShowWindow(Network,false);
	EnableWindow(Network,false);
}
#ShowWindow(Install,false);

[LocalNetwork.EnableControls]
ShowWindow(Cancel,true);
Showwindow(Exit,false);
if CheckValue(Local,eq,true)
{
	if CheckVariable(cgfVar_alreadyInst,eq,true)
	{
		#For a second copy, local path always available to proceed.
		SetVariable(cgfVar_InstallPath,2ndCopy);
		EnableWindow(Continue,true);
		ShowWindow(Note,false);
	} else
	{
		ShowWindow(Note,true);
		#For clean system, local path only available to proceed if printer connected.
		if IsDeviceConnected(4)
		{
			EnableWindow(Continue,true);
		} else
		{
			EnableWindow(Continue,false);
		}
	}
} else
{
	EnableWindow(Continue,true);
}
if CheckVariable(cgfVar_alreadyInst,eq,true)
{
	ShowWindow(Back,false);
	EnableWindow(Back,false);
} else
{
	ShowWindow(Back,false);
	EnableWindow(Back,false);
}
ShowWindow(Continue,true);
ShowWindow(Install,false);

[LocalNetwork.Tips.ButtonClick]
#open Help file for the 
#OpenHelpFile($TEMP_DIR$\%MODELCODE%\%MODELCODE%help.hlp,1,512);
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 512 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

#############################
#AlreadyInstalled Dialog
#############################
[AlreadyInstalled.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
ShowWindow(Cancel,false);
ShowWindow(Exit,true);
ShowWindow(Continue,true);
ShowWindow(Install,false);
ShowWindow(Back,false);
#Prepare the dialog based on the SecondCopy variable.
SetVariable(cgfVar_alreadyInst,true);
SetVariable(cgfVar_InstallPath,updating);
if CheckVariable(SecondCopy,eq,true)
{
	ShowWindow(AlreadyInstalledAffirmation,false);
	SetValue(Update,true);
	SetFocus(Update);
} else
{
	ShowWindow(AlreadyInstalledQuestion,false);
	ShowWindow(Update,false);
	ShowWindow(InstallPrtObject,false);
}

[AlreadyInstalled.EnableControls]
ShowWindow(Back, false);
ShowWindow(Cancel,false);
ShoWWindow(Exit,true);
if CheckValue(Update,eq,true)
{
	SetVariable(cgfVar_InstallPath,updating);
}
ShowWindow(Continue,true);

#############################
#PeerToPeerSetup Dialog
#############################
[PeerToPeerSetup.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
ShowWindow(Back,true);
if CheckOS(XP|VISTA)
{
	SetValue(PeerToPeerSetupFirewallChecked,true);
} else if CheckOS(x64)
{
	SetValue(PeerToPeerSetupFirewallChecked,true);
} else
{
	SetValue(PeerToPeerSetupFirewallChecked,false);
	ShowWindow(FirewallNotice,false);
	ShowWindow(PeerToPeerSetupFirewallChecked,false);
}
SetFocus(EB_RemoteComputerName);


[PeerToPeerSetup.EnableControls]
ShowWindow(Back,true);
EnableWindow(Back,true);
if CheckSize(LanguageGrid,gt,0)
{
	#ShowWindow(Install,false);
	#ShowWindow(Continue,true);
	SetVariable(cgfVar_ShowLangMismatch,true);
} else
{
	#ShowWindow(Install,true);
	#ShowWindow(Continue,false);
	SetVariable(cgfVar_ShowLangMismatch,false);
}

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

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

#############################
#ConnectedToNetworkAIO Dialog
#############################
[ConnectedToNetworkAIO.Init]
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
SetValue(EB_ComputerName,$COMPUTER_NAME$);
RunSection(SetDefaultComputerName);
SetValue(CB_WishPin,false);
EnableWindow(EB_Pin,false);
SetFocus(EB_ComputerName);

[ConnectedToNetworkAIO.HelpAIO.ButtonClick]
RunProgram($WINDOWS_DIR$\hh.exe,NOWAIT,-mapid 528 $TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);

[ConnectedToNetworkAIO.EnableControls]
EnableWindow(Install,true);
EnableWindow(Continue,true);
if CheckValue(EB_ComputerName,eq,empty)
{
	EnableWindow(Install,false);
	EnableWindow(Continue,false);
} 
if CheckSize(LanguageGrid,gt,0)
{
	#ShowWindow(Install,false);
	#ShowWindow(Continue,true);
	SetVariable(cgfVar_ShowLangMismatch,true);
} else
{
	#ShowWindow(Install,true);
	#ShowWindow(Continue,false);
	SetVariable(cgfVar_ShowLangMismatch,false);
}
if CheckValue(CB_WishPin,eq,true)
{
	EnableWindow(EB_Pin,true);
	if CheckValue(EB_Pin,eq,empty)
	{
		EnableWindow(Install,false);
		EnableWindow(Continue,false);
	} 
} else
{
	EnableWindow(EB_Pin,false);
}

############################
#LanguageMismatch Dialog
############################
[LanguageMismatch.Init]
ShowWindow(Back,false);
ShowWindow(Continue,false);

[LanguageMismatch.EnableControls]
ShowWindow(Back,false);
ShowWindow(Agree,false);
ShowWindow(Disagree,false);
ShowWindow(Install,false);
ShowWindow(Cancel,true);
ShowWindow(Continue,true);

############################
# ProgressScreen Dialog
############################
[ProgressScreen.Init]
ShowWindow(Agree,false);
ShowWindow(Continue,false);
ShowWindow(Exit,false);
ShowWindow(Install,false);

#######################
# InstallationComplete
#######################
[InstallationComplete.Init]
ShowWindow(Install,false);
ShowWindow(Disagree,false);
ShowWindow(Done,true);
ShowWindow(Exit,false);
ShowWindow(Continue,false);
SetFocus(Done);
SetValue(RebootYes,false);
SetValue(RebootNo,true);
ShowWindow(RebootScreen,false);
if IsRebootSet()
{
	SetValue(RebootYes,true);
	ShowWindow(RebootScreen,true);		
	SetValue(InstallCompleteInfo,%INSTALL_COMPLETE_INFO_REBOOT%);
}

#############################
#AddNetPrinter PopupDialog
#############################
[AddNetPrinter.Init]
SetFocus(IPAddressEdit);
EnableWindow(Add,false);
EnableWindow(OkAdding,false);

[AddNetPrinter.EnableControls]
if CheckSize(IPAdressList,eq,0)
{
    EnableWindow(Delete,false);
	EnableWindow(OkAdding,false);
} else
{
	EnableWindow(Delete,true);
	EnableWindow(OkAdding,true);
}
if CheckValue(IPAddressEdit,ne,Blank_IP)
{
	EnableWindow(OkAdding,true);
}

[AddNetPrinter.OkAdding.ButtonClick]
ShowWindow(AddNetPrinterPopup,false);
if CheckValue(OneNewPrinter,eq,true)
{
	# If IP editbox is empty, then don't add anything...
	if CheckVariable(IPAddressEdit,ne,Blank_IP)
	{	
        AddValue(IPAdressList,#IPAddressEdit,,trimSpace);
    }
}
SetListVariable(IPAddListData,IPAdressList);
FormatString(%DEVICEID%|LexmarkPrintersNetwork||INKJET|IPADDS,IPADDS,!IPAddListData,parms);
# parms is the form of parameter (INKJET|IP1|IP2|...|IPn)
SetBoxParameters(NetPrinterList,!parms,refresh);

[AddNetPrinter.CancelAdding.ButtonClick]
ShowWindow(AddNetPrinterPopup,false);

[AddNetPrinter.Add.ButtonClick]
if CheckValue(SubNetEdit,ne,Blank_IP)
{
	AddValue(IPAdressList,#SubNetEdit,,trimSpace);
}
SetValue(SubNetEdit,Blank_IP);
SetFocus(SubNetEdit);

[AddNetPrinter.Delete.ButtonClick]
RemoveData(IPAdressList,#IPAdressList);

[AddNetPrinter.OneNewPrinter.RadioSelect]
SetValue(SubNetEdit,Blank_IP);
SetFocus(IPAddressEdit);
EnableWindow(Add,false);
EnableWindow(Delete,false);

[AddNetPrinter.MultNewPrinter.RadioSelect]
SetValue(IPAddressEdit,Blank_IP);
SetFocus(SubNetEdit);
EnableWindow(Add,true);

[AddNetPrinter.IPAddressEdit.OnFocus]
SetValue(OneNewPrinter, true);
SetValue(SubNetEdit,Blank_IP);
EnableWindow(Add,false);

[AddNetPrinter.SubNetEdit.OnFocus]
SetValue(MultNewPrinter, true);
SetValue(IPAddressEdit,Blank_IP);
EnableWindow(Add,true);


##################################
#NetworkConfiguration PopupDialog
##################################
[NetworkConfiguration.Init]
SetValue(DHCP,true);
SetValue(IPAddressManual,#:1:NetPrinterList);
SetValue(SubnetMaskAddress,#:10:NetPrinterList);
SetValue(GatewayAddress,#:9:NetPrinterList);

[NetworkConfiguration.EnableControls]
if CheckValue(DHCP,eq,true)
{
	EnableWindow(IPAddressManual,false);
	EnableWindow(SubnetMaskAddress,false);
	EnableWindow(GatewayAddress,false);
} else
{
	EnableWindow(IPAddressManual,true);
	EnableWindow(SubnetMaskAddress,true);
	EnableWindow(GatewayAddress,true);	
	if CheckValue(IPAddressManual,eq,Blank_IP)
	{
		EnableWindow(OKConfig,false);
	} else
	{
		EnableWindow(OKConfig,true);
	}
	if CheckValue(SubnetMaskAddress,eq,Blank_IP)
	{
		EnableWindow(OKConfig,false);	
	} else	
	{
		EnableWindow(OKConfig,true);
	}
	if CheckValue(GatewayAddress,eq,Blank_IP)
	{
		SetValue(GatewayAddress,#:9:NetPrinterList);	
	}
}

[NetworkConfiguration.OKConfig.ButtonClick]
#Get info from the port select to pass as parameters to configure function.
#The parameters are IPADDRSOURCE,IPADDRESS,BROADCASTADDRESS,IPNETMASK,IPNAME,MACUAA,IPGATEWAY,IPADDRESSCONFIG
#The last 3 parameter NETCONFIGIPADDRESS,NETCONFIGNETMASK,NETCONFIGGATEWAY is set only if the user tries to configure IP manually, not with DHCP.
if CheckValue(DHCP,eq,true)
{
	RunInstallAction(cgfVar_returnValue,RunLibFunction,!cgfVar_NetSuppDLL,ConfigurePortIP,#:6:NetPrinterList|#:1:NetPrinterList|#:7:NetPrinterList|#:10:NetPrinterList|#:8:NetPrinterList|#:3:NetPrinterList|#:9:NetPrinterList);
} else
{
	SetVariable(NETCONFIGIPADDRESS,#IPAddressManual,trimSpace);
	SetVariable(NETCONFIGNETMASK,#SubnetMaskAddress,trimSpace);
	SetVariable(NETCONFIGGATEWAY,#GatewayAddress,trimSpace);
	RunInstallAction(cgfVar_returnValue,RunLibFunction,!cgfVar_NetSuppDLL,ConfigurePortIP,#:6:NetPrinterList|#:1:NetPrinterList|#:7:NetPrinterList|#:10:NetPrinterList|#:8:NetPrinterList|#:3:NetPrinterList|#:9:NetPrinterList|!NETCONFIGIPADDRESS|!NETCONFIGNETMASK|!NETCONFIGGATEWAY);
}
# Close popup window after configuring port.
ShowWindow(NetworkConfigurationPopup,false);
#Refresh the list considering the latest filter.
if CheckVariable(parms,eq,empty)
{
	SetBoxParameters(NetPrinterList,%DEVICEID%|LexmarkPrintersNetwork||INKJET,refresh);
} else
{
	SetBoxParameters(NetPrinterList,!parms,refresh);
}


[NetworkConfiguration.CancelConfig.ButtonClick]
ShowWindow(NetworkConfigurationPopup,false);

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

#########################
# LangPicker PopupDialog
#########################
[LangPicker.Init]
#CurrentLanguage is a special variable set by the gui when the nls file is initialized.
SetValue(LangList,!CurrentLanguage);
SetFocus(LangList);

[LangPicker.LangOk.ButtonClick]
if CheckVariable(CurrentLanguage,ne,#LangList)
{
	# Only make the change if they choose a different language than the current.
	ChangeLanguage(#LangList);
}
ShowWindow(LangPickerPopup,false);

############################
# AltLangPicker PopupDialog
############################
[AltLangPicker.Init]
SetFocus(LangList);

[AltLangPicker.AltLangOk.ButtonClick]
ChangeLanguage(#AltLangList);
ShowWindow(AltLangPickerPopup,false);

######################
# GOTO Sections
######################
[CheckUserGuideDesktop]
if DoesFileExists(!UserGuideDesktopPath)
{
	SetVariable(UserGuideDesktop,true);	
} else
{
	SetVariable(UserGuideDesktop,false);        
}

[CopyUserGuideDesktop]
if CheckVariable(UserGuideDesktop,eq,false)
{
	RunSection(UsersGuideLogic);
}

[CopyGuide]
if CopyFile($CD_ROOT_DIR$\Pubs\%LANG%\%MODELCODE%user.chm,!UserGuideWithPath)
{
} else
{
	ShowMessage(Couldn't copy!,Error,ok);
}

[UsersGuideLogic]
if PromptMessage(%CDFE.CopyUsersGuideInfo%,%CDFE.CopyUsersGuideTitle%,YesNo)
{
        # Use RunAction() instead of GetDesktop()...
        if IsAdmin()
        {
        	GetDesktop(cgfVar,AllUsers);
        } else
        {
        	GetDesktop(cgfVar,CurrentUser);
        }
        FormatString(CD_Pubs\%CDFE.UserGuideShortcut%,CD_Pubs,!cgfVar,UserGuideWithPath);
        # Gotta use RunAction() instead of DoesFileExists()...
        if DoesFileExists(!UserGuideWithPath)
        {
        } else
        {
                # Gotta use RunAction() instead of copyfile()...
                RunSection(CopyGuide);
        }
} else
{
}

[StringLevel]
if CheckVariable(cgfVar_Space,eq,warning)
{
	SetValue(StatusIcon_SR4,%SystemRequirementsWarningIcon%);
	FormatString(%SystemRequirements.Warning_DiskSpace%,%s,!SYSREQ_SPACE,strSpaceWarning);
	SetValue(ST_DiskSpaceStatus,!strSpaceWarning);
} else if CheckVariable(cgfVar_Space,eq,warning2)
{
	SetValue(StatusIcon_SR4,%SystemRequirementsWarning2Icon%);
	FormatString(%SystemRequirements.Warning_DiskSpace%,%s,!SYSREQ_SPACEACCEPT,strSpaceWarning);
	SetValue(ST_DiskSpaceStatus,!strSpaceWarning);
	#SetValue(ST_Warning,%SystemRequirements.Warning2%);
	SetVariable(cgfVar_whatmsg2,warn2);
} else if CheckVariable(cgfVar_Space,eq,failed)
{
	SetValue(StatusIcon_SR4,%SystemRequirementsCriticalIcon%);
	FormatString(%SystemRequirements.Failed_DiskSpace%,%s,!SYSREQ_SPACEMIN,strSpaceFailed);
	SetValue(ST_DiskSpaceStatus,!strSpaceFailed);
	#SetValue(ST_Warning,%SystemRequirements.Error%);
	#EnableWindow(Continue,false);
	SetVariable(cgfVar_whatmsg,error);
}

if CheckVariable(cgfVar_Speed,eq,warning)
{
	SetValue(StatusIcon_SR2,%SystemRequirementsWarningIcon%);
	FormatString(%SystemRequirements.Warning_ProcessorSpeed%,%s,!SYSREQ_CPU,strSpeedWarning);
	SetValue(ST_ProcessorSpeedStatus,!strSpeedWarning);
} else if CheckVariable(cgfVar_Speed,eq,warning2)
{
	SetValue(StatusIcon_SR2,%SystemRequirementsWarning2Icon%);
	FormatString(%SystemRequirements.Warning_ProcessorSpeed%,%s,!SYSREQ_CPUACCEPT,strSpeedWarning);
	SetValue(ST_ProcessorSpeedStatus,!strSpeedWarning);
	#SetValue(ST_Warning,%SystemRequirements.Warning2%);
	SetVariable(cgfVar_whatmsg2,warn2);
} else if CheckVariable(cgfVar_Speed,eq,failed)
{
	SetValue(StatusIcon_SR2,%SystemRequirementsCriticalIcon%);
	FormatString(%SystemRequirements.Failed_ProcessorSpeed%,%s,!SYSREQ_CPUMIN,strSpeedFailed);
	SetValue(ST_ProcessorSpeedStatus,!strSpeedFailed);
	#SetValue(ST_Warning,%SystemRequirements.Error%);
	#EnableWindow(Continue,false);
	SetVariable(cgfVar_whatmsg,error);
}

if CheckVariable(cgfVar_Memory,eq,warning)
{
	SetValue(StatusIcon_SR3,%SystemRequirementsWarningIcon%);
	FormatString(%SystemRequirements.Warning_Memory%,%s,!SYSREQ_MEMORY,strMemoryWarning);
	SetValue(ST_MemoryStatus,!strMemoryWarning);
} else if CheckVariable(cgfVar_Memory,eq,warning2)
{
	SetValue(StatusIcon_SR3,%SystemRequirementsWarning2Icon%);
	FormatString(%SystemRequirements.Warning_Memory%,%s,!SYSREQ_MEMORYACCEPT,strMemoryWarning);
	SetValue(ST_MemoryStatus,!strMemoryWarning);
	#SetValue(ST_Warning,%SystemRequirements.Warning2%);
	SetVariable(cgfVar_whatmsg2,warn2);
} else if CheckVariable(cgfVar_Memory,eq,failed)
{
	SetValue(StatusIcon_SR3,%SystemRequirementsCriticalIcon%);
	FormatString(%SystemRequirements.Failed_Memory%,%s,!SYSREQ_MEMORYMIN,strMemoryFailed);
	SetValue(ST_MemoryStatus,!strMemoryFailed);
	#SetValue(ST_Warning,%SystemRequirements.Error%);
	#EnableWindow(Continue,false);
	SetVariable(cgfVar_whatmsg,error);
}

if CheckVariable(cgfVar_Admin,eq,warning)
{
	SetValue(StatusIcon_SR1,%SystemRequirementsWarningIcon%);
	SetValue(ST_AdminRightsStatus,%SystemRequirements.Failed_AdminRights%);
} else if CheckVariable(cgfVar_Admin,eq,failed)
{
	SetValue(StatusIcon_SR1,%SystemRequirementsCriticalIcon%);
	SetValue(ST_AdminRightsStatus,%SystemRequirements.Failed_AdminRights%);
	SetValue(ST_Warning,%SystemRequirements.Error%);
	EnableWindow(Continue,false);
}
RunSection(BottomMsg);

[BottomMsg]
if CheckVariable(cgfVar_whatmsg,eq,error)
{
	SetValue(ST_Warning,%SystemRequirements.Error%);
	EnableWindow(Continue,false);
} else if CheckVariable(cgfVar_whatmsg2,eq,warn2)
{
	SetValue(ST_Warning,%SystemRequirements.Warning2%);	
}


[LookingForDriverAndPO]
#Check if driver already exist on the system.
if DoesDriverExists(%OEM% %ModelName%,cgfVar_POPortExists)
{
	RunSection(CheckingOnPort);	
} else
{
	#Clean System - Check if correct printer is connected - It tries the local path first.
	SetVariable(cgfVar_InstallPath,firstInstall);
	if IsDeviceConnected(4)
	{
		#Check for Language Mismatch
		if CheckSize(LanguageGrid,gt,0)
		{
			ChangeWindow(LanguageMismatch,mainSplitter.top);
		} else
		{
			#Ready to start installation
			RunSection(WriteWhatToInstall);
			RunSection(StartInstallation);
		}
	} else
	{
		#Request the user to connect the printer.
		ChangeWindow(LocalNetwork,mainSplitter.top,capture);
	}
}

[CheckingOnPort]
if CheckVariable(cgfVar_POPortExists,eq,empty)
{
	#Driver already exists, BUT no PO. So, installer has to proceed as installing in a clean system.
	SetVariable(cgfVar_InstallPath,firstInstall);
	if IsDeviceConnected(4)
	{
		#Check for Language Mismatch
		if CheckSize(LanguageGrid,gt,0)
		{
			ChangeWindow(LanguageMismatch,mainSplitter.top);
		} else
		{
			#Ready to start installation
			RunSection(WriteWhatToInstall);
			RunSection(StartInstallation);
		}
	} else
	{
		#Request the user to connect the printer.
		ChangeWindow(LocalNetwork,mainSplitter.top,capture);
	}
} else
{
	#Driver already Installed and at least one PO exist.
	ChangeWindow(AlreadyInstalled,mainSplitter.top);
}



[WriteWhatToInstall]
if CheckVariable(cgfVar_InstallPath,eq,updating)
{
	WriteToScript(Install.Devices.Device0,1);
	WriteToScript(Install.Devices.Device1,1);
	WriteToScript(Install.Devices.Device2,1);
	WriteToScript(Install.Devices.Device3,1);
	WriteToScript(Install.Devices.Device4,1);
	WriteToScript(Install.Devices.Device5,1);
	WriteToScript(Device4.Model,%OEM% %ModelName%);
	WriteToScript(Device1.Model,%OEM% %ModelName% Scanner);
	WriteToScript(Install.warsaw,1);
} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
{
	WriteToScript(Install.Devices.Device0,1);
	WriteToScript(Install.Devices.Device1,1);
	WriteToScript(Install.Devices.Device2,1);
	WriteToScript(Install.Devices.Device3,1);
	WriteToScript(Install.Devices.Device4,1);
	WriteToScript(Install.Devices.Device5,1);
	WriteToScript(Device4.Model,%OEM% %ModelName%);
	WriteToScript(Device1.Model,%OEM% %ModelName% Scanner);
	if CheckValue(PrinterShared,eq,true)
	{
		WriteToScript(Device4.ShareName,#ShareNameEdit);
		WriteToScript(Device4.Share,1);
	}
	if CheckValue(FirewallChecked,eq,true)
	{
		WriteToScript(Install.AppToFEL.InstallationType,Local);
	}
	#Set a registry value with the printer object name.
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,%CustomInstallKey%\%ModelCode%,LatestPrinterObject,STR,%OEM% %ModelName%);
} else if CheckVariable(cgfVar_InstallPath,eq,2ndCopy)
{
	MakePrinterName(%OEM% %ModelName%,cgfVar_printerName,useInstalled);
	WriteToScript(Install.Drivers.Printer0,1);
	WriteToScript(Printer0.ExistingDriver,%OEM% %ModelName%);
	WriteToScript(Printer0.Name,!cgfVar_printerName);
	if CheckValue(PrinterShared,eq,true)
	{
		WriteToScript(Printer0.Share,1);
		WriteToScript(Printer0.ShareName,#ShareNameEdit);
	}
	GetPrinterPort(cgfVar_POPortExists,USB,last,4);
	WriteToScript(Printer0.Port,!cgfVar_POPortExists);
	WriteToScript(Printer0.Default,1);
	#Set a registry value with the printer object name.
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,%CustomInstallKey%\%ModelCode%,LatestPrinterObject,STR,!cgfVar_printerName);
} else if CheckVariable(cgfVar_InstallPath,eq,P2PInstall)
{
	if CheckValue(PeerToPeerSetupFirewallChecked,eq,true)
	{
		WriteToScript(Install.AppToFEL,1);
		WriteToScript(AppToFEL.InstallationType,P2P);
	}
	WriteToScript(Install.Devices.Device0,1);
	WriteToScript(Install.Devices.Device1,1);
	WriteToScript(Install.Devices.Device2,1);
	WriteToScript(Install.Devices.Device3,1);
	WriteToScript(Install.Devices.Device4,1);
	WriteToScript(Install.Devices.Device5,1);
	WriteToScript(Device4.Model,%OEM% %ModelName%);
	FormatString(\\hostName\shareName,hostName,#EB_RemoteComputerName,cgfVar_PortName);
	FormatString(!cgfVar_PortName,shareName,#EB_SharedPrinterName,cgfVar_PortName);
	WriteToScript(Device4.Port,!cgfVar_PortName);
	WriteToScript(Device1.Model,%OEM% %ModelName% Scanner);
	WriteToScript(Install.Ports.Port1,P2P);
	WriteToScript(Port1.Name,!cgfVar_PortName);
	WriteToScript(Port1.IPAddress,#EB_RemoteComputerName);
	WriteToScript(Port1.ShareName,#EB_SharedPrinterName);
	#Set a registry value with the printer object name.
	MakePrinterName(%OEM% %ModelName%,cgfVar_printerName,useInstalled);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,%CustomInstallKey%\%ModelCode%,LatestPrinterObject,STR,!cgfVar_printerName);
} else if CheckVariable(cgfVar_InstallPath,eq,NAInstall)
{
	if CheckVariable(NetScan,eq,true)
	{
		WriteToScript(Install.NetScan,1);
		WriteToScript(NetScan.HostName,#EB_ComputerName);
		if CheckValue(CB_WishPin,eq,true)
		{
			WriteToScript(NetScan.Pin,#EB_Pin);
		} else
		{
			WriteToScript(NetScan.Pin,0000);
		}
		WriteToScript(NetScan.CodePage,$CODEPAGE$);		
	}
	if CheckValue(NetworkSetupFirewallChecked,eq,true)
	{
		WriteToScript(Install.AppToFEL,1);
		WriteToScript(AppToFEL.InstallationType,NA);	
	}
	WriteToScript(Install.Devices.Device0,1);
	WriteToScript(Install.Devices.Device1,1);
	WriteToScript(Install.Devices.Device2,1);
	WriteToScript(Install.Devices.Device3,1);
	WriteToScript(Install.Devices.Device4,1);
	WriteToScript(Install.Devices.Device5,1);
	WriteToScript(Device4.Model,%OEM% %ModelName%);
	#The port value may come from two different listbox. So, lets use the variable instantiated earlier.
	#WriteToScript(Device4.Port,#NetPrinterList);
	WriteToScript(Device4.Port,!cgfVar_SelectedPort);
	WriteToScript(Device1.Model,%OEM% %ModelName% Scanner);
	#Set a registry value with the printer object name.
	MakePrinterName(%OEM% %ModelName%,cgfVar_printerName,useInstalled);
	RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,%CustomInstallKey%\%ModelCode%,LatestPrinterObject,STR,!cgfVar_printerName);
}

if CheckVariable(cgfVar_InstallPath,ne,updating)
{
	#All paths but Update, install Apps
	WriteToScript(Install.warsaw,1);
	WriteToScript(Install.OCR,1);
	WriteToScript(Install.UsersGd,1);
	WriteToScript(Install.Misc,1);
	if CheckVariable( App4R,ne,true)
	{
		WriteToScript(Install.AppInst.AIOC,1);
		WriteToScript(Install.AppInst.EZPrint,1);
		WriteToScript(Install.AppInst.LaunchPd,1);
		WriteToScript(Install.AppInst.PhotoEd,1);
	} else
	{	
		if CheckVariable(cgfvar_App4R_NotInstall,eq,false)
		{
			WriteToScript(Install.App4R,1);
		}
		# Install these apps temporarily for A1.
		#WriteToScript(Install.AppInst.AIOC,1);
		#WriteToScript(Install.AppInst.EZPrint,1);
		#WriteToScript(Install.AppInst.LaunchPd,1);
		#WriteToScript(Install.AppInst.PhotoEd,1);
	}
	# Turn on these install calls only if the product supports.
	#WriteToScript(Install.Fax3,1);
	#WriteToScript(Install.AppInst.Fax4,1);
	#WriteToScript(Install.FaxSetup,1);
	#WriteToScript(Install.BVRP,1);
	#WriteToScript(Install.Vendor.PageManager,1);
	#WriteToScript(Install.Vendor.Forms,1);
}

[BuildP2PInfo]
FormatString(hostName|shareName|modelName,hostName,#EB_RemoteComputerName,cfgVar_VerifyPrinterParam);
FormatString(!cfgVar_VerifyPrinterParam,shareName,#EB_SharedPrinterName,cfgVar_VerifyPrinterParam);
FormatString(!cfgVar_VerifyPrinterParam,modelName,%OEM% %ModelName%,cfgVar_VerifyPrinterParam);

RunInstallAction(cgfVar_P2PCheckValue,RunLibFunction,!cgfVar_NetSuppDLL,VerifySharedPrinterExists,!cfgVar_VerifyPrinterParam);

[CheckP2PInfo]
if CheckVariable(cgfVar_P2PCheckValue,eq,true)
{
	RunSection(WriteWhatToInstall); 
} else 
{
	ShowMessage(%P2PSetup.Error_Text%,%P2PSetup.Error_Title%,error);
	SetFocus(EB_RemoteComputerName);
	Break();
}

[DoInstallP2PClient]
if CheckVariable(cgfVar_P2PCheckValue,eq,true)
{
	if CheckVariable(cgfVar_ShowLangMismatch,eq,true)
	{
		ChangeWindow(LanguageMismatch,mainSplitter.top);
	} else
	{
		RunSection(CheckP2PInfo);
		RunSection(StartInstallation);
	}
} else
{
	ShowMessage(%P2PSetup.Error_Text%,%P2PSetup.Error_Title%,error);
	SetFocus(EB_RemoteComputerName);
}

[StopWaiting]
if IsWindowActive(LocalNetwork,mainSplitter.top)
{
	if IsDeviceConnected(4)
	{
		EnableWindow(Continue,true);
		SetVariable(cgfVar_FirstTime,true);
		SetVariable(cgfVar_InstallPath,firstInstall);
		RunSection(WriteWhatToInstall);
		RunSection(StartInstallation);
	} else
	{
		TimerCheck(Start,true,100,RunSection,StopWaiting,cgfVar_timerId);
	}
} else 
{
	TimerCheck(Stop,cgfVar_timerId); 		
}

[StartInstallation]
HideMainFrame();
#Set registry to indicate that custom installation will happen.
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Add,HKLM,%CustomInstallKey%,%OEM% %ModelName%,NUM,1);

# Check if Warsaw COMs Server was installed.
if RegExists(HKLM,%Install_Reg%\LCS\Local\%ModelCode%\runtime)
{
	SetVariable(cgfVar_WarsawInstalled,true);
}
HideMainFrame();
StartInstall(ProgressScreen,ProgressBar,ProgressText,,,ComponentProgressBar);	
FNHWThread(Stop);

if CheckVariable(cgfVar_InstallPath,eq,updating)
{
	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,WAIT,-unregister);
		# RunProgram($PROGRAMFILES_DIR$\%OEM% %ModelName%\%ModelCode%amon.exe,NOWAIT);
	}
} else
{
	if CheckVariable(cgfVar_WarsawInstalled,eq,false)
	{
		RunProgram($SYSTEM_DIR$\%ModelCode%coms.exe,WAIT,-install);
		RunProgram($SYSTEM_DIR$\%ModelCode%coms.exe,WAIT,-addmonitor);
	}
}

if CheckVariable(cgfVar_InstallPath,ne,updating)
{
	#All install path but updating has to run the bew tasks, after rebooting or not.
	#Also, BEW Tasks has to know if a local path has been performed.
	if IsRebootSet()
	{
		if CheckOS(x64)
		{
			if CheckVariable(cgfvar_App4R_NotInstall,eq,false)
			{
				if CheckVariable(cgfVar_InstallPath,eq,2ndcopy)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x64\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local);
				} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x64\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local);
				} else
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x64\instgui.exe /M /L:%IS_LANG% /R:bewTasks);
				}
			} else
			{
				if CheckVariable(cgfVar_InstallPath,eq,2ndcopy)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x64\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local App4RFlag=NotInstalled);
				} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x64\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local App4RFlag=NotInstalled);
				} else
				{	
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x64\instgui.exe /M /L:%IS_LANG% /R:bewTasks App4RFlag=NotInstalled);
				}
			}
			RunInstallAction(cgfVar_RunOnce,RegistryEntry,Add,HKLM,Software\Microsoft\Windows\CurrentVersion\RunOnce,%OEM% %ModelName%,STR,!cgfVar_InstCall);
		} else
		{
			if CheckVariable(cgfvar_App4R_NotInstall,eq,false)
			{
				if CheckVariable(cgfVar_InstallPath,eq,2ndcopy)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x86\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local);
				} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x86\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local);
				} else
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x86\instgui.exe /M /L:%IS_LANG% /R:bewTasks);
				}
			} else 
			{
				if CheckVariable(cgfVar_InstallPath,eq,2ndcopy)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x86\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local App4RFlag=NotInstalled);
				} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x86\instgui.exe /M /L:%IS_LANG% /R:bewTasks InstallPath=Local App4RFlag=NotInstalled);
				} else
				{
					SetVariable(cgfVar_InstCall,$CD_ROOT_DIR$\Install\x86\instgui.exe /M /L:%IS_LANG% /R:bewTasks App4RFlag=NotInstalled);
				}
			}
			RunInstallAction(cgfVar_RunOnce,RegistryEntry,Add,HKLM,Software\Microsoft\Windows\CurrentVersion\RunOnce,%OEM% %ModelName%,STR,!cgfVar_InstCall);
		}
		SetVariable(cgfVar_PostInstallPath,InstallComplete);
		RunSection(CheckForceUninstall);
		RunSection(PostInstallSetup);
	} else
	{
		if CheckVariable(cgfvar_App4R_NotInstall,eq,false)
		{
			if CheckVariable(cgfVar_InstallPath,eq,2ndcopy)
			{
				SetVariable(cgfVar_InstParm,/M /L:%IS_LANG% /R:bewTasks InstallPath=Local);
			} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
			{
				SetVariable(cgfVar_InstParm,/M /L:%IS_LANG% /R:bewTasks InstallPath=Local);
			} else
			{
				SetVariable(cgfVar_InstParm,/M /L:%IS_LANG% /R:bewTasks);
			}
		} else
		{
			if CheckVariable(cgfVar_InstallPath,eq,2ndcopy)
			{
				SetVariable(cgfVar_InstParm,/M /L:%IS_LANG% /R:bewTasks InstallPath=Local App4RFlag=NotInstalled);
			} else if CheckVariable(cgfVar_InstallPath,eq,firstInstall)
			{
				SetVariable(cgfVar_InstParm,/M /L:%IS_LANG% /R:bewTasks InstallPath=Local App4RFlag=NotInstalled);
			} else
			{
				SetVariable(cgfVar_InstParm,/M /L:%IS_LANG% /R:bewTasks App4RFlag=NotInstalled);
			}
		}
		SetVariable(cgfVar_PostInstallPath,StartBEW);
		RunSection(CheckForceUninstall);
		RunSection(PostInstallSetup);
	}
} else
{
	# If parser gets in here, we assume driver update is done.
	# Check on [InstallationComplete.Init] for details on what
	# message is displayed on InstallationComplete dialog.
	SetVariable(cgfVar_PostInstallPath,InstallComplete);
	RunSection(CheckForceUninstall);
	RunSection(PostInstallSetup);
}

# Remove help file...
if CheckVariable(cgfVar_CurrentWindow,eq,Install)
{
       	if CheckVariable(cgfVar_CopyHelp,eq,true)
        {
		RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\%MODELCODE%help.chm);
        }
}


[CheckForceUninstall]
#If user cancelled out the install during driver file copy, then at the end invoke the uninstaller.
if RegExists(HKLM,%CustomInstallKey%\%ModelCode%,CancelInstall,cgfVar_CancelInstall)
{
}
if CheckVariable(cgfVar_CancelInstall,eq,1)
{
	SetVariable(cgfVar_ForceCancelInstall,true);
} else
{
	SetVariable(cgfVar_ForceCancelInstall,false);
}

[VerifyUnicode]
if CheckVariable(cgfVar_VerifyUnicode,eq,true)
{	
	if RegExists(HKLM,%CustomInstallKey%\%ModelCode%,ValidateUnicodeString,cgfVar_PtrNameValue)
	{		
		SetValue(EB_ComputerName,!cgfVar_PtrNameValue);
	}		
} else
{
	Break();
}


[VerifyComputerName]
if CheckOS(9x)
{
       FormatString($CD_ROOT_DIR$\Drivers\OS\%LANG%\%MODELCODE%grd.dl*,OS,Win_9X,GrdFile);
       FormatString($CD_ROOT_DIR$\common\OS\%MODELCODE%inst.dll,OS,x86,InstFile);
} else
{ 
       if CheckOS(x64)
       {
		FormatString($CD_ROOT_DIR$\Drivers\Win_XP2K\OS\%LANG%\%MODELCODE%grd.dl*,OS,x64,GrdFile);
       		FormatString($CD_ROOT_DIR$\common\OS\%MODELCODE%inst.dll,OS,x64,InstFile);
       } else 
       {
		FormatString($CD_ROOT_DIR$\Drivers\Win_XP2K\OS\%LANG%\%MODELCODE%grd.dl*,OS,i386,GrdFile);
 		FormatString($CD_ROOT_DIR$\common\OS\%MODELCODE%inst.dll,OS,x86,InstFile);
       }
	
}
RunInstallAction(cgfVar_CopyGrd,File,Copy,!GrdFile,$TEMP_DIR$\%MODELCODE%\);
RunInstallAction(cgfVar_CopyInst,File,Copy,!InstFile,$TEMP_DIR$\%MODELCODE%\);
FormatStringEx(<PORTNAME>%s</PORTNAME>,!cgfVar_SelectedPort,cgfVar_FormattedPort);
RunInstallAction(cgfVar_VerifyUnicode,RunLibFunction,!cgfVar_NetSuppDLL,ValidateUnicodeString,$TEMP_DIR$\%MODELCODE%\%MODELCODE%grd.dll|#EB_ComputerName|!cgfVar_FormattedPort|%CustomInstallKey%\%ModelCode%);
RunSection(VerifyUnicode);
RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\%MODELCODE%grd.dll);
RunInstallAction(cgfVar_RemoveFile,File,Delete,$TEMP_DIR$\%MODELCODE%\%MODELCODE%inst.dll);

[VerifyComputerNameAgain]
if CheckValue(EB_ComputerName,eq,empty)
{
	SetVariable(cgfVar_HostNameValid,false);

} else if CheckLength(EB_ComputerName,gt,14)
{
	SetVariable(cgfVar_HostNameValid,false);
} else
{
	SetVariable(cgfVar_HostNameValid,true);
}

[VerifyComputerNameOnScanner3]
if CheckVariable(cgfVar_PtrNameValue,eq,52)
{	
	ShowMessage(%NetworkAIO.Error_ComputerNameInUse%,%NetConfiguration.Title%,error);
	SetFocus(EB_ComputerName);
	SetVariable(cgfVar_HostNameValid,false);	
}
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,%CustomInstallKey%\%ModelCode%,SetScannerRegisterInfo);


[VerifyComputerNameOnScanner2]
if CheckVariable(cgfVar_SetScannerRegisterInfo,eq,false)
{
	if RegExists(HKLM,%CustomInstallKey%\%ModelCode%,SetScannerRegisterInfo,cgfVar_PtrNameValue)
	{			
		RunSection(VerifyComputerNameOnScanner3);
	}	
}

[VerifyComputerNameOnScanner]
RunInstallAction(cgfVar_RegActionReturn,RegistryEntry,Delete,HKLM,%CustomInstallKey%\%ModelCode%,SetScannerRegisterInfo);
if CheckValue(CB_WishPin,eq,true)
{	
	RunInstallAction(cgfVar_SetScannerRegisterInfo,RunLibFunction,!cgfVar_NetSuppDLL,SetScannerRegisterInfo,!cgfVar_SelectedPort|#EB_ComputerName|$CODEPAGE$|%CustomInstallKey%\%ModelCode%|#EB_Pin);	
} else
{	
	RunInstallAction(cgfVar_SetScannerRegisterInfo,RunLibFunction,!cgfVar_NetSuppDLL,SetScannerRegisterInfo,!cgfVar_SelectedPort|#EB_ComputerName|$CODEPAGE$|%CustomInstallKey%\%ModelCode%|0000);
}
RunSection(VerifyComputerNameOnScanner2);


[VerifyHostNameAndInstall2]
if CheckVariable(cgfVar_HostNameValid,eq,true)
{
	RunSection(WriteWhatToInstall);	
	RunSection(StartInstallation);
} 

[VerifyHostNameAndInstall]
RunSection(VerifyComputerName);
RunSection(VerifyComputerNameAgain);
RunSection(VerifyComputerNameOnScanner);
RunSection(VerifyHostNameAndInstall2);

[VerifyHostNameAndLanguageGrid2]
if CheckVariable(cgfVar_HostNameValid,eq,true)
{
	ChangeWindow(LanguageMismatch,mainSplitter.top);	
} 

[VerifyHostNameAndLanguageGrid]
RunSection(VerifyComputerName);
RunSection(VerifyComputerNameAgain);
RunSection(VerifyComputerNameOnScanner);
RunSection(VerifyHostNameAndLanguageGrid2);

[WindowsUpdate]
if CheckVariable(cgfVar_WUInstallValue,eq,1)
{
	ExitApp(noPrompt);
	if CheckOS(x64)
	{
		RunProgram($CD_ROOT_DIR$\install\x64\instgui.exe,NOWAIT,/M /d /I:..\appinst.isf /R:appinst);
	} else
	{
		RunProgram($CD_ROOT_DIR$\install\x86\instgui.exe,NOWAIT,/M /d /I:..\appinst.isf /R:appinst);
	}	
}


[SetDefaultComputerName]
if CheckLength(EB_ComputerName,gt,14)
{
	SetVariable(cgfVar_ComputerName,#EB_ComputerName);
	FormatStringEx(%.14s,!cgfVar_ComputerName,cgfVar_ComputerName);
	SetValue(EB_ComputerName,!cgfVar_ComputerName);
}

[PostInstallSetup]
if CheckVariable(cgfVar_ForceCancelInstall,eq,true)
{
	RunInstallAction(cgfVar_RunOnce,RegistryEntry,Delete,HKLM,Software\Microsoft\Windows\CurrentVersion\RunOnce,%OEM% %ModelName%);
	ExitApp(noPrompt);
	if CheckOS(x64)
	{
		RunProgram($CD_ROOT_DIR$\Install\x64\uninst.exe,NoWait,/M /R:Uninst SkipConfirm=true);
	} else
	{
		RunProgram($CD_ROOT_DIR$\Install\x86\uninst.exe,NoWait,/M /R:Uninst SkipConfirm=true);
	}
} else
{
	if CheckVariable(cgfVar_PostInstallPath,eq,StartBEW)
	{
		ExitApp(noPrompt);
		if CheckOS(x64)
		{
			RunProgram($CD_ROOT_DIR$\Install\x64\instgui.exe,NOWAIT,!cgfVar_InstParm);
		} else
		{
			RunProgram($CD_ROOT_DIR$\Install\x86\instgui.exe,NOWAIT,!cgfVar_InstParm);
		}
	} else
	{
		ShowMainFrame();
		ChangeWindow(InstallationComplete,mainSplitter.top);
	}
}

[CheckForFirewallApps]
if CheckVariable(cgfVar_IsNull,eq,:0:FWAppsList)
{
	if CheckLength(FWAppsList,gt,0)
	{
		SetValue(FirewallExText,%FirewallExceptions.NewText%);
		TimerCheck(Stop,cgfvar_FWListDelay);
	}
}

[CheckOSRequirement]
if CheckOS(x64)
{
} else if CheckOS(XP)
{
	if CheckOS(XPSP2)
	{
		SetVariable(cgfVar_OSRequireRunOnce,false);
	} else
	{
		if RegExists(HKLM,Software\Microsoft\Updates\Windows XP\SP3\KB893803v2,PackageName,cgfVar_WindowsInstaller31)
		{	
		} else
		{
			RunProgram($CD_ROOT_DIR$\Applications\App4r\tools\WindowsInstaller-KB893803-v2-x86.exe,NOWAIT,/quiet /norestart);
		}
		
		#ChangeWindow(OSRequirements,mainSplitter.top,capture);
		SetVariable(cgfVar_OSRequireRunOnce,false);
		#Break();
	}
} else if CheckOS(2k)
{
	if CheckOS(2kSP4|2kSP3)
	{
		if RegExists(HKLM,Software\Microsoft\Updates\Windows 2000\SP5\KB893803v2,PackageName,cgfVar_WindowsInstaller31)
		{	
		} else
		{
			RunProgram($CD_ROOT_DIR$\Applications\App4r\tools\WindowsInstaller-KB893803-v2-x86.exe,NOWAIT,/quiet /norestart);
		}
		SetVariable(cgfVar_OSRequireRunOnce,false);
	} else
	{
		SetVariable(cgfvar_App4R_NotInstall,true);
		SetVariable(cgfVar_OSRequireRunOnce,false);
	}
} else
{
}

[CDFEMenuOptions]
if CheckVariable(cgfVar_MenuOption,eq,VIEW_LICENSE)
{
	PopupWindow(LicenseEx);

} else if CheckVariable(cgfVar_MenuOption,eq,USER_GUIDE)
{
	RunSection(CDFE.UserGuide.ButtonClick);
} else if CheckVariable(cgfVar_MenuOption,eq,CHANGE_LANGUAGE)
{
	PopupWindow(LangPicker);

} else if CheckVariable(cgfVar_MenuOption,eq,UNINSTALL_DRIVER)
{
	if CheckVariable(cgfVar_ShowAltLangPicker,eq,true)
	{
		PopupWindow(AltLangPicker);
	} else
	{
		if CheckOS(9X)
		{
			ExitApp(noPrompt);
			if CheckVariable(MediaType,eq,BBS)
			{
				RunProgram($CD_ROOT_DIR$\Drivers\Win_9X\%LANG%\%MODELCODE%un9x.exe,NOWAIT,-d ReturnCDFE=true MediaType=BBS);
			} else
			{
				RunProgram($CD_ROOT_DIR$\Drivers\Win_9X\%LANG%\%MODELCODE%un9x.exe,NOWAIT,-d ReturnCDFE=true);
			}

		} else if CheckOS(2K_VISTA)
		{
			ExitApp(noPrompt);
			if CheckVariable(MediaType,eq,BBS)
			{
				if CheckOS(x64)
				{
					RunProgram($CD_ROOT_DIR$\Install\x64\uninst.exe,NOWAIT,/L:%IS_LANG% /R:Uninst ReturnCDFE=true MediaType=BBS);
				} else
				{
					RunProgram($CD_ROOT_DIR$\Install\x86\uninst.exe,NOWAIT,/L:%IS_LANG% /R:Uninst ReturnCDFE=true MediaType=BBS);
				}
			} else
			{
				if CheckOS(x64)
				{
					RunProgram($CD_ROOT_DIR$\Install\x64\uninst.exe,NOWAIT,/L:%IS_LANG% /R:Uninst ReturnCDFE=true);
				} else
				{
					RunProgram($CD_ROOT_DIR$\Install\x86\uninst.exe,NOWAIT,/L:%IS_LANG% /R:Uninst ReturnCDFE=true);
				}
			}
		}
	}
} else if CheckVariable(cgfVar_MenuOption,eq,FAX_INSTALL)
{
	RunProgram($CD_ROOT_DIR$\fax\setup.exe /L%IS_LANG%);

} else if CheckVariable(cgfVar_MenuOption,eq,SYS_INFO)
{
	RunProgram($CD_ROOT_DIR$\Tools\diagnostics\%LANG%\sysinfo.exe,NOWAIT);

} else if CheckVariable(cgfVar_MenuOption,eq,TECH_SUPPORT)
{
	RunShell(!WebTechSupport);

} else if CheckVariable(cgfVar_MenuOption,eq,INST_WEBTOOLBAR)
{
	RunShell(!WebToolbar);
	
} else if CheckVariable(cgfVar_MenuOption,eq,WEB_HOMEPAGE)
{
	RunShell(!WebHomePage);

} else if CheckVariable(cgfVar_MenuOption,eq,WEB_SUPPLIES)
{
	RunShell(!WebSuppliesPage);

} else if CheckVariable(cgfVar_MenuOption,eq,WEB_REGISTER)
{
	RunShell(!WebRegistration); 

} else if CheckVariable(cgfVar_MenuOption,eq,WEB_TECHSUPP)
{
	RunShell(!WebSupportPage);
}

[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.WebTechSupport%,OCODE,!cgfVar_OS,WebTechSupport);
	FormatString(!WebTechSupport,LCODE,!cgfVar_LanguageCode,WebTechSupport);
	FormatString(!WebTechSupport,CCODE,!cgfVar_RegistryLocale,WebTechSupport);

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

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

	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.WebSupportPage%,OCODE,!cgfVar_OS,WebSupportPage);
	FormatString(!WebSupportPage,LCODE,!cgfVar_LanguageCode,WebSupportPage);
	FormatString(!WebSupportPage,CCODE,!cgfVar_RegistryLocale,WebSupportPage);

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

	FormatString(%CDFE_MENU_URLS.WebToolbar%,LCODE,!cgfVar_LanguageCode,WebToolbar);
	FormatString(!WebToolbar,CCODE,!cgfVar_RegistryLocale,WebToolbar);
} else
{
	SetVariable(WebTechSupport,%CDFE_MENU_URLS.WebTechSupport%);
	SetVariable(WebHomePage,%CDFE_MENU_URLS.WebHomePage%);
	SetVariable(WebSuppliesPage,%CDFE_MENU_URLS.WebSuppliesPage%);
	SetVariable(WebRegistration,%CDFE_MENU_URLS.WebRegistration%);
	SetVariable(WebSupportPage,%CDFE_MENU_URLS.WebSupportPage%);
	SetVariable(WebOffer,%CDFE_MENU_URLS.WebOffer%);
	SetVariable(WebToolbar,%CDFE_MENU_URLS.WebToolbar%);
}

[CheckRPSupport]
if IniSectionKeyExists(!cgfVar_RPSupportINI,Skin,RPSupport,cgfvar_RPSupportValue)
{
	RunSection(CheckRPSupportValue);
}

[CheckRPSupportValue]
if CheckVariable(cgfvar_RPSupportValue,eq,0)
{
	SetValue(LicenseText,|%ModelCode%eul2.txt);
} else
{
	SetValue(LicenseText,|%ModelCode%eula.txt);
}
