Javascript Code Review: DO NOT MERGE

Mostly procedural javascript.  That is fine.  

Look for the comments in the code labeled 'CODE REVIEW'