
/**
 * @class WebServiceAPI_Class is intended to centralize all the webservices calls.
 * If a web service is timed out, the control is passed to js function onTimeout.
 * If an error is raised, the control is passed to js function onError.
 * @constructor
 * @see onTimeout({object} result)
 * @see onError({object} result)
 */ 
Core.WebServiceAPI_Class= function() {
    /*
     * Methods
     */

    /**
     * Used to add a product to a customer's favorite list
     * @param {string} CustomerId The customer ID GUID
     * @param {int} FavoriteProductType The type of favorite list to retrieve
     * @param {string} RetailerCode The current retailer code
     * @param {string} ProductCode The product code to add to the customer's favorite list
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.AddToFavorites=function(CustomerId, FavoriteProductType, RetailerCode, ProductCode, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) { return false; }
        try {
            //DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.FavoritesWebService.FavoriteListProductAdd(CustomerId, FavoriteProductType, RetailerCode, ProductCode,eval(OnCompleteFuncName),onError);
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }    

    /**
     * Adds rating information for the selected <i>CustomerID</i>, <i>ProductForumName</i> and <i>ProductCode</i>
     * 
     * @param {string} ProductForumName The product forum name used for this rating
     * @param {string} ProductCode The source product code used to find the associated products
     * @param {string} CustomerID String in a form of GUID representing the Customer ID
     * @param {int} RateLevel The integer rating from the customer
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.AddProductRating=function(ProductForumName, ProductCode, CustomerID, RateLevel, OnCompleteFuncName){
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.AddProductRating(ProductForumName, ProductCode, CustomerID, RateLevel,eval(OnCompleteFuncName),onError);

        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /** 
     * Checks to see if a product is a part of a customer's favorite list.
     * @param {string} CustomerId The customer ID GUID
     * @param {int} FavoriteProductType The type of favorite list to retrieve
     * @param {string} RetailerCode The current retailer code
     * @param {string} ProductCode The product code to add to the customer's favorite list
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.FavoriteListProductMembership=function(CustomerId, FavoriteProductType, RetailerCode, ProductCode, OnCompleteFuncName) {    
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.FavoritesWebService.FavoriteListProductMembership(CustomerId, FavoriteProductType, RetailerCode, ProductCode,eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;                
    }

    /**
     * This method provides a way for a customer to log into the website. This method should
     * be called using a secured page so that information is sent encrypted
     * over the wire.
     * @param {string} CustomerId The customer ID GUID
     * @param {string} Login The customer login (typically email address)
     * @param {string} Password The customer password
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.CustomerLogin=function(CustomerId, Login, Password, OnCompleteFuncName,OnLoginError) {
        if(!IsAjaxLoaded()) { return false; }
        try {
            //DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.CustomerWebService.Login(CustomerId, Login, Password,eval(OnCompleteFuncName),eval(OnLoginError));
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    
    /**
     * This method provides a way for a customer to register on the website. This method should
     * be called using a secured page so that information is sent encrypted
     * over the wire.
     * @param {string} CustomerId The customer ID GUID
     * @param {string} FirstName The customer first name
     * @param {string} LastName The customer last name
     * @param {string} Email The customer email (will be the customer's login)
     * @param {string} Password The customer password
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
     this.CustomerRegister=function(CustomerId, FirstName, LastName, Email, Password, OnCompleteFuncName){
        if(!IsAjaxLoaded()) { return false; }

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.CustomerWebService.Register(CustomerId, FirstName, LastName, Email, Password, eval(OnCompleteFuncName),onError);
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**
     * Retrieves a list of a customer's favorite products
     * @param {string} CustomerId The customer ID GUID
     * @param {int} FavoriteProductType The type of favorite list to retrieve
     * @param {string} RetailerCode The current retailer code
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetFavorites=function(CustomerId, FavoriteProductType, RetailerCode, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) { return false; }

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.FavoritesWebService.FavoriteListGet(CustomerId, FavoriteProductType, RetailerCode, eval(OnCompleteFuncName),onError);
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**
     * This method loads product information for a selected retailer
     * @param {string} RetailerCode Retailer Code
     * @param {string} ProductCode Product Code(SKU)
     * @param {bool} VariantsWanted If true, variants are also loaded with the product information
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetProductInformationByRetailer=function(RetailerCode, ProductCode, VariantsWanted, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) { return false; }

        try {
            DoWait();
           
            if (VariantsWanted) {
                MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationVariantsWantedByRetailer(RetailerCode, ProductCode, VariantsWanted,  eval(OnCompleteFuncName),onError,onTimeout);

            }
             else {
                 MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationByRetailer(RetailerCode, ProductCode, eval(OnCompleteFuncName),onError);
            }
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
   
    /**
     * This method loads a particular product based on product code or a particular variant
     * @param {string} ProductCode Product Code(SKU)
     * @param {bool} VariantsWanted If true, variants are also loaded with the product information
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.LoadProduct=function(ProductCode, VariantsWanted, OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) { return false; }

        try {
            DoWait();
            if (VariantsWanted) {
             MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationVariantsWanted(ProductCode,true,eval(OnCompleteFuncName),onError);
            }
            else {
                MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformation(ProductCode,eval(OnCompleteFuncName),onError);
               
            }
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    
     /**
     * This method loads a particular product based on product code or a particular variant
     * @param {string} ProductCode Product Code(SKU)
     * @param {string} filterExpression
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
     this.LoadProductWithFilteredVariants=function(ProductCode, filterExpression, OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) { return false; }

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInfoWithFilteredVariants(ProductCode,filterExpression,eval(OnCompleteFuncName),onError);
        }
        catch (e)  {
             DoDefault();
             window.status = e.message;
        }
        return false;
    }
        
    /**
     * This method loads a particular product based on product code or a particular variant
     * @param {string} ProductCode Product Code(SKU)
     * @param {bool} VariantsWanted If true, variants are also loaded with the product information
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.LoadDiscontinuedProduct=function(RetailerCode, ProductCode,IgnoreFlags, VariantsWanted, OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) { return false; }

        try {
            if (VariantsWanted) {
             //MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationVariantsWantedIgnoreFlags(RetailerCode, ProductCode, IgnoreFlags, VariantsWanted,eval(OnCompleteFuncName),onError);
              MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationVariantsWantedIgnoreFlagsSetFilter(RetailerCode, ProductCode, IgnoreFlags, VariantsWanted,"PRDRTL_ONLINE=-1",eval(OnCompleteFuncName),onError);
            }
            else {
                MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationIgnoreFlags(RetailerCode, ProductCode, IgnoreFlags, eval(OnCompleteFuncName),onError);
               
            }
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
     
    /**
     * This method loads a pariticular product for a selected retailer. Allows for loading
     * product information for products that are inactive or offline. 
     * @param {string} RetailerCode Retailer Code
     * @param {string} ProductCode Product Code(SKU)
     * @param {bool} IgnoreFlags If true, load the product information regardless of its online status
     * @param {bool} VariantsWanted If true, variants are also loaded with the product information
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.LoadProductIgnoreFlags=function(RetailerCode, ProductCode, IgnoreFlags, VariantsWanted, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) { return false; }
        try {
            //DoWait();
            if (VariantsWanted) {
                   MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationVariantsWantedIgnoreFlags(RetailerCode, ProductCode, IgnoreFlags, VariantsWanted,eval(OnCompleteFuncName),onError);
            }
            else {
               
                   MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductInformationIgnoreFlags(RetailerCode, ProductCode, IgnoreFlags, eval(OnCompleteFuncName),onError);
            }
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**
     * This method loads a pariticular product and its variants for the selected category
     * with information about recommendations based on the specified diagnosis code. 
     * @param {string} CurrentCustomerID The current customer ID (GUID)
     * @param {string} ProductCode Product Code(SKU)
     * @param {string} DiagCode The diagnosis code 
     * @param {string} CategoryCode The category code
     * @param {string} RetailerCode The retailer code
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.LoadProductWithDiagnosisInformation=function(CurrentCustomerID, ProductCode, DiagCode, CategoryCode, RetailerCode,FilterExpression, OnCompleteFuncName)
    {
        if(!IsAjaxLoaded()) { return false; }
        try 
        {
             DoWait();
             MicrosoftFrance.MCS.Commerce.WS.AJAXProject.DiagnosisWebService.GetProductInfoWithDiagRecommendation(CurrentCustomerID, ProductCode, DiagCode, CategoryCode, RetailerCode, FilterExpression, eval(OnCompleteFuncName), onError);
        }
        catch (e)  
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * Retreieve variant information from the server for the selected product code
     * @param {string} RetailerCode Retailer Code
     * @param {string} ProductCode Product Code (SKU)
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetVariantInformation=function(RetailerCode, ProductCode, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) { return false; }

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetVariantInformation(RetailerCode, ProductCode,  eval(OnCompleteFuncName),onError);
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
        /**
     * Retreieve variant information from the server for the selected product code
     * @param {string} RetailerCode Retailer Code
     * @param {string} ProductCode Product Code (SKU)
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetVariantInformationIgnoreFlags=function(RetailerCode, ProductCode, ignoreFlags, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) { return false; }

        try {
            //DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetVariantInformationIgnoreFlags(RetailerCode, ProductCode, ignoreFlags,  eval(OnCompleteFuncName),onError);
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**  
     * This method saves product notification information for a selected email address
     * and product
     * @param {string} CustomerEmail The customer's email address
     * @param {string} ProductCode Product Code(SKU)
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.ProductStockNotificationSave=function(CustomerEmail, ProductCode, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.CustomerWebService.ProductStockNotificationSave(CustomerEmail, ProductCode,eval(OnCompleteFuncName),onError);

        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * This methods adds an item to the shopping bag
     * @param {string} CustomerID String in a form of GUID representing the Customer ID
     * @param {string} ProductCode Product Code of the variant
     * @param {int} Quantity The number of <i>ProductCode</i> variants to add
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.AddSingleProductToCart=function(CustomerID, ProductCode, Quantity, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}
        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.AddSingleItem(CustomerID, ProductCode, Quantity,eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * This methods adds multiple item to the shopping bag
     * @param {string} CustomerID String in a form of GUID representing the Customer ID
     * @param {Array} ProductCodes Array of variant product codes to add to the basket
     * @param {Array} Quantity Array with the cooresponding number of <i>ProductCode</i> variants to add
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.AddMultipleProductsToCart=function(CustomerID, ProductCodes, Quantity, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.AddMultipleItems(CustomerID, ProductCodes, Quantity, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**
     * Retrieves the shopping cart
     * @param {string} CustomerID String in a form of GUID representing the Customer ID
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.RetrieveShoppingCart=function (CustomerID, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.RetrieveShoppingCart(CustomerID,eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * Retrieves the last <i>N</i> number of items from the shopping cart
     * 
     * @param {string} CustomerID String in a form of GUID representing the Customer ID
     * @param {int} intLastItems The number of items to retrieve from the shopping cart. It assumes the shopping cart is stored as a stack so that the last intLastItems will be the most recently added ones.
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.RetrieveShoppingCartLastItems=function(CustomerID, intLastItems, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.RetrieveLastItems(CustomerID, intLastItems, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * Retrieves the promotion proximity for the customer's shopping 
     * cart. This method can be used to retrieve promotion proximity based on 
     * availability. See the parameter promotionAvailabilty for the available switches.
     * @param {string} CustomerID String in a form of GUID representing the Customer ID
     * @param {int} distancesToDisplay The number of distances to display. This will return up to <i>distancesToDisplay</i> promotion distances.
     * @param {string} evaluators Comma-delimited list of the type of promotions to evaluate for distance information. They are: CustomerRoleEvaluator, CustomerSegmentEvaluator, LineNotEmptyEvaluator, BasketPriceEvaluator, BasketItemsQuantityEvaluator, BasketItemsAxeEPQuantityEvaluator, BasketSpecificItemQuantityEvaluator, KeyCodeEvaluator
     * @param {int} promotionAvailability Used to get promotion distances based on promotion availability. Set this to NULL to evaluate only available promtoions. Otherwise, use the following values to tailor which promotions are returned: (0 = ALL, 1 = Available, 2 = Unavailable).
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetPromotionProximity=function(CustomerId, distancesToDisplay, evaluators, promotionAvailability, OnCompleteFuncName, hasDoWait) {
        if(!IsAjaxLoaded()) { return false; }

        try {
            if ( typeof(hasDoWait) != 'undefined' && hasDoWait == true )
                DoWait();
            if (promotionAvailability != null) {
               MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.GetPromotionProximityByAvailability(CustomerId, distancesToDisplay, evaluators, promotionAvailability,eval(OnCompleteFuncName),onError);
            }
            else {
              
               MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.GetPromotionProximity(CustomerId, distancesToDisplay, evaluators, eval(OnCompleteFuncName),onError);
            }
        }
        catch (e)  {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
        /**
     * This methods adds an item to the shopping bag
     * @param {string} cookieName represents name of the cookies
     * @param {string} CookieValue
     * @param {string} Append to existing with a delimiter or override the value
     * @param {string} Delimiter if appending the value like comma, pipe etc...
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.UpdateCookie=function(CookieName, CookieValue, Append,Delimiter, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}
        try
        {
            //MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.UpdateCookie(CookieName, CookieValue, Append,Delimiter,eval(OnCompleteFuncName),onError);
              MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ShoppingCartWebService.UpdateCookie(CookieName, CookieValue, Append,Delimiter,eval(OnCompleteFuncName));
        }
        catch (e)
        {
            DoDefault();
        }
        return false;
    }
    
    /**
     * Retrieves the product association specified for the selected <i>AssociationName</i> and <i>ProductCode</i>
     * TODO - TEST
     * @param {string} RetailerCode The retailer code
     * @param {string} ProductCode The source product code used to find the associated products
     * @param {string} AssociationName The product association name
     * @param {bool} VariantsWanted When true, the variants for each product in the association are returned
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetProductAssociations=function(RetailerCode,ProductCode,AssociationName,VariantsWanted,OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductAssociations(RetailerCode, ProductCode,AssociationName,VariantsWanted, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
        /**
     * Retrieves the dicontinued product association specified for the selected <i>AssociationName</i> and <i>ProductCode</i>
     * TODO - TEST
     * @param {string} RetailerCode The retailer code
     * @param {string} ProductCode The source product code used to find the associated products
     * @param {string} AssociationName The product association name
     * @param {bool} VariantsWanted When true, the variants for each product in the association are returned
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetProductAssociationsIgnoreFlags=function(RetailerCode,ProductCode,AssociationName,VariantsWanted,ignoreFlags,OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductAssociationsIgnoreFlags(RetailerCode, ProductCode,AssociationName,VariantsWanted,ignoreFlags, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
            /**
     * Retrieves the dicontinued product association specified for the selected <i>AssociationName</i> and <i>ProductCode</i>
     * TODO - TEST
     * @param {string} RetailerCode The retailer code
     * @param {string} ProductCode The source product code used to find the associated products
     * @param {string} AssociationName The product association name
     * @param {bool} VariantsWanted When true, the variants for each product in the association are returned
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetDiscontinuedProductAssociationsIgnoreFlags=function(RetailerCode,ProductCode,AssociationName,VariantsWanted,ignoreFlags,OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            //DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetProductAssociationsIgnoreFlags(RetailerCode, ProductCode,AssociationName,VariantsWanted,ignoreFlags, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
     /**
     * Retrieves topic information
     * @param {string} categoryCode The selected categoryCode
     * @param {string} filterCriteria 
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetCategoryProductsCodes=function(categoryCode,filterCriteria,variantsWanted,OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetCategoryProductsCodes(categoryCode,filterCriteria,variantsWanted, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

     /**
     * Retrieves products based on a CategoryCode
     * @param {string} categoryCode The selected categoryCode
     * @param {int} onlineStatus
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetCategoryProductsByOnlineStatus=function(RetailerCode, CategoryCode, onlineStatus, variantsWanted,OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
           MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetCategoryProductsByOnlineStatus(RetailerCode, CategoryCode, onlineStatus, variantsWanted, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

     /**
     * Retrieves Discontinued product information
     * @param {string} categoryCode The selected categoryCode
     * @param {int} onlineStatus
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetCategoryProductsCodesByOnlineStatus=function(CategoryCode,onlineStatus,OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try
        {
           DoWait();
           MicrosoftFrance.MCS.Commerce.WS.AJAXProject.ProductWebService.GetCategoryProductsCodesByOnlineStatus(CategoryCode, onlineStatus, eval(OnCompleteFuncName),onError);
        }
        catch (e)
        {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
        
    /**
     * Retrieves topic information
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetTopicInformation=function(TopicCode, TopicType, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetTopicInformation(TopicCode, TopicType,  eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * Retrieves the products associated to the selected <i>TopicCode</i> and <i>TopicType</i>
     * 
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {string} productSortExpression The  sort
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetTopicProducts= function (TopicCode, TopicType,productSortExpression, OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetTopicProducts(TopicCode, TopicType,productSortExpression,eval(OnCompleteFuncName),onError);

        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
      /**
     * Retrieves the products associated to the selected <i>TopicCode</i> and <i>TopicType</i>
     * 
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {string} productSortExpression The  sort
     * @param {string} filterExpression The filter even by extended property
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetFilteredTopicProducts= function (TopicCode, TopicType, productSortExpression, filterExpression, OnCompleteFuncName)  {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetFilteredTopicProducts(TopicCode, TopicType,productSortExpression,filterExpression,eval(OnCompleteFuncName),onError);

        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
       /**
     * Retrieves the product codes associated to the selected <i>TopicCode</i> and <i>TopicType</i>
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetTopicProductsCodes= function (TopicCode, TopicType, OnCompleteFuncName,HasDoWait)  {
        if(!IsAjaxLoaded()) {return false;}

        try {
            if ( typeof(HasDoWait)!='undefined' && HasDoWait == true)
                DoWait();                        
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetTopicProductsCodes(TopicCode, TopicType,eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
   /**
     * Retrieves the product codes associated to the selected <i>TopicCode</i> and <i>TopicType</i>
     * for the selected <i>RootCateogryCode</i>
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {string} RootCategoryName The root category name
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetTopicProductsCodesByRootCategory = function (TopicCode, TopicType, RootCategoryName, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetTopicProductsCodesByRootCategory(TopicCode, TopicType, RootCategoryName, eval(OnCompleteFuncName), onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
       /**
     * Retrieves the product codes associated to the selected <i>TopicCode1,TopicCode2,TopcCodeN</i> 
     * @param {string} TopicList comma delimited list of toiccodes
      * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetTopicProductsCodesByTopicList= function (TopicList,OnCompleteFuncName,HasDoWait)  {
        if(!IsAjaxLoaded()) {return false;}
        try {
              
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetTopicProductsCodesByTopicList(TopicList,eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
     
    /**
     * Used to remove a product from a customer's favorite list
     * @param {string} CustomerId The customer ID GUID
     * @param {int} FavoriteProductType The type of favorite list to retrieve
     * @param {string} RetailerCode The current retailer code
     * @param {string} ProductCode The product code to add to the customer's favorite list
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.RemoveFromFavorites=function(CustomerId, FavoriteProductType, RetailerCode, ProductCode, OnCompleteFuncName, hasDoWait) {
        if(!IsAjaxLoaded()) {return false;}

        try {
            if( typeof(hasDoWait) == 'undefined')
              DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.FavoritesWebService.FavoriteListProductRemove(CustomerId, FavoriteProductType, RetailerCode, ProductCode,eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**
     * Used to remove a product from a customer's favorite list
     * @param {string} CustomerId The customer ID GUID
     * @param {string} Topic Code
     * @param {string} TopicType
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.RemoveTopicFromFavorites=function(CustomerId, TopicCode, TopicType, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.FavoritesWebService.FavoriteTopicRemove(CustomerId, TopicCode, TopicType,eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
    /**
     * Gets the topic information with the customer's rating information.
     * @param {string} CustomerId The customer ID GUID
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.GetTopicWithCustomerRating=function(CustomerId, TopicType, TopicCode, OnCompleteFuncName) {
        // Check to ensure the ATLAS module has been loaded before calling
        // the web service
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.GetTopicWithCustomerRating(CustomerId, TopicType, TopicCode,  eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * Saves a customer's topic rating information
     * @param {string} CustomerId The customer ID GUID
     * @param {string} TopicCode The selected topic code
     * @param {string} TopicType The topic type
     * @param {string} TopicUrl The topic URL
     * @param {int} Rating The integer rating for the topic
     * @param {string} Comment The comment the customer has submitted related to this topic
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.TopicCustomerRatingRecord=function(CustomerId, TopicType, TopicCode, TopicUrl, Rating, Comment, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.TopicWebService.TopicCustomerRatingRecord(CustomerId, TopicType, TopicCode, TopicUrl, Rating, Comment,eval(OnCompleteFuncName),onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

    /**
     * Retrieves the customer's diagnosis products for a selected category.
     * @param {string} CustomerId The customer ID GUID
     * @param {string} DiagCode The diagnosis code
     * @param {string} CategoryCode The category code
     * @param {function} OnCompleteFuncName This is the callback function after the web service returns the result data
     */
    this.DiagnosisGetProductsByCategory=function(CustomerId, DiagCode, CategoryCode, OnCompleteFuncName) {
        if(!IsAjaxLoaded()) {return false;}

        try {
            DoWait();
            MicrosoftFrance.MCS.Commerce.WS.AJAXProject.DiagnosisWebService.GetProductsByCategory(CustomerId, DiagCode, CategoryCode, AJAX_DEFAULT_RTLCODE, eval(OnCompleteFuncName), onError);
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }

}


/*
 * It registers the WebServiceAPI_Class using registerClass method of MS AJAX Library
 */
// if (IsTypeDefined) { Core.WebServiceAPI_Class.registerClass('Core.WebServiceAPI_Class', null); }
if (IsTypeDefined) { Core.WebServiceAPI_Class.registerClass('Core.WebServiceAPI_Class'); }


