var name = "#floatMenu";
var menuYloc = null;
var peoplename = "#peoplefloatMenu";
var peoplemenuYloc = null;

function loadContent(elementSelector, sourceURL) {


$(""+elementSelector+"").fadeOut('normal', function () {
    $(""+elementSelector+"").load(""+sourceURL+"", {limit: 60}, function(){
        $(""+elementSelector+"").fadeIn();
  $('html, body').animate({scrollTop:0}, 'slow');
  return false;
        
    });
});

};


$(document).ready(function() {
//$('body').loading({mask:true});
$('.menu>li>ul').hide();
    $('.menu>li').mouseover(function(){
        // check that the menu is not currently animated
        if ($('.menu ul:animated').size() == 0) {
            // create a reference to the active element (this)
            // so we don't have to keep creating a jQuery object
            $heading = $(this);
            // create a reference to visible sibling elements
            // so we don't have to keep creating a jQuery object
            $expandedSiblings = $heading.siblings().find('ul:visible');
            if ($expandedSiblings.size() > 0) {
                            $heading.find('ul').slideDown(500,function(){
                                            $expandedSiblings.slideUp(500);
                            });
            }
            else {
                $heading.find('ul').slideDown(500);
            }
        }
    });
menuYloc = $(name).offset().top - parseFloat($(name).css('marginTop').replace(/auto/, 0));

 $(window).scroll(function (event) {
    // what the y position of the scroll is
    var y = $(this).scrollTop();
  
    // whether that's below the form
    if (y >= menuYloc) {
      // if so, ad the fixed class
      $(name).addClass('fixed');
    } else {
      // otherwise remove it
      $(name).removeClass('fixed');
    }
  });
  
  
  if ($(peoplename).length) { // implies *not* zero
peoplemenuYloc = $(peoplename).offset().top - parseFloat($(peoplename).css('marginTop').replace(/auto/, 0));
     $(window).scroll(function (event) {
    // what the y position of the scroll is
    var y = $(this).scrollTop();
  
    // whether that's below the form
    if (y >= menuYloc) {
      // if so, ad the fixed class
      $(peoplename).addClass('fixed');
    } else {
      // otherwise remove it
      $(peoplename).removeClass('fixed');
    }
  });   
}
if ($("contactform").length) { // implies *not* zero
	$("#contactform").validate();
}
        

	$('ul#peoplefilter a').click(function() {
		$(this).css('outline','none');
		$('ul#peoplefilter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase()
		filterVal = filterVal.replace(/\s/g, "");
		if(filterVal == 'all') {             
           $('ul#peoplelist li.hidden').fadeTo('normal', 1).removeClass('hidden');  									

		}
		else {
					
				$('ul#peoplelist li').each(function() {
					if(!$(this).hasClass(filterVal)) {
						$(this).addClass('hidden');
						$(this).fadeTo('normal',0.25);
					}
					else{
						$(this).removeClass('hidden');
						$(this).fadeTo('normal',1);
					}


				});



		}

		
		return false;
	});
	
	$('ul#projectfilter a').click(function() {
		$(this).css('outline','none');
		$('ul#projectfilter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase()
		filterVal = filterVal.replace(/\s/g, "");
		if(filterVal == 'all') {
			$('#projectpane').fadeOut('normal');
			//$('ul#projectlist').fadeOut('normal',function(){
			//$('ul#projectlist li.hidden').removeClass('hidden');
			$('ul#projectlist li').fadeTo('normal',1);
			//});
											

		}
		else {
					$('#projectpane').fadeOut('normal');

				$('ul#projectlist li').each(function() {
					if(!$(this).hasClass(filterVal)) {
						$(this).addClass('hidden');
						$(this).fadeTo('normal',0.25);
					}
					else{
						$(this).removeClass('hidden');
						$(this).fadeTo('normal',1);
					}


				});



		}

		
		return false;
	});

				//Horizontal Fading
				$('.boxgrid.slideright').hover(function(){
                    $(".cover", this).fadeTo('slow', 0.1);
				}, function() {
					$(".cover", this).fadeTo('slow',1);
				});
				
					//Horizontal Fading
				$('.peopleboxgrid.slideright').hover(function(){
                    $(".cover", this).fadeTo('slow', 0.1);
				}, function() {
					$(".cover", this).fadeTo('slow',1);
				});

					//Horizontal Fading
				$('.projboxgrid.slideright').hover(function(){
						$(".cover", this).fadeTo('slow', 0.1);
				}, function() {
					$(".cover", this).fadeTo('slow',1);
				});
				
});


