if(typeof(window.URLPARSER_DEFINED) == 'undefined') {
	window.URLPARSER_DEFINED = true;
	
	URLParser = function () {}
	
	URLParser.parse = function(url) {
		this.url = url;
		
		var result = this.url.match(this.regexp);
		
		this.protocol = result[1];
		this.host = result[2];
		this.port = result[4];
		this.path = result[5];
		this.query = result[6];
		this.baseurl = this.protocol + "://" + this.host
		if(this.port) {
			this.baseurl = this.baseurl + ":" + this.port;
		}
		if(this.path) {
			this.baseurl = this.baseurl + "/" + this.path;
		}
		return this;
	}
	
	URLParser.getQueryParams = function() {
		if(typeof(this.query) == 'undefined' || this.query == '') {
			return false;
		}
		
		if(typeof(this.queryParams) == 'Object') {
			return this.queryParams;
		}
		
		var paramPairs = this.query.split("&");
		if(paramPairs.length > 0) {
			this.queryParams = new Object();
			for(var i = 0;i < paramPairs.length;i++) {
				var paramPair = paramPairs[i].split("=");
				this.queryParams[paramPair[0]] = paramPair[1];
			}
		}
		return this.queryParams;
	}
	
	URLParser.prototype.parse = URLParser.parse;
	URLParser.prototype.getQueryParams = URLParser.getQueryParams;
	URLParser.prototype.regexp = /(https?):\/\/([a-zA-Z0-9_\-\.]+)(:([0-9]+))?\/?([a-zA-Z0-9_\.]+)?\??(.*)?/;
}
