﻿
function productInfoInstance()
{this.callBack=0;this.callerContext=0;this.products=new Array();this.totalCount=0;}
var __productInfo=new productInfoInstance();function productInfoComplete(postHttp,success,callerContext)
{productInfoZero();if(success)
productInfoFill(postHttp.responseXML);else
alert(postHttp.statusText+"\r\n"+postHttp.responseText);callerContext.callerContext.callBack(callerContext.callerContext);}
function productInfoZero()
{__productInfo.totalCount=0;while(__productInfo.products.length)
__productInfo.products.pop();}
function productInfoFill(xmlDoc)
{var products=xmlSelectNodes(xmlDoc,"/cache/products");if(products==null)
return;__productInfo.totalCount=xmlSelectNodes(xmlDoc,"/cache/totalcount")[0].nodeValue;var pIndex=0;for(var c=0;c<products.length;c++)
{if(products[c].tagName=="product"&&products[c].childNodes)
{__productInfo.products[pIndex]=new Array();var childNodes=products[c].childNodes;for(var i=0;i<childNodes.length;i++)
{if(childNodes[i].firstChild)
__productInfo.products[pIndex][childNodes[i].tagName]=childNodes[i].firstChild.nodeValue;}
__productInfo.products[pIndex]["media"]=new Array();var media=xmlSelectNodes(xmlDoc,"/cache/products/product/mediafiles");var mIndex=0;for(var ms=0;ms<media.length;ms++)
{if(media[ms].tagName=="media"&&media[ms].childNodes)
{__productInfo.products[pIndex]["media"][mIndex]=new Array();var mediaNodes=media[ms].childNodes;for(var m=0;m<mediaNodes.length;m++)
{if(mediaNodes[m].firstChild)
__productInfo.products[pIndex]["media"][mIndex][mediaNodes[m].tagName]=mediaNodes[m].firstChild.nodeValue;}
mIndex++;}}
pIndex++;}}}
function productInfoGet(catalogId,callerContext)
{__productInfo.callBack=productInfoComplete;__productInfo.callerContext=callerContext;var d=new Date();asyncPostUrl("/WSProductInfo.asmx/RequestProductInfo?__j__="+d.getTime(),"catalogId="+catalogId,__productInfo);}
