// JavaScript Document

function submit_action(action, id, submitVar) {
	if (submitVar == undefined) submitVar = true;
	document.form.action.value = action;
	document.form.id.value = id;
	if (submitVar) document.form.submit();
}

function confirm_action(message, action, id, submitVar) {
  if (confirm(message)) {
    submit_action(action, id, submitVar);
  }
}

function clear_text_field(id, defaultValue) {
	var s;
	s = document.getElementById(id);
	if (s.value == defaultValue) {
		s.value = "";
		s.style.color = "#000000";
	}
}

function clear_textarea(ta) {
  if (!textareaTouched) {
    ta.value = "";
    ta.style.color = "#000000";
    ta.style.fontSize = ".9em";
    ta.style.fontStyle = "normal";
    textareaTouched = true;
  }
}

function enter_action(action, e) {
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;

  if (keycode == 13) {
   submit_action(action, "");
   return false;
  } else {
   return true;
  }
}

function show_element(id) {
  document.getElementById(id).style.display = "block";
}

function urlencode(str) {
  str = escape(str);
  str = str.replace('+', '%2B');
  str = str.replace('%20', '+');
  str = str.replace('*', '%2A');
  str = str.replace('/', '%2F');
  str = str.replace('@', '%40');
  return str;
}
