I THINK the problem is in your arrays. Your definition var inventorySell[20]; will only give you an array going from inventorySell[0] to inventorySell[19] but your first IF is looking for inventorySell[20] which will contain an unknown random value.
Everything else looks OK but I didnt look that hard.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial