// opens popup windows for adlib site

function openCustomPopup(URL, ID, Height, Width) {
  var win = window.open(URL, ID,
      "status=no,menubar=no,scrollbars=yes,resizable=no,top=64,left=64,width=" + Width + ",height=" + Height);
  }

function openPopup(URL, ID) {
  var win = window.open(URL, ID,
      "status=no,menubar=no,scrollbars=yes,resizable=no,top=120,left=240,width=340,height=480");
  }
  
function emailToColleague(theForm) {
  var addr = theForm.email.value;
  if (isValidEmail(addr)) {
    var URL = "/adlib/popups/email.asp?to=" +
              escape(addr) + "&url=" + escape(window.document.location.href);
    openPopup(URL, "emailtocolleague");
    }
  else window.alert("Please enter a valid e-mail address.");
  }
  
 
 function openEmailUpdate() {
    var URL = "/adlib/popups/alerts.asp?action=newsub"
    openPopup(URL, "emailupdate");
  }
  
  
function emailUpdate(theForm) {
  var addr = theForm.email.value;
  if (isValidEmail(addr)) {
    var URL = "/adlib/popups/alerts.asp?addr=" + escape(addr) + "&action="
    if(theForm.action[0].checked) URL += "subscribe"
      else URL += "remove";
    openPopup(URL, "emailupdate");
    }
  else window.alert("Please enter a valid e-mail address.");
  }
  
function emailEnquiry(action) {
  openPopup("/adlib/popups/email.asp?action=" + action, "emailenquiry");
  }
  
function isValidEmail(addr) {
  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(addr)))
    return false;
  var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
  if (addr.match(illegalChars))
    return false;
  return true;
  }
  
  function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i < buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
 return -1;
} // Ends the "getSelectedRadio" function

    
function checkform1(theForm) {

      if (getSelectedRadio(theForm.offerids) == -1) {
        window.alert("Please select an ADLib Library.");
        return false;
        } 
      else return true;     
            
      }
	  
function checkformfacts(theForm) {

      if (theForm.vouchercode.value == '') {
        window.alert("Please select provide an access code.");
        return false;
        } 
      else return true;     
            
      }	  
  
//-->

//functions to call membership billing backets... 
 function openGroupSubscribe(URL) {
  winPass = window.open(URL, "subscribe", "status=yes,menubar=no,scrollbars=yes,resizable=no,top=32,left=32,width=650,height=540") }

 function openBulkPopup(URL) {
  winPass = window.open(URL, "Import", "status=no,menubar=no,scrollbars=no,resizable=no,top=32,left=32,width=450,height=375")
  }  