var QuickViewPopUp = Class.create({
    name: '',
    skus: null,
    product: null,
    selectedSku: null,
    selectedImageName: '',
    swatchCarousel: null,
    tabs: null,
    isAddAndSave: false,
    parentFamilyId: '',
    promoTypeId: '',
    promoId: '',
    url: '',
    absolutePosition: '',
    iframe: null,
    selectedAvailabilityStatus: 1,
    initialize: function(tname) {

        this.name = tname;
        this.getPopDimensions();

        Event.observe(this.name + "ColorDropDown", 'change', this.ColorDropDownChange.bindAsEventListener(this));
        Event.observe(this.name + "SizeDropDown", 'change', this.SizeDropDownChange.bindAsEventListener(this));
        Event.observe(this.name + "ProgramDropDown", 'change', this.ProgramDropDownChange.bindAsEventListener(this));


        Event.observe(this.name + '_accept', 'click', this.AcceptAddAndSave.bindAsEventListener(this));
        Event.observe(this.name + '_decline', 'click', this.DeclineAddAndSave.bindAsEventListener(this));

        Event.observe(this.name + '_addToCart', 'click', this.AddProductToCart.bindAsEventListener(this));
        Event.observe(this.name + '_quickBuy', 'click', this.QuickBuyProduct.bindAsEventListener(this));


        Control.Window.baseZIndex = 110000;
        this.iframe = new Control.Window($(this.name + 'Wrapper'), Object.extend({
            draggable: $(this.name + '_header')
        }));
        this.iframe.options.fade = true;

        if (navigator.appName == 'Netscape')
            this.iframe.iFrameShim.destroy();


    },
    SetUpAddAndSave: function() {

        if ($(this.name + '_promoMessage')) {
            $(this.name + '_promoMessage').show();
            $(this.name + '_promoMessage').innerHTML = this.promoText;
        }
        //             if($(this.name+ '_closeDiv'))
        //                 $(this.name+ '_closeDiv').hide();
        if ($(this.name + '_buyButton'))
            $(this.name + '_buyButton').hide();
        if ($(this.name + '_addAndSaveButtons'))
            $(this.name + '_addAndSaveButtons').show();

    },
    SetUpQuickView: function() {
        if ($(this.name + '_promoMessage'))
            $(this.name + '_promoMessage').hide();
        if ($(this.name + '_closeDiv'))
            $(this.name + '_closeDiv').show();
        if ($(this.name + '_buyButton'))
            $(this.name + '_buyButton').show();
        if ($(this.name + '_addAndSaveButtons'))
            $(this.name + '_addAndSaveButtons').hide();



    },

    popWidth: 150,
    popHeight: 300,
    popPadding: 5,
    isVisable: false,
    xLoc: 0,
    yLoc: 0,
    promoPrice: 0,
    promoPriceType: -1,
    promoText: "",


    getPopDimensions: function() {

        this.popHeight = $(this.name + 'Wrapper').getDimensions().height;
        this.popWidth = $(this.name + 'Wrapper').getDimensions().width;
    },

    //Load the popup info, and then displayes it next to the item
    ShowPopUp: function() {

        if (!this.isVisable) {
            //Some position logic that I just made up
            if (!this.absolutePosition) {
                var windowPos = document.viewport.getScrollOffsets();
                var windowSize = document.viewport.getDimensions();

                this.xLoc = this.xLoc - (.5 * this.popWidth) + 75;
                this.yLoc = this.yLoc - 20;

                if (this.yLoc < windowPos.top + this.popPadding)
                    this.yLoc = windowPos.top + this.popPadding;

                if (this.yLoc + this.popHeight > windowPos.top + windowSize.height - this.popPadding) {
                    this.yLoc = windowPos.top + windowSize.height - this.popPadding - this.popHeight;
                    this.xLoc = this.xLoc + .5 * this.popWidth + 75;
                }

                if (this.xLoc < windowPos.left + this.popPadding)
                    this.xLoc = windowPos.left + this.popPadding;

                if (this.xLoc + this.popWidth > windowPos.left + windowSize.width - this.popPadding)
                    this.xLoc = windowPos.left + windowSize.width - this.popPadding - this.popWidth
            }

            this.iframe.options.position = new Array();
            this.iframe.options.position[0] = this.xLoc;
            this.iframe.options.position[1] = this.yLoc;

            this.isVisable = this.iframe.open();
            setTimeout(this.name + ".SetCarousel()", 850);
            setTimeout("$('quickViewWrapper').style.top = " + this.name + ".yLoc + \"px\";", 5);

            //tracking
            dcsMultiTrack("dcsuri", "/Quickview.aspx", "WT.ti", "QuickView", "WT.si_x", "1", "WT.tx_u", "1", "WT.si_n", "purchase;quickbuy", "WT.tx_e", "v", "WT.pn_sku", this.familyId, "WT.cg_n", "QuickView", "DCSext.VideoView", "", "DCSext.ProductVideoView", "", "DCSext.tabs", "");


        }
    },

    closePopup: function(overRideAddAndSave) { //overRideAddAndSave is only used when you want to overide the addand savecheck, since this call occures in the declineAddAndSave function
        if (!overRideAddAndSave && this.isAddAndSave) //otherwise you can simply call closePopup();
        {
            this.DeclineAddAndSave();
        }
        else if (this.isVisable) {
            this.StopVideo();
            this.isVisable = !this.iframe.close();
        }
    },

    /************ END OF POP UP DISPLAY PROPERTIES **************/

    // parentFamilyId,promoId, promoTypeId,promoPrice,promoText,promoPriceType are only set on a add and save window 
    // For a normal quickview  you can simply call LoadQuickView(familyId, event) or even just LoadQuickView(familyId)
    LoadQuickView: function(familyId, event, parentFamilyId, promoId, promoTypeId, promoPrice, promoText, promoPriceType) {

        if (this.isVisable && this.familyId == familyId && parentFamilyId == null) //It's a reclick so ignore 
            return;

        this.familyId = familyId;
        if (parentFamilyId) //Is AddAndSave
        {
            this.isAddAndSave = true;
            this.promoId = promoId;
            this.promoPrice = promoPrice;
            this.parentFamilyId = parentFamilyId;
            this.promoTypeId = promoTypeId;
            this.promoText = promoText;
            this.promoPriceType = promoPriceType;
        }
        else
            this.isAddAndSave = false;

        //productServiceUrl is set in the quickview controller to get the productservice url from the config.  
        this.url = productServiceUrl + '/GetProductData/' + familyId + "/SetUpQuickViewData/";

        try {

            if (event != null) {
                if (event.qvx != null && event.qvy != null) {
                    this.xLoc = event.qvx;
                    this.yLoc = event.qvy;

                    var windowSize = document.viewport.getDimensions();
                    var offset = (windowSize.width - 966) / 2;
                    if (offset > 0)
                        this.xLoc = this.xLoc + offset;

                    this.absolutePosition = true;

                }
                else {
                    this.xLoc = Event.pointerX(event);
                    this.yLoc = Event.pointerY(event);
                    this.absolutePosition = false;
                }
            }
            else {
                if (this.xLoc == 0 && this.yLoc == 0)//set location if first time, else we default to the previous location
                {
                    this.xLoc = 10;
                    this.yLoc = 200;

                    var windowSize = document.viewport.getDimensions();
                    var offset = (windowSize.width - 966) / 2;
                    if (offset > 0)
                        this.xLoc = this.xLoc + offset;
                }
                else {

                    this.xLoc = parseInt($(this.name + 'Wrapper').offsetLeft);
                    this.yLoc = parseInt($(this.name + 'Wrapper').offsetTop);

                    if (this.xLoc == 0 && this.yLoc == 0) {
                        this.xLoc = parseInt($(this.name + 'Wrapper').style.left);
                        this.yLoc = parseInt($(this.name + 'Wrapper').style.top);
                    }
                }
                this.absolutePosition = true;
            }
        }
        catch (e) {


        }

        if (!this.isVisable)
            setTimeout(this.name + ".makecall()", 1); //Need this for a fix to show the QV on the OnAir pages.  Not sure why.
        else {
            this.closePopup(true);
            setTimeout(this.name + ".makecall()", 950);
        }

    },
    makecall: function() {
        makeCall(this.url);
    },
    /***  USED TO SET UP THE QUICK VIEW****/

    SetUpQuickViewData: function(product) {

        this.product = product;
        this.skus = product._skus;
        this.selectedAvailabilityStatus = product._availabilityStatus;

        if (this.isAddAndSave)
            this.SetUpAddAndSave();
        else
            this.SetUpQuickView();

        this.SetButtonImage();

        this.SetProductInfo();
        this.DisplayImage('default');
        this.SetMorePhotos();
        this.SetSkuData();
        this.SetupTabs();
        this.tabs = new Control.Tabs(this.name + 'Block_tabs');

        this.UpdateColorText('');
        this.UpdateSizeText('');
        this.ClearMessages();

        this.ShowPopUp();

    },

    SetProductInfo: function() {
        if (this.product != null) {
            if ($(this.name + '_moreInfoPhoto'))
                $(this.name + '_moreInfoPhoto').innerHTML = this.GetLearnMore();
            if ($(this.name + '_moreInfoDesc'))
                $(this.name + '_moreInfoDesc').innerHTML = this.GetLearnMore();

            if ($(this.name + 'ProductNamePhoto'))
                $(this.name + 'ProductNamePhoto').innerHTML = "<a href=\"" + this.GetLearnMoreLink() + "\">" + this.product._familyID + " - " + this.product._familyName + "</a>";
            if ($(this.name + 'ProductNameDesc'))
                $(this.name + 'ProductNameDesc').innerHTML = "<a href=\"" + this.GetLearnMoreLink() + "\">" + this.product._familyID + " - " + this.product._familyName + "</a>";

            if ($(this.name + 'PriceLabelPhoto'))
                $(this.name + 'PriceLabelPhoto').innerHTML = this.product._priceLabel + ": ";
            if ($(this.name + 'PriceLabelDesc'))
                $(this.name + 'PriceLabelDesc').innerHTML = this.product._priceLabel + ": ";

            if ($(this.name + 'PriceBlockPhoto'))
                if (this.isAddAndSave) {
                if (this.promoPrice < 0)
                    $(this.name + 'PriceBlockPhoto').innerHTML = "FREE";
                else if (this.promoPriceType == 1)
                    $(this.name + 'PriceBlockPhoto').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice - ((this.promoPrice / 100) * this.product._currentPrice));
                else if (this.promoPriceType == 0)
                    $(this.name + 'PriceBlockPhoto').innerHTML = "$" + ParseToMoneyString(this.promoPrice);
                else
                    $(this.name + 'PriceBlockPhoto').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice - this.promoPrice);
            }
            else
                $(this.name + 'PriceBlockPhoto').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice);
            if ($(this.name + 'PriceBlockDesc'))
                if (this.isAddAndSave) {
                if (this.promoPrice < 0)
                    $(this.name + 'PriceBlockDesc').innerHTML = "FREE";
                else if (this.promoPriceType == 1)
                    $(this.name + 'PriceBlockDesc').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice - ((this.promoPrice / 100) * this.product._currentPrice));
                else if (this.promoPriceType == 0)
                    $(this.name + 'PriceBlockDesc').innerHTML = "$" + ParseToMoneyString(this.promoPrice);
                else
                    $(this.name + 'PriceBlockDesc').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice - this.promoPrice);
            }
            else
                $(this.name + 'PriceBlockDesc').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice);


            if ($(this.name + 'Description')) {
                var desc = this.product._shortDescription + "<br>" + this.product._longDescription;
                desc = desc.substring(0, 650);
                var len = desc.lastIndexOf('. ');
                if (len > 0)
                    desc = desc.substring(0, len);
                else
                    desc = desc.substring(0, desc.lastIndexOf(' '));
                desc = desc + '...<br>' + this.GetLearnMore(); ;
                $(this.name + 'Description').innerHTML = desc;

            }
        }
    },

    GetLearnMoreLink: function() {
        return "/product/?familyid=" + this.product._familyID + "&track=-10102&ciid=11281"; //&cm_re=" + cmre;
    },
    GetLearnMore: function() {
        var u = this.GetLearnMoreLink();
        var s = "<p><a href=\"" + u + "\" class=\"moreInfo\" >Learn More</a> &nbsp;" + "<img src='/images/global/home/blueCaratRight.gif' />"; +"</p>";
        return s;
    },

    SetMorePhotos: function() {
        if (this.product != null) {
            var photos = this.product._photos;
            if (photos.length > 1) {
                if ($(this.name + 'MorePhotosDiv'))
                    $(this.name + 'MorePhotosDiv').show();

                if ($(this.name + 'MorePhotos')) {
                    $(this.name + 'MorePhotos').innerHTML = "";
                    for (var i = 0; i < photos.length; i++) {
                        var imageName = this.product._familyID.toLowerCase();
                        if (photos[i]._type == 2)
                            if (photos[i]._sequence < 10)
                            imageName = imageName + "_0" + photos[i]._sequence + "_detail";
                        else
                            imageName = imageName + "_" + photos[i]._sequence + "_detail";
                        $(this.name + 'MorePhotos').innerHTML +=
								            "<a href=\"Javascript:" + this.name + ".DisplayImage('"
								            + imageName + "');\"><img src=\"http://images.shopnbc.com/is/image/ShopNBC/"
								            + imageName + "?DefaultImage=1&$80x80_jpg$\" width=\"80\" height=\"80\" alt=\""
								            + ((photos[i]._caption) ? photos[i]._caption : '') + "\" title=\""
								            + ((photos[i]._caption) ? photos[i]._caption : '')
								            + "\" /></a>";
                    }
                }
            }
            else {
                if ($(this.name + 'MorePhotosDiv'))
                    $(this.name + 'MorePhotosDiv').hide();
            }
        }
    },
    hasCarousel: false,
    SetCarousel: function() {
        if (this.hasCarousel) {
            if (this.swatchCarousel == null) {
                this.swatchCarousel = new UI.Carousel(this.name + "_carousel");
                this.swatchCarousel.elements = new Array();
                var swatchImagesLi = $(this.name + '_SwatchImages').childElements();
                for (var i = 0; i < swatchImagesLi.length; i++) {
                    if (swatchImagesLi[i].innerHTML == "")
                        break;
                    this.swatchCarousel.elements[i] = swatchImagesLi[i];
                }
                if (i < 4)
                    this.swatchCarousel.updateButtons()
            }
            else {
                if (this.swatchCarousel.currentIndex() > 0)
                    this.swatchCarousel.scrollTo(0);
                else
                    this.swatchCarousel.updateButtons()
            }
        }
    },

    AddDropDownOption: function(selectbox, text, value) {
        var optn = document.createElement("OPTION");
        optn.text = text;
        optn.value = value;
        selectbox.options.add(optn);
    },

    SetSkuData: function() {

        var colorDropDown = this.GetColorDropDown();
        var sizeDropDown = this.GetSizeDropDown();
        var programDropDown = this.GetProgramDropDown();

        colorDropDown.innerHTML = "";
        this.AddDropDownOption(colorDropDown, "Color", "-1")
        sizeDropDown.innerHTML = "";
        this.AddDropDownOption(sizeDropDown, "Size", "-1")
        programDropDown.innerHTML = "";
        this.AddDropDownOption(programDropDown, "Select Delivery Program", "-2");
        this.AddDropDownOption(programDropDown, "Single Delivery", "-1");

        var sku;
        var addElemnt;
        var swatchImageIndex = 0;
        var swatchImagesLi = $(this.name + '_SwatchImages').childElements();
        var swatchImageArray = new Array();
        var programsAvailable = false;
        for (var i = 0; i < this.skus.length; i++) {
            sku = this.skus[i];

            addElemnt = true;

            for (var j = 1; j < colorDropDown.options.length; j++) {
                if (colorDropDown.options[j].value == sku._colorCode)
                    addElemnt = false;
            }
            if (addElemnt) {
                var status = this.GetColorAvailability(sku._colorCode);
                if (status == 0)
                    this.AddDropDownOption(colorDropDown, sku._colorValue, sku._colorCode);
                else if (status == 1)
                    this.AddDropDownOption(colorDropDown, sku._colorValue + " - Sold Out", sku._colorCode);
                else
                    this.AddDropDownOption(colorDropDown, sku._colorValue + " -Coming Soon", sku._colorCode);

                if (sku._isPhotoActive) {
                    this.selectedSku = sku;

                    var imageSrc = this.GetImageURL('swatch', 40);

                    //if we directly edit the list the carousel script wont work, so we need to edit the objects 
                    //in the list so this script error won't happen.  
                    if (swatchImagesLi.length > swatchImageIndex) {
                        if (this.selectedImageName != '') {
                            swatchImagesLi[swatchImageIndex].innerHTML = "<a href=\"Javascript:"
						                            + this.name + ".SwatchSelect('"
						                            + sku._colorCode
						                            + "');\"><img src=\""
						                            + imageSrc
						                            + "\" id=\""
						                            + this.name + "_swatch"
						                            + this.selectedSku._colorCode
						                            + "\" width=\"40\" height=\"40\" alt=\""
						                            + this.selectedSku._colorValue + "\" title=\""
						                            + this.selectedSku._colorValue + "\" /></a>";
                            swatchImageArray[swatchImageIndex] = swatchImagesLi[swatchImageIndex]
                            swatchImageIndex++;
                        }
                    }
                }
            }

            addElemnt = true;
            for (var j = 1; j < sizeDropDown.options.length; j++) {
                if (sizeDropDown.options[j].value == sku._sizeCode)
                    addElemnt = false;
            }
            if (addElemnt) {
                var status = this.GetSizeAvailability(sku._sizeCode);
                if (status == 0)
                    this.AddDropDownOption(sizeDropDown, sku._sizeValue, sku._sizeCode);
                else if (status == 1)
                    this.AddDropDownOption(sizeDropDown, sku._sizeValue + " - Sold Out", sku._sizeCode);
                else
                    this.AddDropDownOption(sizeDropDown, sku._sizeValue + " -Coming Soon", sku._sizeCode);

            }

            // need to determine if the dropdown box should be displayed or not
            if (sku._autoDeliveryPrograms != null && !this.isAddAndSave) {
                for (var j = 0; j < sku._autoDeliveryPrograms.length; j++) {
                    if (sku._autoDeliveryPrograms[j] != null) {
                        programsAvailable = true;
                        break;
                    }
                }
            }
        }


        if (swatchImageIndex < 1) {
            this.hasCarousel = false;
            $(this.name + "_carousel").hide();
        }
        else {

            this.hasCarousel = true;
            $(this.name + "_carousel").show();


            if (swatchImageIndex > 3) {
                $(this.name + "CarouselButtons").show();
            }
            else {
                $(this.name + "CarouselButtons").hide();
            }
        }

        //we clear out the rest of the carousel from the previous quickview
        while (swatchImagesLi.length > swatchImageIndex && swatchImagesLi[swatchImageIndex].innerHTML != "") {
            swatchImagesLi[swatchImageIndex].innerHTML = "";
            swatchImageIndex++;
        }

        //we need to reset the carousel object with a list of active list items 
        if (this.swatchCarousel)
            this.swatchCarousel.elements = swatchImageArray;

        //make sure we have skus to work with.  It is possible (although highly unlikely) that the familyid is web approved but none
        //of the skus are web avail or have a status with a Do Not Display (DND) outcome, in which case the product object is not null but 
        //no skus are returned.
        if (this.skus.length > 0) {
            if (sizeDropDown != null) {
                if (sizeDropDown.options.length < 3) {

                    sizeDropDown.options[1].selected = true;
                    sizeDropDown.style.display = "none"
                    document.getElementById(this.name + "SizeText").style.display = "none"
                }
                else {
                    sizeDropDown.options[0].selected = true;
                    sizeDropDown.style.display = ""
                    document.getElementById(this.name + "SizeText").style.display = ""
                }
            }
            if (colorDropDown != null) {
                if (colorDropDown.options.length < 3) {
                    colorDropDown.options[1].selected = true;
                    colorDropDown.style.display = "none"
                    document.getElementById(this.name + "ColorText").style.display = "none"
                }
                else {
                    colorDropDown.options[0].selected = true;
                    colorDropDown.style.display = ""
                    document.getElementById(this.name + "ColorText").style.display = ""
                }
            }
        }
        else {
            sizeDropDown.style.display = "none"
            document.getElementById(this.name + "SizeText").style.display = "none"
            colorDropDown.style.display = "none"
            document.getElementById(this.name + "ColorText").style.display = "none"
        }

        if (programDropDown != null) {
            this.RegenorateProgramDropDown();
        }


    },

    SetButtonImage: function() {
        if ($(this.name + '_addToCartBtn'))
            if (this.product._availabilityStatus != 0) {
            $(this.name + '_addToCartBtn').src = '/images/stylesheetimgs/btn_addToCartGrey.jpg';
            $(this.name + '_quickBuyBtn').hide();

        }
        else {
            $(this.name + '_addToCartBtn').src = '/images/stylesheetimgs/btn_addToCart.gif';
            $(this.name + '_quickBuyBtn').show();
        }
    },



    GetColorDropDown: function() {
        return $(this.name + "ColorDropDown");
    },

    GetSizeDropDown: function() {
        return $(this.name + "SizeDropDown");
    },
    GetProgramDropDown: function() {
        return $(this.name + "ProgramDropDown");
    },
     GetProgramText: function() {
        return $(this.name + "ProgramText");
    },

    DoesProductHaveAutoDeliveryPrograms: function() {
        var hasPrograms = false;

        for (var i = 0; i < this.skus.length; i++) {
            var sku = this.skus[i];

            if (sku != null && sku._autoDeliveryPrograms != null) {
                for (var j = 0; j < sku._autoDeliveryPrograms.length; j++) {
                    if (sku._autoDeliveryPrograms[j] != null) {
                        hasPrograms = true;
                        break;
                    }
                }
            }
        }

        return hasPrograms;
    },

    overlayStatus: '',
    GetImageURL: function(type, size) {
        //displays ths swatch  of the selected color
        //looks at selectedAvailabilityStatus to determan what sash to put on the product
        //returns the imageURL;  

        var imageType = '';
        var imageURL;
        var rootURL = "http://images.shopnbc.com/is/image/ShopNBC/";
        var newSelectedImageName = '';
        var familyId = this.product._familyID.toLowerCase();
        //this.overlayStatus = this.product._availabilityStatus; 

        if (type == "default") {
            newSelectedImageName = familyId;
            imageType = 'default'
        }
        else if (type == "swatch") {
            if (this.selectedSku) {
                if (this.selectedSku._isPhotoActive && this.selectedSku._isPhotoActive != 'False') {
                    if (this.selectedSku._photoSequence < 10)
                        newSelectedImageName = familyId + "_0" + this.selectedSku._photoSequence + "_swatch";
                    else
                        newSelectedImageName = familyId + "_" + this.selectedSku._photoSequence + "_swatch";
                }
                imageType = "swatch"
            }

        }
        else if (type == "details") {
            if (selectedSku._photoSequence < 10)
                newSelectedImageName = familyId + "_0" + this.selectedSku._photoSequence + "_detail";

            else
                newSelectedImageName = familyId + "_" + this.selectedSku._photoSequence + "_detail";

            imageType = "details";


        }
        else //then type is the imagename
        {
            newSelectedImageName = type;
        }


        if (newSelectedImageName != '') {
            this.selectedImageName = newSelectedImageName
        }
        if (size != 200) // we are in zoom 
            imageURL = rootURL + this.selectedImageName + "?hei=" + size + "&wid=" + size + "&op_sharpen=1";
        else if (this.selectedAvailabilityStatus == 2)
            imageURL = rootURL + "comingsoon_2008_overlay_1?$product=ShopNBC/" + this.selectedImageName + "&$" + size + "x" + size + "_jpg$";
        else if (this.selectedAvailabilityStatus == 1 && !this.isAddAndSave)
            imageURL = rootURL + "soldout_2008_overlay_1?$product=ShopNBC/" + this.selectedImageName + "&$" + size + "x" + size + "_jpg$";
        else {
            if (this.product._isNewItem == true)
                imageURL = rootURL + "newtoshop_2008_overlay_1?$product=ShopNBC/" + this.selectedImageName + "&$" + size + "x" + size + "_jpg$";
            else
                imageURL = rootURL + this.selectedImageName + "?DefaultImage=1&$" + size + "x" + size + "_jpg$";
        }
        return imageURL
    },

    DisplayImage: function(imageName)//passes in the image name or the type of the object to get off of the selectedSku
    {

        var imageUrl = this.GetImageURL(imageName, 200);

        if (imageUrl && imageUrl.length > 0) {
            var img = document.getElementById(this.name + 'ProductImagePhoto');
            if (img) {

                img.src = imageUrl;
                img.alt = this.product._familyID + " - " + this.product._familyName;
                img.title = this.product._familyID + " - " + this.product._familyName;
            }

            img = document.getElementById(this.name + 'ProductImageDesc');
            if (img) {
                img.src = imageUrl;
                img.alt = this.product._familyID + " - " + this.product._familyName;
                img.title = this.product._familyID + " - " + this.product._familyName;
            }
        }
    },


    /*** Begin event handling***/
    ColorDropDownChange: function() {
        var sizeDropDown = this.GetSizeDropDown();
        var colorDropDown = this.GetColorDropDown();

        if (sizeDropDown.value != -1 || colorDropDown.value != -1) {
            var colorCode = colorDropDown.value;
            this.ClearMessages();

            this.UpdateSelectedSwatch(colorCode);

            this.RegenorateSizeDropDown(colorCode);

            this.UpdateSkuMessage();
            if (colorCode != -1)
                this.DisplayImage('swatch');
        }
        else {
            this.ResetProdduct();
        }

    },
    SetupTabs: function() {
        this.SetVideo();
        Event.observe(this.name + "PhotoTab", 'click', this.PhotoTabClick.bindAsEventListener(this));
        Event.observe(this.name + "DescTab", 'click', this.DescTabClick.bindAsEventListener(this));
        Event.observe(this.name + "VideoTab", 'click', this.VideoTabClick.bindAsEventListener(this));
    },

    PhotoTabClick: function() {
        this.SetVideo();
        dcsMultiTrack("dcsuri", "/Quickview.aspx", "WT.ti", "QuickView", "WT.si_x", "1", "WT.tx_u", "1", "WT.si_n", "purchase;quickbuy", "WT.tx_e", "v", "WT.pn_sku", this.familyId, "WT.cg_n", "QuickView", "DCSext.VideoView", "", "DCSext.ProductVideoView", "", "DCSext.tabs", "QuickView Photos");
    },
    DescTabClick: function() {
        this.SetVideo();
        dcsMultiTrack("dcsuri", "/Quickview.aspx", "WT.ti", "QuickView", "WT.si_x", "1", "WT.tx_u", "1", "WT.si_n", "purchase;quickbuy", "WT.tx_e", "v", "WT.pn_sku", this.familyId, "WT.cg_n", "QuickView", "DCSext.VideoView", "", "DCSext.ProductVideoView", "", "DCSext.tabs", "QuickView Description");
    },
    VideoTabClick: function() {
        dcsMultiTrack("dcsuri", "/QuickviewVideo.aspx", "WT.ti", "QuickViewVideo", "WT.si_x", "1", "WT.tx_u", "1", "WT.si_n", "purchase;quickbuy", "WT.tx_e", "v", "WT.pn_sku", this.familyId, "WT.cg_n", "QuickView Video Player", "DCSext.VideoView", "1", "DCSext.ProductVideoView", "1", "DCSext.tabs", "QuickView Video");
    },

    StopVideo: function() {
        var dTag = $(this.name + 'VideoFlash');
        if (dTag)
            dTag.innerHTML = '';

    },
    SetVideo: function() {
        var dTag = $(this.name + 'VideoFlash');
        if (dTag) {
            dTag.innerHTML = '';
            if (this.product._videos && this.product._videos.length > 0) {
                var videoTab = $(this.name + 'VideoTab');
                videoTab.show();
                var url = this.product._videos[0]._videoURL; // this.product._videos[0].<VideoURL>k__BackingField;

                // need to clean up the video url so that just the video file name is the video url.  Full URL will be built in the flash player.
                if (url != null && url.length > 0) {
                    var replaceText = '';

                    var index = url.lastIndexOf('/');
                    if (index > -1)
                        replaceText = url.substring(0, index + 1);
                    url = url.replace(replaceText, "");

                    index = url.indexOf('.flv');
                    if (index > -1)
                        replaceText = url.substring(index, url.length);
                    url = url.replace(replaceText, "");
                }

                var str = '';
                str = AC_FL_RunContent(
		        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
		        'width', '403',
		        'height', '335',
		        'src', 'FlashVideoPlayer7',
		        'quality', 'best',
		        'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		        'align', 'middle',
		        'play', 'true',
		        'loop', 'false',
		        'scale', 'showall',
		        'wmode', 'transparent',
		        'devicefont', 'false',
		        'id', 'FlashVideoPlayer7',
		        'bgcolor', '#ffffff',
		        'name', 'FlashVideoPlayer7',
		        'menu', 'false',
		        'allowFullScreen', 'false',
		        'allowScriptAccess', 'sameDomain',
		        'movie', '/flash/store1/videoplayers/productVideo_str_IE6?movie=' + url + '',
		        'salign', ''
		        ); //end AC code
                //  alert(str);
                dTag.innerHTML = str;

            }
            else {
                var videoTab = $(this.name + 'VideoTab');
                videoTab.hide();
                //Set Video display to none
            }
        }

    },


    SizeDropDownChange: function() {
        var sizeDropDown = this.GetSizeDropDown();
        var colorDropDown = this.GetColorDropDown();
        if (sizeDropDown.value != -1 || colorDropDown.value != -1) {
            var sizeCode = sizeDropDown.value;
            this.ClearMessages();
            this.RegenorateColorDropDown(sizeCode);

            this.UpdateSkuMessage();
            this.DisplayImage('swatch');
        }
        else {
            this.ResetProdduct();
        }

    },

    ProgramDropDownChange: function() {
        var autoDeliveryDropDown = this.GetProgramDropDown();

        if (this.selectedSku && autoDeliveryDropDown.value != '-2' && autoDeliveryDropDown.value != '-1') {
            for (var j = 0; j < this.selectedSku._autoDeliveryPrograms.length; j++) {
                var program = this.selectedSku._autoDeliveryPrograms[j];

                if (autoDeliveryDropDown.value == program.ProgramId) {
                    if ($(this.name + 'PriceBlockDesc')) {
                        $(this.name + 'PriceBlockDesc').innerHTML = "$" + ParseToMoneyString(program.Price);
                    }

                    if ($(this.name + 'PriceBlockPhoto')) {
                        $(this.name + 'PriceBlockPhoto').innerHTML = "$" + ParseToMoneyString(program.Price);
                    }
                }
            }
        } else {
            // reset price label to product level price
            if ($(this.name + 'PriceBlockDesc')) {
                $(this.name + 'PriceBlockDesc').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice);
            }

            if ($(this.name + 'PriceBlockPhoto')) {
                $(this.name + 'PriceBlockPhoto').innerHTML = "$" + ParseToMoneyString(this.product._currentPrice);
            }
        }
    },

    RegenorateProgramDropDown: function() {
        var programDropDown = this.GetProgramDropDown();
        var sizeDropDown = this.GetSizeDropDown();
        var colorDropDown = this.GetColorDropDown();
        var programText = this.GetProgramText();

        if (programDropDown) {
            this.SetSelectedSku();
            // clear all options
            for (var o = programDropDown.options.length; o >= 0; o--)
                programDropDown[o] = null;

            // add back default options
            this.AddDropDownOption(programDropDown, 'Select Delivery Program', '-2');
            this.AddDropDownOption(programDropDown, 'Single Delivery', '-1');

            var isSizeSelected = sizeDropDown == null ? true : sizeDropDown.value > -1 ? true : false;
            var isColorSelected = colorDropDown == null ? true : colorDropDown.value > -1 ? true : false;

            // add the sku's programs if available
            if (this.selectedSku != null && isSizeSelected && isColorSelected) {
                if (this.selectedSku._autoDeliveryPrograms != null) {
                    for (var j = 0; j < this.selectedSku._autoDeliveryPrograms.length; j++) {
                        this.AddDropDownOption(programDropDown, this.selectedSku._autoDeliveryPrograms[j].ProgramName,
                            this.selectedSku._autoDeliveryPrograms[j].ProgramId);
                    }
                }
            }

            // set default selected program
            if (programDropDown.options.length > 2 && !this.isAddAndSave) {
                programDropDown.show();
                programDropDown.options[0].selected = 'selected';
                programText.show();
            } else {
                programDropDown.hide();
                programDropDown.options[programDropDown.options.length - 1].selected = 'selected';
                programText.hide();
            }
        }
    },

    SwatchSelect: function(colorCode) {
        this.ClearMessages();
        this.UpdateColorDropDown(colorCode);
        this.UpdateSelectedSwatch(colorCode);

        this.RegenorateSizeDropDown(colorCode);

        this.UpdateSkuMessage();
        this.DisplayImage('swatch');

    },

    ResetProdduct: function() {
        this.ClearMessages();
        //var quantityMessage = document.getElementById('ProductQuantity');
        // quantityMessage.innerHTML = FamilyQuantityStatus; 
        this.UpdateSelectedSwatch(-1);
        this.DisplayImage("default");
        this.RegenorateColorDropDown(-1);
        this.RegenorateSizeDropDown(-1);
        this.UpdateColorText('');
        this.UpdateSizeText('');
        this.RegenorateProgramDropDown();

    },

    //genorates the color drop down - listing items as slod out based on the sizeCode; 
    RegenorateSizeDropDown: function(colorCode) {
        this.selectedSku = null;
        colorCode = this.GetColorDropDown().value;

        var skuIndex = 0;
        var colorValue = '';
        var foundSku = false;
        for (var skuIndex = 0; skuIndex < this.skus.length; skuIndex++) {
            var sku = this.skus[skuIndex];

            if (sku._colorCode == colorCode || colorCode == -1) {
                if (this.selectedSku == null)
                    this.selectedSku = sku;
                colorValue = sku._colorValue;
                for (var sizeIndex = 0; sizeIndex < this.GetSizeDropDown().options.length; sizeIndex++) {
                    var sizeOption = this.GetSizeDropDown().options[sizeIndex];

                    if (sizeOption.value == sku._sizeCode) {
                        var status = this.GetSizeAvailability(sku._sizeCode);
                        if (status == 0)
                            sizeOption.innerHTML = sku._sizeValue;
                        else if (status == 1)
                            sizeOption.innerHTML = sku._sizeValue + " - Sold Out";
                        else
                            sizeOption.innerHTML = sku._sizeValue + " -Coming Soon";

                        if (sizeOption.selected) {
                            this.selectedAvailabilityStatus = status;
                            if (colorCode != -1) {
                                foundSku = true;
                                this.selectedSku = sku;
                            }
                        }
                        break;
                    }
                }
            }
        }

        if (colorCode != -1)
            this.UpdateColorText(colorValue)
        else
            this.UpdateColorText('')

        this.RegenorateProgramDropDown();

        return;
    },

    GetColorAvailability: function(colorCode) {//IsColorSoldOut
        var sizeCode = this.GetSizeDropDown().value;
        var availabilityStatus = 1;
        var skuIndex = 0;
        for (var skuIndex = 0; skuIndex < this.skus.length; skuIndex++) {
            if (this.skus[skuIndex]._colorCode == colorCode) {
                if (this.skus[skuIndex]._sizeCode == sizeCode || sizeCode == -1) {
                    if (this.skus[skuIndex]._availabilityStatus == 0) {
                        availabilityStatus = 0; //available 
                        break;
                    }
                    else if (this.skus[skuIndex]._availabilityStatus == 2) {
                        availabilityStatus = 2; //commming Soon
                    }
                }
            }
        }
        return availabilityStatus;
    },
    GetSizeAvailability: function(sizeCode) { //IsSizeSoldOut
        var colorCode = this.GetColorDropDown().value;

        var availabilityStatus = 1;
        var skuIndex = 0;
        for (var skuIndex = 0; skuIndex < this.skus.length; skuIndex++) {
            if (this.skus[skuIndex]._sizeCode == sizeCode) {
                if (this.skus[skuIndex]._colorCode == colorCode || colorCode == -1) {

                    if (this.skus[skuIndex]._availabilityStatus == 0) {
                        availabilityStatus = 0; //available 
                        break;
                    }
                    else if (this.skus[skuIndex]._availabilityStatus == 2) {
                        availabilityStatus = 2; //commming Soon
                    }
                }
            }
        }

        return availabilityStatus;
    },

    //genorates the size dropdown - listing items as sold out when they are sold out
    //returns the total number of the selected combination
    RegenorateColorDropDown: function(sizeCode) {
        this.selectedSku = null;
        sizeCode = this.GetSizeDropDown().value;

        var skuIndex = 0;
        var sizeValue = '';
        var foundSku = false;
        for (var skuIndex = 0; skuIndex < this.skus.length; skuIndex++) {
            sku = this.skus[skuIndex];

            if (sku._sizeCode == sizeCode || sizeCode == -1) {
                if (this.selectedSku == null)
                    this.selectedSku = sku;
                sizeValue = sku._sizeValue;

                for (var colorIndex = 0; colorIndex < this.GetColorDropDown().options.length; colorIndex++) {
                    var colorOption = this.GetColorDropDown().options[colorIndex];

                    if (colorOption.value == sku._colorCode) {
                        var status = this.GetColorAvailability(sku._colorCode);
                        if (status == 0)
                            colorOption.innerHTML = sku._colorValue;
                        else if (status == 1)
                            colorOption.innerHTML = sku._colorValue + " - Sold Out";
                        else
                            colorOption.innerHTML = sku._colorValue + " -Coming Soon";


                        if (colorOption.selected) {
                            this.selectedAvailabilityStatus = status;
                            if (sizeCode != -1) {
                                foundSku = true;
                                this.selectedSku = sku;
                            }
                        }
                        break;
                    }
                }
            }
        }
        if (sizeCode != -1)
            this.UpdateSizeText(sizeValue);
        else
            this.UpdateSizeText('');

        this.RegenorateProgramDropDown();

        return;
    },

    //displays the correcct in stock message
    //sets the isInStock variable 
    UpdateSkuMessage: function() {
        var messageArea = $(this.name + '_skuMessage');

        if (messageArea) {
            if (this.selectedAvailabilityStatus == 0) {
                messageArea.hide();
                messageArea.innerHTML = '';
            }
            else {
                messageArea.show();
                if (this.GetSizeDropDown().options.length > 1 && this.GetColorDropDown().options.length > 1) {
                    messageArea.innerHTML = 'This combination is not available';
                }
                else {
                    messageArea.innerHTML = 'This option is not available';
                }
            }
        }

    },

    UpdateSelectedSwatch: function() {
        //updates the selected swatch with the drop down selection

        var colorCode = this.GetColorDropDown().value;
        var activeSwatch = $$('img.' + this.name + 'activeSwatch');
        if (activeSwatch.length > 0 && activeSwatch[0] != null) {
            activeSwatch[0].removeClassName('activeSwatch');
            activeSwatch[0].removeClassName(this.name + 'activeSwatch');
        }

        //highlight the correct image 
        if (colorCode != -1 && $(this.name + '_swatch' + colorCode)) {
            $(this.name + '_swatch' + colorCode).addClassName('activeSwatch');
            $(this.name + '_swatch' + colorCode).addClassName(this.name + 'activeSwatch');

            if (this.swatchCarousel) //update the carousel if we have it 
            {
                var swatchIndex = 0; // colorDropDown.selectedIndex; 
                var sName = this.name + '_swatch' + colorCode;
                var existing = this.swatchCarousel.container.childElements();

                if ((existing) && existing.length > 3) {
                    for (var i = 0; i < (existing.length); i++) {
                        var imgElement = existing[i].down(1);
                        if ((imgElement) && (imgElement.id) && imgElement.id == sName) {
                            swatchIndex = i;
                            break;
                        }
                    }
                }
                if (this.swatchCarousel.currentIndex() + 3 <= swatchIndex || this.swatchCarousel.currentIndex() + 1 > swatchIndex) //if we can't see it 
                {
                    this.swatchCarousel.scrollTo(swatchIndex);
                }
            }
        }
    },

    //sets the colordropdown to the color code 
    UpdateColorDropDown: function(colorCode) {
        for (var colorIndex = 0; colorIndex < this.GetColorDropDown().options.length; colorIndex++) {
            if (this.GetColorDropDown().options[colorIndex].value) {
                if (this.GetColorDropDown().options[colorIndex].value == colorCode)
                    this.GetColorDropDown().options[colorIndex].selected = true;
                else
                    this.GetColorDropDown().options[colorIndex].selected = false;
            }
        }
    },

    //use the selectedSku object to update text 
    UpdateColorText: function(colorValue) {
        var textarea = document.getElementById(this.name + 'SelectedColor');
        if (textarea)
            textarea.innerHTML = colorValue;
    },

    //use the selectedSku object to update text 
    UpdateSizeText: function(sizeValue) {
        var textarea = document.getElementById(this.name + 'SelectedSize');
        if (textarea)
            textarea.innerHTML = sizeValue;
    },

    ClearMessages: function() {
        var messageArea = document.getElementById(this.name + '_skuMessage');
        if (messageArea) {
            messageArea.style.display = 'none';
            messageArea.innerHTML = '';
        }
    },

    SetSelectedSku: function() {
        var success = false;
        if (this.product != null) {
            var colorSelect = this.GetColorDropDown().value;
            var sizeSelect = this.GetSizeDropDown().value;

            selectedSku = null;
            var skuMessage = document.getElementById(this.name + '_skuMessage');
            if (skuMessage)
                skuMessage.style.display = "";
            if (sizeSelect > -1 && colorSelect > -1) {
                if (skuMessage) {
                    skuMessage.style.display = "none";
                    skuMessage.innerHTML = '';
                }

                for (var i = 0; i < this.skus.length; i++) {
                    if (this.skus[i]._colorCode == colorSelect && this.skus[i]._sizeCode == sizeSelect) {
                        this.selectedSku = this.skus[i];
                        if (this.skus[i]._availabilityStatus == 0)
                            success = true;
                        else
                            this.UpdateSkuMessage();
                        break;
                    }
                }
            }
            else if (!(sizeSelect > -1) && (colorSelect > -1)) {
                if (skuMessage)
                    skuMessage.innerHTML = "Please select size";
            }
            else if ((sizeSelect > -1) && !(colorSelect > -1)) {
                if (skuMessage)
                    skuMessage.innerHTML = "Please select color";
            }
            else if (!(sizeSelect > -1) && !(colorSelect > -1)) {
                if (skuMessage)
                    skuMessage.innerHTML = "Please select color and size";
            }
        }
        return success;
    },

    AddAndSaveType: function(typeId) {
        if (typeId == null)
            typeId = this.promoTypeId;
        if (typeId == 3)
            return 'GWP';
        else if (typeId == 4)
            return 'PWP';
        else
            return '';
    },

    MakeAjaxCall: function(url) {
        if (typeof XMLHttpRequest != 'undefined')
            req = new XMLHttpRequest();
        else if (window.ActiveXObject)
            req = new ActiveXObject("Microsoft.XMLHTTP"); 	// code for IE6, IE5
        if (req != null) {
            this.closePopup(true);
            req.open("GET", url, true);
            req.onreadystatechange = CartCallBack;
            req.send(null);
            return true;
        }
        else
            return false;
    },

    /********* Add/Accept/Decline Functions *************/

    AddProductToCart: function() {
        if (this.SetSelectedSku() && this.selectedSku) {
            if (this.ValidateProgramDelivery()) {
                var programString = "";
                if (this.GetProgramDropDown() != null && this.GetProgramDropDown().value != '-2' && this.GetProgramDropDown().value != '-1') {
                    programString = "&programcode=" + this.GetProgramDropDown().value;
                }


                var url = '/product/?action=addtocart&familyid=' + this.product._familyID + '&selectedsku=' + this.selectedSku._id + '&qty=1' + programString + '&rand=' + (new Date()).getMilliseconds();


                if (this.MakeAjaxCall(url)) {
                    adjustQuantity = true;
                    showCartFlyout = true;
                    dcsMultiTrack("dcsuri", "/Quickview.aspx", "WT.ti", "QuickView", "WT.si_x", "1", "WT.tx_u", "1", "WT.si_n", "purchase", "WT.tx_e", "a", "WT.pn_sku", this.familyId, "WT.cg_n", "QuickView", "DCSext.VideoView", "", "DCSext.ProductVideoView", "", "DCSext.tabs", "");
                }
            }
        }
    },

    ValidateProgramDelivery: function() {
        //assume it is valid.
        var valid = false;
        var noDeliverySeleced = false;
        //Check to make sure the autoDelviery was selected on this item
        if (this.GetProgramDropDown() != null && this.GetProgramDropDown().value == -2) {
            noDeliverySeleced = true;
        }
        else if (this.GetProgramDropDown() != null && this.GetProgramDropDown().value > -1) {
            //check to make sure we have an auto delivery on this item
            if (this.selectedSku._autoDeliveryPrograms != null) {

                for (var i = 0; i < this.selectedSku._autoDeliveryPrograms.length; i++) {

                    if (this.selectedSku._autoDeliveryPrograms[i].ProgramId == this.GetProgramDropDown().value) {
                        //we found our program
                        valid = true;
                        break;
                    }
                }
            }

        }
        else {
            valid = true;
        }

        if (!valid) {
            if (noDeliverySeleced)
                alert('Please select a Delivery Type');
            else
                alert("invalid program selected");
        }

        return valid;
    },


    QuickBuyProduct: function() {
        if (this.SetSelectedSku() && this.selectedSku) {
            isQuickBuy = true;

            var url = '/product/?action=quickbuy&familyid=' + this.product._familyID + '&selectedsku=' + this.selectedSku._id + '&qty=1' + '&rand=' + (new Date()).getMilliseconds();

            if (this.MakeAjaxCall(url)) {
                adjustQuantity = false;
                showCartFlyout = false;
                //dcsMultiTrack("dcsuri","/Quickview.aspx","WT.ti","QuickView","WT.si_x","1","WT.tx_u","1","WT.si_n","purchase;quickview","WT.tx_e","a","WT.pn_sku",this.familyId,"WT.cg_n","QuickView","DCSext.VideoView","","DCSext.ProductVideoView","","DCSext.tabs","")
            }
        }
    },

    AcceptAddAndSave: function() {
        if (this.SetSelectedSku() && this.isAddAndSave) {
            var url;
            if (isQuickBuy) {
                url = '/product/?action=ViewAddAndSaveAcceptQuickBuy&familyid=' + quickView.parentFamilyId + '&addandsavefamilyid=' + quickView.familyId + '&selectedsku=' + quickView.selectedSku._id + '&qty=1&addandsavepromoid=' + this.promoId + '&addandsavetype=' + this.AddAndSaveType() + '&rand=' + (new Date()).getMilliseconds();
            }
            else {
                url = '/product/?action=ViewAddAndSaveAccept&familyid=' + quickView.parentFamilyId + '&addandsavefamilyid=' + quickView.familyId + '&selectedsku=' + quickView.selectedSku._id + '&qty=1&addandsavepromoid=' + this.promoId + '&addandsavetype=' + this.AddAndSaveType() + '&rand=' + (new Date()).getMilliseconds();
                adjustQuantity = true;
                showCartFlyout = true;
            }
            this.MakeAjaxCall(url)
        }
    },

    DeclineAddAndSave: function() {
        if (this.isAddAndSave) {

            if (isQuickBuy) {
                url = '/product/?action=ViewAddAndSaveDeclineQuickBuy&familyid=' + quickView.parentFamilyId + '&addandsavefamilyid=' + quickView.familyId + '&selectedsku=' + quickView.skus[0]._id + '&qty=1&addandsavepromoid=' + this.promoId + '&addandsavetype=' + this.AddAndSaveType() + '&rand=' + (new Date()).getMilliseconds();
            }
            else {
                url = '/product/?action=ViewAddAndSaveDecline&familyid=' + quickView.parentFamilyId + '&addandsavefamilyid=' + quickView.familyId + '&selectedsku=' + quickView.skus[0]._id + '&qty=1&addandsavepromoid=' + this.promoId + '&addandsavetype=' + this.AddAndSaveType() + '&rand=' + (new Date()).getMilliseconds();
                showCartFlyout = true;
                adjustQuantity = false;

            }
            this.MakeAjaxCall(url)
        }
    }


});


var isQuickBuy = false; 

function SetUpQuickViewData(product)
{
    quickView.SetUpQuickViewData(product)
}

    
    function ParseToMoneyString(n)
    {
	    var t = parseInt(n / 1000); 
		var h = parseInt(n - t *1000); 
		var d = Math.round((n - (t*1000) - h)*100);

		if(d<1)
			d = '00'; 
		else if(d<10)
			d = '0' + d; 

		if(t>0)
		{
			t = t + ','; 
			if (h <1 )
				h = '00' + h ; 
			else if (h < 100)
				h = '0' + h ; 
		}
		else
			t = ''; 

		return t + h + '.' + d;
    }
