pack();
}
header("Content-type: application/x-javascript");
if($acf_conf['show_hide_errors_effect'] != 'slide') { $acf_conf['show_hide_errors_effect'] = 'none'; }
?>
/*
Author: Gabriel Comarita
Author's Website: http://www.bitrepository.com/
Copyright (c) BitRepository.com
*/
// Ensure that JQuery won't conflict with other libraries
var = jQuery.noConflict();
(function() { // When DOM is ready
// Important for JS validation
var total_required_inputs = ; /* (usually name, email, subject, message & security code) */
// Preload Icons
// This way they will show instantly without waiting for the browser to load them (for instance the 'ajax loading spinner')
img1 = new Image(18, 15);
img1.src = 'icon-ajax-loader.gif';
img2 = new Image(22, 22);
img2.src = 'icon-dialog-error.png';
img3 = new Image(22, 22);
img3.src = 'icon-button-ok.png';
img4 = new Image(16, 16);
img4.src = 'icon-refresh.png';
/*
-------------------------------------------------
Is the form (ID: 'ajax-contact-form') submitted?
-------------------------------------------------
*/
('#ajax_contact_form').submit(function() {
$acf_value) {
if($acf_value['mandatory'] == 1) {
echo 'check_'.$acf_key.'(\'\', \'none\', \'1\');'."\n";
}
}
?>
check_security_code('');
('html, body').animate({scrollTop: ("#acf_area").offset().top - 10}, 500, function() {
acf_check_status();
});
if((".acf_ok").length < total_required_inputs) {
return false;
}
// Hide 'Submit' Button
('#acf_submit_button').hide();
// Show GIF Spinning Rotator
('#acf_ajax_loading').show();
var formData = (this).serialize(); // Serializes a set of input elements into a string data (example: first_name=John&last_name=Doe)
.ajax({
type: "POST",
url: '',
data: formData,
success: function(response) {
('#acf_note').after('
');
var possible_error = 'Could not instantiate mail function.';
if(response.indexOf(possible_error) != '-1') {
var result = '
'+ possible_error +'
';
("#acf_fields").hide();
} else {
var responseObj = JSON.parse(response);
var status = responseObj.status;
//alert(status);
if(status == 0) { // Message sent
var result = '';
('#acf_success_sent').val(1);
("#acf_fields").hide();
('#ajax_contact_form')[0].reset();
(':input:not(:hidden)').removeClass('acf_ok');
}
else if(status == 1) { // Errors found?
var result = '
';
// First, remove all errors to avoid adding the same errors twice in the page
// If any errors are found, the script will change the 'class' value(s) (error)
('div.acf_error').remove();
$acf_value) {
if($acf_value['validation']['checkbox'] == 1 || $acf_value['validation']['radio'] == 1) {
$filterChckRadOne = '';
$filterChckRadTwo = '';
} else {
$filterChckRadOne = ".addClass('acf_error')";
$filterChckRadTwo = ".removeClass('acf_error')";
}
echo "\n\nif(responseObj.".$acf_key."_none) {
".$acf_jquery_prefix."('#".$acf_key."')".$filterChckRadOne.".removeClass('acf_ok');
result += '".$acf_form_fields[$acf_key]['errors']['none']."
';
} else if(responseObj.".$acf_key."_invalid) {
result += '".$acf_form_fields[$acf_key]['errors']['invalid']."
';
} else if(responseObj.".$acf_key."_min_chars) {
result += '".str_replace('[min_chars]', $acf_form_fields[$acf_key]['validation']['min_chars'], $acf_form_fields[$acf_key]['errors']['min_chars'])."
';
} else {
".$acf_jquery_prefix."('#".$acf_key."').addClass('acf_ok')".$filterChckRadTwo.";
}";
}
?>
if(responseObj.security_code == 1) {
('#security_code').addClass('acf_error').removeClass('acf_ok');
result += '
';
} else if(responseObj.security_code == 2) {
('#security_code').addClass('acf_error').removeClass('acf_ok');
result += '
';
} else {
('#acf_main_sec_div').hide();
('#acf_sec_div_one').hide();
('#acf_sec_div_two').show();
('#acf_captcha_div').hide();
('#acf_sc_error').remove();
}
result += '
';
// Mail cannot be sent?
} else if(status == 2) {
var result = '';
("#acf_fields").hide();
}
}
// Hide GIF Spinning Rotator
('#acf_ajax_loading').hide();
// Show 'Submit' Button
('#acf_submit_button').show();
('html, body').animate({scrollTop: ("#acf_area").offset().top - 10}, 500, function() {
('#acf_note').html(result).slideDown();
});
}
});
return false; // prevent the form from being submitted in the classical way
});
function new_captcha()
{
var c_currentTime = new Date();
var c_miliseconds = c_currentTime.getTime();
document.getElementById('acf_captcha').src = 'captcha.php?x='+ c_miliseconds;
return false;
};
('#acf_captcha_refresh').bind('click', new_captcha);
/* [RealTime Validation] */
$acf_value) {
if($acf_value['validation']['checkbox'] == 1) {
$acf_element_selector = '#'.$acf_key.' > div > ul > li > input[type=checkbox]';
} else if($acf_value['validation']['radio'] == 1) {
$acf_element_selector = '#'.$acf_key.' > div > ul > li > input[type=radio]';
} else {
$acf_element_selector = '#'.$acf_key;
}
?>
var check_ = function(event, show_type, is_submit) {
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
var total_selections_selector = ('# option:selected');
var total_valid_selections = total_selections_selector.length;
(total_selections_selector).each(function () {
if($(this).val() == '') { total_valid_selections--; }
});
if(is_submit === undefined) {
if(event.type != 'focusout' && total_valid_selections < ) {
('#').removeClass('acf_ok');
return false;
}
}
var $ = ('');
var total_selections_selector = $.filter(':checked');
var total_valid_selections = total_selections_selector.length;
if(is_submit === undefined) {
if(total_valid_selections < && total_valid_selections > 0) {
('#').removeClass('acf_ok');
return false;
}
}
if(total_valid_selections == 0) {
remove_errors('', 'no_slide');
('#').removeClass('acf_ok');
if(show_type == 'none') {
('#').after('');
} else if(show_type == 'slide') {
('#').after('');
('#_error').slideDown('fast');
}
acf_check_status();
return false;
}
var $ = ('');
if($.filter(':checked').length == 0) {
remove_errors('', 'no_slide');
('#').removeClass('acf_ok');
if(show_type == 'none') {
('#').after('');
} else if(show_type == 'slide') {
('#').after('');
('#_error').slideDown('fast');
}
acf_check_status();
return false;
}
0 && isSet($acf_value['attributes']['multiple'])) {
$min_selections = $acf_value['validation']['min_selections'];
?>
if(total_valid_selections < ) {
remove_errors('', 'no_slide');
('#').removeClass('acf_ok').addClass('acf_error');
if(show_type == 'none') {
('#').after('');
} else if(show_type == 'slide') {
('#').after('');
('#_error').slideDown('fast');
}
acf_check_status();
return false;
}
if() {
remove_errors('', 'no_slide');
('#').addClass('acf_error').removeClass('acf_ok');
if(show_type == 'none') {
('#').after('');
} else if(show_type == 'slide') {
('#').after('');
('#_error').slideDown('fast');
}
acf_check_status();
return false;
}
if (!filter.test(('').val())) {
('#').addClass('acf_error').removeClass('acf_ok');
remove_errors('', 'no_slide');
if(show_type == 'none') {
('#').after('');
} else if(show_type == 'slide') {
('#').after('');
('#_error_invalid').slideDown('fast');
}
acf_check_status();
return false;
}
0) {
$min_chars = $acf_value['validation']['min_chars'];
?>
if (('').val().length < ) { // if the message's legth is less than 15 characters
remove_errors('', 'no_slide');
('#').addClass('acf_error').removeClass('acf_ok');
if(show_type == 'none') {
('#').after('');
} else if(show_type == 'slide') {
('#').after('');
('#_error_min_chars').slideDown('fast');
}
acf_check_status();
return false;
}
else {
remove_errors('');
('#').removeClass('acf_error').addClass('acf_ok');
acf_check_status();
}
};
('#').bind('change focusout', function(event) {
check_(event, '');
acf_check_status();
});
('#').bind('blur', function(event) {
if(('#').val()) {
check_(event, '');
}
acf_check_status();
});
/*
-----------------
Security Code
-----------------
*/
var check_security_code = function(show_type) {
if (('#acf_captcha_div').is(':visible')) {
('#acf_sc_error').remove();
if(('#security_code').val() == '') {
('#security_code').addClass('acf_error').removeClass('acf_ok');
if(show_type == 'none') {
('#acf_sec_div_one').after('');
} else if(show_type == 'slide') {
('#acf_sec_div_one').after('');
('#acf_sc_error').slideDown('fast');
}
acf_check_status();
} else {
var c_currentTime = new Date();
var c_miliseconds = c_currentTime.getTime();
var validCode = ('#security_code').val();
/* [Start] AJAX Call */
.ajax({ url: 'verify-code.php?x='+ c_miliseconds,
data: "security_code="+ validCode,
type: 'post',
datatype: 'html',
success: function(outData) {
if(outData != 1) {
if(("#acf_sc_error.acf_error").length == 0) {
('#security_code').addClass('acf_error').removeClass('acf_ok');
if(show_type == 'none') {
('#acf_sec_div_one').after('');
} else if(show_type == 'slide') {
('#acf_sec_div_one').after('');
('#acf_sc_error').slideDown('fast');
}
acf_check_status();
}
} else {
('#security_code').remove();
('#acf_sec_div_one').hide();
('#acf_captcha_div').hide();
('#acf_main_sec_div').hide();
('#acf_sec_div_two').fadeIn('fast', function() {
('#acf_submit_button').before('');
});
}
},
error: function(errorMsg) { alert('Error occured: ' + errorMsg); }});
/* [End] AJAX Call */
}
}
};
var checkSecurityCodeLive = function() {
var c_currentTime = new Date();
var c_miliseconds = c_currentTime.getTime();
var validCode = ('#security_code').val();
/* [Start] AJAX Call */
.ajax({ url: 'verify-code.php?x='+ c_miliseconds,
data: "security_code="+ validCode,
type: 'post',
datatype: 'html',
success: function(outData) {
if(outData == 1) {
('#acf_sc_error').remove();
('#security_code').remove();
('#acf_sec_div_one').hide();
('#acf_captcha_div').hide();
('#acf_main_sec_div').hide();
('#acf_sec_div_two').fadeIn('fast', function() {
('#acf_submit_button').before('');
});
('div').removeClass("acf_highlighted");
acf_check_status();
}
},
error: function(errorMsg) { alert('Error occured: ' + errorMsg); }});
/* [End] AJAX Call */
};
var checkSecurityCodeIfNotNULL = function() {
if(('#security_code').val()) { check_security_code(''); }
};
('#security_code').change(function() { check_security_code(''); });
('#security_code').blur(checkSecurityCodeIfNotNULL);
('#security_code').keyup(checkSecurityCodeLive);
(':input.required').bind('change blur keyup', acf_check_status);
function acf_check_status() {
// Necessary if the form was reseted
if(('#acf_success_sent').val() == 1) {
('#acf_note').slideUp('slow');
('#acf_note').html('');
('#acf_success_sent').val(0);
return true;
}
if(("div.acf_error").length > 0) {
// Show the top notice error
('#acf_note').html('').slideDown('slow')show();
}
if(("div.acf_error").length == 0) {
('#acf_note').slideUp('slow')hide(); // Hide the top notice error using a 'slide' effect (if necessary)
}
return true;
};
function remove_errors(keyField, mode) {
if(mode == 'no_slide') {
('div[id^="'+ keyField +'_error"]').remove();
} else {
('div[id^="'+ keyField +'_error"]').slideUp('fast', function() { (this).remove(); });remove();
}
}
$acf_value) {
if($acf_key == 'security_code') {
?>
('#security_code').focusin(function() { (this).parent('div').parent('div').parent('div').addClass("acf_highlighted"); }).focusout(function() { (this).parent('div').parent('div').parent('div').removeClass("acf_highlighted"); });
('#').focusin(function() { ('#').parent('div').addClass("acf_highlighted"); }).focusout(function() { (this).parent('div').removeClass("acf_highlighted"); });
('#').focusin(function() { (this).parent('div').parent('div').addClass("acf_highlighted"); }).focusout(function() { (this).parent('div').parent('div').removeClass("acf_highlighted"); });
// Show the 'Refresh' Icon: This will work if JavaScript is enabled!
('#acf_captcha_refresh').show();
});