

/**
* social_controller
*
* sogden 8-18-11 IDSTARZDOTCOM-2250
*
*/

(function ($) {
    function SocialController() {
        // Set default properties.
        this.name = ("socialController-" + (new Date()).getTime());
        // Gigya Login Parameters
        this.loginParams = {
            useHTML: 'true',
            // This parameter defines the time in seconds that Gigya should keep the login session valid for the user. To end the session when the browser closes, please assign the value '0'. If this parameter is not specified, the session will be valid forever.
            //sessionExpiration: 0,
            showTermsLink: 'false',
            lastLoginIndication: 'none',
            height: 25,
            width: 128,
            containerID: 'social_icons',
            hideGigyaLink: true,
            UIConfig: '<config><body><texts color="#286D51"><links color="#6D6DFF"></links></texts><controls><snbuttons buttonsize="20"></snbuttons></controls><background background-color="Transparent" frame-color="Transparent"></background></body></config>'
        };
        // Gigya API Key
        this.conf = {
            APIKey: AppVars.GigyaApiKey,
            enabledProviders: 'facebook,twitter,yahoo,messenger',
            connectWithoutLoginBehavior: 'loginExistingUser'
        };
        // The Starz AJAX Service Path
        this.servicePath = AppVars.RegisterServiceEndpoint;
        // Gigya User
        this.gigyaUser = "";
        this.noRefreshFlag = false;
    }



    // ----------------------------------------------------------------------- //
    // Init page
    // ----------------------------------------------------------------------- //
    SocialController.prototype.init = function () {
        this.getUserInfo();
    }

    // ----------------------------------------------------------------------- //
    // Setup Gigya
    // ----------------------------------------------------------------------- //
    SocialController.prototype.getUserInfo = function () {
        gigya.services.socialize.getUserInfo(socialController.conf, { callback: socialController.onGetUserInfo });
        gigya.services.socialize.addEventHandlers(socialController.conf, {
            onConnectionAdded: socialController.onConnectionAdded,
            onConnectionRemoved: socialController.onConnectionRemoved
        });
    };

    // ---------------------------------------------------------------------- //
    // Connection Listeners
    // ---------------------------------------------------------------------- //

    SocialController.prototype.onGetUserInfo = function (event) {
        socialController.renderSocialHeader(event);
        $.event.trigger("onGetUserInfoSuccess", ["onGetUserInfo"]);
    }

    SocialController.prototype.onConnectionAdded = function (event) {
        socialController.renderSocialHeader(event);
        $.event.trigger("onGetUserInfoSuccess", ["onConnectionAdded"]);
    }

    SocialController.prototype.onConnectionRemoved = function (event) {
        socialController.renderSocialHeader(event);
        $.event.trigger("onGetUserInfoSuccess", ["onConnectionRemoved"]);
    }



    // ----------------------------------------------------------------------- //
    // Link Account
    // ----------------------------------------------------------------------- //
    SocialController.prototype.autoLinkAccount = function () {
        $("#auto_link_errors").html("");
        $('#dialog-form').block();
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: socialController.servicePath + "AutoLinkAccount",
            data: '{UIDSignature:"' + socialController.gigyaUser.UIDSig + '", signatureTimestamp:"' + socialController.gigyaUser.timestamp + '", gigyaUID:"' + socialController.gigyaUser.UID + '"}',
            success: function (response) {
                // the user is unknown
                // display the register or link dialog
                var errorCode = response.d.errorCode;
                // failure
                if (errorCode != 0) {
                    $("#auto_link_errors").html(response.d.errorMsg);
                    $('#dialog-form').unblock();
                } else {
                    // I wish these worked.
                    //window.location.href = window.location.href;
                    //history.go(0);
                    //alert(window.location.href);
                    window.location.reload();
                    //window.location.href="/";
                }


            },
            error: function (xhr, ajaxOptions, thrownError) {

                $('#dialog-form').unblock();
                //alert(xhr.status);
                //alert(thrownError);
            }
        });
    };


    // ----------------------------------------------------------------------- //
    // User Rates Title
    // ----------------------------------------------------------------------- //
    SocialController.prototype.userRatesTitle = function () {
        $("#auto_link_errors").html("");
        $('#dialog-form').block();
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: socialController.servicePath + "RateTitle",
            data: '{titleId:226, episodeNbr:-1, rating:5}',
            success: function (response) {
                // the user is unknown
                // display the register or link dialog
                var errorCode = response.d.errorCode;
                // failure
                if (errorCode != 0) {
                    $("#auto_link_errors").html(response.d.errorMsg);
                    $('#dialog-form').unblock();
                } else {
                    // I wish these worked.
                    //window.location.href = window.location.href;
                    //history.go(0);
                    //alert(window.location.href);
                    window.location.reload();
                    //window.location.href="/";
                }


            },
            error: function (xhr, ajaxOptions, thrownError) {

                $('#dialog-form').unblock();
                //alert(xhr.status);
                //alert(thrownError);
            }
        });
    };


    // ----------------------------------------------------------------------- //
    // Show the Gigya Login
    // ----------------------------------------------------------------------- //
    SocialController.prototype.gigyaShowLoginUI = function () {
        // show the login UI
        gigya.services.socialize.showLoginUI(socialController.conf, socialController.loginParams);

        // register for login event  
        gigya.services.socialize.addEventHandlers(socialController.conf, {
            context: { str: 'congrats on your' },
            onLogin: socialController.onLoginHandler,
            onLogout: socialController.onLogoutHandler
        });
    };

    // ----------------------------------------------------------------------- //
    // On Login Handler
    // ----------------------------------------------------------------------- //
    SocialController.prototype.onLoginHandler = function (response) {
        //alert(eventObj.context.str + ' ' + eventObj.eventName + ' to ' + eventObj.provider + '!\n' + eventObj.provider + ' user ID: ' + eventObj.user.identities[eventObj.provider].providerUID);  
        // in some cases we don't want to reload the page upon logging in
        if (!socialController.noRefreshFlag) {
            socialController.renderSocialHeader(response);
            registerLoginController.renderDialogOnGiyaLogin(response.user);
        } else {
            socialController.gigyaUser = response.user;
        }
        $.event.trigger("onGetUserInfoSuccess", ["onLoginHandler"]);
    };

    // ----------------------------------------------------------------------- //
    // On Log Out Handler
    // ----------------------------------------------------------------------- //
    SocialController.prototype.onLogoutHandler = function () {
        window.location.href = "/";
    };

    // ----------------------------------------------------------------------- //
    // Getter : Is Logged Into Gigya
    // ----------------------------------------------------------------------- //
    SocialController.prototype.isLoggedIntoGigya = function () {
        if (socialController.gigyaUser == "") {
            return false;
        } else {
            if (socialController.gigyaUser != null) {
                if (socialController.gigyaUser.isLoggedIn) {
                    return true;
                } else {
                    return false;
                }
            }
            else {
                return false;
            }
        }
    };

    // ----------------------------------------------------------------------- //
    // Is User Connected
    // ----------------------------------------------------------------------- //
    SocialController.prototype.isUserConnected = function () {

        // http://devjira1.automation.private:8080/browse/IDSTARZDOTCOM-1800
        // note - you can link an existing starz account to gigya, then open myStarz, then 'disconnect' the connections...
        // this creates a funky gigya user that is logged in, but NOT connected
        // See @register_login_controller.getLoginState() for usage

        if (!socialController.gigyaUser) return false;
        return socialController.gigyaUser.isConnected;
    };

    // ----------------------------------------------------------------------- //
    // Is Logged Into Social Network
    // ----------------------------------------------------------------------- //
    SocialController.prototype.isLoggedIntoSocialNetwork = function (socialNetwork) {

        if (!socialController.gigyaUser) return false;
        if (!socialController.gigyaUser.isConnected) return false;
        return ($.inArray(socialNetwork, socialController.gigyaUser.providers) > -1);

    };

    // ----------------------------------------------------------------------- //
    // Is User Linked
    // ----------------------------------------------------------------------- //
    SocialController.prototype.isUserLinked = function () {
        return (socialController.isLoggedIntoGigya() && socialController.gigyaUser.isSiteUID);
    };


    // ----------------------------------------------------------------------- //
    // Render Social Header
    // ----------------------------------------------------------------------- //
    SocialController.prototype.renderSocialHeader = function (evt) {

        if (evt != undefined) {
            socialController.gigyaUser = evt.user;
        }
        registerLoginController.renderHeader();

        if (registerLoginController.getParameterByName("logout") == "true") {
            registerLoginController.consoleLog("Detected Logout from Query String");
            alert("Clicking OK will successfully log you out of Starz.com.");
            registerLoginController.logout("force_reload");
        }


        if (registerLoginController.getParameterByName("modal_register") == "true" && !registerLoginController.isLoggedIntoStarz()) {
            registerLoginController.showRegisterLogin("");
        }

    }


    // ----------------------------------------------------------------------- //
    // Social Profile
    // ----------------------------------------------------------------------- //
    SocialController.prototype.showSocialProfile = function (user) {
        $("#profile_name").html(user.nickname + "!");
        if (user.thumbnailURL.length > 0) {
            $("#profile_image").attr("src", user.thumbnailURL);
        } else {
            $("#profile_image").attr("src", "http://cdn.gigya.com/site/images/bsAPI/Placeholder.gif");
        }
        $("#profile").fadeIn();
        $("#profile_image").fadeIn();

    };

    SocialController.prototype.hideSocialProfile = function () {
        $("#profile").fadeOut();
        $("#profile_image").fadeOut();
    }

    // ----------------------------------------------------------------------- //
    // Delete Account
    // ----------------------------------------------------------------------- //
    SocialController.prototype.deleteAccount = function (eventObj) {
        gigya.services.socialize.deleteAccount(socialController.conf, { callback: this.accountDeletedHandler });
    };

    SocialController.prototype.accountDeletedHandler = function (eventObj) {
        alert("account deleted")
    };


    // ----------------------------------------------------------------------- //
    // Verify the Signature
    // ----------------------------------------------------------------------- //
    SocialController.prototype.isUserKnown = function (user) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: socialController.servicePath + "IsUserKnown",
            data: '{UIDSignature:"' + user.UIDSignature + '", signatureTimestamp:"' + user.signatureTimestamp + '", UID:"' + user.UID + '"}',
            success: function (response) {
                var userKnown = response.d;
                if (userKnown) {
                    // the user is unknown
                    // display the register or link dialog
                    //window.location.href = window.location.href;
                    window.location.reload();
                } else {
                    // the user is known, and now logged in
                    registerLoginController.showRegisterLogin(); //reload the page					
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                // alert(xhr.status);
                // alert(thrownError);
            }
        });
    };



    // ----------------------------------------------------------------------- //
    // Link Account
    // ----------------------------------------------------------------------- //
    SocialController.prototype.linkAccount = function (gigyaUser, stzUserName, stzPassword, rememberMe) {
        var referrer = registerLoginController.getParameterByName("referrer");

        $('.registration_wrapper').block();
        $("#login_errors").hide();
        var hashed = true;

        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: socialController.servicePath + "LinkAccount",
            data: '{UIDSignature:"' + gigyaUser.UIDSignature + '", signatureTimestamp:"' + gigyaUser.signatureTimestamp + '", gigyaUID:"' + gigyaUser.UID + '", stzUserName:"' + stzUserName + '", stzPassword:"' + stzPassword + '", rememberMe:' + rememberMe + ', hashed: ' + hashed.toString() + ', referrer:"' + referrer + '"}',
            success: function (response) {
                var serviceResponse = response.d;
                if (serviceResponse.errorCode == 0) {
                    // account successfully linked
                    if (response.d.referrer != "") {
                        window.location = response.d.referrer;
                    } else {
                        window.location.reload();
                    }
                }
                else {
                    // account not linked, there was an error
                    var errorMsg = serviceResponse.errorMsg;
                    $("#login_errors").html(errorMsg).show();
                    $('.registration_wrapper').unblock();
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                //alert(xhr.status);
                //alert(thrownError);
                $('.registration_wrapper').unblock();
            }
        });
    };

    // ----------------------------------------------------------------------- //
    // Get Starz User Information
    // ----------------------------------------------------------------------- //
    SocialController.prototype.getStarzUserInfo = function (userId) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            url: socialController.servicePath + "GetStarzUserInfo",
            data: '{userId:"' + userId + '"}',
            success: function (response) {
                socialController.processStarzUserResponse(response);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                // alert(xhr.status);
                // alert(thrownError);
            }
        });
    };



    // ----------------------------------------------------------------------- //
    // Process Starz User Response
    // ----------------------------------------------------------------------- //
    SocialController.prototype.processStarzUserResponse = function (response) {
        // the result is an array: ["true", "userobject"]
        // ["false", "socialUserObject"]
        //alert(result);
        $.blockUI({ message: $('#MyStarzModal') });
        if (result && result.length > 0) {
            //$.blockUI({ message: "<h1>Remote call in progress...</h1>" });
            if (result[0] == "true") {
                var user = result[1];
                // update the ui (top login)
            } else {
                var socialUser = result[1];
                // pop open the registration and account link ui
                socialController.popRegistrationAndAccountDialog(socialUser);
            }
        }

    };

    // ----------------------------------------------------------------------- //
    // Show the Gigya EditConnections UI Plugin
    // ----------------------------------------------------------------------- //

    SocialController.prototype.showEditConnectionsUI = function (aContainerID) {

        var lParamsObj = this.gigyaGetEditConnectionsUIParams(aContainerID,
                                                                this.gigyaOnShowEditConnectionsUILoad,
                                                                this.gigyaOnShowEditConnectionsUIClose,
                                                                this.gigyaOnShowEditConnectionsUIError);

        gigya.services.socialize.showEditConnectionsUI(socialController.conf, lParamsObj);
    };

    SocialController.prototype.gigyaGetEditConnectionsUIParams = function (aContainerID,
                                                                            aOnLoadCallback,
                                                                            aOnCloseCallback,
                                                                            aOnErrorCallback) {

        var tUIConfig = "<config><body><texts color=\"#00006D\"></texts><header background-color=\"#CACACA\" ></header></body></config>";

        // bypass containerID until marketing figures out what they want
        //      so just make it a popup!@

        var tParams = {

            width: 480,                 // integer
            //height: 200,                // integer
            //containerID: aContainerID,  // An ID of a <DIV> element on the page in which you want to display the Plugin. If this parameter is not provided then the Plugin will be displayed as a popup at the center of the page.
            //captionText: "",            // Sets the caption text. This parameter is relevant only when the Plugin is in a popup mode
            //context: ? ,              // A reference to a developer created object that will be passed back unchanged to the event handlers of any event triggered as a consequence of using this Plugin.
            //UIConfig: tUIConfig,        // An XML string describing changes to the default design of the Plugin.   
            showTermsLink: false,       // Show or hide the "Terms" link. Clicking the "Terms" link opens Gigya's Legal Notices page.
            //enabledProviders: ?,      // A comma delimited list of providers that should be displayed on this Plugin. The value of this parameter overrides the value of the identical parameter in the Conf object.
            //disabledProviders: ?,
            showTooltips: true,         // This parameter's default value is 'false'. If set to 'true', a tooltip will be displayed when mouse hover over a social network icon. The tooltip presents the social network's full name.
            //sessionExpiration: ?,     // This parameter defines the time in seconds that Gigya should keep the social network session valid for the user. To end the session when the browser closes, please assign the value '0'. If this parameter is not specified, the session will be valid forever.
            //cid: ?,                   // A string of maximum 100 characters length. This string is associated with each transaction and will later appear on reports generated by Gigya in the "Context ID" combo box. 

            hideGigyaLink: true,

            onLoad: aOnLoadCallback,    // A reference to an event handler function that will be called when the Plugin has finished drawing itself.
            onClose: aOnCloseCallback,  // A reference to an event handler function that will be called when the Plugin is closing
            onError: aOnErrorCallback   // A reference to an event handler function that will be called when an error occurs.
        };

        return tParams;
    };

    SocialController.prototype.gigyaOnShowEditConnectionsUILoad = function (evt) {
        //alert('gigyaOnShowEditConnectionsUILoad');
    };

    SocialController.prototype.gigyaOnShowEditConnectionsUIClose = function (evt) {
        //alert('gigyaOnShowEditConnectionsUIClose');
    };

    SocialController.prototype.gigyaOnShowEditConnectionsUIError = function (evt) {
        //alert('gigyaOnShowEditConnectionsUIError');
    };


    // ----------------------------------------------------------------------- //
    // Show the Gigya ShareUI Plugin
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaShowShareUI = function (aParamsObj) {
        gigya.services.socialize.showShareUI(socialController.conf, aParamsObj);
    };

    SocialController.prototype.gigyaGetShareUIParams = function (aUserAction,
                                                                aOnLoadCallback,
                                                                aOnCloseCallback,
                                                                aOnErrorCallback,
                                                                aOnSendDoneCallback) {
        var tParams = {
            userAction: aUserAction,
            grayedOutScreenOpacity: 60, 							    // 0 - 100
            operationMode: "multiSelect", 								// multiSelect | simpleShare | autoDetect
            initialView: 'share', 										// share | more | email
            enabledProviders: socialController.conf.enabledProviders,
            defaultProviders: 'facebook',
            successMessage: 'true',
            shortURLs: 'whenRequired', 								    // always | whenRequired | never
            sessionExpiration: 0,
            showMoreButton: false,
            showEmailButton: false,
            showAlwaysShare: 'hide', 								    // hide | checked | unchecked
            onLoad: aOnLoadCallback,
            onClose: aOnCloseCallback,
            onError: aOnErrorCallback,
            onSendDone: aOnSendDoneCallback
        };

        return tParams;
    };

    // ----------------------------------------------------------------------- //
    // Show the Gigya ShareUI Plugin via HTML/Javascript
    //
    //      Shares an array of IMAGE objects
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaShowShareUIJS = function (aEmbedPath,
                                                                aEmbedImageArray,
                                                                aEmbedTitle,
                                                                aEmbedLinkBack,
                                                                aEmbedDescription) {
        socialController.noRefreshFlag = true;	
        var tUserAction;
		if( typeof(aEmbedImageArray) != "undefined" ) tUserAction = this.gigyaGetShareImagesUserAction(aEmbedImageArray, aEmbedPath);
		else tUserAction = this.gigyaGetUserAction();

        tUserAction.setUserMessage("enter a message...");
        tUserAction.setTitle(aEmbedTitle);
        tUserAction.setLinkBack(aEmbedLinkBack);
        tUserAction.setDescription(aEmbedDescription);

        var tParams = this.gigyaGetShareUIParams(tUserAction,
                                                    this.gigyaOnShowShareUIJSLoad,
                                                    this.gigyaOnShowShareUIJSClose,
                                                    this.gigyaOnShowShareUIJSError,
                                                    this.gigyaOnShowShareUIJSSendDone);

        this.gigyaShowShareUI(tParams);
    }

    SocialController.prototype.afterShareCallback = function () {
        if (socialController.noRefreshFlag) {
            socialController.noRefreshFlag = false;
            // if the user is linked we need to refresh, if not we need to display the link dialog
            registerLoginController.renderHeader();
        }
    };

    SocialController.prototype.gigyaOnShowShareUIJSLoad = function (evt) {
        //alert('gigyaOnShowShareUIJSLoad');
    };

    SocialController.prototype.gigyaOnShowShareUIJSClose = function (evt) {
        //alert('gigyaOnShowShareUIJSClose');
        socialController.afterShareCallback();
    };

    SocialController.prototype.gigyaOnShowShareUIJSError = function (evt) {
        //alert('gigyaOnShowShareUIJSError');
    };

    SocialController.prototype.gigyaOnShowShareUIJSSendDone = function (evt) {
        //alert('gigyaOnShowShareUIJSSendDone');
    };

    // ----------------------------------------------------------------------- //
    // Show the Gigya ShareUI Plugin from Flash
    //
    //      Share a VIDEO object
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaShareVideoFlash = function (aEmbedVideoSrc,
                                                                aEmbedImageSrc,
                                                                aEmbedTitle,
                                                                aEmbedLinkBack,
                                                                aEmbedDescription) {

        socialController.noRefreshFlag = true;

        // for now, just share a single image
        var tUserAction = this.gigyaGetShareVideoUserAction(aEmbedVideoSrc, aEmbedImageSrc);

        tUserAction.setUserMessage("enter a message...");
        tUserAction.setTitle(aEmbedTitle);
        tUserAction.setLinkBack(aEmbedLinkBack);
        tUserAction.setDescription(aEmbedDescription);

        var tParams = this.gigyaGetShareUIParams(tUserAction,
                                                    this.gigyaOnShowShareUIFlashLoad,
                                                    this.gigyaOnShowShareUIFlashClose,
                                                    this.gigyaOnShowShareUIFlashError,
                                                    this.gigyaOnShowShareUIFlashSendDone);
        socialController.gigyaShowShareUI(tParams);
    };

    SocialController.prototype.gigyaOnShowShareUIFlashLoad = function (evt) {
        //alert('gigyaOnShowShareUIFlashLoad');
        socialController.gigyaGetStarzVideoPlayer().gigyaShareVideoFlashCallback('onShowShareUILoad', evt);
    };

    SocialController.prototype.gigyaOnShowShareUIFlashClose = function (evt) {
        //alert('gigyaOnShowShareUIFlashClose');
        socialController.gigyaGetStarzVideoPlayer().gigyaShareVideoFlashCallback('onShowShareUIClose', evt);
        socialController.afterShareCallback();
    };

    SocialController.prototype.gigyaOnShowShareUIFlashError = function (evt) {
        //alert('gigyaOnShowShareUIFlashError');
        socialController.gigyaGetStarzVideoPlayer().gigyaShareVideoFlashCallback('onShowShareUIError', evt);
    };

    SocialController.prototype.gigyaOnShowShareUIFlashSendDone = function (evt) {
        //alert('gigyaOnShowShareUIFlashSendDone');
        socialController.gigyaGetStarzVideoPlayer().gigyaShareVideoFlashCallback('onShowShareUISendDone', evt);
    };

    // ----------------------------------------------------------------------- //
    // Get a generic userAction object
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaGetUserAction = function () {
        return new gigya.services.socialize.UserAction();
    };

    // ----------------------------------------------------------------------- //
    // Get a userAction object with a flash 'video' element
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaGetShareVideoUserAction = function (aEmbedVideoSrc, aEmbedImageSrc) {
        var tUserAction = this.gigyaGetUserAction();

        var tVideo = {
            type: 'flash',
            src: aEmbedVideoSrc,
            previewImageURL: aEmbedImageSrc
        }

        tUserAction.addMediaItem(tVideo);

        return tUserAction;
    };

    // ----------------------------------------------------------------------- //
    // Get a userAction object with a series 'image' elements
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaGetShareImagesUserAction = function (aEmbedImageArray, aEmbedPath) {

        var tUserAction = this.gigyaGetUserAction();
        var tEmbedImages = aEmbedImageArray.split("||"); // the first item is intentionally blank

        /*
        var tLen = tEmbedImages.length; if (tLen > 3) tLen = 3; // up to 5 images are allowed      

        for (var i = 0; i < tLen; i++) {

        var tEmbedImage = tEmbedImages[i];

        if (tEmbedImage != "") {

        var image = {
        type: 'image',
        src: tEmbedImage,
        href: aEmbedPath
        }

        //alert(image);

        tUserAction.addMediaItem(image);
        }
        }
        */

        var tEmbedImage = tEmbedImages[1];
        //var tEmbedImage = "http://www.starz.com/originals/spartacus/Episode1PastTransgressions/PublishingImages/spartacus_gods_of_the_arena_episode_1_2011_685x385.jpg";

        var tImage = {
            type: 'image',
            src: tEmbedImage,
            href: aEmbedPath
        }

        tUserAction.addMediaItem(tImage);

        return tUserAction;
    };

    // ----------------------------------------------------------------------- //
    // Get a userAction object with a 'image' element
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaGetShareImageUserAction = function (aImageSrc, aImageHref) {

        var tUserAction = this.gigyaGetUserAction();

        var image = {
            type: 'image',
            src: aImageSrc,
            href: aImageHref
        }

        tUserAction.addMediaItem(image);

        return tUserAction;
    };

    // ----------------------------------------------------------------------- //
    // Get the starzVideoPlayer object element
    // ----------------------------------------------------------------------- //

    SocialController.prototype.gigyaGetStarzVideoPlayer = function (aEmbedPath, aEmbedImage) {
        return swfobject.getObjectById("StarzVideoPlayer");
    }



    // ----------------------------------------------------------------------- //
    // ----------------------------------------------------------------------- //


    // Create a new instance of the socialController and store it in the window.
    window.socialController = new SocialController();

    // Return a new socialController instance.
    return (window.socialController);

})(jQuery);


// ----------------------------------------------------------------------- //
// Global Properties
// ----------------------------------------------------------------------- //





