if(!window.Silverlight)
    window.Silverlight={};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}

/*
slta = new Image();
slta.src = 'http://view.atdmt.com/MRT/view/mscmxyou0230000001mrt/direct/01/';

var sltCreateObject = Silverlight.createObject;
Silverlight.createObject = function(a,b,c,d,e,f,g)
{
  if (sltCreateObject)
  {
    var html = sltCreateObject(a,b,c,d,e,f,g);

    slt1 = new Image();
    slt1.src = 'http://switch.atdmt.com/action/mrtyou_FY08HSWLP1Weighted_1';
    if (Silverlight.isInstalled("1.0"))
    {
      slt3 = new Image();
      slt3.src = 'http://switch.atdmt.com/action/mrtyou_FY08HSWLPWithSilverlightFinal_1';
    }
    else
    {
      slt2 = new Image();
      slt2.src = 'http://switch.atdmt.com/action/mrtyou_FY08HSWLPNOSilverlightWeighted_1';
    }

    return html;
  }
}
*/

Silverlight.DetectAndInstallSilverlight = function(version, SilverlightDiv, installExperienceHTML)
{
    var RetryTimeout=3000;	              //The interval at which Silverlight instantiation is attempted(ms)	
    if ( !Silverlight.isInstalled(version) )
    {
	    if ( installExperienceHTML && SilverlightDiv )
	    {
	        SilverlightDiv.innerHTML=installExperienceHTML;
	        document.body.innerHTML;
	        TimeoutDelegate = function()
	        {
	            init();
	        }
	        setTimeout(TimeoutDelegate, 0);	        
	    }
	    if ( ! (Silverlight.available || Silverlight.ua.Browser != 'MSIE' ) )
	    {
	        TimeoutDelegate = function()
	        {
	            Silverlight.DetectAndInstallSilverlight(version, null, null);
	        }
	        setTimeout(TimeoutDelegate, RetryTimeout);
	    }
    }
}

function init(){
    // defaults
    var target = '92822';
    var EULA = '93481';
    var Privacy = '93483'; 

    if (Silverlight.ua.OS=='Windows')
    {
        target = '92799';
        EULA = '92803';
        Privacy = '92805'; 
    }
    else if (Silverlight.ua.OS=='MacIntel')
    {
        target = '92808';
        EULA = '92804';
        Privacy = '92806';
    }
    else if (Silverlight.ua.OS=='MacPPC')
    {
        target = '92807';
        EULA = '92815';
        Privacy = '92816';
    }

    document.getElementById("InstallSilverlightLink").href = Silverlight.fwlinkRoot + target;

    // display the No Silverlight experience
    document.getElementById("sl_alertOverlay").style.display="block";
}
