function openReferenceWindow(href) {
  var iNode = href.replace(/[^0-9]/ig, '');
  
  var newWin = window.open('cms' + iNode + '.asp', 'reference', 'height=300px, width=300px, title=no')
      newWin.focus();
  

}


function showSubNav(linkObj, objId) {
  var wrapper = linkObj.parentNode;
  var tempNode = wrapper.firstChild;
    

  while (tempNode) {
    if (tempNode.nodeName.toLowerCase() == 'div') {
     tempNode.style.display = 'none';
    }
    tempNode = tempNode.nextSibling;
  }

  document.getElementById(objId).style.display = 'block';
  
}





function validateForm(oForm) {
  var blnMasterContinue = true  

  var cSpan = oForm.parentNode.getElementsByTagName('span')
  for (var i=cSpan.length-1; i>=0; i--) {
    if (cSpan[i].className == 'errorFlag') {
      cSpan[i].parentNode.removeChild(cSpan[i]);
    }
  }


  for (var i=0; i<oForm.length; i++) {
    if (oForm[i].getAttribute('validation') !== null) {

      aValidation = oForm[i].getAttribute('validation').split(',')

      var blnContinue = true;

      for (var iInt=0; iInt<aValidation.length; iInt++) {
        if (aValidation[iInt] == 'validateEmail') {
          var regEx = new RegExp('\\w+(.|\\w+)*\\@+(-|\\w)+\\.\\w+', 'igm');
        }
        else if (aValidation[iInt] == 'validateNotEmpty') {
          var regEx = new RegExp('.+', 'igm');
        }
        else {
          var regEx = new RegExp('', 'igm');
        }


        var fieldValue = oForm[i].value;



        if (oForm[i].type == 'radio') {
          fieldValue = '';
          oRadio = oForm.elements[oForm[i].name];
          for (var iInt=0; iInt<oRadio.length; iInt++) {
            if (oRadio[iInt].checked) {
              fieldValue = oRadio[iInt].value;
            }
          }

        }


        if (!regEx.test(fieldValue)) {
          blnContinue = false;
          break;
        }
      }


      if (!blnContinue) {
        blnMasterContinue = false;

        var str = ' <span style="color: red; font-weight: normal;" class="errorFlag">[*]</span>';

        var label = oForm[i].parentNode;
        while (label.tagName.toLowerCase() !== 'label' && label.parentNode) {

          label = label.parentNode;
        }


        
         if (label) {
          var para = label.getElementsByTagName('p')[0];
          para.innerHTML = para.innerHTML + str;
        }
      }

    }
     
  }




  if (blnMasterContinue) {
    return true;
  }
  else {
    alert('Some fields within the form are incomplete.\nPlease review the fields marked with an asterix(*)')
    return false;
  }
}