var totRegs = 1;



function addRegistrant()
{
	var ni = document.getElementById('myDiv');

	var numi = document.getElementById('theValue');

	var num = (document.getElementById("theValue").value -1)+ 2;

	numi.value = num;

	//alert(num);

	var divIdName = "my"+num+"Div";

	var newdiv = document.createElement('div');

	newdiv.setAttribute("id",divIdName);

	newdiv.innerHTML = '\n\n<table border="0" cellpadding="2" cellspacing="2" width="100%"><tr><td width="1%"><input type="text" name="Name'+num+'" size="17" class="field" /></td><td width="16%"><select size="1" name="PreConference_Workshop'+num+'" onChange="CalculateTotal(this.form)"><option value="$0 - None">None</option><option value="$75 - A">$75&nbsp; A</option><option value="$75- B">$75&nbsp; B</option><option value="$75 - C">$75&nbsp; C</option><option value="$75 - D">$75&nbsp; D</option><option value="$75 - E">$75&nbsp; E</option><option value="$75 - F">$75&nbsp; F</option></select></td><td width="15%"><select size="1" name="Continuing_Education_Workshop'+num+'" onChange="CalculateTotal(this.form)"><option value="$0 - None">None</option><option value="$90 - 1 Session">1 Session (3 CR) $90</option><option value="$180 - 2 Sessions">2 Sessions (6 CR) $180</option><option value="$270 - 3 Sessions">3 Sessions (9 CR) $270</option><option value="$360 - 4 Sessions">3 Sessions (12 CR) $360</option></select></td><td width="30%"><select size="1" name="Registration_Type'+num+'" onChange="CalculateTotal(this.form)"><option value="$0 - Nothing chosen">CHOOSE ONE</option><option value="$300 - Adult">$250&nbsp; Adult ($300 after May 31)</option><option value="$175 - Special Honor Roll Nominee Rate">$175&nbsp; Special Honor Roll Nominee Rate</option><option value="$150 - Friday Only">$150&nbsp; Friday Only</option><option value="$150 - Saturday Only">$150&nbsp; Saturday Only</option><option value="$150 - Child">$150&nbsp; Child (7-14)</option><option value="$150 - Teen">$150&nbsp; Teen (15-18)</option><option value="$200 - Full-time student (included meals)">$200&nbsp; Full-time student (incl. meals)</option><option value="$0 - None">$0 &nbsp; &nbsp; CE / Pre-conf Workshop only</option></select></td><td width="1%"><input type="text" name="Age'+num+'" size="1" class="field" disabled="disabled" value="---" /></td><td width="1%"><a href="javascript:;" onclick="removeRegistrant(\''+divIdName+'\')" style="text-decoration: none;">x</a></td></tr></table>\n\n';

	ni.appendChild(newdiv);

	totRegs++;
}



function removeRegistrant(divNum)

{

	var d = document.getElementById('myDiv');

	var olddiv = document.getElementById(divNum);

	d.removeChild(olddiv);

	CalculateTotal(document.forms.dynoform)

}



function StripMoney(value)

{

	return value.slice(1,value.indexOf(" -"));

}



function CalculateTotal(form)
{
	var A = 0;
	var B = 0;
	var C = 0;
	var D = 0;
	var EligD = 0;
	var E = 0;
	var F = 0;
	var ThisDiscount = 0;
	var IsEarly = false;
	var EarlyDeadline = new Date;
	var today = new Date;

	EarlyDeadline.setDate(31);					// Set early registration DATE and add 1
	EarlyDeadline.setMonth(4);					// Set early registration MONTH (January = 0)
	EarlyDeadline.setFullYear(2008); 			// Set early registration YEAR
	if (EarlyDeadline > today)
		IsEarly = true
	else IsEarly = false;


	var numNodes = document.getElementById('myDiv').childNodes.length;
	
	for ( x = 0; x < numNodes; x++ ) {
		var drillToNode = document.getElementById('myDiv').childNodes[x].id;
		drillToNode = drillToNode.substring(2);
		drillToNode = parseFloat(drillToNode);
		//alert('drillToNode='+drillToNode);
		regtype_string = "Registration_Type"+drillToNode;
		preconf_string = "PreConference_Workshop"+drillToNode;
		contedu_string = "Continuing_Education_Workshop"+drillToNode;
		A = A + parseFloat(StripMoney(eval("form."+regtype_string+".value")));
		B = B + parseFloat(StripMoney(eval("form."+preconf_string+".value")));
		C = C + parseFloat(StripMoney(eval("form."+contedu_string+".value")));

		if (((parseFloat(StripMoney(eval("form."+regtype_string+".value")))) != 0 ) && ((parseFloat(StripMoney(eval("form."+contedu_string+".value")))) != 0 )) {
			EligD++;
		}
		if (((eval("form."+regtype_string+".value")) == "$0 - Family member") && ((parseFloat(StripMoney(eval("form."+contedu_string+".value")))) != 0 )) {
			EligD++;
		}
		// Early registration discount
		//alert(eval("form."+regtype_string+".value") + " " + IsEarly)
		ThisDiscount = 0;
		if (((eval("form."+regtype_string+".value")) == "$300 - Adult") && IsEarly) {
			ThisDiscount = -50;
		}
		if (((eval("form."+regtype_string+".value")) == "$175 - Friday Only") && IsEarly) {
			//ThisDiscount = -25;
		}
		if (((eval("form."+regtype_string+".value")) == "$175 - Saturday Only") && IsEarly) {
			//ThisDiscount = -25;
		}
		F = F + ThisDiscount;

		// Age check
		age_string = "Age"+drillToNode;
		var AgeObj = eval("form."+age_string);
		if (((eval("form."+regtype_string+".value")) == "$150 - Child") | ((eval("form."+regtype_string+".value")) == "$150 - Teen")) {
			AgeObj.disabled = false;
			AgeObj.value = "";
		} else {
			AgeObj.disabled = true;
			AgeObj.value = "---";
		}
	
	}

	E = EligD * -25;

	// Donations
	if (form.Donation[1].checked == true) { D = 0; } else
	if (form.Donation[2].checked == true) { D = 25; } else
	if (form.Donation[3].checked == true) { D = 50; } else
	if (form.Donation[4].checked == true) { D = 100; } else
	if (form.Donation[5].checked == true) { D = 500; } else
	if (form.Donation[6].checked == true) { D = 1000; } else
	if (form.Donation[7].checked == true) {
		showdiv(document.getElementById('DollarSign'));
		form.DonationOther.style.display = "inline";
		D = parseFloat(form.DonationOther.value);
		form.DonationOther.focus();
	}


	form.Discount.value = E;
	E = parseFloat(form.Discount.value);

	form.Early.value = F;

	form.Total_Cost.value = A + B + C + D + E + F;
}



function showdiv(which)

{

	if (!document.getElementById)

		return

	which.style.display="inline"

}



function chooseMethod(method)

{

	document.getElementById('method_credit_card').style.display = 'none';

	document.getElementById('method_check').style.display = 'none';

	document.getElementById('method_purchase_order').style.display = 'none';



	document.getElementById(method).style.display = 'block';



//	document.getElementById('method_credit_card').style.visibility = 'hidden';

//	document.getElementById('method_check').style.visibility = 'hidden';

//	document.getElementById('method_purchase_order').style.visibility = 'hidden';



//	document.getElementById(method).style.visibility = 'visible';

}







function checkIT(num) {

	alert(num);

	

	var numNodes = document.getElementById('myDiv').childNodes.length;

	

	for ( x = 0;  x < numNodes; x++ ) {

		alert( 'node= '+document.getElementById('myDiv').childNodes[x].id );

	}



	regtype_string = "Registration_Type"+num;

	preconf_string = "PreConference_Workshop"+num;

	contedu_string = "Continuing_Education_Workshop"+num;

	name_string = "Name"+num;



	alert('Name =' + eval("document.forms.dynoform."+name_string+".value"));

	alert('regtype =' + eval("document.forms.dynoform."+regtype_string+".value"));

	alert('preconf =' + eval("document.forms.dynoform."+preconf_string+".value"));

	alert('contedu =' + eval("document.forms.dynoform."+contedu_string+".value"));

}