// This block grabs the parameters from the URL line and stores it in the parameters variable
var URL = document.URL; //get the full url
var URL_No_Params = "";
var lastSlash = URL.lastIndexOf('/'); //find the position of the last / to get the server/directory location
var serverLocation = URL.slice(0, lastSlash); //slice the url at the position of the last slash
if (URL.indexOf('?') != -1) { // if there is a ? in the url
	var trimPosition = URL.indexOf('?'); //find the position of ?
	URL_No_Params = URL.substring(0, trimPosition);
	var parameters = URL.slice(trimPosition); } // slice at the position of the ? to get the trailing parameters
else { var parameters = "" }

// This function parses the parameters and returns the value of the requested parameter
var params = parameters.slice(1, parameters.length); // get rid of '?'
var aParams = params.split('&'); // separate each parameter

function QueryString(paramRequest) {
	for(i=0; i<aParams.length; i++){
		var paramName = aParams[i].split('=')[0]; // keep name and remove value
		var paramValue = aParams[i].split('=')[1]; // remove name and keep value
		if(paramRequest==paramName){ return paramValue;	}
	}
	return '';
}

function URL_Minus_Param(paramToRemove) {
	var newURL = URL_No_Params+"?";
	for(i=0; i<aParams.length; i++) {
		var paramName=aParams[i].split('=')[0]; // get just the param name
		if(paramName != paramToRemove) { newURL+=aParams[i]+"&"; } // if not to remove then add it to our string
	}
	return newURL.slice(0, newURL.length-1);
}
