General structure, added some jQuery-based sadness