﻿// JScript File
    function ShoppingCartService() 
    {
        this.hostUrl = 'http://pacificfair.alphasalmonstaging.com:8085';     
        this.placeHolder = "horizontalCarousel";        
        this.controlId = "";
        this.ready = false;
    }
       
    ShoppingCartService.prototype.hostUrl;
    ShoppingCartService.prototype.controlId;
    ShoppingCartService.prototype.placeHolder;
    ShoppingCartService.prototype.ready;

    ShoppingCartService.prototype = 
    {
        
        setHostURL: function (url) {
            var loc = new String(window.parent.document.location);
            if (loc.indexOf("https://")!= -1){
                url = url.replace(/http:\/\//,"https://"); 
            }
            this.hostUrl = url;
            if (this.hostUrl.substr(this.hostUrl.length - 1, 1) == '/'){
                this.hostUrl = this.hostUrl.substr(0, this.hostUrl.length - 1);
            }
            
            //alert(this.hostUrl);
        },
    
        setControlID : function(id) {            
            this.controlId = id;    
            //alert(this.controlId);     
        },
        
         setHolderID : function(id) {             
            this.placeHolder = id;
            //alert(this.placeHolder);            
        },
    
        refreshContentCallback: function (data) {                
            var divHolder = document.getElementById(this.placeHolder); 
            //alert('--' + data);                      
            if(divHolder != null)
            {   
                
                divHolder.innerHTML = data;  
                this.ready = true;               
                //window.setTimeout("displayCart()",2000);
            }  
        },

        refreshContent: function () {    
            //alert('----');        
            jQuery.getJSON(this.hostUrl + "/CMSTemplates/AMPSCPacificFair/ShoppingCartService.aspx?controlid=1&retrieve=1&jsoncallback=__cart.refreshContentCallback&foo=?");                                                                          
        }
    }

    var __cart = new ShoppingCartService();

    function getObject() {
        return __cart;
    }


