﻿// JScript File

function wishListInfoInstance()
{
    this.callBack = 0;
    this.callerContext = 0;
    this.totalCount = 0;
    this.products = new Array();
}

var __wishListInfo = new wishListInfoInstance();

function wishListInfoComplete(postHttp, success, callerContext)
{
    wishListInfoZero();
    if(success)
        wishListInfoFill(postHttp.responseXML);
    else
        alert(postHttp.statusText + "\r\n" + postHttp.responseText);
    callerContext.callerContext.callBack(callerContext.callerContext);    
}

function wishListInfoZero()
{        
    while(__wishListInfo.products.length)
        __wishListInfo.products.pop();
}

function wishListInfoFill(xmlDoc)
{
    __wishListInfo.totalCount = xmlSelectNodes(xmlDoc, "/cache/totalcount")[0].nodeValue;
    var products = xmlSelectNodes(xmlDoc, "/cache/products");
    for(c = 0; c < products.length; c++)
    {
        if(products[c].tagName == "product" && products[c].childNodes)
        {
            var product = new Array();
            var childNodes = products[c].childNodes;
            for(var i = 0; i < childNodes.length; i++)
            {
                if(childNodes[i].firstChild)
                    product[childNodes[i].tagName] = childNodes[i].firstChild.nodeValue;
            }
            __wishListInfo.products.push(product);
        }
    }
}

function wishListInfoGet(callerContext)
{    
    __wishListInfo.callBack = wishListInfoComplete;
    __wishListInfo.callerContext = callerContext;
    var d = new Date();
    asyncPostUrl("/Account/WSWishListInfo.asmx/RequestWishListInfo?__j__=" + d.getTime(), "", __wishListInfo);
}

