function html_entity_decode(str) {
  var ta=document.createElement("textarea");
  ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
  return ta.value;
}

function goToUrl(url) {
	window.location.href = url;
}

function enter2submit(handler) {
	return function(e) {
		if(!e) e = window.event;
		if(e.keyCode == 13) {
			handler.call(this);
			return false;
		}
	}
}

/**
* This function adds to all input of a form (defined by formid) a listener to
* for when the user presses the ENTER key. The function listenerFunction is called
* when the ENTER key is pressed. If any checkFunction was defined, the function
* is called before listenerFunction and it's only if it returns true that the
* listenerFunction is called.
*/
function addPressEnterListenerToForm(formId, listenerFunction, checkFunction) {
	jQuery('#'+formId).find('input').each(
		function(index) {
			$(this).onkeydown = function(event) {
				if(!event) event = window.event;
				if(event.keyCode==13) {
					if (checkFunction) {
						var valid = checkFunction(event);
						if (valid) {
							listenerFunction();
						}
					} else {
						listenerFunction();
					}
				}
			}
		}
	);
}