function URL(url) {
	this.url = url;
	this.queryCount = 0;
	this.search = "";
	this.fileName = "";
	this.parentDirName = "";
	this.hash = "";
	this.values = [];

	if ((url != null) && (url != "")) {
		this.decode();
	}
}

URL.prototype.parseQuery = function() {
	var eql  = 0;
	var amp  = 0;
	var rtn  = 0;
	var pnt  = 1;

	this.search = this.url.substring(this.url.indexOf('?'), this.url.length);
	this.values = [];

	while (rtn < this.search.length) {

		rtn = this.search.indexOf('=', pnt);
		if(rtn <= 0) break;

		eql = rtn;
		rtn = this.search.indexOf('&', eql);

		if(rtn > 0) {
			amp = rtn;
			this.values[unescape(this.search.substring(pnt, eql))] = unescape(this.search.substring(eql + 1, rtn));
			pnt = ++rtn;

		} else {
			this.values[unescape(this.search.substring(pnt, eql))] = unescape(this.search.substring(eql + 1, this.search.length));
			this.queryCount++;
			break;
		}

		this.queryCount++;
	}
}


URL.prototype.parseFileName = function() {
	var buff = this.url;
	var pnt = 0;
	var esc = new Array("/", "\\");

	for (var i = 0; i < esc.length; i ++) {
		pnt = buff.lastIndexOf(esc[i]);

		if (pnt > 0) {
			buff = buff.substring(pnt+1, buff.length);
			break;
		}
	}

	pnt = buff.indexOf('?');
	if (pnt != -1) {
		buff = buff.substring(0, pnt);
	}

	pnt = buff.indexOf('#');
	if (pnt != -1) {
		this.hash = buff.substring(pnt, buff.length);
	}

	this.fileName = buff;
}

URL.prototype.parseParentDirName = function() {

	var buff = this.url;
	var pnt = 0;
	var esc = new Array("/", "\\");

	for (var i = 0; i < esc.length; i ++) {
		pnt = buff.lastIndexOf(esc[i]);
		if (pnt >= 0) {
			buff = buff.substring(buff.lastIndexOf(esc[i], pnt-1)+1, pnt);
			break;
		}
	}

	this.parentDirName = buff;
}


URL.prototype.getValue = function(key) {
	return this.values[key];
}


URL.prototype.getQueryCount = function() {
	return this.queryCount;
}

URL.prototype.isValueExists = function(key) {
	var value = this.getValue(key);
	return (value != null) && (value.length != 0);
}

URL.prototype.getFileName = function() {
	return this.fileName;
}

URL.prototype.getParentDirName = function() {
	return this.parentDirName;
}

URL.prototype.getHash = function() {
	return this.hash;
}

URL.prototype.getSearch = function() {
	return this.search;
}

URL.prototype.decode = function() {
	this.parseQuery();
	this.parseFileName();
	this.parseParentDirName();
}
