function openChatPrivate(user_id) { window.open('chat.html?privat_user_id=' + user_id, '_123flashchat', 'HEIGHT=476,resizable=yes,WIDTH=728'); } function getNewChatInvites() { $.ajax({ type: "GET", url: "/ajax-chat_invite.html", dataType: "xml", complete: getNewChatInvitesCallback}); // window.setTimeout('getNewChatInvites()',2000); } function getNewChatInvitesCallback(data) { data = $('response', data.responseXML); if ($(data).find('status')[0].firstChild.data == "ok") { try { var html = $(data).find('html')[0].firstChild.data; } catch(e) { return; } $("#chat_invitations_text").html(html); scroll_top = $(document).scrollTop(); $("#chat_invitations_box").css('top', scroll_top).show('slow'); } else if ($(data).find('status')[0].firstChild.data == "accept") { try { var user_id = $(data).find('user')[0].firstChild.data; } catch(e) { return; } openChatPrivate(user_id); // chatInviteCancel(user_id); } } function getChatInviteStatus() { $.ajax({ type: "GET", url: "/ajax-chat_invite.html?user_id=" + user_id + "&act=status", dataType: "xml", complete: getChatInviteStatusCallback}); } function getChatInviteStatusCallback(data) { data = $('response', data.responseXML); switch ($(data).find('status')[0].firstChild.data) { case 'accept': window.location.reload(); break; case 'decline': $("#chatMessage").text(invite_status_string.sp02); break; case 'deny': $("#chatMessage").text(invite_status_string.sp04); break; case 'waiting': $("#chatMessage").text(invite_status_string.sp01); //window.setTimeout('getChatInviteStatus()', 2000); break; case 'offline': $("#chatMessage").text(invite_status_string.sp03); break; } } function chatInviteNew(user_id) { $.ajax({ type: "GET", url: "/ajax-chat_invite.html?user_id=" + user_id + "&act=new", dataType: "xml", complete: getNewChatInvitesCallback}); } function chatInviteAccept(user_id) { $("#chat_invitations_box").hide('slow'); $("#chat_invitations_text").empty(); $.ajax({ type: "GET", url: "/ajax-chat_invite.html?user_id=" + user_id + "&act=accept", dataType: "xml", complete: getNewChatInvitesCallback}); openChatPrivate(user_id); } function chatInviteDecline(user_id) { $("#chat_invitations_box").hide('slow'); $("#chat_invitations_text").empty(); $.ajax({ type: "GET", url: "/ajax-chat_invite.html?user_id=" + user_id + "&act=decline", dataType: "xml", complete: getNewChatInvitesCallback}); } function chatInviteCancel(user_id) { $("#chat_invitations_box").hide('slow'); $("#chat_invitations_text").empty(); $.ajax({ type: "GET", url: "/ajax-chat_invite.html?user_id=" + user_id + "&act=cancel", dataType: "xml", complete: getNewChatInvitesCallback}); }