function reloadCaptcha() {
if (jQuery('#frm_siimage').length > 0) {
jQuery('#frm_siimage').attr('src', 'http://delasacompany.com/captcha/?sid=' + Math.random());
jQuery('#reg_capthca').attr('value','');
}
}
function showfinalmessage(msg) {
jQuery("#form_container").html('
'+msg+'
');
jQuery('html, body').animate({
scrollTop: jQuery("#form_container").offset().top-50
}, 500);
}
function beforeCall(form, options){
if (window.console)
console.log("Right before the AJAX form validation call");
jQuery("#jNotifywaiting").showwaiting();
return true;
}
// Called once the server replies to the ajax form validation request
function ajaxValidationCallback(status, form, json, options){
if (window.console)
console.log(status);
if (status === true) {
var formData = new FormData(jQuery("#freg_4f23f337dbcb2bc645f84cabdd243570")[0]);
jQuery.ajax({
type: "POST",
url: "http://delasacompany.com/configform.php?act=post",
data: formData, // serializes the form's elements.
async: false,
dataType: 'json',
success: function(data) {
jQuery("#jNotifywaiting").hidewaiting();
if (data.success==true) {
jSuccess(data.msg1, {
autoHide : false, // added in v2.0
clickOverlay : true, // added in v2.0
MinWidth : 250,
TimeShown : 3000,
ShowTimeEffect : 200,
HideTimeEffect : 200,
LongTrip :20,
HorizontalPosition : 'center',
VerticalPosition : 'center',
ShowOverlay : true,
ColorOverlay : '#000',
OpacityOverlay : 0.3,
onClosed : function(){
if (data.redirect==true) {
window.location.replace(data.redirecturl);
} else {
showfinalmessage(data.msg2);
}
},
onCompleted : function(){}
});
} else {
jError(data.msg1,{
autoHide : false, // added in v2.0
clickOverlay : true, // added in v2.0
MinWidth : 250,
TimeShown : 3000,
ShowTimeEffect : 200,
HideTimeEffect : 200,
LongTrip :20,
HorizontalPosition : 'center',
VerticalPosition : 'center',
ShowOverlay : true,
ColorOverlay : '#000',
OpacityOverlay : 0.3,
onClosed : function(){reloadCaptcha();},
onCompleted : function(){}
});
}
},
cache: false,
contentType: false,
processData: false
});
} else {
jQuery("#jNotifywaiting").hidewaiting();
reloadCaptcha();
}
}
jQuery(document).ready(function ($) {
$("#freg_4f23f337dbcb2bc645f84cabdd243570").bind("jqv.form.result", function(event, errorFound) {
if(errorFound) reloadCaptcha();
})
// jqv.form.validating : Triggers when the form is submitted and before it starts the validation process
//jqv.field.result(event, field, errorFound, prompText) : Triggers when a field is validated with the result.
//jqv.form.result(event, errorFound) : Trigger when a form is validated with the result
$("#freg_4f23f337dbcb2bc645f84cabdd243570").validationEngine('attach', {
promptPosition: 'topRight',
ajaxFormValidation: true,
onBeforeAjaxFormValidation: beforeCall,
onAjaxFormComplete: ajaxValidationCallback,
ajaxFormValidationMethod: 'post'
});
});
(function( $ ){
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
return this;
}
jQuery.fn.showwaiting = function() {
jQuery("#jOverlaywaiting").show();
this.center();
this.show();
}
jQuery.fn.hidewaiting = function() {
jQuery("#jOverlaywaiting").hide();
this.hide();
}
})( jQuery );