function disableForm(theForm) {
	for (i = 0; i < theForm.elements.length; i++) {
		var tempobj = theForm.elements[i];
		//if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
//		tempobj.disabled = true;
		tempobj.readOnly = true;
		//document.write(tempobj.value);
	}
}

function CheckWorkshops(workshops, day)
{
	var ordinal = new Array("first", "second", "third");
	var counts = new Array(0, 0, 0);
	var tail = " for " + day + "'s workshops.";
	for (w = workshops.length; w >= 0; w--) {
		var i = workshops[w] - 1;
		if ( ++counts[i] > 1) {
			alert("You have duplicate " + ordinal[i] + " choices selected" + tail);
			return false;
		}
	}
	var prevCount = 0;
	for (i = 2; i >= 0; i--) {
		if (prevCount == 1 && counts[i] == 0) {
			alert("You have made a " + ordinal[i + 1] + " choice without making a " + ordinal[i] + " choice" + tail);
			return false;
		}
		prevCount = counts[i];
	}
	return true;
}

function SymposiumFormValidator(theForm)
{
	// alert("Validating");
	var nameLength = 50;
	var addrLength = 50;

	if (!ValidateField(theForm.first_name, "First Name", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, FV_NAMESYMBOLS_MASK, nameLength))
		return false;
	if (!ValidateField(theForm.last_name, "Last Name", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, FV_NAMESYMBOLS_MASK, nameLength))
		return false;
	if (!ValidateField(theForm.address1, "Address Line 1", true, FV_TEXT, FV_ALLTEXT, "", addrLength)) return false;
	if (!ValidateField(theForm.address2, "Address Line 2", false, FV_TEXT, FV_ALLTEXT, "", addrLength)) return false;
	if (!ValidateField(theForm.city, "City", true, FV_TEXT, FV_ALLTEXT, "", nameLength)) return false;
	if (!ValidateField(theForm.zip, "Zip Code", false, FV_TEXT, FV_ALPHANUMERIC, "- ", 10, 5)) return false;
	if (!ValidateField(theForm.country, "Country", false, FV_TEXT, FV_ALLTEXT, "", nameLength)) return false;

	if (!ValidateField(theForm.company, "Company", false, FV_TEXT, FV_ALLTEXT, "", nameLength)) return false;
	if (!ValidateField(theForm.credentials, "Credentials", true, FV_TEXT, FV_ALLTEXT, "", 50)) return false;

	if (!ValidateField(theForm.work_phone, "Work Phone", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, "()-", 14, 10)) return false;
	if (!ValidateField(theForm.work_ext, "Work Extension", false, FV_TEXT, FV_NUMERIC, "", 5)) return false;
	if (!ValidateField(theForm.fax_no, "Fax Number", false, FV_TEXT, FV_ALPHANUMERIC_WHITE, "()-", 14, 10)) return false;
	if (!ValidateField(theForm.home_phone, "Home Phone", false, FV_TEXT, FV_ALPHANUMERIC_WHITE,  "()-", 14, 10)) return false;

	if (!ValidateField(theForm.email, "E-mail address", true, FV_TEXT, FV_ALPHANUMERIC,  "@.-_", 40, 7)) return false;
	if (theForm.email.value) {
		if (!ValidateEmail(theForm.email.value)) {
			theForm.email.focus();
			return false;
		}
	}

	var titleChecked = false;
	for (var i = 0; i < theForm.elements.length; ++i) {
		var elem = theForm.elements[i];
		if (elem.type == "checkbox" && elem.name.substring(0, 6) == "title_" && elem.checked) {
			titleChecked = true;
			break;
		}
	}
	if (!titleChecked) {
		alert("Please select one or more Professional Titles.");
		return false;
	}

	if (!SymposiumSpecificValidator(theForm)) return false;

	/*	
	if (!ValidateField(theForm.CCard_Number1, "Credit Card Number Field 1", true, FV_TEXT, FV_NUMERIC, "", 4, 3)) 
		return (false);
	if (!ValidateField(theForm.CCard_Number2, "Credit Card Number Field 2", true, FV_TEXT, FV_NUMERIC, "", 4, 3)) 
		return (false);
	if (!ValidateField(theForm.CCard_Number3, "Credit Card Number Field 3", true, FV_TEXT, FV_NUMERIC, "", 4, 3)) 
		return (false);
	if (!ValidateField(theForm.CCard_Number4, "Credit Card Number Field 4", true, FV_TEXT, FV_NUMERIC, "", 4, 3)) 
		return (false);
	if (!ValidateField(theForm.CCard_Name, "Credit Card Name", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, FV_NAMESYMBOLS_MASK, nameLength))
		return false;
	if (!ValidateField(theForm.CCard_Address1, "Credit Card Address Line 1", false, FV_TEXT, FV_ALLTEXT, "", addrLength))
		return false;
	if (!ValidateField(theForm.CCard_Address2, "Credit Card Address Line 2", false, FV_TEXT, FV_ALLTEXT, "", addrLength))
		return false;
	if (!ValidateField(theForm.CCard_City, "Credit Card City", false, FV_TEXT, FV_ALLTEXT, "", nameLength))
		return false;
	if (!ValidateField(theForm.CCard_Zip, "Credit Card Zip Code", false, FV_TEXT, FV_NUMERIC, "-", 10, 5))
		return false;
	*/
		
	if (theForm.email.value != theForm.email_confirm.value) {
		alert("Please check your e-mail address.  The e-mail address and confirmation fields do not match.");
		return false;
	}

	if (theForm.agreement.checked != "1") {
		alert("Please check the box near the Submit button to indicate your understanding of the terms and conditions of this registration.");
		return false;
	}

	if (!theForm.email.value) {
		theForm.email.value = " ";
	}
	
	return true;
}

function DonationFormValidator(theForm)
{
	//alert("Validating");
	var nameLength = 50;
	var addrLength = 50;

	if (!ValidateField(theForm.first_name, "First Name", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, FV_NAMESYMBOLS_MASK, nameLength))
		return false;
	if (!ValidateField(theForm.last_name, "Last Name", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, FV_NAMESYMBOLS_MASK, nameLength))
		return false;
	if (!ValidateField(theForm.address1, "Address Line 1", true, FV_TEXT, FV_ALLTEXT, "", addrLength)) return false;
	if (!ValidateField(theForm.address2, "Address Line 2", false, FV_TEXT, FV_ALLTEXT, "", addrLength)) return false;
	if (!ValidateField(theForm.city, "City", true, FV_TEXT, FV_ALLTEXT, "", nameLength)) return false;
	if (!ValidateField(theForm.zip, "Zip Code", false, FV_TEXT, FV_ALPHANUMERIC, "- ", 10, 5)) return false;
	if (!ValidateField(theForm.country, "Country", false, FV_TEXT, FV_ALLTEXT, "", nameLength)) return false;
	if (!ValidateField(theForm.phone, "Phone", true, FV_TEXT, FV_ALPHANUMERIC_WHITE, "()-", 20, 10)) return false;
	if (!ValidateField(theForm.email, "E-mail address", true, FV_TEXT, FV_ALPHANUMERIC,  "@.-_", 40, 6)) return false;
	if (theForm.email.value) {
		if (!ValidateEmail(theForm.email.value)) {
			theForm.email.focus();
			return false;
		}
	}

	if (theForm.email.value != theForm.email_confirm.value) {
		alert("Please check your e-mail address.  The e-mail address and confirmation fields do not match.");
		return false;
	}
	
	var applyTowardsChecked = false;
	for (var i = 0; i < theForm.apply_towards.length; ++i) {
		var elem = theForm.apply_towards[i];
		if (elem.checked) {
			applyTowardsChecked = true;
			break;
		}
	}
	if (!applyTowardsChecked) {
		alert("Please select what you would like to apply the donation towards.");
		return false;
	}

	var selectedAmountChecked = false;
	var selectedAmountOther = false;
	for (var i = 0; i < theForm.selected_amount.length; ++i) {
		var elem = theForm.selected_amount[i];
		if (elem.checked) {
			selectedAmountChecked = true;
			if (elem.value == "sa_other")
				selectedAmountOther = true;
			break;
		}
	}
	if (!selectedAmountChecked) {
		alert("Please select the amount you wish to donate.");
		return false;
	} else if (selectedAmountOther) {
		if (!ValidateField(theForm.other_amount, "Other amount", true, FV_NUMBER, FV_NUMERIC, ""))
			return false;
	} else {
		if (theForm.other_amount.value != "") {
			alert("You have selected one of the standard amounts, but you have also typed an amount in the 'Other Amount' field.  If you wish to donate the amount that you have typed in, please click the check box next to that option.  Otherwise, please delete the amount from that field.")
			return false;
		}
	}

	if (!theForm.email.value) {
		theForm.email.value = " ";
	}
}

function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
    var img = new Image;
    img.src = imageName;
    if (imageWidth == 0) imageWidth = img.width;
    if (imageHeight == 0) imageHeight = img.height;
    newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
    newWindow.document.open();
    newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
    newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>');
    newWindow.document.write('</body></html>');
    newWindow.document.close();
    newWindow.focus();
}

function openWindow(url,width,height,posLeft,posTop) {
    newWindow = window.open(url,"newWindow","width="+width+",height="+height+",scrollbars,resizable");
    newWindow.focus();
}

function facultyFormValidator(theForm)
{
	if (!formSpecificValidator(theForm)) return false;

	if (theForm.agree_checked != null && theForm.agree_checked.value != "1") {
		alert("Please check the box above the Submit button to indicate your understanding of the terms and conditions of this registration.");
		return false;
	}
}

