(function($) {
    var cache = [];
    // Arguments are image paths relative to the current page.
    $.preLoadImages = function() {
        var args_len = arguments.length;
        for (var i = args_len; i--;) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
})(jQuery)
function postForm() {
    $("#contactForm fieldset").fadeOut(1000, stage2);
}
function stage2() {
    $("#contactForm div.formContainer").append('<br /><div id="loading"><img src="/images/misc/ajax-loader.gif" alt="Loading" id="loading" /><br /><br /><p>Loading...</p></div>')
    .delay(1000).fadeOut(500, stage3);
}
function stage3() {
    $.post("/process.php?js=1", $("#contactForm").serialize(), function() {
        success: $("#contactForm div.formContainer").html("<br /><h4>Thank you. <br /><span>We'll be in touch shortly...</span></h4>").fadeIn(1000);
    });
}
$(document).ready(function() {
       $("#client-login").fancybox({
           'titlePosition'          : 'inside',
           'autoScale'              : true,
           'transitionIn'           : 'none',
           'transitionOut'          : 'fade'
       });
    $("#status1").fancybox({
        'titlePosition'		: 'inside',
        'autoScale'             : true,
        'transitionIn'		: 'none',
        'transitionOut'		: 'fade'
    });
    jQuery.preLoadImages("/images/misc/ajax-loader.gif");
    $("#contactForm").validate({
        submitHandler: function() {
            postForm();
        }
    });
});

