﻿function Location() {
	var i, j, a, b, p
	this.parameters = new Array()
	if((j=document.location.href.lastIndexOf('?'))==-1)
		this.path = document.location.href
	else {
		this.path = document.location.href.substring(0, j)
		a = document.location.href.substr(j+1).split('&')
		for (p in a) {
			b = a[p].split('=')
			this.parameters[b[0]] = b[1]
		}
	}

	this.querystring = function() {
		var p, s = ''
		for (p in this.parameters)
			if(this.parameters[p]!=null)
				s+= (s==''?'?':'&') + p + '=' + this.parameters[p].toString(10).split('#')[0]
		return s
	}

	this.location = function(page_name) {
		return (page_name==null || page_name==''?this.path:page_name) + this.querystring()
	}
	
	this.clear_parameters = function() {
		var i
		for(i=0;i<arguments.length;i++)
			if(this.parameters[arguments[i]]!=null)
				this.parameters[arguments[i]]=null
	}
}
var page = new Location()