
$(document).ready(function($) {

$('a[href*="http://"]:not([href*="'+location.hostname+'"])').attr('target','_blank').attr('rel','nofollow');

	$('.accordion').accordion({
		header:'h4',
		active: false,
		autoHeight: true,
		clearStyle: true,
		collapsible: true,
		fillSpace: true,
		change: function(e, ui) {
			$(this).localScroll();
		}
	});

	$('.unhide').click(function(e) {
	 if ($(this).hasClass('active')) {
 	 $(this).removeClass('active');
 	 $(this).next('.not-hidden').fadeOut().addClass('hidden').removeClass('not-hidden');
	 } else {
 	 $(this).addClass('active');
 	 $(this).next('.hidden').removeClass('hidden').fadeIn().addClass('not-hidden');
	 }
	});

	$('a[href]').click(function(e){
	 tgt = $(this).attr('href');
	 if (tgt.indexOf('#')!=-1) {
	  tgt = tgt.substr(tgt.indexOf('#'));
	  // console.log(tgt.toString());
	  if ($(tgt).length) {
 	  e.preventDefault();
	   if ($(tgt+'.hidden').length) {
	    $('.not-hidden').fadeOut().addClass('hidden').removeClass('not-hidden');
	    $(tgt).removeClass('hidden').fadeIn().addClass('not-hidden');
	   };
	   $(tgt).localScroll().filter('.unhide').click();
	   return false;
	  };
	 };
	 return true;
	});

	$('.album a').click(function(e){
	 $('.active').removeClass('active');
	 $(this).addClass('active');
	});

	if (location.hash.indexOf('#')!=-1) {
	 $('a[id='+location.hash.substr(1)+']').click();
	} else {
	 $('body').localScroll();
	};

});

$.fn.localScroll = function () {
 target = $(this).length ? $(this) : $('body');
 var targetOffset = target.offset().top;
 if (targetOffset>20) targetOffset = targetOffset - 20;
	$('html,body').animate({scrollTop: targetOffset}, 1000);
 return $(this);
}

/* +++++++++++++++++ */
/* + BROWSER CHECK + */
/* +++++++++++++++++ */
var $buoop = {reminder:0, l:'en', newwindow:true}
$buoop.ol = window.onload;
window.onload=function(){
 if ($buoop.ol) $buoop.ol();
 var e = document.createElement("script");
 e.setAttribute("type", "text/javascript");
 e.setAttribute("src", "http://browser-update.org/update.js");
 document.body.appendChild(e);
}


