function animateContainerHeight(height){
	$j("#ajax_main_container").animate({'height':height+'px'}, 'fast');
}

function setContainerHeight(){
	newHeight = $j("#ajax_content_height").height();
	animateContainerHeight(newHeight);
}

function setPageTitle(){
	if(typeof(pageTitle) != 'undefined'){
		document.title = pageTitle;
	}
}

function loadAjaxContentCallback(response, status){
	$j("#ajax_content_height").fadeIn('slow');
	setActiveNav($j.passedURL);
	initMP3Player();
	setContainerHeight();
	initVolumeDetailCallback();
	initImageLoadCallback();
	initAjaxPagination();
	initAlphnumericPaging();
	initNumericPaging();
	initBodySearchField();
	initFaq();
	initWorksList();
	initAddToCartLinks();
	initPreviewPlayers();
	setPageTitle();
	initScrollbars();
	initImagePreview();
	initLyricButtons();
	initSearchResultRadios();
	setBackButtonURL();
	adjustBodyImagePadding();
	hideLoader();
	
	/*if(typeof(_uacct) != 'undefined'){
		urchinTracker();
	}*/
}

function loadAjaxContent(url){
	if (url.charAt(0) != "/") return false;
	$j.passedURL = url;
	showLoader();
	var targetDiv = '#works_ajax_content';
	currentHeight = parseInt(document.getElementById('ajax_main_container').offsetHeight);
	cssHeight = $j("#ajax_main_container").height();
	/*$j("#ajax_main_container").css({'overflow':'hidden'});*/
	$j("#ajax_main_container").css({'height':cssHeight});
	$j("#ajax_content_height").fadeOut('fast');
	$j("#ajax_main_container").load(url, null, loadAjaxContentCallback);
}

function setBackButtonURL(){
	if(typeof(fullWorkDetails) != 'undefined' && fullWorkDetails == true){
		$j('#dynamic_back_btn').css({'display':'none'});
		appendURL = '/full';
		startURL = $j('#back_to_work_link').attr('href') 
		$j('#back_to_work_link').attr('href', startURL+appendURL);
		$j('#back_to_work_link').html('Back to Work Overview');
		return;
	}
	$j('#dynamic_back_btn').click(function(event){
										event.preventDefault();
										
										curResults = $j('.results_toggle:checked').val();
										if(typeof(curResults) != 'undefined'){
											window.location.href='#'+curResults;
											return;
										}
										mySelectedNav = $j('#navMenu_container li.active a');
										url = mySelectedNav.attr('href');
										if(url == '#'){
											mySelectedNav = $j('#navMenu_container li ul li.active a');
										}
										mySelectedNav.trigger('click');
									})
}
