﻿jQuery(document).ready(function() {
    jQuery(".sendDialog").dialog({
        bgiframe: true, autoOpen: false, height: 220, width: 500, modal: true
    });

    $(".sendDialog").bind("dialogbeforeclose", function(event, ui) {
        resetSendDialog();
        return true;
    });

    $(".dialogClose").click(function() {
        $('.sendDialog').dialog('close');
    });
});

//reset sendDialog
function resetSendDialog() {
    $("#sendResp").html("");
    $(".dialogSendButton").show();
    $(".dialogCloseButton").hide();

}

//handle dialogs that use send/close approach
function toggleDialogClose() {

    try {
        $(".dialogSendButton").hide();
        $(".dialogCloseButton").show();
    } catch (err) { }
}


//fb-related funcionts from the toolkit share page
function addFacebookPermissions() {
    FB.Connect.showPermissionDialog(
		"publish_stream,create_event",
		permissionHandler);
}

function permissionHandler(response) {
    $("#checkFbSettings").html("All Set!");
    try {
        pageTracker._trackEvent("FbConnect", "PermissionsSet", "PermissionsSet", 1);
    } catch (err) { }
}

function publishComplete(ajaxContext) {
    try {
        pageTracker._trackEvent("FbConnect", "PublishEvent", "PublishEvent", 1);
    } catch (err) { }
}