﻿$(function() {
    //all hover and click logic for buttons
    $(".fg-button")
		.hover(
			function() {
			    $(this).addClass("ui-state-hover");
			},
			function() {
			    $(this).removeClass("ui-state-hover");
			}
		)
});

function updateCartTotal_root() {
    $.ajax({
        type: "POST",
        url: "WebService.asmx/GetShoppingCartTotal",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            $("#shoppingCartTotal").text("Total : " + response.d);
        },

        error: function(xhr) {

            if (!error) return;

            if (xhr.responseText) {

                var err = JSON2.parse(xhr.responseText);

                if (err)

                    error(err);

                else

                    error({ Message: "Unknown server error." })

            }

            return;

        }
    });
}

function updateCartTotal() {
    $.ajax({
        type: "POST",
        url: "../WebService.asmx/GetShoppingCartTotal",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            $("#shoppingCartTotal").text("Total : " + response.d);
        },

        error: function(xhr) {

            if (!error) return;

            if (xhr.responseText) {

                var err = JSON2.parse(xhr.responseText);

                if (err)

                    error(err);

                else

                    error({ Message: "Unknown server error." })

            }

            return;

        }
    });
}

// curvycorners
$(function() {

    $("#miniShoppingCart").corner({
        tl: { radius: 6 },
        tr: { radius: 6 },
        bl: { radius: 6 },
        br: { radius: 6 }
    });

    $("#search").corner({
        tl: { radius: 8 },
        tr: { radius: 8 },
        bl: { radius: 8 },
        br: { radius: 8 }
    });

    $("#subscriptions").corner({
        tl: { radius: 8 },
        tr: { radius: 8 },
        bl: { radius: 8 },
        br: { radius: 8 }
    });

    $("#leftMenu").corner({
        tl: { radius: 8 },
        tr: { radius: 8 },
        bl: { radius: 8 },
        br: { radius: 8 }
    });
    
});

// Function to display a jQuery dialog with a custom message
function displayMessage(message) {

    $("#messageText").html(message);

    $("#divMessage").dialog({
        modal: true,
        buttons: {
            Ok: function() {
                $(this).dialog("close");
            }
        }
    });


}

//// Function to display jQuery UI dialog with a custom message
//function displayProgress(message) {

////    if (hide) {

////        $("#divProgress").dialog("close");

////    }
////    else {

//        $("#dialogMessage").html(message);

//        $("#divProgress").dialog({
//            modal: true
//        });

////    }
//    
//}