/* --------------------------------------------
EXTERNAL LINKS
---------------------------------------------*/
$(document).ready(function() {
	$('div.link-text p a').attr('target', '_blank');
});

/* --------------------------------------------
SUPERSIZED
---------------------------------------------*/
$(function(){
	$.fn.supersized.options = {  
		startwidth: 1200,  
		startheight: 648,
		minsize: .50,
		slideshow: 0
	};
	$('#supersize').supersized(); 
});

jQuery(document).ready(function(){
	// define a mouseover behaviour
	jQuery('div.project-teaser').hover(function(){
		// add hover class on mousein
		jQuery(this).addClass('hover');
	},function(){
		// remove hover class on mouseout
		jQuery(this).removeClass('hover');
	});
});


/* --------------------------------------------
TOGGLE BLOCKS
---------------------------------------------*/
jQuery(document).ready(function(){
	

	// define a mouseover behaviour
	jQuery('table.toggle-section tbody tr').hover(function(){
		// add hover class on mousein
		jQuery(this).addClass('hover');
	},function(){
		// remove hover class on mouseout
		jQuery(this).removeClass('hover');
	});	



	// store all toggle-tables in an array 'tables'
	var tables = jQuery('table.toggle-section');
	
	// loop through all the tables
	tables.each(function(){
		// store the current table in 'table'
		var table = jQuery(this);
		
		// quickly hide all the .toggle-text blocks
		jQuery(this).find('.toggle-text').css({'display':'none'});
		
		// store all rows in a 'rows' array
		var rows = table.find('tbody tr');
				
		// loops through all the rows
		rows.each(function(){
			// store row in variable 'row'
			var row = jQuery(this);
			
			// store a link to the first td in variable 'firstTD'
			var firstTD = row.find('td:eq(0)');
			// store a link to the second td in variable 'secondTD'
			var secondTD = row.find('td:eq(1)');
			
			// make it look like a link
			row.css({'cursor':'pointer'});
			
			// store a link to the toggle text in variable 'toggleText'
			var toggleText = row.find('td:eq(1) div.toggle-text');
					
			
			// define a click behaviour
			row.click(function(){
				
				// remove all active classes before we do any animation
				jQuery('table.toggle-section tbody tr').removeClass('active');
				
				// hide all .toggle-text elements at aren't already hidden
				jQuery('div.toggle-text').not(':hidden').each(function(){
					// do some neat animation
					jQuery(this).slideUp(500);	
				})
			
			
				// check if the current toggleText variable is hidden. if so, animate:
				if (toggleText.is(':hidden')) {
					// more neat animation
					toggleText.slideToggle(500);
					
					// turn the active class on and off (css)
					row.toggleClass('active');
				}

			});//end define click behaviour
			
		}); // end loop through rows
		
		
	});// end loop through tables



}); 
