$(document).ready(function(){

	/*
		EVENTS PAGE:
		all items display event name and date
		only, when they click "read more" it
		expands the parent div and displays the
		inline content.
	*/
	//read more button
	$('a.event-read-more').click(function(e) {
		e.preventDefault();
		$(this).parents('div:eq(1)').animate({ "height" : '400px'}, 1000);
		$(this).fadeOut(200);
		$('a.event-read-less').fadeIn(200);
	});
	
	//read less
	$('a.event-read-less').click(function(e) {
		e.preventDefault();
		$(this).parents('div:eq(1)').animate({ "height" : '80px'}, 800);
		$(this).fadeOut(200);
		$('a.event-read-more').fadeIn(200);
	});
	
	
	/*
		HOMEPAGE SCROLLING BANNER:
	*/
	
	
	//add listeners
$('a#arrow-right').click(scroll);
$('a#arrow-left').click(scroll);
	
//called on scroll click
/*function scroll(e) {
	
	//vars
	var w = 955;
	pages = 6;
	if (!(scroll.pos >= 0)) scroll.pos = 0;
	var prev_pos = scroll.pos;


	//pick direction
	var dir = 0;
	if ($(e.target).parent().hasClass('right-arrow-cl'))  {
		scroll.pos++;
		if (scroll.pos > pages - 1) scroll.pos = 0;
		dir = 1;
	} else if ($(e.target).parent().hasClass('left-arrow-cl'))  {
		scroll.pos--;
		if (scroll.pos < 0) scroll.pos = pages-1;
		dir = -1;
	}
		
	//reorganize slides.  if the offsets change because of moving shit around, move slides to accomodate
	var x1 = $(".slide_"+prev_pos).position().left;
	if (dir == 1) $(".slide_"+scroll.pos).insertAfter(".slide_"+prev_pos);
	else if (dir == -1) $(".slide_"+scroll.pos).insertBefore(".slide_"+prev_pos);
	var x2 = $(".slide_"+prev_pos).position().left;
	$("#scroll_container").animate({'left': '+='+(x1-x2)+'px'}, 0);
	
	//scroll
	move = (dir == 1 ? '-=' : '+=')+w+'px';
	$("#scroll_container").animate({'left': move}, 500);
	
}

	var count = 0;
	
	window.setTimeout(function() {
		scroll(1);
	}, 1000);

	*/
	

  var currentPosition = 0;
  var slideWidth = 955;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
      currentPosition = ($(this).attr('id')=='ba-right')
    ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(currentPosition);
      // Move slideInner using margin-left
      $('#scroll_container').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      });
    });

  // manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#ba-left').hide() }
    else{ $('#ba-left').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#ba-right').hide() }
    else{ $('#ba-right').show() }
    }



});



