﻿Animation = function(width, height)
{
    var __instance = document.createElement('DIV');

    this.__animation =
    {
        instance: null,
        methods:
        {
            owner: null, start: new Function(), stop: new Function()
        },
        fields:
        {
            owner: null, text: '.', length: 5,
            intervals:
            {
                delay: 100, id: -1, emptyID: -1
            }
        }
    }

    this.__animation.methods.owner = this.__animation;
    this.__animation.fields.owner = this.__animation;

    with (__instance)
    {
        with (style) { padding = "2px"; border = '1px solid #a0a0a0'; color = "gray"; }

        appendChild(document.createTextNode('Loading'));
        this.__animation.instance = appendChild(document.createTextNode('.'));
    }

    this.__animation.methods.start = function()
    {
        with (this.owner)
        {
            if (fields.intervals.id == fields.intervals.emptyID)
            {
                instance.nodeValue = fields.text;

                fields.intervals.id = window.setInterval(function()
                {
                    if (instance.nodeValue.length == fields.length)
                    {
                        instance.nodeValue = fields.text;
                    }
                    else
                    {
                        instance.nodeValue += fields.text;
                    }
                }, fields.intervals.delay);
            }
        }
    }

    this.__animation.methods.stop = function()
    {
        with (this.owner.fields.intervals)
        {
            if (id != emptyID)
            {
                window.clearInterval(id);
                id = emptyID;
            }
        }
    }

    /////////////////////////
    this.GetInstance = function()
    {
        return __instance;
    }

    this.Show = function(isRestart)
    {
        __instance.style.display = 'block';
        this.__animation.methods.start();
    }

    this.Hide = function()
    {
        this.__animation.methods.stop();
        __instance.style.display = 'none';
    }

    this.SetWidth = function(value)
    {
        if (isNaN(parseInt(value)))
        {
            __instance.style.width = '100px';
        }
        else
        {
            value -= 6;

            __instance.style.width = (value < 100) ? '100px' : value.toString() + 'px';
        }
    }
    this.SetHeight = function(value)
    {
        if (isNaN(parseInt(value)))
        {
            __instance.style.height = '100px';
        }
        else
        {
            value -= 6;

            __instance.style.height = (value < 100) ? '100px' : value.toString() + 'px';
        }
    }
    this.SetDimension = function(width, height)
    {
        this.SetWidth(width);
        this.SetHeight(height);
    }

    ////////////////////////
    this.SetDimension(width, height);
}

////////////////////////////////////
ProductDetailPopUp = function()
{
    //-- Constructor
    //#region
    var isIE;
    var productDetailPopUp
    var instance, table, closeButton;
    var shadow = {};
    var entries = {};

    isIE = window.navigator.userAgent.indexOf('MSIE');

    productDetailPopUp = this;
    instance = document.createElement('DIV');
    table = instance.appendChild(document.createElement('TABLE'));
    shadow['1'] = document.body.appendChild(document.createElement('DIV'));
    shadow['2'] = document.body.appendChild(document.createElement('DIV'));
    shadow['3'] = document.body.appendChild(document.createElement('DIV'));

    entries =
{
    styleName: '', price: '', width: '', metalType: '', ringSize: '', numberOfSideDiamond: '',
    shapesOfSideDiamond: '', totalCaratWeight: '', centerDiamondCaratRange: '', shapesOfCenterDiamond: '',
    images:
    {
        basePath: '',
        large: { instance: null, animation: null, GetPath: new Function(), SetPath: new Function(), path: '' },
        front: { instance: null, animation: null, GetPath: new Function(), SetPath: new Function(), paths: { small: '', large: '', 'default': ''} },
        side: { instance: null, animation: null, GetPath: new Function(), SetPath: new Function(), paths: { small: '', large: '', 'default': ''} },
        profile: { instance: null, animation: null, GetPath: new Function(), SetPath: new Function(), paths: { small: '', large: '', 'default': ''} }
    }
};

    with (instance)
    {
        with (style)
        {
            cursor = 'default';
            fontSize = '11px';
            display = 'none';
            border = 'solid 1px #a0a0a0';
            backgroundColor = 'white';
            padding = '10px';
            overflow = 'auto';
            zIndex = '9999';
            position = 'absolute';
            position = 'fixed';
        }
    }
    with (table)
    {
        var row, cell;

        with (style)
        {
            display = 'none';
            textAlign = 'left';
            borderCollapse = 'collapse';
            //width = '100%';
        }

        //-- Logo
        with (insertRow(rows.length))
        {
            with (insertCell(cells.length))
            {
                with (style) { fontWeight = 'bold'; }

                with (appendChild(document.createElement('IMG')))
                {
                    src = '../Images/logo_zales.jpg';
                    alt = 'Zales\'s Logo';
                }
            }
            with (insertCell(cells.length))
            {
                with (style) { textAlign = 'right'; verticalAlign = 'top'; }

                //-- Close Button
                closeButton = appendChild(document.createElement('A'));
                with (closeButton)
                {
                    href = 'javascript:void(0);';

                    closeButton.onclick = function()
                    {
                        productDetailPopUp.Hide();
                    }

                    with (style) { fontSize = '9px'; color = 'blue'; }

                    appendChild(document.createTextNode('Close Window'));
                }
            }
        }

        //-- Caption
        with (insertRow(rows.length))
        {
            with (insertCell(cells.length))
            {
                with (style) { fontSize = '12px'; fontWeight = 'bold'; }

                appendChild(document.createTextNode('Setting Details'));
            }
        }

        //-- Details
        with (insertRow(rows.length))
        {
            with (style) { borderBottom = '#a0a0a0 1px solid'; }

            with (insertCell(cells.length))
            {
                with (style) { fontWeight = 'bold'; verticalAlign = 'top'; borderBottom = '#a0a0a0 1px solid'; }

                //-- Image
                with (appendChild(document.createElement('TABLE')))
                {
                    with (insertRow(rows.length))
                    {
                        with (insertCell(cells.length))
                        {
                            //-- Side Image
                            entries.images.side.instance = appendChild(document.createElement('IMG'));
                            with (entries.images.side.instance)
                            {
                                with (style) { width = '110px'; height = '110px'; }

                                onload = function()
                                {
                                    if (entries.images.side.animation) { entries.images.side.animation.Hide(); }

                                    this.style.display = 'block';
                                }
                                onmouseover = function()
                                {
                                    if (entries.images.large.GetPath() != entries.images.side.paths.large)
                                    {
                                        //entries.images.large.SetPath(entries.images.side.paths.large);
                                        entries.images.large.instance.src = entries.images.side.paths.large
                                    }
                                }
                                onmouseout = function()
                                {
                                    if (entries.images.large.GetPath() != entries.images.side.paths['default'])
                                    {
                                        //entries.images.large.SetPath(entries.images.side.paths['default']);
                                        entries.images.large.instance.src = entries.images.side.paths['default'];
                                    }
                                }
                            }

                            //-- Animation
                            var animation = new Animation(110, 110);

                            appendChild(animation.GetInstance());

                            entries.images.side.animation = animation;
                            entries.images.side.GetPath = function()
                            {
                                return this.instance.src;
                            }
                            entries.images.side.SetPath = function(value)
                            {
                                this.instance.style.display = 'none';
                                this.animation.Show();
                                this.instance.src = value;
                            }
                        }

                        with (insertCell(cells.length))
                        {
                            rowSpan = 2;

                            //-- Large Image
                            entries.images.large.instance = appendChild(document.createElement('IMG'));
                            with (entries.images.large.instance)
                            {
                                with (style) { width = '200px'; height = '200px'; }

                                onload = function()
                                {
                                    if (entries.images.large.animation) { entries.images.large.animation.Hide(); }

                                    this.style.display = 'block';
                                }
                            }

                            //-- Animation
                            var animation = new Animation(200, 200);

                            appendChild(animation.GetInstance());

                            entries.images.large.animation = animation;
                            entries.images.large.GetPath = function()
                            {
                                return this.instance.src;
                            }
                            entries.images.large.SetPath = function(value)
                            {
                                this.instance.style.display = 'none';
                                this.animation.Show();
                                this.instance.src = value;
                            }
                        }
                    }
                    with (insertRow(rows.length))
                    {
                        with (insertCell(cells.length))
                        {
                            //-- Profile Image
                            entries.images.profile.instance = appendChild(document.createElement('IMG'));
                            with (entries.images.profile.instance)
                            {
                                with (style) { width = '110px'; height = '110px'; }

                                onload = function()
                                {
                                    if (entries.images.profile.animation) { entries.images.profile.animation.Hide(); }

                                    this.style.display = 'block';
                                }
                                onmouseover = function()
                                {
                                    if (entries.images.large.GetPath() != entries.images.side.paths.large)
                                    {
                                        //entries.images.large.SetPath(entries.images.profile.paths.large);
                                        entries.images.large.instance.src = entries.images.profile.paths.large;
                                    }
                                }
                                onmouseout = function()
                                {
                                    if (entries.images.large.GetPath() != entries.images.side.paths['default'])
                                    {
                                        //entries.images.large.SetPath(entries.images.profile.paths['default']);
                                        entries.images.large.instance.src = entries.images.profile.paths['default'];
                                    }
                                }
                            }

                            //-- Animation
                            var animation = new Animation(110, 110);

                            appendChild(animation.GetInstance());

                            entries.images.profile.animation = animation;
                            entries.images.profile.GetPath = function()
                            {
                                return this.instance.src;
                            }
                            entries.images.profile.SetPath = function(value)
                            {
                                this.instance.style.display = 'none';
                                this.animation.Show();
                                this.instance.src = value;
                            }
                        }
                    }
                }
            }

            with (insertCell(cells.length))
            {
                with (style) { verticalAlign = 'top'; borderBottom = '#a0a0a0 1px solid'; }

                //-- Information
                with (appendChild(document.createElement('TABLE')))
                {
                    with (style) { borderCollapse = 'collapse'; backgroundColor = 'white'; }

                    //-- Style Number
                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Style #:'));
                        }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; whiteSpace = 'nowrap'; borderBottom = '#a0a0a0 1px solid'; }

                            entries.styleName = appendChild(document.createTextNode('64-S0229'));
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Price (without center diamond):'));
                        }

                        //-- Price
                        with (insertCell(cells.length))
                        {
                            with (style) { borderBottom = '#a0a0a0 1px solid'; }

                            entries.price = appendChild(document.createTextNode('$1,2623.78*'));
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Width (at widest point):'));
                        }

                        //-- Width
                        with (insertCell(cells.length))
                        {
                            with (style) { borderBottom = '#a0a0a0 1px solid'; }

                            entries.width = appendChild(document.createTextNode('8mm'));
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Number of side diamonds:'));
                        }

                        //-- Number of side diamond
                        with (insertCell(cells.length))
                        {
                            with (style) { borderBottom = '#a0a0a0 1px solid'; }

                            entries.numberOfSideDiamond = appendChild(document.createTextNode('20'));
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; verticalAlign = 'top'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Shape(s) of side diamond:'));
                        }

                        //-- Shape(s) of side diamond
                        with (entries.shapesOfSideDiamond = insertCell(cells.length))
                        {
                            with (style) { borderBottom = '#a0a0a0 1px solid'; }

                            innerHTML = '&nbsp;';
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Total carat weight of side diamond:'));
                        }

                        //-- Total carat weight of side diamond
                        with (insertCell(cells.length))
                        {
                            with (style) { borderBottom = '#a0a0a0 1px solid'; }

                            entries.totalCaratWeight = appendChild(document.createTextNode('0.37'));
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (style) { borderBottom = '#a0a0a0 1px solid'; }

                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; borderBottom = '#a0a0a0 1px solid'; }

                            appendChild(document.createTextNode('Center diamond carat weight range:'));
                        }

                        //-- Center diamond carat weight range
                        with (insertCell(cells.length))
                        {
                            with (style) { borderBottom = '#a0a0a0 1px solid'; }

                            entries.centerDiamondCaratRange = appendChild(document.createTextNode('0.5 - 10.5'));
                        }
                    }

                    with (insertRow(rows.length))
                    {
                        with (insertCell(cells.length))
                        {
                            with (style) { fontWeight = 'bold'; verticalAlign = 'top'; }

                            appendChild(document.createTextNode('Center diamond shape choices:'));
                        }

                        //-- Shape(s) of center diamond
                        with (entries.shapesOfCenterDiamond = insertCell(cells.length))
                        {
                            innerHTML = '&nbsp;';
                        }
                    }
                }
            }
        }

        //-- Notice
        with (insertRow(rows.length))
        {
            with (insertCell(cells.length))
            {
                colSpan = 2;
                with (style) { paddingTop = '10px'; }

                //appendChild(document.createTextNode('This setting is available in your choice of six different precious metals. All '));
                //appendChild(document.createElement('BR'));
                //appendChild(document.createTextNode('side diamonds are professionally matched as closely as possible in color'));
                //appendChild(document.createElement('BR'));
                //appendChild(document.createTextNode('and clarity to the center diamond you select.'));

                appendChild(document.createTextNode('This setting is available in your choice of six different precious metals.'));
                appendChild(document.createElement('BR'));
                appendChild(document.createTextNode('All side diamonds are professionally matched as closely as possible in color and clarity to the center diamond you select.'));

                //appendChild(document.createTextNode('This setting is available in your choice of six different precious metals. All side diamonds are professionally matched as closely as possible in color as closely as possible in color and clarity to the center diamond you select.'));
            }
        }

        with (insertRow(rows.length))
        {
            with (insertCell(cells.length))
            {
                colSpan = 2;
                with (style) { paddingTop = '10px'; }

                //entries.metalType = appendChild(document.createTextNode('*Price when made with 14K Precise White Gold, ring size 7.00'));
                appendChild(document.createTextNode('*Price when made with '));
                entries.metalType = appendChild(document.createTextNode('14K Precise White Gold'));
                appendChild(document.createTextNode(', ring size '));
                entries.ringSize = appendChild(document.createTextNode('7.00'));
            }
        }
    }

    for (var shade in shadow)
    {
        with (shadow[shade].style)
        {
            display = 'none';
            zIndex = '9999';
            position = 'absolute';
            position = 'fixed';
            backgroundColor = 'gray';
            switch (shade)
            {
                case '1': opacity = 0.7; break;
                case '2': opacity = 0.5; break;
                case '3': opacity = 0.3; break;
            }
            if (isIE) { filter = 'alpha(opacity=' + (opacity * 100).toString() + ')'; }
        }
    }
    document.body.appendChild(instance);
    //#endregion

    ////////////////////////////////////////////////////////
    this.Margin = 20;

    this.GetInstance = function() { return instance; }
    this.SetVerticalAlignment = function(value) { }
    //    this.ImagePaths = { Front: '', Side: '', Large: '' };
    //    this.SetImagePaths = function()
    //    {
    //        //this.SetSideImagePath(ProductDetailPopUp.ImagePaths.Side);
    //        //this.SetProfileImagePath(ProductDetailPopUp.ImagePaths.Front);
    //        //this.SetLargeImagePath(ProductDetailPopUp.ImagePaths.Large);
    //    }
    this.GetImageBasePath = function() { return entries.images.basePath; }
    this.SetImageBasePath = function(value) { entries.images.basePath = value; }
    this.GetLargeImagePath = function() { return entries.images.large.instance.src; }
    this.SetLargeImagePath = function(value)
    {
        with (entries.images.large)
        {
            SetPath(value);
            //instance.src = value;
            path = value;
        }
    }
    this.SetSideImagePath = function() { return entries.images.side.instance.src; }
    this.SetSideImagePath = function(values)
    {
        with (entries.images.side)
        {
            SetPath(values[0]);
            //instance.src = values[0];
            paths.small = values[0];
            paths.large = values[1];
            paths['default'] = values[2];
        }
    }
    this.GetProfileImagePath = function() { return entries.images.profile.instance.src; }
    this.SetProfileImagePath = function(values)
    {
        with (entries.images.profile)
        {
            SetPath(values[0]);
            //instance.src = values[0];
            paths.small = values[0];
            paths.large = values[1];
            paths['default'] = values[2];
        }
    }
    this.GetStyleName = function() { return entries.styleName.nodeValue; }
    this.SetStyleName = function(value) { entries.styleName.nodeValue = value; }
    this.GetPrice = function() { return entries.price.nodeValue; }
    this.SetPrice = function(value) { entries.price.nodeValue = value; }
    this.GetWidth = function() { return entries.width.nodeValue; }
    this.SetWidth = function(value) { entries.width.nodeValue = value; }
    this.GetNumberOfSideDiamond = function() { return entries.numberOfSideDiamond.nodeValue; }
    this.SetNumberOfSideDiamond = function(value) { entries.numberOfSideDiamond.nodeValue = value; }
    this.GetShapesOfSideDiamond = function() { return entries.shapesOfSideDiamond.innerHTML; }
    this.SetShapesOfSideDiamond = function(value) { entries.shapesOfSideDiamond.innerHTML = value; }
    this.GetTotalCaratWeightOfSideDiamond = function() { return entries.totalCaratWeight.nodeValue; }
    this.SetTotalCaratWeightOfSideDiamond = function(value) { entries.totalCaratWeight.nodeValue = value; }
    this.GetCaratWeightRangeOfCenterDiamond = function() { return entries.centerDiamondCaratRange.nodeValue; }
    this.SetCaratWeightRangeOfCenterDiamond = function(value) { entries.centerDiamondCaratRange.nodeValue = value; }
    this.GetShapesOfCenterDiamond = function() { return entries.shapesOfCenterDiamond.innerHTML; }
    this.SetShapesOfCenterDiamond = function(value) { entries.shapesOfCenterDiamond.innerHTML = value; }
    this.GetMetalType = function() { entries.metalType.nodeValue; }
    this.SetMetalType = function(value) { entries.metalType.nodeValue = value; }
    this.GetRingSize = function() { entries.ringSize.nodeValue; }
    this.SetRingSize = function(value) { entries.ringSize.nodeValue = value; }

    this.Reset = function()
    {
        this.SetPrice('Waiting...');
        //this.SetNumberOfSideDiamond('0');
        //this.SetTotalCaratWeightOfSideDiamond('0.00');
        //this.SetCaratWeightRangeOfCenterDiamond('0.00');
        this.SetWidth('Waiting...');
        this.SetNumberOfSideDiamond('Waiting...');
        this.SetTotalCaratWeightOfSideDiamond('Waiting...');
        this.SetCaratWeightRangeOfCenterDiamond('Waiting...');
        this.SetMetalType('Waiting...');
        this.SetRingSize('Waiting...');
        this.SetLargeImagePath('');
        this.SetSideImagePath(['', '', '']);
        this.SetProfileImagePath(['', '', '']);
        this.SetShapesOfSideDiamond('Waiting...');
        this.SetShapesOfCenterDiamond('Waiting...');
        this.Show();
    }

    this.Show = function()
    {
        var rect, availHeightProductDetailPopUp, offsetPaddingProductDetailPopUp;

        instance.style.height = 'auto';
        instance.style.display = 'block';
        table.style.display = 'block';

        //document.body.style.height = document.body.scrollHeight.toString() + 'px';

        offsetPaddingProductDetailPopUp = instance.offsetHeight - table.offsetHeight;
        availHeightProductDetailPopUp = document.documentElement.clientHeight - (this.Margin * 2);

        if (instance.offsetHeight > availHeightProductDetailPopUp)
        {
            instance.style.height = (availHeightProductDetailPopUp - offsetPaddingProductDetailPopUp).toString() + 'px';
        }

        instance.style.top = ((document.documentElement.clientHeight - instance.offsetHeight) / 2).toString() + 'px';
        instance.style.left = ((document.body.offsetWidth - instance.offsetWidth) / 2).toString() + 'px';

        shadow['1'].style.display = 'block';
        shadow['2'].style.display = 'block';
        shadow['3'].style.display = 'block';

        shadow['1'].style.width = (instance.offsetWidth - 5).toString() + 'px';
        shadow['2'].style.width = shadow['1'].style.width;
        shadow['3'].style.width = shadow['1'].style.width;

        shadow['1'].style.height = (instance.offsetHeight - 5).toString() + 'px';
        shadow['2'].style.height = shadow['1'].style.height;
        shadow['3'].style.height = shadow['1'].style.height;

        rect = { top: parseInt(instance.style.top.replace('px', '')), right: 'auto', bottom: 'auto', left: parseInt(instance.style.left.replace('px', '')) };

        shadow['1'].style.top = (rect.top + 6).toString() + 'px';
        shadow['2'].style.top = (rect.top + 7).toString() + 'px';
        shadow['3'].style.top = (rect.top + 8).toString() + 'px';

        shadow['1'].style.left = (rect.left + 6).toString() + 'px';
        shadow['2'].style.left = (rect.left + 7).toString() + 'px';
        shadow['3'].style.left = (rect.left + 8).toString() + 'px';
    }

    this.Hide = function()
    {
        shadow['1'].style.display = 'none';
        shadow['2'].style.display = 'none';
        shadow['3'].style.display = 'none';

        window.setTimeout(function()
        {
            instance.style.width = instance.offsetWidth.toString() + 'px';
            instance.style.height = instance.offsetHeight.toString() + 'px';
            table.style.display = 'none';

            var repeat = 4;
            var step = { width: parseInt(instance.offsetWidth / repeat), height: parseInt(instance.offsetHeight / repeat) };
            var handle = window.setInterval(function()
            {
                if (repeat < 1)
                {
                    window.clearInterval(handle);
                    instance.style.display = 'none';
                    instance.style.width = 'auto';
                    instance.style.height = 'auto';
                }
                else
                {
                    instance.style.width = (instance.offsetWidth - step.width).toString() + 'px';
                    instance.style.height = (instance.offsetHeight - step.height).toString() + 'px';
                    repeat--;
                }
            }, 25);
        }, 1);

    }
    this.IsVisible = function() { return (instance.style.display == 'block'); }

    //////////////////////////////
    this.WebServices = {};
    this.WebServices.owner = this;
    this.WebServices.GetProductDetailCallback = function(value)
    {
        var values = eval('(' + value + ')');
        var imageBasePath = this.owner.GetImageBasePath();

        this.owner.SetLargeImagePath(imageBasePath + values.FrontLargeImageName);
        this.owner.SetSideImagePath([imageBasePath + values.SideImagePath[0], imageBasePath + values.SideImagePath[1], imageBasePath + values.SideImagePath[2]]);
        this.owner.SetProfileImagePath([imageBasePath + values.ProfileImagePath[0], imageBasePath + values.ProfileImagePath[1], imageBasePath + values.ProfileImagePath[2]]);
        this.owner.SetWidth(values.WidthMax);
        this.owner.SetNumberOfSideDiamond(values.NumberOfSideDiamond);
        this.owner.SetTotalCaratWeightOfSideDiamond(values.TotalCaratWeightOfSideDiamond);
        this.owner.SetShapesOfSideDiamond(values.ShapesOfSideDiamond);
        this.owner.SetCaratWeightRangeOfCenterDiamond(values.CenterStoneMinCarat + ' - ' + values.CenterStoneMaxCarat);
        this.owner.SetShapesOfCenterDiamond(values.ShapesOfCenterDiamond);
        this.owner.Show();
    }
    this.WebServices.GetProductDetail = function(settingNo, shapeCode, metalCode, metalType, prongType, isAsync, callback)
    {
        switch (arguments.length)
        {
            case 4: return ''; break;
            default: if ((arguments[0] == '') || (arguments[1] == '') || (arguments[2] == '') || (arguments[3] == '') || (arguments[4] == '')) { return ''; } break;
        }

        var soapMessage;
        var caller = this;
        var xmlhttp = (window.XMLHttpRequest) ? new window.XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');

        if (isAsync)
        {
            xmlhttp.onreadystatechange = function()
            {
                if (xmlhttp.readyState == 4)
                {
                    if (xmlhttp.status == 200)
                    {
                        var value = xmlhttp.responseXML.getElementsByTagName('GetProductDetailResult')[0].firstChild.nodeValue;

                        if (typeof (callback) == 'function')
                        {
                            callback.call(caller, value, settingNo, shapeCode, metalCode, metalType, prongType);
                        }
                    }
                }
            }
        }
        xmlhttp.open('POST', 'Ering.asmx', isAsync);

        xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
        xmlhttp.setRequestHeader('SOAPAction', 'http://tempuri.org/GetProductDetail');

        soapMessage = '<?xml version="1.0" encoding="utf-8"?>';
        soapMessage += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
        soapMessage += '<soap:Body><GetProductDetail xmlns="http://tempuri.org/">';
        soapMessage += '<settingNo>' + settingNo + '</settingNo>';
        soapMessage += '<shapeCode>' + shapeCode + '</shapeCode>';
        soapMessage += '<metalCode>' + metalCode + '</metalCode>';
        soapMessage += '<metalType>' + metalType + '</metalType>';
        soapMessage += '<prongType>' + prongType + '</prongType>';
        soapMessage += '</GetProductDetail></soap:Body></soap:Envelope>';

        xmlhttp.send(soapMessage);

        if (isAsync)
        {
            return xmlhttp;
        }
        else
        {
            var response = xmlhttp.responseXML.getElementsByTagName('GetProductDetailResult')[0].firstChild;

            return (response) ? response.nodeValue : '';
        }
    }
}
