Advertisement
Guest User

Untitled

a guest
May 3rd, 2011
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 255.62 KB | None | 0 0
  1. document.domain = 'myfreecams.com';
  2. var w = window;
  3. var d = document;
  4. var t = this;
  5.  
  6.  
  7.  
  8. //---
  9. var g_bDebug = (top.location.search.indexOf("debug") > -1) ? true : false;
  10. var g_bLogWriteLock = false;
  11. var g_sLogBuffer = '';
  12. var g_bLogPause = false;
  13. var g_bLogRealtime = (location.search.indexOf("ncdebug") > -1) ? true : false;
  14. document.onmousedown = onMouseDown_Handler;
  15. var g_hCk = {};
  16. UpdateCookieHash();
  17. var g_fBodyLoaded = false;
  18. var sDefaultTarget = 'new_window';
  19. var sMainTarget = 'main';
  20. var g_nZgwLoaded = 0;
  21. var g_nLogCx = 0;
  22. var g_sLogDump = ' ';
  23. var g_hCache = {
  24.     a_tags: {}
  25. };
  26. var g_bLoadChat = 0;
  27. var g_oStartLogTime;
  28. var g_oLastLogTime;
  29. var g_TestMode = (top.location.search.indexOf('test') > -1) ? 1 : 0;
  30. var g_hGroupShowInitiators = {};
  31. var g_hSharedVideo = {};
  32. var g_aPreviousMessages = [];
  33. var g_hServerMap = {
  34.     11: 1,
  35.     12: 2,
  36.     13: 3,
  37.     14: 4,
  38.     19: 9,
  39.     24: 14,
  40.     29: 19,
  41.     34: 24,
  42.     39: 29,
  43.     44: 34,
  44.     49: 39,
  45.     54: 44,
  46.     59: 49,
  47.     94: 54,
  48.     99: 59,
  49.     104: 64,
  50.     109: 69,
  51.     114: 74,
  52.     119: 79,
  53.     120: 80,
  54.     121: 81,
  55.     122: 82,
  56.     123: 83,
  57.     124: 84,
  58.     125: 85,
  59.     126: 86,
  60.     127: 87,
  61.     128: 88,
  62.     149: 112,
  63.     153: 116,
  64.     157: 120,
  65.     161: 124,
  66.     165: 128,
  67.     169: 132,
  68.     181: 144,
  69.     185: 148,
  70.     199: 162,
  71.     203: 166,
  72.     207: 170,
  73.     211: 174,
  74.     215: 178,
  75.     219: 182,
  76.     237: 200,
  77.     241: 204,
  78.     245: 208,
  79.     249: 212,
  80.     253: 216,
  81.     257: 220
  82. };
  83. w.FCTYPE_NULL = 0;
  84. w.FCTYPE_LOGIN = 1;
  85. w.FCTYPE_ADDFRIEND = 2;
  86. w.FCTYPE_PMESG = 3;
  87. w.FCTYPE_STATUS = 4;
  88. w.FCTYPE_DETAILS = 5;
  89. w.FCTYPE_TOKENINC = 6;
  90. w.FCTYPE_ADDIGNORE = 7;
  91. w.FCTYPE_PRIVACY = 8;
  92. w.FCTYPE_ADDFRIENDREQ = 9;
  93. w.FCTYPE_USERNAMELOOKUP = 10;
  94. w.FCTYPE_ANNOUNCE = 13;
  95. w.FCTYPE_STUDIO = 14;
  96. w.FCTYPE_INBOX = 15;
  97. w.FCTYPE_RELOADSETTINGS = 17;
  98. w.FCTYPE_HIDEUSERS = 18;
  99. w.FCTYPE_RULEVIOLATION = 19;
  100. w.FCTYPE_SESSIONSTATE = 20;
  101. w.FCTYPE_REQUESTPVT = 21;
  102. w.FCTYPE_ACCEPTPVT = 22;
  103. w.FCTYPE_REJECTPVT = 23;
  104. w.FCTYPE_ENDSESSION = 24;
  105. w.FCTYPE_TXPROFILE = 25;
  106. w.FCTYPE_STARTVOYEUR = 26;
  107. w.FCTYPE_SERVERREFRESH = 27;
  108. w.FCTYPE_SETTING = 28;
  109. w.FCTYPE_BWSTATS = 29;
  110. w.FCTYPE_SETGUESTNAME = 30;
  111. w.FCTYPE_SETTEXTOPT = 31;
  112. w.FCTYPE_MODELGROUP = 33;
  113. w.FCTYPE_REQUESTGRP = 34;
  114. w.FCTYPE_STATUSGRP = 35;
  115. w.FCTYPE_GROUPCHAT = 36;
  116. w.FCTYPE_CLOSEGRP = 37;
  117. w.FCTYPE_SLAVEVSHARE = 43;
  118. w.FCTYPE_ROOMDATA = 44;
  119. w.FCTYPE_NEWSITEM = 45;
  120. w.FCGROUP_NONE = 0;
  121. w.FCGROUP_EXPIRED = 1;
  122. w.FCGROUP_BUSY = 2;
  123. w.FCGROUP_EMPTY = 3;
  124. w.FCGROUP_DECLINED = 4;
  125. w.FCGROUP_UNAVAILABLE = 5;
  126. w.FCGROUP_SESSION = 9;
  127. w.FCTYPE_CMESG = 50;
  128. w.FCTYPE_JOINCHAN = 51;
  129. w.FCTYPE_CREATECHAN = 52;
  130. w.FCTYPE_INVITECHAN = 53;
  131. w.FCTYPE_KICKCHAN = 54;
  132. w.FCTYPE_BANCHAN = 56;
  133. w.FCTYPE_PREVIEWCHAN = 57;
  134. w.FCTYPE_SETWELCOME = 61;
  135. w.FCTYPE_OFFERCAM = 70;
  136. w.FCTYPE_REQUESTCAM = 71;
  137. w.FCTYPE_MYWEBCAM = 72;
  138. w.FCTYPE_MYCAMSTATE = 73;
  139. w.FCTYPE_PMHISTORY = 74;
  140. w.FCTYPE_CHATFLASH = 75;
  141. w.FCTYPE_TRUEPVT = 76;
  142. w.FCTYPE_REMOTEPVT = 77;
  143. w.FCTYPE_ZGWINVALID = 95;
  144. w.FCTYPE_CONNECTING = 96;
  145. w.FCTYPE_CONNECTED = 97;
  146. w.FCTYPE_DISCONNECTED = 98;
  147. w.FCTYPE_LOGOUT = 99;
  148. w.FCMODE_NOPM = 0;
  149. w.FCMODE_FRIENDPM = 1;
  150. w.FCMODE_ALLPM = 2;
  151. w.FCRESPONSE_SUCCESS = 0;
  152. w.FCRESPONSE_ERROR = 1;
  153. w.FCRESPONSE_NOTICE = 2;
  154. w.FCERRTYPE_INVALIDUSER = 10;
  155. w.FCERRTYPE_NOACCESS = 11;
  156. w.FCCHAN_NOOPT = 0;
  157. w.FCCHAN_JOIN = 1;
  158. w.FCCHAN_PART = 2;
  159. w.FCCHAN_BATCHPART = 64;
  160. w.FCCHAN_OLDMSG = 4;
  161. w.FCCHAN_HISTORY = 8;
  162. w.FCCHAN_CAMSTATE = 16;
  163. w.FCCHAN_WELCOME = 32;
  164. w.FCCHAN_ERR_NOCHANNEL = 2;
  165. w.FCCHAN_ERR_NOTMEMBER = 3;
  166. w.FCCHAN_ERR_GUESTMUTE = 4;
  167. w.FCVIDEO_TX_IDLE = 0;
  168. w.FCVIDEO_TX_RESET = 1;
  169. w.FCVIDEO_TX_AWAY = 2;
  170. w.FCVIDEO_TX_CONFIRMING = 11;
  171. w.FCVIDEO_TX_PVT = 12;
  172. w.FCVIDEO_TX_GRP = 13;
  173. w.FCVIDEO_TX_KILLMODEL = 15;
  174. w.FCVIDEO_RX_IDLE = 90;
  175. w.FCVIDEO_RX_PVT = 91;
  176. w.FCVIDEO_RX_VOY = 92;
  177. w.FCVIDEO_RX_GRP = 93;
  178. w.FCVIDEO_UNKNOWN = 127;
  179. w.EVSESSION_NONE = 0;
  180. w.EVSESSION_PRIVATE = 1;
  181. w.EVSESSION_VOYEUR = 2;
  182. w.EVSESSION_GROUP = 3;
  183. w.EVSESSION_FEATURE = 4;
  184. w.EVSESSION_PUBLIC = 100;
  185. w.EVSESSION_AWAY = 101;
  186. w.FCWINDOW_NO_USER_PM = 20;
  187. w.FCWINDOW_OPTIONS_ADD_FRIEND = 31;
  188. w.FCWINDOW_OPTIONS_ADD_IGNORE = 32;
  189. w.FCACCEPT_NOBODY = 0;
  190. w.FCACCEPT_FRIENDS = 1;
  191. w.FCACCEPT_ALL = 2;
  192. w.MAX_SERVERS = 32;
  193. w.FCOPT_NONE = 0;
  194. w.FCOPT_BOLD = 1;
  195. w.FCOPT_ITALICS = 2;
  196. w.FCOPT_REMOTEPVT = 4;
  197. w.FCOPT_TRUEPVT = 8;
  198. w.FCOPT_CAM2CAM = 16;
  199. var nPrivateMessageBlinkInterval = 1700;
  200. var g_nBroadcasterId = 0;
  201. var g_hUsers = g_hUsers || {};
  202. var g_hStates = {};
  203. var g_hWindows = {};
  204. var g_sElipses = '';
  205. var g_hIgnoredUsers = {};
  206. var g_nBroadcasterCount = -4;
  207. var g_bFriendsLoaded = 0;
  208. var g_bLoadAllComplete = false;
  209. var g_oChatApplet = null;
  210. var g_hoPMWindows = {};
  211. var g_hoPlayerWindows = {};
  212. var g_nSessionId = 0;
  213. var g_XPos = 100;
  214. var g_YPos = 100;
  215. var g_nRxFriends = 0;
  216. var g_nPopupCount = 0;
  217. var g_nConnectingMode = 0;
  218. var g_oTimeReq = createRequestObject();
  219. var g_oAdminReq = createRequestObject();
  220. var g_oStateDumpReq = createRequestObject();
  221. var g_oChatStreamImage_Req = createRequestObject();
  222. var g_nServerUnixTime;
  223. var g_nLocalUnixTime;
  224. var g_nTimeOffset;
  225. var g_nTimezonMod = 0;
  226. var g_sTime = '';
  227. var g_hPlayerTracker = {};
  228. var g_sRetainerState = '';
  229. var g_hOnlineBlockHTML = {};
  230. var g_bIE = (navigator.appName == "Microsoft Internet Explorer") ? 1 : 0;
  231. var g_hSelf = {};
  232. var g_bLoginDone = false;
  233. var g_bFCTYPE_MODELGROUP_Received = false;
  234. var g_bFCTYPE_DETAILS_Received = false;
  235. var g_sUA = '';
  236. if (navigator.appName == "Microsoft Internet Explorer") g_sUA = 'ie';
  237. else if (navigator.userAgent.indexOf("Chrome") > -1) g_sUA = 'ch';
  238. else if (navigator.userAgent.indexOf("Firefox") > -1 || navigator.userAgent.indexOf("Minefield") > -1) g_sUA = 'ff';
  239. else if (navigator.userAgent.indexOf("Safari") > -1) g_sUA = 'sf';
  240. else g_sUA = 'ff';
  241. var g_hSessionTypes = {
  242.     0: 'public',
  243.     1: 'private',
  244.     2: 'voyeur',
  245.     3: 'group_show'
  246. };
  247. var g_hStateMessages = {};
  248. for (sK in g_hSessionTypes) {
  249.     g_hStateMessages[g_hSessionTypes[sK]] = {};
  250.     g_hStateMessages[g_hSessionTypes[sK]][FCVIDEO_TX_IDLE] = "%USERNAME% is in public chat";
  251.     g_hStateMessages[g_hSessionTypes[sK]][FCVIDEO_UNKNOWN] = "%USERNAME% is offline";
  252.     g_hStateMessages[g_hSessionTypes[sK]][FCVIDEO_RX_IDLE] = "%USERNAME% Webcam is Off";
  253.     g_hStateMessages[g_hSessionTypes[sK]][FCVIDEO_TX_AWAY] = "%USERNAME% is temporarily away";
  254. }
  255. g_hStateMessages['private'][t.FCVIDEO_TX_PVT] = "Private Show with %USERNAME%";
  256. g_hStateMessages['private'][t.FCVIDEO_TX_GRP] = "%USERNAME% is in a Group Show";
  257. g_hStateMessages['group_show'][t.FCVIDEO_TX_PVT] = "%USERNAME% is in a session";
  258. g_hStateMessages['group_show'][t.FCVIDEO_TX_GRP] = "Group Show with %USERNAME%";
  259. g_hStateMessages['voyeur'][t.FCVIDEO_TX_PVT] = "You are Spying on %USERNAME%";
  260. g_hStateMessages['voyeur'][t.FCVIDEO_TX_GRP] = "%USERNAME% is in a Group Show";
  261. g_hStateMessages['public'][t.FCVIDEO_TX_PVT] = "%USERNAME% is in a Private Show";
  262. g_hStateMessages['public'][t.FCVIDEO_TX_GRP] = "%USERNAME% is in a Group Show";
  263. g_hUsers[0] = {
  264.     username: 'MyFreeCams',
  265.     access_level: 4
  266. };
  267. var g_Date = new Date();
  268. var g_hPost = false;
  269. var g_hLogoutTimer = null;
  270. var g_sZgwSess = '';
  271. var g_nLastStamp = 0;
  272. var g_fConnected = false;
  273. var g_nSKey = 0;
  274.  
  275. function ResetSeed() {
  276.     g_nSKey = Math.floor(100000 + (899999 * Math.random()));
  277. }
  278. var g_hWindows = {};
  279. var g_hQS = getQueryStringHash();
  280. var g_sToggleFriends = g_hCk['display_friends'] || "block";
  281. var g_sToggleHeader = g_hCk['display_header'] || "block";
  282. var sNewWindowDefaults = "height=600,width=800,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1";
  283. var g_hWindows = new Array();
  284. var g_hBannerMessage = {
  285.     '0': "You are currently a <b>Guest</b> with limited site access.<br><b>" + A('register') + "Click here to get your FREE personal account.</a></b>",
  286.     '1': "As soon as you " + A('purchase') + "buy tokens</a> you will be instantly upgraded to a " + t.A('faq', {
  287.         anchor: 'premium'
  288.     }) + "Premium Member</a> free. " + t.A('faq', {
  289.         anchor: 'premium'
  290.     }) + "Learn more</a>.",
  291.     '2': "Please enjoy your stay with us and " + A('contact') + "let us know</a> if there is ever anything we can do for you.",
  292.     '3': "You are a model currently logged in as a user of " + g_hC['site_name'] + ". " + A('contact_help') + "Contact Us</a> for help at any time",
  293.     '5': "Please enjoy your stay with us. You may " + A('purchase') + "Purchase Tokens</a>, " + A('logout') + "Logout</a>, or " + A('contact_help') + "Contact Us</a> for help at any time"
  294. };
  295. var g_hMainMenuOptions = {
  296.     'logout': 'Logout',
  297.     'purchase': 'Purchase Tokens',
  298.     'register': 'Free Registration',
  299.     'login': 'Login',
  300.     'profiles': 'Profiles',
  301.     'tour': 'Tour',
  302.     'homepage': 'Homepage',
  303.     'asian_homepage': 'Asian Homepage',
  304.     'model_broadcast': 'My Room',
  305.     'contact': 'Contact Us',
  306.     'contact_help': 'Contact Us',
  307.     'toggle_menu': ''
  308. };
  309. var g_haMainMenuModes = {
  310.     'guest': new Array('login', 'contact_help', 'register', 'profiles', 'tour', 'asian_homepage', 'homepage'),
  311.     'registered': new Array('purchase', 'contact_help', 'profiles', 'asian_homepage', 'homepage'),
  312.     'premium': new Array('purchase', 'contact_help', 'profiles', 'asian_homepage', 'homepage'),
  313.     'model': new Array('profiles', 'contact_help', 'asian_homepage', 'homepage')
  314. };
  315. var hStateNames = {
  316.     FCVIDEO_TX_IDLE: 'In Public',
  317.     FCVIDEO_TX_AWAY: 'Away',
  318.     FCVIDEO_TX_PVT: '<b>In Private</b>',
  319.     FCVIDEO_TX_GRP: '<b>Group Show</b>'
  320. };
  321. var g_sHash = top.location.hash.substr(1, top.location.hash.length);
  322. g_sHash = g_sHash.toLowerCase();
  323. g_sHash = g_sHash.replace(/\W/g, '');
  324. if (g_sHash == 'asians') {
  325.     g_sHash = 'asian';
  326. }
  327. var g_sModelGroup = 'default';
  328. var g_hModelGroups = {
  329.     'default': {
  330.         bitmask: 1,
  331.         name: 'Default'
  332.     },
  333.     'asian': {
  334.         bitmask: 2,
  335.         name: 'Asian'
  336.     }
  337. };
  338. var g_hModelGroupNameLookup = {};
  339. for (sK in g_hModelGroups) {
  340.     g_hModelGroupNameLookup[g_hModelGroups[sK]['name'].toLowerCase()] = sK;
  341. }
  342. g_hModelGroupNameLookup['asians'] = 'asian';
  343. if (g_sHash && g_hModelGroupNameLookup[g_sHash]) {
  344.     g_sModelGroup = g_hModelGroupNameLookup[g_sHash];
  345. }
  346. var g_nFlash9 = false;
  347. if (DetectFlashVer(9, 0, 0)) g_nFlash9 = true;
  348. var g_sConnectionMode = g_hQS['conn_mode'] || g_hCk['conn_mode'] || 'none';
  349. if (g_sConnectionMode == 'java' && !navigator.javaEnabled()) g_sConnectionMode = 'none';
  350. if (g_sConnectionMode == 'none' || g_sConnectionMode == '') {
  351.     if (g_nFlash9 == true) g_sConnectionMode = 'flash';
  352.     else if (PluginDetect.isMinVersion('Java', '0') >= 0) g_sConnectionMode = 'java';
  353.     else g_sConnectionMode = 'ajax';
  354. }
  355. document.cookie = "conncur_mode=" + g_sConnectionMode + "; path=/;";
  356. w.name = "top_level";
  357. d.name = "top_level";
  358. window.onload = function LoadWindow() {
  359.     g_fBodyLoaded = true;
  360. };
  361. window.onunload = function UnloadWindow() {};
  362. var g = new MfcGraphics();
  363. var g_oMouseTracker = new MfcMouseTracker();
  364. document.onmousemove = function (e) {
  365.     g_oMouseTracker.track_mouse(e);
  366. };
  367. var g_oDhtmlPopup = new MfcDhtmlPopup();
  368. d.g_oDhtmlPopup = g_oDhtmlPopup;
  369. if (g_sConnectionMode == 'flash') {
  370.     var nWidth = 0;
  371.     var nHeight = 0;
  372.     if (top.location.search.match(/showflash/)) {
  373.         nWidth = 700;
  374.         nHeight = 120;
  375.     }
  376.     document.write('<script src=../lib/flashsocket_global.js?nc=63><\/script>');
  377.     var sFlashUrl = '../lib/MfcChat.swf?nc=5';
  378.     if (top.location.search.match(/chiflash/)) sFlashUrl = 'http://chicagodebug.myfreecams.com/mfc2/lib/MfcChat.swf';
  379.     var sFlashObject = " <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' \n codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' \n width='" + nWidth + "' height='" + nHeight + "' id='flashsocket' align='middle'> \n <param name='allowScriptAccess' value='always' /> \n <param name='movie' value='" + sFlashUrl + "' /> \n <param name='quality' value='high' /> \n <param name='bgcolor' value='#ffffff' /> \n <param name='flashvars' value=''> \n <embed src='" + sFlashUrl + "' \n swliveconnect='true' quality='high' \n flashvars='' bgcolor='#ffffff' \n width='" + nWidth + "' height='" + nHeight + "' \n id='flashsocket_ff' name='flashsocket' \n align='middle' allowScriptAccess='always' \n type='application/x-shockwave-flash' \n pluginspage='http://www.macromedia.com/go/getflashplayer' /> \n </object>\n ";
  380.     if (navigator.userAgent.indexOf('MSIE 6') == -1 && !top.location.search.match(/showflash/)) {
  381.         sFlashObject = "<div style=\"position:absolute;top:0px;right:0px;\">" + sFlashObject + "</div>";
  382.     }
  383.     document.write(sFlashObject);
  384. } else if (g_sConnectionMode == 'ajax') {
  385.     document.write('<script src=../lib/zgw_proxy.js><\/script>');
  386.     document.write("<iframe name=ajaxframe id=ajaxframe frameborder=0 border=0 src='http://ajax.myfreecams.com/lib/zgw_frame.php' width=1 height=1><\/iframe>");
  387. }
  388.  
  389. function RandomChatServer() {
  390.     if (top.location.search.match(/server=chat([^&]*)/)) return RegExp.$1;
  391.     else if (t.location.search.indexOf('server=www') > -1) return 0;
  392.     return Math.floor(w.MAX_SERVERS * Math.random()) + 1;
  393. }
  394. var g_hChatTimer;
  395.  
  396. function ChatPoll(nPollErrors) {
  397.     bChatPoll = 1;
  398.     if (nPollErrors == 20) {
  399.         nPollErrors++;
  400.         if (g_hChatTimer) {
  401.             clearTimeout(g_hChatTimer);
  402.         }
  403.         document.cookie = "conn_mode=ajax; path=/;";
  404.         top.location = "http://www.myfreecams.com/?conn_mode=ajax";
  405.         return;
  406.     } else if (nPollErrors > 20) {
  407.         return;
  408.     }
  409.     if (g_oChatApplet) {
  410.         try {
  411.             sCommandString = new String(g_oChatApplet.RxCmd() || "");
  412.         } catch (oError) {
  413.             g_sElipses = (g_sElipses.length > 3) ? "" : (g_sElipses + ".");
  414.             for (sK in g_hWindows) {
  415.                 if (g_hWindows[sK] && g_hWindows[sK].oChat && g_hWindows[sK].oChat.SetHtml) {
  416.                     g_hWindows[sK].oChat.SetHtml('Loading Java VM' + g_sElipses);
  417.                 }
  418.             }
  419.             if (!nPollErrors) {
  420.                 nPollErrors = 0;
  421.             }
  422.             nPollErrors++;
  423.             g_hChatTimer = setTimeout("ChatPoll(" + nPollErrors + ")", 300);
  424.             return;
  425.         }
  426.         if (sCommandString != undefined && sCommandString.length > 0) {
  427.             sCmds = sCommandString.split("\n");
  428.             for (n in sCmds) {
  429.                 ParseCommand(sCmds[n]);
  430.             }
  431.             g_hChatTimer = setTimeout("ChatPoll()", 200);
  432.             return;
  433.         }
  434.     } else {
  435.         Log("JAVA ChatPoll bad no g_oChatApplet");
  436.     }
  437.     g_hChatTimer = setTimeout("ChatPoll()", 500);
  438.     return;
  439. }
  440.  
  441. function AppendToUserHash(nUserId, hKeyVals) {
  442.     if (!g_hUsers[nUserId]) {
  443.         g_hUsers[nUserId] = {};
  444.         g_hUsers[nUserId]['state'] = w.FCVIDEO_UNKNOWN;
  445.     }
  446.     for (sK in hKeyVals) {
  447.         g_hUsers[nUserId][sK] = hKeyVals[sK];
  448.         if (nUserId == g_hSelf['user_id']) {
  449.             g_hSelf[sK] = hKeyVals[sK];
  450.         }
  451.     }
  452. }
  453. var g_bCreatedAppletCalled = false;
  454.  
  455. function CreateJavaApplet(nOptPort) {
  456.     g_oChatApplet = null;
  457.     g_bCreatedAppletCalled = true;
  458.     try {
  459.         var frame = parent.frames['chat_applet'];
  460.         if (frame == null || frame == undefined) g_bCreatedAppletCalled = false;
  461.     } catch (oError) {
  462.         g_bCreatedAppletCalled = false;
  463.     }
  464.     if (g_bCreatedAppletCalled == false) {
  465.         Log("DBG: JAVA Chat applet frame error: " + oError.description);
  466.         setTimeout("LoadAll()", 50);
  467.         return;
  468.     }
  469.     Log("JAVA - attempt create applet");
  470.     sUser = g_hCk['username'] || 'guest';
  471.     sPass = g_hCk['passcode'] || 'guest';
  472.     if (sPass == 'guest' || sPass == 'undefined') {
  473.         sUser = sPass = 'guest';
  474.     }
  475.     if (g_hCk['guest_username'] && !g_hCk['passcode'] && !g_bLoginDone) {
  476.         sUser = g_hCk['guest_username'];
  477.         sPass = 'guestlogin';
  478.     }
  479.     g_nSessionId = 0;
  480.     var sServer = "chat" + RandomChatServer();
  481.     if (sServer == "chat0") sServer = "fusion";
  482.     if (t.location.search.indexOf('server=impulse') > -1) sServer = "impulse";
  483.     Log('Chat Server: ' + sServer);
  484.     var nPort = nOptPort || 8100;
  485.     var sExtraAppletParam = '';
  486.     if (t.location.search.indexOf('use_alt_port') > -1) {
  487.         nPort = 8550;
  488.     }
  489.     if (navigator.userAgent.indexOf("Safari") != -1) {
  490.         sServer = "www";
  491.     }
  492.     var sData = '';
  493.     if (g_sHash) {
  494.         sData = g_sHash + '/';
  495.     }
  496.     sData += sUser;
  497.     var sCode = "\n\<script> document.domain = 'myfreecams.com'; <\/script>\n <applet id=chat_applet mayscript codebase='http://" + sServer + ".myfreecams.com/cab/'\n archive='FriendChat.jar?nc=3' code=FriendChat.class width=1 height=1>\n <param name=host value='" + sServer + ".myfreecams.com'>\n <param name=port value=" + nPort + ">\n <param name=username value='" + sData + "'>\n <param name=password value='" + sPass + "'>\n </applet> ";
  498.     if (!g_bIE) {
  499.         parent.frames['chat_applet'].document.open();
  500.     }
  501.     parent.frames['chat_applet'].document.write(sCode);
  502.     if (!g_bIE) {
  503.         parent.frames['chat_applet'].document.close();
  504.     }
  505.     g_oChatApplet = parent.frames['chat_applet'].document.getElementById('chat_applet');
  506.     Log('JAVA JAVA JAVA - ' + g_oChatApplet);
  507.     ChatPoll();
  508. }
  509.  
  510. function TxCmd(nType, nFrom, nTo, nArg1, nArg2, sMsg) {
  511.     if (nType == undefined) nType = 0;
  512.     if (nFrom == undefined) nFrom = 0;
  513.     if (nArg1 == undefined) nArg1 = 0;
  514.     if (nArg2 == undefined) nArg2 = 0;
  515.     if (sMsg == undefined) sMsg = '';
  516.     var sCommand = nType + " " + nFrom + " " + nTo + " " + nArg1 + " " + nArg2;
  517.     if (sMsg != null && sMsg.length > 0) {
  518.         sCommand += " " + sMsg;
  519.     }
  520.     Log("TX: " + MfcStringUtilities.prototype.char_padding(g_hTypeMap[nType], 20, ' ', 'right') + " " + sCommand);
  521.     try {
  522.         if (g_sConnectionMode == 'java') {
  523.             g_oChatApplet.TxCmd(sCommand);
  524.         } else {
  525.             var hMsg = {};
  526.             hMsg.c = nType;
  527.             hMsg.f = nFrom;
  528.             hMsg.t = nTo;
  529.             hMsg.a1 = nArg1;
  530.             hMsg.a2 = nArg2;
  531.             if (sMsg != null && sMsg.length > 0) {
  532.                 hMsg.d = sMsg;
  533.             }
  534.             zgw_Post(hMsg);
  535.         }
  536.     } catch (oError) {
  537.         Log("TXCmd Error: " + oError.description);
  538.     }
  539. }
  540.  
  541. function getQueryStringHash(extra_search_string) {
  542.     var search = "";
  543.     var hQS = new Array();
  544.     var aPairs = new Array();
  545.     search += g_hCk['qs'] || '';
  546.     search += location.search;
  547.     if (extra_search_string) {
  548.         search += extra_search_string;
  549.     }
  550.     if (aPairs = search.replace(/\?/g, "&").split("&")) {
  551.         for (var i = 0; i < aPairs.length; i++) {
  552.             hQS[aPairs[i].split('=')[0]] = aPairs[i].split('=')[1];
  553.         }
  554.     }
  555.     return hQS;
  556. }
  557.  
  558. function UpdateCookieHash() {
  559.     var aPairs = new Array();
  560.     if (aPairs = document.cookie.split("; ")) {
  561.         for (var i = 0; i < aPairs.length; i++) {
  562.             g_hCk[aPairs[i].substring(0, aPairs[i].indexOf('='))] = aPairs[i].substring(aPairs[i].indexOf('=') + 1, aPairs[i].length);
  563.         }
  564.     }
  565. }
  566.  
  567. function SetCookie(name, value, expires, path, domain, secure) {
  568.     path = path || g_hC['site_path'];
  569.     domain = domain || g_hC['domain'];
  570.     g_hCk[name] = value;
  571.     if (!value || value == '') {
  572.         expires = "01-Jan-01 00:00:01 GMT";
  573.         value = 1;
  574.     } else {
  575.         if (expires != 'session' && !expires) {
  576.             expires = "Mon, 25 Oct 2032 19:36:54 UTC";
  577.         }
  578.     }
  579.     var sNewCookie = "";
  580.     sNewCookie += name + "=" + value + ";";
  581.     if (expires && expires != 'session') sNewCookie += "expires=" + expires + ";";
  582.     if (path) sNewCookie += "path=/;";
  583.     if (domain) sNewCookie += "domain=myfreecams.com;";
  584.     if (secure) sNewCookie += "secure=" + secure + ";";
  585.     document.cookie = sNewCookie;
  586. }
  587. nReloginTry = 0;
  588.  
  589. function JavaRelogin() {
  590.     sUser = g_hCk['username'] || 'guest';
  591.     sPass = g_hCk['passcode'] || 'guest';
  592.     if (sPass == 'guest' || sPass == 'undefined') {
  593.         sUser = sPass = 'guest';
  594.     }
  595.     if (g_hCk['guest_username'] && !g_hCk['passcode']) {
  596.         sUser = g_hCk['guest_username'];
  597.         sPass = 'guestlogin';
  598.     }
  599.     var sData = '';
  600.     if (g_sHash) {
  601.         sData = g_sHash + '/';
  602.     }
  603.     sData += sUser;
  604.     if (g_oChatApplet) {
  605.         g_oChatApplet.Relogin(sData, sPass);
  606.     }
  607. }
  608.  
  609. function LoadAll(sResource, hOptions) {
  610.     if (top.g_sSlaveServer) {
  611.         Log("Server: " + top.g_sSlaveServer);
  612.     }
  613.     g_bFriendsListSuspendUpdates = 0;
  614.     g_hEmoticonHTMLCache = {};
  615.     top.location.search.match(/^\?(\w+)\W?/);
  616.     if (g_hResources[RegExp.$1]) {
  617.         g_hQS['load'] = RegExp.$1;
  618.     }
  619.     var sResource = sResource || g_hQS['load'] || '';
  620.     if (sResource && !g_hResources[sResource]) {
  621.         sResource = 'bad_link';
  622.     }
  623.     var hOptions = hOptions || {};
  624.     g_hOnlineBlockHTML = {};
  625.     var frame = parent ? parent.frames['chat_applet'] : null;
  626.     Log("LoadAll: '" + sResource + "' , g_bCreatedAppletCalled: '" + g_bCreatedAppletCalled + "', frame: " + frame);
  627.     if (navigator.userAgent.indexOf("Safari") != -1 && !g_fBodyLoaded) {
  628.         Log("Waiting for readyState complete before continuing, it's currently " + document.readyState + "...");
  629.         setTimeout("LoadAll()", 1000);
  630.         return;
  631.     }
  632.     UpdateCookieHash();
  633.     LoadLogin(" ");
  634.     if (!g_hSelf['access_level'] || g_hSelf['access_level'] == 0) {
  635.         g_hSelf['online_model_order'] = 'public_first';
  636.     }
  637.     if (!g_bLoginDone && !hOptions['login_complete']) {
  638.         if (g_hQS['disable_model_notification'] || g_hQS['remove_email_notify']) {
  639.             sResource = 'account';
  640.         } else if (g_hQS['buy']) {
  641.             Load('login', {
  642.                 verification: g_hQS['buy'],
  643.                 post_load: 'purchase' || ''
  644.             });
  645.             return;
  646.         } else if (g_hQS['code'] || g_hQS['verification']) {
  647.             g_hQS['verification'] = g_hQS['verification'] || g_hQS['code'];
  648.             Load('login', {
  649.                 verification: g_hQS['verification'],
  650.                 post_load: sResource || ''
  651.             });
  652.             return;
  653.         }
  654.     } else {
  655.         g_hQS['verification'] = '';
  656.         g_hQS['code'] = '';
  657.         g_hQS['buy'] = '';
  658.         g_hQS['load'] = '';
  659.     }
  660.     Log('g_sConnectionMode: ' + g_sConnectionMode);
  661.     if (g_sConnectionMode == 'java') {
  662.         if (hOptions['fromlogin'] == 1) {
  663.             top.location.reload();
  664.             return;
  665.         }
  666.         if (g_bCreatedAppletCalled == false) {
  667.             CreateJavaApplet(hOptions['java_port']);
  668.         }
  669.     } else {
  670.         if (hOptions['fromlogin'] == 1) {
  671.             location.href.match(/([^\?]*)/);
  672.             location.replace(RegExp.$1);
  673.         }
  674.         if (g_nZgwLoaded == 1) {} else {}
  675.     } if (document.cookie.match(/AFFILIATE.*45/)) {
  676.         top.location.replace('/');
  677.     }
  678.     if (hOptions['login_complete']) {}
  679.     if (g_hQS['mode'] == "under_construction") {
  680.         sResource = "under_construction";
  681.     } else if (g_hQS['delete']) {
  682.         sResource = "delete_account";
  683.     }
  684.     if (hOptions['login']) {
  685.         g_hQS['verification'] = '';
  686.         1;
  687.     }
  688.     g_hQS['target'] = 'main';
  689.     Load(sResource, g_hQS);
  690.     if (g_hQS['mode'] == "under_construction") return;
  691.     PopupPositioner();
  692.     setTimeout("FlushCache()", 1800000);
  693. }
  694.  
  695. function FlushCache() {
  696.     g_hOnlineBlockHTML = {};
  697.     setTimeout("FlushCache()", 1800000);
  698. }
  699.  
  700. function ModelHistory_Pause() {
  701.     g_hSelf['pause_model_history'] = g_hSelf['pause_model_history'] ? 0 : 1;
  702.     SaveSetting('pause_model_history', g_hSelf['pause_model_history'] || 0);
  703.     ModelHistory_Pause_Lable();
  704. }
  705.  
  706. function ModelHistory_Pause_Lable() {
  707.     if (!IdCache('pause_model_history')) {
  708.         return;
  709.     }
  710.     if (g_hSelf['pause_model_history']) {
  711.         IdCache('pause_model_history').innerHTML = " Paused <a href=# onClick=\"ModelHistory_Pause(); return false;\"><span style=background-color:#FFFF33;>Resume</span></a> ";
  712.     } else {
  713.         IdCache('pause_model_history').innerHTML = " <a href=# onClick=\"ModelHistory_Pause(); return false;\">Pause</a> ";
  714.     }
  715. }
  716.  
  717. function ModelHistory_Clear() {
  718.     g_aModelHistory = new Array();
  719.     setTimeout("SetCookie('mh','0','Thu, 21-Jan-2001 00:00:01 GMT');", 100);
  720.     g_hCk['mh'] = '';
  721.     ModelHistory('reset');
  722. }
  723. var g_aModelHistory = new Array();
  724.  
  725. function ModelHistory(nUserId) {
  726.     if (!IdCache("model_history")) {
  727.         return;
  728.     }
  729.     if (g_aModelHistory.length == 0 && g_hCk['mh']) {
  730.         g_aModelHistory = g_hCk['mh'].split(',');
  731.         var aTmp = new Array();
  732.         var bModelInList = 0;
  733.         for (nK in g_aModelHistory) {
  734.             if (g_hUsers[g_aModelHistory[nK]]) {
  735.                 aTmp.push(g_aModelHistory[nK]);
  736.                 g_hUsers[g_aModelHistory[nK]]['model_history'] = 1;
  737.             }
  738.         }
  739.         g_aModelHistory = aTmp;
  740.     }
  741.     if (g_hSelf['pause_model_history'] && nUserId != 'reset') {
  742.         return;
  743.     } else if (nUserId) {
  744.         if (g_aModelHistory.length > 0 && g_aModelHistory[g_aModelHistory.length - 1] == nUserId) {
  745.             1;
  746.         } else {
  747.             g_aModelHistory.push(nUserId);
  748.             if (g_hUsers[nUserId]) {
  749.                 g_hUsers[nUserId]['model_history'] = 1;
  750.             }
  751.         }
  752.     }
  753.     if (g_aModelHistory.length > 8) {
  754.         nRemoveUserId = g_aModelHistory.shift();
  755.         if (g_hUsers[nRemoveUserId]) {
  756.             g_hUsers[nRemoveUserId]['model_history'] = 0;
  757.         }
  758.     }
  759.     var aTmp = new Array();
  760.     if (g_aModelHistory.length > 0) {
  761.         aTmp.push(" <table width=130> ");
  762.         var hOneEntryPerModel = {};
  763.         var cx = 0;
  764.         for (a = g_aModelHistory.length; a > 0; a--) {
  765.             nUserId = g_aModelHistory[a - 1];
  766.             if (!g_hUsers[nUserId] || hOneEntryPerModel[nUserId]) {
  767.                 continue;
  768.             }
  769.             hOneEntryPerModel[nUserId] = 1;
  770.             if (g_hUsers[nUserId]['state'] >= 90) {
  771.                 aTmp.push(" <tr> <td style=\"background-color:#FFFFFF;\" " + PopupBioHandlerCode(nUserId, 'context_only') + "> <i" + "mg height=30 width=30 src=" + AvatarUrl(nUserId, 30) + " style=\"border:1px solid #bbbbbb;\"> </td> <td valign=top style=\"border-top:0px solid #eeeeee;padding-left:2px;background-color:#FFFFFF;\" PopupBioHandlerCode(nUserId,'context_only')> <div style=\"font-size:13px;width:112px;overflow:hidden;white-space:nowrap;\"> <i>" + g_hUsers[nUserId]['username'] + "</i> </div> <div style=\"font-size:8px;\"> Offline  <a href=# onClick=\"PopUserMenu(" + nUserId + "); return false;\">Menu</a> </div> </td> </tr> ");
  772.             } else {
  773.                 aTmp.push(" <tr> <td style=\"\" " + PopupBioHandlerCode(nUserId, 'context_only') + "> <a href=# style=\"" + MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]) + "\" onClick=\" Load('player',{ broadcaster_id: " + nUserId + ", history_click: 1 }); \" ><i" + "mg height=30 width=30 src=" + AvatarUrl(nUserId, 30) + " style=\"border:1px solid #bbbbbb;\"></a> </td> <td valign=top style=\"border-top:0px solid #eeeeee;padding-left:2px;\" " + PopupBioHandlerCode(nUserId, 'context_only') + "> <div style=\"font-size:13px;width:112px;overflow:hidden;white-space:nowrap;\"> <a href=# style=\"" + MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]) + "\" onClick=\" Load('player',{ broadcaster_id: " + nUserId + ", history_click: 1 }); \">" + g_hUsers[nUserId]['username'] + "</a> </div> <div style=\"font-size:8px;\"> " + (!g_hLoungeIds[nUserId] ? "<a href=# onClick=\"PopUserMenu(" + nUserId + "); return false;\">Menu</a>" : "") + " </div> </td> </tr> ");
  774.             }
  775.         }
  776.         aTmp.push("</table>");
  777.     } else {
  778.         aTmp.push("<div style=\"padding:30px 10px;color:#777777;font-size:10px;\">Enter any chat room to add the model to this Model History list.</div>");
  779.     }
  780.     aTmp.push(" <div style=\"font-size:10px;padding-top:6px;\"> <a href=# onClick=\"ModelHistory_Clear(); return false;\">Clear</a> |  <span id=pause_model_history></span> </div> ");
  781.     IdCache("model_history").innerHTML = aTmp.join('');
  782.     setTimeout("SetCookie('mh','" + g_aModelHistory.join() + "','Thu, 21-Jan-2021 00:00:01 GMT');", 100);
  783.     ModelHistory_Pause_Lable();
  784. }
  785. var g_nLoungeReservedId = 486121;
  786. var g_hLoungeIds = {};
  787.  
  788. function InsertPremiumLounge() {
  789.     if (g_hSelf['access_level'] != '2' && g_hSelf['access_level'] != '5') {
  790.         return;
  791.     }
  792.     g_hLoungeIds[486121] = "Lounge";
  793.     g_hUsers[486121] = {
  794.         username: g_hLoungeIds[486121],
  795.         user_id: 486121,
  796.         access_level: '4',
  797.         state: '0',
  798.         photos: '0',
  799.         rating: '-2',
  800.         cam_score: '0',
  801.         asian_cam_score: '0',
  802.         aboutme: 'An exclusive room for Premium Members',
  803.         active: '1',
  804.         blurb: 'An exclusive room for Premium Members',
  805.         topic: 'An exclusive room for Premium Members',
  806.         creation_date: '2007-12-03 00:12:00',
  807.         avatars: '1',
  808.         model_group: '1',
  809.         chat_background_id: '0'
  810.     };
  811.     g_hLoungeIds[486122] = "Asian_Lounge";
  812.     g_hUsers[486122] = {
  813.         username: g_hLoungeIds[486122],
  814.         user_id: 486122,
  815.         access_level: '4',
  816.         state: '0',
  817.         photos: '0',
  818.         rating: '-2',
  819.         cam_score: '0',
  820.         asian_cam_score: '0',
  821.         aboutme: 'An exclusive room for Premium Members',
  822.         active: '1',
  823.         blurb: 'An exclusive room for Premium Members',
  824.         topic: 'An exclusive room for Premium Members',
  825.         creation_date: '2007-12-03 00:12:00',
  826.         avatars: '1',
  827.         model_group: '2',
  828.         chat_background_id: '0'
  829.     };
  830.     if (g_hSelf['rewards_points'] >= 1000) {
  831.         g_hLoungeIds[486123] = "Lounge1000";
  832.         g_hUsers[486123] = {
  833.             username: g_hLoungeIds[486123],
  834.             user_id: 486123,
  835.             access_level: '4',
  836.             state: '0',
  837.             photos: '0',
  838.             rating: '-2',
  839.             cam_score: '0',
  840.             asian_cam_score: '0',
  841.             aboutme: 'An exclusive room for Premium Members with 1000+ Rewards Points',
  842.             active: '1',
  843.             blurb: 'An exclusive room for Premium Members with 1000+ Rewards Points',
  844.             topic: 'An exclusive room for Premium Members with 1000+ Rewards Points',
  845.             creation_date: '2010-02-10 11:27:37',
  846.             avatars: '1',
  847.             model_group: '1',
  848.             chat_background_id: '0'
  849.         };
  850.     }
  851.     for (sK in g_hLoungeIds) {
  852.         g_hLoungeIds[g_hLoungeIds[sK]] = sK;
  853.     }
  854.     for (sK in g_hWindows) {
  855.         if (g_hWindows[sK].RefreshOnlineBroadcasterList) {
  856.             g_hWindows[sK].RefreshOnlineBroadcasterList('initialize');
  857.         }
  858.     }
  859. }
  860.  
  861. function PopupPositioner() {
  862.     if (g_nPopupCount > 3) {
  863.         g_nPopupCount = 0;
  864.     }
  865.     g_XPos = 100 + (g_nPopupCount * 25);
  866.     g_YPos = 70 + (g_nPopupCount * 25);
  867.     setTimeout("PopupPositioner()", 2000);
  868. }
  869.  
  870. function Load(sResource, hOptions, oTarget) {
  871.     Log("Load('" + sResource + "')");
  872.     sResource = sResource || '';
  873.     hOptions = hOptions || {};
  874.     oTarget = oTarget || '';
  875.     if (g_hSelf['rule_violation'] == 1 && sResource != 'rule_violation') {
  876.         return;
  877.     }
  878.     var sTarget;
  879.     if (hOptions['target']) {
  880.         sTarget = hOptions['target'];
  881.     } else if (g_hResources[sResource] && g_hResources[sResource]['target']) {
  882.         sTarget = g_hResources[sResource]['target'];
  883.     } else {
  884.         sTarget = sDefaultTarget;
  885.     }
  886.     if (sResource == 'pm_friend') {
  887.         return ClickFriend(hOptions['user_id'], hOptions);
  888.     } else if (sResource == 'close_pm_window') {
  889.         return ClosePMWindow(hOptions['user_id']);
  890.     } else if (sResource == 'pm_prompt') {
  891.         return PmPrompt();
  892.     } else if (sResource == 'logout') {
  893.         if (g_sConnectionMode == 'flash') zgw_TxLogout();
  894.         t.TxCmd(t.FCTYPE_LOGOUT, g_nSessionId, 0);
  895.         Logout(false);
  896.         return;
  897.     } else if (sResource == 'bookmark') {
  898.         var sTitle = "MyFreeCams - " + g_hUsers[hOptions['user_id']]['username'] + "'s Room";
  899.         var sUrl = "http://www.myfreecams.com/#" + g_hUsers[hOptions['user_id']]['username'];
  900.         if (window.sidebar) window.sidebar.addPanel(sTitle, sUrl, "");
  901.         else if (window.external) window.external.AddFavorite(sUrl, sTitle);
  902.         return;
  903.     } else if (sResource == 'mute') {
  904.         return oTarget.Mute();
  905.     } else if (sResource == 'tx_add_friend') {
  906.         return TxAddRemoveFriend(hOptions['remote_user_code'], 'add');
  907.     } else if (sResource == 'change_model_group') {
  908.         return ChangeModelGroup_Start(hOptions);
  909.     } else if (sResource == 'tx_remove_friend') {
  910.         return TxAddRemoveFriend(hOptions['remote_user_code'], 'remove');
  911.     } else if (sResource == 'toggle_away') {
  912.         return ChangeAway(hOptions);
  913.     } else if (sResource == 'toggle_header') {
  914.         return ToggleHeader(hOptions);
  915.     } else if (sResource == 'toggle_menu') {
  916.         return ToggleFriendsMenu(hOptions);
  917.     } else if (sResource == 'tx_add_ignore') {
  918.         return TxAddRemoveIgnore(hOptions['remote_user_code'], 'add', hOptions);
  919.     } else if (sResource == 'tx_remove_ignore') {
  920.         return TxAddRemoveIgnore(hOptions['remote_user_code'], 'remove', hOptions);
  921.     } else if (sResource == 'toggle_mute_guests' || sResource == 'toggle_mute_regs') {
  922.         for (sK in g_hoPlayerWindows) {
  923.             if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  924.                 try {
  925.                     g_hoPlayerWindows[sK]['handle'].Export().ToggleMuteGuests(sResource);
  926.                 } catch (oError) {
  927.                     Log("Try Catch Failure #1: " + oError.description);
  928.                 }
  929.             }
  930.         }
  931.         return;
  932.     } else if (sResource == 'toggle_video' && oTarget && oTarget.ToggleVideo) {
  933.         return oTarget.ToggleVideo();
  934.     } else if (sResource == 'toggle_size' && oTarget && oTarget.ToggleSize) {
  935.         return oTarget.ToggleSize();
  936.     } else if (sResource == 'register' && hOptions['mode'] == 'guest_bounce') {
  937.         sTarget = sMainTarget;
  938.     } else if (sResource == 'player') {
  939.         if (hOptions['target']) {
  940.             oTarget = window.frames[hOptions['target']];
  941.         } else if (!oTarget) {
  942.             oTarget = window.frames['main'];
  943.         }
  944.         if (oTarget && oTarget.LoadPlayer) {
  945.             hOptions['history'] = 1;
  946.             oTarget.LoadPlayer('', hOptions);
  947.             return;
  948.         }
  949.     } else if (sResource == 'player' && g_hoPlayerWindows[hOptions['broadcaster_id']]) {
  950.         Log("Redirecting focus to existing player instance for model " + hOptions['broadcaster_id']);
  951.         try {
  952.             g_hoPlayerWindows[hOptions['broadcaster_id']]['handle'].Export().focus();
  953.         } catch (oError) {
  954.             Log("Player focus error: " + oError.description);
  955.         }
  956.         return;
  957.     }
  958.     if (!sResource) {
  959.         sResource = 'homepage';
  960.     }
  961.     if (sResource == 'server_connection_error') {
  962.         if (g_sConnectionMode == 'ajax') {
  963.             sResource = 'homepage';
  964.         }
  965.     }
  966.     if (g_hQS['mode'] == "under_construction" && sResource != "under_construction") {
  967.         return;
  968.     }
  969.     if (sResource == 'asian_homepage') {
  970.         if (g_sModelGroup != 'asian') {
  971.             ChangeModelGroup_Start({
  972.                 model_group: 'asian'
  973.             });
  974.             return;
  975.         } else {
  976.             sResource = 'homepage';
  977.         }
  978.     } else if (sResource == 'homepage' && hOptions['user_invoked'] && g_sModelGroup != 'default') {
  979.         ChangeModelGroup_Start({
  980.             model_group: 'default'
  981.         });
  982.         return;
  983.     }
  984.     if (sResource == 'homepage' && sTarget && window.frames[sTarget] && window.frames[sTarget].g_bPlayerHTMLLoaded) {
  985.         window.frames[sTarget].LoadPlayer('homepage');
  986.         return;
  987.     }
  988.     var sLoc = (g_hResources[sResource]) ? MfcStringUtilities.prototype.parse_template(g_hResources[sResource]['page'], hOptions) : '';
  989.     if (!sLoc) {
  990.         return;
  991.     }
  992.     for (sK in hOptions) {
  993.         if (sK != '' && -1 == sLoc.indexOf(sK + "=")) {
  994.             sLoc += ((sLoc.match(/\?/)) ? "&" : "?") + sK + "=" + hOptions[sK];
  995.         }
  996.     }
  997.     sLoc += ((sLoc.match(/\?/)) ? "&" : "?") + "no_cache=" + Math.random();
  998.     if (sTarget) {
  999.         Log(sTarget + ": " + sLoc);
  1000.         if (g_hWindows[sTarget] && g_hWindows[sTarget].location && g_hWindows[sTarget].location.replace) {
  1001.             g_hWindows[sTarget].location.replace(sLoc);
  1002.         } else if (t.frames[sTarget] && sTarget != "new_window") {
  1003.             t.frames[sTarget].location.replace(sLoc);
  1004.         }
  1005.     }
  1006. }
  1007.  
  1008. function LoadHeaderArt() {
  1009.     var hHeaderSets = {
  1010.         'default': {
  1011.             1: {
  1012.                 username: 'Cinnabuns',
  1013.                 place: 1,
  1014.                 month: 2,
  1015.                 year: 2009,
  1016.                 left: '350px',
  1017.                 share: 20
  1018.             },
  1019.             2: {
  1020.                 username: 'Delishiousz',
  1021.                 place: 1,
  1022.                 month: 1,
  1023.                 year: 2009,
  1024.                 left: '140px',
  1025.                 share: 10
  1026.             },
  1027.             3: {
  1028.                 username: 'Nivea',
  1029.                 place: 2,
  1030.                 month: 1,
  1031.                 year: 2009,
  1032.                 left: '160px',
  1033.                 share: 10
  1034.             },
  1035.             4: {
  1036.                 username: 'PrincessLeia',
  1037.                 place: 1,
  1038.                 month: 3,
  1039.                 year: 2009,
  1040.                 left: '160px',
  1041.                 share: 0
  1042.             },
  1043.             5: {
  1044.                 username: 'DaniMerie',
  1045.                 place: 1,
  1046.                 month: 4,
  1047.                 year: 2009,
  1048.                 left: '315px',
  1049.                 share: 5
  1050.             },
  1051.             6: {
  1052.                 username: 'Caterine',
  1053.                 place: 1,
  1054.                 month: 5,
  1055.                 year: 2009,
  1056.                 left: '240px',
  1057.                 share: 20
  1058.             },
  1059.             7: {
  1060.                 username: 'Sue',
  1061.                 place: 2,
  1062.                 month: 5,
  1063.                 year: 2009,
  1064.                 left: '270px',
  1065.                 share: 5
  1066.             },
  1067.             8: {
  1068.                 username: 'Anabell',
  1069.                 place: 1,
  1070.                 month: 6,
  1071.                 year: 2009,
  1072.                 left: '310px',
  1073.                 share: 20
  1074.             },
  1075.             9: {
  1076.                 username: 'Sarany',
  1077.                 place: 3,
  1078.                 month: 6,
  1079.                 year: 2009,
  1080.                 left: '310px',
  1081.                 share: 20
  1082.             },
  1083.             10: {
  1084.                 username: '1Tweety',
  1085.                 place: 2,
  1086.                 month: 6,
  1087.                 year: 2009,
  1088.                 left: '310px',
  1089.                 share: 5
  1090.             },
  1091.             11: {
  1092.                 username: 'GoldenLady',
  1093.                 place: 1,
  1094.                 month: 11,
  1095.                 year: 2009,
  1096.                 left: '370px',
  1097.                 share: 40
  1098.             },
  1099.             12: {
  1100.                 username: 'Mellanny',
  1101.                 place: 1,
  1102.                 month: 9,
  1103.                 year: 2009,
  1104.                 left: '365px',
  1105.                 share: 40
  1106.             },
  1107.             13: {
  1108.                 username: 'ShyTeenn',
  1109.                 place: 1,
  1110.                 month: 1,
  1111.                 year: 2010,
  1112.                 left: '325px',
  1113.                 share: 30
  1114.             },
  1115.             14: {
  1116.                 username: 'MilaMilan',
  1117.                 place: 1,
  1118.                 month: 2,
  1119.                 year: 2010,
  1120.                 left: '370px',
  1121.                 share: 30
  1122.             },
  1123.             15: {
  1124.                 username: 'SarahJean',
  1125.                 place: 1,
  1126.                 month: 3,
  1127.                 year: 2010,
  1128.                 left: '400px',
  1129.                 share: 40
  1130.             },
  1131.             16: {
  1132.                 username: 'NorthStarr',
  1133.                 place: 2,
  1134.                 month: 3,
  1135.                 year: 2010,
  1136.                 left: '270px',
  1137.                 share: 40
  1138.             },
  1139.             17: {
  1140.                 username: 'Jalyn',
  1141.                 place: 1,
  1142.                 month: 4,
  1143.                 year: 2010,
  1144.                 left: '370px',
  1145.                 share: 40
  1146.             },
  1147.             18: {
  1148.                 username: 'SiLolita',
  1149.                 place: 1,
  1150.                 month: 5,
  1151.                 year: 2010,
  1152.                 left: '250px',
  1153.                 share: 40
  1154.             },
  1155.             19: {
  1156.                 username: 'LovelyKittie',
  1157.                 place: 1,
  1158.                 month: 6,
  1159.                 year: 2010,
  1160.                 left: '265px',
  1161.                 share: 40
  1162.             },
  1163.             20: {
  1164.                 username: 'DevonAlexis',
  1165.                 place: 1,
  1166.                 month: 8,
  1167.                 year: 2010,
  1168.                 left: '165px',
  1169.                 share: 60
  1170.             },
  1171.             21: {
  1172.                 username: 'CandieCane',
  1173.                 place: 1,
  1174.                 month: 7,
  1175.                 year: 2010,
  1176.                 left: '320px',
  1177.                 share: 60
  1178.             },
  1179.             22: {
  1180.                 username: 'CrazySysy-2',
  1181.                 place: 1,
  1182.                 month: 9,
  1183.                 year: 2010,
  1184.                 left: '180px',
  1185.                 share: 60
  1186.             },
  1187.             23: {
  1188.                 username: 'BlondeFantasy',
  1189.                 place: 2,
  1190.                 month: 9,
  1191.                 year: 2010,
  1192.                 left: '190px',
  1193.                 share: 60
  1194.             },
  1195.             24: {
  1196.                 username: 'AshaSnow',
  1197.                 place: 2,
  1198.                 month: 8,
  1199.                 year: 2010,
  1200.                 left: '320px',
  1201.                 share: 60
  1202.             },
  1203.             25: {
  1204.                 username: 'AspenRae',
  1205.                 place: 1,
  1206.                 month: 10,
  1207.                 year: 2010,
  1208.                 left: '200px',
  1209.                 share: 60
  1210.             }
  1211.         },
  1212.         'asian': {
  1213.             1: {
  1214.                 username: 'ShowUTheWay',
  1215.                 place: 1,
  1216.                 month: 8,
  1217.                 year: 2009,
  1218.                 left: '340px',
  1219.                 share: 10
  1220.             },
  1221.             2: {
  1222.                 username: 'XHornymayxx',
  1223.                 place: 1,
  1224.                 month: 3,
  1225.                 year: 2010,
  1226.                 left: '340px',
  1227.                 share: 10
  1228.             },
  1229.             3: {
  1230.                 username: 'SexxyMel',
  1231.                 place: 3,
  1232.                 month: 2,
  1233.                 year: 2009,
  1234.                 left: '340px',
  1235.                 share: 0
  1236.             },
  1237.             4: {
  1238.                 username: 'UrMistress',
  1239.                 place: 2,
  1240.                 month: 10,
  1241.                 year: 2009,
  1242.                 left: '340px',
  1243.                 share: 10
  1244.             },
  1245.             5: {
  1246.                 username: 'ChynnaDoll18',
  1247.                 place: 3,
  1248.                 month: 5,
  1249.                 year: 2009,
  1250.                 left: '340px',
  1251.                 share: 0
  1252.             },
  1253.             6: {
  1254.                 username: 'FuckMyASS09',
  1255.                 place: 1,
  1256.                 month: 2,
  1257.                 year: 2010,
  1258.                 left: '260px',
  1259.                 share: 10
  1260.             },
  1261.             7: {
  1262.                 username: 'KimmyUSA',
  1263.                 place: 1,
  1264.                 month: 2,
  1265.                 year: 2010,
  1266.                 left: '295px',
  1267.                 share: 10
  1268.             },
  1269.             8: {
  1270.                 username: 'Pornsawan',
  1271.                 place: 2,
  1272.                 month: 7,
  1273.                 year: 2010,
  1274.                 left: '335px',
  1275.                 share: 10
  1276.             }
  1277.         }
  1278.     };
  1279.     var sBackgroundUrl;
  1280.     var sHideTopImg;
  1281.     if (g_hQS['h'] && hHeaderSets[g_sModelGroup][g_hQS['h']]) {
  1282.         nSet = g_hQS['h'];
  1283.         sBackgroundUrl = "http://files.myfreecams.com/mfc2/styles/mfc/images/header/top-header-tl-" + hHeaderSets[g_sModelGroup][nSet]['username'] + ".jpg";
  1284.     } else {
  1285.         nC = 0;
  1286.         var aShare = new Array();
  1287.         for (nK in hHeaderSets[g_sModelGroup]) {
  1288.             nC++;
  1289.             for (a = 0; a < hHeaderSets[g_sModelGroup][nK]['share']; a++) {
  1290.                 aShare.push(nK);
  1291.             }
  1292.         }
  1293.         nSet = aShare[Math.floor(aShare.length * Math.random())];
  1294.         sBackgroundUrl = "http://img.myfreecams.com/mfc2/styles/mfc/images/header/top-header-tl-" + hHeaderSets[g_sModelGroup][nSet]['username'] + ".jpg";
  1295.     }
  1296.     IdCache('miss_mfc_details').style.left = hHeaderSets[g_sModelGroup][nSet]['left'];
  1297.     IdCache('miss_mfc_name').innerHTML = hHeaderSets[g_sModelGroup][nSet]['username'].replace(/-\d+$/, '');
  1298.     IdCache('miss_mfc_date').innerHTML = g_aMonths[hHeaderSets[g_sModelGroup][nSet]['month']] + ' ' + hHeaderSets[g_sModelGroup][nSet]['year'];
  1299.     if (hHeaderSets[g_sModelGroup][nSet]['place'] == 1) {
  1300.         IdCache('miss_mfc_place').innerHTML = "Miss MyFreeCams";
  1301.     } else if (hHeaderSets[g_sModelGroup][nSet]['place'] == 2) {
  1302.         IdCache('miss_mfc_place').innerHTML = "Miss MyFreeCams 2nd Place";
  1303.     } else if (hHeaderSets[g_sModelGroup][nSet]['place'] == 3) {
  1304.         IdCache('miss_mfc_place').innerHTML = "Miss MyFreeCams 3rd Place";
  1305.     }
  1306.     IdCache('header_logo').src = sBackgroundUrl;
  1307. }
  1308.  
  1309. function LoadModelGroup() {
  1310.     LoadHeaderArt();
  1311.     if (g_bIE) {
  1312.         if (g_hModelGroupNameLookup[g_sHash] || !g_sHash) {
  1313.             if (g_sModelGroup != 'default') {
  1314.                 top.location.hash = g_hModelGroups[g_sModelGroup]['name'];
  1315.             } else {
  1316.                 top.location.hash = '';
  1317.             }
  1318.         }
  1319.     }
  1320. }
  1321. var g_bChangeModelGroup;
  1322.  
  1323. function ChangeModelGroup_Start(hOptions) {
  1324.     hOptions = hOptions || {};
  1325.     g_bChangeModelGroup = 1;
  1326.     g_sModelGroup = hOptions['model_group'];
  1327.     for (nId in g_hUsers) {
  1328.         if (g_hUsers[nId] && ((g_hUsers[nId]['friend'] && g_hUsers[nId]['friend'] == true) || nId == g_hSelf['user_id'] || typeof(g_hUsers[nId]['state']) == 'undefined' || (g_hUsers[nId]['username'] && g_hUsers[nId]['username'].indexOf('Lounge') > -1) || g_hoPMWindows[nId] || g_hUsers[nId]['model_history'])) {
  1329.             1;
  1330.         } else {
  1331.             delete g_hUsers[nId];
  1332.         }
  1333.     }
  1334.     for (var sK in g_hoPlayerWindows) {
  1335.         if (!g_hLoungeIds[sK]) {
  1336.             try {
  1337.                 if (g_hoPlayerWindows[sK]['handle'].Export().opener) {
  1338.                     g_hoPlayerWindows[sK]['handle'].Export().g_bCloseWindow = 1;
  1339.                     alert("When changing to a different homepage, you can only continue to view a model's room in popup mode if they are on your friends list. We apologize for the inconvenience.");
  1340.                 }
  1341.             } catch (oError) {
  1342.                 Log("Logout error: " + oError.description);
  1343.             }
  1344.         }
  1345.     }
  1346.     if (window.frames['main'] && window.frames['main'].g_bPlayerHTMLLoaded) {
  1347.         window.frames['main'].g_nPage = 1;
  1348.         window.frames['main'].CloseFlash();
  1349.         window.frames['main'].SetHTML('menu', "");
  1350.         window.frames['main'].SetHTML('player_main', "<div style='font-size:23px;font-weight:bold;color:#C7CEBD;padding:10px 10px;'>\nLoading...</div>");
  1351.     }
  1352.     g_hOnlineBlockHTML = {};
  1353.     LoadModelGroup();
  1354.     t.TxCmd(t.FCTYPE_MODELGROUP, g_nSessionId, 0, g_hModelGroups[g_sModelGroup]['bitmask'], 0);
  1355. }
  1356.  
  1357. function ChangeModelGroup_Finish() {
  1358.     LoadMenu();
  1359.     LoadBanner();
  1360.     LoadViewers();
  1361.     LoadFriendsList('menu_only');
  1362.     LoadAll();
  1363.     LoadLogin();
  1364. }
  1365.  
  1366. function LoadMenu(sMenuItems) {
  1367.     var nMenuMode;
  1368.     var sMenuItems = sMenuItems || '';
  1369.     if (!sMenuItems) {
  1370.         if (g_hSelf['access_level'] == 1) nMenuMode = 'registered';
  1371.         else if (g_hSelf['access_level'] == 2) nMenuMode = 'premium';
  1372.         else if (g_hSelf['access_level'] == 4) nMenuMode = 'model';
  1373.         else if (g_hSelf['access_level'] == 5) nMenuMode = 'premium';
  1374.         else nMenuMode = 'guest';
  1375.         var sMenuItems = "";
  1376.         for (nK in g_haMainMenuModes[nMenuMode]) {
  1377.             sResource = g_haMainMenuModes[nMenuMode][nK];
  1378.             if (sResource == 'lounge') {
  1379.                 if (g_sModelGroup == 'asian') {
  1380.                     sMenuItems += "<div id=btn_" + sResource + ">" + A("player", {
  1381.                         broadcaster_id: g_hLoungeIds['Asian_Lounge'],
  1382.                         target: 'main',
  1383.                         title: 'Go to the Asian Lounge'
  1384.                     }) + "Asian Lounge</a></div>";
  1385.                 } else {
  1386.                     sMenuItems += "<div id=btn_" + sResource + ">" + A("player", {
  1387.                         broadcaster_id: g_hLoungeIds['Lounge'],
  1388.                         target: 'main',
  1389.                         title: 'Go to the Lounge'
  1390.                     }) + "Lounge</a></div>";
  1391.                 }
  1392.             } else {
  1393.                 sMenuItems += "<div id=btn_" + sResource + ">" + A(sResource, {
  1394.                     'USERNAME': g_hSelf['username'],
  1395.                     'USER_ID': g_hSelf['user_id'],
  1396.                     user_invoked: 1
  1397.                 }) + g_hMainMenuOptions[sResource] + "</a></div>";
  1398.             }
  1399.         }
  1400.     }
  1401.     SetHTML('main_menu', sMenuItems);
  1402. }
  1403.  
  1404. function Logout(fDisconnected) {
  1405.     Log("Logout(" + fDisconnected + ")");
  1406.     g_hSelf = {};
  1407.     g_hIgnoredUsers = {};
  1408.     g_hEmoticonHTMLCache = {};
  1409.     g_hUsers = {};
  1410.     g_bLoginDone = false;
  1411.     g_bFCTYPE_MODELGROUP_Received = false;
  1412.     g_bFCTYPE_DETAILS_Received = false;
  1413.     for (nUserId in g_hUsers) {
  1414.         if (g_hUsers[nUserId]['state'] != w.FCVIDEO_UNKNOWN && g_hUsers[nUserId]['state']) {
  1415.             delete g_hUsers[nUserId];
  1416.         }
  1417.     }
  1418.     for (var sK in g_hoPMWindows) {
  1419.         try {
  1420.             g_hoPMWindows[sK]['handle'].Export().close();
  1421.         } catch (oError) {
  1422.             Log("Logout error: " + oError.description);
  1423.         }
  1424.     }
  1425.     for (var sK in g_hWindows) {
  1426.         try {
  1427.             g_hWindows[sK].close();
  1428.         } catch (oError) {
  1429.             Log("Error closing windows: " + oError.description);
  1430.         }
  1431.     }
  1432.     UpdateCookieHash();
  1433.     for (sK in g_hCk) {
  1434.         if (sK.match(/\x75\x73\x65\x72\x6E\x61\x6D\x65|\x71\x73|\x63\x68\x61\x74\x5F\x65\x6E\x61\x62\x6C\x65\x64/) || g_hC[sK]) {
  1435.             continue;
  1436.         }
  1437.         SetCookie(sK, '');
  1438.     }
  1439.     UpdateCookieHash();
  1440.     LoadFriendsList('reset');
  1441.     LoadLogin();
  1442.     LoadMenu();
  1443.     LoadBanner();
  1444.     LoadViewers();
  1445.     if (!fDisconnected) {
  1446.         Log('--- LogOut() : LoadAll() ------');
  1447.         LoadAll('');
  1448.     }
  1449.     if (g_sConnectionMode == 'java' && g_oChatApplet) {
  1450.         top.location.reload();
  1451.         return;
  1452.     } else {
  1453.         setTimeout("LoadAll();", 100);
  1454.     }
  1455.     Log('Logout() done.');
  1456. }
  1457.  
  1458. function LoadBanner(sContent) {
  1459.     if (sContent) {
  1460.         sBanner = " <div style=\"position:relative;\"> <div style=\"position:absolute;top:5px;left:-2px;height:36px;width:321px;\"> <table height=100% width=100%><td align=center valign=center> <div style='font-weight:bold;'>" + sContent + "</div> </td></table> </div> </div> ";
  1461.     } else {
  1462.         var nBannerMode = g_hSelf['access_level'] || 0;
  1463.         sContent = sContent || g_hBannerMessage[nBannerMode] || "";
  1464.         var nBannerMode = g_hSelf['access_level'] || 0;
  1465.         var sBanner = " <table width=100% height=100%> <td valign=center align=center> " + sContent + " </td> </table> ";
  1466.     }
  1467.     if (IdCache('menu_banner')) {
  1468.         SetHTML('menu_banner', sBanner);
  1469.     }
  1470. }
  1471.  
  1472. function LoadLogin(sContent) {
  1473.     sContent = sContent || "";
  1474.     if (!IdCache('login_box')) {
  1475.         return;
  1476.     }
  1477.     var sUsername = A('account') + g_hSelf['username'] + "</a>";
  1478.     if (!sContent && g_hSelf['access_level'] == 5) {
  1479.         sContent = "Hello <b>" + sUsername + "</b>! (MyFreeCams admin)";
  1480.     } else if (!sContent && g_hSelf['access_level'] >= 3) {
  1481.         sContent = "Hello <b>" + sUsername + "</b>! (MyFreeCams model)";
  1482.     } else if (!sContent && g_hSelf['access_level'] >= 2) {
  1483.         sContent = "Hello <b>" + sUsername + "</b>! (premium member)";
  1484.     } else if (!sContent && g_hSelf['access_level'] == 1) {
  1485.         sContent = "Hello <b>" + sUsername + "</b>! (basic member)";
  1486.     }
  1487.     if (g_hSelf['access_level'] > 0) {
  1488.         sContent = "<table cellpadding=0 cellspacing=0><td nowrap class=login_box_td>" + sContent + "</td><td class=login_box_td>&nbsp;" + " <input type=button value=Logout onClick=\"Load('logout');\" style='height:20px;width:50px;'>" + "</td></table>";
  1489.     } else if (!sContent) {
  1490.         var sUsername = ((g_hCk['username'] && g_hCk['username'].match(/^Guest\d+/)) || !g_hCk['username']) ? '' : g_hCk['username'];
  1491.         nVal = sUsername.charCodeAt(0) || 2;
  1492.         sContent = " <form name=login_form target=main method=POST action='../php/account.php' onSubmit=\";\"> <table cellpadding=0 cellspacing=0 height=15>\n <td nowrap class=login_box_td> <input type=hidden id=submit_login name=submit_login value=" + nVal + "> <input type=hidden name=uid id=login_uid value=\"" + g_nUID + "\"> Username &nbsp; </td> <td nowrap class=login_box_td> " + g.container("top,input_container") + "<input type=text name=username id=username_input value='" + sUsername + "' style=float:right; onChange=ProcessLoginInput(); onKeyUp=ProcessLoginInput(); onClick=ProcessLoginInput(); onPaste=ProcessLoginInput();>" + g.container("bottom,input_container") + " </td> <td nowrap class=login_box_td> &nbsp; Password &nbsp; </td> <td nowrap class=login_box_td> " + g.container("top,input_container") + "<input type=password id=password_input value='' name=password style=float:right; >" + g.container("bottom,input_container") + " </td> <td nowrap class=login_box_td> &nbsp; <input type=submit value=Login style='height:20px;width:36px;'> </td> </table> </form>";
  1493.     }
  1494.     var sH = "<table width=100% height=100%><td valign=center align=center class=login_box_td>" + sContent + "</td></table>";
  1495.     SetHTML('login_box', sH);
  1496.     if (IdCache('username_input') && IdCache('password_input')) {
  1497.         if (IdCache('username_input') && IdCache('username_input').value) {
  1498.             IdCache('password_input').focus();
  1499.         } else {
  1500.             IdCache('username_input').focus();
  1501.         }
  1502.     }
  1503. }
  1504.  
  1505. function ProcessLoginInput() {
  1506.     var nA = IdCache('username_input').value.charCodeAt(0) || 1;
  1507.     IdCache('submit_login').value = nA;
  1508. }
  1509.  
  1510. function Navigation(oCaller) {
  1511.     return '';
  1512.     var sH = "";
  1513.     if (oCaller.opener && oCaller.history.length > 0) {
  1514.         sH += "<a href='javascript:history.go(-1)' onMouseout=\"window.status=''; return true;\" onMouseover=\"window.status='Return to the previous page'; return true;\">Back</a> - \n";
  1515.     }
  1516.     if (oCaller.opener) {
  1517.         sH += "<a href='javascript:window.close()' onMouseout=\"window.status=''; return true;\" onMouseover=\"window.status='Close this window'; return true;\">Close</a> - " + A('help') + "Technical Help</a> - " + A('contact_help') + "Contact Us</a>";
  1518.     }
  1519.     return "<div class=footer_include style='clear:left;'>" + sH + "</div>";
  1520. }
  1521.  
  1522. function A(Arg1, Arg2, Arg3) {
  1523.     var oCaller = '',
  1524.         sResource = '',
  1525.         hOptions = {};
  1526.     if (typeof(Arg1) == 'object') {
  1527.         oCaller = Arg1 || '';
  1528.         sResource = Arg2 || '';
  1529.         hOptions = Arg3 || {};
  1530.     } else {
  1531.         sResource = Arg1 || '';
  1532.         hOptions = Arg2 || {};
  1533.     }
  1534.     var sOptions = "";
  1535.     for (sKey in hOptions) {
  1536.         if (sKey && hOptions[sKey]) {
  1537.             if (typeof(hOptions[sKey]) == 'string') hOptions[sKey] = hOptions[sKey].replace(/['"]/g, '');
  1538.            sOptions += sKey + ": '" + hOptions[sKey] + "',";
  1539.        }
  1540.    }
  1541.    if (sOptions) {
  1542.        sOptions = sOptions.substring(0, sOptions.length - 1);
  1543.    }
  1544.    if (g_hCache['a_tags'] && g_hCache['a_tags'][sResource] && g_hCache['a_tags'][sResource][sOptions] && !oCaller && g_hResources[sResource] && !g_hResources[sResource]['exclusive_window']) {
  1545.        if (oCaller) {
  1546.            oCaller.write(g_hCache['a_tags'][sResource][sOptions]);
  1547.            return;
  1548.        } else {
  1549.            return g_hCache['a_tags'][sResource][sOptions];
  1550.        }
  1551.    }
  1552.    if (sResource.match(/\?/)) sResource += '&';
  1553.    if (!g_hResources[sResource]) {
  1554.        g_hResources['temporary'] = hOptions || {};
  1555.        g_hResources['temporary']['page'] = sResource;
  1556.        g_hResources['temporary']['description'] = hOptions['description'] || '';
  1557.        sResource = 'temporary';
  1558.    }
  1559.    var sDescription = '';
  1560.    if (hOptions['title']) {
  1561.        sDescription = hOptions['title'];
  1562.    } else if (g_hResources[sResource]['description']) {
  1563.        sDescription = eval("MfcStringUtilities.prototype.parse_template(g_hResources['" + sResource + "']['description'],hOptions);");
  1564.    }
  1565.    var sTarget;
  1566.    if (hOptions['target']) {
  1567.        sTarget = hOptions['target'];
  1568.    } else if (g_hResources[sResource] && g_hResources[sResource]['target']) {
  1569.        sTarget = g_hResources[sResource]['target'];
  1570.    } else {
  1571.        sTarget = sDefaultTarget;
  1572.    }
  1573.    var sPage = '';
  1574.    if (g_hResources[sResource]['page']) {
  1575.        sPage = MfcStringUtilities.prototype.parse_template(g_hResources[sResource]['page'], hOptions);
  1576.    }
  1577.    var sWindowStatus = '';
  1578.    if (g_hResources[sResource]['description']) {
  1579.        sWindowStatus = MfcStringUtilities.prototype.parse_template(g_hResources[sResource]['description'], hOptions);
  1580.    }
  1581.    var sQueryString = "";
  1582.    if (sPage && !sResource.match(/profiles|my_profile|bio/)) {
  1583.        for (sKey in hOptions) {
  1584.            if (sKey && hOptions[sKey]) {
  1585.                sQueryString += sKey + "=" + escape(hOptions[sKey]) + "&";
  1586.            }
  1587.        }
  1588.        if (sQueryString) {
  1589.            sPage += ((-1 < sPage.indexOf("?")) ? '&' : '?') + sQueryString;
  1590.        }
  1591.    }
  1592.    sLoadEvent = "t.Load('" + sResource + "',{" + sOptions + "},self);";
  1593.    if (!sPage || (window.frames[sTarget] && window.frames[sTarget].LoadPlayer) || (sResource == 'homepage')) {
  1594.        sAction = " href=# onClick=\"" + sLoadEvent + " return false;\"";
  1595.    } else if (sTarget == '_blank') {
  1596.        if (hOptions['anchor']) sPage += '#' + hOptions['anchor'];
  1597.         sAction = " href=\"" + sPage + "\" target=" + sTarget + " ";
  1598.     } else if (sTarget == 'new_window') {
  1599.         var sNewWindowParams;
  1600.         if (sResource == 'pm_friend') {
  1601.             var nWidth = hOptions['load_video'] ? 650 : 500;
  1602.             sNewWindowParams = g_hResources[sResource]['new_window'] + ',width=' + nWidth;
  1603.         } else if (g_hResources[sResource]['new_window'] != undefined) {
  1604.             sNewWindowParams = g_hResources[sResource]['new_window'];
  1605.         } else {
  1606.             sNewWindowParams = sNewWindowDefaults;
  1607.         }
  1608.         var sWindowKey;
  1609.         if (sResource == 'player') {
  1610.             sWindowKey = PublicChannel(hOptions['broadcaster_id']);
  1611.         } else if (sResource == 'pm_friend') {
  1612.             sWindowKey = sResource + hOptions['user_id'];
  1613.         } else if (g_hResources[sResource]['exclusive_window']) {
  1614.             sWindowKey = sResource + parseInt(Math.random() * 100000);
  1615.         } else {
  1616.             sWindowKey = sResource + (hOptions['user_id'] || hOptions['broadcaster_id'] || '');
  1617.         }
  1618.         var sExtra = '';
  1619.         if (sResource.match(/purchase|message|account|exclusive_gallery|chat_logs/)) {
  1620.             sPage += ((-1 < sPage.indexOf("?")) ? '&' : '?') + "no-cache='+Math.random()+'";
  1621.         }
  1622.         if (hOptions['anchor']) {
  1623.             sPage += '#' + hOptions['anchor'];
  1624.         }
  1625.         sAction = "\n href=# onClick=\" A_Click('" + sWindowKey + "','" + sPage + "','" + sNewWindowParams + "','" + sLoadEvent.replace(/'/g, "\\'") + "','" + sTarget + "'); return false; \" oncontextmenu=\" return false;\" ";
  1626.    } else if (t.frames[sTarget]) {
  1627.        if (!sResource.match(/profiles|my_profile/)) {
  1628.            sPage += ((-1 < sPage.indexOf("?")) ? '&' : '?') + "no-cache='+Math.random()+'";
  1629.        }
  1630.        if (hOptions['anchor']) {
  1631.            sPage += '#' + hOptions['anchor'];
  1632.         }
  1633.         if (g_hSelf['rule_violation'] == 1 && (sResource == 'player' || sResource == 'homepage' || sResource == 'asian_homepage')) {
  1634.             sAction = " href=# onClick=\" if( g_hSelf['rule_violation'] == 1 ) { return false; } t.frames['" + sTarget + "'].location.replace('" + sPage + "');" + sLoadEvent + "; return false;\" ";
  1635.         } else {
  1636.             sAction = " href=# onClick=\"t.frames['" + sTarget + "'].location.replace('" + sPage + "');" + sLoadEvent + "; return false;\" ";
  1637.         }
  1638.     } else {
  1639.         if (!sResource.match(/profiles|my_profile/)) {
  1640.             sPage += ((-1 < sPage.indexOf("?")) ? '&' : '?') + "no-cache=" + Math.random();
  1641.         }
  1642.         if (hOptions['anchor']) sPage += '#' + hOptions['anchor'];
  1643.         sAction = " href=\"" + sPage + "\" target=" + sTarget + " onClick=\"" + sLoadEvent + "\"; return false;";
  1644.     }
  1645.     var sExtraTagDefs = "";
  1646.     if (hOptions['supress_decoration']) {
  1647.         sExtraTagDefs = " style=\"text-decoration:none;\" ";
  1648.     } else if (hOptions['style']) {
  1649.         sExtraTagDefs = " style=\"" + hOptions['style'] + "\" ";
  1650.     }
  1651.     var sLink = "<a " + sAction + "\n " + sExtraTagDefs + "\n title=\"" + sDescription + "\"\n >";
  1652.     if (g_hQS['mode'] == "under_construction") sLink = "<a href='#'></a>";
  1653.     if (!g_hCache['a_tags'][sResource]) g_hCache['a_tags'][sResource] = {};
  1654.     g_hCache['a_tags'][sResource][sOptions] = sLink;
  1655.     if (oCaller) {
  1656.         oCaller.write(sLink);
  1657.     } else {
  1658.         return sLink;
  1659.     }
  1660. }
  1661.  
  1662. function StateDump(sException) {
  1663.     var sLog = "Username: " + g_hCk['username'] + "<br>Exception: " + sException + "<br><br><b>Cookies:<br><table cellpadding=0 cellspacing=1>";
  1664.     for (sK in g_hCk) {
  1665.         sLog += "<tr><td>" + sK + "&nbsp;</td><td>" + g_hCk[sK] + "</td></tr>";
  1666.     }
  1667.     sLog += "</table><br><b>Windows:<br><table cellpadding=0 cellspacing=1>";
  1668.     for (sK in g_hWindows) sLog += "<tr><td>" + sK + "&nbsp;</td><td>" + (g_hWindows[sK].location ? g_hWindows[sK].location.href : "no location!") + "</td></tr>";
  1669.     sLog += "</table><br>" + g_sLogDump;
  1670.     try {
  1671.         g_oStateDumpReq.open("POST", "../php/state_dump.php", true);
  1672.         g_oStateDumpReq.onreadystatechange = Time_Response;
  1673.         g_oStateDumpReq.send(sLog);
  1674.     } catch (oError) {
  1675.         Log('ajax open caught exception');
  1676.     }
  1677. }
  1678.  
  1679. function Log(sMessage) {
  1680.     if (!g_bDebug || !g_sLogDump || !parent.frames || !parent.frames['debug']) {
  1681.         return;
  1682.     }
  1683.     if (!g_oStartLogTime) {
  1684.         var oTime = new Date();
  1685.         g_oStartLogTime = oTime.getTime();
  1686.     }
  1687.     if (g_sLogDump.length > 7000) {
  1688.         g_sLogDump = g_sLogDump.substring(5000, g_sLogDump.length);
  1689.     }
  1690.     g_sLogDump += sMessage + "</b><br>";
  1691.     "".match(/()/);
  1692.     var aMatches = top.location.search.match(/debug=([^&]+)/g);
  1693.     if (aMatches) {
  1694.         var bConditions = 0;
  1695.         var bFailures = 0;
  1696.         for (a = 0; a < aMatches.length; a++) {
  1697.             if (typeof(sMessage) == 'string') {
  1698.                 var aPair = aMatches[a].split('=');
  1699.                 if (aPair[1].charAt(0) == '-') {
  1700.                     if (sMessage.indexOf(aPair[1].substring(1)) > -1) {
  1701.                         return;
  1702.                     }
  1703.                 } else {
  1704.                     bConditions++;
  1705.                     if (sMessage.indexOf(aPair[1]) == -1) {
  1706.                         bFailures++;
  1707.                     }
  1708.                 }
  1709.             }
  1710.         }
  1711.         if (bFailures && bFailures == bConditions) {
  1712.             return;
  1713.         }
  1714.     }
  1715.     var oCurrentLogTime = new Date();
  1716.     var nTotalTime = (oCurrentLogTime.getTime() - g_oStartLogTime) / 1000;
  1717.     var sTotalTime = nTotalTime.toString();
  1718.     while (sTotalTime.length < 7) sTotalTime = sTotalTime += ' ';
  1719.     var nTimeDiff = g_oLastLogTime ? ((oCurrentLogTime.getTime() - g_oLastLogTime) / 1000) : 0;
  1720.     var sTimeDiff = nTimeDiff.toString();
  1721.     while (sTimeDiff.length < 7) sTimeDiff = sTimeDiff += ' ';
  1722.     g_oLastLogTime = oCurrentLogTime.getTime();
  1723.     WriteLog(g_nLogCx + " [" + sTotalTime + "] [" + sTimeDiff + "] " + sMessage + "\n");
  1724.     g_nLogCx++;
  1725. }
  1726.  
  1727. function WriteLog(sMessage) {
  1728.     if (g_bLogPause) return;
  1729.     g_sLogBuffer += sMessage || '';
  1730.     if (g_bLogRealtime) {
  1731.         IdCache(parent.frames['debug'].document, 'debug').scrollTop = 99999999999;
  1732.         IdCache(parent.frames['debug'].document, 'debug').value += g_sLogBuffer;
  1733.         IdCache(parent.frames['debug'].document, 'debug').scrollTop = 99999999999;
  1734.         g_sLogBuffer = '';
  1735.     } else {
  1736.         if (g_bLogWriteLock == false) {
  1737.             IdCache(parent.frames['debug'].document, 'debug').scrollTop = 99999999999;
  1738.             IdCache(parent.frames['debug'].document, 'debug').value += g_sLogBuffer;
  1739.             IdCache(parent.frames['debug'].document, 'debug').scrollTop = 99999999999;
  1740.             g_sLogBuffer = '';
  1741.             setTimeout(" g_bLogWriteLock = false; WriteLog(); ", 500);
  1742.         }
  1743.         g_bLogWriteLock = true;
  1744.     }
  1745. }
  1746. var g_hCmdMap = {};
  1747. var g_hCmdMap_FcType = {};
  1748. var g_oParseCommandSuspend = 0;
  1749. var g_aParseCommandBuffer = new Array();
  1750.  
  1751. function ParseCommand(sCommand) {
  1752.     if (sCommand == 'suspend') {
  1753.         if (g_oParseCommandSuspend) {
  1754.             clearTimeout(g_oParseCommandSuspend);
  1755.         }
  1756.         g_oParseCommandSuspend = setTimeout(" g_oParseCommandSuspend = 0; ParseCommand(); ", 1000);
  1757.         return;
  1758.     }
  1759.     if (sCommand) {
  1760.         g_aParseCommandBuffer.push(sCommand);
  1761.     }
  1762.     if (g_oParseCommandSuspend) {
  1763.         return;
  1764.     }
  1765.     var tm = new MfcTimer;
  1766.     while (g_aParseCommandBuffer.length > 0) {
  1767.         var sCmd = g_aParseCommandBuffer.shift();
  1768.         tm.Start();
  1769.         ParseLine(sCmd);
  1770.         tm.Stop(100, "top/ParseLine - " + sCmd);
  1771.     }
  1772. }
  1773.  
  1774. function ParseLine(sCommand) {
  1775.     if (sCommand == null || sCommand.length < 2) {
  1776.         return;
  1777.     }
  1778.     var aPacket = sCommand.split(' ');
  1779.     var nType = parseInt(aPacket.shift());
  1780.     var nFrom = aPacket.shift();
  1781.     var nTo = aPacket.shift();
  1782.     var nArg1 = aPacket.shift();
  1783.     var nArg2 = aPacket.shift();
  1784.     var sPayload = aPacket.join(' ');
  1785.     var sMessage = unescape(sPayload);
  1786.     if (g_hTypeMap[nType]) {
  1787.         Log("RX: " + MfcStringUtilities.prototype.char_padding(g_hTypeMap[nType], 20, ' ', 'right') + " " + unescape(sCommand));
  1788.     } else {
  1789.         Log("RX: " + MfcStringUtilities.prototype.char_padding(('UNKNOWN TYPE: ' + nType), 20, ' ', 'right') + " " + unescape(sCommand));
  1790.     }
  1791.     var fUpdateHash = true;
  1792.     if (nType == FCTYPE_PMESG && nArg1 == FCCHAN_OLDMSG) {
  1793.         fUpdateHash = false;
  1794.     }
  1795.     var fHistorical = false;
  1796.     if (nType == FCTYPE_CMESG && nArg2 & FCCHAN_OLDMSG) {
  1797.         fHistorical = true;
  1798.     }
  1799.     var nUserId = 0;
  1800.     if (nType == FCTYPE_DETAILS || nType == FCTYPE_ADDFRIEND || nType == FCTYPE_ADDIGNORE || nType == FCTYPE_SESSIONSTATE || nType == FCTYPE_CMESG || nType == FCTYPE_PMESG || nType == FCTYPE_TXPROFILE || nType == FCTYPE_USERNAMELOOKUP || nType == FCTYPE_MYCAMSTATE || nType == FCTYPE_SETGUESTNAME || (nType == FCTYPE_JOINCHAN && nArg2 != FCCHAN_PART)) {
  1801.         nUserId = StoreUserHash(sPayload, fUpdateHash, fHistorical, nType) || 0;
  1802.     }
  1803.     var nPmStamp = 0;
  1804.     if (nType == FCTYPE_PMESG) {
  1805.         hArgs = sPayload.split(':');
  1806.         if (hArgs.length > 8) {
  1807.             nPmStamp = hArgs[8].split('/')[0];
  1808.         }
  1809.     }
  1810.     switch (nType) {
  1811.     case FCTYPE_ADDFRIENDREQ:
  1812.         {
  1813.             if (w.FCRESPONSE_ERROR == nArg1) {
  1814.                 alert("You have reached the maximum number of friends allowed. Please click Manage Friends and remove some friends before adding more.");
  1815.             }
  1816.         }
  1817.         break;
  1818.     case FCTYPE_STATUSGRP:
  1819.         {
  1820.             var nModelId = GetRoomOwnerId(nArg1);
  1821.             if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle'] && g_hoPlayerWindows[nModelId]['handle'].Export) {
  1822.                 try {
  1823.                     g_hoPlayerWindows[nModelId]['handle'].Export().g_oGroupShow.Status(sPayload);
  1824.                 } catch (oError) {
  1825.                     Log("Try Catch Failure on GroupShow.Status (" + sK + "): " + oError.description);
  1826.                 }
  1827.             }
  1828.         }
  1829.         break;
  1830.     case FCTYPE_REQUESTGRP:
  1831.         {
  1832.             var nModelId = GetRoomOwnerId(nTo);
  1833.             var nType = nArg1;
  1834.             var nCode = nArg2;
  1835.             if (nType == FCRESPONSE_ERROR) {
  1836.                 if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle'] && g_hoPlayerWindows[nModelId]['handle'].Export) {
  1837.                     try {
  1838.                         g_hoPlayerWindows[nModelId]['handle'].Export().g_oGroupShow.Error(nArg1, nArg2);
  1839.                     } catch (oError) {
  1840.                         Log("Try Catch Failure on GroupShow.Status (" + sK + "): " + oError.description);
  1841.                     }
  1842.                 }
  1843.             }
  1844.         }
  1845.     case FCTYPE_GROUPCHAT:
  1846.         {
  1847.             nUserId = GetRoomOwnerId(nArg1);
  1848.             var nGroupSessId = nArg2;
  1849.             var nPubChan = PublicChannel(nUserId);
  1850.             var nGroupChan = SessionChannel(nUserId);
  1851.             if (g_hoPlayerWindows[nUserId] && g_hoPlayerWindows[nUserId]['handle'] && g_hoPlayerWindows[nUserId]['handle'].Export) {
  1852.                 try {
  1853.                     g_hoPlayerWindows[nUserId]['handle'].Export().FcAcceptGroupShow(nUserId, nPubChan, nGroupChan, nGroupSessId);
  1854.                 } catch (oError) {
  1855.                     Log("Try Catch Failure #7: " + oError.description);
  1856.                 }
  1857.             }
  1858.             for (nLoungeId in g_hLoungeIds) {
  1859.                 if (g_hoPlayerWindows[nLoungeId] && g_hoPlayerWindows[nLoungeId]['handle'] && g_hoPlayerWindows[nLoungeId]['handle'].Export) {
  1860.                     if (g_hoPlayerWindows[nLoungeId]['handle'].Export().g_nLoungeModel == nUserId) {
  1861.                         try {
  1862.                             g_hoPlayerWindows[nLoungeId]['handle'].Export().FcAcceptGroupShow(nUserId, nPubChan, nGroupChan, nGroupSessId);
  1863.                         } catch (oError) {
  1864.                             Log("Try Catch Failure #7: " + oError.description);
  1865.                         }
  1866.                     }
  1867.                 }
  1868.             }
  1869.             if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export) {
  1870.                 try {
  1871.                     g_hoPMWindows[nUserId]['handle'].Export().FcAcceptGroupShow(nUserId, nPubChan, nGroupChan, nGroupSessId);
  1872.                 } catch (oError) {
  1873.                     Log("Try Catch Failure #8: " + oError.description);
  1874.                 }
  1875.             }
  1876.         }
  1877.         break;
  1878.     case FCTYPE_CLOSEGRP:
  1879.         {
  1880.             var nModelId = GetRoomOwnerId(nArg1);
  1881.             if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle'] && g_hoPlayerWindows[nModelId]['handle'].Export) {
  1882.                 try {
  1883.                     g_hoPlayerWindows[nModelId]['handle'].Export().g_oGroupShow.Shutdown(nArg2);
  1884.                 } catch (oError) {
  1885.                     Log("Try Catch Failure on GroupShow.Shutdown (" + sK + "): " + oError.description);
  1886.                 }
  1887.             }
  1888.         }
  1889.         break;
  1890.     case FCTYPE_REQUESTPVT:
  1891.         {
  1892.             if (nArg2 == FCRESPONSE_ERROR) {
  1893.                 alert("Sorry, the model was unavailable or unable to accept your request for a private session.");
  1894.             }
  1895.         }
  1896.     case FCTYPE_PMHISTORY:
  1897.         {
  1898.             FcPMHistory(nArg1, nArg2, sPayload);
  1899.         }
  1900.         break;
  1901.     case FCTYPE_SERVERREFRESH:
  1902.         {
  1903.             ServerRefresh();
  1904.         }
  1905.         break;
  1906.     case FCTYPE_PRIVACY:
  1907.         {
  1908.             g_hSelf['privacy_state'] = nArg2;
  1909.         }
  1910.         break;
  1911.     case FCTYPE_SETTING:
  1912.         {
  1913.             FcSetting(nArg1, nArg2, sPayload);
  1914.         }
  1915.         break;
  1916.     case FCTYPE_BWSTATS:
  1917.         {
  1918.             g_hUsers[nTo] = g_hUsers[nTo] || {};
  1919.             aGroupedStats = sPayload.split('|');
  1920.             for (nK in aGroupedStats) {
  1921.                 aStats = aGroupedStats[nK].split(',');
  1922.                 g_hUsers[aStats[0]] = g_hUsers[aStats[0]] || {};
  1923.                 g_hUsers[aStats[0]]['kbps'] = aStats[1];
  1924.                 g_hUsers[aStats[0]]['ping'] = aStats[2];
  1925.             }
  1926.         }
  1927.         break;
  1928.     case FCTYPE_RULEVIOLATION:
  1929.         {
  1930.             if (sPayload.indexOf('{') > -1 && sPayload.indexOf('}') > -1 && sPayload.indexOf(':') > -1) {
  1931.                 1;
  1932.             } else {
  1933.                 Load('rule_violation', {
  1934.                     violation: sPayload
  1935.                 });
  1936.                 g_hSelf['rule_violation'] = 1;
  1937.             }
  1938.         }
  1939.         break;
  1940.     case FCTYPE_HIDEUSERS:
  1941.         {
  1942.             if (sPayload) {
  1943.                 var aList = sPayload.split(',');
  1944.                 for (nK in aList) {
  1945.                     g_hUsers[aList[nK]] = g_hUsers[aList[nK]] || {};
  1946.                     g_hUsers[aList[nK]]['hidden'] = 1;
  1947.                 }
  1948.             }
  1949.         }
  1950.         break;
  1951.     case FCTYPE_INBOX:
  1952.         {
  1953.             InboxAlert(nArg1);
  1954.         }
  1955.         break;
  1956.     case FCTYPE_SETGUESTNAME:
  1957.         {
  1958.             SetGuestUsername_Response(nArg1);
  1959.         }
  1960.         break;
  1961.     case FCTYPE_MODELGROUP:
  1962.         {
  1963.             if (nArg2 == 1) {
  1964.                 g_bFCTYPE_MODELGROUP_Received = true;
  1965.             }
  1966.             if (g_bFCTYPE_DETAILS_Received && g_bFCTYPE_MODELGROUP_Received && !g_bLoginDone) {
  1967.                 g_bLoginDone = true;
  1968.                 PostLoginProcedures();
  1969.             }
  1970.             FcModelGroup(nArg1, nArg2);
  1971.         }
  1972.         break;
  1973.     case FCTYPE_SLAVEVSHARE:
  1974.         {
  1975.             SharedVideoHandler(nArg1, nArg2);
  1976.         }
  1977.         break;
  1978.     case FCTYPE_NEWSITEM:
  1979.         {
  1980.             NewsItem(sPayload);
  1981.         }
  1982.         break;
  1983.     case FCTYPE_ROOMDATA:
  1984.         {
  1985.             RoomData(sPayload);
  1986.         }
  1987.         break;
  1988.     case FCTYPE_STARTVOYEUR:
  1989.         {
  1990.             StartVoyeur(nArg1, nArg2);
  1991.         }
  1992.         break;
  1993.     case FCTYPE_LOGIN:
  1994.         {
  1995.             FcLogin(nTo, nArg1, nArg2, sPayload);
  1996.         }
  1997.         break;
  1998.     case FCTYPE_BANCHAN:
  1999.         {
  2000.             if (nFrom == 0 && nTo == 0 && nArg1 == 0 && nArg2 == 0) {
  2001.                 top.location = "http://www.myfreecams.com/redirection.html?chat_block=1";
  2002.                 return;
  2003.             }
  2004.             var nRoomOwnerId = GetRoomOwnerId(nTo);
  2005.             if (g_hoPlayerWindows[nRoomOwnerId]) {
  2006.                 Load('user_banned');
  2007.                 return;
  2008.             } else if (g_hWindows[nTo]) {
  2009.                 g_hWindows[nTo].alert("The model has temporarily banned you from her room. Your ban will be lifted after a short period of time and you may still access other rooms on our site.\n\n Please remember to be polite to our models and users to avoid being banned in the future.\n\n If you are a guest, it's possible that the model banned you by accident. Please login or register for your free account to avoid being banned. Thanks, and please contact us if you have any problems.");
  2010.                 if (g_hWindows[nTo].opener) g_hWindows[nTo].close();
  2011.                 else if (g_hWindows[nTo].LoadPlayer) g_hWindows[nTo].LoadPlayer("homepage");
  2012.                 delete g_hWindows[nTo];
  2013.             }
  2014.         }
  2015.         break;
  2016.     case FCTYPE_ENDSESSION:
  2017.         {
  2018.             var nModelId = nArg1;
  2019.             var nSessionType = nArg2;
  2020.             FcEndSessions(nModelId, nSessionType);
  2021.         }
  2022.         break;
  2023.     case FCTYPE_TXPROFILE:
  2024.         {
  2025.             var nClientSessionsId = nTo;
  2026.             var nModelId = nArg1;
  2027.             var nBitRate = nArg2;
  2028.             FcTxProfile(nModelId, nBitRate, '');
  2029.         }
  2030.         break;
  2031.     case FCTYPE_CONNECTING:
  2032.         {
  2033.             Log('** CONNECTING *** g_nConnectingMode : ' + nType + ', count -3');
  2034.             g_nConnectingMode = nType;
  2035.             g_nBroadcasterCount = -3;
  2036.             try {
  2037.                 for (sK in g_hoPlayerWindows) {
  2038.                     if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  2039.                         try {
  2040.                             g_hoPlayerWindows[sK]['handle'].Export().RefreshOnlineBroadcasterList('force');
  2041.                         } catch (oError) {
  2042.                             Log("Try Catch Failure #2: " + oError.description);
  2043.                         }
  2044.                     }
  2045.                 }
  2046.             } catch (oError) {
  2047.                 1;
  2048.             }
  2049.             if (window.frames['ajaxframe']) zgw_Server('connecting');
  2050.         }
  2051.         break;
  2052.     case FCTYPE_ZGWINVALID:
  2053.         {
  2054.             zgw_Error('Invalid Session');
  2055.         }
  2056.         break;
  2057.     case FCTYPE_CONNECTED:
  2058.         {
  2059.             Log('** CONNECTING *** g_nConnectingMode : ' + nType + ', count -2');
  2060.             g_nConnectingMode = nType;
  2061.             g_nBroadcasterCount = -2;
  2062.             for (sK in g_hUsers) {
  2063.                 if (g_hUsers[sK]) {
  2064.                     g_hUsers[sK]['state'] = t.FCVIDEO_UNKNOWN;
  2065.                 }
  2066.             }
  2067.             if (g_sConnectionMode == 'ajax') {
  2068.                 sUser = g_hCk['username'] || 'guest';
  2069.                 sPass = g_hCk['passcode'] || 'guest';
  2070.                 if (sPass == 'guest' || sPass == 'undefined') {
  2071.                     sUser = sPass = 'guest';
  2072.                 }
  2073.                 var sData = '';
  2074.                 if (g_sHash) {
  2075.                     sData = sHash + '/';
  2076.                 }
  2077.                 sData += sUser;
  2078.                 zgw_TxLogin(sPayload, sData, sPass);
  2079.             }
  2080.             Log("RefreshOnlineBroadcasterList('force') from FCTYPE_CONNECTED");
  2081.             for (sK in g_hWindows) {
  2082.                 if (g_hWindows[sK].RefreshOnlineBroadcasterList) {
  2083.                     g_hWindows[sK].RefreshOnlineBroadcasterList('force');
  2084.                 }
  2085.             }
  2086.         }
  2087.         break;
  2088.     case FCTYPE_LOGOUT:
  2089.         {
  2090.             Logout();
  2091.             alert('You have logged in from a different location, this connection has logged out and will log back in as a guest.');
  2092.         }
  2093.         break;
  2094.     case FCTYPE_DISCONNECTED:
  2095.         {
  2096.             Log('*** DISCONNECTED FROM SERVER **** ConnectingMode : ' + nType + ', count -3');
  2097.             g_nConnectingMode = nType;
  2098.             Log("RefreshOnlineBroadcasterList('force') from FCTYPE_DISCONNECTED");
  2099.             for (sK in g_hWindows) {
  2100.                 if (g_hWindows[sK].RefreshOnlineBroadcasterList) {
  2101.                     g_hWindows[sK].RefreshOnlineBroadcasterList('force');
  2102.                 }
  2103.             }
  2104.             if (g_fConnected == true) {
  2105.                 g_hUsers = {};
  2106.                 g_nBroadcasterCount = -3;
  2107.                 LoadFriendsList('disconnected');
  2108.                 zgw_Disconnect();
  2109.                 if (window.frames['main'].location.href.match(/player.html/)) {
  2110.                     Load('homepage');
  2111.                 }
  2112.                 for (sK in g_hWindows) {
  2113.                     if (g_hWindows[sK].LoadPlayer && g_hWindows[sK].opener) {
  2114.                         g_hWindows[sK].close();
  2115.                         delete g_hWindows[sK];
  2116.                     }
  2117.                 }
  2118.             }
  2119.             if (g_sConnectionMode == 'java') {
  2120.                 if (g_bCreatedAppletCalled == true) {
  2121.                     g_bCreatedAppletCalled = false;
  2122.                     setTimeout(CreateJavaApplet, 750);
  2123.                 }
  2124.             }
  2125.         }
  2126.         break;
  2127.     case FCTYPE_ADDFRIEND:
  2128.         {
  2129.             g_nRxFriends++;
  2130.             FcAddFriend(nArg1, nArg2);
  2131.         }
  2132.         break;
  2133.     case FCTYPE_ADDIGNORE:
  2134.         {
  2135.             FcAddIgnore(nArg1, nArg2);
  2136.         }
  2137.         break;
  2138.     case FCTYPE_STUDIO:
  2139.         {
  2140.             if (g_hWindows[PublicChannel(nArg2)] && g_hWindows[PublicChannel(nArg2)].PlayerQueue) {
  2141.                 if (nArg2 == FCRESPONSE_ERROR) {
  2142.                     g_hWindows[PublicChannel(nArg2)].PlayerQueue("chat", "<font class=chat_notice>No studio found for " + nArg1 + "</font>");
  2143.                 } else {
  2144.                     g_hWindows[PublicChannel(nArg2)].PlayerQueue("chat", "<font class=chat_notice>Studio: " + sMsg + "</font>");
  2145.                 }
  2146.             } else {
  2147.                 Log('Unable to deliver studio response, no window to deliver to');
  2148.             }
  2149.         }
  2150.         break;
  2151.     case FCTYPE_ANNOUNCE:
  2152.         {
  2153.             var hMessage = ParseJSON(unescape(sMessage));
  2154.             if (hMessage) {
  2155.                 for (var sK in g_hoPlayerWindows) {
  2156.                     if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  2157.                         try {
  2158.                             g_hoPlayerWindows[sK]['handle'].Export().ChatAnnounce(hMessage['msg']);
  2159.                         } catch (oError) {
  2160.                             Log("Try Catch Failure #3: " + oError.description);
  2161.                         }
  2162.                     }
  2163.                 }
  2164.             }
  2165.         }
  2166.         break;
  2167.     case FCTYPE_MYCAMSTATE:
  2168.         {
  2169.             if (nArg1 == FCCHAN_JOIN) {
  2170.                 g_hUsers[nUserId]['webcam_viewer'] = 1;
  2171.             } else if (nArg1 == FCCHAN_PART) {
  2172.                 g_hUsers[nUserId]['webcam_viewer'] = 0;
  2173.             }
  2174.             LoadViewers();
  2175.         }
  2176.         break;
  2177.     case FCTYPE_MYWEBCAM:
  2178.         {
  2179.             if (g_hUsers[nArg2]) {
  2180.                 g_hUsers[nArg2]['broadcasting_video'] = nArg1;
  2181.                 LoadFriendsList();
  2182.                 for (sK in g_hoPMWindows) {
  2183.                     if (sK == nArg2 && g_hoPMWindows[sK]['handle'] && g_hoPMWindows[sK]['handle'].Export) {
  2184.                         try {
  2185.                             g_hoPMWindows[sK]['handle'].Export().ConfigureUserControls();
  2186.                             if (nArg1 > 0) {
  2187.                                 if (g_hoPMWindows[sK]['handle'].Export().LoadVideoMenu) g_hoPMWindows[sK]['handle'].Export().LoadVideoMenu();
  2188.                                 if (g_hoPMWindows[sK]['handle'].Export().LoadVideo) g_hoPMWindows[sK]['handle'].Export().LoadVideo();
  2189.                             } else {
  2190.                                 if (g_hoPMWindows[sK]['handle'].Export().LoadVideo) g_hoPMWindows[sK]['handle'].Export().LoadVideo('pre_unload');
  2191.                             }
  2192.                         } catch (oError) {
  2193.                             Log("Try Catch Failure #4: " + oError.description);
  2194.                         }
  2195.                     }
  2196.                 }
  2197.                 for (sK in g_hoPlayerWindows) {
  2198.                     if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  2199.                         try {
  2200.                             g_hoPlayerWindows[sK]['handle'].Export().FcCamState(nArg2);
  2201.                         } catch (oError) {
  2202.                             Log("Try Catch Failure #32: " + oError.description);
  2203.                         }
  2204.                     }
  2205.                 }
  2206.                 if (nArg2 == g_hSelf['user_id']) {
  2207.                     if (nArg1 > 0) {
  2208.                         SetHTML('broadcast_status', "<b>Webcam Running</b>");
  2209.                     } else {
  2210.                         SetHTML('broadcast_status', "Start My Webcam");
  2211.                     }
  2212.                 }
  2213.             }
  2214.         }
  2215.         break;
  2216.     case FCTYPE_SESSIONSTATE:
  2217.         {
  2218.             if (nUserId == 0) {
  2219.                 nUserId = g_hCk['user_id'];
  2220.             }
  2221.             try {
  2222.                 if (g_hoPlayerWindows[nArg2] && g_hoPlayerWindows[nArg2]['handle'] && g_hoPlayerWindows[nArg2]['handle'].Export) {
  2223.                     try {
  2224.                         g_hoPlayerWindows[nArg2]['handle'].Export().g_oGroupShow.UpdateCounter();
  2225.                     } catch (oError) {
  2226.                         Log("Try Catch Failure #6: " + oError.description);
  2227.                     }
  2228.                 }
  2229.             } catch (oError) {
  2230.                 Log("g_oGroupShow.UpdateCounter error: " + oError.description);
  2231.             }
  2232.             if (g_hUsers[nArg2] && g_hUsers[nArg2]['access_level'] == 4 && nArg1 > 90 && g_hUsers[nArg2]['model_history']) {
  2233.                 ModelHistory();
  2234.             }
  2235.             if (g_bLoginDone && g_hUsers[nUserId] && g_hUsers[nUserId]['friend']) {
  2236.                 LoadFriendsList();
  2237.             }
  2238.             FcSessionState(nFrom, nArg1, nArg2 == 0 ? nUserId : nArg2);
  2239.         }
  2240.         break;
  2241.     case FCTYPE_TOKENINC:
  2242.         {
  2243.             TokenInc(nArg1);
  2244.         }
  2245.         break;
  2246.     case FCTYPE_DETAILS:
  2247.         {
  2248.             if (g_nSessionId == nTo && nFrom == 0) {
  2249.                 g_hSelf['tokens'] = (nArg1 > 2147483647) ? ((4294967296 - nArg1) * -1) : nArg1;
  2250.                 g_hSelf['rewards_points'] = (nArg2 > 2147483647) ? ((4294967296 - nArg2) * -1) : nArg2;
  2251.                 TokenInc(g_hSelf['tokens']);
  2252.                 g_bFCTYPE_DETAILS_Received = true;
  2253.                 if (g_bFCTYPE_MODELGROUP_Received && !g_bLoginDone) {
  2254.                     g_bLoginDone = true;
  2255.                     PostLoginProcedures();
  2256.                 }
  2257.             }
  2258.             FcDetails();
  2259.         }
  2260.         break;
  2261.     case FCTYPE_USERNAMELOOKUP:
  2262.         {
  2263.             if (g_nPmPrompt_UserId) {
  2264.                 PmUsernameLookup_Response_FcTypeUsernameLookupRx(nUserId);
  2265.             } else {
  2266.                 FcUsernameLookup(nFrom, nTo, nArg1, nArg2, nUserId);
  2267.             }
  2268.         }
  2269.         break;
  2270.     case FCTYPE_PMESG:
  2271.         {
  2272.             FcPrivateMessage(nArg1, nArg2, sMessage, nUserId, nPmStamp, nFrom, nTo);
  2273.         }
  2274.         break;
  2275.     case FCTYPE_CMESG:
  2276.         {
  2277.             FcChannelMessage(nFrom, nTo, nArg1, nArg2, nUserId, sMessage);
  2278.         }
  2279.         break;
  2280.     case FCTYPE_JOINCHAN:
  2281.         {
  2282.             nPlayerOwnerId = GetRoomOwnerId(nArg1);
  2283.             try {
  2284.                 if (g_hoPlayerWindows[nPlayerOwnerId] && g_hoPlayerWindows[nPlayerOwnerId]['handle'] && g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export) {
  2285.                     try {
  2286.                         g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().FcJoinChan(nArg1, nArg2, nUserId, nFrom);
  2287.                     } catch (oError) {
  2288.                         Log("Try Catch Failure #6: " + oError.description);
  2289.                     }
  2290.                 }
  2291.             } catch (oError) {
  2292.                 Log("FcJoinChan error: " + oError.description);
  2293.             }
  2294.         }
  2295.         break;
  2296.     case FCTYPE_ACCEPTPVT:
  2297.         {
  2298.             FcAcceptPrivate(nArg1, nArg2, nUserId);
  2299.         }
  2300.         break;
  2301.     case FCTYPE_CHATFLASH:
  2302.         {
  2303.             var nUserId = nArg1;
  2304.             if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export) {
  2305.                 try {
  2306.                     g_hoPMWindows[nUserId]['handle'].Export().ChatFlashReceive();
  2307.                 } catch (oError) {
  2308.                     Log("Try Catch Failure #9: " + oError.description);
  2309.                 }
  2310.             } else if (t.IdCache('online_friend_' + nUserId)) {
  2311.                 t.IdCache('online_friend_' + nUserId).style.backgroundColor = "yellow";
  2312.                 setTimeout(" t.IdCache('online_friend_" + nUserId + "').style.backgroundColor = 'white'; ", 5000);
  2313.             }
  2314.         }
  2315.         break;
  2316.     }
  2317. }
  2318.  
  2319. function FcAcceptPrivate(nArg1, nArg2, nUserId) {
  2320.     var nUserId = GetRoomOwnerId(nArg1);
  2321.     var nPrvSessId = nArg2;
  2322.     var nPubChan = PublicChannel(nUserId);
  2323.     var nPrvChan = SessionChannel(nUserId);
  2324.     var bNoPMWindow = 0;
  2325.     var bNoPlayerWindow = 0;
  2326.     if (g_hoPlayerWindows[nUserId] && g_hoPlayerWindows[nUserId]['handle'] && g_hoPlayerWindows[nUserId]['handle'].Export) {
  2327.         try {
  2328.             g_hoPlayerWindows[nUserId]['handle'].Export().FcAcceptPrivate(nUserId, nPubChan, nPrvChan, nPrvSessId);
  2329.         } catch (oError) {
  2330.             Log("Try Catch Failure #7: " + oError.description);
  2331.         }
  2332.     } else {
  2333.         bNoPMWindow = 1;
  2334.     }
  2335.     if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export) {
  2336.         try {
  2337.             g_hoPMWindows[nUserId]['handle'].Export().FcAcceptPrivate(nUserId, nPubChan, nPrvChan, nPrvSessId);
  2338.         } catch (oError) {
  2339.             Log("Try Catch Failure #8: " + oError.description);
  2340.         }
  2341.     } else {
  2342.         bNoPlayerWindow = 1;
  2343.     }
  2344.     if (bNoPMWindow && bNoPlayerWindow) {
  2345.         setTimeout(" t.TxCmd(t.FCTYPE_ENDSESSION, " + g_nSessionId + ", 0, " + t.g_hUsers[nUserId]['sessionid'] + ", 0, 0, null); ", 2000);
  2346.     }
  2347. }
  2348.  
  2349. function RoomTopicHandler(sTopic, nPlayerOwnerId) {
  2350.     var hTopic = ParseJSON(unescape(sTopic));
  2351.     if (hTopic && g_hoPlayerWindows[nPlayerOwnerId]) {
  2352.         try {
  2353.             if (g_hoPlayerWindows[nPlayerOwnerId] && g_hoPlayerWindows[nPlayerOwnerId]['handle'] && g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export && g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().RoomTopic && g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().g_nBroadcasterId > 0) {
  2354.                 g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().RoomTopic.set_topic(hTopic.msg);
  2355.             }
  2356.         } catch (oError) {
  2357.             Log("Try Catch Failure RoomTopic: " + oError.description);
  2358.         }
  2359.     }
  2360. }
  2361.  
  2362. function TokenInc(nTokens) {
  2363.     g_hSelf['tokens'] = nTokens;
  2364.     if (g_hSelf['access_level'] == 1 && nTokens > 0) {
  2365.         g_hSelf['access_level'] = 2;
  2366.         ResetUserState();
  2367.     }
  2368.     for (nWindowId in g_hoPlayerWindows) {
  2369.         try {
  2370.             if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export && g_hoPlayerWindows[nWindowId]['handle'].Export().g_nBroadcasterId > 0) {
  2371.                 g_hoPlayerWindows[nWindowId]['handle'].Export().RefreshMessageBar();
  2372.             }
  2373.         } catch (oError) {
  2374.             Log("Try Catch Failure FCTYPE_TOKENINC: " + oError.description);
  2375.         }
  2376.     }
  2377.     for (sK in g_hoPMWindows) {
  2378.         try {
  2379.             if (t.g_hoPMWindows[sK]['handle'].UpdateControls) {
  2380.                 t.g_hoPMWindows[sK]['handle'].UpdateControls();
  2381.                 return;
  2382.             }
  2383.         } catch (oError) {
  2384.             Log("Try Catch Failure FCTYPE_TOKENINC: " + oError.description);
  2385.         }
  2386.     }
  2387.     FcDetails();
  2388. }
  2389.  
  2390. function PostLoginProcedures() {
  2391.     InsertPremiumLounge();
  2392.     if (g_hSelf['access_level']) {
  2393.         IdCache('offline_friends_tr').style.display = '';
  2394.     }
  2395.     if (g_hQS['mode'] == 'text') {
  2396.         g_hSelf['online_model_pattern'] = 3;
  2397.     }
  2398.     if (g_hSelf['view_model_group'] != 1 && g_sModelGroup == 'default') {
  2399.         for (sK in g_hModelGroups) {
  2400.             if (g_hModelGroups[sK]['bitmask'] == g_hSelf['view_model_group']) {
  2401.                 g_sModelGroup = sK;
  2402.             }
  2403.         }
  2404.     }
  2405.     if (g_sModelGroup != 'default') {
  2406.         LoadModelGroup();
  2407.     }
  2408.     LoadFriendsList('reset');
  2409.     LoadMenu();
  2410.     LoadBanner();
  2411.     ToggleHeader({
  2412.         render_only: true
  2413.     });
  2414.     ToggleFriendsMenu({
  2415.         render_only: true
  2416.     });
  2417.     WindowCloseDetection();
  2418.     PrivateMessageListener();
  2419.     LoadLogin();
  2420.     InboxAlert();
  2421.     LoadPrivateMessageList();
  2422.     LoadHeaderArt();
  2423.     ModelHistory('reset');
  2424.     ToggleOfflineFriends_Lable();
  2425.     if (g_sHash) {
  2426.         var sUsername = g_sHash;
  2427.         if (!g_hModelGroupNameLookup[sUsername.toLowerCase()]) {
  2428.             nModelId = 0;
  2429.             for (nId in g_hUsers) {
  2430.                 if (g_hUsers[nId]['username'] && g_hUsers[nId]['username'].toLowerCase() == sUsername.toLowerCase()) {
  2431.                     nModelId = nId;
  2432.                 }
  2433.             }
  2434.             if (nModelId && g_hUsers[nModelId]) {
  2435.                 Load('player', {
  2436.                     broadcaster_id: nModelId
  2437.                 });
  2438.             } else {
  2439.                 Load('homepage');
  2440.             }
  2441.         }
  2442.     }
  2443.     g_bLoadAllComplete = true;
  2444.     try {
  2445.         for (sK in g_hWindows) {
  2446.             if (g_hWindows[sK].RefreshOnlineBroadcasterList) {
  2447.                 g_hWindows[sK].RefreshOnlineModelControls();
  2448.                 g_hWindows[sK].RefreshOnlineBroadcasterList('reset');
  2449.                 g_hWindows[sK].RenderOfflineBroadcastersControls();
  2450.             }
  2451.         }
  2452.     } catch (oError) {}
  2453.     setTimeout("ClientInfo(1);", 12000);
  2454. }
  2455.  
  2456. function ResetUserState() {
  2457.     var nModelId = 0;
  2458.     for (sK in g_hoPlayerWindows) {
  2459.         nModelId = sK;
  2460.     }
  2461.     for (nRemoteUserId in g_hoPlayerWindows) {
  2462.         t.TxCmd(t.FCTYPE_JOINCHAN, g_nSessionId, 0, t.g_hoPlayerWindows[nRemoteUserId]['room_channel'], t.FCCHAN_PART);
  2463.     }
  2464.     LoadMenu();
  2465.     LoadBanner();
  2466.     LoadViewers();
  2467.     LoadFriendsList('menu_only');
  2468.     LoadAll();
  2469.     LoadLogin();
  2470.     if (nModelId) {
  2471.         Load('player', {
  2472.             broadcaster_id: nModelId,
  2473.             target: 'main'
  2474.         });
  2475.     }
  2476. }
  2477.  
  2478. function FcSetting(nArg1, nArg2, sPayload) {
  2479.     sPayload.match(/([^:]+):(.*)/);
  2480.     g_hSelf[RegExp.$1] = RegExp.$2 == '0' ? 0 : RegExp.$2;
  2481.     if (g_hSelf['models_per_page'] == 0) {
  2482.         g_hSelf['models_per_page'] = 250;
  2483.     }
  2484. }
  2485.  
  2486. function FcPMHistory(nArg1, nArg2, sPayload) {
  2487.     var nUserId = nArg1;
  2488.     if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle']) {
  2489.         try {
  2490.             if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export) {
  2491.                 try {
  2492.                     g_hoPMWindows[nUserId]['handle'].Export().FcPMHistory(nArg1, nArg2, sPayload);
  2493.                 } catch (oError) {
  2494.                     Log("Try Catch Failure #10: " + oError.description);
  2495.                 }
  2496.             }
  2497.         } catch (oError) {
  2498.             Log("ANTI top -> pm FcPMHistory failed user id " + nUserId + " handle: " + oError.description);
  2499.         }
  2500.     }
  2501. }
  2502.  
  2503. function InboxAlert(nInboxCount) {
  2504.     if (typeof nInboxCount != 'undefined') {
  2505.         g_hSelf['inbox_account'] = nInboxCount;
  2506.     }
  2507.     if (g_hSelf['access_level'] < 2) {
  2508.         return;
  2509.     }
  2510.     if (t.IdCache('inbox_alert')) {
  2511.         if (g_hSelf['inbox_account'] > 0) {
  2512.             t.IdCache('inbox_alert').style.display = 'block';
  2513.             SetHTML('inbox_alert', " <div style='padding:0px 0px;'> " + t.A("message") + " <span style='background-color:yellow;'><b>" + g_hSelf['inbox_account'] + "</b> New Message" + (g_hSelf['inbox_account'] > 1 ? 's' : '') + "</span></a> <i" + "mg style='vertical-align:middle;' src=http://img.myfreecams.com/mfc2/images/icons/new_mail.png> </div>");
  2514.         } else {
  2515.             t.IdCache('inbox_alert').style.display = 'none';
  2516.         }
  2517.     }
  2518. }
  2519. var g_oLoungeAutoClick_Threshold;
  2520.  
  2521. function LoungeQuickLinks(sMessage) {
  2522.     for (nUserId in g_hUsers) {
  2523.         if (g_hUsers[nUserId] && g_hUsers[nUserId]['username'] && g_hUsers[nUserId]['username'].length < 4 && !g_hLoungeIds[nUserId]) {
  2524.             continue;
  2525.         }
  2526.         if ((g_hUsers[nUserId]['state'] == 0 || g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_PVT || g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_GRP) && nUserId != g_nLoungeReservedId) {
  2527.             var oRE = new RegExp("(\\W)" + g_hUsers[nUserId]['username'] + "(\\W)", "i");
  2528.             if (sMessage.match(oRE)) {
  2529.                 if (BlockedModelRegionCheck(nUserId) || g_hUsers[nUserId]['hidden']) {
  2530.                     sMessage = sMessage.replace(oRE, "$1<a href=# onClick=\"LoungeVideoCycler(" + nUserId + "); return false;\"><i><span " + PopupBioHandlerCode(nUserId) + ">" + g_hUsers[nUserId]['username'] + "</span></i></a>$2");
  2531.                 } else {
  2532.                     var sLiveSnap = '';
  2533.                     if (g_hUsers[nUserId]['state'] == 0 && !(g_hSelf['lounge_auto_click_link'] & 2)) {
  2534.                         sLiveSnap = "<span " + PopupBioHandlerCode(nUserId, 'livesnap') + " style=''><i" + "mg height=36 width=48 style='border:1px solid #dddddd;' src=" + t.LiveSnapUrl(nUserId, 100) + "></span>";
  2535.                     }
  2536.                     sMessage = sMessage.replace(oRE, "$1<a href=# onClick=\"LoungeVideoCycler(" + nUserId + "); return false;\"><span " + PopupBioHandlerCode(nUserId) + ">" + g_hUsers[nUserId]['username'] + "</span>" + sLiveSnap + "</a>$2");
  2537.                     if (g_hSelf['lounge_auto_click_link'] & 1) {
  2538.                         try {
  2539.                             for (nWindowId in g_hoPlayerWindows) {
  2540.                                 if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['relation_state'] == 'public' && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export && g_hLoungeIds[g_hoPlayerWindows[nWindowId]['handle'].Export().g_nBroadcasterId] && g_hoPlayerWindows[nWindowId]['handle'].Export().g_nLoungeModel != nUserId && g_hoPlayerWindows[nWindowId]['handle'].Export().g_bHaltAutoClick != 1 && g_hUsers[nUserId]['state'] == 0) {
  2541.                                     clearTimeout(g_oLoungeAutoClick_Threshold);
  2542.                                     g_oLoungeAutoClick_Threshold = setTimeout(" g_hoPlayerWindows[" + nWindowId + "]['handle'].Export().LoungeVideoCycler(" + nUserId + "); ", 500);
  2543.                                 }
  2544.                             }
  2545.                         } catch (oError) {
  2546.                             Log("Try Catch Failure #51: " + oError.description);
  2547.                         }
  2548.                     }
  2549.                 }
  2550.             }
  2551.         }
  2552.     }
  2553.     return sMessage;
  2554. }
  2555.  
  2556. function LiveSnapUrl(nUserId, nSize) {
  2557.     if (!t.g_hUsers[nUserId] || !t.g_hUsers[nUserId]['videoserver']) {
  2558.         return "http://img.myfreecams.com/mfc2/images/misc/NoLiveSnap.jpg";
  2559.     }
  2560.     nSize = nSize || 100;
  2561.     return "http://img.myfreecams.com/livesnap" + nSize + "/?user=" + (100000000 + parseInt(nUserId));
  2562. }
  2563.  
  2564. function LiveSnapImage(nUserId, nSize, nWidth, nHeight) {
  2565.     nSize = nSize || 100;
  2566.     var aHtml = new Array();
  2567.     aHtml.push("<i" + "mg ");
  2568.     if (nWidth) aHtml.push(" width=" + nWidth);
  2569.     if (nHeight) aHtml.push(" height=" + nHeight);
  2570.     aHtml.push(" class=img_border src=" + t.LiveSnapUrl(nUserId, nSize) + " onError=\"this.src = ('../images/misc/clear.gif');\" >");
  2571.     return aHtml.join('');
  2572. }
  2573.  
  2574. function BlockedModelRegionCheck(nUserId) {
  2575.     if (!g_hUsers[nUserId] || !g_hUsers[nUserId]['continent']) {
  2576.         return 0;
  2577.     }
  2578.     if (g_hSelf['online_model_regions'] & (1 << 0) && g_hUsers[nUserId]['continent'] == 'AF') return 1;
  2579.     else if (g_hSelf['online_model_regions'] & (1 << 1) && g_hUsers[nUserId]['continent'] == 'AS') return 1;
  2580.     else if (g_hSelf['online_model_regions'] & (1 << 2) && g_hUsers[nUserId]['continent'] == 'AU') return 1;
  2581.     else if (g_hSelf['online_model_regions'] & (1 << 3) && (g_hUsers[nUserId]['continent'] == 'SA' || g_hUsers[nUserId]['continent'] == 'CA')) return 1;
  2582.     else if (g_hSelf['online_model_regions'] & (1 << 4) && g_hUsers[nUserId]['continent'] == 'EU') return 1;
  2583.     else if (g_hSelf['online_model_regions'] & (1 << 5) && g_hUsers[nUserId]['continent'] == 'NA') return 1;
  2584.     else if (g_hSelf['online_model_regions'] & (1 << 6) && g_hUsers[nUserId]['continent'] == 'UK') return 1;
  2585. }
  2586.  
  2587. function GetRoomOwnerId(nChannelId) {
  2588.     var nOwnerId = -1;
  2589.     if (nChannelId >= 1000000000) nOwnerId = nChannelId - 1000000000;
  2590.     else if (nChannelId >= 400000000) nOwnerId = nChannelId - 400000000;
  2591.     else if (nChannelId >= 300000000) nOwnerId = nChannelId - 300000000;
  2592.     else if (nChannelId >= 200000000) nOwnerId = nChannelId - 200000000;
  2593.     else if (nChannelId >= 100000000) nOwnerId = nChannelId - 100000000;
  2594.     return nOwnerId;
  2595. }
  2596.  
  2597. function LoadViewers() {
  2598.     var sViewerHtml = '';
  2599.     for (nUserId in g_hUsers) {
  2600.         if (g_hUsers[nUserId]['webcam_viewer']) {
  2601.             sViewerHtml += BuildFriendsListEntry(nUserId);
  2602.         }
  2603.     }
  2604.     if (!sViewerHtml) {
  2605.         t.SetHTML('viewers', "");
  2606.         t.IdCache('viewers').style.display = 'none';
  2607.     } else {
  2608.         t.IdCache('viewers').style.display = 'block';
  2609.         SetHTML('viewers', " " + g.container("top", "") + " <div class=small_heading style=\"position:relative;\"> Webcam Viewers <div style='position:absolute;top:-3px;right:-1px;'> <i" + "mg src='http://img.myfreecams.com/mfc2/images/icons/binocs.gif'> </div> </div> <div class='chat_friends friends_private_messages' id=friends_private_messages style=\"font-size:11px;padding:6px;\"> " + sViewerHtml + " </div> " + g.container("bottom", "") + " ");
  2610.     }
  2611. }
  2612.  
  2613. function PeopleIcon(nUserId) {
  2614.     var nIcon;
  2615.     if (g_hUsers[nUserId]['username'].match(/^..[aeimquy]/i)) nIcon = 1;
  2616.     else if (g_hUsers[nUserId]['username'].match(/^..[bfjnrvz]/i)) nIcon = 2;
  2617.     else if (g_hUsers[nUserId]['username'].match(/^..[cgkosw]/i)) nIcon = 3;
  2618.     else if (g_hUsers[nUserId]['username'].match(/^..[dhlptx\d_]/i)) nIcon = 4;
  2619.     return 'http://img.myfreecams.com/mfc2/images/icons/small_' + ((g_hUsers[nUserId] && (g_hUsers[nUserId]['access_level'] == 4 || g_hUsers[nUserId]['access_level'] == 3 || !g_hUsers[nUserId]['access_level'])) ? 'woman' : 'man') + '_' + nIcon + '.gif';
  2620. }
  2621.  
  2622. function BuildFriendsListEntry(nUserId) {
  2623.     var aBio = new Array();
  2624.     var sStyle;
  2625.     if (g_hUsers[nUserId]['state'] == t.FCVIDEO_UNKNOWN) {
  2626.         if (g_bIE) sStyle = "filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);";
  2627.         else sStyle = "-moz-opacity:0.5";
  2628.     }
  2629.     aBio.push("<a href=# onClick=\"PopUserMenu(" + nUserId + "); return false;\"><i" + "mg style=\"" + sStyle + "\" src=" + PeopleIcon(nUserId) + " style='vertical-align:bottom;margin:0px;'></a>");
  2630.     if (t.g_hUsers[nUserId]['broadcasting_video'] > 0 || g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_IDLE || g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_RESET || g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_PVT || g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_GRP) {
  2631.         var sCamLink = A("pm_friend", {
  2632.             user_id: g_hUsers[nUserId]['user_id'],
  2633.             username: g_hUsers[nUserId]['username'],
  2634.             load_video: true
  2635.         });
  2636.         aBio.push(sCamLink + "<i" + "mg id=online_friends_arrow src=http://img.myfreecams.com/mfc2/images/icons/webcam_medium.gif style='vertical-align:middle;'></a>");
  2637.     }
  2638.     if (IsBroadcastState(g_hUsers[nUserId]['state'])) {
  2639.         var sIcon;
  2640.         if (g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_IDLE) {
  2641.             sIcon = 'open_door.gif';
  2642.         } else if (g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_GRP) {
  2643.             sIcon = 'closed_door_g.gif';
  2644.         } else if (g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_PVT) {
  2645.             if (g_hUsers[nUserId]['truepvt']) {
  2646.                 sIcon = 'closed_door_locked.gif';
  2647.             } else {
  2648.                 sIcon = 'closed_door.gif';
  2649.             }
  2650.         } else {
  2651.             sIcon = 'faded_door.gif';
  2652.         }
  2653.         aBio.push(A('player', {
  2654.             broadcaster_id: nUserId,
  2655.             target: 'main'
  2656.         }) + "<i" + "mg id=online_friends_arrow src=http://img.myfreecams.com/mfc2/images/icons/" + sIcon + " style='vertical-align:middle;'></a>");
  2657.     }
  2658.     if (g_hUsers[nUserId]['notes']) {
  2659.         aBio.push(A("pm_friend", {
  2660.             user_id: g_hUsers[nUserId]['user_id'],
  2661.             username: g_hUsers[nUserId]['username'],
  2662.             load_notes: 1,
  2663.             title: 'You have notes on this user'
  2664.         }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/notes.png></a> ");
  2665.     }
  2666.     if (g_hUsers[nUserId]['state'] != t.FCVIDEO_UNKNOWN) {
  2667.         var sStatusClass;
  2668.         var sStyle = '';
  2669.         if (IsSessionState(g_hUsers[nUserId]['state'])) {
  2670.             sStatusClass = 'friend_sessionbroadcast';
  2671.         } else {
  2672.             sStatusClass = 'friend_sessionbroadcast friend_active';
  2673.         }
  2674.         sStyle += MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]);
  2675.         return "<div id=online_friend_" + nUserId + " class=" + sStatusClass + " style='position:relative;white-space:nowrap;line-height:16px;vertical-align:middle;border:0px dashed #dddddd;' >" + A("pm_friend", {
  2676.             user_id: g_hUsers[nUserId]['user_id'],
  2677.             username: g_hUsers[nUserId]['username'],
  2678.             style: sStyle
  2679.         }) + "<span style=\"" + sStyle + "\" " + PopupBioHandlerCode(nUserId) + ">" + g_hUsers[nUserId]['username'] + "</span></a> " + aBio.join('') + "</div>";
  2680.     } else {
  2681.         var sStyle = MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]);
  2682.         return "<div class=friend_offline style='position:relative;white-space:nowrap;'>" + A("pm_friend", {
  2683.             user_id: g_hUsers[nUserId]['user_id'],
  2684.             username: g_hUsers[nUserId]['username']
  2685.         }) + "<span style=\"" + sStyle + "\">" + g_hUsers[nUserId]['username'] + "</span></a> " + aBio.join('') + "</div>";
  2686.     }
  2687. }
  2688.  
  2689. function ServerRefresh() {
  2690.     for (sK in g_hoPlayerWindows) {
  2691.         if (t.g_hoPlayerWindows[sK]['relation_state'] == 'private') {
  2692.             setTimeout("ServerRefresh()", 5000);
  2693.             return;
  2694.         }
  2695.     }
  2696.     for (sK in g_hoPMWindows) {
  2697.         if (t.g_hoPMWindows[sK]['relation_state'] == 'private') {
  2698.             setTimeout("ServerRefresh()", 5000);
  2699.             return;
  2700.         }
  2701.     }
  2702.     setTimeout("top.location = '/?no-cache=' + Math.random();", parseInt(Math.random() * 300000));
  2703. }
  2704.  
  2705. function FcLogin(nSession, nResult, nUserId, sName) {
  2706.     for (nK in g_hUsers) {
  2707.         if (g_hUsers[nK]['access_level'] == 4 && !g_hLoungeIds[nK]) {
  2708.             g_hUsers[nK] = {};
  2709.         }
  2710.     }
  2711.     g_nSessionId = nSession;
  2712.     g_bLoginDone = false;
  2713.     g_nConnectingMode = FCTYPE_CONNECTED;
  2714.     g_nBroadcasterCount = -1;
  2715.     if (nResult == FCRESPONSE_SUCCESS) {
  2716.         if (nUserId > 0) {
  2717.             g_hSelf['user_id'] = nUserId;
  2718.         } else {
  2719.             g_hSelf['user_id'] = g_nSessionId;
  2720.         }
  2721.         g_hSelf['username'] = sName;
  2722.         if (window.frames['ajaxframe']) zgw_Server('connected');
  2723.     }
  2724.     for (sK in g_hoPlayerWindows) {
  2725.         if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  2726.             try {
  2727.                 Log("RefreshOnlineBroadcasterList('force') from FcLogin");
  2728.                 g_hoPlayerWindows[sK]['handle'].Export().RefreshOnlineBroadcasterList('force');
  2729.             } catch (oError) {
  2730.                 Log("Try Catch Failure #11: " + oError.description);
  2731.             }
  2732.         }
  2733.     }
  2734. }
  2735.  
  2736. function FcParseErrorType(nErrorCode) {
  2737.     if (nErrorCode == FCERRTYPE_INVALIDUSER) return "That username is invalid. Check the spelling and try again.";
  2738.     else if (nErrorCode == FCERRTYPE_NOACCESS) return "You cannot ignore that user.";
  2739. }
  2740.  
  2741. function FcTxProfile(nModelId, nBitRate, sBitRateDescription) {
  2742.     if (t.g_hUsers[nModelId]) {
  2743.         t.g_hUsers[nModelId]['kbps'] = nBitRate;
  2744.         if (g_hUsers[nModelId]['videoserver'] > 0) {
  2745.             if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle'] && g_hoPlayerWindows[nModelId]['handle'].Export) {
  2746.                 try {
  2747.                     Log('videoserver ' + g_hUsers[nModelId]['videoserver'] + ' for model ' + nModelId);
  2748.                     g_hoPlayerWindows[nModelId]['handle'].Export().LoadVideo();
  2749.                 } catch (oError) {
  2750.                     Log("Try Catch Failure #99 " + oError.description);
  2751.                 }
  2752.             }
  2753.             if (g_hoPMWindows[nModelId] && g_hoPMWindows[nModelId]['handle'] && g_hoPMWindows[nModelId]['handle'].Export) {
  2754.                 try {
  2755.                     Log('videoserver ' + g_hUsers[nModelId]['videoserver'] + ' for model ' + nModelId);
  2756.                     g_hoPMWindows[nModelId]['handle'].Export().LoadVideo();
  2757.                 } catch (oError) {
  2758.                     Log("Try Catch Failure #99 " + oError.description);
  2759.                 }
  2760.             }
  2761.         } else {
  2762.             if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle'] && g_hoPlayerWindows[nModelId]['handle'].Export) {
  2763.                 Log('videoserver 0 for model id ' + nModelId + ' - do nothing');
  2764.             }
  2765.         }
  2766.     }
  2767. }
  2768.  
  2769. function FcUsernameLookup(nFrom, nTo, nArg1, nArg2, nUserId) {
  2770.     var nCallerId = nArg1;
  2771.     var nResponseCode = nArg2;
  2772.     var nUserId;
  2773.     if (nCallerId == FCWINDOW_NO_USER_PM) {
  2774.         var nUserId = nResponseCode;
  2775.         if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export) {
  2776.             try {
  2777.                 g_hoPMWindows[nUserId]['handle'].Export().Initialize();
  2778.             } catch (oError) {
  2779.                 Log("Try Catch Failure PM Initialize(): " + oError.description);
  2780.             }
  2781.         }
  2782.         ClickFriend(nUserId);
  2783.     } else if (nCallerId == FCWINDOW_OPTIONS_ADD_FRIEND) {
  2784.         if (!g_hWindows['user_settings']) return;
  2785.         if (nResponseCode == FCRESPONSE_ERROR) {
  2786.             g_hWindows['user_settings'].alert("We couldn't find a user with that name. Make sure you spelled the username correctly.");
  2787.             g_hWindows['user_settings'].d.getElementById('add_friend_username').disabled = false;
  2788.         } else if (nCallerId == FCWINDOW_OPTIONS_ADD_FRIEND) {
  2789.             nUserId = nResponseCode;
  2790.             TxAddRemoveFriend(nArg2, 'add');
  2791.         }
  2792.     }
  2793. }
  2794.  
  2795. function FcAddFriend(nRemoteUserID, nMode) {
  2796.     if (nMode == FCCHAN_WELCOME) {
  2797.         g_bFriendsLoaded = true;
  2798.         for (sK in g_hWindows) {
  2799.             if (g_hWindows[sK].RefreshOnlineBroadcasterList) {
  2800.                 g_hWindows[sK].RefreshOnlineBroadcasterList('initialize');
  2801.             }
  2802.         }
  2803.         return;
  2804.     }
  2805.     if (nRemoteUserID == g_nLoungeReservedId) {
  2806.         return;
  2807.     }
  2808.     if (!g_hUsers[nRemoteUserID]) {
  2809.         return;
  2810.     }
  2811.     if (nMode == FCCHAN_JOIN) {
  2812.         g_hUsers[nRemoteUserID]['friend'] = true;
  2813.         if (g_bLoginDone && g_bFriendsLoaded) {
  2814.             if (g_hUsers[nRemoteUserID]['state'] == FCVIDEO_UNKNOWN) {
  2815.                 for (sK in g_hUsers[nRemoteUserID]) {
  2816.                     if (sK != 'user_id' && sK != 'username' && sK != 'access_level' && sK != 'state' && sK != 'friend') {
  2817.                         delete g_hUsers[nRemoteUserID][sK];
  2818.                     }
  2819.                 }
  2820.             }
  2821.             var sStateMessage;
  2822.             if (g_hUsers[nRemoteUserID]['sessionid']) {
  2823.                 sStateMessage = "is now online";
  2824.             } else {
  2825.                 sStateMessage = "has logged off";
  2826.             }
  2827.             if (g_hUsers[nRemoteUserID] && g_hUsers[nRemoteUserID]['access_level'] <= 2 && g_hUsers[nRemoteUserID]['access_level'] > 0) {
  2828.                 if (g_hSelf['sound_user_friend_login'] == 1) Sound('sound_user_friend_login');
  2829.                 Notification(t.A('pm_friend', {
  2830.                     user_id: nRemoteUserID,
  2831.                     style: 'font-weight:bold;',
  2832.                     target: 'main'
  2833.                 }) + g_hUsers[nRemoteUserID]['username'] + "</a> " + sStateMessage + ".");
  2834.             } else if (g_hUsers[nRemoteUserID] && g_hUsers[nRemoteUserID]['access_level'] == 4) {
  2835.                 if (g_hSelf['sound_user_friend_login'] == 1) Sound('sound_model_friend_login');
  2836.                 Notification(t.A('player', {
  2837.                     broadcaster_id: nRemoteUserID,
  2838.                     style: 'font-weight:bold;',
  2839.                     target: 'main'
  2840.                 }) + g_hUsers[nRemoteUserID]['username'] + "</a> " + sStateMessage + ".");
  2841.             }
  2842.         }
  2843.     } else if (nMode == FCCHAN_PART || g_hUsers[nRemoteUserID]['sessionid'] == '0') {
  2844.         g_hUsers[nRemoteUserID]['friend'] = false;
  2845.     }
  2846.     if (!g_bLoginDone) {
  2847.         return;
  2848.     }
  2849.     if (g_hoPMWindows[nRemoteUserID] && g_hoPMWindows[nRemoteUserID]['handle'] && g_hoPMWindows[nRemoteUserID]['handle'].Export) {
  2850.         try {
  2851.             g_hoPMWindows[nRemoteUserID]['handle'].Export().FriendNotify(g_hUsers[nRemoteUserID]['state']);
  2852.         } catch (oError) {
  2853.             Log("Try Catch Failure #12: " + oError.description);
  2854.         }
  2855.     }
  2856.     for (sK in g_hoPlayerWindows) {
  2857.         if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  2858.             try {
  2859.                 g_hoPlayerWindows[sK]['handle'].Export().LoadPlayerMenu();
  2860.             } catch (oError) {
  2861.                 Log("Try Catch Failure #31: " + oError.description);
  2862.             }
  2863.         }
  2864.     }
  2865.     LoadFriendsList();
  2866.     if (g_hWindows['user_settings']) {
  2867.         try {
  2868.             g_hWindows['user_settings'].LoadFriendsList();
  2869.             g_hWindows['user_settings'].d.getElementById('add_friend_username').value = '';
  2870.             g_hWindows['user_settings'].d.getElementById('add_friend_username').disabled = false;
  2871.         } catch (oError) {}
  2872.     }
  2873. }
  2874.  
  2875. function FcAddIgnore(nArg1, nArg2) {
  2876.     if (nArg1 == FCRESPONSE_ERROR) {
  2877.         if (g_hWindows['user_settings'] && g_hWindows['user_settings'].d.getElementById('add_ignore_username')) {
  2878.             g_hWindows['user_settings'].alert(FcParseErrorType(nArg2));
  2879.             g_hWindows['user_settings'].d.getElementById('add_ignore_username').disabled = false;
  2880.         }
  2881.     } else if (nArg2 == FCCHAN_PART) {
  2882.         delete g_hIgnoredUsers[nArg1];
  2883.         if (g_hWindows['user_settings'] && g_hWindows['user_settings'].LoadIgnoreList) {
  2884.             g_hWindows['user_settings'].LoadIgnoreList();
  2885.         }
  2886.     } else if (nArg2 == FCCHAN_JOIN) {
  2887.         if (g_hUsers[nArg1]) {
  2888.             g_hIgnoredUsers[nArg1] = g_hUsers[nArg1]['username'];
  2889.         } else {
  2890.             Log("Error, data for user id " + nArg1 + " is not in memory");
  2891.         }
  2892.         if (g_hWindows['user_settings'] && g_hWindows['user_settings'].LoadIgnoreList) {
  2893.             g_hWindows['user_settings'].LoadIgnoreList();
  2894.             g_hWindows['user_settings'].d.getElementById('add_ignore_username').value = '';
  2895.             g_hWindows['user_settings'].d.getElementById('add_ignore_username').disabled = false;
  2896.         }
  2897.     } else {
  2898.         Log('Error occured in FcAddIgnore');
  2899.     }
  2900.     for (nRemoteUserID in g_hoPMWindows) {
  2901.         if (g_hoPMWindows[nRemoteUserID]['handle'] && g_hoPMWindows[nRemoteUserID]['handle'].Export) {
  2902.             try {
  2903.                 g_hoPMWindows[nRemoteUserID]['handle'].Export().ConfigureUserControls();
  2904.             } catch (oError) {
  2905.                 Log("Try Catch Failure #13: " + oError.description);
  2906.             }
  2907.         }
  2908.     }
  2909. }
  2910. var g_hTestHash = {};
  2911. var test;
  2912.  
  2913. function StoreUserHash(sPayload, fUpdateHash, fHistorical, nType) {
  2914.     hMap = {};
  2915.     var hUser = {};
  2916.     if (!sPayload) return;
  2917.     sPayload = unescape(sPayload);
  2918.     if (sPayload.charAt(0) == '[') {
  2919.         sPayload = sPayload.substr(1, sPayload.length - 2);
  2920.         aPayload = sPayload.split(',');
  2921.         hUser['lv'] = 0;
  2922.         hUser['nm'] = "Guest" + MfcStringUtilities.prototype.char_padding(aPayload[0], 5, 0);
  2923.         hUser['sid'] = aPayload[1];
  2924.         hUser['ts'] = 0;
  2925.         hUser['uid'] = 0;
  2926.         hUser['vs'] = 90;
  2927.     }
  2928.     try {
  2929.         if (!hUser['sid']) hUser = ParseJSON(sPayload);
  2930.         if (hUser && hUser.sid != null && hUser.sid != undefined) {
  2931.             hMap['username'] = hUser.nm;
  2932.             hMap['sessionid'] = hUser.sid;
  2933.             hMap['user_id'] = hUser.uid;
  2934.             hMap['access_level'] = hUser.lv;
  2935.             hMap['state'] = hUser.vs;
  2936.             hMap['lastupdated'] = hUser.ts;
  2937.             if (hUser.u) {
  2938.                 hMap['videoserver'] = hUser.u.camserv;
  2939.                 if (hMap['user_id'] == 100) Log('VIDSERVER-SET ' + g_hTypeMap[nType] + ' ' + hMap['user_id'] + ': ' + hUser.u.camserv);
  2940.                 hMap['chat_text_color'] = hUser.u.chat_color;
  2941.                 hMap['chat_text_font'] = hUser.u.chat_font;
  2942.                 hMap['photos'] = hUser.u.photos;
  2943.                 hMap['aboutme'] = hUser.u.blurb;
  2944.                 hMap['active'] = hUser.u.profile;
  2945.                 hMap['city'] = hUser.u.city;
  2946.                 hMap['country'] = hUser.u.country;
  2947.                 hMap['ethnic'] = hUser.u.ethnic;
  2948.                 hMap['blurb'] = hUser.u.blurb;
  2949.                 hMap['lastlogin'] = hUser.u.lastlogin;
  2950.                 hMap['creation_date'] = hUser.u.creation;
  2951.                 hMap['avatars'] = hUser.u.avatar;
  2952.                 hMap['age'] = hUser.u.age;
  2953.                 hMap['occupation'] = hUser.u.occupation;
  2954.                 hMap['chat_background_id'] = hUser.u.chat_bg;
  2955.                 hMap['chat_opts'] = hUser.u.chat_opt;
  2956.                 if (hMap['access_level'] >= 2 && typeof(hMap['chat_opts']) != 'undefined') {
  2957.                     hMap['bold'] = hMap['chat_opts'] & w.FCOPT_BOLD ? 1 : 0;
  2958.                     hMap['italic'] = hMap['chat_opts'] & w.FCOPT_ITALICS ? 1 : 0;
  2959.                     hMap['cam2cam'] = hMap['chat_opts'] & w.FCOPT_CAM2CAM ? 1 : 0;
  2960.                 }
  2961.             }
  2962.             if (hUser.m) {
  2963.                 hMap['topic'] = hUser.m.topic;
  2964.                 hMap['model_group'] = hUser.m.mg;
  2965.                 hMap['continent'] = hUser.m.continent;
  2966.                 hMap['kbps'] = hUser.m.kbit;
  2967.                 hMap['rating'] = hUser.m.camscore;
  2968.                 hMap['ping'] = 0;
  2969.                 hMap['rating'] = 1;
  2970.                 hMap['cam_score'] = hUser.m.camscore;
  2971.                 hMap['asian_cam_score'] = hUser.m.ascamscore;
  2972.                 hMap['rating_count'] = hUser.m.totrating;
  2973.                 hMap['avg_rating'] = hUser.m.avgrating;
  2974.                 hMap['new_model'] = hUser.m.new_model;
  2975.                 hMap['model_settings'] = hUser.m.flags;
  2976.                 hMap['remote_private'] = hMap['model_settings'] & w.FCOPT_REMOTEPVT ? 1 : 0;
  2977.                 hMap['truepvt'] = hMap['model_settings'] & w.FCOPT_TRUEPVT ? 1 : 0;
  2978.             }
  2979.             hMap['italic'] = 0;
  2980.             hMap['static_record'] = 0;
  2981.         } else {
  2982.             Log('DBG: CMESG hUser not eval ok: ' + sPayload);
  2983.         }
  2984.     } catch (e) {
  2985.         Log('DBG: StoreUserHash() failed evaling: ' + sPayload + ', e:' + e.description);
  2986.         return;
  2987.     }
  2988.     hMap['previous_state'] = (t.g_hUsers[hMap['user_id']]) ? t.g_hUsers[hMap['user_id']]['state'] : null;
  2989.     if (hMap['user_id'] == 0 && hMap['sessionid'] > 0) {
  2990.         hMap['user_id'] = hMap['sessionid'];
  2991.     }
  2992.     var fSaveFriend = false;
  2993.     var fSetFriend = false;
  2994.     var nPreviousState = FCVIDEO_UNKNOWN;
  2995.     if (fHistorical && g_hUsers[hMap['user_id']]) {
  2996.         nPreviousState = g_hUsers[hMap['user_id']]['state'];
  2997.     }
  2998.     if (g_hUsers[hMap['user_id']] && g_hUsers[hMap['user_id']]['friend']) {
  2999.         fSaveFriend = g_hUsers[hMap['user_id']]['friend'];
  3000.     }
  3001.     if (!g_hUsers[hMap['user_id']]) {
  3002.         g_hUsers[hMap['user_id']] = {};
  3003.     }
  3004.     if (g_hUsers[hMap['user_id']]['sessionid'] && g_hUsers[hMap['user_id']]['sessionid'] != hMap['sessionid'] && hMap['state'] >= 90 && hMap['sessionid'] != 0) {
  3005.         fUpdateHash = 0;
  3006.         Log('DBG: Conflicting session ID for same users with a state >= 90, dropping hash update: ' + hUser.nm);
  3007.     }
  3008.     var
  3009.     bResetUserState_after_update = 0;
  3010.     if (hMap['user_id'] == g_hSelf['user_id'] && hMap['access_level'] == 2 && g_hSelf['access_level'] == 1) {
  3011.         bResetUserState_after_update = 1;
  3012.     }
  3013.     if (fUpdateHash) {
  3014.         for (sK in hMap) {
  3015.             if (hMap[sK] == 0 && sK != 'chat_text_color') {
  3016.                 hMap[sK] = 0;
  3017.             }
  3018.         }
  3019.         var nUserId = hMap['user_id'];
  3020.         for (sK in hMap) {
  3021.             if (hMap[sK] != undefined && hMap[sK] != null && (sK != 'tokens' || hMap[sK] >= 0)) {
  3022.                 g_hUsers[nUserId][sK] = hMap[sK];
  3023.             }
  3024.         }
  3025.         var hDefaults = {
  3026.             'chat_text_font': 0,
  3027.             'bold': 0,
  3028.             'italic': 0,
  3029.             'cam2cam': 0
  3030.         };
  3031.         for (sK in hDefaults) {
  3032.             if (hMap['user_id'] == g_hSelf['user_id']) {
  3033.                 if (g_hSelf[sK] == null || g_hSelf[sK] == undefined) {
  3034.                     g_hSelf[sK] = hDefaults[sK];
  3035.                 }
  3036.             }
  3037.             if (g_hUsers[nUserId][sK] == null || g_hUsers[nUserId][sK] == undefined) {
  3038.                 g_hUsers[nUserId][sK] = hDefaults[sK];
  3039.             }
  3040.         }
  3041.         if (g_hUsers[hMap['user_id']]) {
  3042.             if (hMap['state'] != t.FCVIDEO_TX_PVT) {
  3043.                 g_hUsers[hMap['user_id']]['truepvt'] = 0;
  3044.             }
  3045.         }
  3046.         if (hMap['user_id'] == g_hSelf['user_id']) {
  3047.             for (sK in hMap) {
  3048.                 if ((sK != 'tokens' || hMap[sK] > 0) && sK != 'user_id' && hMap[sK] != null && hMap[sK] != undefined) {
  3049.                     g_hSelf[sK] = hMap[sK];
  3050.                 }
  3051.             }
  3052.         }
  3053.     } else {
  3054.         if (hMap['username'] != null && hMap['username'] != undefined) g_hUsers[hMap['user_id']]['username'] = hMap['username'];
  3055.     }
  3056.     if (hMap['access_level'] == 4 && !g_hUsers[hMap['user_id']]['highlight_counter']) {
  3057.         if (!g_bLoginDone || g_bChangeModelGroup) {
  3058.             g_hUsers[hMap['user_id']]['highlight_counter'] = 100;
  3059.         } else {
  3060.             g_hUsers[hMap['user_id']]['highlight_counter'] = 0;
  3061.         }
  3062.     }
  3063.     if (fSaveFriend != false) {
  3064.         g_hUsers[hMap['user_id']]['friend'] = fSaveFriend;
  3065.     } else if (!g_hUsers[hMap['user_id']]['friend']) {
  3066.         g_hUsers[hMap['user_id']]['friend'] = 0;
  3067.     }
  3068.     if (nPreviousState != FCVIDEO_UNKNOWN) {
  3069.         g_hUsers[hMap['user_id']]['state'] = nPreviousState;
  3070.     }
  3071.     if (hMap['user_id'] == g_hSelf['user_id'] && !g_hSelf['access_level'] && g_hSelf['username'] && !g_hCk['guest_username']) {
  3072.         SaveGuestName(g_hSelf['username']);
  3073.     }
  3074.     if (bResetUserState_after_update) {
  3075.         ResetUserState();
  3076.     }
  3077.     return hMap['user_id'];
  3078. }
  3079.  
  3080. function Notification(sMessage) {
  3081.     LoadBanner(" <table width=250 > <td valign=center style=padding-right:10px;> <i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/right_arrow_white.gif> </td> <td align=center valign=center width=100%> <span style='color:#FFFFFF;'></span> " + sMessage + " </td> </table>");
  3082.     setTimeout("LoadBanner()", 15000);
  3083. }
  3084.  
  3085. function SortedUserKeys(sMode) {
  3086.     if (!sMode) {
  3087.         sMode = 'username';
  3088.     }
  3089.     var i = 0;
  3090.     var aTmp = new Array();
  3091.     var aResult = new Array();
  3092.     for (sK in t.g_hUsers) {
  3093.         if (t.g_hUsers[sK] && t.g_hUsers[sK][sMode]) {
  3094.             aTmp[i++] = t.g_hUsers[sK]['username'].toLowerCase() + ':' + sK;
  3095.         }
  3096.     }
  3097.     i = 0;
  3098.     for (sK in aTmp.sort()) {
  3099.         aResult.push(aTmp[sK].split(':')[1]);
  3100.     }
  3101.     return aResult;
  3102. }
  3103. var g_oFriendsLimit;
  3104. var g_nFriendsListDelay_Lock = 0;
  3105. var g_oFriendsListDelay_CallTimeout = 0;
  3106. var g_bFriendsListSuspendUpdates = 0;
  3107. var g_bUsernameAvailable = false;
  3108.  
  3109. function LoadFriendsList(sMode) {
  3110.     if (g_bFriendsListSuspendUpdates || g_sToggleFriends == 'none') {
  3111.         return;
  3112.     }
  3113.     if (sMode == 'suspend') {
  3114.         g_nFriendsListDelay_Lock = 1;
  3115.         setTimeout(" g_nFriendsListDelay_Lock=0 ", 3000);
  3116.         return;
  3117.     } else if (g_nFriendsListDelay_Lock > 0) {
  3118.         g_oFriendsListDelay_CallTimeout = setTimeout(" LoadFriendsList('" + sMode + "'); ", 1000);
  3119.         return;
  3120.     } else {
  3121.         clearTimeout(g_oFriendsListDelay_CallTimeout);
  3122.     }
  3123.     sMode = sMode || '';
  3124.     if (!sMode) {
  3125.         clearTimeout(g_oFriendsLimit);
  3126.         g_oFriendsLimit = setTimeout("LoadFriendsList('load');", 100);
  3127.         return;
  3128.     }
  3129.     Log(" LoadFriendsList('" + sMode + "') called ");
  3130.     try {
  3131.         for (nRemoteUserID in g_hoPMWindows) {
  3132.             if (g_hUsers[nRemoteUserID] && g_hoPMWindows[nRemoteUserID]['handle'] && g_hoPMWindows[nRemoteUserID]['handle'].Export) {
  3133.                 g_hoPMWindows[nRemoteUserID]['handle'].Export().ConfigureUserControls();
  3134.             }
  3135.         }
  3136.     } catch (oError) {
  3137.         Log("Try Catch Failure #14: " + oError.description);
  3138.     }
  3139.     if (!IdCache('private_message_list') || sMode == 'reset' || sMode == 'menu_only') {
  3140.         var sH = "\n <div style='position:relative;'>\n <div id=private_message_list class=chat_private_message_list style='display:none;'></div>\n <div id=personal_menu> ";
  3141.         var sMenu = '';
  3142.         if (g_hSelf['access_level'] > 0) {
  3143.             sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('account') + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/account_small.gif style='vertical-align:center;margin:1px;'></a></div>" + A('account') + "My Account</a></div>";
  3144.             sMenu += "\n <div class=chat_friends_list style='white-space:nowrap;'>\n <div class=pmenu><div class=pmenu_icon>" + A("user_settings") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/options.gif style='vertical-align:center;margin:0px;'></a></div>" + A("user_settings") + "Personal Options</a></div> ";
  3145.             if (g_hSelf['access_level'] == 1) {
  3146.                 if (g_hSelf['user_id'] && g_hUsers[g_hSelf['user_id']] && g_hUsers[g_hSelf['user_id']]['active']) {
  3147.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('my_profile', {
  3148.                         user_id: g_hSelf['user_id']
  3149.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/my_profile_small.gif style='vertical-align:center;margin:1px;'></a></div> " + A('my_profile', {
  3150.                         user_id: g_hSelf['user_id']
  3151.                     }) + "My Profile</a></div>";
  3152.                 } else {
  3153.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('create_profile', {
  3154.                         user_id: g_hSelf['user_id']
  3155.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/my_profile_small.gif style='vertical-align:center;margin:1px;'></a></div> " + A('create_profile', {
  3156.                         user_id: g_hSelf['user_id']
  3157.                     }) + "Create Your Profile</a></div>";
  3158.                 }
  3159.                 if (g_sModelGroup == 'asian') {
  3160.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("model_matrix") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/model_matrix-sm.png style='vertical-align:center;margin:0px;'></a></div> " + A("model_matrix", {
  3161.                         mode: 'asian'
  3162.                     }) + "Asian Explorer</span></a></div>";
  3163.                 } else {
  3164.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("model_matrix") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/model_matrix-sm.png style='vertical-align:center;margin:0px;'></a></div> " + A("model_matrix") + "Model Explorer</span></a></div>";
  3165.                 }
  3166.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("news_feed") + "<i" + "mg src=http://img.myfreecams.com/ico/newsfeed.16x16.png style='vertical-align:center;margin:0px;'></a></div> <span id=news_feed_menu_item onClick=\"this.style.backgroundColor = '#FFFFFF';\">" + A("news_feed") + "News Feed</span></a></div>";
  3167.                 sMenu += "<div style=\"padding-top:15px;padding-bottom:10px;\">" + t.A('faq', {
  3168.                     anchor: 'premium'
  3169.                 }) + "Premium</a> Members:</div>";
  3170.                 sMenu += "<div style=\"padding-left:15px;\">";
  3171.             }
  3172.             if (g_hSelf['access_level'] == 2 || g_hSelf['access_level'] == 5) {
  3173.                 if (g_sModelGroup == 'asian') {
  3174.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("player", {
  3175.                         broadcaster_id: g_hLoungeIds['Asian_Lounge'],
  3176.                         target: 'main',
  3177.                         title: 'Go to the Asian Lounge'
  3178.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/asian_lounge.16x16.gif style='vertical-align:center;margin:0px;'></a></div>" + A("player", {
  3179.                         broadcaster_id: g_hLoungeIds['Asian_Lounge'],
  3180.                         target: 'main',
  3181.                         title: 'Go to the Asian Lounge'
  3182.                     }) + "Asian Lounge</a> " + A("player", {
  3183.                         broadcaster_id: g_hLoungeIds['Asian_Lounge'],
  3184.                         target: 'new_window',
  3185.                         title: 'Open the Asian Lounge in a popup window'
  3186.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/popup.gif style='vertical-align:center;margin:0px;'></a></div>";
  3187.                 } else {
  3188.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("player", {
  3189.                         broadcaster_id: g_hLoungeIds['Lounge'],
  3190.                         target: 'main',
  3191.                         title: 'Go to the Lounge'
  3192.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/martini.gif style='vertical-align:center;margin:0px;'></a></div>" + A("player", {
  3193.                         broadcaster_id: g_hLoungeIds['Lounge'],
  3194.                         target: 'main',
  3195.                         title: 'Go to the Lounge'
  3196.                     }) + "Lounge</a> " + A("player", {
  3197.                         broadcaster_id: g_hLoungeIds['Lounge'],
  3198.                         target: 'new_window',
  3199.                         title: 'Open the Lounge in a popup window'
  3200.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/popup.gif style='vertical-align:center;margin:0px;'></a></div>";
  3201.                 }
  3202.                 if (g_hLoungeIds['Lounge1000']) {
  3203.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("player", {
  3204.                         broadcaster_id: g_hLoungeIds['Lounge1000'],
  3205.                         target: 'main',
  3206.                         title: 'Go to the Lounge1000'
  3207.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/martini.gif style='vertical-align:center;margin:0px;'></a></div>" + A("player", {
  3208.                         broadcaster_id: g_hLoungeIds['Lounge1000'],
  3209.                         target: 'main',
  3210.                         title: 'Go to the Lounge1000'
  3211.                     }) + "Lounge1000</a> " + A("player", {
  3212.                         broadcaster_id: g_hLoungeIds['Lounge1000'],
  3213.                         target: 'new_window',
  3214.                         title: 'Open the Lounge1000 in a popup window'
  3215.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/popup.gif style='vertical-align:center;margin:0px;'></a></div>";
  3216.                 }
  3217.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('message') + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/my_inbox_small.gif style='vertical-align:center;margin:1px;'></a></div> " + A('message') + "MFC Mail</a></div>";
  3218.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('chat_logs') + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/archive.gif></a></div> " + A('chat_logs') + "Archives</a></div>";
  3219.                 if (g_hSelf['rewards_points'] >= 20) {
  3220.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + t.A('exclusive_gallery', {
  3221.                         model_group: g_hModelGroups[g_sModelGroup]['bitmask']
  3222.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/camera.gif style='vertical-align:center;margin:0px;'></a></div> " + t.A('exclusive_gallery', {
  3223.                         model_group: g_hModelGroups[g_sModelGroup]['bitmask']
  3224.                     }) + (g_sModelGroup == 'asian' ? "Asian Gallery" : "Private Gallery") + "</a></div>";
  3225.                 }
  3226.                 if (g_hUsers[g_hSelf['user_id']] && g_hUsers[g_hSelf['user_id']]['active']) {
  3227.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('my_profile', {
  3228.                         user_id: g_hSelf['user_id']
  3229.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/my_profile_small.gif style='vertical-align:center;margin:1px;'></a></div> " + A('my_profile', {
  3230.                         user_id: g_hSelf['user_id'],
  3231.                         username: g_hSelf['username']
  3232.                     }) + "My Profile</a></div>";
  3233.                 } else {
  3234.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('create_profile', {
  3235.                         user_id: g_hSelf['user_id']
  3236.                     }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/my_profile_small.gif style='vertical-align:center;margin:1px;'></a></div> " + A('create_profile', {
  3237.                         user_id: g_hSelf['user_id'],
  3238.                         username: g_hSelf['username']
  3239.                     }) + "Create Your Profile</a></div>";
  3240.                 }
  3241.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("group_shows_board") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/group_show_board.small.png style='vertical-align:center;margin:0px;'></a></div> " + A("group_shows_board") + "Group Shows</span></a></div>";
  3242.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("news_feed") + "<i" + "mg src=http://img.myfreecams.com/ico/newsfeed.16x16.png style='vertical-align:center;margin:0px;'></a></div> <span id=news_feed_menu_item onClick=\"this.style.backgroundColor = '#FFFFFF';\">" + A("news_feed") + "News Feed</span></a></div>";
  3243.                 if (document.cookie.match(/mfcuser|aaron1|adminleo/i)) {
  3244.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("top_rooms", {
  3245.                         model_group: g_sModelGroup
  3246.                     }) + "<i" + "mg src=../images/icons/top_rooms.16x16.png style='vertical-align:center;margin:0px;'></a></div> " + A("top_rooms", {
  3247.                         model_group: g_sModelGroup
  3248.                     });
  3249.                     sMenu += g_sModelGroup == 'asian' ? "Popular Asian Rooms" : "Most Popular Rooms";
  3250.                     sMenu += "</span></a></div>";
  3251.                 }
  3252.                 if (document.cookie.match(/mfcuser|aaron1/)) {
  3253.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("user_created_rooms") + "<i" + "mg src=http://img.myfreecams.com/ico/ucr.16x16.png style='vertical-align:center;margin:0px;'></a></div> " + A("user_created_rooms") + "Member Rooms</span></a></div>";
  3254.                 }
  3255.                 if (g_sModelGroup == 'asian') {
  3256.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("miss_mfc", {
  3257.                         mode: 'asian'
  3258.                     }) + "<i" + "mg src=http://img.myfreecams.com/ico/crown-16x.gif style='vertical-align:center;margin:0px;'></a></div> " + A("miss_mfc", {
  3259.                         mode: 'asian'
  3260.                     }) + "Miss Asian MFC</span></a></div>";
  3261.                 } else {
  3262.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("miss_mfc") + "<i" + "mg src=http://img.myfreecams.com/ico/france-16x16.png style='vertical-align:center;margin:0px;'></a></div> " + A("miss_mfc") + "Miss MyFreeCams</span></a></div>";
  3263.                 }
  3264.                 if (g_sModelGroup == 'asian') {
  3265.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("model_matrix") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/model_matrix-sm.png style='vertical-align:center;margin:0px;'></a></div> " + A("model_matrix", {
  3266.                         mode: 'asian'
  3267.                     }) + "Asian Explorer</span></a></div>";
  3268.                 } else {
  3269.                     sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("model_matrix") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/model_matrix-sm.png style='vertical-align:center;margin:0px;'></a></div> " + A("model_matrix") + "Model Explorer</span></a></div>";
  3270.                 }
  3271.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("member_webcams") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/member_webcams.16x16.png style='vertical-align:center;margin:0px;'></a></div> " + A("member_webcams") + "Member Webcams</span></a></div>";
  3272.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("broadcast", {
  3273.                     session_id: g_nSessionId
  3274.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/webcam_medium.gif style='vertical-align:center;margin:0px;'></a></div> " + A("broadcast", {
  3275.                     session_id: g_nSessionId
  3276.                 }) + "<span id=broadcast_status>Start My Webcam</span></a></div>";
  3277.             } else if (g_hSelf['access_level'] == 1) {
  3278.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('tour', {
  3279.                     anchor: 'lounge'
  3280.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/martini_3.16x16.gif></div> " + A('tour', {
  3281.                     anchor: 'lounge'
  3282.                 }) + "Lounge</a></div>";
  3283.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('tour', {
  3284.                     anchor: 'archives'
  3285.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/archive.gif></div> " + A('tour', {
  3286.                     anchor: 'archives'
  3287.                 }) + "Private Archives</a></div>";
  3288.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('tour', {
  3289.                     anchor: 'private_gallery'
  3290.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/camera.gif></div> " + A('tour', {
  3291.                     anchor: 'private_gallery'
  3292.                 }) + "Private Gallery</a></div>";
  3293.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('tour', {
  3294.                     anchor: 'mail'
  3295.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/my_inbox_small.gif></div> " + A('tour', {
  3296.                     anchor: 'mail'
  3297.                 }) + "MFC Mail</a></div>";
  3298.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('tour', {
  3299.                     anchor: 'my_webcam'
  3300.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/webcam_medium.gif></div> " + A('tour', {
  3301.                     anchor: 'my_webcam'
  3302.                 }) + "My Webcam</a></div>";
  3303.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A("group_shows_board") + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/group_show_board.small.png style='vertical-align:center;margin:0px;'></a></div> " + A("group_shows_board") + "Group Shows</span></a></div>";
  3304.                 sMenu += "<div class=pmenu><div class=pmenu_icon>" + A('tour', {
  3305.                     anchor: 'member_webcams'
  3306.                 }) + "<i" + "mg src=http://img.myfreecams.com/mfc2/images/icons/member_webcams.16x16.png></div> " + A('tour', {
  3307.                     anchor: 'my_webcam'
  3308.                 }) + "My Webcam</a></div>";
  3309.             }
  3310.         }
  3311.         if (sMode == 'menu_only') {
  3312.             SetHTML('personal_menu', sMenu);
  3313.             return;
  3314.         }
  3315.         sH += sMenu + "\n </div> </div> <div id=inbox_alert style='display:none;'></div>\n </div>\n ";
  3316.         SetHTML('friends_private_messages', sH);
  3317.     } else if (sMode == 'disconnected') {
  3318.         SetHTML('friends_private_messages', "\n <div style='position:relative;'>\n <div id=private_message_list class=chat_private_message_list></div>\n You have been disconnected from the server. We are attempting to reconnect. \n ");
  3319.         if (g_hSelf['access_level'] > 0) {
  3320.             SetHTML('friends_private_messages', "\n <div class=chat_friends_list style='white-space:nowrap;'>\n " + A("toggle_menu") + "Hide Friends Menu</a><br>\n ");
  3321.             SetHTML('friends_private_messages', "\n </div>\n ");
  3322.         }
  3323.         SetHTML('online_friends_list', "");
  3324.         SetHTML('offline_friends_list', "");
  3325.         return;
  3326.     }
  3327.     SetHTML('online_friends', "\n <div id=online_friends_list class=chat_friends_list style='width:100%;'></div>\n ");
  3328.     SetHTML('offline_friends', "\n <div id=offline_friends_list class=chat_friends_list style='width:100%;'></div>");
  3329.     if (!g_hCk['passcode'] && IdCache('private_message_list')) {
  3330.         var sPersonalMenu = "<div style='font-size:12px ! important;border:0px dashed red;'>";
  3331.         var sGuestName = g_hSelf['username'] || '...';
  3332.         if (g_hSelf['username'] && g_hSelf['username'].match(/^Guest\d+/) || sMode == 'new_guest_name') {
  3333.             sPersonalMenu += "\n You are <b>" + g_hSelf['username'] + "</b><br><br> Choose a new name:<br><br> <form onSubmit=\" return SubmitGuestUsername(); \"> <div style=\"text-align:center;\"> <input type=text id=guest_username value=\"Choose Nickname\" onKeyUp=\"CheckGuestUsernameQueue(this.value);\" style=\"font-size:13px;width:140px;\" onClick=\"if(this.value=='Choose Nickname') this.value='';\"> <div id=username_status>&nbsp;</div> <input type=button value=\"Change Name\" id=username_change_submit style=\"font-size:13px;width:120px;\" disabled=true onClick=\"SubmitGuestUsername()\"> </div> </form> ";
  3334.         } else {
  3335.             sPersonalMenu += "<br>";
  3336.             if (g_hSelf['username']) {
  3337.                 sPersonalMenu += " You are <b>" + g_hSelf['username'] + "</b><br> ";
  3338.             }
  3339.             sPersonalMenu += "\n <span style='font-size:10px;'>[<a href=\"#\" onClick=\" g_bFriendsListSuspendUpdates = 0; ResetGuestUsername(); \">Reset Guest Name</a>]</span> ";
  3340.         }
  3341.         if (g_hSelf['username'] && !g_hSelf['username'].match(/^Guest\d+/)) {
  3342.             sPersonalMenu += "\n <br> <br> <form onSubmit='return SubmitGuestSignup();'> Enter your e-mail address to become a member for free:<br><br> <div style=\"text-align:center;\"> <input type=text id=guest_email style=\"font-size:13px;width:140px;\" onKeyUp=GuestSignupValidate() value=\"E-mail Address\" onClick=\"if(this.value=='E-mail Address') this.value='';\"> <input type=button id=guest_signup_submit value=\"Register Free\" style=\"font-size:13px;\" disabled=true onClick=\"SubmitGuestSignup()\"> </div> </form> ";
  3343.         }
  3344.         sPersonalMenu += "\n <br> <br> Members use this toolbar to access:<br> <br> - " + t.A('tour', {
  3345.             anchor: 'instant_message'
  3346.         }) + "instant messages</a><br> - " + t.A('tour', {
  3347.             anchor: 'special_features'
  3348.         }) + "special features</a><br> - " + t.A('tour', {
  3349.             anchor: 'my_webcam'
  3350.         }) + "your own webcam</a><br><br> " + t.A('register', {
  3351.             target: 'new_window'
  3352.         }) + "Become a member free</a><br><br> " + t.A('login') + "Log in to your account</a> ";
  3353.         sPersonalMenu += "</div>";
  3354.         IdCache('private_message_list').style.display = "block";
  3355.         SetHTML('friends_private_messages', sPersonalMenu);
  3356.         SetHTML('online_friends_list', "\n <div style='font-size:12px'> Your online models and friends are shown here. </div> ");
  3357.         SetHTML('offline_friends_list', "\n <div style='font-size:12px'> You can message your offline friends too! </div> ");
  3358.         g_bFriendsListSuspendUpdates = 1;
  3359.     } else {
  3360.         var aList = SortedUserKeys();
  3361.         var aOnline = new Array();
  3362.         for (nK in aList) {
  3363.             nRemoteUserID = aList[nK];
  3364.             if (g_hUsers[nRemoteUserID] && g_hUsers[nRemoteUserID]['friend'] == true) {
  3365.                 if (g_hUsers[nRemoteUserID]['state'] != t.FCVIDEO_UNKNOWN && typeof(g_hUsers[nRemoteUserID]['state']) != 'undefined') {
  3366.                     aOnline.push(BuildFriendsListEntry(nRemoteUserID));
  3367.                 }
  3368.             }
  3369.         }
  3370.         var nOfflineLimit = 0;
  3371.         var aOffline = new Array();
  3372.         var aList = SortedUserKeys();
  3373.         for (nK in aList) {
  3374.             nRemoteUserID = aList[nK];
  3375.             if (g_hUsers[nRemoteUserID] && g_hUsers[nRemoteUserID]['friend'] == true) {
  3376.                 if (g_hUsers[nRemoteUserID]['state'] != t.FCVIDEO_UNKNOWN) {
  3377.                     continue;
  3378.                 }
  3379.                 if (nOfflineLimit >= 50) {
  3380.                     aOffline.push("...<br><br>This list is limited to the 50 friends who have most recently logged on.");
  3381.                     nOfflineLimit++;
  3382.                     break;
  3383.                 } else {
  3384.                     aOffline.push(BuildFriendsListEntry(nRemoteUserID));
  3385.                     nOfflineLimit++;
  3386.                 }
  3387.             }
  3388.         }
  3389.         if (!aOnline[0] && !aOffline[0]) {
  3390.             aOnline.push("\n You can chat privately with models and users by clicking their names!\n <br><br>You can add your friends inside the message windows or by opening the " + A('user_settings') + " <b>friend manager</b></a> window.<br><br> ");
  3391.             aOffline.push("Your offline friends will apear in this box.");
  3392.         }
  3393.         aOnline.push("<br>" + A("pm_prompt") + "Send Private Message</a>");
  3394.         aOnline.push("<br>" + A("manage_friends", {
  3395.             load: 'manage_friends'
  3396.         }) + "Manage / Add Friends</a>");
  3397.         SetHTML('online_friends_list', aOnline.join(''));
  3398.         SetHTML('offline_friends_list', aOffline.join(''));
  3399.     }
  3400.     LoadPrivateMessageList();
  3401.     var nTotalHeight = IdCache('friends_inner_frame_foot').offsetTop - IdCache('friends_inner_frame').offsetTop;
  3402.     if (IdCache('friends_container_foot').offsetTop > 0 && nTotalHeight < IdCache('friends_container_foot').offsetTop) {
  3403.         var hSize = {
  3404.             ie: 188,
  3405.             ff: 188,
  3406.             sf: 180,
  3407.             ch: 178
  3408.         };
  3409.         IdCache('friends_inner_frame').style.width = (hSize[t.g_sUA]) + "px";
  3410.         IdCache('friend_content_div').style.width = (hSize[t.g_sUA]) + "px";
  3411.     } else {
  3412.         var hSize = {
  3413.             ie: 172,
  3414.             ff: 172,
  3415.             sf: 160,
  3416.             ch: 158
  3417.         };
  3418.         IdCache('friends_inner_frame').style.width = (hSize[t.g_sUA]) + "px";
  3419.         IdCache('friend_content_div').style.width = (hSize[t.g_sUA]) + "px";
  3420.     }
  3421. }
  3422.  
  3423. function GuestSignupValidate() {
  3424.     var sEmail = IdCache('guest_email').value;
  3425.     if (sEmail.length > 5 && sEmail.match(/\w@.+\.\w+/)) {
  3426.         IdCache('guest_signup_submit').disabled = false;
  3427.     } else {
  3428.         IdCache('guest_signup_submit').disabled = true;
  3429.     }
  3430. }
  3431.  
  3432. function SubmitGuestSignup() {
  3433.     if (IdCache('guest_signup_submit').disabled == true) {
  3434.         return false;
  3435.     }
  3436.     if (ValidateEmail) {
  3437.         var sErr;
  3438.         if (sErr = ValidateEmail(IdCache('guest_email').value)) {
  3439.             alert(sErr);
  3440.             return false;
  3441.         }
  3442.     }
  3443.     var sQS = "submit_signup=1&mode=side_bar&username=" + g_hSelf['username'] + "&email=" + escape(IdCache('guest_email').value);
  3444.     window.open('../php/account.php?' + sQS, 'account', 'height=440,width=800,status=0,resizable=1');
  3445.     return false;
  3446. }
  3447. var g_oCheckUsernameTimeout;
  3448. var g_sCheckPmUsername = '';
  3449.  
  3450. function CheckPmUsernameQueue() {
  3451.     sUsername = document.getElementById('pm_username_lookup').value;
  3452.     sUsername = sUsername.replace(/\W/, '');
  3453.     sUsername = sUsername.substr(0, 20);
  3454.     SetHTML('username_recognized', "&nbsp;");
  3455.     if (sUsername.length < 5) {
  3456.         return;
  3457.     }
  3458.     g_sCheckPmUsername = sUsername;
  3459.     if (g_oCheckUsernameTimeout) {
  3460.         clearTimeout(g_oCheckUsernameTimeout);
  3461.         g_oCheckUsernameTimeout = setTimeout("CheckPmUsername('" + sUsername + "')", 500);
  3462.     } else {
  3463.         CheckPmUsername(sUsername);
  3464.         g_oCheckUsernameTimeout = setTimeout("1;", 500);
  3465.     }
  3466. }
  3467. var g_sNewUsername = '';
  3468.  
  3469. function CheckGuestUsernameQueue(sUsername) {
  3470.     if (IdCache('guest_username')) sUsername = IdCache('guest_username').value;
  3471.     sUsername = sUsername.replace(/\W/, '');
  3472.     sUsername = sUsername.substr(0, 20);
  3473.     if (IdCache('guest_username')) IdCache('guest_username').value = sUsername;
  3474.     if (document.getElementById('username_recognized')) {
  3475.         SetHTML('username_recognized', "&nbsp;");
  3476.     } else if (document.getElementById('username_status')) {
  3477.         SetHTML('username_status', "&nbsp;");
  3478.     }
  3479.     if (sUsername.length < 5 && IdCache('username_change_submit')) {
  3480.         IdCache('username_change_submit').disabled = true;
  3481.         g_oCheckUsernameTimeout = setTimeout("CheckGuestUsername('" + sUsername + "')", 500);
  3482.         return;
  3483.     }
  3484.     g_sNewUsername = sUsername;
  3485.     if (g_oCheckUsernameTimeout) {
  3486.         clearTimeout(g_oCheckUsernameTimeout);
  3487.         g_oCheckUsernameTimeout = setTimeout("CheckGuestUsername('" + sUsername + "')", 500);
  3488.     } else {
  3489.         CheckGuestUsername(sUsername);
  3490.         g_oCheckUsernameTimeout = setTimeout("1;", 500);
  3491.     }
  3492. }
  3493. var g_oCheckUsernameReq = null;
  3494.  
  3495. function CheckGuestUsername(sUsername) {
  3496.     if (g_oCheckUsernameReq == null) g_oCheckUsernameReq = createRequestObject();
  3497.     g_oCheckUsernameReq.open("get", "../php/account.php?check_username=1&potential_username=" + sUsername + "&" + Math.random());
  3498.     g_oCheckUsernameReq.onreadystatechange = GuestUsername_Response;
  3499.     g_oCheckUsernameReq.send(null);
  3500. }
  3501. var g_oCheckUsernameReq = null;
  3502.  
  3503. function CheckPmUsername(sUsername) {
  3504.     if (g_oCheckUsernameReq == null) g_oCheckUsernameReq = createRequestObject();
  3505.     g_oCheckUsernameReq.open("get", "../php/account.php?check_username=1&potential_username=" + sUsername + "&user_hash=1&" + Math.random());
  3506.     g_oCheckUsernameReq.onreadystatechange = PmUsernameLookup_Response;
  3507.     g_oCheckUsernameReq.send(null);
  3508. }
  3509.  
  3510. function GuestUsername_Response() {
  3511.     if (g_oCheckUsernameReq.readyState != 4) {
  3512.         return;
  3513.     }
  3514.     if (g_oCheckUsernameReq.responseText == -1) {
  3515.         g_bUsernameAvailable = true;
  3516.         SetHTML('username_status', "[<span style='color:green;'>Username available</span>]");
  3517.         IdCache('username_change_submit').disabled = false;
  3518.     } else if (g_oCheckUsernameReq.responseText.match(/^[\d\-]*$/)) {
  3519.         g_bUsernameAvailable = false;
  3520.         SetHTML('username_status', "[<span style='color:red;'>Username in use</span>]");
  3521.         IdCache('username_change_submit').disabled = true;
  3522.     } else {
  3523.         alert('lookup error');
  3524.     }
  3525. }
  3526.  
  3527. function PmUsernameLookup_Response() {
  3528.     if (g_oCheckUsernameReq.readyState != 4) {
  3529.         return;
  3530.     }
  3531.     if (g_oCheckUsernameReq.responseText == -1) {
  3532.         g_bUsernameAvailable = true;
  3533.         try {
  3534.             SetHTML('username_recognized', "[<span style='color:red;'>We can't find a user by this name</span>]");
  3535.         } catch (oError) {}
  3536.         try {
  3537.             document.getElementById('pm_username_lookup_submit').disabled = true;
  3538.         } catch (oError) {}
  3539.     } else if (g_oCheckUsernameReq.responseText.match(/^[\d\-]*$/)) {
  3540.         g_nPmPrompt_UserId = g_oCheckUsernameReq.responseText;
  3541.         g_bUsernameAvailable = false;
  3542.         SetHTML('username_recognized', "<span style='color:green;'>Username found!</span>");
  3543.         clearTimeout(g_oPmPrompt_InputListener_Timer);
  3544.         TxCmd(FCTYPE_USERNAMELOOKUP, 0, 0, t.FCWINDOW_NO_USER_PM, 0, g_sCheckPmUsername);
  3545.     } else {
  3546.         alert('lookup error');
  3547.     }
  3548. }
  3549.  
  3550. function PmUsernameLookup_Response_FcTypeUsernameLookupRx(nUserId) {
  3551.     g_nPmPrompt_UserId = nUserId;
  3552.     document.getElementById('pm_username_lookup_submit').disabled = false;
  3553. }
  3554.  
  3555. function ResetGuestUsername(sMode) {
  3556.     g_sNewUsername = "Guest" + MfcStringUtilities.prototype.char_padding(Math.floor(Math.random() * 99999), 5, 0);
  3557.     t.TxCmd(t.FCTYPE_SETGUESTNAME, g_nSessionId, 0, t.g_hSelf['user_id'], 0, g_nUID + ":" + g_sNewUsername);
  3558. }
  3559.  
  3560. function SubmitGuestUsername(sMode) {
  3561.     if (g_bUsernameAvailable != true || IdCache('username_change_submit').disabled == true) {
  3562.         return false;
  3563.     }
  3564.     t.TxCmd(t.FCTYPE_SETGUESTNAME, g_nSessionId, 0, t.g_hSelf['user_id'], 0, g_nUID + ":" + g_sNewUsername);
  3565.     return false;
  3566. }
  3567.  
  3568. function SetGuestUsername_Response(nResponse) {
  3569.     {
  3570.         g_bFriendsListSuspendUpdates = 0;
  3571.         try {
  3572.             for (sK in g_hoPlayerWindows) {
  3573.                 if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  3574.                     g_hoPlayerWindows[sK]['handle'].Export().RefreshPeopleBox('reset');
  3575.                 }
  3576.             }
  3577.         } catch (oError) {
  3578.             Log("Try Catch Failure #16: " + oError.description);
  3579.             alert(2);
  3580.         }
  3581.         SaveGuestName(g_sNewUsername);
  3582.         g_hSelf['username'] = g_sNewUsername;
  3583.         g_hUsers[g_hSelf['user_id']]['username'] = g_sNewUsername;
  3584.         LoadFriendsList('reset');
  3585.     }
  3586. }
  3587.  
  3588. function FcModelGroup(nArg1, nArg2) {
  3589.     if (nArg2 == 1) {
  3590.         ChangeModelGroup_Finish();
  3591.         g_bChangeModelGroup = 0;
  3592.         return;
  3593.     }
  3594.     for (sK in g_hModelGroups) {
  3595.         if (g_hModelGroups[sK]['bitmask'] == parseInt(nArg1)) {
  3596.             if (g_sModelGroup != sK) {
  3597.                 g_sModelGroup = sK;
  3598.                 LoadModelGroup();
  3599.             } else {
  3600.                 g_sModelGroup = sK;
  3601.             }
  3602.         }
  3603.     }
  3604. }
  3605.  
  3606. function SaveGuestName(sUsername) {
  3607.     var oExp = new Date();
  3608.     oExp.setTime(oExp.getTime() + (1000 * 60 * 60 * 24 * 3));
  3609.     document.cookie = "guest_username=" + sUsername + "; path=/ ; expires=" + oExp.toGMTString();
  3610. }
  3611.  
  3612. function ChangeAway() {
  3613.     if (!t.g_hSelf['privacy_state']) {
  3614.         t.g_hSelf['privacy_state'] = t.FCMODE_ALLPM;
  3615.     }
  3616.     var sPayload;
  3617.     if (t.g_hSelf['away_state']) {
  3618.         sPayload = null;
  3619.         t.g_hSelf['away_state'] = false;
  3620.     } else {
  3621.         sPayload = "use existing";
  3622.         t.g_hSelf['away_state'] = true;
  3623.     }
  3624.     t.TxCmd(t.FCTYPE_PRIVACY, g_nSessionId, 0, t.g_hSelf['user_id'], t.g_hSelf['privacy_state'], sPayload);
  3625. }
  3626.  
  3627. function PopupBioHandlerCode(nUserId, sMode) {
  3628.     if (!t.g_hUsers[nUserId]) {
  3629.         return;
  3630.     }
  3631.     var sH = " onMouseOver=\" t.PopupBio_onMouseOver(document," + nUserId + ",'" + sMode + "'); \" onMouseOut=\" t.PopupBio_onMouseOut(document); \" ";
  3632.     return sH;
  3633. }
  3634. var g_nContextMenuUserId = 0;
  3635.  
  3636. function onMouseDown_Handler(e) {
  3637.     var bRightClick;
  3638.     if (!e) var e = window.event;
  3639.     if (e.which) bRightClick = (e.which == 3);
  3640.     else if (e.button) bRightClick = (e.button == 2);
  3641.     if (bRightClick && t.g_nContextMenuUserId > 0) {
  3642.         setTimeout("PopUserMenu(" + t.g_nContextMenuUserId + ");", 10);
  3643.         return false;
  3644.     }
  3645. }
  3646.  
  3647. function PopupBio_onMouseOver(oCaller, nUserId, sMode) {
  3648.     if (sMode == 'livesnap') oCaller.g_oDhtmlPopup.open(t.LiveSnapImage(nUserId, 320, 320, 240), 'child,hover');
  3649.     if (nUserId > 0) t.g_nContextMenuUserId = nUserId;
  3650. }
  3651.  
  3652. function PopupBio_onMouseOut(oCaller) {
  3653.     t.g_nContextMenuUserId = 0;
  3654.     oCaller.g_oDhtmlPopup.close('popup_child', 'hover');
  3655. }
  3656. var g_hUserDetailKey = {
  3657.     'city': 'City',
  3658.     'country': 'Country',
  3659.     'ethnic': 'Ethnicity',
  3660.     'occupation': 'Occupation',
  3661.     'age': 'Age',
  3662.     'creation_date': 'Signed Up'
  3663. };
  3664. var g_aMonths = new Array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  3665. var g_aShortMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
  3666. var g_DrawUserDetailsCache = {};
  3667.  
  3668. function DrawUserDetails(nUserId, hOptions) {
  3669.     hOptions = hOptions || {};
  3670.     if (!g_hUsers[nUserId]) {
  3671.         return;
  3672.     }
  3673.     if (g_hLoungeIds[nUserId]) {
  3674.         hOptions['menu'] = 0;
  3675.     }
  3676.     if (!hOptions['menu'] && g_DrawUserDetailsCache[nUserId]) {
  3677.         1;
  3678.     }
  3679.     var sStyle = '';
  3680.     if (!g_hSelf['chat_text_ignore']) {
  3681.         sStyle = MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]);
  3682.     }
  3683.     var aDetails = new Array();
  3684.     for (sK in g_hUserDetailKey) {
  3685.         if (!t.g_hUsers[nUserId] || !t.g_hUsers[nUserId][sK] || t.g_hUsers[nUserId][sK] == -1 || t.g_hUsers[nUserId][sK] == 0 || t.g_hUsers[nUserId][sK] == 'No Answer' || nUserId == 703889) {
  3686.             continue;
  3687.         }
  3688.         var sValue;
  3689.         if (sK == 'creation_date') {
  3690.             if (t.g_hUsers[nUserId][sK] == 0) {
  3691.                 continue;
  3692.             }
  3693.             var oDate = new Date();
  3694.             oDate.setTime(parseInt(t.g_hUsers[nUserId][sK]) * 1000);
  3695.             sValue = g_aShortMonths[oDate.getMonth()] + " '" + MfcStringUtilities.prototype.char_padding(oDate.getFullYear() - 2000, 2, 0);
  3696.         } else if (sK == 'lastlogin') {
  3697.             if (t.g_hUsers[nUserId][sK] == 0) {
  3698.                 continue;
  3699.             }
  3700.             var oDate = new Date();
  3701.             oDate.setTime(parseInt(t.g_hUsers[nUserId][sK]) * 1000);
  3702.             var sDate = oDate.getDate().toString();
  3703.             if (sDate.match(/(11|12|13|4|5|6|7|8|9|0)$/)) sDate += 'th';
  3704.             else if (sDate.match(/3|23/)) sDate += 'rd';
  3705.             else if (sDate.match(/2$/)) sDate += 'nd';
  3706.             else if (sDate.match(/1$/)) sDate += 'st';
  3707.             sValue = "" + g_aShortMonths[oDate.getMonth()] + " " + sDate + " '" + MfcStringUtilities.prototype.char_padding(oDate.getFullYear() - 2000, 2, 0);
  3708.         } else {
  3709.             sValue = t.g_hUsers[nUserId][sK];
  3710.             if (sValue.length > 70) {
  3711.                 if (hOptions['menu']) {
  3712.                     sValue = sValue.substr(0, 70) + "..." + A('bio', g_hUsers[nUserId]) + "More</a>";
  3713.                 } else {
  3714.                     sValue = sValue.substr(0, 70) + "...";
  3715.                 }
  3716.             }
  3717.         }
  3718.         aDetails.push(" <div style='font-size:10px;position:relative;padding-bottom:2px;'> <div style='position:absolute;top:0px;left:0px;width:95px;color:green;font-weight:bold;" + sStyle + "'>" + g_hUserDetailKey[sK] + "</div> <div style='padding-left:95px;font-size:10px;indent:95px;'>" + sValue + "&nbsp;</div> </div> ");
  3719.     }
  3720.     if (t.g_hUsers[nUserId] && t.g_hUsers[nUserId]['access_level'] == 4) {
  3721.         if (g_sModelGroup == 'asian' && t.g_hUsers[nUserId]['asian_cam_score'] > 0) {
  3722.             aDetails.push(" <div style='font-size:10px;position:relative;'> <div style='position:absolute;top:0px;left:0px;width:95px;color:green;font-weight:bold;" + sStyle + "'>AsianCamScore</div> <div style='padding-left:95px;font-size:10px;indent:95px;color:red;'>" + t.g_hUsers[nUserId]['asian_cam_score'] + "</div> </div> ");
  3723.         } else if (t.g_hUsers[nUserId]['cam_score'] > 0) {
  3724.             aDetails.push(" <div style='font-size:10px;position:relative;'> <div style='position:absolute;top:0px;left:0px;width:95px;color:green;font-weight:bold;" + sStyle + "'>CamScore</div> <div style='padding-left:95px;font-size:10px;indent:95px;color:red;'>" + t.g_hUsers[nUserId]['cam_score'] + "</div> </div> ");
  3725.         }
  3726.         if (g_hUsers[nUserId]['state'] != w.FCVIDEO_UNKNOWN) {
  3727.             if (!g_hUsers[nUserId]['kbps']) {
  3728.                 g_hUsers[nUserId]['kbps'] = 100;
  3729.             }
  3730.             var sBitRateCategory = 2;
  3731.             g_hUsers[nUserId]['kbps'] = parseInt(g_hUsers[nUserId]['kbps']);
  3732.             if (g_hUsers[nUserId]['kbps'] > 201) sBitRateCategory = 4;
  3733.             else if (g_hUsers[nUserId]['kbps'] > 120) sBitRateCategory = 3;
  3734.             else if (g_hUsers[nUserId]['kbps'] > 90) sBitRateCategory = 2;
  3735.             else if (g_hUsers[nUserId]['kbps'] > 48) sBitRateCategory = 1;
  3736.             else if (g_hUsers[nUserId]['kbps'] > 0) sBitRateCategory = 0;
  3737.             hDescriptions = {
  3738.                 0: 'Very Bad',
  3739.                 1: 'Bad',
  3740.                 2: 'Average',
  3741.                 3: 'Good',
  3742.                 4: 'Very Good'
  3743.             };
  3744.             sValue = hDescriptions[sBitRateCategory];
  3745.             aDetails.push(" <div style='font-size:10px;position:relative;'> <div style='position:absolute;top:0px;left:0px;width:95px;color:green;font-weight:bold;" + sStyle + "'>Connection</div> <div style='padding-left:95px;font-size:10px;indent:95px;color:red;'>" + sValue + "</div> </div> ");
  3746.         }
  3747.     }
  3748.     var aHtml = new Array();
  3749.     aHtml.push(" <div style=\"text-align:right;font-size:10px;\"> ");
  3750.     if (t.g_hUsers[nUserId]) {
  3751.         aHtml.push(" <span style=\"cursor:pointer;\" onClick=\"t.PopImage({ caller:document, src: 'http://img.myfreecams.com/photos2/" + nUserId.toString().substr(0, 3) + "/" + nUserId + "/avatar.300x300.jpg', height:300, width:300 });\"> ");
  3752.     }
  3753.     aHtml.push(" <i" + "mg class=avatar_border ");
  3754.     if (t.g_hUsers[nUserId] && t.g_hUsers[nUserId]['avatars'] > 0) aHtml.push(" src=" + AvatarUrl(nUserId, 90));
  3755.     else aHtml.push(" src=" + t.g_hC['site_path_images'] + "/images/misc/clear.gif");
  3756.     sUsernameStyle = MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]);
  3757.     aHtml.push(" ></span> ");
  3758.     if (g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_IDLE) {
  3759.         aHtml.push("<span style=\"cursor:pointer;\" onClick=\"t.PopImage({caller:document,src:t.LiveSnapUrl('" + nUserId + "',320),go_to_room:" + nUserId + ",height:240,width:320,style_class:'livesnap_border'});\"><i" + "mg class=livesnap_border height=90 src=" + t.LiveSnapUrl(nUserId, 100) + "></span> <br>" + t.A('player', {
  3760.             broadcaster_id: nUserId
  3761.         }) + "Load Cam</a>");
  3762.     }
  3763.     aHtml.push(" </div> <div style='font-size:19px;padding-bottom:10px;color:green;font-weight:bold;" + sUsernameStyle + "'>" + t.g_hUsers[nUserId]['username'] + "</div> ");
  3764.     if (t.g_hUsers[nUserId]['topic']) {
  3765.         aHtml.push("<div style='font-size:10px;padding-bottom:10px;'> " + t.g_hUsers[nUserId]['topic'] + (hOptions['menu'] ? ("..." + A('bio', g_hUsers[nUserId]) + "More</a>") : '') + "</div>");
  3766.     }
  3767.     if (hOptions['menu']) {
  3768.         var sHideModel = '';
  3769.         if (g_hSelf['access_level'] && g_hSelf['access_level'] >= 2 && t.g_hUsers[nUserId] && t.g_hUsers[nUserId]['access_level'] == 4) {
  3770.             if (g_hUsers[nUserId]['hidden']) {
  3771.                 sHideModel = "<a href=\"javascript:t.HideModel(" + nUserId + ",{ unhide: 1 });ClosePopup();\">Un-Hide Model</a><br>";
  3772.             } else {
  3773.                 sHideModel = "<a href=\"javascript:t.HideModel(" + nUserId + ");ClosePopup();\">Hide Model</a><br>";
  3774.             }
  3775.         }
  3776.         if (t.g_hUsers[nUserId]['active'] && t.g_hUsers[nUserId]['access_level'] >= 2) {
  3777.             aDetails.push(" <div style='font-size:10px;position:relative;'> <div style='position:absolute;top:0px;left:0px;width:95px;color:green;font-weight:bold;" + sStyle + "'>Images</div> <div style='padding-left:95px;font-size:10px;indent:95px;'> ");
  3778.             for (n = 1; n < 5; n++) {
  3779.                 aDetails.push(" <span style=\"cursor:pointer;\" onClick=\"t.PopImage({ caller:document,src:'http://img.myfreecams.com/photos2/" + nUserId.toString().substr(0, 3) + "/" + nUserId + "/pic" + n + ".300x.jpg',width:300});\"><i" + "mg src=\"http://img.myfreecams.com/photos2/" + nUserId.toString().substr(0, 3) + "/" + nUserId + "/pic" + n + ".x30.jpg\"></span> ");
  3780.             }
  3781.             aDetails.push(" <div style=text-align:right;>" + t.A('bio', t.g_hUsers[nUserId]) + "View All Pictures</a></div> </div> </div> ");
  3782.         }
  3783.         aDetails.push(" <div style='font-size:10px;position:relative;padding-top:10px;'> <div style='color:green;font-weight:bold;" + sStyle + "'>Menu</div> <div style='font-size:10px;padding-top:5px;padding-bottom:10px;'> <table border=0> <td style=\"line-height:15px;font-size:10px;\" valign=top nowrap> ");
  3784.         if (t.g_hUsers[nUserId]['access_level'] == 4) {
  3785.             aDetails.push("" + t.A('bio', t.g_hUsers[nUserId]) + "View Full Profile</a> <br>");
  3786.             if (IsBroadcastState(t.g_hUsers[nUserId]['state'])) {
  3787.                 aDetails.push((g_hSelf['access_level'] >= 2 ? t.A('pm_friend', {
  3788.                     user_id: nUserId,
  3789.                     load_video: 'true'
  3790.                 }) : t.A('register', {
  3791.                     message: 'premium_feature'
  3792.                 })) + "View Webcam in PM</a> <br>");
  3793.                 if ((g_hSelf['access_level'] == 2 || g_hSelf['access_level'] == 5) && window.frames['main'] && window.frames['main'].Export && window.frames['main'].Export().g_nBroadcasterId > -1) {
  3794.                     try {
  3795.                         if (g_sModelGroup == 'asian') {
  3796.                             aDetails.push(A('player', {
  3797.                                 broadcaster_id: g_hLoungeIds['Asian_Lounge'],
  3798.                                 target: 'main',
  3799.                                 title: 'Go to the Lounge',
  3800.                                 lounge_model_id: nUserId
  3801.                             }) + "View Webcam In Lounge</a> <br>");
  3802.                             if (g_hLoungeIds['Lounge1000']) {
  3803.                                 aDetails.push(A('player', {
  3804.                                     broadcaster_id: g_hLoungeIds['Lounge1000'],
  3805.                                     target: 'main',
  3806.                                     title: 'Go to the Lounge',
  3807.                                     lounge_model_id: nUserId
  3808.                                 }) + "View Webcam In Lounge1000</a> <br>");
  3809.                             }
  3810.                         } else {
  3811.                             aDetails.push(A('player', {
  3812.                                 broadcaster_id: g_hLoungeIds['Lounge'],
  3813.                                 target: 'main',
  3814.                                 title: 'Go to the Lounge',
  3815.                                 lounge_model_id: nUserId
  3816.                             }) + "View Webcam In Lounge</a> <br>");
  3817.                             if (g_hLoungeIds['Lounge1000']) {
  3818.                                 aDetails.push(A('player', {
  3819.                                     broadcaster_id: g_hLoungeIds['Lounge1000'],
  3820.                                     target: 'main',
  3821.                                     title: 'Go to the Lounge',
  3822.                                     lounge_model_id: nUserId
  3823.                                 }) + "View Webcam In Lounge1000</a> <br>");
  3824.                             }
  3825.                         }
  3826.                     } catch (oError) {
  3827.                         Log("Try Catch Failure #21: " + oError.description);
  3828.                     }
  3829.                 }
  3830.             }
  3831.             aDetails.push(t.A('player', {
  3832.                 broadcaster_id: nUserId
  3833.             }) + "Go To Chat Room</a> <br>");
  3834.             aDetails.push(t.A('player', {
  3835.                 broadcaster_id: nUserId,
  3836.                 target: 'new_window'
  3837.             }) + "Popup Chat Room</a> <br>");
  3838.             aDetails.push(" </td> <td>&nbsp;</td> <td style=\"line-height:15px;font-size:10px;\" valign=top nowrap> ");
  3839.             aDetails.push((g_hSelf['access_level'] >= 2 ? t.A('pm_friend', {
  3840.                 user_id: nUserId
  3841.             }) : t.A('register', {
  3842.                 message: 'premium_feature'
  3843.             })) + "Send A Message</a> <br>");
  3844.             aDetails.push(g_hSelf['access_level'] >= 2 ? t.A('tip', {
  3845.                 broadcaster_id: nUserId
  3846.             }) + "Send A Tip</a> <br>" : '');
  3847.             aDetails.push(g_hSelf['access_level'] >= 2 ? t.A('message', {
  3848.                 user_id: nUserId
  3849.             }) + "Send MFC Mail</a> <br>" : '');
  3850.             if (t.g_hUsers[nUserId]['friend']) {
  3851.                 aDetails.push("Remove Friend (" + t.A('tx_remove_friend', {
  3852.                     remote_user_code: nUserId
  3853.                 }) + "x</a>) <br>");
  3854.             } else if (g_hSelf['access_level'] >= 1) {
  3855.                 aDetails.push("" + t.A('tx_add_friend', {
  3856.                     remote_user_code: nUserId
  3857.                 }) + "Add Friend</a> <br>");
  3858.             } else {
  3859.                 aDetails.push("" + t.A('register') + "Add Friend</a> <br>");
  3860.             }
  3861.             aDetails.push(sHideModel);
  3862.         } else {
  3863.             if (t.g_hUsers[nUserId]['active'] || t.g_hUsers[nUserId]['state'] >= 90) {
  3864.                 aDetails.push(t.A('bio', t.g_hUsers[nUserId]) + "View Full Profile</a><br>");
  3865.             }
  3866.             if (g_hSelf['access_level'] > 0) {
  3867.                 aDetails.push(t.A('pm_friend', {
  3868.                     user_id: nUserId
  3869.                 }) + "Send A Message</a><br>");
  3870.             } else {
  3871.                 aDetails.push(t.A('members_feature') + "Send A Message</a><br>");
  3872.             }
  3873.             if (g_hSelf['access_level'] == 0 || !g_hSelf['access_level']) {
  3874.                 aDetails.push(t.A('members_feature') + "Add To Friends List</a><br>");
  3875.             } else if (t.g_hUsers[nUserId]['friend']) {
  3876.                 aDetails.push("Remove From Friends List (" + t.A('tx_remove_friend', {
  3877.                     remote_user_code: nUserId
  3878.                 }) + "x</a>)<br>");
  3879.             } else {
  3880.                 aDetails.push(t.A('tx_add_friend', {
  3881.                     remote_user_code: nUserId
  3882.                 }) + "Add Friend</a><br>");
  3883.             }
  3884.             if (g_hUsers[nUserId] && g_hUsers[nUserId]['access_level'] == 4) {
  3885.                 aDetails.push(t.A('tip', {
  3886.                     broadcaster_id: nUserId
  3887.                 }) + "Leave A Tip</a><br>");
  3888.             }
  3889.             if (g_hSelf['access_level'] == 0) {
  3890.                 aDetails.push(t.A('members_feature') + "Send MFC Mail</a><br>");
  3891.             } else {
  3892.                 aDetails.push(t.A('message', {
  3893.                     user_id: nUserId
  3894.                 }) + "Send MFC Mail</a><br>");
  3895.             }
  3896.             if (g_hSelf['access_level'] == 0) {
  3897.                 aDetails.push(t.A('members_feature') + "Ignore User</a><br>");
  3898.             } else if (t.g_hIgnoredUsers[nUserId]) {
  3899.                 aDetails.push(t.A('tx_remove_ignore', {
  3900.                     remote_user_code: nUserId
  3901.                 }) + "<span style='background-color:#ffcccc;'>Stop Ignoring</span></a>" + "<br>");
  3902.             } else {
  3903.                 aDetails.push(t.A('tx_add_ignore', {
  3904.                     remote_user_code: nUserId
  3905.                 }) + "Ignore User</a>" + "<br>");
  3906.             }
  3907.         }
  3908.         aDetails.push("</td></table> <div style='text-align:right;'> <a href='#' onClick='ClosePopup()'>Close</a> </div> </div> </div> ");
  3909.         if (top.g_sClearCode && top.g_sClearCode.length > 1 && (g_hSelf['username'].match(/^mfcuser$|^AdminAaron$|^adminleo|^AdminAndrew$/i))) {
  3910.             aDetails.push("<hr>Admin<br><table><td style=font-size:10px;padding-right:20px; valign=top>");
  3911.             aDetails.push("<a href=../php/alias_lookup.php?user_id=" + nUserId + "&code=" + top.g_sClearCode + " target=_blank >Alias Lookup</a>" + "<br>");
  3912.             aDetails.push("<a href=# onClick=\"t.Admin('reset'," + nUserId + ")\">Reset</a>" + "<br>");
  3913.             aDetails.push("<a href=# onClick=\"t.Admin('disable_user'," + nUserId + ")\">Disable</a>" + "<br>");
  3914.             aDetails.push("</td><td style=font-size:10px; valign=top>");
  3915.             aDetails.push("<a href=# onClick=\"t.Admin('no_first_pm'," + nUserId + ")\">Disable 1st PM</a>" + "<br>");
  3916.             if (t.g_hUsers[nUserId]['model_group'] == 2) {
  3917.                 aDetails.push("<a href=# onClick=\"t.Admin('set_both'," + nUserId + ")\">Set 'Both'</a>" + "<br>");
  3918.             }
  3919.             if (t.g_hUsers[nUserId]['access_level'] == 4) {
  3920.                 aDetails.push("<a href=../php/rule_violations.php?user_id=" + nUserId + "&code=" + top.g_sClearCode + " target=_blank >Rule Violations</a>" + "<br>");
  3921.             }
  3922.             aDetails.push("</td></table>");
  3923.         }
  3924.     }
  3925.     aHtml.push(aDetails.join(''));
  3926.     if (!hOptions['menu']) {
  3927.         g_DrawUserDetailsCache[nUserId] = "<div style='width:285px;height:450px;padding-bottom:20px;'>" + aHtml.join('') + "</div>";
  3928.         return g_DrawUserDetailsCache[nUserId];
  3929.     } else {
  3930.         return "<div style='padding-bottom:20px;height:470px;width:285px;'>" + aHtml.join('') + "</div>";
  3931.     }
  3932. }
  3933.  
  3934. function AvatarError(oCaller, nUserId) {
  3935.     oCaller.src = '../images/misc/generic_avatar.90x90.gif';
  3936.     g_hUsers[nUserId]['avatars'] = 0;
  3937. }
  3938.  
  3939. function PopImage(hOptions) {
  3940.     hOptions = hOptions || {};
  3941.     hOptions['caller'] = hOptions['caller'] || document;
  3942.     var sPopupChildContent = "<i" + "mg src='" + hOptions['src'] + "' onClick=\"g_oDhtmlPopup.close('popup_child');\" ";
  3943.     if (hOptions['width']) sPopupChildContent += " width=" + hOptions['width'] + " ";
  3944.     if (hOptions['height']) sPopupChildContent += " height=" + hOptions['height'] + " ";
  3945.     if (hOptions['style_class']) sPopupChildContent += " class=" + hOptions['style_class'] + " ";
  3946.     sPopupChildContent += ">";
  3947.     if (hOptions['go_to_room']) {
  3948.         var nUserId = hOptions['go_to_room'];
  3949.         sPopupChildContent += "<div style=white-space:nowrap;width:250px;>" + t.A('player', {
  3950.             broadcaster_id: nUserId
  3951.         }) + "Go to <b>" + t.g_hUsers[nUserId]['username'] + "'s</b> Room</div>";
  3952.     }
  3953.     hOptions['caller'].g_oDhtmlPopup.open(sPopupChildContent, 'child');
  3954. }
  3955.  
  3956. function HideModel(nModelId, hOptions) {
  3957.     hOptions = hOptions || {};
  3958.     if (nModelId == 'all') {
  3959.         for (nId in g_hUsers) {
  3960.             g_hUsers[nId]['hidden'] = 0;
  3961.         }
  3962.     } else {
  3963.         g_hUsers[nModelId]['hidden'] = hOptions['unhide'] ? 0 : 1;
  3964.     }
  3965.     for (sK in g_hWindows) {
  3966.         if (g_hWindows[sK].RefreshOnlineBroadcasterList) {
  3967.             g_hWindows[sK].RefreshOnlineBroadcasterList('initialize');
  3968.         }
  3969.     }
  3970.     for (sK in g_hWindows) {
  3971.         if (g_hWindows[sK].LoadHiddenModelsList) {
  3972.             g_hWindows[sK].LoadHiddenModelsList();
  3973.         }
  3974.     }
  3975.     SaveSetting('hide_model', nModelId, hOptions['unhide'] || 0);
  3976. }
  3977. var g_hHaltPopupClose = {};
  3978.  
  3979. function PopUserMenu(nUserId, hOptions) {
  3980.     hOptions = hOptions || {};
  3981.     if (!nUserId) nUserId = t.g_nContextMenuUserId;
  3982.     if (!hOptions['hover_bio']) hOptions['menu'] = 1;
  3983.     g_oDhtmlPopup.open(DrawUserDetails(nUserId, hOptions));
  3984. }
  3985.  
  3986. function IsBroadcastState(nState) {
  3987.     if (nState < FCVIDEO_RX_IDLE) {
  3988.         return true;
  3989.     }
  3990.     return false;
  3991. }
  3992.  
  3993. function IsOnline(nState) {
  3994.     if (parseInt(nState) != FCVIDEO_UNKNOWN) {
  3995.         return true;
  3996.     }
  3997.     return false;
  3998. }
  3999.  
  4000. function IsSessionState(nState) {
  4001.     if (parseInt(nState) == t.FCVIDEO_TX_PVT || parseInt(nState) == t.FCVIDEO_RX_PVT || parseInt(nState) == t.FCVIDEO_RX_VOY || parseInt(nState) == t.FCVIDEO_RX_GRP || parseInt(nState) == t.FCVIDEO_TX_GRP) {
  4002.         return true;
  4003.     }
  4004.     return false;
  4005. }
  4006.  
  4007. function PublicChannel(nChan) {
  4008.     return 100000000 + parseInt(nChan);
  4009. }
  4010.  
  4011. function SessionChannel(nChan) {
  4012.     return 200000000 + parseInt(nChan);
  4013. }
  4014.  
  4015. function SessionToPublic(nChan) {
  4016.     if (parseInt(nChan) >= 100000000 && parseInt(nChan) < 200000000) return nChan;
  4017.     else if (parseInt(nChan) >= 200000000) return PublicChannel(parseInt(nChan) - 200000000);
  4018.     return parseInt(nChan) + 100000000;
  4019. }
  4020.  
  4021. function ChannelModel(nChan) {
  4022.     if (nChan > 200000000) return parseInt(nChan) - 200000000;
  4023.     else if (nChan > 100000000) return parseInt(nChan) - 100000000;
  4024.     return nChan;
  4025. }
  4026.  
  4027. function SerializeHash(hMap) {
  4028.     str = "";
  4029.     str += hMap['username'] + ':' + hMap['sessionid'] + ':' + hMap['user_id'] + ':';
  4030.     str += hMap['access_level'] + ':' + hMap['state'] + ':' + hMap['rewards_points'] + ':';
  4031.     str += hMap['tokens'] + ':' + hMap['ip'];
  4032.     if (hMap['msg'] && hMap['msg'].length > 0) {
  4033.         str += '/' + hMap['msg'];
  4034.     }
  4035.     return str;
  4036. }
  4037.  
  4038. function ParseJSON(sObject) {
  4039.     if (!sObject) return null;
  4040.     try {
  4041.         return JSON.parse(sObject);
  4042.     } catch (oError) {
  4043.         Log("JSON Error: " + oError + ", " + oError.description);
  4044.     }
  4045.     return null;
  4046. }
  4047.  
  4048. function FcChannelMessage(nFrom, nTo, nArg1, nArg2, nUserId, sMessage) {
  4049.     sMessage = sMessage.replace(/%\w\w/g, '');
  4050.     if (g_bLoadChat > 0 && nUserId != g_hSelf['user_id']) {
  4051.         LoadChat();
  4052.         return;
  4053.     }
  4054.     if (nArg1 == FCRESPONSE_ERROR) {
  4055.         if (nArg2 == FCCHAN_ERR_NOCHANNEL) {
  4056.             alert("channel does not exist");
  4057.         } else if (nArg2 == FCCHAN_ERR_GUESTMUTE) {
  4058.             nPlayerOwnerId = GetRoomOwnerId(nTo);
  4059.             if (g_hoPlayerWindows[nPlayerOwnerId]) {
  4060.                 if (g_hSelf['access_level'] == 1) {
  4061.                     sMessage = "Basic members have been temporarily muted by the model. Buy tokens once to become a Premium Member for life.";
  4062.                 } else {
  4063.                     sMessage = "Guests have been temporarily muted by the model. Members can still chat normally. Please login or register free to chat.";
  4064.                 }
  4065.                 try {
  4066.                     g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().PlayerQueue('chat', FormatChat(sMessage, 0));
  4067.                 } catch (oError) {
  4068.                     Log("Try Catch Failure #5: " + oError.description);
  4069.                 }
  4070.             }
  4071.         }
  4072.         return;
  4073.     }
  4074.     nPlayerOwnerId = GetRoomOwnerId(nTo);
  4075.     if ((g_hSelf['mute_guests'] == 1 && g_hUsers[nUserId] && g_hUsers[nUserId]['access_level'] == 0) || (g_hSelf['mute_regs'] == 1 && g_hUsers[nUserId] && g_hUsers[nUserId]['access_level'] == 1)) {
  4076.         Log('CMESG mute guests/regs on skip');
  4077.         return;
  4078.     }
  4079.     if (nArg2 & FCCHAN_OLDMSG && g_hUsers[nUserId]['state'] == FCVIDEO_UNKNOWN) {
  4080.         g_hUsers[nUserId]['oldmsg'] = 1;
  4081.     } else if (g_hUsers[nUserId]['state'] != FCVIDEO_UNKNOWN) {
  4082.         g_hUsers[nUserId]['oldmsg'] = 0;
  4083.     }
  4084.     if (nArg2 == FCCHAN_OLDMSG) {
  4085.         Log('CMESG old msh, player owner: ' + nPlayerOwnerId);
  4086.     }
  4087.     if (nArg2 == FCCHAN_WELCOME) {
  4088.         RoomTopicHandler(sMessage, nPlayerOwnerId);
  4089.     }
  4090.     if (!g_hoPlayerWindows[nPlayerOwnerId]) {
  4091.         Log('CMESG routing cmesg to ' + nPlayerOwnerId + ' but it doesnt exist');
  4092.         return;
  4093.     }
  4094.     var hMsg = null;
  4095.     try {
  4096.         hMsg = ParseJSON(unescape(sMessage));
  4097.     } catch (e) {
  4098.         Log("FCTYPE_CMESG parsing error");
  4099.         return;
  4100.     }
  4101.     if (!g_hUsers[nUserId] || hMsg == null) {
  4102.         Log("FCTYPE_CMESG called without any user association or json code");
  4103.         return;
  4104.     }
  4105.     var sMessage = hMsg['msg'];
  4106.     var hOptions = {
  4107.         'room_owner_id': nPlayerOwnerId,
  4108.         'type': 'player',
  4109.         'obj': sMessage,
  4110.         'from': nUserId,
  4111.         'oldmsg': (nArg2 == FCCHAN_OLDMSG ? 1 : 0),
  4112.         'welcome': (nArg2 == FCCHAN_WELCOME ? 1 : 0)
  4113.     };
  4114.     if (nArg2 == FCCHAN_OLDMSG || (g_hUsers[nUserId] && g_hUsers[nUserId]['oldmsg'] == 1 && g_hUsers[nUserId]['state'] == FCVIDEO_UNKNOWN)) {
  4115.         hOptions['oldmsg'] = 1;
  4116.     }
  4117.     sMessage = FormatChat(sMessage, nUserId, hOptions);
  4118.     if (g_hLoungeIds[nPlayerOwnerId]) {
  4119.         sMessage = LoungeQuickLinks(sMessage);
  4120.     }
  4121.     try {
  4122.         if (g_hoPlayerWindows[nPlayerOwnerId] && g_hoPlayerWindows[nPlayerOwnerId]['handle'] && g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export) {
  4123.             try {
  4124.                 g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().PlayerQueue('chat', sMessage);
  4125.                 if (nPlayerOwnerId && !hOptions['oldmsg'] && g_hUsers[nUserId]['access_level'] == 4 && !g_hSelf['access_level']) {
  4126.                     g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().g_nModelToGuestChatCount++;
  4127.                 }
  4128.             } catch (oError) {
  4129.                 Log("Try Catch Failure #15: " + oError.description);
  4130.             }
  4131.         }
  4132.     } catch (oError) {
  4133.         Log("PlayerQueue error: " + oError.description);
  4134.     }
  4135. }
  4136.  
  4137. function Sound(sMode, nSound) {
  4138.     if (g_hSelf['access_level'] < 1) {
  4139.         return;
  4140.     }
  4141.     var sSound;
  4142.     if (sMode == 'sound_model_friend_login') sSound = 'gling';
  4143.     else if (sMode == 'sound_user_friend_login') sSound = 'notify';
  4144.     else if (sMode == 'sound_new_model_login') sSound = 'diamond';
  4145.     else if (sMode == 'sound_model_friend_private') sSound = 'heartput';
  4146.     else {
  4147.         nSound = nSound || g_hSelf['pm_sound_type'] || 5;
  4148.         sSound = "ding" + nSound + "_" + sMode;
  4149.     }
  4150.     var oFlashUtilities = getFlashObject('flash_utilities');
  4151.     if (oFlashUtilities) {
  4152.         oFlashUtilities.SetVariable("/:g_sSound", sSound);
  4153.         oFlashUtilities.SetVariable("/:g_sAction", "play_sound");
  4154.     }
  4155. }
  4156.  
  4157. function getFlashObject(sFlashId, oD, oW) {
  4158.     var oW = oW || window;
  4159.     var oD = oD || document;
  4160.     if (oW.document[sFlashId]) {
  4161.         return oW.document[sFlashId];
  4162.     }
  4163.     if (navigator.appName.indexOf("Microsoft Internet") == -1) {
  4164.         if (oD.embeds && oD.embeds[sFlashId]) {
  4165.             return oD.embeds[sFlashId];
  4166.         }
  4167.     } else {
  4168.         return oD.getElementById(sFlashId);
  4169.     }
  4170. }
  4171.  
  4172. function FriendLimiter(oCaller) {
  4173.     oCaller = oCaller || this;
  4174.     var nFriendCount = 0;
  4175.     for (sK in g_hUsers) {
  4176.         if (g_hUsers[sK]['friend']) {
  4177.             nFriendCount++;
  4178.         }
  4179.     }
  4180.     if (g_hSelf['access_level'] == 1 && nFriendCount > 10) {
  4181.         oCaller.alert("Sorry, only premium members can have more than 10 friends at a time!\n \n \nYou can remove some from the Set Chat Options window, or purchase some tokens to become a premium member.");
  4182.         return true;
  4183.     } else {
  4184.         return false;
  4185.     }
  4186. }
  4187.  
  4188. function TxAddRemoveIgnore(nUserId, sAction, hOptions) {
  4189.     var hOptions = hOptions || {};
  4190.     if (hOptions['with_alert']) {
  4191.         alert("You will no longer see " + t.g_hUsers[nUserId]['username'] + "'s messages.\n\nYou can un-ignore this user at a later time in the 'My Friends & Options' ignore settings.");
  4192.     }
  4193.     var nMode = '';
  4194.     if (sAction == 'add') {
  4195.         nMode = FCCHAN_JOIN;
  4196.         TxCmd(FCTYPE_ADDIGNORE, t.g_hSelf['sessionid'], 0, 0, nMode, g_hUsers[nUserId]['username']);
  4197.         t.g_hIgnoredUsers[nUserId] = g_hUsers[nUserId]['username'];
  4198.     } else if (sAction == 'remove') {
  4199.         nMode = FCCHAN_PART;
  4200.         TxCmd(FCTYPE_ADDIGNORE, t.g_hSelf['sessionid'], 0, nUserId, nMode);
  4201.         delete t.g_hIgnoredUsers[nUserId];
  4202.     }
  4203.     try {
  4204.         for (sK in g_hoPlayerWindows) {
  4205.             if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  4206.                 g_hoPlayerWindows[sK]['handle'].Export().RefreshPeopleBox('reset');
  4207.             }
  4208.         }
  4209.     } catch (oError) {
  4210.         Log("Try Catch Failure #16: " + oError.description);
  4211.     }
  4212. }
  4213.  
  4214. function TxAddRemoveFriend(sReceivingUserID_or_Name, sAction) {
  4215.     if (sAction == 'add' && FriendLimiter(this)) return;
  4216.     sReceivingUserID_or_Name = new String(sReceivingUserID_or_Name);
  4217.     sReceivingUserID_or_Name = sReceivingUserID_or_Name.replace(/\W/g, '').substr(0, 32);
  4218.     if (sReceivingUserID_or_Name.length < 2) {
  4219.         alert("Please check the username of the friend you are attempting to add.");
  4220.         return;
  4221.     }
  4222.     if (sReceivingUserID_or_Name.match(/^\d+$/)) {
  4223.         var nMode = '';
  4224.         if (sAction == 'add') nMode = FCCHAN_JOIN;
  4225.         else nMode = FCCHAN_PART;
  4226.         TxCmd(FCTYPE_ADDFRIENDREQ, g_nSessionId, 0, sReceivingUserID_or_Name, nMode);
  4227.     } else {
  4228.         TxCmd(FCTYPE_ADDFRIENDREQ, g_nSessionId, 0, 0, FCCHAN_JOIN, sReceivingUserID_or_Name);
  4229.     }
  4230. }
  4231. var g_nPmPrompt_UserId = 0;
  4232.  
  4233. function PmPrompt(hOptions) {
  4234.     hOptions = hOptions || {};
  4235.     g_oDhtmlPopup.open(" <form onSubmit=\"PmPromptSubmit(); return false;\"> Enter the username of the user you wish to message:<br><br> <input type=text name=pm_username_lookup id=pm_username_lookup onKeyUp=\"CheckPmUsernameQueue();\"> <input type=submit id=pm_username_lookup_submit value=\"Done\" disabled=true> <div id=username_recognized style=padding:5px;>&nbsp;</div> <div style='position:absolute;bottom:8px;right:10px;'> <a href='#' onClick=\"g_oDhtmlPopup.close();\">Close</a> </div> </form> ", 'no_close_on_mouseout');
  4236. }
  4237.  
  4238. function PmPromptSubmit() {
  4239.     if (!g_nPmPrompt_UserId) return false;
  4240.     if (!g_hoPMWindows[g_nPmPrompt_UserId]) {
  4241.         g_hoPMWindows[g_nPmPrompt_UserId] = {};
  4242.         g_hoPMWindows[g_nPmPrompt_UserId]['handle'] = window.open((g_hC['dhtml_path'] + (top.g_sClearCode ? 'pm.' + top.g_sClearCode + '.html' : 'pm.html') + "?remote_user_id=" + g_nPmPrompt_UserId + "&"), "_blank", "height=430,width=550,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=0");
  4243.     }
  4244.     ClickFriend(g_nPmPrompt_UserId);
  4245.     g_nPmPrompt_UserId = 0;
  4246.     g_oDhtmlPopup.close();
  4247.     return false;
  4248. }
  4249. var g_oPmPrompt_InputListener_Timer;
  4250.  
  4251. function PmPrompt_InputListener() {
  4252.     if (document.getElementById('pm_username_lookup')) {
  4253.         if (document.getElementById('pm_username_lookup').value.length > 5 && document.getElementById('pm_username_lookup').value != g_sCheckPmUsername) {
  4254.             clearTimeout(g_oPmPrompt_InputListener_Timer);
  4255.             CheckPmUsernameQueue(document.getElementById('pm_username_lookup').value);
  4256.         }
  4257.         if (!g_nPmPrompt_UserId) {
  4258.             g_oPmPrompt_InputListener_Timer = setTimeout("PmPrompt_InputListener()", 1000);
  4259.         }
  4260.     }
  4261. }
  4262.  
  4263. function ClosePMWindow(nRemoteUserID) {
  4264.     if (g_hoPMWindows[nRemoteUserID] && g_hoPMWindows[nRemoteUserID]['handle']) {
  4265.         g_hoPMWindows[nRemoteUserID]['handle'].Export().g_bCloseWindow = 1;
  4266.         g_hoPMWindows[nRemoteUserID]['handle'].Export().AssertTop();
  4267.     }
  4268.     delete g_hoPMWindows[nRemoteUserID];
  4269.     LoadPrivateMessageList();
  4270.     return;
  4271. }
  4272.  
  4273. function ClickFriend(nRemoteUserID, hOptions) {
  4274.     var hOptions = hOptions || {};
  4275.     if (!nRemoteUserID) {
  4276.         return;
  4277.     }
  4278.     if (!g_hoPMWindows[nRemoteUserID]) {
  4279.         g_hoPMWindows[nRemoteUserID] = {};
  4280.         g_hoPMWindows[nRemoteUserID]['handle'] = 0;
  4281.         g_hoPMWindows[nRemoteUserID]['blinker_phase'] = 0;
  4282.         g_hoPMWindows[nRemoteUserID]['offline_message_rx'] = 0;
  4283.     }
  4284.     if (!g_hoPMWindows[nRemoteUserID]['handle']) {
  4285.         if (g_hUsers[nRemoteUserID] && g_hUsers[nRemoteUserID]['state'] == t.FCVIDEO_UNKNOWN) {
  4286.             if (!g_hoPMWindows[nRemoteUserID]['offline_message_rx']) {
  4287.                 g_hoPMWindows[nRemoteUserID]['offline_message_rx']++;
  4288.                 ReceivePrivateMessage({
  4289.                     'msg': g_hUsers[nRemoteUserID]['username'] + " is offline. " + g_hUsers[nRemoteUserID]['username'] + " will receive your message the next time he/she logs in.",
  4290.                     'from': nRemoteUserID,
  4291.                     'msguid': 0
  4292.                 });
  4293.             }
  4294.         } else if (g_hUsers[nRemoteUserID] && g_hoPMWindows[nRemoteUserID] && (!g_hoPMWindows[nRemoteUserID]['message_buffer'] || !g_hoPMWindows[nRemoteUserID]['message_buffer'][nRemoteUserID])) {
  4295.             ReceivePrivateMessage({
  4296.                 'msg': g_hUsers[nRemoteUserID]['username'] + " is online.",
  4297.                 'from': nRemoteUserID,
  4298.                 'msguid': 0
  4299.             });
  4300.         }
  4301.     }
  4302.     if (!g_hoPMWindows[nRemoteUserID]['listing']) {
  4303.         LoadPrivateMessageList();
  4304.         if (g_hoPMWindows[nRemoteUserID]) g_hoPMWindows[nRemoteUserID]['listing'] = IdCache('private_message_list_' + nRemoteUserID);
  4305.     }
  4306.     if (g_hoPMWindows[nRemoteUserID] && g_hoPMWindows[nRemoteUserID]['handle'] && g_hoPMWindows[nRemoteUserID]['handle'].Export) {
  4307.         try {
  4308.             g_hoPMWindows[nRemoteUserID]['handle'].Export().focus();
  4309.         } catch (oError) {
  4310.             Log("Try Catch Failure #17: " + oError.description);
  4311.         }
  4312.     }
  4313.     return;
  4314. }
  4315.  
  4316. function FcPrivateMessage(nArg1, nArg2, sMessage, nUserId, nPmStamp, nFrom, nTo) {
  4317.     sMessage = sMessage.replace(/%\w\w/g, '');
  4318.     if (!nArg1) {
  4319.         nPmStamp = nArg2;
  4320.     }
  4321.     var hPmesg = ParseJSON(unescape(sMessage));
  4322.     if (hPmesg == null) return;
  4323.     if (!hPmesg['msg'] && nArg1 == w.FCRESPONSE_ERROR) {
  4324.         ReceivePrivateMessage({
  4325.             'msg': "This user is offline and will receive your message the next time he/she logs in.",
  4326.             'from': nArg2,
  4327.             'msguid': 0
  4328.         });
  4329.         return;
  4330.     } else if (g_bLoadChat > 0 && nUserId != g_hSelf['user_id'] && Rate() > .1) {
  4331.         LoadChat();
  4332.         return;
  4333.     } else if (nArg1 == w.FCRESPONSE_NOTICE) {
  4334.         var nWindow = nUserId;
  4335.         var nNotice = 1;
  4336.         if (hPmesg['msg'] && hPmesg['msg'].indexOf("(Auto Reply)") == 0 && nFrom == 0) {
  4337.             nNotice = 0;
  4338.             if (nUserId == g_hSelf['user_id']) {
  4339.                 nWindow = nUserId;
  4340.                 nUserId = nArg2;
  4341.             }
  4342.         }
  4343.         ReceivePrivateMessage({
  4344.             'type': 'pm',
  4345.             'msg': hPmesg['msg'],
  4346.             'from': nUserId,
  4347.             'window': nWindow,
  4348.             'pmstamp': nPmStamp,
  4349.             'notice': nNotice
  4350.         });
  4351.     } else if (nArg1 == w.FCCHAN_OLDMSG) {
  4352.         Log("FCCHAN_OLDMSG: " + nUserId);
  4353.         ReceivePrivateMessage({
  4354.             'type': 'pm',
  4355.             'msg': hPmesg['msg'],
  4356.             'from': nUserId,
  4357.             'offline': true,
  4358.             'offline_date': nArg2,
  4359.             'pmstamp': nArg2
  4360.         });
  4361.     } else {
  4362.         Log("Normal pmesg");
  4363.         ReceivePrivateMessage({
  4364.             'type': 'pm',
  4365.             'msg': hPmesg['msg'],
  4366.             'from': nUserId,
  4367.             'pmstamp': nPmStamp
  4368.         });
  4369.     }
  4370. }
  4371.  
  4372. function ReceivePrivateMessage(hChatParams) {
  4373.     var nUserId = hChatParams['from'];
  4374.     var sMessage = hChatParams['msg'] || '';
  4375.     var nMessagingUserID = hChatParams['msguid'];
  4376.     var nWindow = hChatParams['window'] || nUserId;
  4377.     if (nWindow != nUserId) nMessagingUserID = nWindow;
  4378.     nMessagingUserID = (nMessagingUserID == undefined) ? nUserId : nMessagingUserID;
  4379.     if (hChatParams['msguid'] == undefined) {
  4380.         hChatParams['msguid'] = nMessagingUserID;
  4381.     }
  4382.     if (!g_hoPMWindows[nUserId]) {
  4383.         g_hoPMWindows[nUserId] = {};
  4384.         g_hoPMWindows[nUserId]['blinker_phase'] = 0;
  4385.     }
  4386.     if (sMessage.indexOf('is online') == -1 && (g_hSelf['pm_sound_mode'] == 'rx' || g_hSelf['pm_sound_mode'] == 'txrx' || !g_hSelf['pm_sound_mode'] || (g_hSelf['pm_sound_mode'] == 'on_first' && g_hoPMWindows[nUserId] && !g_hoPMWindows[nUserId]['alerted']))) {
  4387.         Sound('down');
  4388.         if (g_hoPMWindows[nUserId]) g_hoPMWindows[nUserId]['alerted'] = true;
  4389.     }
  4390.     if (!g_hoPMWindows[nUserId]['message_buffer']) {
  4391.         g_hoPMWindows[nUserId]['message_buffer'] = {};
  4392.     }
  4393.     if (g_hoPMWindows[nUserId]['message_buffer'][nMessagingUserID] == undefined) {
  4394.         g_hoPMWindows[nUserId]['message_buffer'][nMessagingUserID] = new Array();
  4395.     }
  4396.     if (!g_hoPMWindows[nUserId]['listing']) {
  4397.         LoadPrivateMessageList();
  4398.         if (g_hoPMWindows[nUserId]) {
  4399.             g_hoPMWindows[nUserId]['listing'] = IdCache('private_message_list_' + nUserId);
  4400.         }
  4401.     }
  4402.     if (sMessage && g_hoPMWindows[nUserId]['blinker_phase'] < 1) {
  4403.         PrivateMessageBlinker(nUserId, 1);
  4404.     }
  4405.     if (sMessage) {
  4406.         g_hoPMWindows[nUserId]['message_buffer'][nMessagingUserID].push(hChatParams);
  4407.     }
  4408.     if (g_sToggleFriends == 'none') {
  4409.         g_bMenuRevealBlinker = 1;
  4410.         MenuRevealBlinker();
  4411.     }
  4412. }
  4413. var g_bMenuRevealBlinker = 0;
  4414. var g_oMenuRevealBlinker_Timer;
  4415.  
  4416. function MenuRevealBlinker() {
  4417.     if (g_bMenuRevealBlinker == 0) {
  4418.         IdCache('reveal_menu_img').src = 'http://img.myfreecams.com/mfc2/styles/mfc/images/misc/reveal_menu.5.gif';
  4419.         g_bMenuRevealBlinker = 0;
  4420.         clearTimeout(g_oMenuRevealBlinker_Timer);
  4421.     } else if (g_bMenuRevealBlinker % 2 == 0) {
  4422.         IdCache('reveal_menu_img').src = 'http://img.myfreecams.com/mfc2/styles/mfc/images/misc/reveal_menu_on.5.gif';
  4423.         g_bMenuRevealBlinker++;
  4424.         g_oMenuRevealBlinker_Timer = setTimeout(" MenuRevealBlinker(); ", 700);
  4425.     } else if (g_bMenuRevealBlinker % 2 == 1) {
  4426.         IdCache('reveal_menu_img').src = 'http://img.myfreecams.com/mfc2/styles/mfc/images/misc/reveal_menu.5.gif';
  4427.         g_bMenuRevealBlinker++;
  4428.         g_oMenuRevealBlinker_Timer = setTimeout(" MenuRevealBlinker(); ", 700);
  4429.     }
  4430. }
  4431. var g_oPMListenerTimeout = 0;
  4432.  
  4433. function PrivateMessageListener() {
  4434.     try {
  4435.         for (nUserId in g_hoPMWindows) {
  4436.             for (key_nUserId in g_hoPMWindows[nUserId]['message_buffer']) {
  4437.                 if (g_hoPMWindows[nUserId]['message_buffer'][key_nUserId]) {
  4438.                     try {
  4439.                         if (g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export) {
  4440.                             for (sK in g_hoPMWindows[nUserId]['message_buffer'][key_nUserId]) {
  4441.                                 g_hoPMWindows[nUserId]['handle'].Export().Receive(g_hoPMWindows[nUserId]['message_buffer'][key_nUserId][sK]);
  4442.                             }
  4443.                             g_hoPMWindows[nUserId]['message_buffer'][key_nUserId] = new Array();
  4444.                         }
  4445.                     } catch (oError) {
  4446.                         Log("PrivateMessageListener error: " + oError.description);
  4447.                     }
  4448.                 }
  4449.             }
  4450.         }
  4451.     } catch (oError) {
  4452.         Log("Try Catch Failure #18: " + oError.description);
  4453.     }
  4454.     if (g_oPMListenerTimeout) {
  4455.         clearTimeout(g_oPMListenerTimeout);
  4456.     }
  4457.     g_oPMListenerTimeout = setTimeout("PrivateMessageListener()", 500);
  4458. }
  4459. var g_oWindowCloseDetection_Timer;
  4460.  
  4461. function WindowCloseDetection() {
  4462.     var nPopupCount = 0;
  4463.     if (g_hSelf['access_level'] > 0 && !document.cookie.match(/passcode=[^;]+;/)) {
  4464.         top.location.reload();
  4465.         return;
  4466.     }
  4467.     for (nRemoteUserId in g_hoPMWindows) {
  4468.         nPopupCount++;
  4469.         var bDeadWindow = false;
  4470.         try {
  4471.             if (g_hoPMWindows[nRemoteUserId] && g_hoPMWindows[nRemoteUserId]['closed']) {
  4472.                 bDeadWindow = true;
  4473.             }
  4474.             if (g_hoPMWindows[nRemoteUserId] && g_hoPMWindows[nRemoteUserId]['handle'] && !g_hoPMWindows[nRemoteUserId]['handle'].Export) {
  4475.                 bDeadWindow = true;
  4476.             }
  4477.         } catch (oError) {
  4478.             bDeadWindow = true;
  4479.             Log("g_hoPMWindows WindowCloseDetection exception: " + oError.description);
  4480.         }
  4481.         if (bDeadWindow) {
  4482.             Log("WindowCloseDetection kill reference to g_hoPMWindows " + nRemoteUserId);
  4483.             try {
  4484.                 if (t.g_hoPMWindows[nRemoteUserId] && t.g_hUsers[nRemoteUserId] && t.g_hoPMWindows[nRemoteUserId]['pm_video'] == true) {
  4485.                     t.TxCmd(t.FCTYPE_PREVIEWCHAN, t.g_hSelf['sessionid'], 0, t.FCCHAN_PART, nRemoteUserId);
  4486.                     if (t.g_hoPMWindows[nRemoteUserId]['relation_state'] && t.g_hoPMWindows[nRemoteUserId]['relation_state'].match(/^voyeur|private|group_show$/) && (!t.g_hoPlayerWindows[nRemoteUserId] || !t.g_hoPlayerWindows[nRemoteUserId]['relation_state'] || !t.g_hoPlayerWindows[nRemoteUserId]['relation_state'].match(/^voyeur|private|group_show$/))) {
  4487.                         t.TxCmd(t.FCTYPE_ENDSESSION, g_nSessionId, 0, t.g_hUsers[nRemoteUserId]['sessionid'], 0, 0, null);
  4488.                     }
  4489.                 }
  4490.             } catch (oError) {
  4491.                 Log("PM Close window and video error: " + oError.description);
  4492.                 if (t.g_hUsers[nRemoteUserId]) {
  4493.                     t.TxCmd(t.FCTYPE_ENDSESSION, g_nSessionId, 0, t.g_hUsers[nRemoteUserId]['sessionid'], 0, 0, null);
  4494.                 }
  4495.             }
  4496.             delete g_hoPMWindows[nRemoteUserId];
  4497.             LoadPrivateMessageList();
  4498.         }
  4499.     }
  4500.     for (nBroadcasterId in g_hoPlayerWindows) {
  4501.         var bDeadWindow = false;
  4502.         try {
  4503.             if (!g_hoPlayerWindows[nBroadcasterId]['handle'].Export().g_bPlayerHTMLLoaded) {
  4504.                 bDeadWindow = true;
  4505.             }
  4506.             if (g_hoPlayerWindows[nBroadcasterId]['handle'].Export().g_nBroadcasterId && g_hoPlayerWindows[nBroadcasterId]['handle'].Export().g_nBroadcasterId != nBroadcasterId) {
  4507.                 bDeadWindow = true;
  4508.             }
  4509.         } catch (oError) {
  4510.             bDeadWindow = true;
  4511.             Log("g_hoPlayerWindows WindowCloseDetection exception: " + oError.description);
  4512.             if (t.g_hUsers[nBroadcasterId]) {
  4513.                 t.TxCmd(t.FCTYPE_ENDSESSION, g_nSessionId, 0, t.g_hUsers[nBroadcasterId]['sessionid'], 0, 0, null);
  4514.             }
  4515.         }
  4516.         if (bDeadWindow == true) {
  4517.             t.TxCmd(t.FCTYPE_JOINCHAN, g_nSessionId, 0, t.g_hoPlayerWindows[nBroadcasterId]['room_channel'], t.FCCHAN_PART);
  4518.             if (t.g_hoPlayerWindows[nBroadcasterId]) {
  4519.                 Log("WindowCloseDetection kill reference to g_hoPlayerWindows " + nBroadcasterId);
  4520.                 if (t.g_hoPlayerWindows[nBroadcasterId]['relation_state'] && t.g_hoPlayerWindows[nBroadcasterId]['relation_state'].match(/^voyeur|private|group_show$/)) {
  4521.                     if (t.g_hUsers[nBroadcasterId]) {
  4522.                         t.TxCmd(t.FCTYPE_ENDSESSION, g_nSessionId, 0, t.g_hUsers[nBroadcasterId]['sessionid'], 0, 0, null);
  4523.                     }
  4524.                 }
  4525.             }
  4526.             if (t.g_hoPMWindows[nBroadcasterId]) {
  4527.                 Log("WindowCloseDetection kill reference to g_hoPlayerWindows " + nBroadcasterId);
  4528.                 if (t.g_hoPlayerWindows[nBroadcasterId]['relation_state'] && t.g_hoPlayerWindows[nBroadcasterId]['relation_state'].match(/^voyeur|private|group_show$/) && (!t.g_hoPMWindows[nBroadcasterId] || !t.g_hoPMWindows[nBroadcasterId]['relation_state'] || !t.g_hoPMWindows[nBroadcasterId]['relation_state'].match(/^voyeur|private|group_show$/))) {
  4529.                     if (t.g_hUsers[nBroadcasterId]) {
  4530.                         t.TxCmd(t.FCTYPE_ENDSESSION, g_nSessionId, 0, t.g_hUsers[nBroadcasterId]['sessionid'], 0, 0, null);
  4531.                     }
  4532.                 }
  4533.             }
  4534.             delete g_hoPlayerWindows[nBroadcasterId];
  4535.         }
  4536.     }
  4537.     for (sK in g_hWindows) {
  4538.         nPopupCount++;
  4539.         if (g_hWindows[sK] && sK != '-1') {
  4540.             try {
  4541.                 if (!g_hWindows[sK] || g_hWindows[sK].closed) {
  4542.                     Log("lost window " + sK + " closed: " + g_hWindows[sK].closed);
  4543.                     g_hWindows[sK] = false;
  4544.                 }
  4545.             } catch (oError) {
  4546.                 Log("WindowCloseDetection error: " + oError.description);
  4547.             }
  4548.         }
  4549.     }
  4550.     clearTimeout(g_oWindowCloseDetection_Timer);
  4551.     g_oWindowCloseDetection_Timer = setTimeout("WindowCloseDetection()", nPopupCount > 1 ? 1000 : 5000);
  4552. }
  4553.  
  4554. function InitializePlayerWindowHash(nId) {
  4555.     g_hoPlayerWindows[nId] = {};
  4556. }
  4557.  
  4558. function LoadPrivateMessageList() {
  4559.     if (!IdCache('private_message_list') || !g_hSelf['access_level']) {
  4560.         return;
  4561.     }
  4562.     var sPrivateMessageListHtml = "";
  4563.     for (nUserId in g_hoPMWindows) {
  4564.         if (!g_hUsers[nUserId]) continue;
  4565.         var sWebCam = '1';
  4566.         if (IsBroadcastState(g_hUsers[nUserId]['state']) || g_hUsers[nUserId]['broadcasting_video']) {
  4567.             sWebCam = " <div style='position:absolute;left:98px;top:1px;'>" + A("pm_friend", {
  4568.                 user_id: g_hUsers[nUserId]['user_id'],
  4569.                 username: g_hUsers[nUserId]['username'],
  4570.                 load_video: 'true'
  4571.             }) + "<i" + "mg id=online_friends_arrow src=http://img.myfreecams.com/mfc2/images/icons/webcam_medium.gif style='vertical-align:middle;' ></a> </div> ";
  4572.         }
  4573.         var sStyle;
  4574.         if (g_hUsers[nUserId]['state'] == t.FCVIDEO_UNKNOWN) {
  4575.             if (g_bIE) sStyle = "filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);";
  4576.             else sStyle = "-moz-opacity:0.5";
  4577.         }
  4578.         sPrivateMessageListHtml += "\n <div class='private_alert' id=private_message_list_" + nUserId + "\n style='position:relative;height:22px;overflow:hidden;border:0px dashed red;width:153px;'\n >\n <div style='position:absolute;left:117px;top:4px;width:40px;'> <a href=# onClick=\"PopUserMenu(" + nUserId + "); return false;\"><i" + "mg style=\"" + sStyle + "\" src=" + PeopleIcon(nUserId) + " style='vertical-align:bottom;margin:0px;'></a>(" + A("close_pm_window", {
  4579.             user_id: g_hUsers[nUserId]['user_id']
  4580.         }) + "<b>x</b></a>) </div> " + A('pm_friend', {
  4581.             user_id: nUserId
  4582.         }) + " <div style='top:0px;left:0px;cursor:pointer;border:0px dashed red;width:115px;cursor:pointer;'\n id=private_message_blinker_" + nUserId + "\n class=private_alert_off> " + A('pm_friend', {
  4583.             user_id: nUserId
  4584.         }) + "<span " + PopupBioHandlerCode(nUserId) + ">" + g_hUsers[nUserId]['username'] + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "</span>" + "</a>" + "\n </div>\n " + " " + sWebCam + " </div> ";
  4585.     }
  4586.     if (sPrivateMessageListHtml) {
  4587.         sPrivateMessageListHtml += "<div style='font-size:8px;'>&nbsp;</div>";
  4588.     }
  4589.     if (sPrivateMessageListHtml) {
  4590.         SetHTML('private_message_list', sPrivateMessageListHtml);
  4591.         IdCache('private_message_list').style.display = "block";
  4592.     } else {
  4593.         IdCache('private_message_list').style.display = "none";
  4594.     }
  4595. }
  4596.  
  4597. function ToggleHeader(hOptions) {
  4598.     if (!hOptions['render_only']) {
  4599.         g_sToggleHeader = (g_sToggleHeader == "block") ? "none" : "block";
  4600.         SetCookie('display_header', g_sToggleHeader, 'Thu, 21-Jan-2021 00:00:01 GMT', g_hC['site_path']);
  4601.     }
  4602.     if (IdCache('header') && IdCache('header_wrapper')) {
  4603.         if (g_sToggleHeader == 'none') {
  4604.             if (!g_bIE) {
  4605.                 IdCache('header').style.top = "-81px";
  4606.                 IdCache('header_wrapper').style.height = "24px";
  4607.                 IdCache('menu_td').style.height = "24px";
  4608.                 IdCache('reveal_header').style.display = "block";
  4609.             } else {
  4610.                 SlideHeader('shrink');
  4611.             }
  4612.         } else {
  4613.             if (!g_bIE) {
  4614.                 IdCache('header').style.top = "0px";
  4615.                 IdCache('header_wrapper').style.height = "105px";
  4616.                 IdCache('menu_td').style.height = "105px";
  4617.                 IdCache('reveal_header').style.display = "none";
  4618.             } else {
  4619.                 SlideHeader('grow');
  4620.             }
  4621.         }
  4622.     }
  4623.     UntoggleMenuItem();
  4624.     if (window.frames['main'] && window.frames['main'].SizeChatArea && window.frames['main'].RefreshMessageBar) {
  4625.         window.frames['main'].SizeChatArea();
  4626.         window.frames['main'].RefreshMessageBar();
  4627.     }
  4628. }
  4629. g_bHeaderLock = false;
  4630. g_nHeaderWrapper = 105;
  4631. g_nHeader = 0;
  4632.  
  4633. function SlideHeader(sMode, bLoopCall) {
  4634.     if (g_bHeaderLock && !bLoopCall) return;
  4635.     g_bHeaderLock = true;
  4636.     if (sMode == 'shrink') {
  4637.         if (g_nHeaderWrapper <= 24 || g_nHeader <= -80) {
  4638.             g_bHeaderLock = false;
  4639.             IdCache('header').style.top = "-81px";
  4640.             IdCache('header_wrapper').style.height = "24px";
  4641.             IdCache('reveal_header').style.display = "block";
  4642.             return;
  4643.         } else {
  4644.             g_nHeaderWrapper = g_nHeaderWrapper - 10;
  4645.             g_nHeader = g_nHeader - 10;
  4646.         }
  4647.     } else if (sMode == 'grow') {
  4648.         if (g_nHeaderWrapper >= 105 || g_nHeader >= 0) {
  4649.             g_bHeaderLock = false;
  4650.             IdCache('header').style.top = "0px";
  4651.             IdCache('header_wrapper').style.height = "105px";
  4652.             IdCache('reveal_header').style.display = "none";
  4653.             return;
  4654.         } else {
  4655.             g_nHeaderWrapper = g_nHeaderWrapper + 10;
  4656.             g_nHeader = g_nHeader + 10;
  4657.         }
  4658.     }
  4659.     IdCache('header').style.top = g_nHeader + "px";
  4660.     IdCache('header_wrapper').style.height = g_nHeaderWrapper + "px";
  4661.     setTimeout(" SlideHeader('" + sMode + "',1); ", 10);
  4662. }
  4663.  
  4664. function UntoggleMenuItem() {
  4665.     return;
  4666.     if (!IdCache('btn_toggle_menu')) {
  4667.         return;
  4668.     }
  4669.     var sLabel = '';
  4670.     if (g_sToggleHeader != "block") {
  4671.         sLabel += A('toggle_header') + "<span style=''>Top</span>" + "</a>";
  4672.     }
  4673.     if (g_sToggleFriends != "block") {
  4674.         if (sLabel) sLabel += ", ";
  4675.         sLabel += A('toggle_menu') + "<span style=''>Friends</span>" + "</a>";
  4676.     }
  4677.     if (sLabel) {
  4678.         SetHTML('btn_toggle_menu', "Show " + sLabel);
  4679.         IdCache('btn_toggle_menu').style.display = 'block';
  4680.     } else {
  4681.         IdCache('btn_toggle_menu').style.display = 'none';
  4682.     }
  4683. }
  4684.  
  4685. function PrivateMessageBlinker(nPrivateUserId, nSetPhase) {
  4686.     if (!g_hoPMWindows[nPrivateUserId]) {
  4687.         return;
  4688.     }
  4689.     if (nSetPhase == 1 && g_hoPMWindows[nPrivateUserId]['blinker_phase'] == 3) {
  4690.         return;
  4691.     } else if (nSetPhase == 1) {
  4692.         g_hoPMWindows[nPrivateUserId]['blinker_phase'] = 2;
  4693.     } else if (nSetPhase) {
  4694.         g_hoPMWindows[nPrivateUserId]['blinker_phase'] = nSetPhase;
  4695.     }
  4696.     if (g_hoPMWindows[nPrivateUserId]['blinker_phase'] == -1) {
  4697.         g_hoPMWindows[nPrivateUserId]['blinker_phase'] = 0;
  4698.         try {
  4699.             IdCache('private_message_blinker_' + nPrivateUserId).className = "private_alert_off";
  4700.         } catch (oError) {
  4701.             Log("PM Blinker error: " + oError.description);
  4702.         }
  4703.         return;
  4704.     } else if (g_hoPMWindows[nPrivateUserId]['blinker_phase'] == 2) {
  4705.         g_hoPMWindows[nPrivateUserId]['blinker_phase'] = 3;
  4706.         try {
  4707.             IdCache('private_message_blinker_' + nPrivateUserId).className = 'private_alert_on';
  4708.         } catch (oError) {
  4709.             Log("PM Blinker error #2: " + oError.description);
  4710.         }
  4711.     } else if (g_hoPMWindows[nPrivateUserId]['blinker_phase'] == 3) {
  4712.         g_hoPMWindows[nPrivateUserId]['blinker_phase'] = 2;
  4713.         try {
  4714.             IdCache('private_message_blinker_' + nPrivateUserId).className = 'private_alert_off';
  4715.         } catch (oError) {
  4716.             Log("PrivateMessageBlinker error: " + oError.description);
  4717.         }
  4718.     }
  4719.     setTimeout("PrivateMessageBlinker(" + nPrivateUserId + ")", nPrivateMessageBlinkInterval);
  4720. }
  4721.  
  4722. function NewsFeed_InChatHTML(sType, sMsg, nUserId, sUsername) {
  4723.     var sHtml;
  4724.     if (nUserId == 481462) {
  4725.         sUsername = sUsername.replace(/_/, ' ');
  4726.         sHtml = " <div style=\"margin:25px 6px 25px 0px;padding:0px;background-color:#FFFFFF;border:6px double #aaaaaa;font-size:15px;font-weight:bold;\"> <div style=\"background-color:#FFFF22;color:#000000;font-size:11px;padding:4px;font-weight:normal;\"><b> ";
  4727.     } else {
  4728.         sHtml = " <div style=\"margin:10px 6px 10px 0px;padding:0px;background-color:#FFFFFF;border:2px solid #E5AAAA;\"> <div style=\"background-color:#EEEEEE;color:#000000;font-size:11px;padding:4px;\"><b> ";
  4729.     }
  4730.     sHtml += A('news_feed');
  4731.     sHtml += "News Feed</a></b> message from <b>";
  4732.     if (g_hUsers[nUserId] && g_hUsers[nUserId]['access_level'] == 4) {
  4733.         sHtml += A('player', {
  4734.             broadcaster_id: nUserId,
  4735.             target: 'main'
  4736.         });
  4737.     } else if (g_hUsers[nUserId] && g_hUsers[nUserId]['access_level']) {
  4738.         sHtml += A("pm_friend", {
  4739.             user_id: nUserId,
  4740.             username: sUsername
  4741.         });
  4742.     }
  4743.     sHtml += sUsername + "</a></b>";
  4744.     if (nUserId != 481462) {
  4745.         sHtml += " - " + A('news_feed', {
  4746.             mode: 'hidden',
  4747.             manual_username: sUsername,
  4748.             popup_menu: 1
  4749.         }) + "<span style='color:#999999;text-decoration:none;'>Ignore</span></a>";
  4750.     }
  4751.     sHtml += "</div> <div style=\"padding:6px 9px;color:#000000;font-size:13px;\">" + sMsg + "</div> </div> ";
  4752.     return sHtml;
  4753. }
  4754.  
  4755. function FormatChat(sMsg, nUserId, hOptions) {
  4756.     hOptions = hOptions || {};
  4757.     var fEmote = false;
  4758.     if (!sMsg) return '';
  4759.     if (sMsg.substr(0, 9) == '{*emote*}') {
  4760.         fEmote = true;
  4761.         sMsg = sMsg.substr(10, 1024);
  4762.     }
  4763.     if (nUserId != 0) {
  4764.         sMsg = sMsg.replace(/</g, '&lt;');
  4765.         sMsg = sMsg.replace(/`/g, ' ');
  4766.     }
  4767.     var sSep = ":";
  4768.     var hUserDetails = {
  4769.         access_level: 0
  4770.     };
  4771.     if (nUserId == g_hSelf['user_id']) {
  4772.         hUserDetails = g_hSelf;
  4773.         for (sK in g_hSelf) {
  4774.             hUserDetails[sK] = g_hSelf[sK];
  4775.         }
  4776.     } else {
  4777.         for (sK in g_hUsers[nUserId]) {
  4778.             hUserDetails[sK] = g_hUsers[nUserId][sK];
  4779.         }
  4780.     }
  4781.     if (sMsg.match(/(http:[^ ]*)/)) {
  4782.         var sUrl = RegExp.$1;
  4783.         sUrl.match(/http:\/\/([^\/]+)/);
  4784.         var sDomain = RegExp.$1;
  4785.         var sConfirm = '';
  4786.         if (sDomain != 'www.youtube.com' && sDomain != 'www.myfreecams.com' && sDomain != 'profiles.myfreecams.com' && sDomain != 'www.myfreecamswiki.com') {
  4787.             sConfirm = " onClick=\" if( ! confirm('Warning: you are accessing a site not affiliated with MyFreeCams.com. Beware of scams and exercise caution if asked to provide personal information such as your password or email address.')) { return false; }\" ";
  4788.         }
  4789.         if (hUserDetails['access_level'] >= 2) {
  4790.             sMsg = sMsg.replace(/http:[^ ]*/, "<a target=_blank href=\"" + sUrl.replace(/"/, '') + "\" " + sConfirm + "><span style=\"font-weight:bold;font-size:10px;\">" + sUrl + "</span></a>");
  4791.         } else {
  4792.             sMsg = sMsg.replace(/http:[^ ]*/, "");
  4793.         }
  4794.     }
  4795.     sMsg = ParseEmoteOutput.prototype.Parse(sMsg, {
  4796.         access_level: hUserDetails['access_level'],
  4797.         onclick_code: "t.EnlargeImage(document,'%IMAGE%','%IMAGE%','%IMAGE%')"
  4798.     });
  4799.     var sMode = '';
  4800.     if (hOptions['mode']) {
  4801.         sMode = hOptions['mode'] + "_";
  4802.     }
  4803.     var sSelf_Or_Other = '';
  4804.     if (hOptions['user']) {
  4805.         sSelf_Or_Other = hOptions['user'];
  4806.     } else if (nUserId && g_hUsers[nUserId] && IsBroadcastState(g_hUsers[nUserId]['state'])) {
  4807.         sSelf_Or_Other = 'model';
  4808.     } else if (nUserId == g_hSelf['user_id']) {
  4809.         sSelf_Or_Other = 'self';
  4810.     } else {
  4811.         sSelf_Or_Other = 'other';
  4812.     }
  4813.     var sExtraClass_Name = '';
  4814.     var sExtraClass_Chat = '';
  4815.     if (hOptions['extra_class']) {
  4816.         sExtraClass_Name = hOptions['extra_class'] + '_name ';
  4817.         sExtraClass_Chat = hOptions['extra_class'] + '_chat ';
  4818.     }
  4819.     var sType = "";
  4820.     if (hUserDetails['access_level'] == '5') sType = "admin";
  4821.     else if (hUserDetails['access_level'] == '4') sType = "model";
  4822.     else if (hUserDetails['access_level'] == '2') sType = "premium";
  4823.     else if (hUserDetails['access_level'] == '1') sType = "registered";
  4824.     else if (hUserDetails['access_level'] == '-1') sType = "system";
  4825.     else if (hUserDetails['user_id'] == 0) sType = "system";
  4826.     else sType = "guest";
  4827.     var sOfflineMsg = '';
  4828.     var sH = '';
  4829.     var sDate = '';
  4830.     if (hOptions['date']) {
  4831.         sDate = "<span style=\"width:70px;white-space:nowrap;padding:0px 10px 0px 20px;font-size:10px;color:#33aa33;";
  4832.         if (!g_bIE) sDate += "padding-left:0px;";
  4833.         sDate += "\">" + hOptions['date'] + "</span>";
  4834.     }
  4835.     if (hOptions && hOptions['mode'] && hOptions['mode'] == 'private') {
  4836.         sExtraClass_Name += " pmname ";
  4837.         sExtraClass_Chat += " pmchat ";
  4838.     } else if (hOptions['offline']) {
  4839.         var then = new Date(hOptions['offline_date'] * 1000);
  4840.         var hours = then.getHours();
  4841.         var min = then.getMinutes();
  4842.         if (hours < 10) hours = "0" + hours;
  4843.         if (min < 10) min = "0" + min;
  4844.         sOfflineMsg = " <font style='font-size:10px;'>[" + (then.getMonth() + 1) + "-" + then.getDate() + " " + hours + ":" + min + "]</font> ";
  4845.         sH = "<i>";
  4846.     }
  4847.     var sExtraStyle = '';
  4848.     if (!g_hSelf['chat_text_ignore']) {
  4849.         sExtraStyle = MfcCustomFonts.prototype.get_style(g_hUsers[nUserId]);
  4850.     }
  4851.     var ATag = '';
  4852.     if (hOptions['mode'] != 'private') {
  4853.         if (g_hSelf['access_level'] > 0 && g_hUsers[nUserId] && g_hUsers[nUserId]['access_level'] > 0) {
  4854.             ATag = "<a href=# style='text-decoration:none;' onClick=\"PopUserMenu('" + nUserId + "');\">";
  4855.         } else if (g_hSelf['access_level'] == 0) {
  4856.             ATag = A("members_feature", {
  4857.                 supress_decoration: true
  4858.             });
  4859.         }
  4860.     }
  4861.     var sExtraMouseCode = PopupBioHandlerCode(nUserId);
  4862.     if (hUserDetails['access_level'] > 0 && hOptions['mode'] != 'private') sExtraMouseCode += "onMouseover=\"this.style.textDecoration = 'underline';\" onMouseout=\"this.style.textDecoration = 'none';\" ";
  4863.     if (sType == 'system') {
  4864.         if (sMsg.indexOf('has tipped') > -1) {
  4865.             sExtraStyle += "background-color:#FFFF00;";
  4866.         }
  4867.         sMsg.replace(/Registered/, t.A('register') + "Registered</a>");
  4868.     }
  4869.     if (hOptions['welcome']) {
  4870.         sH += " <div style=\" " + MfcCustomFonts.prototype.get_style(g_hUsers[hOptions['room_owner_id']]) + " padding: 5px 5px 5px 0px; font-size:17px; \"> Topic: " + sMsg + " </div> <br> ";
  4871.     } else if (hOptions['notice'] == 1) {
  4872.         sH += "<div style='text-decoration:none;font-size:13px;font-weight:bold;color:#FF0000;'>* " + sMsg + "</div>";
  4873.     } else if (fEmote) {
  4874.         sH += ATag + "<span style='text-decoration:none;' class='\n ' " + sExtraMouseCode + " style='text-decoration:none;'><i>* " + hUserDetails['username'] + sOfflineMsg + "</span></a> " + sMsg + "</span><br>";
  4875.     } else {
  4876.         var sName = '';
  4877.         if (nUserId > 0) {
  4878.             sName = ATag + "<span class='\n " + sMode + "name_" + sType + "\n " + sMode + "name_" + sSelf_Or_Other + "\n " + sExtraClass_Name + "\n ' " + sExtraMouseCode + " style='text-decoration:none;" + sExtraStyle + "'>" + hUserDetails['username'] + sOfflineMsg + sSep + "</span></a> ";
  4879.         }
  4880.         sH += "<div style='text-indent:-20px;padding-left:20px;padding-bottom:8px;'>" + sName + sDate + "<span class='\n " + sMode + "chat \n " + sMode + "chat_" + sType + "\n " + sMode + "chat_" + sSelf_Or_Other + "\n " + sExtraClass_Chat + "\n ' style='" + sExtraStyle + "'>" + sMsg + "</span></div>";
  4881.     }
  4882.     if (hOptions['offline'] || hOptions['oldmsg']) sH += "</i>";
  4883.     sH += "<end>";
  4884.     return sH;
  4885. }
  4886. var g_hInvertedEmoticonMap = {};
  4887. for (sK in ParseEmoteInput.prototype.m_hEmoticonMap) {
  4888.     g_hInvertedEmoticonMap[ParseEmoteInput.prototype.m_hEmoticonMap[sK]] = sK;
  4889. }
  4890. var g_aGuestEmoticons = new Array(1, 569, 364, 289, 2, 34, 115, 270, 330, 278, 325, 367, 448, 369, 518, 152, 301, 122, 123, 587, 179, 314, 200, 27, 326, 203, 200, 292, 164, 132, 12, 13, 343, 465, 259, 524, 139, 3, 26, 417, 173, 175, 177, 178, 372, 176);
  4891. var g_hGuestEmoticons = {};
  4892. for (var i = 0; i < g_aGuestEmoticons.length; i++) g_hGuestEmoticons[g_aGuestEmoticons[i]] = 1;
  4893. var g_aPrimaryEmoticons = new Array(1, 363, 343, 569, 364, 289, 551, 34, 115, 452, 270, 330, 463, 116, 278, 325, 367, 448, 369, 518, 152, 74, 301, 122, 123, 587, 563, 43, 155, 179, 314, 504, 200, 27, 406, 326, 203, 200, 292, 348, 164, 132, 12, 13, 343, 465, 259, 524, 535, 444, 47, 566, 139, 140, 3, 26, 417, 173, 175, 177, 178, 372, 176, 107, 71, 386, 573, 397, 210, 174, 231, 33, 430, 211, 119, 398, 449, 427, 163, 161, 214, 196, 284, 216, 129, 35, 470, 510, 551, 531, 29, 321, 10, 19, 265, 153, 193, 320, 11, 28, 118, 221, 522, 383, 401, 146, 21, 22, 253, 255, 198, 127, 81, 70, 39, 97, 62, 513, 63, 281, 65, 156, 66, 327, 60, 394, 208, 52, 61, 53);
  4894. var g_hPrimaryEmoticons = {};
  4895. for (var i = 0; i < g_aPrimaryEmoticons.length; i++) g_hPrimaryEmoticons[g_aPrimaryEmoticons[i]] = 1;
  4896. var g_hEmoticonHTMLCache = {};
  4897.  
  4898. function LoadEmoticons(oCallingDocument, sInputObjectID) {
  4899.     if (!g_hEmoticonHTMLCache[sInputObjectID]) {
  4900.         g_hEmoticonHTMLCache[sInputObjectID] = '';
  4901.         aHtml = new Array();
  4902.         aHtml.push(g.container("top,popup_container") + "<div style='padding:0px 0px 0px 0px;'>" + g_hEmoticonHTMLCache[sInputObjectID]);
  4903.         var hLoadedTrue = {};
  4904.         for (nK = 0; nK < g_aPrimaryEmoticons.length; nK++) {
  4905.             var sK = g_hInvertedEmoticonMap[g_aPrimaryEmoticons[nK]];
  4906.             if (hLoadedTrue[ParseEmoteInput.prototype.m_hEmoticonMap[sK]]) continue;
  4907.             else hLoadedTrue[ParseEmoteInput.prototype.m_hEmoticonMap[sK]] = true;
  4908.             if (!g_hPrimaryEmoticons[ParseEmoteInput.prototype.m_hEmoticonMap[sK]] || (g_hSelf['access_level'] < 1 && !g_hGuestEmoticons[ParseEmoteInput.prototype.m_hEmoticonMap[sK]])) continue;
  4909.             aHtml.push(" <div style=\"height:28px;padding:0px;margin:0px;vertical-align:center;float:left;overflow-y:hidden;\"> <i" + "mg style='cursor:pointer;' onClick=\"t.InsertEmoticon('" + sK + "',document,'" + sInputObjectID + "')\" src=http://img.myfreecams.com/mfc2/images/emoticons/" + ParseEmoteInput.prototype.m_hEmoticonMap[sK] + ".gif border=0 title='" + sK + "' > </div>");
  4910.         }
  4911.         if (!t.g_hSelf['access_level']) {
  4912.             aHtml.push(" <div style=\"float:clear;width:100%;height:25px;vertical-align:bottom;text-align:right;\"> &nbsp; &nbsp;" + A('register') + "Click here</a> to become a member free and access 500 more emoticons! &nbsp;&nbsp; &nbsp;<a href=\"javascript:t.InsertEmoticon('',document,'" + sInputObjectID + "')\"><b>Close</b></a>&nbsp;&nbsp;</div>");
  4913.         } else {
  4914.             aHtml.push(" <div style=\"width:100%;height:20px;vertical-align:bottom;text-align:right;\">" + (t.g_hSelf['access_level'] >= 1 ? "<a href=\"#\" onClick=\" t.g_sMoreEmoticons_oCallingDocument = document; t.g_oWinMoreEmoticons = window.open('/emoticons/','more_emoticons'); \">More</a>&nbsp;" : (" " + A('members_feature') + "<span onClick=\"t.InsertEmoticon('',document,'" + sInputObjectID + "');\">More</span></a>")) + (g_hSelf['access_level'] >= 2 ? (A('user_chat_images', {
  4915.                 category: 29
  4916.             }) + "Custom</a>") : (" " + A('members_feature') + "Custom</span></a>")) + "&nbsp;<a href=\"javascript:t.InsertEmoticon('',document,'" + sInputObjectID + "')\">Cancel</a></div>");
  4917.         }
  4918.         aHtml.push("</div>" + "</div>" + g.container("bottom,popup_container"));
  4919.         g_hEmoticonHTMLCache[sInputObjectID] = aHtml.join(' ');
  4920.     }
  4921.     return g_hEmoticonHTMLCache[sInputObjectID];
  4922. }
  4923. var Rate = Math.random;
  4924. var g_hMoreEmoticonsHTMLCache = {};
  4925. var g_oWinMoreEmoticons = '';
  4926. var g_sMoreEmoticons_oCallingDocument = '';
  4927.  
  4928. function MoreEmoticons(oCallingDocument, sInputObjectID) {
  4929.     IdCache(oCallingDocument, "emoticon_field").style.display = 'none';
  4930.     g_sMoreEmoticons_oCallingDocument = oCallingDocument;
  4931.     if (!g_hMoreEmoticonsHTMLCache[sInputObjectID]) {
  4932.         g_hMoreEmoticonsHTMLCache[sInputObjectID] = '';
  4933.         aHtml = new Array();
  4934.         aHtml.push("<ht" + "ml>" + g_sStyleHTML + "<title>More Emoticons</title>\n <style> <scr" + "ipt>\n if(opener && opener.t) document.write(' .more_emoticon { cursor:pointer; } ');\n .thumb_float { float:left;width:150px;height:30px; } </scr" + "ipt>\n </style> <body class=outer_body>\n" + g.container("top") + "<div style=padding:5px;><b>Please be patient, this page has over 500 images and is almost 3 megabytes in size. It takes a bit of time to load!</b> Next time you load it should be cached and load up quickly.<br><br>Hold your mouse over any emoticon below to see what text is associated with it. Click on any emoticon to automatically insert it into the chat.</div>" + "<div style='margin:8px;padding:2px'>");
  4935.         var hLoadedTrue = {};
  4936.         for (sK in ParseEmoteInput.prototype.m_hEmoticonMap) {
  4937.             if (hLoadedTrue[ParseEmoteInput.prototype.m_hEmoticonMap[sK]]) continue;
  4938.             else hLoadedTrue[ParseEmoteInput.prototype.m_hEmoticonMap[sK]] = true;
  4939.             aHtml.push("\n <div class=thumb_float>x\n <i" + "mg src=http://img.myfreecams.com/mfc2/images/emoticons/" + ParseEmoteInput.prototype.m_hEmoticonMap[sK] + ".gif border=0\n class=more_emoticon\n onClick=\" function Emoticon_onClick('" + sK + "'); \"\n >\n " + sK + "\n </div>\n ");
  4940.         }
  4941.         aHtml.push("\n </div>\n" + g.container("bottom") + "<scr" + "ipt> function Emoticon_onClick( sEmote ) { try {\n if(opener && opener.t && opener.t.InsertEmoticon )\n {\n opener.t.InsertEmoticon(sEmote);\n window.close();\n }\n } catch(oError){}\n } </scr" + "ipt> <scr" + "ipt> setTimeout('window.focus()',500);</scr" + "ipt></body></ht" + "ml>");
  4942.         g_hMoreEmoticonsHTMLCache[sInputObjectID] = aHtml.join(' ');
  4943.     }
  4944.     g_oWinMoreEmoticons.document.write(g_hMoreEmoticonsHTMLCache[sInputObjectID]);
  4945.     g_oWinMoreEmoticons.document.close();
  4946. }
  4947.  
  4948. function ViewEmoticons(oCallingDocument, sInputObjectID) {
  4949.     IdCache(oCallingDocument, "emoticon_field").style.display = 'block';
  4950.     SetHTML(oCallingDocument, "emoticon_field", LoadEmoticons('', sInputObjectID));
  4951. }
  4952.  
  4953. function InsertEmoticon(sEmoticon, oCallingDocument, sInputObjectID) {
  4954.     if (sEmoticon.indexOf(':') == -1) {
  4955.         sEmoticon = ':' + sEmoticon;
  4956.     }
  4957.     sInputObjectID = sInputObjectID || 'message_input';
  4958.     oCallingDocument = oCallingDocument || g_sMoreEmoticons_oCallingDocument;
  4959.     SetHTML(oCallingDocument, "emoticon_field");
  4960.     var oInputObject = oCallingDocument.getElementById(sInputObjectID);
  4961.     if (oInputObject) {
  4962.         if (oInputObject.value == undefined) {
  4963.             try {
  4964.                 oInputObject.AddText(sEmoticon);
  4965.             } catch (oError) {}
  4966.         } else {
  4967.             oInputObject.value += sEmoticon;
  4968.             oInputObject.focus();
  4969.             oInputObject.value = oInputObject.value;
  4970.         }
  4971.     } else {
  4972.         Log("InsertEmoticons found no oInputObject");
  4973.     }
  4974. }
  4975. var LoadVideo = setTimeout;
  4976.  
  4977. function FcDetails() {
  4978.     for (nRemoteUserId in g_hoPMWindows) {
  4979.         if (g_hoPMWindows[nRemoteUserId] && g_hoPMWindows[nRemoteUserId]['handle'] && g_hoPMWindows[nRemoteUserId]['handle'].Export) {
  4980.             try {
  4981.                 g_hoPMWindows[nRemoteUserId]['handle'].Export().FcDetails();
  4982.             } catch (oError) {
  4983.                 Log("Try Catch Failure #19: " + oError.description);
  4984.             }
  4985.         }
  4986.     }
  4987.     for (nRemoteUserId in g_hoPlayerWindows) {
  4988.         if (g_hoPlayerWindows[nRemoteUserId] && g_hoPlayerWindows[nRemoteUserId]['handle'] && g_hoPlayerWindows[nRemoteUserId]['handle'].Export) {
  4989.             try {
  4990.                 g_hoPlayerWindows[nRemoteUserId]['handle'].Export().FcDetails();
  4991.             } catch (oError) {
  4992.                 Log("Try Catch Failure #20: " + oError.description);
  4993.             }
  4994.         }
  4995.     }
  4996. }
  4997.  
  4998. function LoadChat() {
  4999.     if (g_bLoadChat == 1) {
  5000.         for (var a = 0; a < 2; a++) {
  5001.             LoadVideo("LoadChat()", 20000 * Rate());
  5002.         }
  5003.         if (!g_bLoadChat) g_bLoadChat = 1;
  5004.         Log("LoadChat()");
  5005.     }
  5006. }
  5007.  
  5008. function StartVoyeur(nModelId, nPrvSessId) {
  5009.     for (nWindowId in g_hoPlayerWindows) {
  5010.         if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export && g_hLoungeIds[g_hoPlayerWindows[nWindowId]['handle'].Export().g_nBroadcasterId]) {
  5011.             try {
  5012.                 if (g_hoPlayerWindows[nWindowId]['handle'].Export().g_nLoungeModel == nModelId) {
  5013.                     g_hoPlayerWindows[nWindowId]['handle'].Export().FcStartVoyeur(nPrvSessId);
  5014.                 }
  5015.             } catch (oError) {
  5016.                 Log("Try Catch Failure #21: " + oError.description);
  5017.             }
  5018.         }
  5019.     }
  5020.     if (g_hoPMWindows[nModelId] && g_hoPMWindows[nModelId]['handle']) {
  5021.         try {
  5022.             g_hoPMWindows[nModelId]['handle'].Export().FcStartVoyeur(nPrvSessId);
  5023.         } catch (oError) {
  5024.             Log("Try Catch Failure #22: " + oError.description);
  5025.         }
  5026.     }
  5027.     if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle']) {
  5028.         try {
  5029.             g_hoPlayerWindows[nModelId]['handle'].Export().FcStartVoyeur(nPrvSessId);
  5030.         } catch (oError) {
  5031.             Log("Try Catch Failure #23: " + oError.description);
  5032.         }
  5033.     }
  5034. }
  5035.  
  5036. function FcSessionState(nFrom, nState, nUserId) {
  5037.     if (!g_hUsers[nUserId]) {
  5038.         return;
  5039.     }
  5040.     if (g_hUsers[nUserId]['state'] == w.FCVIDEO_TX_AWAY && g_hUsers[nUserId]['truepvt']) {
  5041.         g_hUsers[nUserId]['truepvt'] = 0;
  5042.     }
  5043.     if (g_hUsers[nUserId]['friend']) {
  5044.         if (g_hUsers[nUserId]['state'] == FCVIDEO_TX_GRP) {
  5045.             Notification(t.A('player', {
  5046.                 broadcaster_id: nUserId,
  5047.                 style: 'font-weight:bold;',
  5048.                 target: 'main'
  5049.             }) + g_hUsers[nUserId]['username'] + "</a> is in a Group Show.");
  5050.             if (g_hSelf['sound_model_friend_private'] == 1) {
  5051.                 Sound('sound_model_friend_private');
  5052.             }
  5053.         } else if (g_hUsers[nUserId]['state'] == FCVIDEO_TX_PVT) {
  5054.             Notification(t.A('player', {
  5055.                 broadcaster_id: nUserId,
  5056.                 style: 'font-weight:bold;',
  5057.                 target: 'main'
  5058.             }) + g_hUsers[nUserId]['username'] + "</a> is in a private session.");
  5059.             if (g_hSelf['sound_model_friend_private'] == 1) {
  5060.                 Sound('sound_model_friend_private');
  5061.             }
  5062.         } else if (g_hUsers[nUserId]['state'] == 0 && g_hUsers[nUserId]['previous_state'] == 2) {
  5063.             Notification(t.A('player', {
  5064.                 broadcaster_id: nUserId,
  5065.                 style: 'font-weight:bold;',
  5066.                 target: 'main'
  5067.             }) + g_hUsers[nUserId]['username'] + "</a> has returned.");
  5068.         }
  5069.     }
  5070.     if (g_hoPMWindows[nUserId] && g_hoPMWindows[nUserId]['handle'] && g_hoPMWindows[nUserId]['handle'].Export && g_hoPMWindows[nUserId]['handle'].Export().RefreshSessionState) {
  5071.         try {
  5072.             g_hoPMWindows[nUserId]['handle'].Export().RefreshSessionState();
  5073.         } catch (oError) {
  5074.             Log("Try Catch Failure #25: " + oError.description);
  5075.         }
  5076.     }
  5077.     if (g_hoPlayerWindows[nUserId] && g_hoPlayerWindows[nUserId]['handle'] && g_hoPlayerWindows[nUserId]['handle'].Export && g_hoPlayerWindows[nUserId]['handle'].Export().RefreshSessionState) {
  5078.         try {
  5079.             g_hoPlayerWindows[nUserId]['handle'].Export().RefreshSessionState();
  5080.         } catch (oError) {
  5081.             Log("Try Catch Failure #26: " + oError.description);
  5082.         }
  5083.     }
  5084.     if (g_hUsers[nUserId]['access_level'] == 4) {
  5085.         clearTimeout(g_oFcSessionState_RateLimited);
  5086.         g_oFcSessionState_RateLimited = setTimeout("FcSessionState_RateLimited('" + nFrom + "','" + nState + "','" + nUserId + "');", 1000);
  5087.     }
  5088. }
  5089. var g_oFcSessionState_RateLimited;
  5090.  
  5091. function FcSessionState_RateLimited(nFrom, nState, nUserId) {
  5092.     for (nWindowId in g_hoPlayerWindows) {
  5093.         try {
  5094.             if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export && g_hLoungeIds[g_hoPlayerWindows[nWindowId]['handle'].Export().g_nBroadcasterId]) {
  5095.                 try {
  5096.                     if (g_hoPlayerWindows[nWindowId]['handle'].Export().g_nLoungeModel == nUserId) {
  5097.                         g_hoPlayerWindows[nWindowId]['handle'].Export().RefreshMessageBar();
  5098.                     }
  5099.                 } catch (oError) {
  5100.                     Log("Try Catch Failure #24: " + oError.description);
  5101.                 }
  5102.             }
  5103.         } catch (oError) {
  5104.             Log("Try Catch Failure #24.5: " + oError.description);
  5105.         }
  5106.     }
  5107.     for (nWindowId in g_hoPlayerWindows) {
  5108.         try {
  5109.             if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export) {
  5110.                 try {
  5111.                     g_hoPlayerWindows[nWindowId]['handle'].Export().RefreshOnlineBroadcasterList();
  5112.                 } catch (oError) {
  5113.                     Log("Try Catch Failure #27: " + oError.description);
  5114.                 }
  5115.             }
  5116.         } catch (oError) {
  5117.             Log("Try Catch Failure #27.5: " + oError.description);
  5118.         }
  5119.     }
  5120. }
  5121.  
  5122. function FcEndSessions(nModelId, nSessionType) {
  5123.     for (nWindowId in g_hoPlayerWindows) {
  5124.         if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export && g_hLoungeIds[g_hoPlayerWindows[nWindowId]['handle'].Export().g_nBroadcasterId]) {
  5125.             g_hoPlayerWindows[nWindowId]['private_session_id'] = 0;
  5126.             g_hoPlayerWindows[nWindowId]['relation_state'] = "public";
  5127.         }
  5128.     }
  5129.     if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle']) {
  5130.         g_hoPlayerWindows[nModelId]['relation_state'] = "public";
  5131.         g_hoPlayerWindows[nModelId]['private_session_id'] = 0;
  5132.     }
  5133.     if (g_hoPMWindows[nModelId] && g_hoPMWindows[nModelId]['handle']) {
  5134.         g_hoPMWindows[nModelId]['relation_state'] = "public";
  5135.         g_hoPMWindows[nModelId]['private_session_id'] = 0;
  5136.     }
  5137.     for (nWindowId in g_hoPlayerWindows) {
  5138.         if (g_hoPlayerWindows[nWindowId] && g_hoPlayerWindows[nWindowId]['handle'] && g_hoPlayerWindows[nWindowId]['handle'].Export && g_hLoungeIds[g_hoPlayerWindows[nWindowId]['handle'].Export().g_nBroadcasterId]) {
  5139.             g_hoPlayerWindows[nWindowId]['relation_state'] = "public";
  5140.             try {
  5141.                 g_hoPlayerWindows[nWindowId]['handle'].Export().FcEndSession(nModelId, nSessionType);
  5142.             } catch (oError) {
  5143.                 Log("Try Catch Failure #28: " + oError.description);
  5144.             }
  5145.         }
  5146.     }
  5147.     if (g_hoPlayerWindows[nModelId] && g_hoPlayerWindows[nModelId]['handle']) {
  5148.         try {
  5149.             g_hoPlayerWindows[nModelId]['handle'].Export().FcEndSession(nModelId, nSessionType);
  5150.         } catch (oError) {
  5151.             Log("Try Catch Failure #29: " + oError.description);
  5152.         }
  5153.     }
  5154.     if (g_hoPMWindows[nModelId] && g_hoPMWindows[nModelId]['handle']) {
  5155.         try {
  5156.             g_hoPMWindows[nModelId]['handle'].Export().FcEndSession(nModelId, nSessionType);
  5157.         } catch (oError) {
  5158.             Log("Try Catch Failure #30: " + oError.description);
  5159.         }
  5160.     }
  5161. }
  5162.  
  5163. function GetBroadcasterCount() {
  5164.     var nBroadcasterCount = 0;
  5165.     for (sK in g_hUsers) {
  5166.         if (g_hUsers[sK]) {
  5167.             if (IsBroadcastState(g_hUsers[sK]['state'])) nBroadcasterCount++;
  5168.         }
  5169.     }
  5170.     return nBroadcasterCount;
  5171. }
  5172.  
  5173. function ToggleFriendsMenu(hOptions) {
  5174.     hOptions = hOptions || {};
  5175.     g_bMenuRevealBlinker = 0;
  5176.     if (!hOptions || !hOptions['item']) {
  5177.         if (!hOptions['render_only']) {
  5178.             g_sToggleFriends = (g_sToggleFriends == "block") ? "none" : "block";
  5179.             SetCookie('display_friends', g_sToggleFriends, 'Thu, 21-Jan-2021 00:00:01 GMT', g_hC['site_path']);
  5180.         }
  5181.         LoadFriendsList('reset');
  5182.         if (!g_bIE) {
  5183.             IdCache('friends').style.display = g_sToggleFriends;
  5184.         } else {
  5185.             SlideOpenClose(d.getElementById("friends"), g_sToggleFriends, 196, 12, "x");
  5186.         }
  5187.         IdCache('main_menu').style.right = (g_sToggleFriends == "block") ? '5px' : '77px';
  5188.         IdCache('reveal_menu').style.display = (g_sToggleFriends == "block") ? "none" : "block";
  5189.         UntoggleMenuItem();
  5190.         if (window.frames['main'] && window.frames['main'].RefreshMessageBar) {
  5191.             window.frames['main'].RefreshMessageBar();
  5192.         }
  5193.     }
  5194. }
  5195.  
  5196. function ChatStreamImage_FlagBad(sSrc) {
  5197.     try {
  5198.         g_oChatStreamImage_Req.open("get", "../php/chat_stream_image.php?flag_bad=1&user_id=" + g_hSelf['user_id'] + "&image_src=" + sSrc + "&" + Math.random());
  5199.         g_oChatStreamImage_Req.onreadystatechange = ChatStreamImage_FlagBadResponse;
  5200.         g_oChatStreamImage_Req.send(null);
  5201.     } catch (oError) {
  5202.         Log('ChatStreamImage_FlagBad() ajax open caught exception');
  5203.     }
  5204. }
  5205.  
  5206. function ChatStreamImage_FlagBad_Response() {
  5207.     if (g_oChatStreamImage_Req.readyState != 4) return;
  5208. }
  5209.  
  5210. function ChatStreamImage(nHostUserId, sCallingWindowType, sMessage) {
  5211.     try {
  5212.         g_oChatStreamImage_Req.open("get", "../php/chat_stream_image.php?host_user_id=" + nHostUserId + "&calling_window_type=" + sCallingWindowType + "&message=" + escape(sMessage) + "&user_id=" + g_hSelf['user_id']);
  5213.         g_oChatStreamImage_Req.onreadystatechange = ChatStreamImage_Response;
  5214.         g_oChatStreamImage_Req.send(null);
  5215.     } catch (oError) {
  5216.         if (g_hSelf['username'] == "mfcuser") alert("ajax exception: " + oError.description);
  5217.         else Log('ChatStreamImage() ajax open caught exception');
  5218.     }
  5219. }
  5220.  
  5221. function ChatStreamImage_Response() {
  5222.     if (g_oChatStreamImage_Req.readyState != 4) return;
  5223.     var sResponse = g_oChatStreamImage_Req.responseText;
  5224.     aResponseFields = sResponse.split('\t');
  5225.     var hResponseFields = {
  5226.         response_code: aResponseFields[0],
  5227.         host_user_id: aResponseFields[1],
  5228.         calling_window_type: aResponseFields[2],
  5229.         message: aResponseFields[3],
  5230.         original_message: aResponseFields[4] || ''
  5231.     };
  5232.     if (sResponse.match(/ERROR/i)) {
  5233.         if (hResponseFields['calling_window_type'] == 'player') {
  5234.             g_hoPlayerWindows[hResponseFields['host_user_id']]['handle'].Export().PlayerQueue('chat', FormatChat(hResponseFields['message'], 0));
  5235.             t.TxCmd(t.FCTYPE_CMESG, t.g_nSessionId, t.g_hoPlayerWindows[hResponseFields['host_user_id']]['room_channel'], 0, 0, hResponseFields['original_message']);
  5236.         } else if (hResponseFields['calling_window_type'] == 'pm') {
  5237.             TxPrivateMessage(hResponseFields['host_user_id'], hResponseFields['original_message']);
  5238.             try {
  5239.                 g_hoPMWindows[hResponseFields['host_user_id']]['handle'].Export().Receive({
  5240.                     msg: hResponseFields['message'],
  5241.                     msguid: g_hSelf['user_id']
  5242.                 });
  5243.             } catch (oError) {}
  5244.         }
  5245.     } else if (!sResponse.match(/OK/)) {
  5246.         if (g_hSelf['username'] == "mfcuser") {
  5247.             alert("Error: " + g_oChatStreamImage_Req.responseText);
  5248.         } else {
  5249.             g_hoPlayerWindows[nPlayerOwnerId]['handle'].Export().PlayerQueue('chat', FormatChat("There was an error. Please contact support.\n\n", 0));
  5250.         }
  5251.     } else {
  5252.         if (hResponseFields['calling_window_type'] == 'player') {
  5253.             t.TxCmd(t.FCTYPE_CMESG, t.g_nSessionId, t.g_hoPlayerWindows[hResponseFields['host_user_id']]['room_channel'], 0, 0, hResponseFields['message']);
  5254.         } else if (hResponseFields['calling_window_type'] == 'pm') {
  5255.             TxPrivateMessage(hResponseFields['host_user_id'], hResponseFields['message']);
  5256.             try {
  5257.                 g_hoPMWindows[hResponseFields['host_user_id']]['handle'].Export().Receive({
  5258.                     msg: hResponseFields['message'],
  5259.                     msguid: g_hSelf['user_id']
  5260.                 });
  5261.             } catch (oError) {
  5262.                 alert("PM Window Image Error: " + oError.description);
  5263.             }
  5264.         }
  5265.     }
  5266.     return;
  5267. }
  5268. var g_oClientInfoReq = null;
  5269. var g_sTZ;
  5270. var g_nUID = 0;
  5271. var g_sSystemInfo = 0;
  5272. var g_sSystemFonts = 0;
  5273. var g_nClientInfo_Retries = 0;
  5274.  
  5275. function ClientInfo(bConnectionComplete) {
  5276.     bConnectionComplete = bConnectionComplete || 0;
  5277.     if (g_oClientInfoReq == null) g_oClientInfoReq = createRequestObject();
  5278.     var oTime = new Date();
  5279.     g_sTZ = -oTime.getTimezoneOffset() / 60;
  5280.     var oUtilities = getFlashObject('flash_utilities');
  5281.     try {
  5282.         g_nUID = oUtilities.GetVariable("/:g_nUID");
  5283.         g_sSystemInfo = oUtilities.GetVariable("/:g_SystemInfo");
  5284.         g_sSystemFonts = oUtilities.GetVariable("/:g_SystemFonts");
  5285.     } catch (oError) {
  5286.         g_nUID = -1;
  5287.     }
  5288.     if (g_nUID < 2 && g_nClientInfo_Retries < 3) {
  5289.         g_nClientInfo_Retries++;
  5290.         setTimeout("ClientInfo(1);", 5000);
  5291.         return;
  5292.     }
  5293.     try {
  5294.         IdCache('login_uid').value = g_nUID;
  5295.     } catch (e) {}
  5296.     var aSystemInfo = g_sSystemInfo.split('\n');
  5297.     var hSystemInfo = {};
  5298.     for (nK in aSystemInfo) {
  5299.         hSystemInfo[aSystemInfo[nK].split(':')[0]] = aSystemInfo[nK].split(':')[1];
  5300.     }
  5301.     var sSelectiveSystemInfo = '';
  5302.     for (sK in hSystemInfo) {
  5303.         if (sK == 'avHardwareDisable' || sK == 'hasAccessibility' || sK == 'hasAudioEncoder' || sK == 'hasAudio' || sK == 'hasEmbeddedVideo' || sK == 'hasIME' || sK == 'hasMP3' || sK == 'hasPrinting' || sK == 'hasScreenBroadcast' || sK == 'hasScreenPlayback' || sK == 'hasStreamingAudio' || sK == 'hasStreamingVideo' || sK == 'hasTLS' || sK == 'hasVideoEncoder' || sK == 'isEmbeddedInAcrobat' || sK == 'language' || sK == 'localFileReadDisable' || sK == 'maxLevelIDC' || sK == 'pixelAspectRatio' || sK == 'screenColor' || sK == 'screenDPI' || sK == 'screenResolutionX' || sK == 'screenResolutionY' || sK == 'windowlessDisable') {
  5304.             sSelectiveSystemInfo += (sK + ": " + hSystemInfo[sK] + "\n");
  5305.         }
  5306.     }
  5307.     aSystemFonts = g_sSystemFonts.split(',');
  5308.     aSystemFonts.sort();
  5309.     var sSystemFontsSorted = aSystemFonts.join();
  5310.     var sCrcSystemInfo = MfcCrc32.prototype.string(g_sSystemInfo);
  5311.     var sCrcSystemBroad = MfcCrc32.prototype.string(g_sSystemFonts + sSelectiveSystemInfo);
  5312.     var sCrcSystemFonts = MfcCrc32.prototype.string(g_sSystemFonts);
  5313.     var sCrcSystemFontsSorted = MfcCrc32.prototype.string(sSystemFontsSorted);
  5314.     var sRequest = "../php/client_info.php?" + "r=" + Math.round(Math.random() * 1000000) + "&uid=" + g_nUID + "&tz=" + g_sTZ + "&username=" + g_hCk['username'] + "&passcode=" + g_hCk['passcode'] + "&co=" + oTime.getTime() + "&sz=" + (screen.width + 'x' + screen.height) + "&session_id=" + g_nSessionId + "&sCrcSystemInfo=" + escape(sCrcSystemInfo) + "&sCrcSystemBroad=" + escape(sCrcSystemBroad) + "&sCrcSystemFonts=" + escape(sCrcSystemFonts) + "&sCrcSystemFontsSorted=" + escape(sCrcSystemFontsSorted) + "&flashver=" + escape(GetSwfVer()) + "&connection_completed=" + bConnectionComplete;
  5315.     try {
  5316.         g_oClientInfoReq.open("get", sRequest);
  5317.         g_oClientInfoReq.onreadystatechange = ClientInfo_Response;
  5318.         g_oClientInfoReq.send(null);
  5319.     } catch (oError) {
  5320.         Log('ClientInfo ajax open caught exception');
  5321.     }
  5322. }
  5323.  
  5324. function ClientInfo_Response() {
  5325.     if (g_oClientInfoReq.readyState != 4) return;
  5326.     var sUserNotepad;
  5327.     if (top.location.search.match(/dbg_tz/)) {
  5328.         alert(g_oClientInfoReq.responseText);
  5329.     }
  5330.     eval(g_oClientInfoReq.responseText);
  5331.     if (sUserNotepad) {
  5332.         aUserNotepad = sUserNotepad.split(',');
  5333.         for (nK in aUserNotepad) {
  5334.             var nUserId = aUserNotepad[nK];
  5335.             if (!t.g_hUsers[nUserId]) {
  5336.                 t.g_hUsers[nUserId] = {};
  5337.             }
  5338.             t.g_hUsers[nUserId]['notes'] = 1;
  5339.         }
  5340.     }
  5341.     return;
  5342. }
  5343. var g_oNewsFeedListenerReq;
  5344.  
  5345. function NewsFeedListener() {
  5346.     if (g_hSelf['access_level'] < 2) {
  5347.         return;
  5348.     }
  5349.     if (g_oNewsFeedListenerReq == null) g_oNewsFeedListenerReq = createRequestObject();
  5350.     var sRequest = "../php/news_feed_listener.php?" + Math.random();
  5351.     g_oNewsFeedListenerReq.open("get", sRequest);
  5352.     g_oNewsFeedListenerReq.onreadystatechange = NewsFeedListener_Response;
  5353.     g_oNewsFeedListenerReq.send(null);
  5354. }
  5355. var g_hNewsFeed_OldNews = {};
  5356. var g_oNewsFeed_Timeout = {};
  5357.  
  5358. function NewsFeedListener_Response() {
  5359.     if (g_oNewsFeedListenerReq.readyState != 4) return;
  5360.     if (g_oNewsFeedListenerReq.responseText == '-1') {
  5361.         return;
  5362.     }
  5363.     var aNewsItems = g_oNewsFeedListenerReq.responseText.split('\n');
  5364.     for (a = 0; a < aNewsItems.length; a++) {
  5365.         var aNewsItem = aNewsItems[a].split('|');
  5366.         var nNewsId = aNewsItem[0];
  5367.         var nUserId = aNewsItem[1];
  5368.         var sUsername = aNewsItem[2];
  5369.         var sMessage = aNewsItem[3];
  5370.         if (g_hNewsFeed_OldNews[nNewsId] || !nNewsId) {
  5371.             continue;
  5372.         }
  5373.         if (IdCache('news_feed_menu_item')) {
  5374.             IdCache('news_feed_menu_item').style.backgroundColor = '#FFFF00';
  5375.             setTimeout("IdCache('news_feed_menu_item').style.backgroundColor = '#FFFFFF';", 300000);
  5376.         }
  5377.         Notification(A('news_feed') + "<b>News Feed</b></a> message from <b>" + A("pm_friend", {
  5378.             user_id: nUserId,
  5379.             username: sUsername
  5380.         }) + sUsername + "</a>");
  5381.         if (g_hSelf['news_feed_options'] & 1) {
  5382.             for (var sK in g_hoPlayerWindows) {
  5383.                 if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  5384.                     try {
  5385.                         g_hoPlayerWindows[sK]['handle'].Export().PlayerQueue('chat', NewsFeed_InChatHTML('player', sMessage, nUserId, sUsername));
  5386.                     } catch (oError) {
  5387.                         Log("Try Catch Failure #3: " + oError.description);
  5388.                     }
  5389.                 }
  5390.             }
  5391.         }
  5392.         if (g_hSelf['news_feed_options'] & 2) {
  5393.             for (var sK in g_hoPMWindows) {
  5394.                 if (g_hoPMWindows[sK] && g_hoPMWindows[sK]['handle'] && g_hoPMWindows[sK]['handle'].Export) {
  5395.                     try {
  5396.                         g_hoPMWindows[sK]['handle'].Export().AppendContents(NewsFeed_InChatHTML('pm', sMessage, nUserId, sUsername));
  5397.                     } catch (oError) {
  5398.                         Log("Try Catch Failure #3: " + oError.description);
  5399.                     }
  5400.                 }
  5401.             }
  5402.         }
  5403.         g_hNewsFeed_OldNews[nNewsId] = 1;
  5404.     }
  5405.     clearTimeout(g_oNewsFeed_Timeout);
  5406.     g_oNewsFeed_Timeout = setTimeout(NewsFeedListener, 120000);
  5407. }
  5408.  
  5409. function getFlashObject(sFlashId) {
  5410.     if (window.document[sFlashId]) {
  5411.         return window.document[sFlashId];
  5412.     }
  5413.     if (navigator.appName.indexOf("Microsoft Internet") == -1) {
  5414.         if (document.embeds && document.embeds[sFlashId]) {
  5415.             return document.embeds[sFlashId];
  5416.         }
  5417.     } else {
  5418.         return document.getElementById(sFlashId);
  5419.     }
  5420. }
  5421. var g_nGrowShrinkProgress = 0;
  5422. var g_oDiv;
  5423.  
  5424. function SlideOpenClose(oDiv, sMode, nWidthOrHeight, nSpeed, cAxis) {
  5425.     nSpeed = parseInt(nSpeed);
  5426.     if (sMode == 'none') {
  5427.         g_nGrowShrinkProgress = g_nGrowShrinkProgress - nSpeed;
  5428.         if (g_nGrowShrinkProgress <= nSpeed) {
  5429.             if (cAxis == 'x') oDiv.style.width = 0;
  5430.             else oDiv.style.height = 0;
  5431.             oDiv.style.display = sMode;
  5432.             g_nGrowShrinkProgress = 0;
  5433.             return;
  5434.         }
  5435.     } else if (sMode == 'block') {
  5436.         if (g_nGrowShrinkProgress == 0 || g_nGrowShrinkProgress >= nWidthOrHeight) {
  5437.             oDiv.style.display = sMode;
  5438.         }
  5439.         g_nGrowShrinkProgress = g_nGrowShrinkProgress + nSpeed;
  5440.         if (g_nGrowShrinkProgress >= nWidthOrHeight) {
  5441.             if (cAxis == 'x') oDiv.style.width = nWidthOrHeight;
  5442.             else oDiv.style.height = nWidthOrHeight;
  5443.             g_nGrowShrinkProgress = nWidthOrHeight;
  5444.             return;
  5445.         }
  5446.     }
  5447.     if (g_nGrowShrinkProgress < 0) {
  5448.         return;
  5449.     }
  5450.     if (cAxis == 'x') oDiv.style.width = Math.round(g_nGrowShrinkProgress);
  5451.     else oDiv.style.height = Math.round(g_nGrowShrinkProgress);
  5452.     g_oDiv = oDiv;
  5453.     setTimeout("SlideOpenClose(g_oDiv,'" + sMode + "','" + nWidthOrHeight + "','" + nSpeed + "','" + cAxis + "')", 1);
  5454. }
  5455.  
  5456. function TrackUsage(sKey, sVal1, sVal2, sVal3) {
  5457.     sVal1 = sVal1 || '';
  5458.     sVal2 = sVal2 || '';
  5459.     sVal3 = sVal3 || '';
  5460.     try {
  5461.         g_oAdminReq.open("get", "../php/admin_tools.php?track_usage=1&key=" + sKey + "&value1=" + escape(sVal1) + "&value2=" + escape(sVal2) + "&value3=" + escape(sVal3) + "&clear_code=" + top.g_sClearCode + "&" + Math.random());
  5462.         g_oAdminReq.onreadystatechange = Admin_Response;
  5463.         g_oAdminReq.send(null);
  5464.     } catch (oError) {
  5465.         Log('TrackUsage ajax open caught exception');
  5466.     }
  5467. }
  5468.  
  5469. function Admin(sCommand, sArg1) {
  5470.     sArg1 = sArg1 || '';
  5471.     try {
  5472.         g_oAdminReq.open("get", "../php/admin_tools.php?command=" + sCommand + "&arg1=" + escape(sArg1) + "&clear_code=" + top.g_sClearCode + "&" + Math.random());
  5473.         g_oAdminReq.onreadystatechange = Admin_Response;
  5474.         g_oAdminReq.send(null);
  5475.     } catch (oError) {
  5476.         Log('Admin ajax open caught exception');
  5477.     }
  5478. }
  5479.  
  5480. function Admin_Response() {
  5481.     if (g_oAdminReq.readyState != 4) return;
  5482. }
  5483. var g_oSaveSettingReq = {};
  5484. var g_oSaveSettingReqId = 0;
  5485.  
  5486. function SaveSetting(sSetting, sVal, sVal2) {
  5487.     g_hSelf[sSetting] = sVal;
  5488.     Log("DBGMUTE: SaveSetting('" + sSetting + "', '" + sVal + "', '" + sVal2 + "') ");
  5489.     if (g_hSelf['access_level'] < 1) {
  5490.         return;
  5491.     }
  5492.     sVal2 = (sVal2 == 'undefined') ? '' : sVal2;
  5493.     if (sSetting == 'webcam_security_access_level' && t.g_hWindows['broadcast']) {
  5494.         alert("Your new security settings will not take effect until you have restarted your webcam.");
  5495.         t.g_hWindows['broadcast'].location.reload();
  5496.     }
  5497.     try {
  5498.         g_oSaveSettingReqId++;
  5499.         g_oSaveSettingReq[g_oSaveSettingReqId] = createRequestObject();
  5500.         g_oSaveSettingReq[g_oSaveSettingReqId].open("get", "../php/user_settings.php?user_id=" + g_hSelf['user_id'] + "&update=1&key=" + sSetting + "&value=" + escape(sVal) + "&value2=" + escape(sVal2) + "&" + Math.random());
  5501.         g_oSaveSettingReq[g_oSaveSettingReqId].onreadystatechange = SaveSetting_Response;
  5502.         g_oSaveSettingReq[g_oSaveSettingReqId].send(null);
  5503.     } catch (oError) {
  5504.         alert("SaveSetting error. Please report this to MyFreeCams Support: " + oError.description);
  5505.     }
  5506.     Log("SaveSetting(" + sSetting + "," + sVal + "," + sVal2 + ")");
  5507. }
  5508.  
  5509. function SaveSetting_Response() {
  5510.     for (sK in g_oSaveSettingReq) {
  5511.         if (g_oSaveSettingReq[sK].readyState == 4) {
  5512.             try {
  5513.                 if (g_oSaveSettingReq[sK].responseText == 1) {
  5514.                     t.TxCmd(t.FCTYPE_RELOADSETTINGS, g_nSessionId, 0);
  5515.                 } else if (g_oSaveSettingReq[sK].responseText) {
  5516.                     eval(g_oSaveSettingReq[sK].responseText);
  5517.                 }
  5518.             } catch (oError) {
  5519.                 alert(oError.description + " " + g_oSaveSettingReq[sK].responseText + " " + g_oSaveSettingReq[sK].responseText);
  5520.             }
  5521.             delete g_oSaveSettingReq[sK];
  5522.         }
  5523.     }
  5524. }
  5525.  
  5526. function GetDocumentDimensions(oDoc, oWin) {
  5527.     oDoc = oDoc || document;
  5528.     var nWidth;
  5529.     var nHeight;
  5530.     if (typeof(oWin.innerWidth) == 'number') {
  5531.         nWidth = oWin.innerWidth;
  5532.         nHeight = oWin.innerHeight;
  5533.     } else if (oDoc.documentElement && (oDoc.documentElement.clientWidth || oDoc.documentElement.clientHeight)) {
  5534.         nWidth = document.documentElement.clientWidth;
  5535.         nHeight = oDoc.documentElement.clientHeight;
  5536.     } else if (oDoc.body && (oDoc.body.clientWidth || oDoc.body.clientHeight)) {
  5537.         nWidth = oDoc.body.clientWidth;
  5538.         nHeight = oDoc.body.clientHeight;
  5539.     }
  5540.     return {
  5541.         width: nWidth,
  5542.         height: nHeight
  5543.     };
  5544. }
  5545.  
  5546. function RoomData(sPayload) {
  5547.     var hCounts = ParseJSON(sPayload);
  5548.     for (var n = 0; n < hCounts.length;) {
  5549.         var nModel = hCounts[n++];
  5550.         var nCount = hCounts[n++];
  5551.         if (g_hUsers[nModel]) g_hUsers[nModel]['room_count'] = nCount;
  5552.     }
  5553. }
  5554.  
  5555. function NewsItem(sPayload) {
  5556.     var hNewsItem = ParseJSON(unescape(sPayload));
  5557.     if (IdCache('news_feed_menu_item')) {
  5558.         IdCache('news_feed_menu_item').style.backgroundColor = '#FFFF00';
  5559.         setTimeout("IdCache('news_feed_menu_item').style.backgroundColor = '#FFFFFF';", 300000);
  5560.     }
  5561.     Notification(A('news_feed') + "<b>News Feed</b></a> message from <b>" + A("pm_friend", {
  5562.         user_id: hNewsItem['user_id'],
  5563.         username: hNewsItem['username']
  5564.     }) + hNewsItem['username'] + "</a>");
  5565.     if (g_hSelf['news_feed_options'] & 1) {
  5566.         for (var sK in g_hoPlayerWindows) {
  5567.             if (g_hoPlayerWindows[sK] && g_hoPlayerWindows[sK]['handle'] && g_hoPlayerWindows[sK]['handle'].Export) {
  5568.                 try {
  5569.                     g_hoPlayerWindows[sK]['handle'].Export().PlayerQueue('chat', NewsFeed_InChatHTML('player', hNewsItem['msg'], hNewsItem['user_id'], hNewsItem['username']));
  5570.                 } catch (oError) {
  5571.                     Log("Try Catch Failure #3: " + oError.description);
  5572.                 }
  5573.             }
  5574.         }
  5575.     }
  5576.     if (g_hSelf['news_feed_options'] & 2) {
  5577.         for (var sK in g_hoPMWindows) {
  5578.             if (g_hoPMWindows[sK] && g_hoPMWindows[sK]['handle'] && g_hoPMWindows[sK]['handle'].Export) {
  5579.                 try {
  5580.                     g_hoPMWindows[sK]['handle'].Export().AppendContents(NewsFeed_InChatHTML('pm', hNewsItem['msg'], hNewsItem['user_id'], hNewsItem['username']));
  5581.                 } catch (oError) {
  5582.                     Log("Try Catch Failure #3: " + oError.description);
  5583.                 }
  5584.             }
  5585.         }
  5586.     }
  5587. }
  5588.  
  5589. function SharedVideoHandler(nServerId, nModelId) {
  5590.     nServerId = parseInt(nServerId);
  5591.     nModelId = parseInt(nModelId);
  5592.     g_hSharedVideo[nServerId] = nModelId;
  5593.     var hVideoUserIds = {};
  5594.     for (nUserId in g_hoPlayerWindows) {
  5595.         hVideoUserIds[nUserId] = 1;
  5596.     }
  5597.     for (nUserId in g_hoPMWindows) {
  5598.         hVideoUserIds[nUserId] = 1;
  5599.     }
  5600.     for (nVideoUserId in hVideoUserIds) {
  5601.         if (nVideoUserId && g_hUsers[nVideoUserId] && g_hUsers[nVideoUserId]['shared_videoserver'] && nServerId == g_hUsers[nVideoUserId]['shared_videoserver'] && (nModelId == 0 || nModelId != nVideoUserId)) {
  5602.             g_hUsers[nVideoUserId]['shared_videoserver'] = 0;
  5603.             if (g_hoPlayerWindows[nVideoUserId]) {
  5604.                 try {
  5605.                     g_hoPlayerWindows[nVideoUserId]['handle'].Export().LoadVideo();
  5606.                 } catch (oError) {
  5607.                     Log("Try Catch Failure #100: " + oError.description);
  5608.                 }
  5609.             }
  5610.             if (t.g_hoPMWindows[nVideoUserId] && t.g_hoPMWindows[nVideoUserId]['pm_video']) {
  5611.                 try {
  5612.                     g_hoPMWindows[nVideoUserId]['handle'].Export().LoadVideo();
  5613.                 } catch (oError) {
  5614.                     Log("Try Catch Failure #100: " + oError.description);
  5615.                 }
  5616.             }
  5617.         }
  5618.     }
  5619. }
  5620.  
  5621. function DrawVideo(nUserId, hOptions, oCaller) {
  5622.     hOptions = hOptions || {};
  5623.     var sHtml = '';
  5624.     var sFlashVars = '';
  5625.     var sFlashUrl = '/mfc2/flash/MfcVideoBeta.swf?nc=33';
  5626.     var bMute = hOptions['mute'] == 'off' ? true : false;
  5627.     if (!t.g_hUsers[nUserId]) return;
  5628.     if (top.location.search.match(/vtest/)) {
  5629.         sFlashUrl = '/mfc2/flash/MfcVideoBeta2.swf?nc=34';
  5630.     }
  5631.     if (t.g_hUsers[nUserId]['access_level'] == 4) {
  5632.         if (hOptions['stats']) {
  5633.             sFlashVars += "&stats=true";
  5634.         }
  5635.         hOptions['width'] = hOptions['width'] || 320;
  5636.         hOptions['height'] = hOptions['height'] || 240;
  5637.         if (hOptions['private_session_id']) {
  5638.             sFlashVars += "&pvtsession=" + hOptions['private_session_id'];
  5639.             hOptions['roomid'] = t.SessionChannel(nUserId);
  5640.         } else if (hOptions['group_session_id']) {
  5641.             sFlashVars += "&grpsession=" + hOptions['group_session_id'];
  5642.             hOptions['roomid'] = t.SessionChannel(nUserId);
  5643.         } else {
  5644.             hOptions['roomid'] = hOptions['roomid'] || t.PublicChannel(nUserId);
  5645.         }
  5646.         nVideoServer = -1;
  5647.         if (g_hUsers[nUserId] && g_hUsers[nUserId]['videoserver']) {
  5648.             nVideoServer = g_hUsers[nUserId]['
  5649. videoserver'];
  5650.             if (nUserId == 100) Log("VIDSERV-PRE: " + nVideoSe
  5651.             rver);
  5652.         }
  5653.         if (!g_hServerMap[nVideoServer] || g_hServerMap[nVideoServer] == undefined) {
  5654.             if (nUserId == 100) Log("VIDSERV error, vid server is " + nVideoServer + ", will make 20");
  5655.             nVideoServer = 20;
  5656.         } else nVideoServer = g_hServerMap[nVideoServer];
  5657.         if (hOptions['private_session_id'] || hOptions['group_session_id']) {} else {
  5658.             var n = nVideoServer;
  5659.             var hDevServers = null;
  5660.             if (n >= 112)
  5661.                hDevServers = new Array(n + 1, n + 2, n + 3);
  5662.             else
  5663.                hDevServers = new Array(n + 1, n + 2, n + 3, n + 4);
  5664.             for (nShared in g_hSharedVideo) {
  5665.                 if (g_hSharedVideo[nShared] == nUserId) {
  5666.                     hDevServers.push(nShared, nShared, nShared);
  5667.                 }
  5668.             }
  5669.             nIdx = Math.floor(hDevServers.length * Math.random());
  5670.             nVideoServer = hDevServers[nIdx];
  5671.         }
  5672.         if (g_hQS['vidserv'] && g_hQS['vidserv'] > 0)
  5673.            nVideoServer = g_hQS['vidserv'];
  5674.            
  5675.         sFlashVars += "&server=video" + nVideoServer + "&sessionID=" + g_nSessionId + "&roomID=" + hOptions['roomid'] + "&password=" + (t.g_hCk['passcode'] || '') + "&mode=" + "DOWNLOAD" + "&modelID=" + nUserId;
  5676.         g_hUsers[nUserId]['shared_videoserver'] = g_hSharedVideo[nVideoServer] ? nVideoServer : 0;
  5677.         if (bMute) {
  5678.             sFlashVars += "&mute=true";
  5679.         }
  5680.         var nState = FCVIDEO_RX_IDLE;
  5681.         if (hOptions['state']) {
  5682.             nState = hOptions['state'];
  5683.         } else {
  5684.             if (g_hoPlayerWindows[nUserId]) {
  5685.                 if (g_hoPlayerWindows[nUserId]['relation_state'] == 'voyeur') {
  5686.                     nState = FCVIDEO_RX_VOY;
  5687.                 } else if (g_hoPlayerWindows[nUserId]['relation_state'] == 'private') {
  5688.                     nState = FCVIDEO_RX_PVT;
  5689.                 } else if (g_hoPlayerWindows[nUserId]['relation_state'] == 'group_show') {
  5690.                     nState = FCVIDEO_RX_GRP;
  5691.                 }
  5692.             }
  5693.             if (g_hoPMWindows[nUserId] && nState == FCVIDEO_RX_IDLE) {
  5694.                 if (g_hoPMWindows[nUserId]['relation_state'] == 'voyeur') {
  5695.                     nState = FCVIDEO_RX_VOY;
  5696.                 } else if (g_hoPMWindows[nUserId]['relation_state'] == 'private') {
  5697.                     nState = FCVIDEO_RX_PVT;
  5698.                 } else if (g_hoPMWindows[nUserId]['relation_state'] == 'group_show') {
  5699.                     nState = FCVIDEO_RX_GRP;
  5700.                 }
  5701.             }
  5702.         }
  5703.         sFlashVars += "&state=" + nState;
  5704.     } else {
  5705.         nVideoServer = g_hUsers[nUserId]['broadcasting_video'];
  5706.         var sFlashUrl = '/mfc2/flash/video16.swf?nc=5';
  5707.         sFlashVars = "sessionID=" + g_nSessionId + "&roomID=" + (nUserId + 100000000) + "&password=" + (t.g_hCk['passcode'] || '') + "&mode=" + "CAM2CAM" + "&modelID=" + nUserId;
  5708.         if (nVideoServer == 60) {
  5709.             sFlashVars += "&state=" + FCVIDEO_TX_IDLE;
  5710.         } else {
  5711.             sFlashVars += "&server=video" + g_hServerMap[nVideoServer];
  5712.         }
  5713.         if (bMute) sFlashVars += "&mute=true";
  5714.         Log('MYWEBCAM DrawVideo(): ' + sFlashVars);
  5715.     }
  5716.     if (hOptions['varsonly'] == 1) return sFlashVars;
  5717.     sHtml = " <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'\n codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'\n width='" + hOptions['width'] + "'\n height='" + hOptions['height'] + "'\n id='fvideo'\n align='middle'>\n <param name='allowScriptAccess' value='always' />\n <param name='movie' value='" + sFlashUrl + "' />\n <param name='quality' value='high' />\n <param name='wmode' value='transparent' />\n <param name='bgcolor' value='#ffffff' />\n <param name='flashvars' value='" + sFlashVars + "'>\n <embed\n wmode=transparent src='" + sFlashUrl + "'\n swliveconnect='true'\n quality='high'\n flashvars='" + sFlashVars + "'\n bgcolor='#ffffff'\n width='" + hOptions['width'] + "'\n height='" + hOptions['height'] + "'\n id='fvideo'\n name='fvideo'\n align='middle'\n allowScriptAccess='always'\n type='application/x-shockwave-flash'\n pluginspage='http://www.macromedia.com/go/getflashplayer' />\n </object>";
  5718.     Log("FLASH: DrawVideo() for model " + nUserId + " room: " + hOptions['roomid'] + " private_session_id: " + hOptions['private_session_id']);
  5719.     Log("FLASH: DrawVideo() vars: " + sFlashVars);
  5720.     return sHtml;
  5721. }
  5722.  
  5723. function EnlargeImage(oCaller, sImgSrc) {
  5724.     sMediumSrc = sImgSrc.replace(/(.+)\.(\w{3})$/, "$1.200x.$2");
  5725.     oCaller.g_oDhtmlPopup.open(" <i" + "mg src=\"" + sMediumSrc + "\" onMouseover=\"if( this.width >= 199 ){ this.style.cursor='pointer'; }\" onLoad=\"g_oDhtmlPopup.popup_resize();\" onClick=\"if( this.width >= 199 ) { window.open('../static/image_popup.html?image=" + escape(sImgSrc) + "', '_blank', 'height=' + (this.height + 20) + ',width=' + (this.width + 20) + ',status=0'); } \"> <div style='text-align:center;border:0px solid red;white-space:nowrap;width:300px;'> <a href=# onClick=\"alert('MyFreeCams administrators will be notified.');t.ChatStreamImage_FlagBad('" + sImgSrc + "');ClosePopup();\">Flag as offensive</a> &nbsp; <a href=# onClick=\"g_oDhtmlPopup.close();\">Close</a> </div> ");
  5726. }
  5727.  
  5728. function OfflineFriendsSort(sMode) {
  5729.     g_hSelf['offline_friends_sort'] = sMode;
  5730.     SaveSetting('offline_friends_sort', sMode);
  5731.     LoadFriendsList();
  5732. }
  5733.  
  5734. function ToggleOfflineFriends() {
  5735.     if (!g_hSelf['show_offline_friends']) {
  5736.         g_hSelf['show_offline_friends'] = 0;
  5737.     }
  5738.     g_hSelf['show_offline_friends'] = g_hSelf['show_offline_friends'] ? 0 : 1;
  5739.     SaveSetting('show_offline_friends', g_hSelf['show_offline_friends'] || 0);
  5740.     ToggleOfflineFriends_Lable();
  5741. }
  5742.  
  5743. function ToggleOfflineFriends_Lable() {
  5744.     if (g_hSelf['show_offline_friends']) {
  5745.         IdCache('offline_friends_toggle_lable').innerHTML = 'Hide';
  5746.         IdCache('offline_friends_list_wrapper').style.display = '';
  5747.     } else {
  5748.         IdCache('offline_friends_toggle_lable').innerHTML = 'Show';
  5749.         IdCache('offline_friends_list_wrapper').style.display = 'none';
  5750.     }
  5751. }
  5752. var g_hTypeMap = {};
  5753. if (g_bDebug) {
  5754.     var sType;
  5755.     for (sK in w) {
  5756.         if (sK.indexOf('FCTYPE') == 0) {
  5757.             g_hTypeMap[w[sK]] = sK;
  5758.         }
  5759.     }
  5760. }
  5761.  
  5762. //-----
  5763.  
  5764. A(d, "miss_mfc", {
  5765.     supress_decoration: true
  5766. })
  5767.  
  5768. //-----
  5769. d.write(g.container("top"))
  5770.  
  5771. d.write(g.container("top"))
  5772.  
  5773. d.write(g.container("bottom"))
  5774.  
  5775. d.write(g.container("top"))
  5776.  
  5777. A(d, 'offline_friends')
  5778.  
  5779. d.write(g.container("bottom"))
  5780.  
  5781. d.write(g.container("top,expanded"))
  5782.  
  5783. d.write(g.container("bottom"))
  5784.  
  5785. document.getElementById('main').src = '/mfc2/static/main_template.html';
  5786.  
  5787. IdCache('friend_content_div').style.height = "100%";
  5788. IdCache('friends_container').style.height = "100%";
  5789. var g_oResize;
  5790.  
  5791. function QueueResizeHandler() {
  5792.     clearTimeout(g_oResize);
  5793.     g_oResize = setTimeout(" ResizeHandler(); ", 100);
  5794. }
  5795.  
  5796. function ResizeHandler() {
  5797.     IdCache('friends').style.height = (GetDocumentDimensions(d, w).height - 35) + 'px';
  5798.     IdCache('main_table').style.height = (GetDocumentDimensions(d, w).height - 125) + 'px';
  5799. }
  5800.  
  5801. function FlashLog(sMsg) {
  5802.     t.Log("FLASH: " + sMsg);
  5803. }
  5804. g_fBodyLoaded = true;
  5805. SetHTML('main_menu', '');
  5806. if (g_sConnectionMode == 'flash') {
  5807.     onload = function () {
  5808.         g_hLoadSetup = setInterval(TryOnLoad, 1000);
  5809.     };
  5810. } else {
  5811.     setTimeout("LoadAll()", 100)
  5812. }
  5813.  
  5814. function FlashPing() {
  5815.     if (g_sConnectionMode == 'flash' || g_sConnectionMode == 'java') {
  5816.         TxCmd(FCTYPE_NULL, g_nSessionId, 0, 0, 0);
  5817.     }
  5818. }
  5819. var g_hLoadSetup = null;
  5820. var g_nLoadSetupTries = 0;
  5821.  
  5822. function TryOnLoad() {
  5823.     g_nLoadSetupTries++;
  5824.     Log('DBG:: XML Trying to call OnLoad-x #' + g_nLoadSetupTries + ', con mode: ' + g_sConnectionMode);
  5825.     if (g_sConnectionMode == 'flash') {
  5826.         if (zgw_XmlOnLoad) {
  5827.             if (zgw_XmlOnLoad()) {
  5828.                 Log('DBG:: XML zgw_XmlOnLoad() success');
  5829.                 clearInterval(g_hLoadSetup);
  5830.                 g_hLoadSetup = null;
  5831.             } else {
  5832.                 Log('DBG:: XML zgw_XmlOnLoad() returned false');
  5833.             }
  5834.         } else {
  5835.             Log('DBG:: XML zgw_XmlOnLoad not there yet: ' + typeof(zgw_XmlOnLoad));
  5836.         }
  5837.     } else if (LoadAll) {
  5838.         Log('DBG:: XML Connection mode was not flash, calling inline LoadAll()...');
  5839.         LoadAll();
  5840.         clearInterval(g_hLoadSetup);
  5841.         g_hLoadSetup = null;
  5842.     } else {
  5843.         Log('DBG:: XML LoadAll has con mode of ' + g_sConnectionMode + ', no LoadAll? ' + typeof(LoadAll));
  5844.     }
  5845. }
  5846. setInterval(FlashPing, 120000);
  5847. g_oDhtmlPopup.dhtml_popop_html();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement