package classes.matuto.social
{
    import flash.display.*;
    import flash.net.*;
    
    public class ShareAPI extends flash.display.Sprite
    {
        public function ShareAPI(arg1:String="")
        {
            super();
            this.username = arg1;
            return;
        }

        public function share(arg1:String, arg2:String="menu", arg3:Object=null):void
        {
            var loc2:*=null;
            arg3 = arg3 || {};
            var loc1:*=new flash.net.URLVariables();
            var loc4:*=0;
            var loc5:*=DEFAULT_OPTIONS;
            for (loc2 in loc5)
            {
                if (!(DEFAULT_OPTIONS[loc2] || arg3[loc2]))
                {
                    continue;
                }
                loc1[loc2] = arg3[loc2] || DEFAULT_OPTIONS[loc2];
            }
            loc1.url = arg1;
            if (stage)
            {
                if (loc1.width == -1)
                {
                    loc1.width = stage.stageWidth;
                }
                if (loc1.height == -1)
                {
                    loc1.height = stage.stageHeight;
                }
            }
            if (username)
            {
                loc1.username = username;
            }
            if (arg2 == "menu")
            {
                arg2 = "";
            }
            var loc3:*;
            (loc3 = new flash.net.URLRequest(ENDPOINT + (arg2 ? "/" + arg2 : "") + "/offer")).data = loc1;
            flash.net.navigateToURL(loc3, "_blank");
            return;
        }

        public static const ENDPOINT:String="http://api.addthis.com/oexchange/0.8/forward";

        private static const DEFAULT_OPTIONS:Object={"url":"", "swfurl":"", "width":-1, "height":-1, "title":"", "description":"", "screenshot":""};

        private var username:String;
    }
}
