//-----------------------------------------------------------------------------
// quick-donate.js - 8806
// Handle the 'donate amount selection' panel on the main donate page
//-----------------------------------------------------------------------------
$(function() {
    if ($('body').attr('id') == 'donatepage' || $('body').attr('id') == 'donate')
    {
        quick_donate($('body').attr('id'));
    }
});
function quick_donate(id)
{
    $('#gallery').cycle({
        fx:     'fade',
        speed:  2000,
        pager:  '#gallery-nav',
        next: '#gallery'
    });
    var fragment = window.location + '';
    fragment = fragment.substring(fragment.lastIndexOf('#'));
    $('#gallery').css('height', '300px');
    $('#everymonth').click();
    if (fragment != '#regulargiving')
    {
        $('.regulargiving').hide();
    }
    $('.examplesoneoff').hide();
    // Hide unwanted radio buttons
    $('.examplesregular input').css('position', 'absolute');
    $('.examplesregular input').css('left', '-9000px');
    $('.examplesoneoff input').css('position', 'absolute');
    $('.examplesoneoff input').css('left', '-9000px');

    // Add 'regular giving more info' link
    if (id == 'donatepage')
    {
        $('#rglrgiving').before('<a id="rgivingmoreinfo" href="#">How regular giving saves children\'s lives &raquo;</a>');
    }
    else
    {
        $('#everymonth').parent().append('(<a id="rgivingmoreinfo" href="#">how regular giving saves children\'s lives &raquo;</a>)');
    }
    $('#onceonly').click(function() {
        $('.regulargiving').slideUp('slow');
        if (id == 'donatepage')
        {
            $('#rgivingmoreinfo').html('How regular giving saves children\'s lives &raquo;');
        }
        else
        {
            $('#rgivingmoreinfo').html('how regular giving saves children\'s lives &raquo;');
        }
        $('.examplesregular').hide();
        $('.examplesoneoff').show();
    });
    $('#everymonth').click(function() {
        $('.examplesoneoff').hide();
        $('.examplesregular').show();
    });
    $('#rgivingmoreinfo').click(function() {
        if ($('.regulargiving').is(':visible'))
        {
            $('.regulargiving').slideUp('slow');
            if (id == 'donatepage')
            {
                $('#rgivingmoreinfo').html('How regular giving saves children\'s lives &raquo;');
            }
            else
            {
                $('#rgivingmoreinfo').html('how regular giving saves children\'s lives &raquo;');
            }
        }
        else
        {
            $('.regulargiving').slideDown('slow');
            _gaq.push(['_trackEvent', "Click", "Regular giving more info"]);
            if (id == 'donatepage')
            {
                $('#rgivingmoreinfo').html('&laquo; Children need you, not just today but every day');
            }
            else
            {
                $('#rgivingmoreinfo').html('&laquo; children need you, not just today but every day');
            }
        }
        return false;
    });
    $('.examplesregular input[type=radio]').click(function() {
        $('#donate-amount').val($(this).val());
        id = this.id;
        // highlight the label too
        $("label").removeClass('current').filter("[for=" + id + "]").addClass("current");
        // ... and record a google analytics 'hit'
        //urchinTracker("/donate-amount/" + $(this).val());
        _gaq.push(['_trackEvent', "Main donate page", "Click", "Regular giving amount", $(this).val()]);
    });
    $('.examplesoneoff input[type=radio]').click(function() {
        $('#donate-amount').val($(this).val());
        id = this.id;
        // highlight the label too
        $("label").removeClass('current').filter("[for=" + id + "]").addClass("current");
        // ... and record a google analytics 'hit'
        //urchinTracker("/donate-amount/" + $(this).val());
        _gaq.push(['_trackEvent', "Main donate page", "Click", "One-off amount", $(this).val()]);
    });
    $('#donate-amount').change(function() {
        $("label").removeClass('current');
    });
}
 
 
 
