Javascript query string parser & encoder