jQuery(document).ready(function() {

	var $ = jQuery;

$("#slides").slides({
		container: 'bannergroup',
		fadeEasing: 'easeOutQuad',
		effect: 'fade',
		generatePagination: false,
		play: 9000,
		slideSpeed: 900
	});
	
	
    $('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:1000, // Slide transition speed
        pauseTime:5000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:false, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:false, // Use left & right arrows
        pauseOnHover:false, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });


	function filter_projects(catid) {

		var projects = $('#project_cats');
		projects.find('div').stop().hide();
		projects.find('div.'+catid).stop().fadeIn(300,'swing');
	}

	function update_menu(currenthash) {

		currenthash = (currenthash) ? currenthash : 'cat0';
		$('#pmenu_'+currenthash).css({'background-color':'#e2e2e2','color':'#5f5f5f', '-moz-border-radius':'3px', 'border-radius':'3px'}) 
		filter_projects(currenthash);
	}

	$('#project_menu a').click(function() {

		$('#project_menu a').css({'background-color':'transparent','color':'#5f5f5f'});
		update_menu($(this).attr('id').replace('pmenu_',''));
	});
	
	update_menu(window.location.hash.replace('#',''));
	
	$('ul.projects_navmenu li ul li').click(function() {

		window.location.href=$(this).find('a.route').attr('href');
	});


	$('ul.projects_navmenu li span.cattitle').click(function() {

		if($(this).parents('li').hasClass('selected') == false) {

			$('ul.projects_navmenu li.selected ul').slideUp(300,'swing',function() {
				
				$(this).parents('li.selected').removeClass('selected');
			});
			$(this).siblings('ul').slideDown(300,'swing',function() {

				$(this).parents('li:first').addClass('selected');
			});
		}
	});
	
	$('.bump').hover(function () {
		
		$(".preview_image", this).stop().animate({top:"-45px"},{queue:false,duration:200});
	},
	function() {
	
		$(".preview_image", this).stop().animate({top:"0px"},{queue:false,duration:200});
	});
	
	$("a[rel='sarah']").colorbox({transition:"fade",scalePhotos:true,maxWidth:'80%',maxHeight:'80%'});

	$('#Navigation ul li').click(function() {

		$('html,body').animate({ scrollTop: $($(this).find('a').attr('href')).offset().top }, 1500,'easeInOutExpo');
		return false;
	});
	
		$('.backtop a').click(function() {

		$('html,body').animate({ scrollTop: 0}, 1500,'easeInOutExpo');
		return false;
	});
		
		$('#End a').click(function() {

		$('html,body').animate({ scrollTop: 0}, 1500,'easeInOutExpo');
		return false;
	});
});


jQuery.fn.topLink = function(settings) {
  settings = jQuery.extend({
    min: 1,
    fadeSpeed: 200
  }, settings);
  return this.each(function() {
    //listen for scroll
    var el = $(this);
    el.hide(); //in case the user forgot
    $(window).scroll(function() {
      if($(window).scrollTop() >= settings.min)
      {
        el.fadeIn(settings.fadeSpeed);
      }
      else
      {
        el.fadeOut(settings.fadeSpeed);
      }
    });
  });
};



//usage w/ smoothscroll
$(document).ready(function() {
  //set the link
  $('#top-link').topLink({
    min: 400,
    fadeSpeed: 500
  });
  //smoothscroll
  $('#top-link').click(function(e) {
    e.preventDefault();
    $.scrollTo(0,1000,{easing:'easeInOutExpo'});
  });
   
});

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 * @author Ariel Flesler
 * @version 1.4
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);




$(document).ready(function () {

	$('div.DirectorBio').hide();

	$(".menu_class").click(function(){

		if($('div.ContentFull').height() > 1000) {
			
			newheight = 230;
		}
		else {
			
			newheight = 1025;
		}
		var this_display = $(this).parents('div.Director').find('div.DirectorBio').css('display');
		if(this_display == 'none' && $('div.ContentFull').height() < 1000
			|| (this_display == 'block' && $('div.ContentFull').height() > 1000 && $('div.active').length == 1)
		) {

			$('div.ContentFull').animate({

				height:newheight
			},500,'easeInOutExpo');
		}
		$(this).parents('div.Director').find('div.DirectorBio').slideToggle(500,'easeInOutExpo').toggleClass('active');

	});

});
	



