function parseUrl(url) {
    /* Parse URL into protocol, host, path, file and hash (and url)
     *    must be URL only
     * Args: url
     * Return object or null if no match
     */

    url = url.replace(/^\s+|\s+$/g, ''); //alltrim

    if (url.match(/^((http|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?$/)) {
        //RegExp['$&'] is null in some browsers s/b original url
        return  {url: RegExp['$&'], protocol: RegExp.$2,host:RegExp.$3,path:RegExp.$4,
                 file:RegExp.$6,hash:RegExp.$7};
    }
    else {
        return null;
    }
}