jQuery.fn.WG_Ajax = function(ajax_url) {
  // 'this' is a jQuery object at this point - with all the jQuery functions

  return this.each(function() {
  	// return so we don't break the chain
    // now we are inside of a jQuery function, the DOM element is the context
    // so 'this' has changed to become a DOM element.
    html_elem = this;
 	var path_loading_image = '/gfx/loading.gif';
	if(((jQuery(html_elem)).is('*')) && (ajax_url != ""))
	{
		jQuery.ajax({
		  type: "GET",
		  async: false,
		  timeout:0.1,
		  url: ajax_url,
			beforeSend: function(){
				//Create loading image
				var loadingImage = jQuery('<div/>').attr('class','ajax_container').attr('style', 'text-align:center;margin-top:0px;margin-bottom:0px;padding:10px 0px 10px 0px;width:100%;').append(jQuery('<img/>').attr('src', path_loading_image).attr('id', 'LoadingImage'));
				jQuery(html_elem).html(loadingImage);
			},
			success: function(data){
				jQuery(html_elem).html(data);
			},
			error: function(){
				jQuery('div.ajax_container').html("Error. Probeer u het later nog eens.");
			},
			complete: function(){

			}
		})
	}
  });
};