fixing invitation bug, moving javascript into head