var ShowMorePhoto = {
	
	minHeight:400,
	maxHeight:400,
	expanded:false,
	
	initialize: function () {
		var _self = this;
		this.body = $('body');
		this.win = $(window);
		this.doc = $(document);
		this.header = $('#headerWrapper');
		this.cta=$('#heroCta');
		this.hero = $('.empty');

		$('.athleteShowPhoto').click (function () {

			if ( _self.expanded ) {
				_self.close();
				_self.update();
				_self.expanded=false;
			} else {
				_self.expand();
				_self.update();
				_self.expanded=true;
			}
		});
		
	},

	reposition: function () {

	},

	expand: function () {
		var _self = this;
		var html = 'Show less photo';
		$('.athleteShowPhoto span:not(:last)').html(html);
		$('.athleteShowPhoto').addClass('expanded');

		var scroll = Number($(window).scrollTop());
		var initHeight = this.win.height() - this.cta.outerHeight(true) - this.header.outerHeight(true) - 31;


		// initHeight += scroll;
		_self.expanded = true;


		// the height of the invisible div is expanded pushing conetent down,
		// making the background image expand
		_self.hero.animate({height:initHeight}, 1000, 'easeInOutExpo');
		
		// scroll page to the top, fixes show less button from dropping off the page
		$('html, body').animate({scrollTop: 0}, 1000, 'easeInOutExpo');

		// changes the display of the arrow icon when expanded
		$('.athleteShowPhoto span').last().removeClass('arrow').addClass('arrowUp');

	},
	
	close: function () {
		var _self = this;
		var html = 'Show more photo';
		var invisibleHeight = 65;
		$('.athleteShowPhoto span:not(:last)').html(html);
		$('.athleteShowPhoto').removeClass('expanded');

		_self.expanded = false;

		// check to see if we're on the athlete page
		if($('body').hasClass('athlete')) {
			invisibleHeight = 0
		}
		
		// the height of the invisible div is collapsed pulling conetent up,
		// making the background image close
		_self.hero.animate({height:invisibleHeight}, 1000, 'easeInOutExpo');

		$('html, body').animate({scrollTop: 0}, 1000, 'easeInOutExpo');

		// changes the display of the arrow icon when closed
		$('.athleteShowPhoto span').last().removeClass('arrowUp').addClass('arrow');
	},

	update: function () {
		Cufon.replace('.helvetica');
	}

};
$(function(){
		ShowMorePhoto.initialize();
	});

