/* Hightlights a product on mouse over it. */

function highlight(product) {
  document.getElementById(product).style.backgroundColor = '#323232';
}

/* Unhighlights a product on mouse out of it. */

function unhighlight(product) {
  document.getElementById(product).style.backgroundColor = '#232323';
}

/* Opens the large photo frame window. */

function openProductLargePhoto(imageName, productName, imageWidth, imageHeight) {
  xLeft = (screen.width / 2) - (imageWidth / 2);
  xTop = (screen.height / 2) - (imageHeight / 2);
  win = window.open('', "win", "dependent=yes, titlebar=no, toolbar=no, location=no, directories=no, status=no, menubar=no, resizeable=no, scrollbars=no, width=" + (imageWidth) + ", height=" + (imageHeight) + ", left=" + xLeft + ", top=" + xTop);
  win.document.writeln("<html>");
  win.document.writeln("<head>");
  win.document.writeln("  <title>" + productName + "</title>");
  win.document.writeln("</head>");
  win.document.writeln("<body style=\"padding: 0; margin: 0; background-color: black;\">");
  win.document.writeln("  <img src=\"../products_img/big/" + imageName + "\">");
  win.document.writeln("</body>");
  win.document.writeln("</html>");
}

/* Adds the item to the shopping cart by assembling appropriate URL link. */

function addItem(item, locale) {
  refNum = item;
  quantity = document.getElementById("q" + item).value;
  price = document.getElementById("pr" + item).value;
  name = document.getElementById("n" + item).value;
  weight = (document.getElementById("weight" + item) ? document.getElementById("weight" + item).value : 0);
  sizeElem = document.getElementById("size" + item);
  size = "";
  if (sizeElem) {
    for (var i = 0; i < sizeElem.options.length; i++) {
      if (sizeElem.options[i].selected) {
        size = " (" + sizeElem.options[i].text + ")";
        break;
      }
    }
  }
  url = "http://www.prixusa.com/fr/shopping_cart/addproduct.php?refnum=" + refNum + "&locale=" + locale + "&quantity=" + quantity + "&price=" + price + "&name=" + name + size + "&weight=" + weight;
  location.href = url;
}

/* Removes the item from the shopping cart by assembling appropriate URL link. */

function removeItem(path, item, locale, site, name) {
  refNum = item;
  url = path + "/deleteproduct.php?refnum=" + refNum + "&locale=" + locale + "&site=" + site + "&name=" + name;
  location.href = url;
}

/* Opens the product technical information window. */

function openTechInfo(productName, techInfoText) {
  screenWidth = 400;
  screenHeight = 300;
  xLeft = (screen.width / 2) - (screenWidth / 2);
  xTop = (screen.height / 2) - (screenHeight / 2);
  win = window.open('', "win", "dependent=yes, titlebar=no, toolbar=no, location=no, directories=no, status=no, menubar=no, resizeable=no, scrollbars=no, width=" + (screenWidth) + ", height=" + (screenHeight) + ", left=" + xLeft + ", top=" + xTop);
  win.document.writeln("<html>");
  win.document.writeln("<head>");
  win.document.writeln("  <title>" + productName + "</title>");
  win.document.writeln("  <meta http-equiv=\"content-type\" content=\"text/html; charset=iso8859-1\">");
  win.document.writeln("</head>");
  win.document.writeln("<body style=\"background-color: black;\">");
  win.document.writeln('<span style="color: #ffffff; font-size: 12px; font-family: verdana;">' + techInfoText + '</span>');
  win.document.writeln("</body>");
  win.document.writeln("</html>");
}

/* Opens the product technical information window. */

function openTechInfo2(productName, techInfoText) {
  tb_show(productName, 'showTechInfo.php?KeepThis=true&techInfoText=' + escape(techInfoText) + '&width=300&height=250&TB_iframe=true', "");
}
function openLargeImage(img, leftPos, topPos) {
  $("#imageViewer").css("display", "block");
  $("#imageViewer").css("left", (leftPos) + "px");
  $("#imageViewer").css("top", (topPos - 250) + "px");
  $("#imageViewer").load("showPicture.php?img=" + img);
}

function closeLargeImage(img) {
  $("#imageViewer").css("display", "none");
}