  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('#mainNav').find('a').each(function(){

  contentTop.push( jQuery( jQuery(this).attr('href') ).offset().top );

 })



 // Animate menu scroll to content

  jQuery('#mainNav').find('a').click(function(){

   var sel = this,

       newTop = Math.min( contentTop[ jQuery('#mainNav 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('#mainNav a')

     .removeClass('active')

     .eq(i).addClass('active');

   }

  })

 })

  

})

 

 

 jQuery(function() {

	  /*jQuery('ul.mainNav a').bind('click',function(event){

		  var jQueryanchor = jQuery(this);   

		  jQuery('ul.mainNav 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");

	});







		

jQuery('.workItemSliderContainer').cycle({ 

		fx:     'scrollHorz', 

		prev:   '.prevBtn', 

		next:   '.nextBtn', 

		speed:  '700',

		after:   onAfter,

		nowrap:       1,

		timeout:0

});

	function onAfter(curr, next, opts) {

    var index = opts.currSlide;

	if(index == 0){$('.prevBtn').addClass('prevBtnDisable');}

	else{$('.prevBtn').removeClass('prevBtnDisable');}

   // $('#prev')[index == 0 ? 'hide' : 'show']();

	if(index == opts.slideCount - 1){$('.nextBtn').addClass('nextBtnDisable');}

	else{$('.nextBtn').removeClass('nextBtnDisable');}

   // $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();

}




	$("#contactForm").validate();


	  

  });
 
 
 
 jQuery(document).ready(function(){
	jQuery(".galBtn").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		jQuery('html, body').animate({scrollTop:target_top}, 500);
	});
});


 
