/* IT&T SIG namespace - Gotta Keep 'em Separated */
var ITTSIG = {
		
	showVideos: function (qty, headingHtml) {
		var albumId = '114160', // the id of the album we're pulling videos from.
			url = 'http://www.vimeo.com/api/v2/album/' + albumId + '/videos.json?callback=?',
			i; // iterator			
								
		$.getJSON(url, function(videos){								
			if (videos.length >= 1) {
				$('#vimeo_widget').addClass('filled').prepend(headingHtml);
				for (i = 0; i < qty; i += 1) {			 			
 					$('#vimeo_widget').append('<div><p>'+ videos[i].title +'</p><a href="http://vimeo.com/moogaloop.swf" rel="shadowbox;width=' + videos[i].width + ';height=' + videos[i].height +';options={flashVars:{clip_id:' + videos[i].id + ',autoplay:\'true\'}}"><img alt="'+ videos[i].title +'" src="' + videos[i].thumbnail_medium + '" /></a></div>');	
				}																			
			}			
		});
		
		$('#vimeo_widget a:not("h2 a")').live('click', function(event) {
			Shadowbox.open(this);
			return false;
		});		
	}, 	
	
	addLastChild: function () {
		jQuery('#navigation_global, #navigation_primary, #navigation_secondary, #navigation_footer, #flickr_widget').children(':last-child').addClass('last-child');
	},
	
	createHistoryLink: function () {
		if (jQuery('body').hasClass('people_section')) {
			jQuery('h1').before('<p id="history_return">&larr; <a href="/">Return to Previous Page</a></p>');
			jQuery('#history_return').click(function (e) {
				e.preventDefault();
				history.back();
			});
		}
	},
	
	init: function () {		
		this.addLastChild();
		this.createHistoryLink();

		$('a.flickr').each(function() {
			var newHref = $(this).attr('href').replace(/_s.jpg/, '.jpg');
			$(this).attr('href', newHref);
		});
		
	}
};

jQuery(document).ready(function () {
	ITTSIG.init();
});
