function slidePanel(from, to, direction) {
	$('#' + from).animate({left:'-320px'}, 'slow', function() {
		window.scrollTo(0, 1);
	});
	$('#' + to).css({left:'320px'}).show().animate({left:'0px'}, 'slow', function() {
		window.scrollTo(0, 1);
	});
}

function slidePanelAJAX(from, to, direction) {
	
}
/*
function tabLoadAJAX(from, to, url, paramObj) {
	alert('woot!');
	var source = document.getElementById(from);
	if(document.getElementById(to)) {
		var dest = document.getElementById(to);
	} else {
		var dest = source.cloneNode(false);
		dest.id = to;
		dest.style.display = 'none';
		source.parentNode.insertBefore(dest, source.nextSibling);
	}
	source.style.display = 'none';
	dest.style.display = 'block';
	dest.appendChild(document.createTextNode('woot!'));
}
*/


function tabLoadAJAX(from, to, url, paramObj) {
	var source = $('#' + from);
	var dest = $('#' + to).length > 0 ? $('#' + to) : source.clone(true).empty().attr('id',to).css('display','none').insertAfter(source);
	// make/find loading indicator
	if($('#waiting').length == 0) {
		var waiting = source.clone(true).empty().attr('id','waiting').insertAfter(source).css('display','none').css('text-align','center');
		waiting.append($(document.createElement('img')).attr('src','/images/loading_mid.gif').css('padding','50px'));
	} else {
		var waiting = $('#waiting');
	}
	// animate from source to loading indicator
	source.parent().css('height',source.parent().height());
	source.fadeOut('fast', function() {
		if(dest.contents().length == 0) {
			$(this).parent().animate({ height: waiting.outerHeight() }, 'fast', function() {
				waiting.fadeIn('fast', function() {
					// start loading new tab and animate when done
					dest.load(url, paramObj, function() {
						waiting.parent().css('height',waiting.parent().height());
						waiting.fadeOut('fast', function() {
							$(this).parent().animate({ height: dest.outerHeight() }, 'fast', function() {
								dest.fadeIn('slow');
							});
						});
					});
				});
			});
		} else {
			$(this).parent().animate({ height: dest.innerHeight() }, 'fast', function() {
				dest.fadeIn('fast');
			});
		}
	});
}
