$(document).ready(function() {
	anchorslider.init();

	var location = window.location;
	var text = location.toString();

	pos = text.indexOf('#');

	if (pos != -1) {
		len = text.length - pos;
		anchor = text.substr(pos, len);

		switch (anchor) {
			case '#news':
				destination = 836;
				break;
			case '#research':
				destination = 1520;
				break;
			case '#get_involved':
				destination = 2379;
				break;
			default:
				destination = 0;
		}
		$("html:not(:animated),body:not(:animated)").animate({scrollTop: destination}, 600);
	}
});

anchorslider = {
	init : function()  {

		$("a[rel='navigation']").click(function () {
			elementClick = $(this).attr("href");
			offset = (elementClick == '#home') ? 218 : 111;
			destination = ($(elementClick).offset().top-offset);
			$("html:not(:animated),body:not(:animated)").animate({scrollTop: destination}, 600);
			window.location = elementClick;
			return false;
		})
	}
}
