$(document).ready(function() {

	/*$('div#slideshow').css("background-image", "none");
	// from: http://jquery.malsup.com/cycle/
	$('#slides img:first').fadeIn(2000, function() {
		$('#slides').cycle({
			fx: 'fade'
		})
    });*/
	
	$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=67751060@N04&lang=en-us&format=json&jsoncallback=?", function(data){
		$.each(data.items, function(i,item){
			$("<img/>").attr("src", item.media.m).appendTo("#images")
			.wrap('<a href="' + item.link + '" title="View full sized photo on Flickr"></a>');
		});
		
		//$("#title").html(data.title);
		//$("#description").html(data.description);
		$("#link").html('<a href="'+data.link+'" target="_blank" title="Visit the Tavistock Roundtable Flickr account: roundtable661"><img src="/images/trt-on-flickr.png" alt="roundtable661" width="162" height="40" /></a>');
		//Notice that the object here is "data" because that information sits outside of "items" in the JSON feed
		
		$('#images').cycle({
			fx:     'fade',
			speed:    5000,
			timeout:  100
		});
	});
	
	if(window.show_noticeboard === undefined) {show_noticeboard = false;} // from: http://quomon.com/question-how-to-check-if-a-javascript-variable-is-defined-891.aspx
	if(show_noticeboard) {
		height = '100px';
    	width = '250px';
		$.colorbox({href:"/functions/notices.asp", innerHeight: height, innerWidth: width, scrolling: false, iframe: true, top: '-7px', close: '<img src="/images/colorbox-close-button.png" alt="close" title="close" width="18" height="18" />', title: 'Latest announcements'});
		$('#cboxOverlay').hide(); //{ display:none !important; }
	}/**/

	$('a img').hover(
		function() {
			$(this).stop(true, true).fadeTo( 100, 0.5 );
		},
		function(){
			$(this).stop(true, true).fadeTo( 100, 1.0 );
		}
	);

	$('tr, .bulletlist li').hover(
		function() {
			$(this).stop(true, true).css( "backgroundColor", "#111" );
		},
		function(){
			$(this).stop(true, true).css( "backgroundColor", "" );
		}
	);

	// not used
	var TabbedContent = {
		init: function() {	
			$(".tab_item").mouseover(function() {
				$(".tab_item").css({color: '#FFF'});
			
				var background = $(this).parent().find(".moving_bg");
				
				$(background).stop(true, true).animate({
					left: $(this).position()['left']
				}, {
					duration: 500
				});
				TabbedContent.slideContent($(this));
				$(this).css({textDecoration: 'underline'});			
			});
			$(".tab_item").mouseleave(function() {
				$(this).css({textDecoration: 'none'});			
			});
		},
		
		slideContent: function(obj) {
			
			var margin = $(obj).parent().parent().find(".slide_content").width();
			margin = margin * ($(obj).prevAll().size() - 1);
			margin = margin * -1;
			
			$(obj).parent().parent().find(".tabslider").stop().animate({
				marginLeft: margin + "px"
			}, {
				duration: 500
			});
		}
	}
	TabbedContent.init();
	
	$(".colorboxmap").colorbox({width:"70%", height: "80%", iframe:true, close: '<img src="/images/colorbox-close-button.png" alt="close" title="close" width="18" height="18" />', opacity: 0.7, fixed: false});
	// $("#fb_menu").colorbox({width:"90%", height: "90%", iframe:true, close: '<img src="/images/colorbox-close-button.png" alt="close" title="close" width="18" height="18" />', opacity: 0.7, fixed: false});
	
});
