function count() {
  var msgLen = document.quikSend.msgText.value.length;
  //Truncate message if exceeds length of 130
  if (msgLen > 130) 
  {
    document.quikSend.msgText.value=document.quikSend.msgText.value.substr(0,130)
    msgLen = 130;
  } 
  var remaining = 130 - msgLen;
  var i = 0;
  id="limitTxt";

  if(document.layers)
  { //if ns4 
    document.layers[id].document.open();
    document.layers[id].document.write('remaining'+"</strong> characters remaining")
    document.layers[id].document.close();
  }
  else if(document.all)
  {//if ie4
    //document.all[id].innerText=remaining+"</strong> characters remaining"
    document.all[id].innerText=remaining
  }
  else if (document.getElementById) 
  { // IE 5+ / NS6
      document.getElementById(id).innerHTML = remaining+" remaining";
  }
}

function applyTemplate(tmpl) {
  var msgText = document.quikSend.msgText.value;
  document.quikSend.msgText.value=tmpl;
}

function applyToString(dest) {
  var destString = document.quikSend.toString.value;
  var newString = document.quikSend.contact.options[document.quikSend.contact.selectedIndex].text;
  document.quikSend.toString.value=destString+newString+",";
}

function applyMLToString() {
  var destString = document.quikSend.tolist.value;
  var newString = document.quikSend.mlist.options[document.quikSend.mlist.selectedIndex].text;
  document.quikSend.tolist.value=destString+newString+"(group),";
}

function applyContactToString() {
  var destString = document.quikSend.tolist.value;
  var newString = document.quikSend.contact.options[document.quikSend.contact.selectedIndex].text;
  document.quikSend.tolist.value=destString+newString+",";
}


function selectMulti(box) {
     for(var i=0; i<box.length; i++) {
     box[i].selected = true;
     }
}

function destmove(fbox, tbox) {
     var multimode = document.getElementById("wtlon");
     var arrFbox = new Array();
     var arrTbox = new Array();
     var arrLookup = new Array();
     var i;
    if(multimode.style.visibility=="visible") {
     for(i=0; i<tbox.options.length; i++) {
          arrLookup[tbox.options[i].text] = tbox.options[i].value;
          arrTbox[i] = tbox.options[i].text;
     }
     var fLength = 0;
     var tLength = arrTbox.length
     for(i=0; i<fbox.options.length; i++) {
          arrLookup[fbox.options[i].text] = fbox.options[i].value;
          if(fbox.options[i].selected && fbox.options[i].value != "") {
               arrTbox[tLength] = fbox.options[i].text;
               tLength++;
          } else {
               arrFbox[fLength] = fbox.options[i].text;
               fLength++;
          }
     }
     //arrFbox.sort();
     arrTbox.sort();
     fbox.length = 0;
     tbox.length = 0;
     var c;
     for(c=0; c<arrFbox.length; c++) {
          var no = new Option();
          no.value = arrLookup[arrFbox[c]];
          no.text = arrFbox[c];
          fbox[c] = no;
     }
     for(c=0; c<arrTbox.length; c++) {
      var no = new Option();
      no.value = arrLookup[arrTbox[c]];
      no.text = arrTbox[c];
      tbox[c] = no;
     }
  }
}

function txtmove(fbox, tbox) {
     var arrFbox = new Array();
     var arrTbox = new Array();
     var arrLookup = new Array();
     var i;
     for(i=0; i<tbox.options.length; i++) {
          arrLookup[tbox.options[i].text] = tbox.options[i].value;
          arrTbox[i] = tbox.options[i].text;
     }
     var fLength = 0;
     var tLength = arrTbox.length
     for(i=0; i<fbox.options.length; i++) {
          arrLookup[fbox.options[i].text] = fbox.options[i].value;
          if(fbox.options[i].selected && fbox.options[i].value != "") {
               arrTbox[tLength] = fbox.options[i].text;
               tLength++;
          } else {
               arrFbox[fLength] = fbox.options[i].text;
               fLength++;
          }
     }
     //arrFbox.sort();
     arrTbox.sort();
     fbox.length = 0;
     tbox.length = 0;
     var c;
     for(c=0; c<arrFbox.length; c++) {
          var no = new Option();
          no.value = arrLookup[arrFbox[c]];
          no.text = arrFbox[c];
          fbox[c] = no;
     }
     for(c=0; c<arrTbox.length; c++) {
      var no = new Option();
      no.value = arrLookup[arrTbox[c]];
      no.text = arrTbox[c];
      tbox[c] = no;
     }
}
