
// Standard function for getting cookie
function getHelpCookie(name)
{
	if(document.cookie.length > 0) {
		offset = document.cookie.indexOf(name + '=');
		if(offset == -1) {
			return '';
		}
		// if cookie exists
		offset += name.length + 1;
		end = document.cookie.indexOf(';', offset);
		if(end == -1) {
			end = document.cookie.length;
		}
		return unescape(document.cookie.substring(offset, end));
	}
	return '';
}

// Constructor for object to hold name value pairs
function hiddenVar (varName, varValue) {
  this.varName = varName;
  this.varValue = varValue;
}

// Get help cookie, populate form variables and submit form
function sendHelpForm()  {
	var str = new String(getHelpCookie('help_info'));
	var arr = new Array();
	// write cookie data values to an array
	var i = 0;
	token = str.substring(0, str.indexOf('&'));
	str = str.substring(token.length + 1, str.length);
	while (token.length > 0) {
		var y = token.indexOf('=');
		var vName = token.substring(0, y);
		var vVal = token.substring(y+1, token.length);
		arr[i++] = new hiddenVar (vName, vVal);
		token = str.substring(0, str.indexOf('&'));
		str = str.substring(token.length + 1, str.length);
	}
	var f = document.helpForm;
	// foreach array item, set form variable
	for (j = 0; j < arr.length; j++) {
		var s = 'f.' + arr[j].varName + '.value=' + '"' + arr[j].varValue + '"';
		eval(s);
	}
	// submit form	
	f.submit();
}

