// JavaScript Document
var intellipay_login = "inteq";
var intellipay_password = "auditls6";
var optionValue = "";

function submitForm() 
{

if(document.BillingInfo.NAME.value == "" )
{
	alert("Please enter the Name");
	document.BillingInfo.NAME.focus();
	return false;
}
if(document.BillingInfo.EMAIL.value=='')     
{
	alert("Enter your email address");
	document.BillingInfo.EMAIL.focus();   
	return false;
}
	var re = /^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
if (!document.BillingInfo.EMAIL.value.match(re)) 
{
	alert("Enter a valid email address");
	document.BillingInfo.EMAIL.select();   
	return false;
}
if(document.BillingInfo.ADDRESS.value == "" )
{
	alert("Please enter the street address");
	document.BillingInfo.ADDRESS.focus();
	return false;
}
if(document.BillingInfo.CITY.value == "" )
{
	alert("Please enter the city");
	document.BillingInfo.CITY.focus();
	return false;
}
if(document.BillingInfo.ZIP.value == "" )
{
	alert("Please enter the zip code");
	document.BillingInfo.ZIP.focus();
	return false;
}
if(document.BillingInfo.PHONE.value == "" )
{
	alert("Please enter the phone");
	document.BillingInfo.PHONE.focus();
	return false;
}

	
this.document.forms["BillingInfo"].LOGIN.value=intellipay_login;
this.document.forms["BillingInfo"].PASSWORD.value=intellipay_password;
if (document.forms["BillingInfo"].USER3.value == "Bedford") {
	optionValue = document.forms["BillingInfo"].BedfordCourse[document.forms["BillingInfo"].BedfordCourse.selectedIndex].value;
}
else if (document.forms["BillingInfo"].USER3.value == "San Diego") {
	optionValue = document.forms["frmSD"].SDCourse[document.forms["frmSD"].SDCourse.selectedIndex].value;
}
else if (document.forms["BillingInfo"].USER3.value == "Online") {
	optionValue = document.forms["BillingInfo"].USER4.value;
}
else {
	alert("There was an error while submitting this request. Please try again.");
	return false;
}
var splitval = optionValue.split("|");
this.document.forms["BillingInfo"].USER1.value=splitval[0]; //CourseName
this.document.forms["BillingInfo"].USER2.value=splitval[1]; //StartDate
this.document.forms["BillingInfo"].AMOUNT.value=splitval[2]; //Amount

if (document.forms["BillingInfo"].USER3.value == "Online") {
	this.document.forms["BillingInfo"].DESCRIPTION.value=splitval[0]; //Description
}else {
	if (splitval[2] == 0) {
		alert("Please select a course before submitting the form.");
		return false;
	}
	this.document.forms["BillingInfo"].DESCRIPTION.value=splitval[0] + " at " + this.document.forms["BillingInfo"].USER3.value + " on "+ splitval[1]; //Description
}
//alert("Course Name::"+this.document.forms["BillingInfo"].USER1.value+"\nStart Date::"+this.document.forms["BillingInfo"].USER2.value+"\nAmount::"+this.document.forms["BillingInfo"].AMOUNT.value);
//return true;

document.BillingInfo.action = "https://www.intellipay.net/LinkSmart/";
document.BillingInfo.submit();

}


