// JavaScript Document
<!--
// ---------------------------------------------------
// My_Form_Validator()- Client side form validator 
// ---------------------------------------------------
function My_Form_Validator(form){

	if (form.totalamount.value == 0){
		alert("Please enter a donation to at least one fund before submitting.");
		return false;
	}

	if ((form.GIFT_AMOUNT11.value != 0) && ((form.fundEntry11.value.length < 2) || (form.fundEntry11.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry11.focus();
		return false;
	}
	else {
		form.FUND11.value = "00000000/" + form.fundEntry11.value;
	}

	if ((form.GIFT_AMOUNT9.value != 0) && ((form.fundEntry9.value.length < 2) || (form.fundEntry9.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry9.focus();
		return false;
	}
	else {
		form.FUND9.value = "00000000/" + form.fundEntry9.value;
	}

	if ((form.GIFT_AMOUNT3.value != 0) && ((form.fundEntry3.value.length < 2) || (form.fundEntry3.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry3.focus();
		return false;
	}
	else {
		form.FUND3.value = "00000000/" + form.fundEntry3.value;
	}


	if ((form.GIFT_AMOUNT4.value != 0) && ((form.fundEntry4.value.length < 2) || (form.fundEntry4.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry4.focus();
		return false;
	}
	else {
		form.FUND4.value = "00000000/" + form.fundEntry4.value;
	}
	
	if ((form.GIFT_AMOUNT5.value != 0) && ((form.fundEntry5.value.length < 2) || (form.fundEntry5.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry5.focus();
		return false;
	}
	else {
		form.FUND5.value = "00000000/" + form.fundEntry5.value;
	}
	
	if ((form.GIFT_AMOUNT6.value != 0) && ((form.fundEntry6.value.length < 2) || (form.fundEntry6.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry6.focus();
		return false;
	}
	else {
		form.FUND6.value = "00000000/" + form.fundEntry6.value;
	}
	
	if ((form.GIFT_AMOUNT7.value != 0) && ((form.fundEntry7.value.length < 2) || (form.fundEntry7.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry7.focus();
		return false;
	}
	else {
		form.FUND7.value = "00000000/" + form.fundEntry7.value;
	}
	
	if ((form.GIFT_AMOUNT8.value != 0) && ((form.fundEntry8.value.length < 2) || (form.fundEntry8.value == "Other - Indicate where to direct donation here"))){
		alert("Please enter a fund to receive your donation.");
		form.fundEntry8.focus();
		return false;
	}
	else {
		form.FUND8.value = "00000000/" + form.fundEntry8.value;
	}
	
	
	
	
} // End of My_Form_Validator 



// -----------------------------------------------------------------
// WinOpen1() - Open pop-up window for Descripton of Fund #1
// -----------------------------------------------------------------
function WinOpen1() {
	open("http://www.uic.edu/pharmacy/offices/alumni/annual_fund.htm","Window1","width=400,height=400,scrollbars");
}


// -----------------------------------------------------------------
// CalcDisplayAmount - convert numeric entry to formatted text value
// -----------------------------------------------------------------
function CalcDisplayAmount(amt)
{
	var displayAmt;
	var amtValue;
	if (isNaN(amt)== true){   //not a valid number
		displayAmt = "0.00";
		return displayAmt;		
	}

      if (amt.length==0) {		// no value at all
		displayAmt = "0.00";
		return displayAmt;	
	}

// round to 2 places after the decimal point
	amtValue = parseFloat(amt);
	amtValue = Math.round(amtValue * 100) / 100;
	//	if user enters in value < 0, make it 0
	if (amtValue < 0) 
		amtValue = 0;
	
//	if it doesn't contain decimal point, add it 
	if (amtValue == Math.round(amtValue)) {
		displayAmt = amtValue + ".00";
	}
// else if it only contains one place after the decimal, add one more
	else if (amtValue * 10 == Math.round(amtValue * 10)) {
		displayAmt = amtValue + "0";
	}

// else it contains 2 places after the decimal, just return it
	else {
		displayAmt = amtValue;
	}
	return displayAmt;
}

// -----------------------------------------------------------------
// amountchange() - called when any amount changes
// -----------------------------------------------------------------
function amountchange()    {
	var total;

	/* change display format */

	total = 0;

	document.FrontPage_Form1.GIFT_AMOUNT1.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT1.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT1.value)

	document.FrontPage_Form1.GIFT_AMOUNT2.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT2.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT2.value)

	document.FrontPage_Form1.GIFT_AMOUNT3.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT3.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT3.value)

	document.FrontPage_Form1.GIFT_AMOUNT4.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT4.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT4.value)

	/*modifying function to include field 5 - 9 in calculating the sum*/
	
	/*this field was deleted from the donate_online.xml file.*/
	/* This field re-added on 2/15/2011  */
	document.FrontPage_Form1.GIFT_AMOUNT5.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT5.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT5.value)

	document.FrontPage_Form1.GIFT_AMOUNT6.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT6.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT6.value)

	document.FrontPage_Form1.GIFT_AMOUNT7.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT7.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT7.value)

	document.FrontPage_Form1.GIFT_AMOUNT8.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT8.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT8.value)

	document.FrontPage_Form1.GIFT_AMOUNT9.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT9.value);
	total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT9.value)

    /* modifying to add a 10th field */
	/* 10th field added on 12/9/2011  */
	
	 document.FrontPage_Form1.GIFT_AMOUNT11.value=CalcDisplayAmount(document.FrontPage_Form1.GIFT_AMOUNT11.value);
	 total = total + parseFloat(document.FrontPage_Form1.GIFT_AMOUNT11.value)

	total = Math.round(total * 100) / 100;
	document.FrontPage_Form1.totalamount.value=CalcDisplayAmount(total);
}
-->
