Cufon.replace('h1.page-title, h2, h3');

var homeTitleImages = 3;
var currrentHomeTitleImage = 1;

$(document).ready(function() {
    
    // home hero animation
    $('.home h1 span').each( function( i ){
        $(this).hide();
        $(this).css( 'backgroundImage', 'url(images/home/home-text-' + ( i + 1 ) + '.gif)' );
    });
    
    homeTitleImages = $('.home h1 span').length;
    initFadeCycle();
    
	// email
    var address = $('dd.email').html().replace(' [at] ', '@');
    $('.email').html(
        '<a href="mailto:' + address + '" title="Email ' + address + '">' + address + '<\/a>'
    );

    
});

function initFadeCycle()
{
    $('.home h1 span:nth-child(' + currrentHomeTitleImage + ')')
    .css( 'display', 'block')
    .hide()
    .fadeIn('slow')
    .animate( {opacity: 1.0}, 3000 )
    .fadeOut('slow', function() {
        if(homeTitleImages>1){
            currrentHomeTitleImage++;
            if( currrentHomeTitleImage > homeTitleImages){
                currrentHomeTitleImage = 1;}
            initFadeCycle();
        }
    });
}