function ShoppingCart(){  this.clear();}ShoppingCart.prototype.clearStaticPages = function(){  // this.totalStaticPagesCount = 0;  this.totalStaticPagesProgressCount = 0;  this.totalStaticPagesProgressPercents = 0;  this.totalStaticPagesRecreated = 0;  this.totalStaticPagesErrors = 0;  this.updateHtml();}ShoppingCart.prototype.clearTemplatesPages = function(){  this.clearStaticPages();  // this.templatesPagesCount = 0;  this.templatesPagesProgressCount = 0;  this.templatesPagesProgressPercents  = 0;  this.templatesPagesRecreated = 0;  this.templatesPagesErrors = 0;  this.updateHtml();}ShoppingCart.prototype.clearCategoriesPages = function(){  this.clearStaticPages();  // this.categoriesPagesCount = 0;  this.categoriesPagesProgressCount = 0;  this.categoriesPagesProgressPercents  = 0;  this.categoriesPagesRecreated = 0;  this.categoriesPagesErrors = 0;  this.updateHtml();}ShoppingCart.prototype.clearProductsPages = function(){  this.clearStaticPages();  // this.productsPagesCount = 0;  this.productsPagesProgressCount = 0;  this.productsPagesProgressPercents  = 0;  this.productsPagesRecreated = 0;  this.productsPagesErrors = 0;  this.updateHtml();}ShoppingCart.prototype.clear = function(){  // this.totalStaticPagesCount = 0;  this.totalStaticPagesProgressCount = 0;  this.totalStaticPagesProgressPercents = 0;  this.totalStaticPagesRecreated = 0;  this.totalStaticPagesErrors = 0;  // this.templatesPagesCount = 0;  this.templatesPagesProgressCount = 0;  this.templatesPagesProgressPercents  = 0;  this.templatesPagesRecreated = 0;  this.templatesPagesErrors = 0;  // this.categoriesPagesCount = 0;  this.categoriesPagesProgressCount = 0;  this.categoriesPagesProgressPercents  = 0;  this.categoriesPagesRecreated = 0;  this.categoriesPagesErrors = 0;  // this.productsPagesCount = 0;  this.productsPagesProgressCount = 0;  this.productsPagesProgressPercents  = 0;  this.productsPagesRecreated = 0;  this.productsPagesErrors = 0;  this.updateHtml();}ShoppingCart.prototype.updateHtml = function(){  this.totalStaticPagesProgressCount = this.templatesPagesProgressCount + this.categoriesPagesProgressCount + this.productsPagesProgressCount;  this.totalStaticPagesProgressPercents = Math.ceil(((this.totalStaticPagesProgressCount / this.totalStaticPagesCount) *  100));  this.totalStaticPagesErrors = this.templatesPagesErrors + this.categoriesPagesErrors + this.productsPagesErrors;  var spanObject = document.getElementById("totalStaticPagesCount");  if (spanObject != null)  {    spanObject.innerHTML = this.totalStaticPagesCount;  }  spanObject = document.getElementById("totalStaticPagesProgressPercents");  if (spanObject != null)  {    spanObject.innerHTML = this.totalStaticPagesProgressPercents;  }  spanObject = document.getElementById("totalStaticPagesRecreated");  if (spanObject != null)  {    spanObject.innerHTML = this.totalStaticPagesRecreated;  }  spanObject = document.getElementById("totalStaticPagesErrors");  if (spanObject != null)  {    spanObject.innerHTML = this.totalStaticPagesErrors;  }    spanObject = document.getElementById("templatesPagesCount");  if (spanObject != null)  {    spanObject.innerHTML = this.templatesPagesCount;  }  spanObject = document.getElementById("templatesPagesProgressPercents");  if (spanObject != null)  {    spanObject.innerHTML = this.templatesPagesProgressPercents;  }  spanObject = document.getElementById("templatesPagesRecreated");  if (spanObject != null)  {    spanObject.innerHTML = this.templatesPagesRecreated;  }  spanObject = document.getElementById("templatesPagesErrors");  if (spanObject != null)  {    spanObject.innerHTML = this.templatesPagesErrors;  }    spanObject = document.getElementById("categoriesPagesCount");  if (spanObject != null)  {    spanObject.innerHTML = this.categoriesPagesCount;  }  spanObject = document.getElementById("categoriesPagesProgressPercents");  if (spanObject != null)  {    spanObject.innerHTML = this.categoriesPagesProgressPercents;  }  spanObject = document.getElementById("categoriesPagesRecreated");  if (spanObject != null)  {    spanObject.innerHTML = this.categoriesPagesRecreated;  }  spanObject = document.getElementById("categoriesPagesErrors");  if (spanObject != null)  {    spanObject.innerHTML = this.categoriesPagesErrors;  }    spanObject = document.getElementById("productsPagesCount");  if (spanObject != null)  {    spanObject.innerHTML = this.productsPagesCount;  }  spanObject = document.getElementById("productsPagesProgressPercents");  if (spanObject != null)  {    spanObject.innerHTML = this.productsPagesProgressPercents;  }  spanObject = document.getElementById("productsPagesRecreated");  if (spanObject != null)  {    spanObject.innerHTML = this.productsPagesRecreated;  }  spanObject = document.getElementById("productsPagesErrors");  if (spanObject != null)  {    spanObject.innerHTML = this.productsPagesErrors;  }    spanObject = document.getElementById("doneSpan");  if (spanObject != null)  {    if (this.isCompleted())    {      spanObject.style.display = "block";    }    else    {      spanObject.style.display = "none";    }  }}ShoppingCart.prototype.isCompleted = function(){  if (this.totalStaticPagesCount == (this.templatesPagesProgressCount + this.categoriesPagesProgressCount + this.productsPagesProgressCount))  {    return true;  }  return false;}ShoppingCart.prototype.recreateTemplatesPages = function(url){  this.url = url;  this.clearTemplatesPages();  var ac = new AjaxCommunicator();  ac.setUrl(url);  ac.setParameter("command","get_templates_pages");  ac.invoke("",            "clsShoppingCart.onGetTemplatesPagesSuccess",            "clsShoppingCart.onGetTemplatesPagesError");              spanObject = document.getElementById("templatesPagesImage");  if (spanObject != null)  {    spanObject.style.visibility = "visible";  }            }ShoppingCart.prototype.recreateCategoriesPages = function(url){  this.url = url;  this.clearCategoriesPages();  var ac = new AjaxCommunicator();  ac.setUrl(url);  ac.setParameter("command","get_categories_pages");  ac.invoke("",            "clsShoppingCart.onGetCategoriesPagesSuccess",            "clsShoppingCart.onGetCategoriesPagesError");  spanObject = document.getElementById("categoriesPagesImage");  if (spanObject != null)  {    spanObject.style.visibility = "visible";  }            }ShoppingCart.prototype.recreateProductsPages = function(url){  this.url = url;  this.clearProductsPages();  var ac = new AjaxCommunicator();  ac.setUrl(url);  ac.setParameter("command","get_products_pages");  ac.invoke("",            "clsShoppingCart.onGetProductsPagesSuccess",            "clsShoppingCart.onGetProductsPagesError");  spanObject = document.getElementById("productsPagesImage");  if (spanObject != null)  {    spanObject.style.visibility = "visible";  }            }ShoppingCart.prototype.recreateAllPages = function(url){  this.url = url;  this.clear();  this.recreateTemplatesPages(url);  this.recreateCategoriesPages(url);  this.recreateProductsPages(url);}ShoppingCart.prototype.onGetTemplatesPagesSuccess = function(parameters,                                                             ajaxCommunicator,                                                             responseText,                                                             responseXMLObject){  var tags = responseXMLObject.getElementsByTagName("template_tag");  for(var i=0; i<tags.length; i+=10)   {    var ids = "";    var to = (i + 10);    if (tags.length < to)    {      to = tags.length;    }    for (var j=i; j<to; j++)     {      if (ids == "")      {        ids += tags[j].firstChild.nodeValue;      }      else      {        ids += "," + tags[j].firstChild.nodeValue;      }    }    var ac = new AjaxCommunicator();    ac.setUrl(this.url);    ac.setParameter("command","recreate_template_page");    ac.setParameter("template_tag",ids);    ac.invoke("",              "clsShoppingCart.onRecreateTemplatePageSuccess",              "clsShoppingCart.onRecreateTemplatePageError");  }  this.updateHtml();}ShoppingCart.prototype.onGetTemplatesPagesError = function(parameters,                                                           ajaxCommunicator,                                                           responseText,                                                           responseXMLObject){  // to do}ShoppingCart.prototype.onRecreateTemplatePageSuccess = function(parameters,                                                                ajaxCommunicator,                                                                responseText,                                                                responseXMLObject){  this.templatesPagesProgressCount += parseInt(responseXMLObject.getElementsByTagName("recreated_pages_count")[0].firstChild.nodeValue) + parseInt(responseXMLObject.getElementsByTagName("not_recreated_pages_count")[0].firstChild.nodeValue);  this.templatesPagesProgressPercents = Math.ceil(((this.templatesPagesProgressCount / this.templatesPagesCount) *  100));  if (responseXMLObject.getElementsByTagName("recreated")[0].firstChild.nodeValue == "True")  {    this.templatesPagesRecreated += parseInt(responseXMLObject.getElementsByTagName("recreated_pages_count")[0].firstChild.nodeValue);  }  spanObject = document.getElementById("templatesPagesImage");  if (spanObject != null)  {    if (this.templatesPagesCount == this.templatesPagesProgressCount)    {      spanObject.style.visibility = "hidden";    }  }  this.updateHtml();}ShoppingCart.prototype.onRecreateTemplatePageError = function(parameters,                                                              ajaxCommunicator,                                                              responseText,                                                              responseXMLObject){  // to do  this.templatesPagesErrors++;  this.updateHtml();}ShoppingCart.prototype.onGetCategoriesPagesSuccess = function(parameters,                                                              ajaxCommunicator,                                                              responseText,                                                              responseXMLObject){  var tags = responseXMLObject.getElementsByTagName("category_id");  for(var i=0; i<tags.length; i+=20)   {    var ids = "";    var to = (i + 20);    if (tags.length < to)    {      to = tags.length;    }    for (var j=i; j<to; j++)     {      if (ids == "")      {        ids += tags[j].firstChild.nodeValue;      }      else      {        ids += "," + tags[j].firstChild.nodeValue;      }    }    var ac = new AjaxCommunicator();    ac.setUrl(this.url);    ac.setParameter("command","recreate_category_page");    ac.setParameter("category_id",ids);    ac.invoke("",              "clsShoppingCart.onRecreateCategoryPageSuccess",              "clsShoppingCart.onRecreateCategoryPageError");  }  this.updateHtml();}ShoppingCart.prototype.onGetCategoriesPagesError = function(parameters,                                                            ajaxCommunicator,                                                            responseText,                                                            responseXMLObject){  // to do}ShoppingCart.prototype.onRecreateCategoryPageSuccess = function(parameters,                                                                ajaxCommunicator,                                                                responseText,                                                                responseXMLObject){  this.categoriesPagesProgressCount += parseInt(responseXMLObject.getElementsByTagName("recreated_pages_count")[0].firstChild.nodeValue) + parseInt(responseXMLObject.getElementsByTagName("not_recreated_pages_count")[0].firstChild.nodeValue);  this.categoriesPagesProgressPercents = Math.ceil(((this.categoriesPagesProgressCount / this.categoriesPagesCount) *  100));  if (responseXMLObject.getElementsByTagName("recreated")[0].firstChild.nodeValue == "True")  {    this.categoriesPagesRecreated += parseInt(responseXMLObject.getElementsByTagName("recreated_pages_count")[0].firstChild.nodeValue);  }  spanObject = document.getElementById("categoriesPagesImage");  if (spanObject != null)  {    if (this.categoriesPagesCount == this.categoriesPagesProgressCount)    {      spanObject.style.visibility = "hidden";    }  }  this.updateHtml();}ShoppingCart.prototype.onRecreateCategoryPageError = function(parameters,                                                              ajaxCommunicator,                                                              responseText,                                                              responseXMLObject){  this.categoriesPagesErrors++;  this.updateHtml();}ShoppingCart.prototype.onGetProductsPagesSuccess = function(parameters,                                                            ajaxCommunicator,                                                            responseText,                                                            responseXMLObject){  var tags = responseXMLObject.getElementsByTagName("product_id");  for(var i=0; i<tags.length; i+=20)   {    var ids = "";    var to = (i + 20);    if (tags.length < to)    {      to = tags.length;    }    for (var j=i; j<to; j++)     {      if (ids == "")      {        ids += tags[j].firstChild.nodeValue;      }      else      {        ids += "," + tags[j].firstChild.nodeValue;      }    }      var ac = new AjaxCommunicator();    ac.setUrl(this.url);    ac.setParameter("command","recreate_product_page");    ac.setParameter("product_id",ids);    ac.invoke("",              "clsShoppingCart.onRecreateProductPageSuccess",              "clsShoppingCart.onRecreateProductPageError");  }  this.updateHtml();}ShoppingCart.prototype.onGetProductsPagesError = function(parameters,                                                          ajaxCommunicator,                                                          responseText,                                                          responseXMLObject){  // to do}ShoppingCart.prototype.onRecreateProductPageSuccess = function(parameters,                                                               ajaxCommunicator,                                                               responseText,                                                               responseXMLObject){  this.productsPagesProgressCount += parseInt(responseXMLObject.getElementsByTagName("recreated_pages_count")[0].firstChild.nodeValue) + parseInt(responseXMLObject.getElementsByTagName("not_recreated_pages_count")[0].firstChild.nodeValue);  this.productsPagesProgressPercents = Math.ceil(((this.productsPagesProgressCount / this.productsPagesCount) *  100));  if (responseXMLObject.getElementsByTagName("recreated")[0].firstChild.nodeValue == "True")  {    this.productsPagesRecreated += parseInt(responseXMLObject.getElementsByTagName("recreated_pages_count")[0].firstChild.nodeValue);  }  spanObject = document.getElementById("productsPagesImage");  if (spanObject != null)  {    if (this.productsPagesCount == this.productsPagesProgressCount)    {      spanObject.style.visibility = "hidden";    }  }  this.updateHtml();}ShoppingCart.prototype.onRecreateProductPageError = function(parameters,                                                             ajaxCommunicator,                                                             responseText,                                                             responseXMLObject){  // to do  this.productsPagesErrors++;  this.updateHtml();}ShoppingCart.prototype.recreatePage = function(url,                                               templateTag,                                               categoryId,                                               productId){  var ac = new AjaxCommunicator();  ac.setUrl(url);  if (templateTag != "")  {    ac.setParameter("command","recreate_template_page");    ac.setParameter("template_tag",templateTag);    ac.invoke("",              "clsShoppingCart.onRecreatePageSuccess",              "clsShoppingCart.onRecreatePageError");  }  else if (categoryId != "0")  {    ac.setParameter("command","recreate_category_page");    ac.setParameter("category_id",categoryId);    ac.invoke("",              "clsShoppingCart.onRecreatePageSuccess",              "clsShoppingCart.onRecreatePageError");  }  else if (productId != "0")  {    ac.setParameter("command","recreate_product_page");    ac.setParameter("product_id",productId);    ac.invoke("",              "clsShoppingCart.onRecreatePageSuccess",              "clsShoppingCart.onRecreatePageError");  }}ShoppingCart.prototype.onRecreatePageSuccess = function(parameters,                                                        ajaxCommunicator,                                                        responseText,                                                        responseXMLObject){  var tag = responseXMLObject.getElementsByTagName("recreated");  if (tag.length > 0 &&      tag[0].firstChild.nodeValue == "True")  {    window.document.location.replace(window.document.location.href);  }}ShoppingCart.prototype.onRecreatePageError = function(parameters,                                                      ajaxCommunicator,                                                      responseText,                                                      responseXMLObject){  // to do}  var clsShoppingCart = new ShoppingCart();
