﻿if (!window.Silverlight)
    window.Silverlight = {};


Silverlight.createDelegate = function(instance, method) {
    return function() {
        return method.apply(instance, arguments);
    }
}


Silverlight.InstallAndCreateSilverlight = function(version, SilverlightDiv, installExperienceHTMLSL, installExperienceHTMLLX, installPromptDivID, createSilverlightDelegate, onGetSilverlightHandler, onSilverlightInstalled) {

	var isLinux = false;
	var isMacPC = false;
	var installExperienceHTML = "";
	
	var installExperienceHTMLMACPC = '<div style="position:auto; text-align:left; background-repeat:no-repeat; height:477px; background-image:url(install_player.jpg);">';
	installExperienceHTMLMACPC += '<div style="padding-left:0px; padding-top:70px;">';
	installExperienceHTMLMACPC += '<center style="color:black;" ><a>Per visualizzare il contenuto video installa Microsoft Silverlight e poi torna sulla pagina.</a></center>';
	installExperienceHTMLMACPC += '<div style="padding-left:90px; padding-top:50px;">';
	installExperienceHTMLMACPC += '<div id="InstallPromptDiv"> </div> </div></div>';	

	if (window.navigator.platform.toLowerCase().search("linux") != -1) {
			isLinux = "true";
	}
		
	if (window.navigator.platform.toLowerCase().search("macppc") != -1) {
			isMacPC = "true";		
	}

	if (isMacPC) {
		installExperienceHTML = installExperienceHTMLMACPC;
    } else if (isLinux) {
		installExperienceHTML = installExperienceHTMLLX;
    } else {
        installExperienceHTML = installExperienceHTMLSL;
    }

    if (installExperienceHTML && SilverlightDiv) {
        SilverlightDiv.innerHTML = installExperienceHTML;
        document.body.innerHTML;
    }

   // if (isLinux) {
    if (isMacPC) {
        if (Silverlight.isInstalled(version)) {
            createSilverlightDelegate();
        }
        else {
            if (window.navigator.platform.toLowerCase().search("macppc") != -1) {
                var installPromptDiv = document.getElementById("InstallPromptDiv");
                installPromptDiv.innerHTML = Silverlight.createObject(null, null, null, { version: "1.0", inplaceInstallPrompt: true }, {}, null);
            }
            //            var installPromptDiv = document.getElementById(installPromptDivID);
            //            var installHandler = new Silverlight.InstallHandler(version, SilverlightDiv, installExperienceHTML, installPromptDivID, createSilverlightDelegate);

            //            if (Silverlight.onGetSilverlight != null)
            //            { }
            //            else {
            //                Silverlight.onGetSilverlight = Silverlight.createDelegate(installHandler, installHandler.onGetSilverlightHandler);
            //            }

            //            if (onSilverlightInstalled != null)
            //            { }
            //            else {
            //                Silverlight.onSilverlightInstalled = Silverlight.createDelegate(installHandler, installHandler.onSilverlightInstalledHandler);
            //            }
        }
    }


}

Silverlight.InstallAndCreateSilverlightPhotogallery = function(urlXml, divHTML) {
if (Silverlight.isInstalled("1.0")) {
    createSlideshow(divHTML, {
        width: '100%',
        height: '100%',
        slidesSource: urlXml,
        background: '#000000',
        buttonBackground: 'Black',
        buttonForeground: 'White',
        buttonBorderColor: 'White',
        buttonPlayForeground: 'LightGreen',
        captionBackground: 'Black',
        captionForeground: 'White',
        captionFontFamily: 'Verdana',
        captionFontSize: 11,
        captionFontStyle: 'Normal',
        captionFontWeight: 'Normal',
        captionOpacity: .7,
        contentBackground: 'Black',
        selectedThumbnailBorderColor: 'Yellow',
        trackerForeground: 'Silver',
        trackerFontFamily: 'Verdana',
        trackerFontSize: 11,
        trackerFontStyle: 'Normal',
        trackerFontWeight: 'Normal',
        borderRadius: 8,
        padding: 8,
        captionVisible: true,
        thumbnailsVisible: false,
        trackerVisible: false,
        buttonOptions: BUTTON_PLAYPAUSE | BUTTON_PREVNEXT | BUTTON_PREVNEXTPAGE | BUTTON_FULLSCREEN,
        autoPlay: false,/*era true*/
        slideSettings: {
            speedRatio: 1,
            theme: THEME_NONE
        }
    });

 } else {

 var installPromptDiv = document.getElementById(divHTML);
 if (window.navigator.platform.toLowerCase().search("linux") != -1) {
     var installExperienceHTMLLX = '<div style="position:auto; text-align:left; background-repeat:no-repeat; height:477px; background-image:url(install_player.jpg);">';
     installExperienceHTMLLX += '<div style="padding-left:0px; padding-top:70px;">';
     installExperienceHTMLLX += '<center style="color:black;" ><a>Per visualizzare il contenuto video installa Moonlight <a href="http://www.go-mono.com/moonlight/">da questo sito</a> e poi torna sulla pagina.</a></center>';
     installExperienceHTMLLX += '<div style="padding-left:90px; padding-top:50px;">';
     installExperienceHTMLLX += '</div></div>';
     installPromptDiv.innerHTML = installExperienceHTMLLX;
 } else {
     installPromptDiv.innerHTML = Silverlight.createObject(null, null, null, { version: "1.0", inplaceInstallPrompt: true }, {}, null);
 }



}
  
}
    
    
    




Silverlight.InstallHandler = function(version, SilverlightDiv, installExperienceHTML, installPromptDivID, createSilverlightDelegate) {
    this.createSilverlightDelegate = createSilverlightDelegate;
}

Silverlight.InstallHandler.prototype =
        {
            onGetSilverlightHandler: function() {

            },

            onSilverlightInstalledHandler: function() {
                if (Silverlight.isBrowserRestartRequired == false) {
                    this.createSilverlightDelegate();
                }
            }
        }


