function sendContactUs(fn, ln, ea, sb, con) { $j.ajax({ url: "includes/ajax/general.ajax.php", data: "action=contact_us&first="+fn+"&last="+ln+"&email="+ea+"&subject="+sb+"&content="+con, success: function(msg){ $j('#contact_us_dialog').dialog('close'); $j('#contact_us_success_dialog').dialog('open') var submitButton = $j('.ui-dialog-buttonpane button:contains(Contact Us)'); submitButton.removeClass('ui-state-disabled'); submitButton.attr('disabled', false); } }); } function validateContactUs() { var error = ''; if ($('contact_first').value == '') { error += ' - First Name is a required field\n'; } if ($('contact_last').value == '') { error += ' - Last Name is a required field\n'; } if ($('contact_email_address').value == '') { error += ' - Email Address is a required field\n'; } if ($('contact_email_address').value != '') { if (!validate_email($('contact_email_address').value)) { error += ' - Email Address must be formatted properly\n'; } } if ($('contact_subject').value == '') { error += ' - Subject is a required field\n'; } if ($('contact_content').value == '') { error += ' - Content is a required field\n'; } if (error != '') { error = 'The following error(s) have occured:\n\n'+error; alert(error); return false; } else { var submitButton = $j('.ui-dialog-buttonpane button:contains(Contact Us)'); submitButton.addClass('ui-state-disabled'); submitButton.attr('disabled', 'disabled'); sendContactUs($j('#contact_first').val(), $j('#contact_last').val(), $j('#contact_email_address').val(), $j('#contact_subject').val(), $j('#contact_content').val()); return true; } } $j(document).ready(function(){ $j("#accordion").accordion({ collapsible: true, autoHeight: false }); function goToOrder(firstAr, lastAr, phoneAr, zipAr) { $j.ajax({ type: "GET", url: "includes/ajax/general.ajax.php", data: "action=new_cust&first="+firstAr+"&last="+lastAr+"&phone="+phoneAr+"&zip="+zipAr, success: function(msg){ window.location = 'https://plondosecurity.com/protect-your-home.php'; } }); } var first = $j("#first"), last = $j("#last") phoneArea = $j('#home_area'), phonePre = $j('#home_prefix'), phoneSuf = $j('#home_suffix'), zip = $j('#zip'), exist = $j('#existing_cust'), allFields = $j([]).add(first).add(last).add(phoneArea).add(phonePre).add(phoneSuf).add(zip).add(exist), tips = $j(".validateTips"); function updateTips(t) { tips .text(t) .addClass('ui-state-highlight'); setTimeout(function() { tips.removeClass('ui-state-highlight', 1500); }, 500); } function checkLength(o,n,min,max) { if ( (o.val().length > max && max != 0) || o.val().length < min ) { o.addClass('ui-state-error'); var tip = (max == 0) ? 'Length of '+ n +' must be '+ min +' digits long.' : "Length of " + n + " must be between "+min+" and "+max+"."; updateTips(tip); return false; } else { return true; } } function checkRegexp(o,regexp,n) { if ( !( regexp.test( o.val() ) ) ) { o.addClass('ui-state-error'); updateTips(n); return false; } else { return true; } } $j("#validate-form").dialog({ autoOpen: false, height: 275, width: 375, modal: true, buttons: { 'Start Order': function() { var bValid = true; allFields.removeClass('ui-state-error'); var validateButton = $j('.ui-dialog-buttonpane button:contains(Start Order)'); validateButton.addClass('ui-state-disabled'); validateButton.attr('disabled', 'disabled'); bValid = bValid && checkLength(first,"first name",2,80); bValid = bValid && checkLength(last,"last name",2,80); bValid = bValid && checkLength(phoneArea,"home phone area code",3,0); bValid = bValid && checkLength(phonePre,"home phone prefix",3,0); bValid = bValid && checkLength(phoneSuf,"home phone suffix",4,0); bValid = bValid && checkLength(zip,"zip code",5,0); bValid = bValid && checkRegexp(first,/^([a-zA-Z])+$/,"First name may consist of only letters."); bValid = bValid && checkRegexp(last,/^([a-zA-Z])+$/,"Last name may consist of only letters."); // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/ //bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com"); bValid = bValid && checkRegexp(phoneArea,/^([0-9])+$/,"Home phone area code may consist of only numbers."); bValid = bValid && checkRegexp(phonePre,/^([0-9])+$/,"Home phone prefix may consist of only numbers."); bValid = bValid && checkRegexp(phoneSuf,/^([0-9])+$/,"Home phone suffix may consist of only numbers."); bValid = bValid && checkRegexp(zip,/^([0-9])+$/,"Zip code may consist of only numbers."); if (bValid) { goToOrder(first.val(), last.val(), phoneArea.val().toString()+phonePre.val().toString()+phoneSuf.val().toString(), zip.val()); //$j(this).dialog('close'); } else { validateButton.removeClass('ui-state-disabled'); validateButton.attr('disabled', false); } }, 'Cancel': function() { $j(this).dialog('close'); } }, close: function() { allFields.val('').removeClass('ui-state-error'); } }); $j("#contact_us_dialog").dialog({ autoOpen: false, height: 575, width: 475, modal: true, buttons: { 'Contact Us': function() { validateContactUs(); } } }); $j("#contact_us_success_dialog").dialog({ autoOpen: false, height: 150, width: 575, modal: true }); $j("#exist_cust").dialog({ autoOpen: false, height: 150, width: 500, modal: true }); $j("#popup_one_dialog").dialog({autoOpen: false, width: 600, height: 600}); $j("#popup_one_one").click(function() { $j("#popup_one_dialog").dialog('open'); return false; }); $j("#popup_one_two").click(function() { $j("#popup_one_dialog").dialog('open'); return false; }); $j("#popup_two_dialog").dialog({autoOpen: false, width: 600, height: 600}); $j("#popup_two_one").click(function() { $j("#popup_two_dialog").dialog('open'); return false; }); $j("#popup_two_two").click(function() { $j("#popup_two_dialog").dialog('open'); return false; }); $j("#products_dialog").dialog({autoOpen: false, width: 650, height: 600}); $j("#products_image").click(function() { //$j("#products_dialog").dialog('open'); $j('#validate-form').dialog('open'); return false; }); $j("#termsconditions").dialog({autoOpen: false, width: 600, height: 400}); $j("#terms").click(function() { $j("#termsconditions").dialog('open'); return false; }); $j("#partner").click(function() { window.location = 'https://plondosecurity.com/pos'; return false; }); });