
  function add(el){
    var select1 = document.getElementById(el + '_opt');
    var select2 = document.getElementById(el + '_val');
    for(i=select1.options.length-1;i>0;i--){
      if(select1.options[i].selected){
        select2.options[select2.options.length] = new Option(select1[i].text,select1[i].value);
        select1.options[i] = null;
      }
    }
    rehash(el);
  }
  
  function remove(el){
    var select1 = document.getElementById(el + '_opt');
    var select2 = document.getElementById(el + '_val');
    for(i=select2.options.length-1;i>0;i--){
      if(select2.options[i].selected){
        select1.options[select1.options.length] = new Option(select2[i].text,select2[i].value);
        select2.options[i] = null;
      }
    }
    rehash(el);
  }
  
  function rehash(el){
    var str = "";
    var hide = document.getElementById(el);
    var val = document.getElementById(el + '_val');
    for(i=1;i<val.options.length;i++){
        str += val[i].value;
        if(i<val.options.length-1) str += ",";
    }
    //alert(str);
    hide.value = str;  
  }

  function popUpDg(idEl, valEl, pageName, className){

    var popUp = open(pageName + "?RunSearch=true&popUpClass=" + className +
        "&FieldName=" + idEl.name,
        "popUp", "scrollbars=1,toolbars=0,width=450height=600");
  }



  function del(id){
    return document.getElementById(id);
  }



function buildQueryString(theFormName) {
  if(theFormName=='') return '';
  theForm = document.getElementById(theFormName);
  var qs = ''
  for (e=0;e<theForm.elements.length;e++) {
    if (theForm.elements[e].name!='') {
      qs+='&';
      qs+=theForm.elements[e].name+'='+escape(theForm.elements[e].value)
      }
    }
  return qs
}


var IFrameObj; // our IFrame object
function callToServer(page, form, call) {
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = page;
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);

      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }

    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.

      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }

  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout("callToServer('" + page + "','" + form + "',call)",10);
    return false;
  }

  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument;
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6

    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5

    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  var qs = buildQueryString(form);
  if(qs.length>1500) qs = qs.substring(0, 1500);
  IFrameDoc.location.replace(URL + "?rc=" + call + qs);

  //return false;
}

