//<!--
function disit(txt){  
  if(document.getElementById(txt+'_cec_fee').checked == true )  
  {  
    document.getElementById(txt+'_pace_fee').disabled = false;   
    document.getElementById(txt+'_pacle_fee').disabled = false; 
      
  }  
  else  
  {  
    document.getElementById(txt+'_pace_fee').disabled = true;  
    document.getElementById(txt+'_pace_fee').checked = false;  
    document.getElementById(txt+'_pacle_fee').disabled = true;  
    document.getElementById(txt+'_pacle_fee').checked = false
  }  
}  

function getPageName() {
  return document.location.href.substring(document.location.href.length, document.location.href.lastIndexOf('/') + 1);
}

function jsIsArray(obj) {
 if (obj.constructor.toString().indexOf("Array") == -1)
  return false;
 else
  return true;
}

function jsPopup(url) 
{
  var width  = 520;
  var height = 600;
  // var left   = (screen.width  - width)/2;
  // var top    = (screen.height - height)/2;
  var params = 'width='+width;
  params += ', height='+height;
  // params += ', top='+top;
  // params += ', left='+left;
  params += ', directories=no';
  params += ', location=no';
  params += ', menubar=no';
  params += ', resizable=yes';
  params += ', scrollbars=yes';
  params += ', status=no';
  params += ', toolbar=no';
  newwin=window.open(url,'Details', params);
  if (window.focus) {newwin.focus()};
  return false;
}

function jsValSelection(form)
{
  //check member flag
  myOption = -1;
  for (i = form.btnMember.length - 1; i > -1; i--) {
    if (form.btnMember[i].checked) {
      myOption = i; i = -1;
    }
  }
  if (myOption == -1) {
    alert("You must select either Member or Non-Member.");
    return false;
  }
  
  //check selection made
  myCount = 0;
  for (var i=0; i<form.elements.length; i++ ) {
    if (form.elements[i].type == 'checkbox') {
        if (form.elements[i].checked == true) {
          myCount = myCount + 1;
        }
    }
  }
  if (myCount == 0) {
    alert("You must select at least one class.");
    return false;
  }

  form.submit(); // this line submits the form after validation
}

function jsValSelectionLive(obj)
{ //check 110 against 101,103,105,108
  if (obj.checked) {
    form = obj.form
    selected = ''
    for (i = form.classID.length - 1; i > -1; i--) {
      if (form.classID[i].checked) {
        selected = selected + form.classID[i].value + ';'
      }
    }
    ck110 = selected.search('110;');
    if (ck110 > 0) {
      ck101 = selected.search('101;');
      ck103 = selected.search('103;');
      ck105 = selected.search('105;');
      ck108 = selected.search('108;');
      if ((ck101 == -1) || (ck103 == -1) || (ck105 == -1) || (ck108 == -1)) {
        alert('Course ID 110 is inclusive of courses 101, 103, 105 & 108.  Please do not select course 110 AND any of these other sub-courses.');
      }
    }
  }
}

function validate_required(field, alerttxt) {
  with (field) {
    if (value == null || value == "") {
      alert(alerttxt); return false;
    }
    else {
      return true;
    }
  }
}

function validate_reg(thisform) {
  with (thisform) {
    // check required fields
    if (validate_required(FirstName, "First Name is required.") == false)
    { FirstName.focus(); return false; }
    if (validate_required(LastName, "Last Name is required.") == false)
    { LastName.focus(); return false; }
    if (validate_required(EmailAddress, "Email Address is required.") == false)
    { EmailAddress.focus(); return false; }
    if (validate_required(BusinessPhone, "Work Phone is required.") == false)
    { BusinessPhone.focus(); return false; }

    // check payment options
    var blnCard = (CardType.value.length > 0) || (Credit_Card.value.length > 0) || (Exp_Date.value.length > 0);
    var blnCheck = (chkPayByCheck.checked) || (checknum.value.length > 0);

    //make sure both types not filled out
    if (blnCard && blnCheck) {
      alert('Please pay by check OR credit card.');
      CardType.focus(); return false;
    }

    if (blnCard) {
      //pay by card
      if (CardType.value.length == 0) {
        alert('Please enter the card type.');
        CardType.focus(); return false;
      }

      var ccnum = Credit_Card.value.replace(/\D+/g, '');
      if (!(ccnum.length == 15) && !(ccnum.length == 16)) {
        alert('Please enter a valid credit card number.');
        Credit_Card.focus(); return false;
      }
      Credit_Card.value = ccnum;

      if (Exp_Date.value.length == 0) {
        alert('Please enter the expiration date.');
        Exp_Date.focus(); return false;
      }
    }
    else if (blnCheck) {
      //pay by check
      if (!chkPayByCheck.checked) {
        alert('Please check the Pay by Check box if you wish to pay by check.');
        chkPayByCheck.focus(); return false;
      }

      if (checknum.value.length == 0) {
        alert('Please enter a check number if you wish to pay by check.');
        checknum.focus(); return false;
      }
    }
    else {
      //undefined
      alert('Please choose your payment type and complete all payment information.');
      CardType.focus(); return false;
    } 
  }
}
//-->