/* smooth scroll with jQuery animate */

$(document).ready(function(){
	$('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;
				$('html,body')
				.animate({scrollTop: targetOffset}, 500, "swing" );
			 return false;
			}
		}
	});
});


/* add class="active" for links to the same path with temporal page */

$(function(){

  var path =     location.pathname.substring(1);
  path =         path.replace(/index\.html/,"");
  var navpath  = path.replace(/^(.+?)\/(.+?)\/.*$/,"$1\/$2\/");
  var sidepath = path.replace(/^(.+)\/.*.html$/,"$1\/");


// main navigation
    $('#nav li a[href$="' + navpath + '"]').attr('class', 'active');

// sidebar navigation
  if ( navpath == sidepath ){
    $('#sidenav li a[href$="' + sidepath + '"]').attr('class', 'active');
  }else{
    $('#sidenav li a[href$="' + navpath + '"]').attr('class', 'active');
  }
});




/* lightbox activation with elements inside classname "lightbox" 

$(function() {  
	$('.lightbox a').lightBox();  
});
*/


/* add class="active" for links to the same path with temporal page

$(function(){
	var path = location.pathname.substring(1);
	if ( path ) {
		$('a[href$="' + path + '"]').attr('class', 'active');
	} else {
		$('a[href$="/"]').attr('class', 'active');
	}
});

*/

