
function f_apply_discount()
{
document.frmMain.action = "#disc";
document.frmMain.hdnFunc.value = "DISCOUNT";
document.frmMain.submit();
}

function f_validate_all()
{
var d1,d2,ra,sm;

document.frmMain.hdnFunc.value = "REGISTER";

d1 = document.frmMain.ArrivalDate.value;
d2 = document.frmMain.DepartDate.value;
ra = f_get_radio_value("Roomaccommodations");
sm = f_get_radio_value("smoking");
//alert(d1 + ' ' + d2 + ' ' + ra + ' ' + sm);

if(f_validate_email("email")==false) {
	alert('email address appears to be invalid.');
	document.frmMain["email"].focus();
	return(0);
	}

if((d1!="") && (d2=="")) {
	alert('must include a departure date.');
	return(false);			
	}
if((d1=="") && (d2!="")) {
	alert('must include an arrival date.');
	return(false);			
	}
if(f_validate_dates("DepartDate")==false) {
	return(0);
	}
//if(f_is_radio_checked("regfee")==false) 
if(document.frmMain["regfee"].checked==false) 
	{
	alert('please select the proper registration fee.');
	document.frmMain["regfee"][0].focus();
	return(0);
	}
if(f_is_radio_checked("trans")==false) {
	alert('please indicate whether you will require transportation to Spraying Systems Co. on day 3.');
	document.frmMain["trans"][0].focus();
	return(0);
	}
//indchemical;indpharm;indFoodProc;indPollution;indother
i1 = document.frmMain["indchemical"].checked;
i2 = document.frmMain["indpharm"].checked;
i3 = document.frmMain["indFoodProc"].checked;
i4 = document.frmMain["indPollution"].checked;
i5 = document.frmMain["indother"].checked;
if((i1 || i2 || i3 || i4 || i5) == false) {
	alert('you must check an industry or other');
	return(0);
	}
//appGasCond;appTankWash;appTablet;appSprayDry;appother
a1 = document.frmMain["appGasCond"].checked;
a2 = document.frmMain["appTankWash"].checked;
a3 = document.frmMain["appTablet"].checked;
a4 = document.frmMain["appSprayDry"].checked;
a5 = document.frmMain["appother"].checked;
if((a1 || a2 || a3 || a4 || a5) == false) {
	alert('you must check an application or other');
	return(0);
	}

if(f_is_radio_checked("ShareName")==false) {
	alert('please check YES or NO to indicate whether we can share your name with other seminar registrants.');
	document.frmMain["ShareName"][0].focus();
	return(0);
	}

if((f_get_radio_value("Hotelaccommodations")=="Y") && (document.frmMain.paybycheck.checked==true)) {
	//alert('payment by credit card is required for us to handle your hotel reservations.');
	//document.frmMain["Hotelaccommodations"].focus();
	//return(0);
	}
if((f_get_radio_value("Hotelaccommodations")=="Y") && ((d1=="") || (d2=="") || (ra=="") || (sm==""))) {
	alert('if you need hotel reservations, you must specify the arrival and departure dates, single/double, and smoking/non preference.');
	document.frmMain["Hotelaccommodations"].focus();
	return(0);
	}
if(f_is_radio_checked("optSource")==false) {
	alert('please tell us how you learned about the seminar.');
	document.frmMain["optSource"][0].focus();
	return(0);
	}	
	
//alert('ok');
document.frmMain.submit();
}

function f_validate_date(obj)
{
var d1,d2;
obj.value = f_fmt_date(obj.value);
f_validate_dates(obj.name);
}

function f_validate_dates(sName)
{
var d1,d2;
d1 = document.frmMain.ArrivalDate.value;
d2 = document.frmMain.DepartDate.value;

//alert(d1 + "," + d2);
if(d1!="") {
	if(f_datediff_today(d1)<1) {
		//obj.value = "";
		document.frmMain[sName].value = "";
		alert('arrival date must be in the future.');
		document.frmMain[sName].focus();
		return(false);
		}
	}
if(d2!="") {
	if(f_datediff_today(d2)<1) {
		document.frmMain[sName].value = "";
		alert('departure date must be in the future.');
		document.frmMain[sName].focus();
		return(false);
		}
	}
if((d1!="") && (d2!="")) {
	//alert(f_datediff(d1,d2));
	if(f_datediff(d1,d2)<1) {
		document.frmMain[sName].value = "";
		alert('departure date must be later than arrival date.');
		document.frmMain[sName].focus();
		return(false);
		}
	}
return(true);
}
