$(document).ready(function() {
	if(!$.fontAvailable('Museo') && !($.browser.name == 'msie' && $.browser.versionNumber == 6)) {
		Cufon.replace('h1, h2, h3, h4, .details dd[class!=services]', {
			fontFamily: 'Museo',
			textShadow: '0 2px #07090d'
		});
		Cufon.replace('.nav.site li a strong, .recent-work h3, .link h3', {
			fontFamily: 'Museo',
			textShadow: '0 1px #07090d'
		});
		Cufon.replace('.panel.header h2, .panel h2.header, .panel.header h3, .panel h3.header, h3.button', {
			fontFamily: 'Museo',
			textShadow: '0 1px #b3cdec'
		});
		Cufon.replace('.post .meta .month, .post .meta .day', {
			fontFamily: 'Junction',
			textShadow: '0 1px #07090d'
		});
	}
	
	$('.posts.index .post')
		.hover(function() {
			$(this).find('.meta dd:not(.permalink)').show('fast');
		}, function() {
			$(this).find('.meta dd:not(.permalink)').hide('fast');
		});
	
	$('.post .meta dd.reblog, .post .meta dd.tags, .post .meta dd.notes')
		.hover(function() {
			$(this).children(':first').fadeIn('fast');
		}, function() {
			$(this).children(':first').fadeOut('fast');
		});
	
	
	// work
	if ($('body#work').length) {
		$('.recent-work .window').rotator();
	}
	
	
	// Work
	if ($('body#work').length) {
		$('.gallery .nav a.toggle').bind("click", function() {
			$(this).toggleClass('active');
			$('.all-work').slideToggle('normal');
			return false;
		});
	}
	
	
	/*if (AC_FL_RunContent == 0) {
		
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
			'width', '150',
			'height', '30',
			'src', 'playerlite',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'playerlite',
			'bgcolor', '#000000',
			'name', 'playerlite',
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'playerlite',
			'salign', ''
			); //end AC code
	}*/
});


/* 
 * Content Rotator
 * Scrolls content inside a frame
 * @author Eric Grossnickle
 */
jQuery.fn.rotator = function(options) {
	var settings = jQuery.extend({
		"group_id": $(this).attr('id'),
		"inner_id": $(this).children(':first').attr('class'),
		"timer": false,
		"duration": 5000,
		"onInit": function() {},
		"onHover": function() {},
		"onLeave": function() {},
		"center": false
	}, options);
	
	var $images = $(this).find('.images:first'),
	    imageH = $images.find('a:first').height() + parseInt($images.find('a:first').css('margin-bottom').replace('px', '')),
	    current = 1,
	    total = $images.children('a').size();
	
	$('.pager a').unbind("click");
	$('.pager a.previous').bind("click", function() {
		previous();
		return false;
	});
	$('.pager a.next').bind("click", function() {
		next();
		return false;
	});
	
	function previous() {
		last = current;
		
		if(current == 1) current = total;
		else current--;
		
		$images.animate({
			marginTop: -(current-1) * imageH
		}, {duration: 2000, easing: 'easeOutElastic', queue: false});
		
		$('#work-info-'+last).fadeOut('1000', function() {
			$('#work-info-'+current).fadeIn('1000');
		});
	}
	
	function next() {
		last = current;
		
		if(current == total) current = 1;
		else current++;
		
		$images.animate({
			marginTop: -(current-1) * imageH
		}, {duration: 2000, easing: 'easeOutElastic', queue: false});
		
		$('#work-info-'+last).fadeOut('1000', function() {
			$('#work-info-'+current).fadeIn('1000');
		});
	}
};


