$(function() {

	$('#toggle-work').live('click', function() {
		$(this).parent().children('ul').toggle();
		return false;
	});
	
	if ( window.location.hash == '#FSContact1' ) {
		$('#reel-request').show();
		window.scrollTo(0,500);
	}
	
	$('#view-request').live('click', function() {
		$('#reel-request').toggle();
		window.scrollTo(0,500);
		return false;
	});
	
	if ( $('body.parent-pageid-4').length ) {
		var pageTitle = $('#content h2').text();
		document.title = pageTitle+' | Sandymontana';
	}
	
	if ( $('#pagenav').length ) {
	
		var activeWork = $('#work .current_page_item');
		if ( $(activeWork).next('li').length ) {
			var nextHref = $(activeWork).next('li').find('a').attr('href');
		} else {
			var nextHref = $('#work li:first a').attr('href');
		}
		
		if ( $(activeWork).prev('li').length ) {
			var prevHref = $(activeWork).prev('li').find('a').attr('href');
		} else {
			var prevHref = $('#work li:last a').attr('href');
		}
	
		$('#previous-project-link a').attr('href', prevHref);
		$('#next-project-link a').attr('href', nextHref);
	
	}

});



window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};
