﻿function openF1(type, code)
{
    var churchCode = "/yYNWP0e+7rdNHA6SEZ0Rg==";
    var title = "";

    var url = null;
    switch (type)
    {
        case "create":
            {
                title = "Create Account"
                url = "https://integration.fellowshipone.com/integration/conversion/create.aspx?cCode=" + encodeURI(churchCode);
                break;
            }
        case "update":
            {
                title = "My Account"
                url = "https://integration.fellowshipone.com/integration/profileEditor.aspx?cCode=" + encodeURI(churchCode);
                break;
            }
        case "giving":
            {
                title = "Give Online"
                url = "https://integration.fellowshipone.com/integration/contribution/onlinecontribution.aspx?cCode=" + encodeURI(churchCode);
                break;
            }
        case "eventRegistration":
            {
                title = "Register"
                url = "https://integration.fellowshipone.com/integration/registration/eventregistration.aspx?cCode=" + encodeURI(churchCode) + "&fCode=" + encodeURI(code);
                break;
            }
        case "customRegister":
            {
                title = "Register"
                url = "https://integration.fellowshipone.com/integration/FormBuilder/FormBuilder.aspx?cCode=" + encodeURI(churchCode) + "&fCode=" + encodeURI(code);
                break;
            }
        case "loginHelp":
            {
                title = "My Account"
                url = "https://integration.fellowshipone.com/integration/loginhelp.aspx?cCode=" + encodeURI(churchCode);
                break;
            }
        case "resetPassword":
            {
                title = "My Account"
                url = "https://integration.fellowshipone.com/integration/resetpassword.aspx?cCode=" + encodeURI(churchCode);
                break;
            }
        case "groupFinder":
            {
                title = "Group Finder"
                url = "https://integration.fellowshipone.com/integration/activityfinder/activityfinder.aspx?cCode=" + encodeURI(churchCode) + "&mCode=J0JzfLVEKnSgY1UpRSDCnQ==" + code;
                break;
            }
        case "groupManager":
            {
                title = "Group Manager"
                //I odn't know what the acode is at the end of this
                url = "https://integration.fellowshipone.com/integration/smallgroup/sgmembers.aspx?cCode=" + encodeURI(churchCode) + "&aCode=" + code + "&icode=" + f1ID;
                break;
            }
        case "f1Contact":
            {
                title = "Contact"
                url = "https://integration.fellowshipone.com/integration/contact/onlinecontact.aspx?cCode=" + encodeURI(churchCode) + "&ctCode=" + code;
                break;
            }
        case "volunteer":
            {
                title = "Volunteer"
                url = "https://integration.fellowshipone.com/integration/volunteer/volunteerapplication.aspx?cCode=" + encodeURI(churchCode) + "&appCode=" + code + "&icode=" + f1ID;
                break;
            }
    }


    //alert(url)
    //$(function(e)
    //{
    //e.preventDefault();
    var $this = $(this);
    var horizontalPadding = 30;
    var verticalPadding = 30;
    $('<iframe id="externalSite" class="externalSite" src="' + url + '" />').dialog({
        title: ($this.attr('title')) ? $this.attr('title') : title,
        autoOpen: true,
        width: 800,
        height: 600,
        modal: true,
        resizable: true,
        autoResize: true,
        overlay: {
            opacity: 0.5,
            background: "black"
        }
    }).width(800 - horizontalPadding).height(600 - verticalPadding);
    // });
}
