/*Custom scripting for FG.com. Depends on the jQuery library */


/*DOM READY*/
enhancedDomReady(function(){
	
	//set up slideshows
	$('body#home ul.slideShow').fgSlideShow({controls: false, timer: 5000, startDelay: 0});

	$('body').not('body#home').find('ul.slideShow').fgSlideShow({controls: false, timer: 2000});

	$('#labFeature').equalHeights().fgSlideShow({controls: false, timer: 6000, items: 'div.labFeatureItem'});
//if twitter fails
var twitterFail = '<h3 class="tweet_relative_date">Currently...</h3><p class="tweet_text">Twitter is not responding at the moment. To see our latest updates, please visit <a href="http://twitter.com/filamentgroup/">our feed</a> on Twitter.</p>';
if( $('#labTwitter p').size() == 0 ){$('#labTwitter').append(twitterFail);}
if( $('#twitterUpdate p').size() == 1 ){$('#twitterUpdate').prepend(twitterFail);}
	//set up iframed content for inline viewing (for lab)
	var eventType = 'load';
	if($.browser.opera) eventType = 'ready';
	$('iframe').not('[src^=http://digg.com]')[eventType](function(){	
		  var frameBody = $(this).contents().find('body');
$(this).contents().find('script[src*=/mint/]').remove();
		  frameBody.css('margin', 0).find('#demoHeader').remove();
		  /*$(this).height((frameBody.height() + 30).pxToEm());*/
		  $(this).after('<p class="iframeSourceLink"><a href="'+ $(this).attr('src') +'" class="external">View this example in a new window</a></p>');
		  $(this).next().find('a.external').newWindow();
	});

	$('.example_left, .example_right').each(function(){
		var childWidth = $(this).find(':first-child').width();
		$(this).width(childWidth);
	});

	// contact button drop shadow
	$('#contact a').textDropShadow();

	// contact hover
	$('div#contact').hover(
		function(){$(this).addClass('contactHover');}, 
		function(){$(this).removeClass('contactHover');}
	);

	// primary nav hover
	$('#primaryNavigation li').hover(
		function(){$(this).addClass('hover');}, 
		function(){$(this).removeClass('hover');}
	);

	//png fix for IE
	$('#header').pngFix();

	//404 back link
	$('a#goBack').click(function(){
		history.go(-1);
		return false;
	});

$('#whatwerethinking #labArticles').equalHeights();

	//new window links
	$('a.external').newWindow();

});  // End DOM ready fn