// JavaScript Document 
<!-- Begin
//To calculate  total due  bases on changes in line items
function  calcTotal(which)
{

  title = which.name;
  // each fee item has an associated _cost and _total  _count with a base name of 7 characters
  count = title.substr(0,6) + "_count"
  cost =title.substr(0,6) + "_cost"
  total=title.substr(0,6) + "_total"
  willAttend=title.substr(0,6) + "_willAttend"
   
  // if (document.getElementById(willAttend)=null)
    // which.value=0;

//alert(which.name);
//if(which.name == 'golfoutg_willAttend' || which.name == 'sailingg_willAttend' || which.name == 'cliftour_willAttend') {
//document.getElementById(total).value = (document.getElementById(count).value*document.getElementById(cost).value) + document.getElementById(willAttend).value;
//} else {
document.getElementById(total).value = document.getElementById(count).value*document.getElementById(cost).value;
//}

 // calc total of all items
 calcAll();

}

//used to calculate total registration fees dues
function calcAll()
{
 elementsInForm=document.form.elements.length;
 // below is registration fee for registrant
  var totaldue=document.form.regFee.value;

 for (i = 0; i < elementsInForm; i++)
 {
  if (document.form.elements[i].name.substr(7,5)=="total")
   {
       totaldue= eval(totaldue) + eval(document.form.elements[i].value);
    }
  } 
    document.form.due.value=totaldue.toFixed(2); 
 
}

// used to  set the registration fee based on  
// non/member status and whether registration id completed before/after
// early date 
// initiated by  "onchange" on conferencetype
function setReg(which)
{
var myDate = new Date;
var my2Date = new Date;
//var myStatus = 'Non-Member';

myDate.setFullYear(2008,8,14);


//alert('myDate(' + myDate + ')my2Date(' + my2Date + ')conferenceType(' + document.form.conferenceType.options.value + ')');
//M Clark wawb
 if (which.value=="2")
 {
     // alert('In SetReg should update as sponsor');
     document.form.regFee.value=0;
     document.form.due.value=0;
 }
 else
//M Clark wawb
 if (which.value=="0")
 {
	if (my2Date < myDate)
	{
	// alert('In SetReg should update to early stuff as non member');
		document.form.regFee.value=265;
		document.form.due.value=265;
		
 	}
	else
	{
//	alert('In SetReg should update to late stuff as non-member');
		document.form.regFee.value=275;
		document.form.due.value=275;
		 
	} 
 }	 	
 else
  {	 
 // alert('In if 1');
	if (my2Date < myDate)
	{
	// alert('In SetReg should update to early stuff as member');
	    document.form.regFee.value=250;
		 document.form.due.value=250;
		 	}
	else
	{
//	 alert('In SetReg should update to late stuff as member');
		 document.form.regFee.value=275;
		 document.form.due.value=275;
	 }    
  	 
  } 
  
}

// this clears all the checkboxes dropdowns totals
function clearAll()
{

alert('Meal and Social events have been cleared, please re-select your choices if necessary.');
  document.form.sailingg_count.disabled=true;
  document.form.sailingg_total.value=0;
  document.form.sailingg_willAttend.checked=false;
  document.form.sailingg_count.options.value=0;
  
  document.form.golfoutg_count.disabled=true;
  document.form.golfoutg_total.value=0;
  document.form.golfoutg_willAttend.checked=false;
  document.form.golfoutg_count.options.value=0;
  
  //document.form.walktour_count.disabled=true;
 // document.form.walktour_willAttend.checked=false;
  //document.form.walktour_count.options.value=0;
  
  document.form.cliftour_count.disabled=true;
  document.form.cliftour_total.value=0;
  document.form.cliftour_willAttend.checked=false;
  document.form.cliftour_count.options.value=0;
  
  
    document.form.clambake_count.disabled=true;
  document.form.clambake_total.value=0;
  document.form.clambake_willAttend.checked=false;
  document.form.clambake_count.options.value=0;
  
    document.form.presRcpt_count.disabled=true;
  document.form.presRcpt_total.value=0;
  document.form.presRcpt_willAttend.checked=false;
  document.form.presRcpt_count.options.value=0;
  
  //  document.form.busLunch_count.disabled=true;
  document.form.busLunch_total.value=0;
  document.form.busLunch_willAttend.checked=false;
  document.form.busLunch_count.options.value=0;
    document.form.busLunch_count.disabled=true;
  
    document.form.bapcpalp_count.disabled=true;
  document.form.bapcpalp_total.value=0;
  document.form.bapcpalp_willAttend.checked=false;
  document.form.bapcpalp_count.options.value=0;
  
  
}
// this function enables a dropdown count list based on a checkbox
function makeEnable(which)
{
 var boxName= which.name;
 var dropName= boxName.substr(0,6) + "_count";
  

 // alert('Please select either Sailing Excursion, or Cliff Walk but not both.');
  if(boxName == 'golfoutg_willAttend') {
  alert("The count INCLUDES YOU.  Increase the number for guests.");
 document.form.golfoutg_count.options[1].selected=true;
 
 }
 
 if(boxName == 'clambake_willAttend') {
   alert("Be sure to pick a meal (below).");
   }

 if(boxName == 'sailingg_willAttend') {
 alert("The count INCLUDES YOU.  Increase the number for guests.");
  document.form.cliftour_willAttend.checked=false;
  document.form.cliftour_count.options.value=0;
  document.form.cliftour_total.value=0;
  document.form.sailingg_count.options[1].selected=true;
  document.form.cliftour_count.disabled=true;
  document.form.cliftour_count.disabled=true;
 }
 if(boxName == 'cliftour_willAttend') {
 alert("The count INCLUDES YOU.  Increase the number for guests.");
 document.form.sailingg_willAttend.checked=false;
 document.form.sailingg_count.options.value=0;
 document.form.sailingg_total.value=0;
 document.form.cliftour_count.options[1].selected=true;
document.form.sailingg_count.disabled = true;
document.form.sailingg_count.disabled=true;
 }
 
 if (which.checked && which.disabled==false )
{
  document.getElementById(dropName).disabled=false;
  if (boxName.substr(0,4) == "soci") {
    document.getElementById(dropName).value=1;
  }
  calcTotal(which);
}
 else
{
  document.getElementById(dropName).disabled=true;
  document.getElementById(dropName).value=0;
 calcTotal(which);
  }
}



// this function disables  lunch option if non-member
function noLunch(which)
{
if (which.value=="0")
 {
	  
  document.form.busLunch_willAttend.disabled=true;
  document.form.busLunch_willAttend.checked=false;
  document.form.busLunch_count.value=0;
  document.form.busLunch_count.disabled=true;
  makeEnable(document.form.busLunch_willAttend);
 }
 else
  document.form.busLunch_willAttend.disabled=false;
}


//  End -->
