function changeDisplay(missingfield) {
	var blankfield = document.getElementById(missingfield);
	
	blankfield.style.backgroundColor="#FFF";
	blankfield.style.borderColor="#900";
	
	blankfield.parentNode.parentNode.style.backgroundColor="#ECD2D2";
	
	// THIS WAS CHANGING THE ACTUAL CLASS. Now just modifying the output style.
	//blankfield.className=blankfield.className+"Error";
	//blankfield.parentNode.parentNode.className="Error";
}


function enableField(livingField) {
	var livefield = document.getElementById(livingField);
	var formType = livefield.getAttribute("type");
	if (formType=="text") {
		livefield.style.backgroundColor="#F7F7F7";
	}
	if (formType=="submit") {
		livefield.style.backgroundColor="#F7F7F7";
	}
	livefield.disabled=false;
}
function disableField(dyingField) {
	var deadfield = document.getElementById(dyingField);
	var formType = deadfield.getAttribute("type");
	if (formType=="text") {
		//deadfield.setAttribute("value","");
		deadfield.style.backgroundColor="#EEE";
	}
	if (formType=="submit") {
		deadfield.style.backgroundColor="#EEE";
		deadfield.style.borderColor="#CCC";
	}
	deadfield.disabled=true;
}

function boolDisable(thisOne,thatOne,otherOne) {
	var thisfield = document.getElementById(thisOne);
	var thatfield = document.getElementById(thatOne);
	var otherfield = document.getElementById(otherOne);
	if (thisfield.checked) {
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.setAttribute("value","");
			otherfield.style.backgroundColor="#EEE";
		}
		otherfield.disabled=true;
		thatfield.checked=false;
	} else if (thatfield.checked) {
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.style.backgroundColor="#F7F7F7";
		}
		otherfield.disabled=false;
		thisfield.checked=false;
	} else {
		thisfield.checked=false;
		thatfield.checked=false;
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.setAttribute("value","");
			otherfield.style.backgroundColor="#EEE";
		}
		otherfield.disabled=true;
	}
}
function boolEnable(thisOne,thatOne,otherOne) {
	var thisfield = document.getElementById(thisOne);
	var thatfield = document.getElementById(thatOne);
	var otherfield = document.getElementById(otherOne);
	if (thisfield.checked) {
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.style.backgroundColor="#F7F7F7";
		}
		otherfield.disabled=false;
		thatfield.checked=false;
	} else if (thatfield.checked) {
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.setAttribute("value","");
			otherfield.style.backgroundColor="#EEE";
		}
		otherfield.disabled=true;
		thisfield.checked=false;
	} else {
		thisfield.checked=false;
		thatfield.checked=false;
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.setAttribute("value","");
			otherfield.style.backgroundColor="#EEE";
		}
		otherfield.disabled=true;
	}
}

function boolSwitch(thisOne,thatOne) {
	var thisfield = document.getElementById(thisOne);
	var thatfield = document.getElementById(thatOne);
	if (thisfield.checked) {
		thatfield.checked=false;
	} else if (thatfield.checked) {
		thisfield.checked=false;
	} else {
		thisfield.checked=false;
		thatfield.checked=false;
	}
}

function soloEnable(thisOne,otherOne) {
	var thisfield = document.getElementById(thisOne);
	var otherfield = document.getElementById(otherOne);
	if (thisfield.checked) {
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.style.backgroundColor="#F7F7F7";
		}
		if (formType=="submit") {
			otherfield.style.backgroundColor="#F7F7F7";
		}
		otherfield.disabled=false;
	} else {
		var formType = otherfield.getAttribute("type");
		if (formType=="text") {
			otherfield.setAttribute("value","");
			otherfield.style.backgroundColor="#EEE";
		}
		if (formType=="submit") {
			otherfield.style.backgroundColor="#EEE";
		}
		otherfield.disabled=true;
	}
}

function spouseEnable(thisOne,thatOne) {
	var thisfield = document.getElementById(thisOne);
	var thatfield = document.getElementById(thatOne);
	var spousefields = new Array("spouse_name","spouse_vegetarian_meals","spouse_food_allergies","spouse_shabbat_dinner");
	var remainDisabled = true;
	
	if (thisfield.checked) {
		thatfield.checked = false;
		remainDisabled = false;
	}
	if (thatfield.checked) {
		thisfield.checked = false;
		remainDisabled = false;
	}
	
	for (var i=0; i<spousefields.length; i++) {
		var thisSpouse = document.getElementById(spousefields[i]);
		var formType = thisSpouse.getAttribute("type");
		if (remainDisabled) {
			if (formType=="text") {
				thisSpouse.setAttribute("value","");
				thisSpouse.style.backgroundColor="#EEE";
			}
			if (formType=="checkbox") thisSpouse.checked = false;
			thisSpouse.disabled=true;
		} else {
			if (formType=="text") thisSpouse.style.backgroundColor="#F7F7F7";
			thisSpouse.disabled=false;
		}
	}
}


function memberFeeEnable(thisOne,price) {
	var theFees = new Array("fee_member1","fee_member2","fee_member3");
	var thePrices = new Array(525,625,675);
	
	var thisfee;
	var otherfee1;
	var otherfee2;
	
	var thisprice;
	var otherprice1;
	var otherprice2;
	
	for (var i=0; i<theFees.length; i++) {
		if (thisOne==theFees[i]) {
			thisfee = theFees[i];
			thisprice = thePrices[i];
		} else if (!otherfee1) {
			otherfee1 = theFees[i];
			otherprice1 = thePrices[i];
		} else {
			otherfee2 = theFees[i];
			otherprice2 = thePrices[i];
		}
	}
	
	var this_box = document.getElementById(thisfee);
	var that_box1 = document.getElementById(otherfee1);
	var that_box2 = document.getElementById(otherfee2);
	var amount_field = document.getElementById("registration_fee");
	
	if (this_box.checked) {
		that_box1.checked = false;
		that_box2.checked = false;
		amount_field.setAttribute("value",thisprice);
		//amount_field.disabled=true;
	} else if (that_box1.checked) {
		this_box.checked = false;
		that_box2.checked = false;
		amount_field.setAttribute("value",otherprice1);
		//amount_field.disabled=true;
	} else if (that_box2.checked) {
		this_box.checked = false;
		that_box1.checked = false;
		amount_field.setAttribute("value",otherprice2);
		//amount_field.disabled=true;
	} else {
		this_box.checked = false;
		that_box1.checked = false;
		that_box2.checked = false;
		amount_field.setAttribute("value","");
		//amount_field.disabled=true;
	}
	totalFees();
}
function spouseFeeEnable(thisOne,price) {
	var theFees = new Array("fee_spouse1","fee_spouse2","fee_spouse3");
	var thePrices = new Array(525,625,675);
	
	var thisfee;
	var otherfee1;
	var otherfee2;
	
	var thisprice;
	var otherprice1;
	var otherprice2;
	
	for (var i=0; i<theFees.length; i++) {
		if (thisOne==theFees[i]) {
			thisfee = theFees[i];
			thisprice = thePrices[i];
		} else if (!otherfee1) {
			otherfee1 = theFees[i];
			otherprice1 = thePrices[i];
		} else {
			otherfee2 = theFees[i];
			otherprice2 = thePrices[i];
		}
	}
	
	var this_box = document.getElementById(thisfee);
	var that_box1 = document.getElementById(otherfee1);
	var that_box2 = document.getElementById(otherfee2);
	var amount_field = document.getElementById("spouse_fee_full");
	
	if (this_box.checked) {
		that_box1.checked = false;
		that_box2.checked = false;
		amount_field.setAttribute("value",thisprice);
		//amount_field.disabled=true;
	} else if (that_box1.checked) {
		this_box.checked = false;
		that_box2.checked = false;
		amount_field.setAttribute("value",otherprice1);
		//amount_field.disabled=true;
	} else if (that_box2.checked) {
		this_box.checked = false;
		that_box1.checked = false;
		amount_field.setAttribute("value",otherprice2);
		//amount_field.disabled=true;
	} else {
		this_box.checked = false;
		that_box1.checked = false;
		that_box2.checked = false;
		amount_field.setAttribute("value","");
		//amount_field.disabled=true;
	}
	totalFees();
}

function arrivalEnable(theday) {
	var thedays = new Array("friday","saturday","sunday");
	
	var thisday;
	var otherday1;
	var otherday2;
	
	for (var i=0; i<thedays.length; i++) {
		if (theday==thedays[i]) thisday = thedays[i];
		else if (!otherday1) otherday1 = thedays[i];
		else otherday2 = thedays[i];
	}
	var this_box = document.getElementById("arrive_"+thisday);
	var that_box1 = document.getElementById("arrive_"+otherday1);
	var that_box2 = document.getElementById("arrive_"+otherday2);
	
	var this_field = document.getElementById("time_"+thisday);
	var that_field1 = document.getElementById("time_"+otherday1);
	var that_field2 = document.getElementById("time_"+otherday2);
	
	var remainDisabled = true;
	
	if (this_box.checked) {
		that_box1.checked = false;
		that_box2.checked = false;
		this_field.disabled=false;
		
		that_field1.disabled=true;
		that_field1.setAttribute("value","");
		that_field2.disabled=true;
		that_field2.setAttribute("value","");
	} else if (that_box1.checked) {
		this_box.checked = false;
		that_box2.checked = false;
		that_field1.disabled=false;
		
		this_field.disabled=true;
		this_field.setAttribute("value","");
		that_field2.disabled=true;
		that_field2.setAttribute("value","");
	} else if (that_box2.checked) {
		this_box.checked = false;
		that_box1.checked = false;
		that_field2.disabled=false;
		
		this_field.disabled=true;
		this_field.setAttribute("value","");
		that_field1.disabled=true;
		that_field1.setAttribute("value","");
	} else {
		this_box.checked = false;
		that_box1.checked = false;
		that_box2.checked = false;
		
		this_field.disabled=true;
		this_field.setAttribute("value","");
		that_field1.disabled=true;
		that_field1.setAttribute("value","");
		that_field2.disabled=true;
		that_field2.setAttribute("value","");
	}
}
function departEnable(theday) {
	var thedays = new Array("monday","tuesday","wednesday");
	
	var thisday;
	var otherday1;
	var otherday2;
	
	for (var i=0; i<thedays.length; i++) {
		if (theday==thedays[i]) thisday = thedays[i];
		else if (!otherday1) otherday1 = thedays[i];
		else otherday2 = thedays[i];
	}
	var this_box = document.getElementById("depart_"+thisday);
	var that_box1 = document.getElementById("depart_"+otherday1);
	var that_box2 = document.getElementById("depart_"+otherday2);
	
	var this_field = document.getElementById("time_"+thisday);
	var that_field1 = document.getElementById("time_"+otherday1);
	var that_field2 = document.getElementById("time_"+otherday2);
	
	var remainDisabled = true;
	
	if (this_box.checked) {
		that_box1.checked = false;
		that_box2.checked = false;
		this_field.disabled=false;
		
		that_field1.disabled=true;
		that_field1.setAttribute("value","");
		that_field2.disabled=true;
		that_field2.setAttribute("value","");
	} else if (that_box1.checked) {
		this_box.checked = false;
		that_box2.checked = false;
		that_field1.disabled=false;
		
		this_field.disabled=true;
		this_field.setAttribute("value","");
		that_field2.disabled=true;
		that_field2.setAttribute("value","");
	} else if (that_box2.checked) {
		this_box.checked = false;
		that_box1.checked = false;
		that_field2.disabled=false;
		
		this_field.disabled=true;
		this_field.setAttribute("value","");
		that_field1.disabled=true;
		that_field1.setAttribute("value","");
	} else {
		this_box.checked = false;
		that_box1.checked = false;
		that_box2.checked = false;
		
		this_field.disabled=true;
		this_field.setAttribute("value","");
		that_field1.disabled=true;
		that_field1.setAttribute("value","");
		that_field2.disabled=true;
		that_field2.setAttribute("value","");
	}
}

function totalFees() {
	var thefees = new Array("registration_fee","spouse_fee_full","spouse_fee_partial","shabbat_dinner_fee","fta_fee","other_fees");
	
	var fee_sum = 0.00;
	var current_amount = 0.00;
	var mazon_amount = 0.00;
	
	for (var i=0; i<thefees.length; i++) {
		var current_fee = document.getElementById(thefees[i]);
		current_amount = parseFloat(current_fee.getAttribute("value"));
		if (!current_amount) current_amount = 0.00;
		fee_sum = parseFloat(fee_sum) + parseFloat(current_amount);
	}
	//mazon_amount = (fee_sum * 0.03);
	
	var total_fees = document.getElementById("total_fees");
	//var mazon_con = document.getElementById("mazon_contribution");
	//var nata_con = document.getElementById("nata_contribution");
	
	total_fees.setAttribute("value",fee_sum);
	//mazon_con.setAttribute("value",mazon_amount);
	//nata_con.setAttribute("value",18.00);
}

function boolDisableDepart(thisOne,thatOne) {
	var day1="monday";
	var day2="tuesday";
	var day3="wednesday";
	
	var day1_box = document.getElementById("depart_"+day1);
	var day2_box = document.getElementById("depart_"+day2);
	var day3_box = document.getElementById("depart_"+day3);
	
	var day1_field = document.getElementById("time_"+day1);
	var day2_field = document.getElementById("time_"+day2);
	var day3_field = document.getElementById("time_"+day3);
	
	var thisfield = document.getElementById(thisOne);
	var thatfield = document.getElementById(thatOne);
	
	if (thisfield.checked) {
		day1_box.disabled=true;
		day2_box.disabled=true;
		day3_box.disabled=true;

		day1_box.checked = false;
		day2_box.checked = false;
		day3_box.checked = false;
		
		day1_field.disabled=true;
		day2_field.disabled=true;
		day3_field.disabled=true;
		
		day1_field.setAttribute("value","");
		day2_field.setAttribute("value","");
		day3_field.setAttribute("value","");
		
		thatfield.checked=false;
	} else if (thatfield.checked) {
		day1_box.disabled=false;
		day2_box.disabled=false;
		day3_box.disabled=false;
		
		thisfield.checked=false;
	} else {
		thisfield.checked=false;
		thatfield.checked=false;
		
		day1_box.disabled=true;
		day2_box.disabled=true;
		day3_box.disabled=true;
		
		day1_box.checked = false;
		day2_box.checked = false;
		day3_box.checked = false;
		
		day1_field.disabled=true;
		day2_field.disabled=true;
		day3_field.disabled=true;
		
		day1_field.setAttribute("value","");
		day2_field.setAttribute("value","");
		day3_field.setAttribute("value","");
	}
}
function boolEnableDepart(thisOne,thatOne) {
	var day1="monday";
	var day2="tuesday";
	var day3="wednesday";
	
	var day1_box = document.getElementById("depart_"+day1);
	var day2_box = document.getElementById("depart_"+day2);
	var day3_box = document.getElementById("depart_"+day3);
	
	var day1_field = document.getElementById("time_"+day1);
	var day2_field = document.getElementById("time_"+day2);
	var day3_field = document.getElementById("time_"+day3);
	
	var thisfield = document.getElementById(thisOne);
	var thatfield = document.getElementById(thatOne);
	
	if (thisfield.checked) {
		day1_box.disabled=false;
		day2_box.disabled=false;
		day3_box.disabled=false;
		
		thatfield.checked=false;
	} else if (thatfield.checked) {
		day1_box.disabled=true;
		day2_box.disabled=true;
		day3_box.disabled=true;

		day1_box.checked = false;
		day2_box.checked = false;
		day3_box.checked = false;
		
		day1_field.disabled=true;
		day2_field.disabled=true;
		day3_field.disabled=true;
		
		day1_field.setAttribute("value","");
		day2_field.setAttribute("value","");
		day3_field.setAttribute("value","");
		
		thisfield.checked=false;
	} else {
		thisfield.checked=false;
		thatfield.checked=false;
		
		day1_box.disabled=true;
		day2_box.disabled=true;
		day3_box.disabled=true;
		
		day1_box.checked = false;
		day2_box.checked = false;
		day3_box.checked = false;
		
		day1_field.disabled=true;
		day2_field.disabled=true;
		day3_field.disabled=true;
		
		day1_field.setAttribute("value","");
		day2_field.setAttribute("value","");
		day3_field.setAttribute("value","");
	}
}

// didn't use this, but for future....
function submitWarning(thisOne) {
	var submitButton = document.getElementById(thisOne);
	if (submitButton.disabled == true) {
		alert("You need to agree!");
	} else {
		return true;
	}
}

