var LoadingImage = '
';
//Sets a login cookie
function setCookie(c_name,value) {
var exdays = 1;
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()+";path=/");
document.cookie=c_name + "=" + c_value;
}
function clearCookie () {
setCookie("LoginEmail", '');
setCookie("LoginID", '');
location.reload();
}
//Validates user email address
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
//Populates form with ajax data
function PopulateForm(htmlData) {
$('#Content').html(htmlData);
}
//Verifies sign-in information and proceeds
function login_Process()
{
//Gather User Input
email = $("#loginEmail").val();
password = $("#loginPassword").val();
//Check for errors
error = false;
errormsg = "";
if (email == '') {
errormsg += "You did not enter your email address
";
error = true;
} else if (validateEmail(email) != true) {
errormsg += "You did not enter a valid email address
";
error = true;
}
if (password == '') {
errormsg += "You did not enter your password
";
error = true;
}
if (error == true) {
$("#ErrorDiv").html(errormsg);
showErrorDiv();
//Process Results
} else {
sd = {
'loginEmail':email,
'loginPassword':password,
'formType': 'loginForm'
}
$.ajax({'url': "/account/login_Process.php", 'global': false, 'dataType': "html", 'type': "POST", 'data': sd, 'success': function (data) {
if (data == 'success') {
window.location = "/index.html";
location.replace(document.referrer);
//$("#Content").html("We sent you a verification email, Check your email for the link");
} else {
$('#ErrorDiv').html(data);
showErrorDiv();
}
}});
}
}
//Process adding a member
function signup_Process()
{
var Email = $("#Email").val();
var Password = $("#Password").val();
var PasswordConfirm = $("#PasswordConfirm").val();
var First_Name = $("#First_Name").val();
var Last_Name = $("#Last_Name").val();
var Business_Name = $("#Business_Name").val();
var Business_Type = $("#Business_Type").val();
var Phone = $("#Phone").val();
var Billing_Address1 = $("#Billing_Address1").val();
var Billing_Address2 = $("#Billing_Address2").val();
var Billing_City = $("#Billing_City").val();
var Billing_State = $("#Billing_State").val();
var Billing_Zip = $("#Billing_Zip").val();
var Billing_Country = $("#Billing_Country").val();
var Shipping_Address1 = $("#Shipping_Address1").val();
var Shipping_Address2 = $("#Shipping_Address2").val();
var Shipping_City = $("#Shipping_City").val();
var Shipping_State = $("#Shipping_State").val();
var Shipping_Zip = $("#Shipping_Zip").val();
var Shipping_Country = $("#Shipping_Country").val();
var recaptcha = $("#g-recaptcha-response").val();
//alert("recaptcha" + recaptcha);
//Error Check
var errorMsg = new Array();
if(Email == '') {errorMsg.push('You did not enter your email address
');
} else if (validateEmail(Email) != true) {errorMsg.push("You did not enter a valid email address");}
if(Password == '') {errorMsg.push('You did not enter your password
');}
if(PasswordConfirm == '') {errorMsg.push('You did not confirm your password
');}
if(Password != PasswordConfirm) {errorMsg.push('Your passwords do not match
');}
if(First_Name == '') {errorMsg.push('You did not enter your first name
');}
if(Last_Name == '') {errorMsg.push('You did not enter your last name
');}
if(Business_Name == '') {errorMsg.push('You did not enter your business name
');}
if(Business_Type == '') {errorMsg.push('You did not select your business type
');}
if(Phone == '') {errorMsg.push('You did not enter your phone number
');}
if(Billing_Address1 == '') {errorMsg.push('You did not enter your billing address
');}
if(Billing_City == '') {errorMsg.push('You did not enter your billing city
');}
if(Billing_State == '') {errorMsg.push('You did not select your billing province/state
');}
if(Billing_Zip == '') {errorMsg.push('You did not enter your billing postal code
');}
if(Billing_Country == '') {errorMsg.push('You did not select your billing country
');}
if(Shipping_Address1 == '') {errorMsg.push('You did not enter your shipping address
');}
if(Shipping_City == '') {errorMsg.push('You did not enter your shipping city
');}
if(Shipping_State == '') {errorMsg.push('You did not select your shipping province/state
');}
if(Shipping_Zip == '') {errorMsg.push('You did not enter your shipping postal code
');}
if(Shipping_Country == '') {errorMsg.push('You did not select your shipping country
');}
//If errors, print errors
clearErrorDiv();
if (errorMsg.length > 0) {
for(var i=0; iPlease check your email for instructions on validating your email address. You must validate your email address before proceeding.');
}
}});
}
}
//Process validating a member
function validateEmail_Process(KEY)
{
var memberKEY = KEY;
sd = {
'memberKEY': memberKEY
}
$.ajax({'url': "/account/validateEmail_Process.php", 'global': false, 'dataType': "html", 'type': "POST", 'data': sd, 'success': function (data) {
setCookie("LoginEmail", '');
setCookie("LoginID", '');
$("#Content").html(data);
}});
}
//Process activating a member
function activateEmail_Process(KEY)
{
var memberKEY = KEY;
sd = {
'memberKEY': memberKEY
}
$.ajax({'url': "/account/activateEmail_Process.php", 'global': false, 'dataType': "html", 'type': "POST", 'data': sd, 'success': function (data) {
setCookie("LoginEmail", '');
setCookie("LoginID", '');
}});
}
//To process forgot-password form
function forgotPassword_Process()
{
memberEmail = $("#Forgot_Password_Email").val();
//Error Check
var errorMsg = new Array();
if(memberEmail == '') {
errorMsg.push('You did not enter your email address
');
} else if (validateEmail(memberEmail) != true) {
errorMsg.push("You did not enter a valid email address");
}
//If errors, print errors
$("#ErrorDiv").html('').removeClass('d-none').removeClass('d-block');
if (errorMsg.length > 0) {
for(var i=0; i');
}
if(memberLastName == '') {
errorMsg.push('You did not enter your last name
');
}
//If errors, print errors
$("#ErrorDiv").html('');
if (errorMsg.length > 0) {
for(var i=0; i');
}
if(memberPasswordConfirm == '') {
errorMsg.push('You did not confirm your password
');
}
if(memberPassword != memberPasswordConfirm) {
errorMsg.push('Your passwords do not match
');
}
//If errors, print errors
$("#ErrorDiv").html('');
if (errorMsg.length > 0) {
for(var i=0; i