function moveModuleMultiSelect(objFrom, objTo) {

  var strText;
  var strValue;
  for (var intLoop=0; intLoop < objFrom.length; intLoop++) {
    if (objFrom[intLoop].selected) {
      strText = objFrom.options[intLoop].text;
      strValue = objFrom.options[intLoop].value;
      objFrom.options[intLoop] = null;
      intLoop = intLoop - 1;
      objTo.options[objTo.length] = new Option (strText, strValue, false, true);
    }
  }
}


function moveModule(o_col, d_col) 
{
  o_sl = document.frmSort[o_col].selectedIndex;
  d_sl = document.frmSort[d_col].length;
  if (o_sl != -1 && document.frmSort[o_col].options[o_sl].value > "") {
    oText = document.frmSort[o_col].options[o_sl].text;
    oValue = document.frmSort[o_col].options[o_sl].value;
    document.frmSort[o_col].options[o_sl] = null;
    document.frmSort[d_col].options[d_sl] = new Option (oText, oValue, false, true);
  } else {
    alert("Please select a module first");
  }
}  


function orderModule(down, col) 
{
  sl = document.frmSort[col].selectedIndex;
  if (sl != -1 && document.frmSort[col].options[sl].value > "") {
    oText = document.frmSort[col].options[sl].text;
    oValue = document.frmSort[col].options[sl].value;
    if (document.frmSort[col].options[sl].value > "" && sl > 0 && down == 0) {
      document.frmSort[col].options[sl].text = document.frmSort[col].options[sl-1].text;
      document.frmSort[col].options[sl].value = document.frmSort[col].options[sl-1].value;
      document.frmSort[col].options[sl-1].text = oText;
      document.frmSort[col].options[sl-1].value = oValue;
      document.frmSort[col].selectedIndex--;
    } else if (sl < document.frmSort[col].length-1 && document.frmSort[col].options[sl+1].value > "" && down == 1) {
      document.frmSort[col].options[sl].text = document.frmSort[col].options[sl+1].text;
      document.frmSort[col].options[sl].value = document.frmSort[col].options[sl+1].value;
      document.frmSort[col].options[sl+1].text = oText;
      document.frmSort[col].options[sl+1].value = oValue;
      document.frmSort[col].selectedIndex++;
    }
  } else {
    alert("Please select a module first");
  }
}

function xMod(col) 
{
  req = "";
  sl = document.frmSort[col].selectedIndex;
  if (sl != -1 && document.frmSort[col].options[sl].value > "") {
    if (req.indexOf(document.frmSort[col].options[sl].value) > -1) {
      alert ("You may not delete a required corporate module.");
    } else {
      if (confirm("This will delete the selected module.")) {
        if (document.frmSort[col].options[sl].value!=".none") {
          if (document.frmSort[col].length==1) {
            //Don't know why this is needed
            //document.frmSort[col].options[0].text="";
            //document.frmSort[col].options[0].value=".none";
            document.frmSort[col].options[sl]=null;
          } else {
            document.frmSort[col].options[sl]=null; 
          } 
        } else {
          alert("Please select a module first");
        }
      }
    }
  }
}

function doSub() {
	if (document.frmSort["C0"]) {
		document.frmSort["AvailableList"].value = makeList("C0");
	}
	if (document.frmSort["C1"]) {
		document.frmSort["ActiveList"].value = makeList("C1");
	}
	if (document.frmSort["C2"]) {
		document.frmSort["ActiveList2"].value = makeList("C2");
	}
	if (document.frmSort["C3"]) {
		document.frmSort["ActiveList3"].value = makeList("C3");
	}
	return true;
}

function makeList(col) 
{
  val = "";
  for (j=0; j<document.frmSort[col].length; j++) {
    if (val > "") { val += ","; }
    if (document.frmSort[col].options[j].value > "") val += document.frmSort[col].options[j].value;
  } 
  return val;
}

function sub_layout(layout) {
  document.frmSort['.commit'][0].value="";
  document.frmSort['.layout'].value=layout;
  doSub();
  document.frmSort.submit();
}