/**
 * @description An Exception class.
 *
 * @author Sami Keskinen
 * @since 14.06.2006
 */
function Exception(strName, strDescription) {
  /*
    14.06.2006 SK:
      Defining name and description Fields.
  */
  this.name = strName;
  this.message = strDescription;
}

/**
 * @description A function to determine whether or not the given variable
 *              is void.
 *
 * @author Sami Keskinen
 * @since 14.06.2006
 *
 * @return Boolean value; true when variable is void, false otherwise.
 */
function isVoid(variable) {
  return ((typeof variable) == "undefined");
}

/**
 * @description Checks if input is a string.
 *
 * @author Sami Keskinen
 * @since 15.08.2006
 *
 * @param variable the input to be checked.
 *
 * @return Boolean value, indicating whether or not the given input is
 *         a string.
 */
function isString(variable) {
  return ((typeof variable) == "string");
}

/**
 * @description A function to include scripts to HTML compilations dynamically.
 *
 * @author Sami Keskinen
 * @since 14.06.2006
 *
 * @param strScript The filename of the includable script.
 *
 * @throws Exception('invalidInput') If given input is not a string.
 */
var arrScripts = new Array();

function include(strScript) {
  /*
    14.06.2006 SK:
      Check input.
  */
  if (typeof strScript != "string") {
    throw new Exception('invalidInput', 'The given script name is invalid.');
  }

  /*
    14.06.2006 SK:
      Check if the script is already included.
  */
  for (var iItem in arrScripts) {
    if (arrScripts[iItem] == strScript) {
      return true;
    }
  }

  /*
    14.06.2006 SK:
      Search for the correct add position in HTML document.
  */
  var objHTML = document.getElementsByTagName('head').item(0);

  /*
    14.06.2006 SK:
      Construct a script HTML element.
  */
  var elemJS = document.createElement('script');
  elemJS.setAttribute('language', 'javascript');
  elemJS.setAttribute('type', 'text/javascript');
  elemJS.setAttribute('src', strScript);

  /*
    14.06.2006 SK:
      Append the created element to the HTML DOM.
  */
  objHTML.appendChild(elemJS);

  /*
    14.06.2006 SK:
      Append the script name to included scripts check array.
  */
  arrScripts.push(strScript);

  return false;
}

/*
Clear default form value
*/

function clearText(field){
  if (field.defaultValue==field.value)
    field.value = "";
} 
