function checkUpload() {
    var value = $('#image').val();
    if (value === 'logoProvidedNow') {
        $('#imageUpload').slideDown();
    } else if (value === 'logoProvidedLater') {
        $('#imageUpload').slideUp();
    }
}

function onLoad() {

    if ($('input[name=paymentMethod]').length) {
        $('input[name=paymentMethod]').click(function(event) {
            var id = $(this).attr('id');
            if (id == 'cheque') {
                $('#manual').show();
                $('#online').hide();
            } else if (id == 'paypal') {
                $('#manual').hide();
                $('#online').show();
            }
        });
    }

    if ($('.right').length) {
        if (typeof jQuery.fn.jScrollable == 'function') {
            $('.right').jScrollable({});
        }
    }

    $('#backToTop a').click(function(e)
    {
        e.preventDefault();
        var id = $(e.target).attr('href');
        $.scrollTo(id, 800);
    });

    if (typeof jQuery.fn.lightBox == 'function') {
        $('.thumbnailLink').lightBox();
    }

    $('div.menu ul ul').each(function(key, value) {
        $(value.parentNode).hover(
            function() {
                $(this).children('ul').slideDown(100);
            },
            function() {
                $(this).children('ul').slideUp(100);
            });
    });

    $('select#option').change(function() {
        var value = $(this).val();
        if ( (value === 'Embroider')
            || (value === 'Screen Print') ) {
            $('#imageSelect').slideDown();
        } else {
            $('#imageSelect').slideUp();
        }
        checkUpload();
    });

    $('select#image').change(function() {
        checkUpload();
    });

}

$(document).ready(onLoad);

