function s4() {
        return Math.floor((1 + Math.random()) * 0x10000)
                .toString(16)
                .substring(1);
    }
Function s4() and guid() originate from:
http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript