﻿var lastDetectedVersion = null;

pageLoad = function()
{
    if ((typeof(window.setTimeout) != "undefined") && (window.setTimeout != null))
    {
        window.setTimeout("testVersionInfo()", 1000);
    }    
}

testVersionInfo = function()
{
    var detectedVersion = detectAgControlVersion();
    if (lastDetectedVersion != detectedVersion)
    {
        lastDetectedVersion = detectedVersion;
        forceServerUpdate(detectedVersion);
    }
    lastDetectedVersion = detectedVersion;
    window.setTimeout("testVersionInfo()", 5000);
}

forceServerUpdate = function(version)
{
    var detectedVersionHiddenField = document.getElementById("ctl00_MainContent_DetectedVersionHiddenField");
    if (detectedVersionHiddenField != null)
    {
        detectedVersionHiddenField.value = version;
        __doPostBack("ctl00_MainContent_DetectedVersionHiddenField","");
    }
}

notifyThatUninstallOf11IsNeeded = function()
{
    alert(window.GlobalResources.mustUninstall);
    return false;
}

initLicenseDev = function(ver)
{
    if ((typeof(window.GlobalResources) != 'undefined') && (window.GlobalResources != null) &&
        (typeof(window.GlobalResources.mustUninstall) != 'undefined') && (window.GlobalResources.mustUninstall != null) &&
        (typeof(window.Silverlight) != 'undefined') && (window.Silverlight != null) &&
        (typeof(window.Silverlight.isInstalled) != 'undefined') && (window.Silverlight.isInstalled != null) &&
        window.Silverlight.isInstalled('1.0') &&
        !window.Silverlight.isInstalled(ver))
    {
        notifyThatUninstallOf11IsNeeded();

        try
        {
            var acceptLink = document.getElementById('acceptLink');
            if (acceptLink != null)
            {
                acceptLink.href = 'javascript:void(0);';
                acceptLink.style.color = '#374A58';
                if (window.addEventListener)
                {
                    acceptLink.addEventListener('onclick', notifyThatUninstallOf11IsNeeded, false);
                    acceptLink.addEventListener('onkeypress', notifyThatUninstallOf11IsNeeded, false);
                }
                else if (window.attachEvent)
                {
                    acceptLink.attachEvent('onclick', notifyThatUninstallOf11IsNeeded);
                    acceptLink.attachEvent('onkeypress', notifyThatUninstallOf11IsNeeded);
                }
                else
                {
                    acceptLink.onload = notifyThatUninstallOf11IsNeeded;
                    acceptLink.onkeypress = notifyThatUninstallOf11IsNeeded;
                }
            }
        }
        catch (e)
        {
        }
    }
}
