//-- jQuery Functions --//
$.noConflict();
jQuery(document).ready(function($) {
	
	//-- Colorbox --//
	//Add Colorbox to all image links
	$( 'a[href$="jpg"], a[href$="png"], a[href$="gif"]' ).colorbox({
		maxWidth:'90%',
		maxHeight:'90%' 
	});
	
	$( '.modal' ).colorbox();
	
	
	//-- Hidden Top Button --//
	$( '#top-link' ).css({ 'display': 'none' }); // Fade #top-link to 0 opacity on default
		
	var scroll_timer;
	var displayed = false;
	var $message = $( '#top-link' );
	var $window = $( window) ;
	var top = $( document.body ).children( 0 ).position().top;
	
	$window.scroll( function(){
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout( function(){
			if( $window.scrollTop() <= top ){
				displayed = false;
				$message.fadeOut( 500 );
			}
			else if( displayed == false ){
				displayed = true;
				$message.stop(true, true ).show().click( function(){ $message.fadeOut( 500 ); });
			}
		}, 100);
	});
	
	
	//-- Smooth Scroll --//
	$('a[href*=#]').click(function() {
  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
      && location.hostname == this.hostname) {
          var $target = $(this.hash);
          $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
          if ($target.length) {
              var targetOffset = $target.offset().top - 60;
              $('html,body').animate({scrollTop: targetOffset}, 600);
              return false;
          }
      }
  });
	

});
//-- End jQuery Functions --//
