function get_url_hash(argument) {
	var hash = location.hash.replace('#','');
	if(argument=='' || argument==undefined) {
		return hash;
	} else {
		var foundhash = false;
		// specific argument given - let's find the value attached. 
		var hashblock = hash.split(',');
		if(hashblock.length>0) {
			for(x in hashblock) {
				if(typeof hashblock[x]=="string") {
					var hasharray = hashblock[x].split(':');
					if(hasharray[0]==argument) {
						return hasharray[1];
						foundhash = true;
					}
				}
			}
		}
		if(foundhash==false) {
			return false;
		}
	}
}

function modify_url_hash(argument, value) {
	// This function goes through the entire hash,
	// figures out which parts of the hash should be added, updated or removed based on entry, 
	// and then spits out final result. 
	var hash = get_url_hash();
	var foundhash = false; // foundhash is set to false by default. if this hash is NOT found, then we add it at the end! 
	var hashcount = 0; // keep count of total # so as to determine where to put the commas etc. 
	var newhash = '';
	if(hash.length>0) {
		var hashblock = hash.split(',');
		for(x in hashblock) {
			if(typeof hashblock[x]=="string") {
				var hasharray = hashblock[x].split(':');
				// while looping, IF the current hash block's name matches the argument value, replace the value with the value var. 
				if(hasharray[0]==argument) {
					hasharray[1] = value;
					foundhash = true;
				}
				
				// now append the hash value with the new hash argument:value pair and keep extending
				if(hasharray[1]!=false && hasharray[1]!='' && hasharray[1]!=undefined) { // if new value is NOT false, we keep it in.. otherwise don't feed it to new hash so it disappears.
					if(hashcount>0) { newhash = newhash+','; }
					newhash = newhash+hasharray[0]+':'+hasharray[1];
					hashcount++;
				}
			}
		}
	}
	
	if(foundhash==false && value!='' && value!=undefined && value!=false) {
		// this is a new hash block. 
		if(hashcount>0) { newhash = newhash+','; }
		newhash = newhash+argument+':'+value;
	}
	location.hash = newhash;
}
