///////////////////////////////////////////////////////////////////////////////
//
//  installcreatesilverlight.js   			version 1.0
//
//  This file is provided by Microsoft as a helper file for websites that
//  incorporate Silverlight Objects. This file is provided under the Silverlight 
//  SDK 1.0 license available at http://go.microsoft.com/fwlink/?linkid=94240.  
//  You may not use or distribute this file or the code in this file except as 
//  expressly permitted under that license.
// 
//  Copyright (c) 2007 Microsoft Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
if(!window.Silverlight)
    window.Silverlight={};

Silverlight.InstallAndCreateSilverlight = function(version, SilverlightDiv, installExperienceHTML, installPromptDivID, createSilverlightDelegate)
{
    $('#redesignPage').val("1");
    var RetryTimeout=3000;	              //The interval at which Silverlight instantiation is attempted(ms)	
    if ( Silverlight.isInstalled(version) )
    {
	createSilverlightDelegate();
    }
    else
    {
	if ( installExperienceHTML && SilverlightDiv )
	{
        var isRedesignPage = $('#redesignPage').val();
        if (isRedesignPage) {
            installExperienceHTML = installExperienceHTML.replace("style=\"padding-left:212px; padding-top:170px;\"", "");
            installExperienceHTML = installExperienceHTML.replace("height:477px;", "height:330px;");
            //installExperienceHTML = installExperienceHTML.replace("<div style=\"background: #fff; border: solid 2px #ccc; font-family:sans-serif; margin: 0 50px; padding: 20px; text-align:center; color:#3366ff; font-weight:normal; font-size:11pt\" id=\"PostInstallGuidance\">&nbsp;</div>", "");
            $('#PostInstallGuidance').css("display", "none");
            $('#PostInstallGuidance').css("height", "0px;");
        }
	    SilverlightDiv.innerHTML=installExperienceHTML;
	    document.body.innerHTML;
        
        if (isRedesignPage) {
            $('#PostInstallGuidance').css("display", "none");
            $('#PostInstallGuidance').css("height", "0px;");
            
        }
	}
        if (installPromptDivID)
        {
	    var installPromptDiv = document.getElementById(installPromptDivID);
	    if ( installPromptDiv )
		installPromptDiv.innerHTML = Silverlight.createObject(null, null, null, {version: version, inplaceInstallPrompt:false},{}, null);
        }
        
        if ( !Silverlight.available ) { $('#redesignPage').val("disabled"); }
        
        
        
	if ( ! (Silverlight.available || Silverlight.ua.Browser != 'MSIE' ) )
	{
        
	    TimeoutDelegate = function()
	    {
	        Silverlight.InstallAndCreateSilverlight(version, null, null, null, createSilverlightDelegate);
	    }
	    setTimeout(TimeoutDelegate, RetryTimeout);
	}
    }
}
