/*====================================================================*/
/* Javascript file created by Boudewijn Overgaauw on October 6, 2006  */
/* Last updated by Cees Overgaauw on January 17, 2012                 */
/* Copyright (c) Boudewijn Overgaauw, 2006-2012. All Rights Reserved  */
/*====================================================================*/

/*===================================================*/
/* Information about the Maguelone bekers collection */
/*===================================================*/
var $MagueloneBekersArticlesWithPrices =
 [
   ['bekers, set van 2',   '19,00']
 ];
var $MagueloneBekersColors =
 [
   'zinc',
   'craie'
 ];
var $MagueloneBekersDetails =
 [
   ['kleur', $MagueloneBekersColors]
 ];
var $MagueloneBekersData = [$MagueloneBekersArticlesWithPrices, $MagueloneBekersDetails];

/*=========================================*/
/* Information about the Karo M collection */
/*=========================================*/
var $KaroMArticlesWithPrices =
 [
   ['vaas M (h32 x b8 x d7 cm, wit)',   '59,00']
 ];
var $KaroMData = [$KaroMArticlesWithPrices, new Array()];

/*=========================================*/
/* Information about the Karo L collection */
/*=========================================*/
var $KaroLArticlesWithPrices =
 [
   ['vaas L (h41 x b11 x d8 cm)',   '65,00']
 ];
var $KaroLColors =
 [
   'lindegroen',
   'wit'
 ];
var $KaroLDetails =
 [
   ['kleur', $KaroLColors]
 ];
var $KaroLData = [$KaroLArticlesWithPrices, $KaroLDetails];

/*==============================================*/
/* Information about the Bouteille L collection */
/*==============================================*/
var $BouteilleLArticlesWithPrices =
 [
   ['Bouteille 1 ltr',   '27,90']
 ];
var $BouteilleLColors =
 [
   'lindegroen',
   'cerise',
   'citron',
   'aubergine',
   'orange'
 ];
var $BouteilleLDetails =
 [
   ['kleur', $BouteilleLColors]
 ];
var $BouteilleLData = [$BouteilleLArticlesWithPrices, $BouteilleLDetails];

/*================================================*/
/* Information about the Bouteille XL collection */
/*================================================*/
var $BouteilleXLArticlesWithPrices =
 [
   ['Bouteille 1,5 ltr',   '29,90']
 ];
var $BouteilleXLColors =
 [
   'cerise',
   'citron'
 ];
var $BouteilleXLDetails =
 [
   ['kleur', $BouteilleXLColors]
 ];
var $BouteilleXLData = [$BouteilleXLArticlesWithPrices, $BouteilleXLDetails];

/*=================================================*/
/* Information about the Tourron kommen collection */
/*=================================================*/
var $TourronKommenArticlesWithPrices =
 [
   ['Kom Indigo, set van 2',   '25,00'],
   ['Kom Jade, set van 2',   '25,00']
 ];
var $TourronKommenData = [$TourronKommenArticlesWithPrices, new Array()];

/*==========================================================*/
/* Information about the Grain de cafe diep bord collection */
/*==========================================================*/
var $GrainDeCafeArticlesWithPrices =
 [
   ['Koffieglaasje',   '5,00']
 ];
var $GrainDeCafeData = [$GrainDeCafeArticlesWithPrices, new Array()];

/*=============================================*/
/* Information about the Tourron KS collection */
/*=============================================*/
var $TourronKSArticlesWithPrices =
 [
   ['Espresso kopje en schotel, set van 2',   '35,00']
 ];
var $TourronKSData = [$TourronKSArticlesWithPrices, new Array()];

/*============================================*/
/* Information about the Tima cafe collection */
/*============================================*/
var $TimaCafeArticlesWithPrices =
 [
   ['Koffiekopje',     '13,90'],
   ['Espressokopje',   '12,50']
 ];
var $TimaCafeData = [$TimaCafeArticlesWithPrices, new Array()];

/*========================================*/
/* Information about the Sacha collection */
/*========================================*/
var $SachaArticlesWithPrices =
 [
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00'],
   ['',   '0,00']
 ];
var $SachaData = [$SachaArticlesWithPrices, new Array()];

/*===============================================*/
/* Information about the TourronWater collection */
/*===============================================*/
var $TourronWaterArticlesWithPrices =
 [
   ['dinerbord',                '19,75'],
   ['soep/diep bord',           '18,40'],
   ['ontbijt/dessertbord',      '17,80'],
   ['laag schaaltje',           '15,45'],
   ['pastabord',                '19,90'],
   ['pastaschaal',              '33,65'],
   ['presenteerbord',           '43,10'],
   ['kom ( hoog)',              '17,80'],
   ['saladier (19 cm)',         '33,65'],
   ['saladier (23 cm)',         '42,25'],
   ['saladier (27 cm)',         '53,25'],
   ['beker',                    '15,45'],
   ['mokkakopje en schotel',    '20,75'],
   ['koffiekopje en schotel',   '22,55'],
   ['theekop en schotel',       '23,20'],
   ['ontbijtkop en schotel',    '25,05'],
   ['melkkan',                  '20,20'],
   ['suikerpot',                '23,75'],
   ['theepot (0,45 ltr)',       '43,55'],
   ['theepot (1,4 ltr)',        '51,25'],
   ['pichet (kan)',             '25,25'],
   ['bord met laag schaaltje',  '29,75']
 ];
var $TourronWaterColors =
 [
   'grijs',
   'jadegroen',
   'lindegroen',
   'indigoblauw',
   'wit',
   'samoa'
 ];
var $TourronWaterDetails =
 [
   ['kleur', $TourronWaterColors]
 ];
var $TourronWaterData = [$TourronWaterArticlesWithPrices, $TourronWaterDetails];

/*==============================================*/
/* Information about the TourronVuur collection */
/*==============================================*/
var $TourronVuurArticlesWithPrices =
 [
   ['dinerbord',                '24,50'],
   ['soep/diep bord',           '23,50'],
   ['ontbijt/dessertbord',      '22,60'],
   ['laag schaaltje',           '19,60'],
   ['pastabord',                '25,40'],
   ['pastaschaal',              '42,90'],
   ['presenteerbord',           '54,95'],
   ['kom ( hoog)',              '22,65'],
   ['saladier (19 cm)',         '42,90'],
   ['saladier (23 cm)',         '53,90'],
   ['saladier (27 cm)',         '69,45'],
   ['beker',                    '19,55'],
   ['mokkakopje en schotel',    '26,35'],
   ['koffiekopje en schotel',   '28,10'],
   ['theekop en schotel',       '29,35'],
   ['ontbijtkop en schotel',    '31,10'],
   ['melkkan',                  '22,35'],
   ['suikerpot',                '27,15'],
   ['theepot (0,45 ltr)',       '56,30'],
   ['theepot (1,4 ltr)',        '64,10'],
   ['pichet (kan)',             '28,70']
 ];
var $TourronVuurColors =
 [
   'cerise',
   'citron',
   'orange'
 ];
var $TourronVuurDetails =
 [
   ['kleur', $TourronVuurColors]
 ];
var $TourronVuurData = [$TourronVuurArticlesWithPrices, $TourronVuurDetails];

/*===============================================*/
/* Information about the TourronAarde collection */
/*===============================================*/
var $TourronAardeArticlesWithPrices =
 [
   ['dinerbord',                '19,75'],
   ['soep/diep bord',           '18,40'],
   ['ontbijt/dessertbord',      '17,80'],
   ['laag schaaltje',           '15,45'],
   ['pastabord',                '19,90'],
   ['presenteerbord',           '43,10'],
   ['saladier (23 cm)',         '42,25'],
   ['schaal (medium)',          '44,50'],
   ['pichet (groot)',           '25,25'],
   ['pichet (medium)',          '22,55'],
   ['beker',                    '15,45'],
   ['theekop en schotel',       '23,20'],
   ['theekom',                  '11,90'],
   ['melkkan',                  '20,20'],
   ['suikerpot',                '23,75'],
   ['theepot (0,45 ltr)',       '43,55'],
   ['theepot (1,4 ltr)',        '51,25']
 ];
var $TourronAardeColors =
 [
   'aubergine',
   'kaki'
 ];
var $TourronAardeDetails =
 [
   ['kleur', $TourronAardeColors]
 ];
var $TourronAardeData = [$TourronAardeArticlesWithPrices, $TourronAardeDetails];

/*=======================================*/
/* Information about the Tima collection */
/*=======================================*/
var $TimaArticlesWithPrices =
 [
   ['beker (klein)',          '7,75'],
   ['beker (medium)',         '8,25'],
   ['beker (groot)',         '12,75'],
   ['schaal (extra klein)',  '16,85'],
   ['schaal (klein)',        '26,60'],
   ['schaal (medium)',       '38,90'],
   ['schaal (groot)',        '26,60'],
   ['schaal (extra groot)',  '48,60']
 ];
var $TimaColors =
 [
   'zwart',
   'vuurzwart'
 ];
var $TimaDetails =
 [
   ['kleur', $TimaColors]
 ];
var $TimaData = [$TimaArticlesWithPrices, $TimaDetails];

/*================================================*/
/* Information about the TimaVuurzwart collection */
/*================================================*/
var $TimaVuurzwartArticlesWithPrices =
 [
   ['karaf (medium)',      '27,95'],
   ['karaf (groot)',       '31,05'],
   ['rond bord (21 cm)',   '19,15'],
   ['rond bord (26 cm)',   '20,75'],
   ['rond bord (30 cm)',   '27,20'],
   ['theepot (0,5 l)',     '53,92']
 ];
var $TimaVuurzwartData = [$TimaVuurzwartArticlesWithPrices, new Array()];

/*========================================*/
/* Information about the Plume collection */
/*========================================*/
var $PlumeArticlesWithPrices =
 [
   ['dinerbord XL',               '27,15'],
   ['dinerbord',                  '24,95'],
   ['soep/diep bord',             '25,80'],
   ['ontbijt/dessertbord',        '24,50'],
   ['schaaltje',                  '21,95'],
   ['saladier',                   '55,00'],
   ['espresso kop en schotel',    '24,80'],
   ['koffiekop en schotel',       '25,50'],
   ['theekop en schotel',         '28,00']
 ];
var $PlumeColors =
 [
   'atol',
   'parel'
 ];
var $PlumeDetails =
 [
   ['kleur', $PlumeColors]
 ];
var $PlumeData = [$PlumeArticlesWithPrices, $PlumeDetails];

/*=========================================*/
/* Information about the Vuelta collection */
/*=========================================*/
var $VueltaArticlesWithPrices =
 [
   ['bord L',                '27,90'],
   ['bord M',                '19,55'],
   ['soep/diep bord L',      '20,30'],
   ['soep/diep bord M',      '18,80'],
   ['ontbijt/dessertbord',   '18,05'],
   ['hoge kom',              '15,70'],
   ['saladier',              '43,00'],
   ['beker',                 '15,70'],
   ['espressobekertje',       '7,25'],
   ['kop en schotel',        '22,55'],
   ['hors \'doevre S',       '21,30'],
   ['hors \'doevre M',       '45,45'],
   ['cakeschaal',            '36,90']
 ];
var $VueltaColors =
 [
   'litchi',
   'menthe',
   'zeste'
 ];
var $VueltaDetails =
 [
   ['kleur', $VueltaColors]
 ];
var $VueltaData = [$VueltaArticlesWithPrices, $VueltaDetails];

/*========================================*/
/* Information about the Poeme collection */
/*========================================*/
var $PoemeArticlesWithPrices =
 [
   ['dinerbord',        '24,50'],
   ['diep/soep bord',   '23,50']
 ];
var $PoemeColors =
 [
   'autumn',
   'autumn uni',
   'orage',
   'orage uni'
 ];
var $PoemeDetails =
 [
   ['kleur', $PoemeColors]
 ];
var $PoemeData = [$PoemeArticlesWithPrices, $PoemeDetails];

/*============================================*/
/* Information about the Poeme Uni collection */
/*============================================*/
var $PoemeUniArticlesWithPrices =
 [
   ['ontbijt/dessertbord',   '22,65']
 ];
var $PoemeUniColors =
 [
   'autumn uni',
   'orage uni'
 ];
var $PoemeUniDetails =
 [
   ['kleur', $PoemeUniColors]
 ];
var $PoemeUniData = [$PoemeUniArticlesWithPrices, $PoemeUniDetails];

/*=============================================*/
/* Information about the Poeme Arte collection */
/*=============================================*/
var $PoemeDecoArticlesWithPrices =
 [
   ['presenteerbord',    '31,19'],
   ['groot rond bord',   '54,95']
 ];
var $PoemeDecoColors =
 [
   'autumn',
   'orage'
 ];
var $PoemeDecoDetails =
 [
   ['kleur', $PoemeDecoColors]
 ];
var $PoemeDecoData = [$PoemeDecoArticlesWithPrices, $PoemeDecoDetails];

/*============================================*/
/* Information about the Empreinte collection */
/*============================================*/
var $EmpreinteArticlesWithPrices =
 [
   ['dinerbord, gomme, 26cm',             '19,50'],
   ['ontbijt/dessertbord, gomme, 21cm',   '18,00'],
   ['diep bord S, etoile, 20cm',          '19,50'],
   ['diep bord S, damier, 20cm',          '19,50'],
   ['diep bord L, etoile, 30cm',          '49,50'],
   ['diep bord L, gomme, 30cm',           '49,50'],
   ['bord L, etoile, 33x15cm',            '49,50'],
   ['bord S, stries, 12,5x25,5cm',        '27,50'],
   ['plateau S, damier, 25x21cm',         '33,00'],
   ['plateau L, stries, 35x27cm',         '55,00']
 ];
var $EmpreinteColors =
 [
   'nature',
   'blanc'
 ];
var $EmpreinteDetails =
 [
   ['kleur', $EmpreinteColors]
 ];
var $EmpreinteData = [$EmpreinteArticlesWithPrices, $EmpreinteDetails];

/*============================================*/
/* Information about the MatoWater collection */
/*============================================*/
var $MatoWaterArticlesWithPrices =
 [
   ['Mato (groot)',    '61,40'],
   ['Mato (medium)',   '47,65'],
   ['Mato (klein)',    '25,30']
 ];
var $MatoWaterColors =
 [
   'lindegroen',
   'indigoblauw'
 ];
var $MatoWaterDetails =
 [
   ['kleur', $MatoWaterColors]
 ];
var $MatoWaterData = [$MatoWaterArticlesWithPrices, $MatoWaterDetails];

/*===========================================*/
/* Information about the MatoVuur collection */
/*===========================================*/
var $MatoVuurArticlesWithPrices =
 [
   ['Mato (groot)',   '79,85'],
   ['Mato (medium)',  '60,85'],
   ['Mato (klein)',   '32,95']
 ];
var $MatoVuurColors =
 [
   'cerise',
   'citron',
   'orange'
 ];
var $MatoVuurDetails =
 [
   ['kleur', $MatoVuurColors]
 ];
var $MatoVuurData = [$MatoVuurArticlesWithPrices, $MatoVuurDetails];

/*=================================================*/
/* Information about the SolifloreWater collection */
/*=================================================*/
var $SolifloreWaterArticlesWithPrices =
 [
   ['Soliflore',  '14,50']
 ];
var $SolifloreWaterColors =
 [
   'lindegroen',
   'stuc blanc'
 ];
var $SolifloreWaterDetails =
 [
   ['kleur', $SolifloreWaterColors]
 ];
var $SolifloreWaterData = [$SolifloreWaterArticlesWithPrices, $SolifloreWaterDetails];

/*================================================*/
/* Information about the SolifloreVuur collection */
/*================================================*/
var $SolifloreVuurArticlesWithPrices =
 [
   ['Soliflore',  '14,50'],
   ['Soliflore',  '14,50']
 ];
var $SolifloreVuurColors =
 [
   'cerise',
   'citron',
   'orange'
 ];
var $SolifloreVuurDetails =
 [
   ['kleur', $SolifloreVuurColors]
 ];
var $SolifloreVuurData = [$SolifloreVuurArticlesWithPrices, $SolifloreVuurDetails];

/*========================================*/
/* Information about the Edo collection   */
/*========================================*/
var $EdoArticlesWithPrices =
 [
   ['Edo S',   '33,00'],
   ['Edo M',   '51,45']
 ];
var $EdoColors =
 [
   'mat wit',
   'geel',
   'rood'
 ];
var $EdoDetails =
 [
   ['kleur', $EdoColors]
 ];
var $EdoData = [$EdoArticlesWithPrices, $EdoDetails];

/*=====================================*/
/* Definition of the entire collection */
/*=====================================*/
var $Collection =
 [
   ['Maguelone bekers',   $MagueloneBekersData],
   ['Karo M',                       $KaroMData],
   ['Karo L',                       $KaroLData],
   ['Bouteille L',             $BouteilleLData],
   ['Bouteille XL',           $BouteilleXLData],
   ['Tourron kommen',       $TourronKommenData],
   ['Grain de cafe',          $GrainDeCafeData],
   ['Tourron KS',               $TourronKSData],
   ['Tima cafe',                 $TimaCafeData],

   ['Sacha',                        $SachaData],
   ['Tourron water',         $TourronWaterData],
   ['Tourron vuur',           $TourronVuurData],
   ['Tourron aarde',         $TourronAardeData],
   ['Tima',                          $TimaData],
   ['Tima vuurzwart',       $TimaVuurzwartData],
   ['Plume',                        $PlumeData],
   ['Vuelta',                      $VueltaData],
   ['Poeme',                        $PoemeData],
   ['Poeme uni',                 $PoemeUniData],
   ['Poeme deco',               $PoemeDecoData],
   ['Empreinte',                $EmpreinteData],//new
   ['Mato water',               $MatoWaterData],
   ['Mato vuur',                 $MatoVuurData],
   ['Soliflore water',     $SolifloreWaterData],
   ['Soliflore vuur',       $SolifloreVuurData],
   ['Edo',                            $EdoData]
 ];

/*============================*/
/* Script specific parameters */
/*============================*/
var $VATNotice = '(de vermelde prijzen zijn inclusief BTW)';

/*====================*/
/* General parameters */
/*====================*/
var $EuroSign = unescape('%u20AC');
var $SingleQuote = unescape('%27');
var $CookieLifeTimeInMinutes = 180;
var $CookieLifeTime = $CookieLifeTimeInMinutes * 60000;

/*=================*/
/* Main Javascript */
/*=================*/
var $OrderCookieName = 'GlazuurComOrderSessionCookie';
var $OrderDocumentQueryString = document.location.search.slice(1);
var $QueryStringIsValid = true;
if ($OrderDocumentQueryString != '')
{
  var $ArticleReference = $OrderDocumentQueryString.split('&');
  var $CollectionName = unescape($ArticleReference[0]);
  var $CollectionID = -1;
  for (var $i = 0; $i < $Collection.length; $i++)
  {
    if ($CollectionName == $Collection[$i][0])
    {
      $CollectionID = $i;
    };
  };
  if
   (
     ($CollectionID == -1) ||
     ($ArticleReference[1].search(/^\d+$/) == -1) ||
     ($ArticleReference[1] > $Collection[$CollectionID][1][0].length)
   )
  {
    var $QueryStringIsValid = false;
  }
  else
  {
    var $ArticleName = $Collection[$CollectionID][1][0][($ArticleReference[1] - 1)][0];
    var $ArticlePrice = $Collection[$CollectionID][1][0][($ArticleReference[1] - 1)][1];
    var $ArticleDetailsArray = $Collection[$CollectionID][1][1];
  };
};

function WriteArticlePrice($CollectionName, $ArticleIndex)
{
  var $CollectionID = -1;
  for (var $i = 0; $i < $Collection.length; $i++)
  {
    if ($CollectionName == $Collection[$i][0])
    {
      $CollectionID = $i;
    };
  };
  if
   (
     ($CollectionID == -1) ||
     ($ArticleIndex.search(/^\d+$/) == -1) ||
     ($ArticleIndex == 0) ||
     ($ArticleIndex > $Collection[$CollectionID][1][0].length)
   )
  {
    document.write('Error!');
  }
  else
  {
    document.write($Collection[$CollectionID][1][0][($ArticleIndex - 1)][1]);
  };
};

function OpenOrderDocument($CollectionName, $ArticleIndex)
{
  if ($ArticleIndex == 0)
  {
    var $URL = 'bestellijst.php';
  }
  else
  {
    var $URL = 'bestellijst.php?' + escape($CollectionName) + '&' + $ArticleIndex;
  };
  var $WindowName = 'OrderFormWindow';
  var $WindowOptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,' +
   'resizable=1,height=600,width=700';
  var $OrderFormWindow = window.open($URL, $WindowName, $WindowOptions);
  $OrderFormWindow.focus();
};

function TryToSetCookie($CookieName, $CookieValue)
{
  if (TestCookieSettings() && ($CookieValue !== false))
  {
    SetCookie($CookieName, $CookieValue);
  };
};

function SetCookie($CookieName, $CookieValue)
{
  var $CurrentTime = new Date().valueOf();
  var $CookieExpirationTime = new Date($CurrentTime + $CookieLifeTime).toUTCString();
  document.cookie = escape($CookieName) + '=' + $CurrentTime + ':' +
   $CookieValue + ';path=/;' + 'expires=' + $CookieExpirationTime;
};

function GetCookieDataStartIndex($CookieName)
{
  if (!document.cookie.length)
  {
    return false;
  }
  else
  {
    var $CookieNameStartIndex = document.cookie.indexOf(unescape($CookieName) + '=');
    if ($CookieNameStartIndex == -1)
    {
      return 0;
    }
    else
    {
      return $CookieNameStartIndex + $CookieName.length + 1;
    };
  };
};

function GetCookie($CookieName)
{
  var $CookieDataStartIndex = GetCookieDataStartIndex($CookieName);
  if (!$CookieDataStartIndex)
  {
    return false;
  }
  else
  {
    var $CookieDataEndIndex = document.cookie.indexOf(';', $CookieDataStartIndex);
    if ($CookieDataEndIndex == -1)
    {
      $CookieDataEndIndex = document.cookie.length;
    };
    var $CookieTimeStampEndIndex = document.cookie.indexOf(':', $CookieDataStartIndex);
    if ($CookieTimeStampEndIndex == -1)
    {
      DeleteCookie($CookieName);
      return false;
    }
    else
    {
      var $CurrentTime = new Date().valueOf();
      $CookieTimeStamp =
       Number(document.cookie.substring($CookieDataStartIndex, $CookieTimeStampEndIndex));
      if ($CurrentTime > ($CookieTimeStamp + $CookieLifeTime))
      {
        DeleteCookie($CookieName);
        return false;
      }
      else
      {
        $CookieValueStartIndex = $CookieTimeStampEndIndex + 1;
        return document.cookie.substring($CookieValueStartIndex, $CookieDataEndIndex);
      };
    };
  };
};

function DeleteCookie($CookieName)
{
  while (GetCookieDataStartIndex($CookieName))
  {
    document.cookie = escape($CookieName) + '=empty;path=/;' +
     'expires=Thu, 01-Jan-1970 00:00:01 GMT';
  };
};

function TestCookieSettings()
{
  SetCookie('GlazuurComTestCookie', 'CookieTest');
  if (!GetCookie('GlazuurComTestCookie'))
  {
    alert
     (
       'Uw browser accepteert onze cookies niet.\n' +
       'Voor het bestellen van onze artikelen is het\n' +
       'gebruik van cookies echter noodzakelijk.'
     );
    return false;
  }
  else
  {
    DeleteCookie('GlazuurComTestCookie');
    return true;
  };
};

function ConvertOrderListArrayToCookieValue($OrderListArray)
{
  function ConvertArrayToString($Array)
  {
    var $String = '[';
    for (var $i = 0; $i < $Array.length; $i++)
    {
      if ((typeof $Array[$i]) != 'object')
      {
        $ArrayItem = escape($Array[$i]);
        $String += $SingleQuote + $ArrayItem + $SingleQuote;
      }
      else
      {
        $String += ConvertArrayToString($Array[$i]);
      };
      if ($i != ($Array.length - 1))
      {
        $String += ',';
      };
    };
    return $String + ']';
  };

  if ((!$OrderListArray) || ((typeof $OrderListArray) != 'object'))
  {
    return false;
  }
  else
  {
    return ConvertArrayToString($OrderListArray);
  };
};

function ConvertCookieValueToOrderListArray($CookieValue)
{
  function UnescapeArrayValues($Array)
  {
    for (var $i = 0; $i < $Array.length; $i++)
    {
      if ((typeof $Array[$i]) != 'object')
      {
        $Array[$i] = unescape($Array[$i]);
      }
      else
      {
        UnescapeArrayValues($Array[$i]);
      };
    };
  };

  if
   (
     (!$CookieValue) ||
     ((typeof $CookieValue) != 'string') ||
     ($CookieValue.charAt(0) != '[') ||
     ($CookieValue.charAt($CookieValue.length - 1) != ']')
   )
  {
    return false;
  }
  else
  {
    $OrderListArray = eval($CookieValue);
    UnescapeArrayValues($OrderListArray);
    return $OrderListArray;
  };
};

function GetOrderListItems()
{
  var $Cookie = GetCookie($OrderCookieName);
  if ($Cookie === false)
  {
    return new Array();
  }
  else
  {
    return ConvertCookieValueToOrderListArray($Cookie);
  };
};

function GetNonNegativeInteger($String)
{
  if ($String.search(/^\d+$/) == -1)
  {
    return 'NaNNI';
  }
  else
  {
    return parseInt($String, 10);
  };
};

function ProcessOrder()
{
  var $ArticleQuantityFieldValue = document.forms['OrderForm'].OrderQuantity.value;
  if ($ArticleQuantityFieldValue == '')
  {
    document.location = document.location.pathname;
  }
  else
  {
    var $ArticleQuantity = GetNonNegativeInteger($ArticleQuantityFieldValue);
    if ($ArticleQuantity == 'NaNNI')
    {
      alert('Bij het aantal alleen hele getallen invullen.');
    }
    else
    {
      if ($ArticleQuantity == 0)
      {
        document.location = document.location.pathname;
      }
      else
      {
        var $ArticleDetails = new Array();
        var $MissingArticleDetails = new Array();
        for (var $i = 0; $i < $ArticleDetailsArray.length; $i++)
        {
          eval
           (
             '$ArticleDetails[$i] = document.forms[' + $SingleQuote + 'OrderForm' +
             $SingleQuote + '].' + $ArticleDetailsArray[$i][0] + '.value'
           );
          if ($ArticleDetails[$i] == 'onbepaald')
          {
            $MissingArticleDetails[$MissingArticleDetails.length] =
             $ArticleDetailsArray[$i][0];
          };
        };
        if ($MissingArticleDetails.length != 0)
        {
          var $AlertMessage = 'Voor het bestellen van dit artikel moet bij\n';
          for (var $i = 0; $i < $MissingArticleDetails.length; $i++)
          {
            $AlertMessage += '"' + $MissingArticleDetails[$i] + '"';
            if ($i != ($MissingArticleDetails.length - 1))
            {
              $AlertMessage += ' en ';
            };
          };
          $AlertMessage += ' een keuze gemaakt worden.';
          alert($AlertMessage);
        }
        else
        {
          var $OrderListItems = GetOrderListItems();
          var $Item =
           [$CollectionName, $ArticleName, $ArticleDetails, $ArticlePrice, $ArticleQuantity];
          $OrderListItems[$OrderListItems.length] = $Item;
          TryToSetCookie
           ($OrderCookieName, ConvertOrderListArrayToCookieValue($OrderListItems));
          document.location = document.location.pathname;
        };
      };
    };
  };
};

function ChangeListItemQuantity($ListItemIndex)
{
  var $OrderListItems = GetOrderListItems();
  var $NewOrderQuantityFieldValue =
   document.getElementById('QuantityForItem' + $ListItemIndex).value;
  if ($NewOrderQuantityFieldValue == '')
  {
    var $NewOrderQuantity = 0;
  }
  else
  {
    var $NewOrderQuantity = GetNonNegativeInteger($NewOrderQuantityFieldValue);
  };
  if ($NewOrderQuantity == 'NaNNI')
  {
    alert('Bij het aantal alleen hele getallen invullen.');
  }
  else
  {
    if ($OrderListItems[$ListItemIndex][4] != $NewOrderQuantity)
    {
      $OrderListItems[$ListItemIndex][4] = $NewOrderQuantity;
      TryToSetCookie($OrderCookieName, ConvertOrderListArrayToCookieValue($OrderListItems));
    };
  };
  CompressOrderList();
};

function CompressOrderList($ReloadChoice)
{
  var $OrderListItems = GetOrderListItems();
  var $NewOrderListItems = new Array();
  var $CookieIsToBeSet = false;
  for (var $i = 0; $i < $OrderListItems.length; $i++)
  {
    var $ListItemQuantity = $OrderListItems[$i][4];
    if (($ListItemQuantity != '0') && ($ListItemQuantity != ''))
    {
      $NewOrderListItems[$NewOrderListItems.length] = $OrderListItems[$i];
    }
    else
    {
      $CookieIsToBeSet = true;
    };
  };
  if ($CookieIsToBeSet)
  {
    $OrderListItems = $NewOrderListItems;
    TryToSetCookie($OrderCookieName, ConvertOrderListArrayToCookieValue($OrderListItems));
  };
  DisplayTotalPrice($OrderListItems);
  if ($ReloadChoice != 'noreload')
  {
    document.location = document.location.pathname;
  };
};

function CalculateTotalPrice($OrderListItems)
{
  var $TotalPriceInCents = 0;
  for (var $i = 0; $i < $OrderListItems.length; $i++)
  {
    var $ListItemQuantity = $OrderListItems[$i][4];
    var $ListItemPriceInCents = $OrderListItems[$i][3].replace(/,/, '');
    $TotalPriceInCents += $ListItemQuantity * $ListItemPriceInCents;
  };
  var $TotalPriceInCentsString = String($TotalPriceInCents);
  return $TotalPriceInCentsString.slice(0, -2) + ',' +
   $TotalPriceInCentsString.slice(($TotalPriceInCentsString.length - 2));
};

function DisplayTotalPrice($OrderListItems)
{
  var $TotalPriceField = document.getElementById('TotalPriceField');
  if ($TotalPriceField)
  {
    $TotalPriceField.value = $EuroSign + ' ' + CalculateTotalPrice($OrderListItems);
  };
};

function EmptyOrderList()
{
  DeleteCookie($OrderCookieName);
  document.location = document.location.pathname;
};

function WriteOrderDocument()
{
  if ($QueryStringIsValid)
  {
    if ($OrderDocumentQueryString == '')
    {
      document.title = 'Bestelformulier';
    }
    else
    {
      if ($OrderDocumentQueryString != '')
      {
        document.title = 'Bestelformulier voor ' + $CollectionName + ' - ' + $ArticleName;
        WriteOrderForm();
      };
    };
    WriteOrderList();
  }
  else
  {
    alert('System error! Please contact the webmaster.');
    window.close;
  };
};

function WriteOrderForm()
{
  document.writeln('<TR>');
  document.writeln('  <TD>');
  document.writeln('    <FORM NAME="OrderForm" ACTION="javascript:ProcessOrder();">');
  document.writeln('      <TABLE WIDTH="650" BORDER="0" CELLPADDING="0" CELLSPACING="0">');
  document.writeln('        <TR>');
  document.write  ('          <TD COLSPAN="6" CLASS="pu-regheader">');
  document.write  (            'Vul de details in voor:');
  document.writeln(          '</TD>');
  document.writeln('        </TR>');
  document.writeln('        <TR>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="110" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="190" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="100" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="100" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="75" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="75" HEIGHT="1"></TD>');
  document.writeln('        </TR>');
  document.writeln('        <TR>');
  document.writeln('          <TD CLASS="pu-regtext">collectie</TD>');
  document.writeln('          <TD CLASS="pu-regtext">artikel</TD>');
  for (var $i = 0; $i < $ArticleDetailsArray.length; $i++)
  {
    var $ColumnHeading = $ArticleDetailsArray[$i][0];
    document.write  ('          <TD CLASS="pu-regtext">');
    document.write  (             $ColumnHeading);
    document.writeln(          '</TD>');
  };
  for (var $i = ($ArticleDetailsArray.length + 1); $i <= 2; $i++)
  {
    document.writeln('          <TD>&nbsp;</TD>');
  };
  document.write  ('          <TD CLASS="pu-regtext" ALIGN="right">');
  document.write  (            'prijs/stuk');
  document.writeln(          '</TD>');
  document.writeln('          <TD CLASS="pu-regtext" ALIGN="right">aantal</TD>');
  document.writeln('        </TR>');
  document.writeln('        <TR>');
  document.writeln('          <TD CLASS="pu-regtext">' + $CollectionName + '</TD>');
  document.writeln('          <TD CLASS="pu-regtext">' + $ArticleName + '</TD>');
  for (var $i = 0; $i < $ArticleDetailsArray.length; $i++)
  {
    var $ArticleDetailName = $ArticleDetailsArray[$i][0];
    var $ArticleDetailList = $ArticleDetailsArray[$i][1];
    document.writeln('          <TD CLASS="pu-regtext">');
    document.writeln('            <SELECT NAME="' + $ArticleDetailName + '">');
    document.writeln('              <OPTION VALUE="onbepaald"> - Kies - </OPTION>');
    for (var $j = 0; $j < $ArticleDetailList.length; $j++)
    {
      document.write  ('              <OPTION VALUE="' + $ArticleDetailList[$j] + '">');
      document.write  (                 $ArticleDetailList[$j]);
      document.writeln(              '</OPTION>');
    };
    document.writeln('            </SELECT>');
    document.writeln('          </TD>');
  };
  for (var $i = ($ArticleDetailsArray.length + 1); $i <= 2; $i++)
  {
    document.writeln('          <TD>&nbsp;</TD>');
  };
  document.write  ('          <TD CLASS="pu-regtext" ALIGN="right">');
  document.write  (            '&euro; ' + $ArticlePrice);
  document.writeln(          '</TD>');
  document.write  ('          <TD ALIGN="right" CLASS="pu-regtext">');
  document.write  (            '<INPUT NAME="OrderQuantity" SIZE="3" VALUE="1" TYPE="text"');
  document.write  (            ' CLASS="bestellen-textfield">');
  document.writeln(          '</TD>');
  document.writeln('        </TR>');
  document.writeln('        <TR>');
  document.write  ('          <TD COLSPAN="6" ALIGN="right" CLASS="pu-regtext">');
  document.write  (            '<INPUT NAME="toevoegen" TYPE="image"');
  document.write  (            ' SRC="../images/frm-toevoegen.gif" WIDTH="200" HEIGHT="30"');
  document.write  (            ' BORDER="0">');
  document.writeln(          '</TD>');
  document.writeln('        </TR>');
  document.writeln('      </TABLE>');
  document.writeln('    </FORM>');
  document.writeln('  </TD>');
  document.writeln('</TR>');
  document.writeln('<TR>');
  document.writeln('  <TD CLASS="pu-line">&nbsp;</TD>');
  document.writeln('</TR>');
};

function WriteOrderList()
{
  var $OrderListItems = GetOrderListItems();
  if ($OrderListItems.length)
  {
    WriteOrderListForm($OrderListItems);
  }
  else
  {
    document.writeln('<TR>');
    document.write  ('  <TD CLASS="pu-regheader">');
    document.write  (    'Uw bestellijst bevat nog geen artikelen.');
    document.writeln(  '</TD>');
    document.writeln('</TR>');
    document.writeln('<TR>');
    document.write  ('  <TD CLASS="pu-regtext">');
    document.write  (    '<A HREF="javascript:self.close();">');
    document.write  (      '<IMG SRC="../images/frm-sluiten.gif" WIDTH="160" HEIGHT="30"');
    document.write  (      ' BORDER="0">');
    document.write  (    '</A>');
    document.writeln(  '</TD>');
    document.writeln('</TR>');
  };
};

function WriteOrderListForm($OrderListItems)
{
  CompressOrderList('noreload');
  document.writeln('<TR HEIGHT="32">');
  document.write  ('  <TD CLASS="pu-regheader">');
  document.write  (    'Uw bestellijst bevat de volgende artikelen ');
  document.write  (    '<SPAN class="pu-regtext">');
  document.write  (       $VATNotice);
  document.write  (    '</SPAN>');
  document.write  (    ':');
  document.writeln(  '</TD>');
  document.writeln('</TR>');
  document.writeln('<TR>');
  document.writeln('  <TD>');
  document.writeln('    <FORM NAME="OrderListForm" ACTION="javascript:void();">');
  document.writeln('      <TABLE WIDTH="650" BORDER="0" CELLPADDING="0" CELLSPACING="0">');
  document.writeln('        <TR>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="110" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="190" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="100" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="100" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="75" HEIGHT="1"></TD>');
  document.writeln('          <TD><IMG SRC="../images/spacer.gif" WIDTH="75" HEIGHT="1"></TD>');
  document.writeln('        </TR>');
  document.writeln('        <TR>');
  document.writeln('          <TD CLASS="pu-regtext">collectie</TD>');
  document.writeln('          <TD CLASS="pu-regtext">artikel</TD>');
  document.writeln('          <TD COLSPAN="2" CLASS="pu-regtext">details</TD>');
  document.write  ('          <TD CLASS="pu-regtext" ALIGN="right">');
  document.write  (            'prijs/stuk');
  document.writeln(          '</TD>');
  document.writeln('          <TD CLASS="pu-regtext" ALIGN="right">aantal</TD>');
  document.writeln('        </TR>');
  for (var $i = 0; $i < $OrderListItems.length; $i++)
  {
    var $ListItemID = 'QuantityForItem' + $i;
    var $CollectionName = $OrderListItems[$i][0];
    var $ArticleName = $OrderListItems[$i][1];
    var $ArticleDetails = ['&nbsp;', '&nbsp;'];
    for (var $j = 0; $j < $OrderListItems[$i][2].length; $j++)
    {
      $ArticleDetails[$j] = $OrderListItems[$i][2][$j];
    };
    var $ArticlePrice = '&euro; ' + $OrderListItems[$i][3];
    var $ArticleQuantity = $OrderListItems[$i][4];
    document.writeln('        <TR>');
    document.writeln('          <TD CLASS="pu-regtext">' + $CollectionName + '</TD>');
    document.writeln('          <TD CLASS="pu-regtext">' + $ArticleName + '</TD>');
    document.write  ('          <TD CLASS="pu-regtext">');
    document.write  (             $ArticleDetails[0]);
    document.writeln(          '</TD>');
    document.write  ('          <TD CLASS="pu-regtext">');
    document.write  (             $ArticleDetails[1]);
    document.writeln(          '</TD>');
    document.write  ('          <TD CLASS="pu-regtext" ALIGN="right">');
    document.write  (             $ArticlePrice);
    document.writeln(          '</TD>');
    document.write  ('          <TD ALIGN="right" CLASS="pu-regtext">');
    document.write  (            '<INPUT ID="' + $ListItemID + '" NAME="OrderQuantity"');
    document.write  (            ' SIZE="3" VALUE="' + $ArticleQuantity + '" TYPE="text"');
    document.write  (            ' ONCHANGE="ChangeListItemQuantity(' + $i + ')"');
    document.write  (            ' CLASS="bestellen-textfield">');
    document.writeln(          '</TD>');
    document.writeln('        </TR>');
  };
  document.writeln('        <TR HEIGHT="27">');
  document.writeln('          <TD COLSPAN="3">&nbsp;</TD>');
  document.writeln('          <TD CLASS="pu-regtext">Totaalprijs:</TD>');
  document.write  ('          <TD ALIGN="right" CLASS="pu-regtext">');
  document.write  (            '<INPUT ID="TotalPriceField" READONLY NAME="TotalPrice"');
  document.write  (            ' SIZE="10" VALUE="" TYPE="text">');
  document.writeln(          '</TD>');
  document.writeln('          <TD>&nbsp;</TD>');
  document.writeln('        </TR>');
  document.writeln('        <TR HEIGHT="32">');
  document.write  ('          <TD COLSPAN="6" CLASS="pu-regtext" ALIGN="center">');
  document.write  (            'Artikel verwijderen? Zet ' + $SingleQuote + 'aantal');
  document.write  (             $SingleQuote + ' op nul en toon ');
  document.write  (            '<A HREF="#">de nieuwe totaalprijs.</A>');
  document.writeln(          '</TD>');
  document.writeln('        </TR>');
  document.writeln('      </TABLE>');
  document.writeln('    </FORM>');
  document.writeln('    <TABLE WIDTH="650" BORDER="0" CELLPADDING="0" CELLSPACING="0">');
  document.writeln('      <TR>');
  document.write  ('        <TD CLASS="pu-regtext">');
  document.write  (          '<A HREF="javascript:self.close();">');
  document.write  (            '<IMG SRC="../images/frm-sluiten.gif" WIDTH="160" HEIGHT="30"');
  document.write  (            ' BORDER="0">');
  document.write  (          '</A>');
  document.writeln(        '</TD>');
  document.write  ('        <TD ALIGN="center" CLASS="pu-regtext">');
  document.write  (          '<A HREF="javascript:javascript:EmptyOrderList();">');
  document.write  (            '<IMG SRC="../images/frm-leegmaken.gif" WIDTH="160"');
  document.write  (            ' HEIGHT="30" BORDER="0">');
  document.write  (          '</A>');
  document.writeln(        '</TD>');
  document.write  ('        <TD ALIGN="right" CLASS="pu-regtext">');
  document.write  (          '<A HREF="bestellen.php">');
  document.write  (            '<IMG SRC="../images/frm-afmaken.gif" WIDTH="160" HEIGHT="30"');
  document.write  (            ' BORDER="0">');
  document.write  (          '</A>');
  document.writeln(        '</TD>');
  document.writeln('      </TR>');
  document.writeln('    </TABLE>');
  document.writeln('  </TD>');
  document.writeln('</TR>');
  DisplayTotalPrice($OrderListItems);
};

function WriteMailList()
{
  var $OrderListItems = GetOrderListItems();
  if ($OrderListItems.length != 0)
  {
    var $TotalPrice = CalculateTotalPrice($OrderListItems);
    var $MailList = new String();
    var $AccentedA = unescape('%E0');
    var $MailListHorizontalSeparatorLine = '----------------\n';
    for (var $i = 0; $i < $OrderListItems.length; $i++)
    {
      $MailList += $OrderListItems[$i][0] + ': ' + $OrderListItems[$i][1];
      for (var $j = 0; $j < $OrderListItems[$i][2].length; $j++)
      {
        if ($j == 0)
        {
          $MailList += ' [';
        };
        $MailList += $OrderListItems[$i][2][$j];
        if ($j != ($OrderListItems[$i][2].length - 1))
        {
          $MailList += ', ';
        }
        else
        {
          $MailList += ']';
        };
      };
      $MailList += ' ' + $AccentedA + ' ' + $OrderListItems[$i][3] + ' euro; ';
      $MailList += 'Aantal: ' + $OrderListItems[$i][4] + '\n';
    };
    $MailList += $MailListHorizontalSeparatorLine;
    $MailList += 'Totaalprijs: ' + $TotalPrice + ' euro';
    return $MailList + '\n';
  }
  else
  {
    return 'System error! Please contact the webmaster.';
  };
};

