// based on http://www.netspade.com/articles/javascript/cookies.xml

/* Sets a Cookie with the given name and value. */
function setCookie(name, value)
{
    document.cookie= name + "=" + escape(value);
}

/* 
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return '';
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


/* Remove the _desc= parameter from the search parameters, return the rest of the searchstring */
function exciseDesc() {
	startDesc = document.location.search.indexOf('_desc=');
	if (startDesc == -1) return document.location.search.substring(1);

	endDesc = document.location.search.indexOf('&', startDesc);
	if (endDesc == -1) {
		if (document.location.search.charAt(startDesc-1) == '&')
			return document.location.search.substring(1, startDesc-1);
		else
			return document.location.search.substring(1, startDesc);

	} else {
		return document.location.search.substring(1, startDesc) + document.location.search.substring(endDesc+1);
	}
}

