// this is the object that control the switching of the video and text for each product
var ContentSwitcher = {
    showProduct: function(productName) {
        this.CurrentProduct = Office14Data.products[productName];

        $("h3.productTitle").html(this.CurrentProduct.title);
        $("p.productDescription").html(this.CurrentProduct.description);

        var videoPlayerElement = document.getElementById('videoPlayer');
        var productThumbnailElement = document.getElementById("productThumbnail");

        // if the uuid for the product is not defined then the product does not hae a video
        if (this.CurrentProduct.uuid != undefined) {
            // for the silverlight the uuid is used to play the video
            var initParams = "ImageSource=" + this.CurrentProduct.ImageSource + ",Culture=en,Uuid=" + this.CurrentProduct.uuid + ",Autoplay=False,ShowMenu=False,Tabs=Embed;Email;Share;Info,ShowRelatedVideos=False,ShowMarketingOverlay=False,MarketingOverlayStartTime=10;MarketingOverlayUrl=http://www.microsoft.com/office/2010,MiscControls=FullScreen;Detached,AutoPlay=False,VideoUrl=http://www.microsoft.com/showcase/silverlight/player/1/?culture=en-US"

            // The entire contents of the videoPlayer div is replaced to reload the silverlight with a different video.
            // The markup includes the image tag that is used for products that dont have a video.
            var playerHtml = '<div id="SilverLightMovie"><object id="SilverlightPlugin" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="384" height="291">';
            var playerHtml = playerHtml + '<param name="source" value="http://www.microsoft.com/showcase/silverlight/player/1/player.xap"/>';
            var playerHtml = playerHtml + '<param name="enableHtmlAccess" value="true"/>';
            var playerHtml = playerHtml + '<param name="background" value="#FFFFFFFF"/>';
            var playerHtml = playerHtml + '<param name="minRuntimeVersion" value="2.0.31005.0"/>';
            var playerHtml = playerHtml + '<param name="autoUpgrade" value="true"/>';
            var playerHtml = playerHtml + '<param name="initParams" value="' + initParams + '"/>';
            var playerHtml = playerHtml + '<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">';
            var playerHtml = playerHtml + '<img src="http://img.microsoft.com/video/Content/img/resx/en-us/installSL.gif" alt="Get Microsoft Silverlight" style="border-style: none"/>';
            var playerHtml = playerHtml + '</a>';
            var playerHtml = playerHtml + '<noscript><div><img alt="DCSIMG" id="DCSIMG" width="1" height="1" src="http://m.webtrends.com/ dcsygm2gb10000kf9xm7kfvub_9p1t/njs.gif?dcsuri=/nojavascript&amp;WT.js=No"/></div></noscript>';
            var playerHtml = playerHtml + '</object></div>';
            var playerHtml = playerHtml + '<a id="productThumbnail" href="" style="display:none">';
            var playerHtml = playerHtml + '<img height="291" width="405" alt="" src=""/>';
            var playerHtml = playerHtml + '</a>';

            videoPlayerElement.innerHTML = playerHtml;

            $("ul.shareVideoLinks").show()
        } else {
            var silverLightMovieDiv = document.getElementById("SilverLightMovie");
            if (silverLightMovieDiv != null) {
                silverLightMovieDiv.style.display = 'none';
                silverLightMovieDiv.innerHTML = '';
            }

            $("#productThumbnail img").attr({
                src: this.CurrentProduct.thumbnailLocation,
                alt: this.CurrentProduct.callToAction
            });
            $("#productThumbnail").attr({
                href: this.CurrentProduct.imageLocation,
                alt: this.CurrentProduct.callToAction
            }).css("display", "block").lightBox();

            $("ul.shareVideoLinks").hide();
        }

    },
    CurrentProduct: null
}