 $(document).ready(function(){

	
	$('.person_list_wrap .menu a').click(function(){
	
		var check = $(this).parent('li').hasClass('current');
		var stuff_group = $(this).attr('class');
	
		
		if(check != 1){
		 	$('.person_list_wrap .menu li.current').removeClass('current');
		 	$(this).parent('li').addClass('current');
		 	
			if(stuff_group=='all'){
			
				$('#stuff_list li').fadeIn('swoll');
			}
			else
			{
				$('#stuff_list li').fadeOut(100,function(){});
				stuff_group = '#stuff_list .'+stuff_group;
				$(stuff_group).wait(100).fadeIn();
			}
			
		}
	
	return false;
	})
		
	$('.wpcf7-not-valid-tip-no-ajax').parent('span').parent('label').addClass('error');

	
	
	
	$('.scrollPage').click(function() 
	{
		   var elementClicked = $(this).attr("href");
		   var destination = $(elementClicked).offset().top;
		   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination - 20 }, 3500 );
		   return false;
	});
	
	//this is the floating content
	var $floatingbox = $('.sidebar');

	if($('body').length > 0){
 
	  var bodyY = parseInt($('body').offset().top) - 20;
	  var originalX = $floatingbox.css('margin-left');
	  var heightSidebar = $('.sidebar').height();
	  var heightContent = $('.content').height();
	  //alert(heightContent);
	  $(window).scroll(function () { 
 
	   var scrollY = $(window).scrollTop();
	   var isfixed = $floatingbox.css('position') == 'relative'; 
	   
	   if($floatingbox.length > 0){
		   var test = heightSidebar - scrollY;
	     //$floatingbox.html("srollY : " + scrollY + ", sidebar height  : "  + heightSidebar + " test :" + test );
 
	      if ( scrollY > ( bodyY - 160) ) {
	    	  var scroling;
	    	  if( ( scrollY - 180 ) > 0 ){
	    		 
	    		  if( scrollY + heightSidebar < heightContent + 380){
	    			  
	    			  scroling = scrollY - 120;
	    			  
	    		  }
	    		  
	    		 
	    	  }
	    	  else
	    	  {
	    		  
	    		 scroling = scrollY;
	    	  }
	    	  $floatingbox.stop().animate({
	    		  marginTop:scroling
	    		  }, 3000, function() {
	    		    // Animation complete.
	    		  });
	    	  /*
			$floatingbox.stop().css({
				marginTop: scrollY
			});*/
		} else if ( scrollY < bodyY && isfixed ) {
		 	  $floatingbox.css({
			  position: 'relative',
			  left: 0,
			  top: 0,
			  marginLeft: originalX
		});
	     }		
	   }
       });
     }
	
	
	$('.dropdown_but').click( function(){
		
		$('#content_portfolio').slideToggle(1500);
		//$( '.prev , .next').toggleClass('disable');
	})

        /* add onclick event to thumbnail to make the main
        carousel scroll to the right slide*/
        $('.pager div').click(function() {
        	var next_ellement = '#'+$(this).attr('id');
        	//alert( next_ellement );
        	next_ellement = next_ellement.replace(/\D/g, '');

        	$('.pager div,.item').removeClass( 'current' );
        	$( next_ellement ).addClass( 'current' );
            $('.listing-project-images').trigger( 'slideTo', [ next_ellement , 0, true] );
            return false;
     
    });
	
	
})

 $.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
    
  /*  
	$('.casess_wrap .casess').click(function(){
	
	
			var current_id = 'div.'+$(this).attr('id');
			
			var current_status = $(current_id).css('display');
			
			if(current_status=='none'){
				$('div.casess').fadeOut("slow");
					$(current_id).wait().fadeIn("slow");
				
						}
			return false;
	});
	
	
		carusell();
	
	  $(window).resize(function () { 
		  carusell();
	  });
	
	////////////////////////////////////////////////////////
	
	
	
	    
function carusell(){
	
	var window_width = $(window).width();
	//alert(window_width);
	$('.item img').css('width',window_width);
	 
	var window_height = $(window).height();
	var toper_arrow = ( window_height / 2 ) - 75;
		$('.prev,.next').css('top', toper_arrow );
	$(".listing-project-images").carouFredSel({
		prev: '.prev',
		next: '.next',
		width: window_width,
		height: window_height,
		//circular: false,
		items: {
			visible: 1,
			minimum: 1,
			width: window_width
		},
		scroll: {
			easing: "easeOutBack",
			duration: 1200,
			fx: "cover",
				
				
				onBefore: function() {
	              
	                var pos = $(this).triggerHandler( 'currentPosition' );
	                var selctted_item = '#itemnum'+pos;
	               
	                $('.pager div,.item').removeClass( 'selected' );
	                
	                $( selctted_item ).addClass( 'selected' );
	                
	                $('#thumbs').trigger( 'slideToPage', pos );
	            }
					
				
		},
		auto: false
	});
	
}
	
	
	
	*/
