function redirect(url){
    if (url) {
        setTimeout(function() {
            window.location.replace(url);
        },3000);
    }
}

function prepare_guests(){
    if ($('body').hasClass('guests')) {
        $('#guests_nav a:first').fadeTo('normal',0.18);
        $('#guests_nav a').click(function(event) {
            $('#guests_nav a').fadeTo('fast',1);
            $(this).fadeTo('normal',0.18);
            var url = this.href+' div.guest';
            $('#guests_content').fadeOut(200,function(){
                $('#guests_content').load(url,false,function(){
                    $('#guests_content').fadeIn(400);
                });
            });
            return false;
        });
    }
}

function floating_hotel_link(){
    if ($('body').hasClass('location')) {
        $('<a href="http://www.marriott.com/hotels/travel/bwiwf-baltimore-marriott-waterfront/" target="_blank"></a>').css({display:'block',position:'absolute',width:'100px',height:'30px',top:'8%',right:'11%'}).appendTo('#feature');
    }
}

function prepare_ga(){
    if ($('body').hasClass('downloads')) {
        $('.ga').bind('mouseup', function(event) {
            var u = $(this);
            var type = 'Asset';
            if (u.hasClass('wallpaper')) {
                type = 'Wallpaper';
            } else if (u.hasClass('icon')) {
                type = 'Facebook Icon';
            } else if (u.hasClass('video')) {
                type = 'Video';
            } else if (u.hasClass('promo')) {
                type = 'Promo';
            }
            pageTracker._trackEvent(type, 'Download', u.attr('rel'));
            // alert(type+' Download: '+u.attr('rel')); return false;
        });
    }
    $('.ga_reg').bind('click', function(event) {
        pageTracker._trackEvent('Register Now', 'Click');
    });
    $('a[href^=http://]').bind('click', function(event) {
        pageTracker._trackEvent('External Link', 'Click', this.href);
    });
}

$(function() {
    prepare_guests();
    floating_hotel_link();
});