function putClientHash(name, value, domain, path) {
    document.cookie = name + '=' + value +
		((domain) ? '; domain=' + domain : '') +
        ((path) ? '; path=' + path : '; path=/');

}

function getClientHash(name) {
    var dc = document.cookie;
    var prefix = name + '=';
    var begin = dc.indexOf('; ' + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(';', begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function needsClientHash(hashName, hashValue, clientSrc, nextPage) {
	var clientHash = getClientHash(hashName);
		
	var needsClientHash = clientHash == hashValue;
	
	if (!needsClientHash) {
		var currLoc = unescape(window.location.href);
		var index = currLoc.indexOf(hashValue, 0);
		needsClientHash = index > -1;
	}

	if (!needsClientHash) {
		window.location.href = nextPage + '&winLoc=' + window.location + '&c=' + clientHash + '&s=' + hashValue + '&cs=' + clientSrc;
	}

	return needsClientHash;
}

