jQuery.noConflict();

var api;

jQuery(document).ready(function()
{
	/* Header Slideshow
	---------------------------------------------------------------------- */
	
	var interval = 5000;
	
	// Initializes the slideshow
	api = jQuery('#header .slideshow .scrollable').scrollable(
	{
		items: '.photos',
		item: '.photo',
		size: 1,
		speed: 1000,
		easing: 'jswing',
		keyboard: false
	})
	.circular()
	.autoscroll(
	{
		interval: interval,
		autoplay: false,
		autopause: false,
		api: true
	});
	
	// Prevents a strange bug where the second item is skipped the first time
	var timeout1 = setTimeout('api.begin();', interval / 2);
	var timeout2 = setTimeout('api.play();', interval);
	
	// Shows the full caption
	function ShowCaptions()
	{
		clearTimeout(timeout1);
		clearTimeout(timeout2);
		api.stop();
		
		var photos = api.getItems();
		jQuery(photos).children('.caption').animate({ bottom: '0px' }, 'normal')
		                                   .children('h2').animate({ color: '#e6ba4f' }, 'normal');
	}
	
	// Hides the full caption
	function HideCaptions()
	{
		var photos = api.getItems();
		jQuery(photos).children('.caption').animate({ bottom: '-4em' }, 'normal')
		                                   .children('h2').animate({ color: 'white' }, 'normal');
		api.play();
	}
	
	// Passes events to the slideshow controller
	jQuery('#header .slideshow-listener').click(function()
	{
		api.next();
	});
	
	jQuery('#header .slideshow-listener').hover(function()
	{
		ShowCaptions();
	},
	function()
	{
		HideCaptions();
	});
	
	jQuery('#header .slideshow-listener').mousemove(function()
	{
		clearTimeout(timeout1);
		clearTimeout(timeout2);
		api.stop();
	});
	
	// Fades in the slideshow on page load
	jQuery('#header .slideshow .scrollable, #header .slideshow-listener').hide();
	setTimeout("jQuery('#header .slideshow .scrollable, #header .slideshow-listener').fadeIn(1000);", 500);
	
	
	
	/* Header Photo
	---------------------------------------------------------------------- */
	
	// Fades in the photo on page load
	jQuery('#header > .photo').hide();
	setTimeout("jQuery('#header > .photo').fadeIn(1000);", 500);
	
	
	
	/* Portfolio Page
	---------------------------------------------------------------------- */
	
	jQuery('#portfolio #body > .content .entries li:odd').addClass('even');
	jQuery('#portfolio #body > .content .entries li:even').addClass('odd');
	
	
	
	/* Dynamic Font Replacement
	---------------------------------------------------------------------- */
	
	FontJazz.register('clearlygothic',
	{
		image: 'assets/templates/yellowhat/images/clearlygothic.gif',
		width: 1620,
		height: 37,
		'A': [0, 28, 3, 26],
		'B': [29, 26, 0, 23],
		'C': [56, 24, -2, 20],
		'D': [81, 26, 0, 23],
		'E': [108, 24, 0, 19],
		'F': [133, 24, 0, 17],
		'G': [158, 25, -2, 22],
		'H': [184, 28, 0, 24],
		'I': [213, 14, 0, 10],
		'J': [228, 19, 3, 15],
		'K': [248, 28, 0, 23],
		'L': [277, 20, 0, 18],
		'M': [298, 35, 0, 32],
		'N': [334, 27, 0, 24],
		'O': [362, 26, -1, 23],
		'P': [389, 25, 0, 21],
		'Q': [415, 26, -1, 23],
		'R': [442, 26, 0, 22],
		'S': [469, 23, 0, 19],
		'T': [493, 22, -1, 15],
		'U': [516, 26, -2, 21],
		'V': [543, 26, 0, 19],
		'W': [570, 38, -2, 31],
		'X': [609, 32, 3, 26],
		'Y': [642, 26, -1, 19],
		'Z': [669, 29, 3, 24],
		'a': [699, 22, -1, 19],
		'b': [722, 22, 0, 20],
		'c': [745, 20, -1, 16],
		'd': [766, 22, -1, 19],
		'e': [789, 20, -1, 17],
		'f': [810, 19, -1, 10],
		'g': [830, 23, 1, 20],
		'h': [854, 22, 0, 21],
		'i': [877, 13, 0, 9],
		'j': [891, 19, 6, 15],
		'k': [911, 23, 0, 19],
		'l': [935, 13, 0, 9],
		'm': [949, 32, 0, 30],
		'n': [982, 22, 0, 21],
		'o': [1005, 21, -1, 18],
		'p': [1027, 23, 1, 21],
		'q': [1051, 22, -1, 19],
		'r': [1074, 16, -1, 11],
		's': [1091, 19, 0, 16],
		't': [1111, 15, -1, 10],
		'u': [1127, 21, -2, 19],
		'v': [1149, 20, -1, 16],
		'w': [1170, 30, -1, 26],
		'x': [1201, 24, 3, 21],
		'y': [1226, 25, 4, 20],
		'z': [1252, 23, 3, 19],
		'0': [1276, 22, -2, 19],
		'1': [1299, 18, -2, 19],
		'2': [1318, 23, 0, 21],
		'3': [1342, 23, 0, 21],
		'4': [1366, 21, -1, 20],
		'5': [1388, 23, 0, 21],
		'6': [1412, 19, -1, 10],
		'7': [1432, 21, -3, 18],
		'8': [1454, 22, -1, 20],
		'9': [1477, 21, -2, 19],
		'&': [1499, 27, -1, 24],
		'!': [1527, 13, 0, 8],
		'?': [1541, 19, -2, 14],
		'-': [1561, 13, -1, 10],
		' ': [1575, 12, 1, 11],
		'.': [1588, 9, 0, 8],
		'\"': [1598, 13, -3, 10],
		'\'': [1612, 7, -3, 4]
	});
	
	FontJazz.apply('h1', 'clearlygothic');
});
