/*******************Form Validation and processing*****************/
function isEmpty(strValue) {
if((strValue == null) || (strValue == '') || (strValue.length < 0)) {
//alert("You must enter in a value with the fields marked by an asterisk *.");
//return msg;
return false;
} else {
//return msg;
return true;
}
}
function isNum(num) {
if((isNaN(num)) || (num.length != 5)) {
return false;
} else {
return true;
}
}
function CheckEmail(src) {
//var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
var regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;
return regex.test(src);
}
function hideDiv (divID) {
$(divID).hide();
}
function showDiv(divID) {
$(divID).show();
}
function formSubmit() {
//form validation
var message = "";
var industry = "";
//Get industry list
var ob = document.getElementById('industry');
if (!isEmpty($("#industry").val())) {
message = "You must select at least one industry.";
}
for (i = 0; i < ob.options.length; i++) {
if (ob.options[i].selected) {
industry = industry + "," + ob.options[i].value;
}
}
if((!isEmpty($("#alertZip").val())) || (!isEmpty($("#email_address").val()))) {
message = message + "\n" + "You must enter a value in all fields.";
}
if(!CheckEmail($("#email_address").val())) {
message = message + "\n" + "The email address must be entered in the correct format:johndoe@you.com";
}
if(!isNum($("#alertZip").val())) {
message = message + "\n" + "The zipcode must be a 5 digit number in order to be processed.";
}
if(message != "") {
alert(message);
return false;
}
var sold_dailydeal_source_url = $("#sold_dailydeal_source_url").val();
var sold_dailydeal_ip_address = $("#sold_dailydeal_ip_address").val();
var sold_dailydeal_optin_code = $("#solddotcom").attr('checked') ? 1 : 0
//Prepare data to submitted using jquery:ajax
params = {
alertZip : $("#alertZip").val(),
email_address : $("#email_address").val(),
industry : industry,
sold_dailydeal_source_url : sold_dailydeal_source_url,
sold_dailydeal_ip_address : sold_dailydeal_ip_address,
sold_dailydeal_optin_code : sold_dailydeal_optin_code
}
data = $.param(params);
//var data = "alertZip=" + $("#alertZip").val() + "&email_address=" + $("#email_address").val() + "&industry=" + industry + "&option_info=" + $("#info").val();
//data += "&sold_dailydeal_source_url=" + sold_dailydeal_source_url + "&sold_dailydeal_ip_address=" + sold_dailydeal_ip_address + "&sold_dailydeal_optin_code=" + sold_dailydeal_optin_code
//alert(industry);return false;
var test = $.ajax({
type: "POST",
url: "jobAlert.php",
data: data,
async: false
}).responseText;
s=s_gi('deemploymentguideprod');
s.linkTrackVars="events";
s.linkTrackEvents="event10";
s.events="event10";
s.tl(true,'o','jobalert');
/* //Hide the job alert form and reset the form values
hideDiv('#jobAlert');
document.getElementById('alertZip').value = "";
document.getElementById('email_address').value = "";
//Show confirmation and link to submit another job alert
var otherInfo = '
Submit another Job Alert';
$("#jobConfirm").html(test + otherInfo);
showDiv('#jobConfirm');
}*/
//Hide the job alert form and reset the form values
$('#JAForm').hide();
document.getElementById('alertZip').value = "";
document.getElementById('email_address').value = "";
//Show confirmation and link to submit another job alert
var otherInfo = 'Your Job Alert request has been sent!';
$("#JAConfirm").html(test + otherInfo);// used to add this test +
$('#JAConfirm').show();
}
/****************end form validation and processing*****************/
/*******************form window control*****************/
$('#jAIcon').mousedown(function() {
$('#JobAlertSignup').show();
});
$('#jAtextLink').click(function() {
$('#jAIcon').mousedown();
});
$('#JAClose').mousedown(function() {
$('#JobAlertSignup').hide();
});
$('#newAlertLink').mousedown(function() {
$('#JAConfirm').hide();
$('#JAForm').hide();
});
/****************end form window control*****************/
/**************** Sets page URL value for Sold.com submissions *****************/
$(function() {
$('#sold_dailydeal_source_url').val(document.location);
});