﻿var timeoutID = null;

function TrackSilverlightVersion()
{
    ///<summary>Track the Silverlight version.
    /// If Silverlight is not installed
    ///</summary>
    
    if (Silverlight.isInstalled("2.0"))
    {
        TrackEvent("SLInstalled/20");
    }
    else if (Silverlight.isInstalled("1.1"))
    {
        TrackEvent("SLInstalled/11");
    }
    else if (Silverlight.isInstalled("1.0"))
    {
        TrackEvent("SLInstalled/10");
    }
    else
    {   
        TrackEvent("SLInstalled/Not");
        
        timeoutID = setTimeout(IsSL10Installed, 5000);
    }
}

function IsSL10Installed()
{
    clearTimeout(timeoutID);
    
    if (Silverlight.isInstalled("1.0"))
    {
        TrackEvent("SLInstalled/NewInstall");
        TrackEvent("SLInstalled/10");
        
        createSilverlight();
    }
    else
    {
        timeoutID = setTimeout(IsSL10Installed, 5000);
    }
}

function TrackEvent(eventName)
{
    ///<summary>Track a RIA event using Microsoft Analytics (Gatineau)</summary>
    ///<param name="eventName" type="String">the name of the event</param>
    
    var url = document.URL + "/" + eventName;
    
    try
    {
        //Override page view tracking guard to prevent multiple calls to TrackPage
        msAnalytics.PageViewRegistered = false; 
        
        msAnalytics.TargetPage = url;
        
        msAnalytics.TrackPage();
    }
    catch(error)
    {
    }
}
