function SetCatalogueOpt()
{
  var allCells = document.getElementsByTagName("td");
  for (var i = 0; i < allCells.length; i++)
  {
    if (allCells[i].className == "catalogItem")
    {
      for (var j = 0; j < allCells[i].childNodes.length; j++)
      {
        var curNode = allCells[i].childNodes[j];
        if (curNode.tagName && curNode.tagName.toLowerCase() == "a")
        {
          var url = curNode.href;
          curNode.href = "javascript:ShowPopupThenNavigateTo('" + url + "')";
        }
      }
    }
  }
  allCells = document.getElementsByTagName("a");
  for (var i = 0; i < allCells.length; i++)
  {
    if (allCells[i].className == "catalogItemFooter")
    {
      var url = allCells[i].href;
      allCells[i].href = "javascript:ShowPopupThenNavigateTo('" + url + "')";
    }
  }
}

function FixForIE(hasBackground)
{
  var element = document.documentElement;
  if (!hasBackground && element.style.backgroundImage)// || element.style.backgroundImage == ""))
    document.documentElement.style.backgroundImage = "url(http:)";
  document.documentElement.style.backgroundAttachment = "fixed";
  element = document.body;
  if (!hasBackground && element.style.backgroundImage)// || element.style.backgroundImage == "")
    document.body.style.backgroundImage = "url(http:)";
  document.body.style.backgroundAttachment = "fixed";
  document.getElementById("preloader_image").style.display = "";
  document.getElementById("preloader_frame").style.display = "none";
}

function ShowPopupThenNavigateTo(newurl)
{
  ShowPopup();
  window.location = newurl;
  var popup_throbber = document.getElementById("preloader_image");
  if (popup_throbber.style.display != "none")
  {
    popup_throbber.src = popup_throbber.src;
  }
}

function ShowPopup()
{
  document.getElementById("DisabledBG").style.display = "";
  document.getElementById("PleaseWait").style.display = "";
}

function HidePopup()
{
  document.getElementById("PleaseWait").style.display = "none";
  document.getElementById("DisabledBG").style.display = "none";
}

function SetFormFillOpt()
{
  var formfield = document.getElementById("__DisableForm");
  if (formfield && formfield.value == "Y")
  {
    if (typeof(StorefrontPostAjaxHook) == typeof(StorefrontPostAjaxHook_283981501AD46548))
    {
      StorefrontPostAjaxHook = HidePopup;
    }
    else
    {
      var old_hook = StorefrontPostAjaxHook;
      StorefrontPostAjaxHook = function()
        {
          HidePopup();
          old_hook();
        }
    }

    var old_ajax = PFSF_AjaxUpdateForm;
    PFSF_AjaxUpdateForm = function(a,b)
      {
        ShowPopup();
        old_ajax(a,b);
      }
  }
}
