var SEPARATOR = "|";

function addVariableToUrl(url, variableName, value)
{
  return url + ((url.indexOf("?") < 0) ? "?" : "&") + variableName + "=" + escape(value);
}

function addArrayToUrl(url, arrayName, arrayValue)
{
  return url + ((url.indexOf("?") < 0) ? "?" : "&") + arrayName + "=" + escapeArray(arrayValue);
}

function escapeArray(array)
{
  var result = SEPARATOR;
  for (var index = 0; index < array.length; index++)
  {
    result = result + array[index] + SEPARATOR;
  }
  return result;
}

function systemError(message)
{
  alert(message);
}

function performAction(action)
{
  setPhrameAction(action);
  submitPhrame();
}

function setPhrameAction(action)
{
	set('action', action);
}

function submitPhrame()
{
  document.getElementById('Phrame').submit();
}

function set(id, value)
{
  document.getElementById(id).value = value;
}

function get(id)
{
  return document.getElementById(id).value;
}

function disable(id, disabled)
{
  document.getElementById(id).disabled = disabled;
}

function isChecked(id)
{
  return document.getElementById(id).checked;
}

function check(id, checked)
{
  document.getElementById(id).checked = checked;
}

function submit()
{
  document.forms[0].submit();
}

var buttonActions = new Object();
function disableButton(name, disabled)
{
  elems = document.getElementsByName(name);
  
  if (elems.length > 0)
  {
  
    if (disabled)
    {
      if (!buttonActions[name])
      {
				buttonActions[name] = elems[0].href;
			}
			for (index = 0; index < elems.length; index++)
			{
				elems[index].removeAttribute('href');
				elems[index].className = "disabled";
			}
	  }
	  else
	  {
	    if (buttonActions[name])
	    {
	      for (index = 0; index < elems.length; index++)
	      {
	        elems[index].href = buttonActions[name];
	        elems[index].removeAttribute('class');
	      }
	    }
	  }
	 }
}
