/* ----------------------------------------------------------
	title		  : DCC Framework
	created		  : 9/29/09
	last updated  : 11/5/09
---------------------------------------------------------- */
jQuery.noConflict();     
jQuery(document).ready(function($){




/* Image Rotator */
function buildPager(ind, slide) {
	
	ind++;
	var tabTitle = $('.container', slide).remove().text();
	
	if (tabTitle.replace(/\s/g,'') == '') { tabTitle = 'slide ' + ind }
	
	return '<li class="tab-'+ ind +'"><a href="#">' + tabTitle + '</a></li>';
	
}



function rotateMagic() {
	if ( $('#feature').length ) {
	
	
	if ( $('#adminbar #toolbar').length ) {} else {
		$('.f-slide').each(function(){
	
		var tabContent = $(this).text();
		if (tabContent.replace(/\s/g,'') == '') { $(this).remove(); }
	});
}
	
	
	$('#feature').append('<ul id="feature-controls"></ul>');
	
		$('#feature-contents').cycle({
		fx: 'fade',
		speed: 'slow',
		timeout: 5000,
		pause: 1,
		pager: '#feature-controls',
		pagerAnchorBuilder: buildPager,
		startingSlide: 0
		});
	
	}

}



rotateMagic();



/* Slider */
var isSlideShowing = false;
var timeAndLocPath = $('#t-l a').attr('href');
var alreadyRun = false;

$('#t-l a').click(function(){
	
	if (isSlideShowing) {
		
		$('#top-bar-wrap').slideUp();
		isSlideShowing = false;
		
		} else {
		
		if (!alreadyRun) {
		
			$.ajax({
			type: "GET",
			url: timeAndLocPath,
			dataType: "html",
			success: function(html) {
				$('#content-main',html).contents().appendTo('#top-bar');
				alreadyRun = true;			
			},
			error: function() {
				$('#top-bar').append('<div class="ajax-error"><h2>Hmmm... there seems to be a problem</h2> <p>Sorry about that. Try, <a href="'+ timeAndLocPath +'">visiting our time and location page</a>.</p></div>');
				alreadyRun = true;
			}
			});
		
		}
		
		$('#top-bar-wrap').slideDown();
		isSlideShowing = true;
			
		}
	return false;
	}); 


 



});//end doc ready
