Vars = function(qStr) 
{
	this.numVars = 0;
	if(qStr != null) 
	{
		var nameValue, name;
		var pairs = qStr.split('&');
		var pairLen = pairs.length;
		for(var i = 0; i < pairLen; i++) 
		{
			var pair = pairs[i];
			if( (pair.indexOf('=')!= -1) && (pair.length > 3) ) 
			{
				var nameValue = pair.split('=');
				var name = nameValue[0];
				var value = nameValue[1];
				if(this[name] == null && name.length > 0 && value.length > 0) 
				{
					this[name] = value;
					this.numVars++;
				}
			}
		} 
	}
}

Vars.prototype.toString = function(pre) 
{
	var result = '';
	if(pre == null) 
	{ 
		pre = ''; 
	}
	for(var i in this) 
	{
		if(this[i] != null && typeof(this[i]) != 'object' && typeof(this[i]) != 'function' && i != 'numVars') 
		{
			result += pre + i + '=' + this[i] + '&';
		}
	}
	if(result.length > 0) 
		result = result.substr(0, result.length-1);
	return result;
}

Vars.prototype.isEqual = function(aVars) 
{
	if(this.view != null && aVars.view != null) 
	{
		if(unescape(this.view) != unescape(aVars.view)) 
		{ 
			return false; 
		}
	}
	if(this.viewName != null && aVars.viewName != null) 
	{
		if(unescape(this.viewName) != unescape(aVars.viewName)) 
		{ 
			return false; 
		}
	}	
	if(this.numVars != aVars.numVars) 
	{ 
		return false; 
	}
	for(var k in aVars) 
	{
		if(k != null && typeof k != 'object' && typeof k != 'function') 
		{
			if(unescape(this[k]) != unescape(aVars[k])) 
			{ 
				return false; 
			}
		}
	}
	return true;
}

function getHash(wRef) 
{
	var hashStr = '';
	if(wRef.location.hash.length > 1) 
	{
		var locStr = new String(wRef.location);
		hashStr = locStr.slice(locStr.indexOf('#') + 1);
	}
	return hashStr;
}

function getSearch(wRef) 
{
	var searchStr = '';
	if(wRef.location.search.length > 1) 
	{
		searchStr = new String(wRef.location.search);
		searchStr = searchStr.substring(1, searchStr.length);
	}
	return searchStr;
} 

function getMainURI() 
{
	var v = new Vars(getHash(window)+'&'+getSearch(window));
	return 'main.html#' + v.toString();
} 
