
Cufon.replace('#primary a, #secondary a, h1, h2, h3, .descr, p.intro, .packagetitle', { hover: true })

$(document).ready(function () {
    resize();
    boxes();
    packages();
    
});


$(window).resize(function () {
    resize();
});

function packages() {
    $('#packagesSlider').cycle({
        fx: 'fade',
        speed: 400,
        timeout: 5000,
        pager: '#packagesPager',
        pagerAnchorBuilder: function (index, el) {
            return '<a href="#">&nbsp;</a>';
        }
    });
    $("#packagesPager a").click(function () {
        $('#packagesSlider').cycle('pause');
    })
}

function boxes() {
    $('.box a').hover(function() {
        $('.box a img').not($(this).find('img')).stop().fadeTo('fast', 0.5);
    }, function () {
        $('.box a img').stop().fadeTo('fast', 1);
    })
}

function footer() {
    var windowHeight = $(window).height();
    var containerHeight = $('#container').height();
    var footerHeight = $('#footer').height();
    var totalHeight = windowHeight - (containerHeight + footerHeight) - 20;  //footer padding
    if (totalHeight >= 0) {
        $('#footer').css('top', totalHeight).show();
    }
    else {
        $('#footer').css('top', 0).show();
    }
    
}

function resize() {
    var ratio = 2.37;
    var sw = $('#slideshow').width() + 20;
    
    //$('#cycle').height(sw / ratio);
    $('#cycle').height((sw / ratio) - 30); // temp

    $('#cycle img').width(sw).height(sw / ratio);
    carousel();
    footer();
}

function carousel() {
    $('#cycle').cycle({
        fx: 'fade',
        speed: 500,
        timeout: 4500,
        next: '#prv',
        prev: '#nxt',
        after: onAfter,
        before: onBefore
    });

    $("#prv, #nxt, #cycle img").click(function () {$('#cycle').cycle('pause');})

    function onAfter(curr, next, opts) {
        var cpt = $(this).attr('cpt');
        if (cpt.length > 0) {
            $('#capCycle').stop().fadeIn('fast', function () {
                if (jQuery.browser.msie) { this.style.removeAttribute("filter") }
            });
            $('#capCycle p').html(cpt);
        }
    }

    function onBefore(curr, next, opts) {
        $('#nxtCycle, #prvCycle').not('is:visible').show();
        $('#capCycle').stop().fadeOut('fast', function () {
            $(this).find('p').empty();
        });
    }

}


	
	


