﻿function parseUrl(data) {// ParseUrl
    var e = /((http|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?/;
    if (data.match(e)) {
        return { url: RegExp['$&'],
            protocol: RegExp.$2,
            host: RegExp.$3,
            path: RegExp.$4,
            file: RegExp.$6,
            hash: RegExp.$7
        };
    }
    else {
        return { url: "", protocol: "", host: "", path: "", file: "", hash: "" };
    }
}

function getParameterByName(location, name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(location);
    if (results == null)
        return "";
    else
        return results[1];
}
