jQuery(function ($) {
	var clicked = false;
	$('a[href*="#"]').live('click', function(event) {
		$.bbq.pushState('#/' + this.hash.slice(1));
		clicked = true;
		return false;
	});
	
	$(window).bind('hashchange', function(event) {
		if (location.hash) {
			var tgt = location.hash.replace(/#\//,'');
			var elem = $('#' + tgt);
			if (clicked == true) {
				$(document).scrollTo(elem, 400, {offset: {top:-120}});
			} else {
				$(document).scrollTo(elem, 0, {offset: {top:-120}});
			}
		}
	});
	
	$('#ticker').list_ticker({
		speed:6000,
		effect:'fade'
	});
	
	$('#slideshow').slides({
		preload: true,
		preloadImage: 'img/lib/loading.gif',
		effect: 'fade',
		generatePagination: false,
		crossfade: true,
		play: 5000,
		fadeSpeed: 450,
		hoverPause: true
	});
	
	$('#portfolio').slides({
		generatePagination: true
	});
});

window.onload = function() {
	$(window).trigger('hashchange');
};
