  var topRange      = 200,  // measure from the top of the viewport to X pixels down

     edgeMargin    = 20,   // margin above the top or margin from the end of the page

     animationTime = 1200, // time in milliseconds

     contentTop = [];



jQuery(document).ready(function(){



 // Stop animated scroll if the user does something

 jQuery('html,body').bind('scroll mousedown DOMMouseScroll mousewheel keyup', function(e){

 if ( e.which > 0 || e.type == 'mousedown' || e.type == 'mousewheel' ){

  jQuery('html,body').stop();

 }

})



 // Set up content an array of locations

 jQuery('#menu').find('a').each(function(){

  contentTop.push( jQuery( jQuery(this).attr('href') ).offset().top );

 })



 // Animate menu scroll to content

  jQuery('#menu').find('a').click(function(){

   var sel = this,

       newTop = Math.min( contentTop[ jQuery('#menu a').index( jQuery(this) ) ], jQuery(document).height() - jQuery(window).height() ); // get content top or top position if at the document bottom

   jQuery('html,body').stop().animate({ 'scrollTop' : newTop }, animationTime, function(){

    window.location.hash = jQuery(sel).attr('href');

   });

   return false;

 })

 

 // adjust side menu

 jQuery(window).scroll(function(){

  var winTop = jQuery(window).scrollTop(),

      bodyHt = jQuery(document).height(),

      vpHt = jQuery(window).height() + edgeMargin;  // viewport height + margin

  jQuery.each( contentTop, function(i,loc){

   if ( ( loc > winTop - edgeMargin && ( loc < winTop + topRange || ( winTop + vpHt ) >= bodyHt ) ) ){

    jQuery('#menu a')

     .removeClass('active')

     .eq(i).addClass('active');

   }

  })

 })

  

})

 

 

 jQuery(function() {

	  /*jQuery('ul.menu a').bind('click',function(event){

		  var jQueryanchor = jQuery(this);   

		  jQuery('ul.menu a').removeClass('active');

		  jQuery(this).addClass('active');

		  

		  jQuery('html, body').stop().animate({

			  scrollTop: jQuery($anchor.attr('href')).offset().top

		  }, 1500,'easeInOutExpo');

		  event.preventDefault();

	  });*/

	  

	  jQuery(".workItem .hoverShad").css("opacity","0");

		// on mouse over

		jQuery(".workItem").hover(function () {

			// animate opacity to full

			jQuery(this).find(".hoverShad").stop().animate({

				opacity: 1

			}, "slow");

			jQuery(this).find(".imageCover").stop().animate({

				opacity: 0

			}, "slow");

			jQuery(this).find(".infoBlk").stop().animate({

				backgroundColor: "#333333"

			}, "slow");

		},

		// on mouse out

		function () {

			// animate opacity to nill

			jQuery(this).find(".hoverShad").stop().animate({

				opacity: 0

			}, "slow");

			jQuery(this).find(".imageCover").stop().animate({

				opacity: 1

			}, "slow");

			jQuery(this).find(".infoBlk").stop().animate({

				backgroundColor: "#fff"

			}, "slow");

			jQuery(this).find(".infoCont").slideUp();

			jQuery(this).find(".infoBlk .infoLink").removeClass('current')

		});

		

		

		jQuery('.workItem .infoLink').click(function() {

			jQuery(this).toggleClass('current');							

  			jQuery(this).parents('.workItem').find(".infoCont").slideToggle();

		});

		

    jQuery('.workItem').each(function() {

   			jQuery(this).find('.slideInfo .totalImg').html(jQuery(this).find('.workImgCont img').length);

  	});



    jQuery('.imageCover').click(function() {

   // var $active = $(this).parent().find('.workImgCont img.active');

   // if ( $active.length == 0 ) $active = $(this).parent().find('.workImgCont img:last');



    //var $next =  $active.next().length ? $active.next(): $(this).parent().find('.workImgCont img:first');

	var currentImgInSlides = jQuery(this).next('.workImgCont').find('img:visible').next().index()+1;

	//alert(currentImgInSlides)

	if(currentImgInSlides==0)

	{

		jQuery(this).parents('.workItem').find('.slideInfo .currentImg').html(1)

	}

	else

	{

		jQuery(this).parents('.workItem').find('.slideInfo .currentImg').html(currentImgInSlides)

	}

	

   // $active.addClass('last-active');

    //$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 500, function() {

          //  $active.removeClass('active last-active');

      //  });

	});

   jQuery('.workImgCont').each(function() {

	   jQuery(this).cycle({ 

			fx:     'scrollHorz', 

			next:   jQuery(this).parents('.workItem').find('.imageCover'), 

			timeout: 0,

			speed:200

		});

	});



	jQuery(".aaa a").click(function(){

		jQuery(".infoAAA").slideDown("slow");

	});



	jQuery("a.closeBtn").click(function(){

		jQuery(".infoAAA").slideUp("hide");

	});
	  

  });

 
