﻿
  // PAGES
        function showDisplayPage(pageNumber) {
                $( "[id^=displaypage]" ).hide();
                $("#displaypage" + pageNumber).show();
                removeMagnifier(); 
        };

        function pageHome() {
            showDisplayPage(99);
            //pause(4000);
            //$("#displaypage1").load("Content/Pages/DisplayProductSelector.aspx", { 'root': 'Nothing', 'preset': 'Homepage' }, function () { testingPause(); showDisplayPage(1); });
            $("#displaypage1").load("Content/Widgets/widgetProductSelector.aspx", { 'root': 'Nothing', 'preset': 'Homepage' }, function () { testingPause(); showDisplayPage(1); });
        };

        function pageBasket() {
            showDisplayPage(99);
            $("#result_displaypage5").load("Content/Widgets/widgetBasket.aspx", { "displayText": "Basket And Checkout" }, function () { });
        };


        function pageCountry() {
            showDisplayPage(99);
            $("#displaypage1").load("Content/Pages/CountryRegion.aspx", function () { showDisplayPage(1); });
        };

        function pageHelp() {
            showDisplayPage(99);
            $("#displaypage1").load("Content/Pages/Blank.aspx", { "displayText": "System Help - FAQs and Live Chat" }, function () { showDisplayPage(1); });
        };

        function pageAccount() {
                  showDisplayPage(99);
                  $("#displaypage1").load("Content/Widgets/widgetUserAccount.aspx", { "displayText": "Account" }, function () { showDisplayPage(1); });
        };

        function pageLogIn() {
            showDisplayPage(99);
            $("#displaypage1").load("Content/Pages/LogOn.aspx", { "destination": "Account" }, function () {  });
                showDisplayPage(1);
        };

        function pageSystemSearchHistory() {
            showDisplayPage(99);
            $("#displaypage1").load("Content/Pages/SystemSearchHistory.aspx", { "noCache": getUniqueID() }, function () { showDisplayPage(1); });
        };

        function pageSessionSearchHistory() {
            showDisplayPage(99);
            $("#displaypage1").load("Content/Pages/SessionSearchHistory.aspx", { "noCache": getUniqueID() }, function () { showDisplayPage(1); });
        };

        function pagePreviouslyViewed() {
            showDisplayPage(99);
            $("#displaypage1").load("Content/Widgets/widgetProductSelector.aspx", { 'root': 'Nothing', 'preset': 'PreviouslyViewed' }, function () { showDisplayPage(1); });
        };


        function pageInformationLink(suppliedRoot,informationLink) {
                  showDisplayPage(99);
                  $("#result_displaypage2").load("Content/Widgets/widgetInformationViewer.aspx", { "root": suppliedRoot, "informationLink": informationLink }, function () { showDisplayPage(2); });
        };


        // ==============================================================================================================================
        // SITE RESET
        // ==============================================================================================================================

        function siteReset() {
                  siteResetCountry('XYZ');
                  pageBasket();
                  pageHome();
        };

        function siteResetCountry(GUID) {
                  $("#Inv_AddressCountryCode_" + GUID).val($('#siteCountryCode').val());
                  $("#Inv_AddressCountry_" + GUID).val($('#siteCountry').val());
                  $("#Del_AddressCountryCode_" + GUID).val($('#siteCountryCode').val());
                  $("#Del_AddressCountry_" + GUID).val($('#siteCountry').val());
        };



  // PROCESS SITE SEARCH =====================================================================================================
        function processSiteSearch(Preset) {
                  if (validateProcessSiteSearch()) {
                        if (Preset == null) { Preset = "GlobalSearch" };
                        var SearchText = "";
                        try { SearchText = $("#siteSearchText").val();} catch (e) { };
                        switch(SearchText) {
                            case "=coannltd": 
                                         showDisplayPage(99);
                                       $( "#result_displaypage2" ).load("Content/Pages/ContentManager.aspx", function () { showDisplayPage(2); });
                                       showDisplayPage(2);
                                       break;
                           case "newrequest": 


                                    break;
                                default:
                                    //Build search page
                                    showDisplayPage(99);
                                    $("#displaypage1").load("Content/Widgets/widgetProductSelector.aspx", { 'root': 'Nothing', 'preset': Preset, 'globalSearchText': SearchText }, function () { showDisplayPage(1); });
                                    //Record the search
                                    ws_2g_Core.WSRecordSiteSearch(SearchText,
                                    NoAction_SucceededCallback, TimeoutCallback, FailedCallback);
                                   
                        }; 
                     
                };
         };

// PROCESS NO ACTION SUCCEEDED
        function NoAction_SucceededCallback(result) {
                if (result.Success == false) {
                } else {
                };
        };
        
// VALIDATE PROCESS SITE SEARCH
            function validateProcessSiteSearch() {
                    //Set initial conditions
                   var returnvalue = true;
                    
                    //Form Fields
                    var SearchText = $("#siteSearchText");

                    //Validate Form Fields
                    if (checkLength(SearchText,2,10000)) {
                    } else {
                            returnvalue = false;
                    };
                    
                     return returnvalue;
                     
            };
