$(document).ready( function() {

    pic1 = new Image();
    pic1.src="images/home_hover.png";

    pic2 = new Image();
    pic2.src="images/order_hover.png";

    pic3 = new Image();
    pic3.src="images/faq_hover.png";

    pic4 = new Image();
    pic4.src="images/contact_hover.png";

    $(".home").hover( function () {
        $(".home").attr('src','images/home_hover.png');
    }, function () {
        $(".home").attr('src','images/home.png');
    }
    );

    $(".order").hover( function () {
        $(".order").attr('src','images/order_hover.png');
    }, function () {
        $(".order").attr('src','images/order.png');
    }
    );

    $(".faq").hover( function () {
        $(".faq").attr('src','images/faq_hover.png');
    }, function () {
        $(".faq").attr('src','images/faq.png');
    }
    );

    $(".contact").hover( function () {
        $(".contact").attr('src','images/contact_hover.png');
    }, function () {
        $(".contact").attr('src','images/contact.png');
    }
    );

    $( "#questions a" ).each( function(index) {
        $(this).attr('href','#'+parseInt(index+1,10));
    });
    $( "#answers h3" ).each( function(index) {
        $(this).attr('id',parseInt(index+1,10));
    });
    $('#name').focus();
    $('#firstname').focus();
    $('#username').focus();

    $('[name=paypal_address]').click( function() {

        if ($('#email').val() == '') {
            alert('Please enter your e-mail address before selecting your PayPal Address');
            $('[name=paypal_address]').attr('checked','');
            return false;
        } else {

            is_paypal_address = $(this).val();

            $('#paypal_email_address').val($('#email').val());
            $('#confirm_paypal_email_address').val($('#email').val());

            if (is_paypal_address == 'Yes') {
                $('.paypal_email_address').slideUp( function() {

                });
            } else {
                $('#paypal_email_address').val('');
                $('#confirm_paypal_email_address').val('');
                $('.paypal_email_address').slideDown();
            }

        }

    });
    $('.show_details').click( function() {

        if ($('.update_details_form').is(":visible")) {

            $('.update_details_form').slideUp('slow');

            $('.show_details').html('Click here to show your account information.');

        } else {

            $('.update_details_form').slideDown('slow');

            $('.show_details').html('Click here to hide your account information.');

        }

        return false;
    });
    $('.show_detailed').click( function() {

        if ($('.detailed_account_info').is(":visible")) {

            $('.detailed_account_info').slideUp('slow');

            $('.show_detailed').html('Click here to show detailed balance information.');

        } else {

            $('.detailed_account_info').slideDown('slow');

            $('.show_detailed').html('Click here to hide detailed balance information.');

        }

        return false;
    });
});
