/* Javascript: sraarchitects.net - Author: James E Rybolt
 *
 * Copyright (c) 2009
 *
 * Last Revision May 20 (3)
 */

//JQuery Javascript
$(document).ready(function() {	

//	Animated ScrollTo
	$('a[href*=#]').click(function() // Run function on any link with a hash
	{
		if (location.pathname == this.pathname) // Check if location pathname is sames as that of target
		{
			try
			{
				var $target = $(this.hash); // Get hash from href
				var $offset = $target.offset().top; // Set offset to offset of the hash
			}
			catch(err) // Hash has no target specified
			{
				var $offset = '0'; // Just give it a target offset
			}

			$('html,body').animate({scrollTop: $offset}, 'slow'); // Animate!
			return false;
		}
	});
	
//	Fancybox image zoom
	$(".fancybox").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'overlayOpacity': 0.7,
		'centerOnScroll': false
	});
	
//	Cycle slideshow
	$('div.cycle').after('<p id="nav">').cycle({
		fx: 'fade',
	    speed: 1500,
	    timeout: 6000,
//	    next: ".cycle",
	    pause: 1,
	    pager: '#nav',
	    before: onBefore
//	    after: onAfter
	});

	function onBefore () { 
		$('#output').html("<b>Project:</b><br>" + this.title); 
	}
	
});
