/**
 *
 */
function createPackage(str, shorthand)
{
    if (!str || (str == ''))  throw new Error('No package specified');
    if (str.indexOf('.') < 0) throw new Error('Package must contain at least three dot-separated parts: ' + str);
    if (shorthand in window)  throw new Error('Shorthand notation already exists in global object (' + shorthand + ')');

    var namespace = window;

    var parts = str.split('.');
    if (parts.length > 2) {

        for (var i = 0; i < parts.length; i++) {
            if (!/^[a-zA-Z\_\$]{1}[a-zA-Z0-9\_\$]*$/.test(parts[i])) throw new Error('Invalid part of package: ' + parts[i]);

            // create object, if not already created
            if (!namespace[parts[i]]) namespace[parts[i]] = {};

            namespace = namespace[parts[i]];
        }

    } else {
        throw new Error('Package contains less than three parts: ' + str);
    }

    window[shorthand] = namespace;
    return namespace;
}