/*jshint asi: false, bitwise: true, boss: false, curly: true, debug: false, devel: false, eqeqeq: true, evil: false, forin: true, immed: true, laxbreak: false, newcap: true, noarg: true, noempty: true, nonew: true, nomen: true, onevar: true, plusplus: true, regexp: false, undef: true, sub: false, strict: true, white: false*/
/*global jQuery, console, baseUrl, window */
(function ($) {	
	"use strict";
	
	if (!window.validation) {
		alert("plugin.ajaxform.js moet worden ingeladen na plugion.validation.js!");
	}
	
	$("form.ajax").unbind("submit").submit(function ( ) {
		var $this	=	$(this);
		
		validation.apply(this, [function ( ) {
			var $container;
			
			$this.hide();
			
			$container	=	$([
				'<div style="width: ' + $this.width() + 'px; height: ' + $this.height() + 'px; " class="overlay">',
				'</div>'
			].join(""))
			
			$.ajax({
				"url":		$this.attr("action"),
				"type":		$this.attr("method").toUpperCase(),
				"data":		$this.serialize(),
				"dataType":	"html",
				"success":	function (data) {
					$container.html(data).insertAfter($this);
				}
			});
		}]);
		
		return false;
	});
}(jQuery));

