// Not strictly a package, but it does the job
pkg('website.getGoing');

$(document).ready(function() {

	/*
		handle vimeo embeds
	*/

	website.getGoing.rowTop = (function() {

		// Check if vimeo element is present. If not, quit.
		if($('#getGoing-rowTop > .rowContent > .mediaViewer > .media > .video').length == 0)
			return;

		var pub = {};

		var vimeoId = $('#getGoing-rowTop > .rowContent > .mediaViewer > .media > .video').attr('vimeoId');


		/*
			constructor
		*/

		init = function() {

			// bind eventHandlers
			setEventHandlers();

		}

		/*
			private methods
		*/

		var setEventHandlers = function() {
			$('#getGoing-rowTop > .rowContent > .mediaViewer > .media > .video > .play-overlay').bind('click', function() {

				showVimeo();
			});
		}


		var showVimeo = function() {

			// remove the play button overlay
			$('#getGoing-rowTop > .rowContent > .mediaViewer > .media > .video > .play-overlay').css('display', 'none');

		 	// insert the vimeo iframe
			$('#getGoing-rowTop > .rowContent > .mediaViewer > .media > .video').html('<iframe src="http://player.vimeo.com/video/'+vimeoId+'?color=00ab4e&title=0&amp;byline=0&amp;portrait=0&amp;autoplay=1&amp;loop=1" width="559" height="314" frameborder="0" style="display: block; background-color: #000;"></iframe>');

		};

		/*
			public methods
		*/


		// call constructor
		init();

		// expose public methods / objects
		return pub;

	})();

});
