function sendRequest() {
var source = "";
var name = "";
var address = "";
var city = "";
var state = "";
var zip = "";
var check1 = false;
var check2 = false;
var check3 = false;
var check4 = false;
var email = "";
var phone = "";
var comments = "";
if ( $("#name_small").val() != "" ) {
source = $("#source_small").val();
name = $("#name_small").val();
address = $("#address_small").val();
city = $("#city_small").val();
state = $("#state_small").val();
zip = $("#zip_small").val();
check1 = $("#check1_small").prop("checked");
check2 = $("#check2_small").prop("checked");
check3 = $("#check3_small").prop("checked");
check4 = $("#check4_small").prop("checked");
email = $("#email_small").val();
phone = $("#phone_small").val();
comments = $("#comments_small").val();
} else if ( $("#name_large").val() != "" ) {
source = $("#source_large").val();
name = $("#name_large").val();
address = $("#address_large").val();
city = $("#city_large").val();
state = $("#state_large").val();
zip = $("#zip_large").val();
check1 = $("#check1_large").prop("checked");
check2 = $("#check2_large").prop("checked");
check3 = $("#check3_large").prop("checked");
check4 = $("#check4_large").prop("checked");
email = $("#email_large").val();
phone = $("#phone_large").val();
comments = $("#comments_large").val();
} else {
alertMsg("You must enter a valid Name, Address, Email and Phone Number");
return;
}
if ( !ValidateEmail(email) ) {
alertMsg("You have entered an invalid email address.");
return;
}
var phoneUnFormatted = phone;
phoneUnFormatted = phoneUnFormatted.trim();
phoneUnFormatted = phoneUnFormatted.replaceAll("(", "");
phoneUnFormatted = phoneUnFormatted.replaceAll(")", "");
phoneUnFormatted = phoneUnFormatted.replaceAll(" ", "");
phoneUnFormatted = phoneUnFormatted.replaceAll(".", "");
phoneUnFormatted = phoneUnFormatted.replaceAll("-", "");
if ( !ValidatePhoneNumber(phoneUnFormatted) ) {
alertMsg("You have entered an invalid phone number.");
return;
}
$("#ModalMessage").modal();
var thisEmail = "
" +
"Thank you for requesting information from NVblu, Inc. Based on your request, an NVblu representative will contact you within 1 business day." +
"
" +
"If you have any questions that you would like answered immediately, please call NVblu at 703.968.8888 Extension 400 (Residential Sales)." +
"
" +
"Your interest in NVblu, Inc. is very important to us and we greatly appreciate your interest in our company." +
"
";
var leadEmail =
"" +
"REQUEST FOR APPOINTMENT
" +
"From: " + name + "
" +
"Address:
" +
address + "
" + city + ", " + state + " " + zip + "
" +
"Phone: " + phone + "
" +
"Email: " + email + "
" +
"Comments:
" +
comments + "
" +
"How did you find out about NVblu?: " + source + "
" +
"Interested In:
";
if ( check1 )
leadEmail = leadEmail + "* In-home estimate & custom designed pool plan.
";
if ( check2 )
leadEmail = leadEmail + "* Info about remodeling/updating an existing pool.
";
if ( check3 )
leadEmail = leadEmail + "* To hear from a design consultant.
";
if ( check4 )
leadEmail = leadEmail + "* Service for my pool.
";
leadEmail = leadEmail +
"
";
var data = {};
data['sf'] = 'sendemail';
data['Customers'] = '';
data['Tasks'] = '';
data['Subject'] = 'NVblu Appointment Request';
data['EmailText'] = thisEmail + "
" + leadEmail;
data['Email'] = email;
data['BCCEmail'] = "";
data['sendToCustomers'] = "";
data['formName'] = "";
data['formType'] = "";
$("#ModalMessageBody").html("PROCESSING REQUEST...
");
$.ajax({
url: '/screens/data/contact/',
type: 'post',
data: data,
dataType: 'json',
success: function(data) {
sendLeadEmail(leadEmail);
},
error: function (jqXHR, textStatus, errorThrown)
{
$("#ModalMessage").modal('hide');
alertMsg(jqXHR.responseText);
}
});
}
function sendLeadEmail(leadEmail) {
var data = {};
data['sf'] = 'sendemail';
data['Customers'] = '';
data['Tasks'] = '';
data['Subject'] = 'NVblu Appointment Request';
data['EmailText'] = leadEmail;
data['Email'] = "eric@nvblu.com";
data['BCCEmail'] = "";
data['sendToCustomers'] = "";
data['formName'] = "";
data['formType'] = "";
$.ajax({
url: '/screens/data/contact/',
type: 'post',
data: data,
dataType: 'json',
success: function(data) {
$("#ModalMessageBody").html("Request completed!");
$("#CloseButton").show();
},
error: function (jqXHR, textStatus, errorThrown)
{
$("#ModalMessage").modal('hide');
alertMsg(jqXHR.responseText);
}
});
}
function ValidateEmail(inputText)
{
inputText = inputText.trim();
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(inputText.match(mailformat))
{
return true;
}
else
{
return false;
}
}
function ValidatePhoneNumber(inputText)
{
var mailformat = /^\d{10}$/;
if(inputText.match(mailformat))
{
return true;
}
else
{
return false;
}
}
function closeScreen() {
window.close();
}