$(document).ready(function() {
	
	
	// BRIEFING (S)
	$('#projects li > a').click(function(event) {
		event.preventDefault(); 				// cancel click through
		$('#projects div').fadeIn();			// when 'project details' clicked, fadein description div
		$(this).fadeOut();						// fade out the button itself 'project details'.
	});
	
	
	
	// CLOSE BRIEFING
	$('a.close').click(function(event) {
		event.preventDefault(); 				// cancel click through
		$('#projects div').slideUp('fast'); 	// hide briefing,
		$('#projects li > a').fadeIn('fast'); 	// re-display the 'project details' anchor
	});
	
	
	
	
	$('#projects div, #projects li').hide();	// initially, hide 'descriptive' content, AND all list items
	$('#projects li').first().show(); 			// show first item

	// NEXT
	$('#next_project').click(function(event) {
		event.preventDefault(); 				// cancel click through
		$('#projects div').slideUp('slow');		// select current (if any) descriptive 'div', and hide.
		$('#projects li > a').fadeIn();			// make sure to re-display the 'project details' button.
		
		$('#projects li').stop(true,true); 					// added by 'tentonaxe' jquery forums
		var curlistitem = $('#projects li:visible');    	// find the current list item
		var nextlistitem = curlistitem.next();  			// get next in list
		
		// if last list item is visible ..
		if (nextlistitem.length == 0) {         // if length equal to '0'
		nextlistitem = curlistitem.siblings(':first');
		}
		
		nextlistitem.fadeIn(1000);
		$('#projects div').fadeOut('fast');
		curlistitem.fadeOut(1000);
	}); //end 'click' function
	
	
	
	// PREVIOUS
	$('#previous_project').click(function(event) {
		event.preventDefault(); 				
		$('#projects div').slideUp('slow');
		$('#projects li > a').fadeIn();
		
		$('#projects li').stop(true,true); 					
		var curlistitem = $('#projects li:visible');    	
		var prevlistitem = curlistitem.prev();  
		
		if (prevlistitem.length == 0) {       
		prevlistitem = curlistitem.siblings(':last');
		}
		
		prevlistitem.fadeIn(1000);
		$('#projects div').fadeOut('fast');
		curlistitem.fadeOut(1000);
	}); //end 'click' function
	
	
	/*MAIN NAV, APPLY CUSTOM
	CSS BASED ON 'IF' ANY CHILDREN (SUBNAV) PRESENT*/
	$('ul.nav.top > li > a').filter(function() {
    return ($(this).next().length == 1);
	}).css('cursor','default');
	
	$('ul.nav.top > li > a').click(function(event) { 
	if ($(this).next().length == 1) {
	event.preventDefault(); 
	}
	});
	
	//CLEAR / RESET PRE-DEFINED FORM FIELD VALUES	
	$("input.reset_value").focus(function() {
    var thisVal = $(this).val();
    if (thisVal.match(/^Your/)) {
         	$(this).val('');
         	$(this).css({
             'font-style': 'normal',
             'color': '#333'
			 });
     }
     });//End
	
	
	/*
	COLLAPSIBLE PROFILES, 
	OUR TEAM PAGE
	*/		
	$('body.our_team div#content h3').toggle(function() {
	$(this).next().slideDown('fast');
	$(this).addClass('active');
	}, function() {
	$(this).next().slideUp('slow');
	$(this).removeClass('active');
	});
	
	
});	//end ALL

