package admin.util
{
    import admin.conn.*;
    import admin.model.*;
    import com.adobe.serialization.json.*;
    import flash.external.*;

    public class FuncUtil extends Object
    {
        private static var _instance:FuncUtil = null;

        public function FuncUtil()
        {
            return;
        }// end function

        private function init() : void
        {
            if (ExternalInterface.available)
            {
                ExternalInterface.addCallback("setUserAS", this.setUser);
            }
            return;
        }// end function

        private function setUser(param1:String) : Boolean
        {
            var _loc_2:* = param1;
            UserModel.instance.email = _loc_2.email;
            UserModel.instance.password = _loc_2.password;
            var _loc_3:* = new Object();
            _loc_3.cmd = 65538;
            _loc_3.Name = UserModel.instance.email;
            _loc_3.Pwd = UserModel.instance.password;
            AdminConn.instance.send(_loc_3);
            return true;
        }// end function

        public function callUser(param1:Object = null) : void
        {
            var _loc_2:String = null;
            try
            {
                _loc_2 = JSON.encode(param1);
                if (ExternalInterface.available)
                {
                    ExternalInterface.call("setUser", _loc_2);
                }
            }
            catch (e:Error)
            {
            }
            return;
        }// end function

        public function getUser() : String
        {
            var _loc_1:String = null;
            var _loc_2:Object = null;
            if (ExternalInterface.available)
            {
                _loc_1 = ExternalInterface.call("getUser");
                _loc_2 = JSON.decode(_loc_1);
                UserModel.instance.email = _loc_2.email;
                UserModel.instance.password = _loc_2.password;
                return _loc_1;
            }
            return null;
        }// end function

        public static function get instance() : FuncUtil
        {
            if (!_instance)
            {
                _instance = new FuncUtil;
            }
            return _instance;
        }// end function

    }
}
