From the looks of it, a decent script. However it is riddled with errors.
Several Min/Max variables have a period before them. Removing these is a simple matter.
However, I have also recieved a NoMethodError code. I honestly doubt I can fix that. SO I'll leave it up to you...