///// FEATURES - IMAGE VIEWER FUNCTION \\\\\\

  var shopclothing_http_request = false;
  var shopclothing_initializeCount = 0;
  var shopclothing_autoDiv = 1;
  var shopclothing_activeDiv = 0;
  var shopclothing_activationTimer = 0;
  var shopclothing_currImage = 0;
  var shopclothing_pause = 0;
  var shopclothing_featureImages = new Array();
  var shopclothing_imgLen = 0;
  var shopclothing_lang = "";
  var shopclothing_loaded = new Array(), shopclothing_preImages = new Array(), shopclothing_preId = new Array(), shopclothing_preTitle = new Array(), shopclothing_preCopy = new Array(), shopclothing_prePrice = new Array(), shopclothing_preLang = new Array(), shopclothing_currCount = 0;

  function shopclothing_makeRequest(url) {
    shopclothing_http_request = false;
        
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
      shopclothing_http_request = new XMLHttpRequest();
      if (shopclothing_http_request.overrideMimeType) {
        shopclothing_http_request.overrideMimeType('text/xml');
      }
    } else if (window.ActiveXObject) { // IE
      try {
        shopclothing_http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
        shopclothing_http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }

    if (!shopclothing_http_request) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
    }
    
    shopclothing_http_request.onreadystatechange = preloadshopclothing;
    shopclothing_http_request.open('GET', url, true);
    shopclothing_http_request.send(null);
  }
  
  function preloadshopclothing() {
    if (shopclothing_http_request.readyState == 4) {
      if (shopclothing_http_request.status == 200) {
        var shopclothing_RESPONSE = String(shopclothing_http_request.responseText);
        var shopclothing_RETURNED = shopclothing_RESPONSE.split("|");

        for (i=0; i<shopclothing_RETURNED.length; i++) {
          var shopclothing_parts = shopclothing_RETURNED[i].split('^');
          shopclothing_preImages[i] = new Image();
          shopclothing_preImages[i].src = '/_images/shop/clothing/' + shopclothing_parts[2];
          shopclothing_preId[i] = shopclothing_parts[0];
          shopclothing_preTitle[i] = shopclothing_parts[1];
          shopclothing_preCopy[i] = shopclothing_parts[3];
          shopclothing_prePrice[i] = shopclothing_parts[4];
          shopclothing_preLang[i] = shopclothing_parts[5];
          shopclothing_loaded[i] = 0;
        }
        shopclothing_imgLen = shopclothing_preImages.length;

        shopclothing_preLoad__checkLoad();

      } else {
        alert('Couldn\'t preload. Refresh page. ' + shopclothing_http_request.responseText);
      }
    }
  }
  
  function shopclothing_preLoad__checkLoad() {
    if (shopclothing_loaded[0]) { shopclothing_displayImage(shopclothing_preId[0], shopclothing_preTitle[0], shopclothing_preImages[0].src, shopclothing_preCopy[0], shopclothing_prePrice[0], shopclothing_preLang[0]); }

    if (shopclothing_currCount == shopclothing_imgLen) {
      //activationTimer = setInterval('changeshopclothing("next")', 5000);
      return;
    }
    for (i = 0; i < shopclothing_imgLen; i++) {
      if (!shopclothing_loaded[i] && shopclothing_preImages[i].complete) {
        shopclothing_loaded[i] = 1; shopclothing_currCount++;
        shopclothing_preLoad__checkLoad();
        return;
      }
    }
    setTimeout("shopclothing_preLoad__checkLoad()",10);
  }

  function changeshopclothing(action) {
    if (action == 'next') {
      shopclothing_currImage++;
      if (shopclothing_currImage == shopclothing_preImages.length) { shopclothing_currImage = 0; }
    }
    else if (action == 'previous') {
      shopclothing_currImage--;
      if (shopclothing_currImage == -1) { shopclothing_currImage = shopclothing_preImages.length-1; }
    }

    shopclothing_displayImage(shopclothing_preId[shopclothing_currImage], shopclothing_preTitle[shopclothing_currImage], shopclothing_preImages[shopclothing_currImage].src, shopclothing_preCopy[shopclothing_currImage], shopclothing_prePrice[shopclothing_currImage], shopclothing_preLang[shopclothing_currImage]);
  }

  function shopclothing_displayImage(id, title, src, copy, price, lang) {
    if(lang == 'fr'){
      shopclothing_lang = "Lisez plus";
    }else{
      shopclothing_lang = "Read More";
    }
  
    document.getElementById("shopclothingpic").innerHTML = "<a href=\"/" + index + "shop/clothing\"><img src=\"" + src + "\" /></a>";
    document.getElementById("shopclothingtext").innerHTML = 
    "<b>$" + price + " CAD</b><br /><span style=\"font-size:16px;color:#00CCFF;font-weight:bold;\">" + title + "</span><br />" + copy + " " + "<a href=\"/" + index + "shop/clothing\">" + shopclothing_lang + "</a>";
  }