/* ***********************************************************
 * jQuery Activation Scripts 
 * 
 * Since:          2010-06-29 > Takanori Murakami
 * Last Modified:  2011-07-11 > KANI
 * Guideline:      Ver.1.00
 * ***********************************************************
 */


/* 1) smooth scroll ---
 any <a> links to inside-page anchors */

$(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;
			}
		}
	});
});


/* 2) jQuery lightbox activation ---
 for <a> inside any elements with classname "lightbox" */

$(function() {  
	$('.lightbox a').lightBox();  
});
 
 
 /* 4)add class="active" for links to the same path with temporal page */

//$(function(){

//  var path = location.pathname.substring(1);
//  path =         path.replace(/index\.html/,"");
//  path = "/" + path;

//  $('#sidebar li a[href$="' + path + '"]').attr('class', 'active');

//});


/* add class="active" NEW VERSION! */

$(document).ready(function(){

  var path = location.pathname.substring(1);
  path = path.replace(/index\.html/,"");
  var navpath = path.replace(/^(.+?)\/(.+?)\/(.+?)\/.*$/,"$1\/$2\/");
  // main navigation
    $('#sidebar li a[href$="' + navpath + '"]').attr('class', 'active');
});
