

  function openGenericPopup(strURL, strWinTitle, intWidth, intHeight)
  {
    var oWin = window.open(strURL, strWinTitle, "screenX=200,screenY=200,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=yes,fullscreen=no,width=" + intWidth + ",height=" + intHeight);
   oWin.focus();
  }
  var g_bNewMember;
  function findContact(bNewMember)
  {

     var sSurname;
     if(bNewMember)
       sSurname=getObj('Surname').value;
     else
       sSurname=getObj('SearchContact').value;

     var sURL;
    if(sSurname==null||sSurname=="")
    {
       alert("Please enter a surname to search for.");
       return;
    }

    sURL="../findcontact/main.php?Surname="+escape(sSurname);
    g_bNewMember=bNewMember;
    var sContactString=openGenericDialog(sURL,"Find Contact",500,400);
    useMemberID(sContactString);
 }

 function useMemberID(sContactString)
 {
    if(sContactString)
    {
      var iHash=sContactString.indexOf(" ");
      var sContactID=sContactString.substr(0,iHash);
      var sName=sContactString.substr(iHash+1);
      if(g_bNewMember)
      {
        getObj('UseMemberID').value=sContactID;
        getObj('theForm').submit();
      }
      else
      {
        getObj('MainContactMemberID').value=sContactID;
        getObj('td_Contact').innerHTML=sName;
      }
    }
  }




  function showError(sTitle,sText)
  {
    openGenericDialog("../error/main.php?Title="+escape(sTitle)+"&Text="+escape(sText), "Error", 300, 150) ;
  }

  function openGenericDialog(strURL, strWinTitle, intWidth, intHeight)
  {
    if(window.showModalDialog)
    {
      return window.showModalDialog(strURL,strWinTitle,"center:1;status:no;resizable:no;dialogWidth:" + intWidth + "px;dialogHeight:" + intHeight+"px;");
    }
    else
    {

      var modalWin = window.open(strURL, strWinTitle, "screenX=200,screenY=200,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=yes,fullscreen=no,width=" + intWidth + ",height=" + intHeight);

    }
  }


  function getObj(name)
  {
    var obj;
    if (document.getElementById)
    {
            obj = document.getElementById(name);
    }
    else if (document.all)
    {
        obj = document.all[name];

    }
    else if (document.layers)
    {
             obj = document.layers[name];
    }
    return obj;
  }
    function getObj(name)
  {
    var obj;
    if (document.getElementById)
    {
            obj = document.getElementById(name);
    }
    else if (document.all)
    {
        obj = document.all[name];

    }
    else if (document.layers)
    {
             obj = document.layers[name];
    }
    return obj;
  }

  var g_selobjid;
  var g_selobj;

  function setSelected(objID,ID,variableID)
  {
    var obj=getObj(objID);
 // no deselection in this version
 //   if(obj.className=="selected")
 //   {
 //     obj.className="notSelected";
 //   }
 //   else
 //   {
      obj.style.backgroundColor="#BBBBFF";
      if(g_selobjid!=objID)
      {
        var selObj=getObj(variableID);
        if(selObj)
        {
          selObj.value=ID;
        }
        var objOld=g_selobj;
        if(objOld)
          objOld.style.backgroundColor="#FFFFFF";
        g_selobj=obj;
        g_selobjid=objID;
      }
 //   }
    if(updateActivation)
    {
      updateActivation();
    }
  }
  function transfer(objFrom,objTo)
{
    for (var i=0; i< objFrom.options.length;)
    {
      var objOptionFrom=objFrom.options(i);
      if( objOptionFrom.selected>0)
      {
         var objOptionTo = document.createElement("OPTION");

         objTo.options.add(objOptionTo);
         objOptionTo.innerText = objOptionFrom.innerText;
         objOptionTo.selected = 1;
         objFrom.options.remove(i);
      }
      else
        i++;
    }
}

function selectAll(sObjSelect)
{
    var objSelect=getObj(sObjSelect);
    for (var i=0; i< objSelect.options.length;i++)
    {
      objSelect.options(i).selected=1;
    }

}