  // Forms Code ----------------------------------------------------
  var e1,e2,e3,hid,dld;
  function  urlPost(strURL,qstr) {
    var xmlHttpReq = false;
    var self = this; 
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.send(qstr);
  }

  function showDownload(hubspotid,dldfile) {
    e1 = document.getElementById('articleselect');
    e2 = document.getElementById('articleform');
    e3 = document.getElementById('articledld');
    if (e1 && e2 && e3 ) {
      hid=hubspotid;
      dld=dldfile;
      e1.style.display='none';
      e2.style.display='block';
      e3.style.display='none';
    }
  }
  function restoreArticles() {
    e1 = document.getElementById('articleselect');
    e2 = document.getElementById('articleform');
    e3 = document.getElementById('articledld');
    if (e1 && e2 && e3 ) {
      e1.style.display='block';
      e2.style.display='none';
      e3.style.display='none';
    }
  }
  function showArticle () {
    e1 = document.getElementById('articleselect');
    e2 = document.getElementById('articleform');
    e3 = document.getElementById('articledld');
    var email = document.getElementById('aremail');
    var re= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/i;
    if (email) {
      if (email.value.match(re) == null) {
        alert('Please enter a valid email address');
        return false;
      }
    }
    if (e1 && e2 && e3 && dld && hid) {
      re ='FormName='+hid+'&Email='+email.value+'&PDF='+dld;
      urlPost('http://www.cfaw.com/hubspot.trap.php',re);
      e1.style.display='none';
      e2.style.display='none';
      e3.style.display='block';
      e3.innerHTML='<br/><center>[<a target="_blank" href="http://www.cfaw.com/library/200/'+dld+'" onclick="restoreArticles()">click to download</a>]</center>';
    }
  }
  // End Forms Code
  // Validate Contact Form ----------------------------------------------
  function validate_frm(frm) {
    if (frm.firstname.value.length < 2) {
      alert('Please enter a valid firstname');
      return false;
    }
    if (frm.lastname.value.length < 3) {
      alert('Please enter a valid lastname');
      return false;
    }
    re= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/i;
    if (frm.email.value.match(re) == null) {
      alert('Please enter a valid email address.');
      return false;
    }
  }
  // End validate
