<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<installer-gui-script minSpecVersion='1'>
    <platforms>
        <Windows arch="intel"/>
    </platforms>
    <choices-outline>
        <line choice='manual'/>
    </choices-outline>
    <title>SU_TITLE</title>
    <choice id='manual' title="SU_TITLE">
        <pkg-ref id='manual' auth='Root'>.</pkg-ref>
    </choice>
    <choice id='manual' title='SU_TITLE'/>
    <choice id='manual' versStr='SU_VERS'/>
    <choices-outline ui='UIType()'>
        <line choice='su'/>
    </choices-outline>
    <choice id='su' suDisabledGroupID='iTunes' selected='!IsNewSoftware()'>
        <pkg-ref id='com.apple.swu.AppleApplicationSupport' version="2.1.9" arguments='PARENTUILVL=2' enabled='InstallAAS()'>AppleApplicationSupport.msi</pkg-ref>
        <pkg-ref id='com.apple.swu.Bonjour' version="3.0.0.10" enabled='InstallBonjour()'>Bonjour.msi</pkg-ref>
        <pkg-ref id='com.apple.swu.AppleMobileDeviceSupport' version="5.2.0.6" enabled='InstallAMDS()'>AppleMobileDeviceSupport.msi</pkg-ref>
        <pkg-ref id='com.apple.swu.SetupAdmin'>SetupAdmin.exe</pkg-ref>
        <pkg-ref id='com.apple.swu.iTunes' version="10.6.3.25" arguments='IS_ASU=1'>iTunes.msi</pkg-ref>
        <pkg-ref id='com.apple.swu.AppleSoftwareUpdate' version="2.1.3.127" enabled="InstallWASU()">AppleSoftwareUpdate.msi</pkg-ref>
    </choice>
    <choice id='su' visible='visibleCheck()'/>
    <choice id='su' title='SU_TITLE' versStr='SU_VERS'/>
    <choice id='su' description='SU_DESCRIPTION' description-mime-type='text/html'/>
    <script>

    function isEnglishCookiePresent()
    {
		var englishValue = ASURegistryQueryStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\Apple Computer, Inc.\\iTunes", "EnglishOnly");

				
        if ( !englishValue || (englishValue == "false"))
        {
          return false;
        }
				
	    return true;
    }

    function isBallotCookiePresent()
    {
		var ballotValue = ASURegistryQueryStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\Apple Computer, Inc.\\Safari\\ASUNewSoftware", "Offer");

				
        if ( !ballotValue || (ballotValue == "false"))
        {
          return false;
        }
				
	    return true;
    }

	function IsNewSoftware()
    {
      return(!productInVersionRange("iTunes", "0.0.0.0.1", "255.255.65535.65535.65535"));
    }

	function UIType() {
        if ( IsNewSoftware() ) {
            return ("NewSoftware");
        } else {
            return ("SoftwareUpdate");
        }
    }
  
	function InstallBonjour() {
        if ( productInVersionRange("Bonjour", "3.0.0.10", "255.255.65535.65535.65535") ) {
			return false;
		}
	  	return true;
	}
    
    function InstallWASU() {
        if ( productInVersionRange("Apple Software Update", "2.1.3.127", "255.255.65535.65535.65535") ) {
            return false;
        }
        return true;
    } 

	function InstallAAS() {
		if ( productInVersionRange("Apple Application Support", "2.1.9", "255.255.65535.65535.65535") ) {
			return false;
		}
		return true;
	}
	
	function InstallAMDS() {
        if ( productInVersionRange("Apple Mobile Device Support", "5.2.0.6", "255.255.65535.65535.65535") ) {
            return false;
        }
        return true;
    }

    function visibleCheck()
    { 
        // if new software and cookie present, don't offer
        if(IsNewSoftware() &amp;&amp; isBallotCookiePresent()){
            return false;
        }
        
        if (isEnglishCookiePresent()){
		    return false;
		}
        
        // If we don't have a valid ASU, or we already have iTunes 9.0.2+
        if ( productInVersionRange("iTunes", "10.6.3", "255.255.65535.65535.65535") ||
             productInVersionRange("Apple Software Update", "0.0.0.0.0", "2.1.2.999") )
        {
           return false;
        }
   
        //Check windows version 
        var windowsVersion = WindowsVersion();
        if (windowsVersion == "5.1.2600")
        {
            // Running XP, check Service Pack level.
            var spVersion = GetInstalledServicePackRegistry();

            if (spVersion != "" &amp;&amp; spVersion != "Service Pack 1")
            {
                return true;
            }
        }
        // Anything above XP
        else if (compareVersionStrings(windowsVersion, "5.1.0.0.0") == 1)
        {
            //Only show up on 32-bit OS's
            if ( !isSixtyFourBitOS() )
            {
                return true;
            }
        }

        //System doesn't meet our conditions    
        return false;
    }

		function isSixtyFourBitOS()
		{
		  if ( OSArchitecture() != 0 ) {
		    return true;
		  } else {                                                                                                                    
		    return false;
		  }
		}
    
    function GetInstalledServicePackRegistry()
    {
        var spInstalled = RegistryQueryStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CSDVersion");
        log("Installed Service Pack (Registry): " + spInstalled);
        return spInstalled;
    }
    
    function productInVersionRange(productName, minVersion, maxVersion) 
    {
        var i = 0;
        var productIndex;
        
        do
        {
            productIndex = system.ASUEnumerateProducts(i++);
				    if (!productIndex) {
				        break;
				    }
            var foundName = system.ASUGetProductInfo(productIndex,"ProductName");

            system.log("found product: " + foundName);

            if (foundName == productName) 
            {
                var foundVersion = system.ASUGetProductInfo(productIndex,"VersionString");

                system.log("version of " + foundName + " is: " + foundVersion);

                return(versionInRange(foundVersion, minVersion, maxVersion));
            }
        
        } while(productIndex);
        
        // they do not already have it, but should get it
        if(minVersion == "0.0.0.0.0") 
        {
            return true;
        }

        // otherwise, we require a minimum version
        return false;
        
    }

    function versionInRange(testVersion, minVersion, maxVersion) 
    {
        if ((-1 != compareVersionStrings(testVersion, minVersion)) &amp;&amp; (1 != compareVersionStrings(testVersion, maxVersion)))
            return true;
        else
            return false;
    }
    
    function compareVersionStrings(string1, string2) 
    {
        var parts1 = string1.split(".");
        var parts2 = string2.split(".");

        while(parts1.length &lt; parts2.length)
            parts1[parts1.length] = "0";

                while(parts2.length &lt; parts1.length)
            parts2[parts2.length] = "0";

        for( var i in parts1 ) 
        {
            var sub1 = 1*parts1[i];
            var sub2 = 1*parts2[i];

            if( sub1 != sub2 )
            {
                if( sub1 > sub2 )
                    return 1;
                else
                    return -1;
            }
        }

        return 0;
    }

    </script>
    <localization>
        <strings language="English"><![CDATA["SU_VERS" = "10.6.3";
"SU_TITLE" = "iTunes";
"SU_SERVERCOMMENT" = "For Windows systems";

"SU_DESCRIPTION"='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1138.32">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Helvetica}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
    p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    span.s1 {text-decoration: underline ; color: #0e6ce8}
  </style>
</head>
<body>
<p class="p1"><b>What\'s New in iTunes 10.6.3</b></p>
<p class="p2"><br></p>
<p class="p3">iTunes 10.6.3 addresses a number of important issues:</p>
<p class="p2"><br></p>
<p class="p3">• Addresses a problem where iTunes may become unresponsive when syncing an iPad (1st generation) that contains an iBooks textbook</p>
<p class="p3">• Fixes a problem where photos synced to a device may appear in an unexpected order</p>
<p class="p3">• Resolves an issue where iTunes may unexpectedly delete playlists created on a device</p>
<p class="p3">• Fixes issues where iTunes may unexpectedly delete apps on a device</p>
<p class="p3">• Improves overall performance and reliability</p>
<p class="p2"><br></p>
<p class="p3">For information on the security content of this update, please visit: <a href="http://support.apple.com/kb/HT1222"><span class="s1">support.apple.com/kb/HT1222</span></a></p>
</body>
</html>
';
]]></strings>
    </localization>
</installer-gui-script>