﻿function showModalLoadingMessage(title) {
    $('#loadingtext').text(title);
    $('#loading').fadeIn('slow');
}

function hideModalLoadingMessage() {
    $('#loading').fadeOut('slow');
}

function HandleDeleteCartItemButton(row) {
    row.find('input:first').val('0');
    row.fadeTo('slow', 0);
}

$(document).ready(function() {

    $('<div class="loading" id="loading"><div id="loadingtext"></div><div id="loadingbar"></div></div>').appendTo('body');

    $('.photozoom').fancybox();

    $('.galleryimage').fancybox({
        'cyclic': true
    });

    $('.enlargebutton').click(function(e) {
        $('.photozoom').trigger('click');
        return false;
    });

    $('.photozoom').loupe({
        width: 200, // width of magnifier
        height: 150, // height of magnifier
        loupe: 'loupe' // css class for magnifier
    });

    $("#flash").delay(4000).slideUp(1000);

    if ($('#shippingAddressSame').is(":checked")) {
        $('#ShippingAddressDiv').before("<div class='note' id='ShippingAddressSameLabel'>Same as billing address</div>");
        $('#ShippingAddressDiv').hide();
    }

    $("#shippingAddressSame").click(function() {

        if ($("#ShippingAddressSameLabel").length == 0) {
            $('#ShippingAddressDiv').before("<div class='note' id='ShippingAddressSameLabel'>Same as billing address</div>");
        }
        if ($('#shippingAddressSame').is(":checked")) {
            $("#ShippingAddressSameLabel").stop(true, true).slideDown();
            $('#ShippingAddressDiv').stop(true, true).fadeOut(1000);
        } else {
            $("#ShippingAddressSameLabel").stop(true, true).slideUp();
            $('#ShippingAddressDiv').stop(true, true).fadeIn(1000);
        }
    });
});