  selectBoxes = new Array();
  directOrder = new Array();
  function selectBoxNotify(formField){;}
  function setOption( text, value, formField, notify, index ){
    formFieldValue = value;
    activeText = text;
    setVisibilityOnly( 'selectBoxContent'+formField, 0, 'none' );
    writeIntoLayer( 'selectedValue' + formField, text );
    if( document.forms.length > 0 ) {
      document.forms[0][formField].value = formFieldValue;
    }
    if( notify ) {
      selectBoxNotify( formField, formFieldValue, index );
    }
  }

  function writeSelectBox( formField, keyValueArray, zIndex, elementWidth, visibleEntries, selectedValue, notify, error, readonly, direction, elementClass ) {
	  var formValue = "";
	  entryFound = false;
	  var pulldownImage  = pulldownGif;
	  if( error == true ){
	    pulldownImage = pulldownErrorGif;
	  }
	  for( i=0; i < keyValueArray.length; i++ ){
	    if( keyValueArray[i+1] == selectedValue ){
	      selectText = keyValueArray[i];
	      formValue  = keyValueArray[i+1];
	      entryFound = true;
	      break;
	    }
	    i++;
	  }
	  if( !entryFound ){
	    selectText = keyValueArray[0];
	    formValue  = keyValueArray[1];
	  }
	  selectBoxes.push( formField );
	  directOrder[formField] = false;
	  selectBox = '';
	  deep = (visibleEntries * 16) + 14;
	  elementClass = ( elementClass != undefined )? elementClass:"";
	  if( readonly == true ){
	    selectBox += '<input type="text" class="defaultReadonly '+elementClass+'" readonly="readonly" value="' + selectText + '" '+'/'+'>';
	    selectBox += '<input type="hidden" name="' + formField + '" value="' + formValue + '" '+'/'+'>';
	  }else{
			selectBox += '<div id="'+ formField +'" class="selectBoxContainer '+elementClass+'" style="z-index:' + zIndex +';">';
			selectBox += '<div class="selectBoxTitle" onClick="setVisibilityOnly(\'selectBoxContent' + formField + '\');" onMouseover="directOrder[\'' + formField + '\']=true;" onMouseout="directOrder[\'' + formField + '\']=false;">';
			selectBox += '<div id="selectedValue' + formField + '" class="selectBoxCaption">' + selectText + '<'+'/div>';
			selectBox += '<div class="selectBoxButton"><img src="' + pulldownImage + '" width="18" height="16" alt="' + selectText + '" '+'/'+'><'+'/div>';
			selectBox += '<'+'/div>';
			selectBox += '<div id="selectBoxContent' + formField + '" class="selectBoxDropdown" style="height:'+deep+'">';
			selectBox += '<div class="selectBoxDropdownList" style="height:'+deep+'">';
			for( i=0; i < keyValueArray.length; i++ ){
			  keyValueArray[i+1] = keyValueArray[i+1].replace(/'/g,"\\\'");
			  var tempValue = keyValueArray[i].replace(/'/g,"\\\'");
			  selectBox += '<a href="javascript://" onclick="setOption(\'' + tempValue + '\',\'' + keyValueArray[i+1] + '\',\'' + formField + '\',' + notify + ',' + zIndex +');return false;" class="selectboxEntry">' + keyValueArray[i] + '<'+'/a>';
			  i++;
			}
			selectBox += '<'+'/div>';
			selectBox += '<'+'/div>';
			selectBox += '<input type="hidden" name="' + formField + '" value="' + formValue + '" '+'/'+'>';
			selectBox += '<'+'/div>';
	  }
	  return selectBox;
	}

function setVisibilityOnly(elementId, visibilityValue, displayValue, initialSet){
  if (typeof elementId != 'object') {
    elementId = document.getElementById(elementId);
  }
  if (elementId) {
    if (typeof visibilityValue == 'undefined') {
      currentState = getDivInformation(elementId, 'visibility');
      if (currentState == '') {
        if (initialSet) {
          currentState = 'visible';
        } else {
          currentState = 'hidden';
        }
      }
      if (currentState == 'hidden') {
        elementId.style.visibility = 'visible';
      } else if (currentState == 'visible') {
        elementId.style.visibility = 'hidden';
      }
    } else if (visibilityValue == 1) {
      elementId.style.visibility = 'visible';
    } else if (visibilityValue == 0) {
      elementId.style.visibility = 'hidden';
    }
  }
}

  function checkSelectBoxStatus() {
    for( j=0; j<selectBoxes.length; j++ ) {
      if( !directOrder[ selectBoxes[j] ] ) {
        setVisibilityOnly( 'selectBoxContent' + selectBoxes[j], 0, 'none' );
      }
    }
  }
  var scriptedCheckbox = "";
  function writeCheckbox( formField, description, boxInputValue, boxInputName, boxIndex, zIndex, elementWidth, notify, error, className, mandatory, readonly ){
    // old true/false checkbox method
    var isChecked = (boxInputValue == "true");
    getCheckboxHTML(formField, description, "false", "true", isChecked, boxInputName, boxIndex, zIndex, elementWidth, notify, error, className, true, readonly);
  }

  function getCheckboxHTML( formField, description, uncheckedValue, checkedValue, isChecked, boxInputName, boxIndex, zIndex, elementWidth, notify, error, className, renderMandatory, readonly ){
    var currentGifDefault;
    var currentGifSwitch;
    var boxInputValue = ( isChecked == true ) ? checkedValue : uncheckedValue;
    if(isChecked){
      currentGifDefault   = checkboxGifHigh;
      currentGifSwitch    = checkboxGif;
      if( error ){
        currentGifDefault = checkboxErrorGifHigh;
        currentGifSwitch  = checkboxErrorGif;
      }
      if( readonly ){
        currentGifDefault = checkboxDisabledGifHigh;
        currentGifSwitch  = checkboxDisabledGif;
        checkReadOnly.push( formField );
      }else{
        for( i = 0; i<checkReadOnly.length; i++ ){
          if( checkReadOnly[i] == formField ){
            checkReadOnly.slice( i, 1 );
          }
        }
      }
    }else{
      currentGifDefault   = checkboxGif;
      currentGifSwitch    = checkboxGifHigh;
      if( error ){
        currentGifDefault = checkboxErrorGif;
        currentGifSwitch  = checkboxErrorGifHigh;
      }
      if( readonly ){
        currentGifDefault = checkboxDisabledGif;
        currentGifSwitch  = checkboxDisabledGifHigh;
        checkReadOnly.push( formField );
      }else{
        for( i = 0; i < checkReadOnly.length; i++ ) {
          if( checkReadOnly[i] == formField ) {
            checkReadOnly.slice( i, 1 );
          }
        }
      }
    }

    description = description.replace( /\n/g, '<br /><br />' );
    checkClient();

	var mandatoryRendering = renderMandatory?" <em>*</em>":"";

    scriptedCheckbox =  '<div id="' + formField + '_container" class="elementContainer checkbox';
    if (className && className != null && className.length > 0) {
      scriptedCheckbox += ' '+className;
    }
    scriptedCheckbox += '" >\n';
    scriptedCheckbox += '  <label for="' + boxInputName + '">' + description + mandatoryRendering+ '</label>\n';
    scriptedCheckbox += '  <img src="' + currentGifDefault + '" id="checkboxImage' + boxIndex + '" preload="' + currentGifSwitch + '" onclick="setCheckbox(this,\'' + formField + '\',\'' + boxInputName + '\');" vspace="1" />\n';
    scriptedCheckbox += '  <input name="' + boxInputName + '" value="'+boxInputValue+'" type="hidden" />\n';
    scriptedCheckbox += '</div>';
    return scriptedCheckbox;
  }

  var allowSend = true;
  function handleSubmit( cValue ){
   if( allowSend == true ){
     allowSend = false;
     if( cValue ){
       document.forms[0].elements['action_name'].value = cValue;
     }
     document.forms[0].submit();
   }
   return false;
  }
  function writeButton( formId, formName, className, currentValue, label ){
    var scriptedButton = '<a href="#" onclick="return handleSubmit(\'' + currentValue + '\')" id="defaultAnchorButton">'+label+'</a>';
    return scriptedButton;
  }
  function writeLinkButton( formId, formName, className, currentValue, label) {
    var scriptedButton = '<a href="#" onclick="return handleSubmit(\'' + currentValue + '\')" class="arrow"><img src="../../narrowband/img/palette/1x1_trans.gif">' + label + '</a>';
    return scriptedButton;
  }

