Silverlight.InstallAndCreateSilverlight = function(version, SilverlightDiv, installExperienceHTML, installPromptDivID, createSilverlightDelegate) {

    var RetryTimeout=3000;	              //The interval at which Silverlight instantiation is attempted(ms)	

    if ( Silverlight.isInstalled(version) ) {
    
		miniclipTrack = new Image();
  		miniclipTrack.src = 'http://ads.miniclip.com/RealMedia/ads/adstream_sx.ads/miniclip.com/zombomatic/134344@x01';
    
		createSilverlightDelegate();
		
    } else {
    
    	var links = Silverlight.GetLinks();
    
		if ( installExperienceHTML && SilverlightDiv ) {
		
		    SilverlightDiv.innerHTML=installExperienceHTML;
		    document.body.innerHTML;
		    
		}
		
        if ( installPromptDivID ) {
        
	    	var installPromptDiv = $(installPromptDivID);
			//installPromptDiv.innerHTML = "<a style=\"background-image:url( ../images/button.jpg );\" id=\"SilverlightDownload\" href='" + links.DirectDownload + "'>Download Microsoft Silverlight Plugin</a><br />";
			installPromptDiv.innerHTML = "<a style=\"background-image:url( ../images/button.jpg );\" id=\"SilverlightDownload\" href='#' onclick='javascript:Silverlight.followFWLink(\"" + links.DirectDownload + "\");'>Download Microsoft Silverlight Plugin</a><br />";
			installPromptDiv.innerHTML += "By clicking <strong>\"Play\"</strong> you accept the <a target='_blank' href='" + links.EULA + "'>Silverlight License Agreement</a><br />";
			installPromptDiv.innerHTML += "Microsoft Silverlight updates automatically, <a target='_blank' href='" + links.Privacy + "'>learn more</a>";
			
			sltInstallPromptLoad();
        }
        
		if ( ! (Silverlight.available || Silverlight.ua.Browser != 'MSIE' ) ) {
		
			// refresh checking for plugin (for IE)
		    TimeoutDelegate = function() { Silverlight.InstallAndCreateSilverlight(version, null, null, null, createSilverlightDelegate); }
		    setTimeout(TimeoutDelegate, RetryTimeout);
		    
		}
		
	}
	
}

//Create our install experience html
var installExperienceHTML =  '<div style="text-align:center; background:url( ../images/background.jpg ) no-repeat; width: 590px; height:433px;">'; 
    installExperienceHTML += '<div id="InstallPromptDiv"></div>';
	installExperienceHTML += '<div id="PostInstallGuidance"></div>';
    installExperienceHTML += '</div>';

//calls installandcreatesilverlight method to instantiate silverlight once it is installed
Silverlight.InstallAndCreateSilverlight('1.0.20816.0', 
	$( 'SilverlightControlHost' ), 
	installExperienceHTML,
	'InstallPromptDiv',
	createSilverlight );

//place text below the install medallion to inform the users what to do after installation
var PostInstallGuidance = $('PostInstallGuidance');

if ( PostInstallGuidance ) {

    if ( Silverlight.ua.Browser == "MSIE" ) {
    
	    if ( Silverlight.available ) {
            PostInstallGuidance.innerHTML="When installation is complete, restart your browser to activate your Silverlight content.";
	    } else {
            PostInstallGuidance.innerHTML= "";
        }
    
	} else if ( Silverlight.ua.Browser == "Firefox" || Silverlight.ua.Browser == "Safari") {
    
	    PostInstallGuidance.innerHTML="When installation is complete,<br />restart the browser to play the game";
    
	} else {
    
	    PostInstallGuidance.innerHTML="Your browser may not be supported by Microsoft Silverlight.<br />Please visit http://www.microsoft.com/silverlight/system-requirements.aspx for more information.";
    
	}
    
}
