/**
 * Copyright 2006 Olivier Clavel
 *
 * This file is part of Renata Shop Website software.
 *
 * Renata Shop Website is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License,
 * or any later version.
 *
 * Renata Shop Website is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MediaNetLive portal software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @author Olivier Clavel <contact AT retiz DOT com>
 * @version $Id$
 */

/**
 * functions to customize wz_tooltips for some elements
 */

function clotheTooltip(elem) {
  elem.T_WIDTH = 330;
  elem.T_TEXTALIGN = 'center';
  var theText = elem.getElementsByTagName('span').item(0).childNodes.item(0).nodeValue;
  var coma = theText.indexOf(',');
  var clotheName = theText.substring(0, coma);
  var restOfText = theText.substring(coma+1, theText.length);
  coma = restOfText.indexOf(',');
  if (coma != -1) {
    clotheName += '<br />' + restOfText.substring(0, coma);
    restOfText = restOfText.substring(coma+1, restOfText.length);
  }
  return clotheName.bold() + '<br />' + restOfText;
}

function linkTooltip(elem) {
  elem.T_WIDTH = 100;
  elem.T_TEXTALIGN = 'center';
  return elem.getAttribute('title');
}

function visitTooltip(elem) {
  elem.T_ABOVE = true;
  elem.T_TEXTALIGN = 'center';
  elem.T_OFFSETY = 25;
  return elem.getAttribute('title');
}

function thumbnailTooltip(elem) {
  elem.T_TEXTALIGN = 'center';
  elem.T_WIDTH = 425;
  elem.T_PADDING = 0;
  elem.T_BORDERWIDTH = 0;
  elem.T_BGCOLOR = '#000000';
  var imageSrc = elem.src;
  var myRe = new RegExp("/images/clotheThumb/50/(.*)\.jpg");
  var fullImg = imageSrc.match(myRe);
  var alt = elem.alt;
  return '<img src="/images/clothes/' + fullImg[1] + '" alt="' + alt + '"/>';
}

function sizeTooltip(elem) {
  elem.T_TEXTALIGN = 'center';
  elem.T_WIDTH = 502;
  elem.T_PADDING = 0;
  elem.T_BORDERWIDTH = 0;
  elem.T_BGCOLOR = '#000000';
  return '<img src="/images/TableauTailles.jpg" alt="Tailles/Sizes"/>';
}

function colorTooltip(elem) {
  var lang = document.body.className;
  var altText = {"fr" : "Gamme de couleurs", "en" : "Color card"};
  elem.T_TEXTALIGN = 'center';
  elem.T_WIDTH = 600;
  elem.T_OFFSETX = -300;
  elem.T_PADDING = 0;
  elem.T_BORDERWIDTH = 0;
  elem.T_BGCOLOR = '#000000';
  return '<img src="/images/gammeCouleurs_' + lang + '.png" alt="' + altText[lang] + '"/>';
}
