var isExtended = 0;
var height = 445;
var width = 500;
var slideDuration = 1000;
var opacityDuration = 1500;

function extendContract(){

	if(isExtended == 0){
		sideBarSlide(0, height, 0, width);
		sideBarOpacity(0, 1);
		isExtended = 1;
		// make expand tab arrow image face left (inwards)
		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/(\.[^.]+)$/, '-active$1');
	}
	else{
		sideBarSlide(height, 0, width, 0);
		sideBarOpacity(1, 0);
		isExtended = 0;
		// make expand tab arrow image face right (outwards)
		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/-active(\.[^.]+)$/, '$1');
	}

}

function sideBarSlide(fromHeight, toHeight, fromWidth, toWidth) {
	$("sideBarContents").css ({'height': fromHeight, 'width': fromWidth});
	$("#sideBarContents").animate( { 'height': toHeight, 'width': toWidth }, { 'queue': false, 'duration': slideDuration }, "linear" );
}

function sideBarOpacity(from, to){
	$("#sideBarContents").animate( { 'opacity': to }, opacityDuration, "linear" );
}


$(function(){
  // Document is ready
	$('#sideBarTab').click( function() { extendContract(); return false; });
	
});
