﻿        	    
        function setSilverlight(data, param, controlId, divname, requested) {

            data = data.replace('[path]', '/remix/ClientBin/BestBuyRemix.xap');
            data = data.replace('//', '/');
            data = data.replace('[config]', 'SiteMap=MENU');

            $('#' + divname).html(data);//don't want to see it until it shows it's self.

        }

        function setProductSilverlight(data, param, controlId, divname, requested) {

            data = data.replace('[path]', '/remix/ClientBin/BestBuyRemix.xap');
            data = data.replace('//', '/');
            data = data.replace('[config]', 'ControlId=' + controlId + ',requested=' + requested);

            $('#' + divname).html(data); //don't want to see it until it shows it's self.

        } 
        function pageload(hash) {
            // hash doesn't contain the first # character.
            if(hash) {
                // restore ajax loaded state
                $("#load").load(hash + ".html");
            } else {
                // start page
                $("#load").empty();
            }
        }

        $(document).ready(function() {
           
            //fetch the silverlight menu and plug it in, it's controlid #1
            $.get('/remix/js/htmlSLControls/sl.htm', function(data) {
                setSilverlight(data, 'ControlId', 1, 'sl-categoryNavigation');
            })
            $('#categoryNavigation').fadeOut("slow");

            // Initialize history plugin.
            // The callback is called at once by present location.hash. 
            $.historyInit(pageload);

        });
         
         
		        // set onlick event for buttons
        function silverlightHistory(detailsurl) {
            return;
			        // 
			        var hash = detailsurl;
			        hash = hash.replace(/^.*#/, '');
			        // moves to a new page. 
			        // pageload is called at once. 
			        $.historyLoad(hash);
			        return false;
		        }
         
         
        


 function showHtmlMenu() {

		            $('#sl-categoryNavigation').fadeOut("slow");
		            $('#categoryNavigation').fadeIn("slow");

		        }

 function showSlMenu()
         {
            $('#categoryNavigation').fadeOut("slow");
            $('#sl-categoryNavigation').fadeIn("slow");

         }
 function showProduct() {
     
            $('#sl-productListDisplay').fadeIn("slow");
         }
         function setProductDetails(detailsurl) {
             //setup for browser history
             silverlightHistory(detailsurl);
            /////////// $('#sl-productListDisplay').fadeOut("slow").html(" ");
             //fetch the silverlight product details and plug it in, it's controlid #2
             $.get('/remix/js/htmlSLControls/sl.htm', function(data) {
                 setProductSilverlight(data, 'ControlId', 2, 'sl-productListDisplay', detailsurl);
             })
         }
      
