jQuery.fn.extend({
  replace: function(str) {
    return this.empty().append(str);
  }
});
$(function() {
	$('a').click(function(e){
		e.preventDefault(); 
		progressWindow('div#content');
		$.ajax({ type: "POST", url: $(this).attr('href'), data: "templateFile=ajax&content_type=text/xml", dataType: "xml",
		success: function(hxml){	
			closeProgressWindow();		
			document.title = jQuery('title', hxml).text();
			$('div#content').hide(1500);
			$('<div id="newContent">' + $('content', hxml).text() + '</div>').hide().insertBefore('div#content').show(1500, function(){
				$(this).parent().empty().append('<div id="content">' + $('content', hxml).text() + '</div>');
			});
		}});		
	});
});
function addslashes(str) { return str.replace(/\\/g,'\\\\'); }
function stripslashes(str) { return str.replace(/\\\\/g,'\\'); }
function progressWindow(str){
	if($(str).css('position') == 'static')	
		$(str).attr("style", "position:relative");
		
	$('<img id="progWin" src="gfx/progress.gif" alt=""/>').css({display: "block", top: (($(str).height()-$('#progWin').height())/2), left: (($(str).width()-$('#progWin').width())/2)}).appendTo(str);
}
function closeProgressWindow(){ $('#progWin').remove(); }

