$(document).ready(function() {
	Cufon.replace('h1, p strong, p.sub_head, .desc, .division_inner .link, .more_link, .close_link, #divisions h2, #divisions h3', { fontFamily: 'cufoned-gotham' });

	//Cufon.replace('#top_cta .cta', { fontFamily: 'Clan-Book' });
	
	$('#quotes').height($('#quotes li').max_height());
	$('#quotes li').match_heights();
	$('#quotes li').css('opacity', 0);
	$('#quotes').cycle({
		timeout: 10000
	});
	
	$('body.home #divisions').height($('#divisions li').max_height());
	$('body.home #divisions li').each(function() {
		this.var_left = $(this).position().left;
	});
	$('body.home #divisions li').each(function() {
		$(this).css('position', 'absolute');
		$(this).css('bottom', '0px');
		$(this).css('left', this.var_left + 'px');
	});
	
	$('body.home #divisions li .division_inner').hide();
	
	$('body.home #divisions li').hover(function() {
		$(this).find('.division_inner').slideDown('fast');
	},function() {
		$(this).find('.division_inner').slideUp('fast');
	});
	
	
	$('body.services .link_holder').show();
	
	$('body.services #divisions').addClass('js');
	$('body.services #divisions li .division_service').each(function() {
		var division_service = this;
		
		$(this).find('.close_link').click(function() {
			$(this).hide();
			$(division_service).removeClass('shown');
			$(this).parent().parent().find('.division_service_content').animate(
				{ height: 'hide' },
				{
					step: function() {
						$('body.services #divisions li').css('height', 'auto');
						$('body.services #divisions li').match_heights();
					},
					complete: function() {
						$(division_service).find('.more_link').show();
						$('body.services #divisions li').css('height', 'auto');
						$('body.services #divisions li').match_heights();
					}
				}
			);
			
			return false;
		});
		
		$(this).find('.more_link').click(function() {
			$(this).hide();
			$('.shown .close_link').click();
			$(division_service).addClass('shown');
			$(this).parent().parent().find('.division_service_content').animate(
				{ height: 'show' },
				{
					step: function() {
						$('body.services #divisions li').css('height', 'auto');
						$('body.services #divisions li').match_heights();
					},
					complete: function() {
						$(division_service).find('.close_link').show();
						$('body.services #divisions li').css('height', 'auto');
						$('body.services #divisions li').match_heights();
					}
				}
			);
			
			return false;
		});
	});
	
	$('.work_examples li span').hide();
	$('.work_examples li').hover(function() {
		$(this).find('span').fadeIn('fast');
	},function() {
		$(this).find('span').fadeOut('fast');
	});
	
	$('.close_link, .division_service_content').hide();
	$('body.services #divisions li').match_heights();
	
	$('#ticker_items li').css('opacity', 0);
	$('#ticker_items').cycle({ 
		fx: 'custom', 
		cssBefore: { top: 22, opacity: 1 }, 
		animIn:  { top: 0 }, 
		animOut: { top: -22 },
		timeout: 4000
	});
});
