
function httpget() {
	this.locationString = window.location.href;
	this.vars = null;
	this.base = null;
	this.result = null;

	this.parse = function() {
		var str = this.locationString;
		if (str.indexOf('?') < 0) {
			this.vars = {};
			this.base = str;
			return;
		}
		str = str.split('?');
		this.base = str[0];
		str = str[1];
		if (str.indexOf('&') > -1) {
			str = str.split('&');
		} else {
			str = [str];
		}
		var tmp = {};
		for (var x=0; x<str.length; x++) {
			if (str[x].indexOf('=') > -1) {
				var arr = str[x].split('=');
				if (tmp[arr[0]] == undefined) {
					tmp[arr[0]] = [arr[1]];
				} else {
					tmp[arr[0]].push(arr[1]);
				}
			}
		}
		this.vars = tmp;
	}

	this.build = function() {
		this.result = this.base + '?';
		var count = 0;
		for (var i in this.vars) {
			if (this.vars[i] == undefined)
				continue;
			count++;
			for (var x=0; x<this.vars[i].length; x++) {
				if (this.result != this.base + '?') {
					this.result += '&';
				}
				this.result += i + '=' + this.vars[i][x];
			}
		}
		if (count < 1)
			this.result = this.base;
	}

	this.append = function(key, value) {
		if (this.vars[key] == undefined)
			this.vars[key] = [];
		this.vars[key].push(value);
	}

	this.exists = function(key) {
		return (this.vars[key] != undefined);
	}

	this.get = function(key) {
		return (this.exists(key) ? this.vars[key] : undefined);
	}

	this.replace = function(key, value) {
		this.vars[key] = [value];
	}

	this.remove = function(key, value) {
		this.vars[key] = undefined;
	}

	this.navigate = function() {
		this.build();
		window.location.href = this.result;
	}

	this.parse();
}


