	function deselectFields(givenvalueofresident) {
					//alert("it's running");
		if (givenvalueofresident.value != "US" && givenvalueofresident.value != "PR") {
			//alert("Hey");
			MWForm.ethinicity[0].checked = false;
			MWForm.ethinicity[1].checked = false;
			MWForm.AmericanIndian.checked = false;
			MWForm.AsianAmerican.checked = false;
			MWForm.AfricanAmerican.checked = false;
			MWForm.NativeHawaiian.checked = false;
			MWForm.White.checked = false;
		}
	}
	function usaOnly(fieldname,controlname) {
		//if (fieldname.checked && controlname[2].checked) {
		if (fieldname.checked && controlname.value != 'US' && controlname.value != 'PR') {
			fieldname.checked = false;
			alert("If you are not a US Citizen or Permanent Resident do not answer the questions about Race or Ethnicity.");
		}
	}
	function checkradio0values(fieldname,controlname) {
		if (fieldname[0].checked && controlname.value != 'US' && controlname.value != 'PR') {
			fieldname[0].checked = false;
			alert("If you are not a US Citizen or Permanent Resident do not answer the questions about Race or Ethnicity.");
		}
	}
	function checkradio1values(fieldname,controlname) {
		if (fieldname[1].checked && controlname.value != 'US' && controlname.value != 'PR') {
			fieldname[1].checked = false;
			alert("If you are not a US Citizen or Permanent Resident do not answer the questions about Race or Ethnicity.");
		}
	}
	
function checkJournalSelections(numJournals) {

	var AllJournalsObjNameObj;
	var AllJournalsObj;
	var PrintJRTypeObj;
	var PrintJRType;
	var AJOValue;
	var JRTypeObj;
	var i, j;
	
	AllJournalsObjNameObj = document.all["AllASMFormElement"];
	
	if (AllJournalsObjNameObj) {
		
		AllJournalsObj = document.all[AllJournalsObjNameObj.value];
		
		if (AllJournalsObj) {
		
			AJOValue = "";
			i = 0;
			for (i = 0; i < AllJournalsObj.length; i++) {
				if (AllJournalsObj[i].checked) {
					AJOValue = AllJournalsObj[i].value;
				}
			}
		
			if (AJOValue != "") {
				
				PrintJRTypeObj = document.all["printJRTypeID"];
			
				if (PrintJRTypeObj) {
					printJRTypeID = PrintJRTypeObj.value;
				
					for (i = 0; i < numJournals - 2; i++) {

						objName = "JournalProduct" + i
						radioObj = document.all[objName];
						
						if (radioObj) {
							if (radioObj != AllJournalsObj) {
								for (j = 0; j < radioObj.length - 1; j++) {
									if (radioObj[j].checked) {
										JRTypeObj = document.all[objName + j + "JRTypeID"];
										if (JRTypeObj.value != printJRTypeID) {										
											radioObj[radioObj.length - 1].checked = true;
										}
									}
								}
							}
						}
					}
				
				}
			}
		}
	}
}

function updateJournalFields() {
	var numJournalsObj = document.all["TotalJournals"];
	var hiddenCostObj;
	var radioObj;
	var textObj;
	var totalJournalCostObj;
	var ASMDuesCostObj;
	var OLDiscountObj;
	var subTotalCostObj;
	var itemCost;
	var totalJCost;
	var subTotalCost;
	var DonationObj;
	var TotalCostObj;
	var objName;
	var i;
	var j;
	var done;

	checkJournalSelections(numJournalsObj.value);

	totalJCost = 0;

	for (i = 0; i < numJournalsObj.value; i++) {

		objName = "JournalProduct" + i
		radioObj = document.all[objName];
		
		done = false;
		for (j = 0; j < radioObj.length && !done; j++) {
			if (radioObj[j].checked) {
				if (radioObj[j].value != "") {
					hiddenCostObj = document.all[radioObj[j].value + "Cost"];
					itemCost = 	hiddenCostObj.value * 1; //forces to integer
				}
				else {
					itemCost = 0;
				}
			}
		}


		textObj = document.all["Total" + i];
		textObj.value = "$" + itemCost;

		totalJCost += itemCost;
	}

	totalJournalCostObj = document.all["TotalJournalCost"];
	totalJournalCostObj.value = "$" + totalJCost;
	ASMDuesCostObj = document.all["ASMDuesTotal"];
	OLDiscountObj = document.all["OLDuesDiscount"];
	subTotalCost = totalJCost + (ASMDuesCostObj.value * 1) + (OLDiscountObj.value * 1);
	subTotalCostObj = document.all["SubTotalCost"];
	subTotalCostObj.value = "$" + subTotalCost;
	DonationObj = document.all["Donation"];
	if (DonationObj.value < 0) {
		DonationObj.value = 0;
	}
	TotalCostObj = document.all["TotalCost"];
	
	totalCost = subTotalCost + (DonationObj.value * 1);
	TotalCostObj.value = "$" + totalCost;

}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function checkVoteSelect() {

	var obj1;
	var obj2
	var val1;
	var val2;

	obj1 = document.getElementById("MICF02");
	obj2 = document.getElementById("MISCV1");
	
	val1 = obj1.options[obj1.selectedIndex].value;
	val2 = obj2.options[obj2.selectedIndex].value;
	
	if (val1==val2) {
		obj2.options[0].selected = true;
		alert("Please select different areas for primary and secondary voting divisions.");
	}
	
	return 0;

}

function exp_coll(ind) {
	s = document.getElementById("sp_" + ind);
	i = document.getElementById("im_" + ind);
 
	if (!(s && i)) return false;
	if (s.style.display == 'none') {
		s.style.display = 'block';
		i.src = "/estore/images/minus.gif";
		}
	else if (s.style.display == 'block') {
		s.style.display = 'none';
		i.src = "/estore/images/plus2.gif";
	}
}

function exp(ind) {
 
	s = document.getElementById("sp_" + ind);
	i = document.getElementById("im_" + ind);
	if (!(s && i)) return false;
	s.style.display = 'block';
	i.src = "/estore/images/minus.gif";
 
}

function coll(ind) {
	s = document.getElementById("sp_" + ind);
	i = document.getElementById("im_" + ind);
	if (!(s && i && i2)) return false;
	s.style.display = 'none';
	i.src = "/estore/images/plus2.gif";
}