﻿var obj_artwork = new Object();

obj_artwork.shippingCost = {tube:15.00, flat:35.00};

// Obs: Each entry in the inventory list should carry the follows information, in order.
//      item number, item type, item name, unit price, standard shipping cost, additional shipping cost
var inventoryList = [
  "JH100 | original | In the Wind | 900.00 | 0.00 | 0.00",
  "JH101 | original | Ancient Site | 400.00 | 0.00 | 0.00",
  "JH102 | original | Trinity | 800.00 | 0.00 | 0.00",
  "JH103 | original | Harmonious | 675.00 | 0.00 | 0.00",
  "JH104 | original | Prosperity | 675.00 | 0.00 | 0.00",
  "JH105 | original | Scouring Rush |1000.00 | 0.00 | 0.00",
  "JH106 | original | Splendid Squares | 900.00 | 0.00 | 0.00",
  "JH107 | original | Veronica's Secret | 900.00 | 0.00 | 0.00",
  "JH108 | original | Endless Summer | 800.00 | 0.00 | 0.00",
  "JH109 | original | Fall Colors | 900.00 | 0.00 | 0.00",
  "JH110 | original | Arabian Nights | 1100.00 | 0.00 | 0.00",
  "JH111 | original | The Settlement | 250.00 | 0.00 | 0.00",
  "JH112 | original | Labyrinth | 1500.00 | 0.00 | 0.00",
  "JH113 | original | Side by Side | 500.00 | 0.00 | 0.00",
  "JH114 | original | Renaissance Diana | 2500.00 | 0.00 | 0.00",
  "JH115 | original | Renaissance Charles | 2500.00 | 0.00 | 0.00",
  "JH116 | original | A Touch of Class | 3000.00 | 0.00 | 0.00",
  "JH117 | original | Freeform | 250.00 | 0.00 | 0.00",
  "JH118 | original | Eye of the Tiger | 900.00 | 0.00 | 0.00",
  "JH119 | original | Nurturing | 2000.00 | 0.00 | 0.00",
  "JH120 | original | Into the Light | 2000.00 | 0.00 | 0.00",
  "JH121 | original | King of the Savannah | 2000.00 | 0.00 | 0.00",
  "JH122 | original | Solitude | 700.00 | 0.00 | 0.00",
  "JH123 | original | White Lion | 1200.00 | 0.00 | 0.00",
  "JH124 | original | Majestic Leader | 1200.00 | 0.00 | 0.00",
  "JH125 | original | Shadow Eyes | 900.00 | 0.00 | 0.00",
  "JH126 | original | Intense Eyes | 900.00 | 0.00 | 0.00",
  "JH127 | original | Stop & Smell the Daisies | 1400.00 | 0.00 | 0.00",
  "JH128 | original | Tree Hugger | 1500.00 | 0.00 | 0.00",
  "JH129 | original | On the Shore | 250.00 | 0.00 | 0.00",
  "JH130 | original | Field of Dreams | 150.00 | 0.00 | 0.00",
  "JH131 | original | Under the Sea | 600.00 | 0.00 | 0.00",
  "JH132 | original | Laughing Lorries | 600.00 | 0.00 | 0.00",
  "JH133 | original | Six Pack | 1200.00 | 0.00 | 0.00",
  "JH134 | original | Hollyhocks & Hummingbirds | 900.00 | 0.00 | 0.00",
  "JH135 | original | All Couped Up | 300.00 | 0.00 | 0.00",
  "JH136 | original | Perfectly Proud | 1100.00 | 0.00 | 0.00",
  "JH137 | giclee | Divine Proportion | 300.00 | 20.00 | 0.00",
  "JH138 | giclee | Welcome to My Universe | 300.00 | 20.00 | 0.00",
  "JH139 | giclee | Fire in the Belly | 300.00 | 20.00 | 0.00",
  "JH140 | giclee | Out of This World | 300.00 | 20.00 | 0.00",
  "JH141 | giclee | Opening | 275.00 | 20.00 | 0.00",
  "JH142 | limited edition | Feel'n Their Oats | 125.00 | 0.00 | 0.00",
  "JH143 | limited edition | On the Watch | 125.00 | 0.00 | 0.00",
  "JH144 | limited edition | Pride of the Rockies | 125.00 | 0.00 | 0.00",
  "JH145 | limited edition | Murky Waters | 125.00 | 0.00 | 0.00",
  "JH146 | limited edition | His Highness | 145.00 | 0.00 | 0.00",
  "JH147 | limited edition | Nuttal's Cottontail | 65.00 | 0.00 | 0.00",
  "JH148 | limited edition | Our Cabin | 125.00 | 0.00 | 0.00",
  "JH149 | limited edition | Africa | 45.00 | 0.00 | 0.00",
  "JH150 | limited edition | Antarctica | 45.00 | 0.00 | 0.00",
  "JH151 | limited edition | Asia | 45.00 | 0.00 | 0.00",
  "JH152 | limited edition | Australia | 45.00 | 0.00 | 0.00",
  "JH153 | limited edition | Europe | 45.00 | 0.00 | 0.00",
  "JH154 | limited edition | North America | 45.00 | 0.00 | 0.00",
  "JH155 | limited edition | South America | 45.00 | 0.00 | 0.00",
  "JH156 | open edition | Bengal Pride | 40.00 | 0.00 | 0.00",
  "JH157 | open edition | Soul Mates | 40.00 | 0.00 | 0.00",
  "JH158 | open edition | Elusive Encounter | 40.00 | 0.00 | 0.00",
  "JH159 | open edition | Special Bond | 30.00 | 0.00 | 0.00",
  "JH160 | open edition | Under Cover | 20.00 | 0.00 | 0.00",
  "JH161 | open edition | Reflections | 30.00 | 0.00 | 0.00",
  "JH162 | open edition | Contemplating Moments | 20.00 | 0.00 | 0.00",
  "JH163 | open edition | Silent Approach | 30.00 | 0.00 | 0.00",
  "JH164 | open edition | The Watcher | 30.00 | 0.00 | 0.00",
  "JH165 | open edition | Snow Leopard | 30.00 | 0.00 | 0.00",
  "JH166 | open edition | A Mothers Love | 20.00 | 0.00 | 0.00",
  "JH167 | open edition | Into the Light | 30.00 | 0.00 | 0.00",
  "JH168 | open edition | Rooster 1 | 20.00 | 0.00 | 0.00",
  "JH169 | open edition | Rooster 2 | 20.00 | 0.00 | 0.00",
  "JH170 | open edition | All Couped Up | 20.00 | 0.00 | 0.00",
  "JH171 | open edition | Savannah Stroll | 30.00 | 0.00 | 0.00",
  "JH172 | open edition | Two by Two | 30.00 | 0.00 | 0.00",
  "JH173 | original | Opening | 900.00 | 0.00 | 0.00",
  "JH174 | original | Triumvirate | 1500.00 | 0.00 | 0.00",
  "JH175 | original | Aspens | 950.00 | 0.00 | 0.00", 
  "JH176 | original | Primordial | 900.00 | 0.00 | 0.00",
  "JH177 | original | Tree Frog 1 | 800.00 | 0.00 | 0.00",
  "JH178 | original | Tree Frog 2 | 800.00 | 0.00 | 0.00",
  "JH179 | original | Peppers | 900.00 | 0.00 | 0.00",
  "JH180 | original | Jupiter | 1100.00 | 0.00 | 0.00",
  "JH181 | original | On the Edge | 1200.00 | 0.00 | 0.00",
  "JH182 | original | World | 2000.00 | 0.00 | 0.00",
  "JH183 | limited edition print | Spirit of the Jungle | 125.00 | 0.00 | 0.00",
  "JH184 | open edition | Cedar Breaks | 20.00 | 0.00 | 0.00",
  "JH185 | giclee | LA Louie | 40.00 | 0.00 | 0.00",
  "JH186 | open edition | Black is Beautiful | 30.00 | 0.00 | 0.00", 
  "JH187 | original | Lemur | 150.00 | 0.00 | 0.00",
  "JH188 | open edition | fish trio | 60.00 | 0.00 | 0.00",
  "JH189 | original | fur border | 150.00 | 0.00 | 0.00",
  "JH190 | original | Tarot | 50.00 | 0.00 | 0.00",
  "JH191 | open edition | numbers |10.00 | 0.00 | 0.00",
  "JH192 | original | Yorkies | 40.00 | 0.00 | 0.00",
  "JH193 | original | Spring Break | 500.00 | 0.00 | 0.00",
  "Do not place items below this point."
];

// Eliminates space characters from the ends of a specified string.
function trim(str_content)
{
  if (typeof str_content == 'string' && str_content.length > 0)
  {
    var characterIsWhitespace = function(str_character)
    {
      return str_character.charCodeAt(0) <= 32 || str_content.charAt(0) == '\u00A0';
    };
    while (characterIsWhitespace(str_content.charAt(0)))
    {
      str_content = str_content.slice(1);
    }
    while (characterIsWhitespace(str_content.charAt(str_content.length - 1)))
    {
      str_content = str_content.slice(0, str_content.length - 1);
    }
  }
  return str_content;
}

function configureInventory()
{
  var tokenList = new Array();
  var artwork = new Object();
  for (var inventoryIndex = 0; inventoryIndex < self.inventoryList.length; inventoryIndex++)
  {
    tokenList = self.inventoryList[inventoryIndex].split('|');
    for (var tokenIndex = 0; tokenIndex < tokenList.length; tokenIndex++)
    {
      tokenList[tokenIndex] = self.trim(tokenList[tokenIndex]);
    }
    artwork = self.obj_artwork[tokenList[0]] = new Object();
    artwork.type = tokenList[1];
    artwork.name = tokenList[2];
    artwork.price = tokenList[3];
    artwork.standardShipping = tokenList[4];
    artwork.additionalShipping = tokenList[5];
  }
}

self.configureInventory();

