// Main script for the mig33 AJAX app // Include other files document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); window.onresize = calcPageWidthAndHeight; // Global variables var server = 'http://www.mig33.com'; var ajaxServer; var imageServer = 'http://img.mig33.com'; var pollInterval = 2000; // In milliseconds var sessionId; var browser = new Browser(); var topMenu, loggingInPanel, mailPanel; var winContactList, winMyProfile, winEditProfile, winScrapbook, winEmail, winCommunity, winAccount, winAffiliates; var pageWidth = 0, pageHeight = 0; var cursorX, cursorY; var username; var ajaxRequest; var contactListTree; var contactGroups; var contacts; var receivedInitialContactList = false; var allowEmail = false; var contactList, otherIMsButton; var contactSubmenu, contactGroupSubmenu, moveToGroupSubmenu, otherIMSubmenu, chatroomsMenu; var chatWindowSubmenu = null; // The menu presented when the user clicks "Kick User", "Private Chat" etc in a chatroom var msnSignedIn = false, yahooSignedIn = false, aimSignedIn = false, gtalkSignedIn = false; var nextWindowPos = { x: 0, y: 0 }; var windows = new Object(); // Stores references to all of the windows we create var menuData = [ { text: "mig33", submenu: { id: "menu_mig33", itemdata: [ { text: "mig33 Home", url: "/", target: "_blank" }, { text: "About mig33", url: "/about_mig33/", target: "_blank" }, { text: "Merchants", url: "/merch/", target: "_blank" } ] } }, { text: "Me", id: "menu_me", submenu: { id: "menu_me_submenu", itemdata: [ { text: "My Profile", url: "javascript:showMyProfile();" }, { text: "Scrapbook", url: "javascript:showScrapbook();" } ] } }, { text: "Community", submenu: { id: "menu_community", itemdata: [ [ { text: "Browse", url: "javascript:showBrowseProfiles();" }, { text: "Search", url: "javascript:showSearchProfiles();" } ], [ { text: "Invite Friend", url: "javascript:showInviteFriend();" }, ] ] } }, { text: "Connect", submenu: { id: "menu_connect", itemdata: [ { text: "Call", url: "javascript:showCallback('');" }, { text: "SMS", url: "javascript:showSendSMS('');" }, { text: "Email", url: "javascript:showSendEmail('');" } ] } }, { text: "Account & Preferences", submenu: { id: "menu_account", itemdata: [ [ { text: "My Details", url: "javascript:showMyDetails();" }, { text: "Change Password", url: "javascript:showChangePassword();" } ], [ { text: "Recharge", url: "javascript:showRecharge();" }, { text: "Transfer Credit", url: "javascript:showTransferCredit();" } ], [ { text: "Account History", url: "javascript:showAccountHistory();" }, { text: "Call History", url: "javascript:showCallHistory();" }, { text: "SMS History", url: "javascript:showSMSHistory();" } ] ] } }, { text: "Help", submenu: { id: "menu_help", itemdata: [ { text: "Help Contents", url: "http://info.mig33.com/support", target: "_blank" }, { text: "FAQs", url: "http://info.mig33.com/support", target: "_blank" }, { text: "Contact Us", url: "javascript:showContactUs();" } ] } }, { text: "Log Out", submenu: { id: "menu_logout", itemdata: [ { text: "Log out of mig33", url: "javascript:logout();" } ] } } ]; function mig33_init() { if (browser.isIE) { ajaxServer = server + ':8080/'; } else { ajaxServer = server + '/xml/'; } calcPageWidthAndHeight(); contactGroups = new Dictionary(); contacts = new Dictionary(); username = readCookie('ajaxu'); loggingInPanel = new YAHOO.widget.Panel("wait", { width:"240px", fixedcenter:true, close:false, draggable:false, modal:true, visible:false } ); loggingInPanel.setHeader("Connecting..."); loggingInPanel.setBody(''); loggingInPanel.render(document.body); // Keep track of the cursor location, only Netscape requires the // captureEvents() method to capture events outside of its intended target. if (navigator.appName == "Netscape" && window.Event) { document.addEventListener("mousemove", getCursorXY, false); } document.onmousemove = getCursorXY; window.setTimeout('login()', 1000); } function showMenuBar() { if (!topMenu) { var topMenu = new YAHOO.widget.MenuBar("menubar", { lazyload: true, showDelay: 0, itemdata: menuData }); topMenu.render('topmenucontainer'); topMenu.bringToTop(); } document.getElementById('logo').style.visibility = 'visible'; } function hideMenuBar() { topMenu.destroy(); topMenu = null; } function getCursorXY(e) { // And IE do not support event. cursorX = (navigator.appName == "Netscape" && window.Event) ? e.pageX : event.clientX; cursorY = (navigator.appName == "Netscape" && window.Event) ? e.pageY : event.clientY; } function startLoggingInDisplay() { loggingInPanel.show(); } function stopLoggingInDisplay() { loggingInPanel.hide(); } function showDefaultWindows() { winContactList.setScreenPosition(pageWidth - 255, 40); winContactList.show(); contactListWindowResized(); showScrapbook(); showMyProfile(); } function calculateNextWindowPos(width, height) { if (nextWindowPos.x == 0) { nextWindowPos.x = 20; nextWindowPos.y = 40; } else if (nextWindowPos.x + 30 + width > pageWidth || nextWindowPos.y + 30 + height > pageHeight) { nextWindowPos.x = 20; nextWindowPos.y = 40; } else { nextWindowPos.x += 30; nextWindowPos.y += 30; } } function iframeWindowClicked(win_id) { if (windows[win_id]) windows[win_id].activate(); } function showSendEmail(destination) { if (!allowEmail) { alert("Email is temporarily unavailable. Please try again soon"); return; } calculateNextWindowPos(500, 350); var winId = 'send_email_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 450, left: nextWindowPos.x, top: nextWindowPos.y, title: 'mig33 Email', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/mail_compose.php?win_id=' + winId + '&to=' + destination, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showEmail() { if (!allowEmail) { alert("Email is temporarily unavailable. Please try again soon"); return; } if (winEmail != null) { winEmail.restore(); winEmail.activate(); } else { calculateNextWindowPos(500, 350); winEmail = Zapatec.Window.setup({ width: 650, height: 525, left: nextWindowPos.x, top: nextWindowPos.y, raiseOnlyOnTitle: false, title: 'mig33 Email', theme: 'mig33', showStatus: false, iframeContent: false, urlContent : '/members/mail_main.php?win_id=win_mail', eventListeners : { onClose: function() { winEmail = null; windows['win_mail'] = null; }, onResize: mailWindowResized, onRestore: mailWindowResized, //onShow : mailShow, onMaximize: mailWindowMax }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); nextWindowPos.x = 90; nextWindowPos.y = 110; windows['win_mail'] = winEmail; } } function showEmailView(url, winTitle) { calculateNextWindowPos(220, 250); var winId = 'emailview_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 550, height: 550, left: nextWindowPos.x, top: nextWindowPos.y, title: winTitle, theme: 'mig33', showStatus: false, iframeContent: true, urlContent: url + '&win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showMyProfile() { if (winMyProfile != null) { winMyProfile.restore(); winMyProfile.activate(); } else { winMyProfile = Zapatec.Window.setup({ width: 510, height: 500, left: 90, top: 110, raiseOnlyOnTitle: false, title: 'My Profile', theme: 'mig33', showStatus: false, iframeContent: true, onClose: function() { winMyProfile = null; windows['my_profile'] = null; }, urlContent : '/members/my_profile.php?win_id=my_profile', limit : { minY: 23, minWidth: 125, minHeight: 125 } }); nextWindowPos.x = 90; nextWindowPos.y = 110; windows['my_profile'] = winMyProfile; } } function showScrapbook() { if (winScrapbook != null) { winScrapbook.win.restore(); winScrapbook.win.activate(); } else { winScrapbook = new ScrapbookWindow(); } } function showBrowseProfiles() { calculateNextWindowPos(520, 500); var winId = 'browse_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 520, height: 500, left: nextWindowPos.x, top: nextWindowPos.y, title: 'mig33 Community', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/community.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showSearchProfiles(queryString) { calculateNextWindowPos(500, 350); var winId = 'search_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 400, left: nextWindowPos.x, top: nextWindowPos.y, title: 'mig33 Community', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/search_profiles.php?win_id=' + winId + '&' + queryString, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showUserProfile(username) { calculateNextWindowPos(515, 425); var winId = 'user_profile_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 510, height: 500, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Profile of ' + username, theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/view_profile.php?win_id=' + winId + '&username=' + username, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showPublicPhotos(username) { calculateNextWindowPos(510, 425); var winId = 'public_photos_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 510, height: 425, left: nextWindowPos.x, top: nextWindowPos.y, title: username + "'s Photos", theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/view_public_photos.php?win_id=' + winId + '&username=' + username, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showMyDetails() { calculateNextWindowPos(500, 350); var winId = 'my_details_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'My Account Details', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/account_details.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showEditProfile() { if (winEditProfile != null) { winEditProfile.restore(); winEditProfile.activate(); } else { calculateNextWindowPos(500, 550); var winId = 'edit_profile'; winEditProfile = Zapatec.Window.setup({ width: 500, height: 550, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Edit Profile', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/edit_profile.php?win_id=' + winId, onClose: function() { winEditProfile = null; windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = winEditProfile; } } function showScrapbookPhoto(owner, scrapbook_id) { calculateNextWindowPos(420, 360); var winId = 'scrapbook_photo_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 420, height: 360, left: nextWindowPos.x, top: nextWindowPos.y, title: owner + "'s Photo", theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/view_scrapbook_photo.php?win_id=' + winId + '&scrapbook_id=' + scrapbook_id, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showPhoto(owner, file_id) { calculateNextWindowPos(420, 350); var winId = 'photo_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 420, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: owner + "'s Photo", theme: 'mig33', showStatus: false, iframeContent: true, //urlContent : '/members/view_photo.php?original=1&win_id=' + winId + '&file_id=' + file_id + '&owner=' + owner, urlContent : '/sites/index.php?c=photos&v=ajax&a=received&original=1&win_id=' + winId + '&nid=' + file_id + '&sender=' + owner, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showWallImage(username, file_id, description, country, date_created, original_width, original_height) { calculateNextWindowPos(420, 360); var winId = 'wall_image_' + Math.floor(Math.random() * 10001); description = description.replace(/\x26/, '%26'); var win = Zapatec.Window.setup({ width: 420, height: 360, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Posted by ' + username, theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/wall.php?win_id=' + winId + '&image_id=' + file_id + '&username=' + username + '&description=' + description + '&country=' + country + '&date_created=' + date_created + '&originalwidth=' + original_width + '&originalheight=' + original_height, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showUploadPhoto() { calculateNextWindowPos(420, 350); var winId = 'upload_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 420, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: "Upload a Photo", theme: 'mig33', showStatus: false, iframeContent: true, urlContent: '/members/upload_photo.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showAccountHistory() { calculateNextWindowPos(570, 400); var winId = 'account_history_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 570, height: 400, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Account History', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/account_history.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showCallHistory() { calculateNextWindowPos(500, 350); var winId = 'call_history_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Call History', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/call_history.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showSMSHistory() { calculateNextWindowPos(500, 350); var winId = 'call_history_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'SMS History', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/sms_history.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showRecharge() { calculateNextWindowPos(570, 550); var winId = 'recharge_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 620, height: 550, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Recharge', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/recharge.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showTransferCredit() { calculateNextWindowPos(500, 350); var winId = 'transfer_credit_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Transfer Credit', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/transfer_credit.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showChangePassword() { calculateNextWindowPos(500, 350); var winId = 'change_pwd_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Change Password', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/change_password.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showCallback(destination) { calculateNextWindowPos(500, 350); var winId = 'callback_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Create a Callback', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/call.php?win_id=' + winId + '&callDestination=' + destination, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showVoIPToolbarCall() { calculateNextWindowPos(500, 350); var winId = 'voip_toolbar_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'VoIP Toolbar', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/voip_toolbar.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showSendSMS(destination) { calculateNextWindowPos(500, 350); var winId = 'send_sms_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Send an SMS', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/sms_send.php?win_id=' + winId + '&to=' + destination, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showInviteFriend() { calculateNextWindowPos(380, 280); var winId = 'invite_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 380, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Invite a Friend', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/refer_friend.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showWall() { calculateNextWindowPos(520, 600); var winId = 'wall_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 520, height: 600, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Photo Wall', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/wall.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showHelp() { calculateNextWindowPos(500, 350); var winId = 'help_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Help', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/help.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showFAQs() { calculateNextWindowPos(500, 350); var winId = 'faqs_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'FAQs', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/faqs.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showAbout() { calculateNextWindowPos(500, 350); var winId = 'about_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'About mig33', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/about.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showContactUs() { calculateNextWindowPos(200, 100); var winId = 'contact_us_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 550, left: nextWindowPos.x, top: nextWindowPos.y, title: 'Contact Us', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/contact_us.php?win_id=' + winId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showBuzz(destination, cid) { calculateNextWindowPos(500, 350); var winId = 'buzz_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'mig33 Buzz', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/buzz_contact.php?win_id=' + winId + '&to=' + destination + '&cid=' + cid, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showLookout(destination, cid) { calculateNextWindowPos(500, 350); var winId = 'lookout_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 350, left: nextWindowPos.x, top: nextWindowPos.y, title: 'mig33 Lookout', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/lookout_contact.php?win_id=' + winId + '&to=' + destination + '&cid=' + cid, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function showReportAbuse(type, offender, subject, subjectId) { calculateNextWindowPos(500, 350); var winId = 'report_abuse_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 500, height: 370, left: nextWindowPos.x, top: nextWindowPos.y, title: 'mig33 Lookout', theme: 'mig33', showStatus: false, iframeContent: true, urlContent : '/members/report_abuse.php?win_id=' + winId + '&type=' + type + '&offender=' + offender + '&subject=' + subject + '&subjectid=' + subjectId, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function reloadMyProfile() { if (winMyProfile != null) { winMyProfile.setContentUrl('/members/my_profile.php?win_id=my_profile'); } } function showLoginMessageWindow(url) { calculateNextWindowPos(350, 350); var winId = 'loginMessage_' + Math.floor(Math.random() * 10001); var win = Zapatec.Window.setup({ width: 400, height: 420, left: nextWindowPos.x, top: nextWindowPos.y, title: "Login Message from mig33", theme: 'mig33', showStatus: false, iframeContent: true, urlContent : url, onClose: function() { windows[winId] = null; }, limit : { minY: 23, minWidth: 125, minHeight: 125 } }); windows[winId] = win; } function closeWindow(id) { var win = windows[id]; if (win) { win.close(); windows[id] = null; } } function mig33_final() { return; // Log out var packet = new fusionPacket(300); packet.size = 0; sendPacket(packet); } // Browser detection function Browser() { var ua, s, i; this.isIE = false; // Internet Explorer this.isNS = false; // Netscape this.isOpera = false; // Opera this.version = null; this.useABlur=true; ua = navigator.userAgent; s = "MSIE"; if ((i = ua.indexOf(s)) >= 0) { this.isIE = true; this.useABlur=false; this.version = parseFloat(ua.substr(i + s.length)); return; } s = "Netscape6/"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = parseFloat(ua.substr(i + s.length)); return; } // Treat any other "Gecko" browser as NS 6.1. s = "Gecko"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = 6.1; return; } s = "Opera/"; if ((i = ua.indexOf(s)) >= 0) { this.isOpera = true; this.version = parseFloat(ua.substr(i + s.length)); return; } } function calcPageWidthAndHeight() { if (typeof(window.innerWidth) == 'number' ) { //Non-IE pageWidth = window.innerWidth; pageHeight = window.innerHeight; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { //IE 6+ in 'standards compliant mode' pageWidth = document.documentElement.clientWidth; pageHeight = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { //IE 4 compatible pageWidth = document.body.clientWidth; pageHeight = document.body.clientHeight; } } function removeChildNodes(node) { while (node.childNodes.length >= 1) { node.removeChild(node.firstChild); } } function addOnBlur(frame,func,param) { var emptyA = document.createElement('A'); frame.appendChild(emptyA); var blurFrame=browser.useABlur?emptyA:frame; blurFrame.focus(); if (param) blurFrame.onblur = func(param); else blurFrame.onblur = func; } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; } function removeNodeFromParent(node) { if (node == null) return; if(browser.isIE) { node.removeNode(true); } else { if(node.parentNode!=undefined) { node.parentNode.removeChild(node); } } } function deselect() { if (window.getSelection) window.getSelection().removeAllRanges(); else if (document.selection) document.selection.empty(); } function delayedFunction(func) { if(browser.isNS) { eval("setTimeout("+func+",250);"); } else { eval(func+"()"); } } function logout(checkSession) { logoutPanel = new YAHOO.widget.Panel("wait", { width:"240px", fixedcenter:true, close:false, draggable:false, modal:true, visible:true, zIndex:99999 } ); logoutPanel.setHeader("Logging out..."); logoutPanel.setBody(''); logoutPanel.bringToTop(); logoutPanel.render(document.body); // Send a log out packet var packet = new fusionPacket(300); packet.size = 0; sendPacket(packet, null, null, checkSession); // send a checkSession flag for immediate logout setTimeout( finishLogout, 3000 ); // Wait 3 seconds to ensure the packet gets sent } function finishLogout() { // Redirect to the logout page window.location = '/'; } function removeChildrenFromNode(node) { if (!node) return; while (node.hasChildNodes()) { node.removeChild(node.firstChild); } } function findPosX(obj) { var curleft = 0; if(obj.offsetParent) while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if(obj.offsetParent) while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.y) curtop += obj.y; return curtop; } /** * Before every request to the server, check current username against current cookie user param * (uajax) The server allows users to login with two different user names in the same browser; * we want to be sure only one user is active at a time. Last login wins. * * function compareUserNames * @param string username The username captured from the cookie on initial login of the session */ function compareUserNames(username) { cookie_username = readCookie('ajaxu'); if(username != cookie_username) your_screwed_logout(); // emergency log out current session } /** * If the system detects a new user has logged into the same browser with a different user name * log out the current user session, with a warning message about what is happening. * * function your_screwed_logout */ function your_screwed_logout() { var logoutMessage = "This mig33 session will now be closed, because a different user login in the same browser has been detected."; clearInterval(pollingId); // STOP POLLING var handleOk = function() { this.hide(); logout("noCheck"); // normal logout with NO SESSION CHECKING }; // Instantiate the Dialog YAHOO.example.container.simpledialog1 = new YAHOO.widget.SimpleDialog("simpledialog1", { width: "300px", fixedcenter: true, visible: true, draggable: false, close: false, modal: true, text: logoutMessage, constraintoviewport: true, zIndex:99999, buttons: [ { text:"OK", handler:handleOk, isDefault:true } ] } ); YAHOO.example.container.simpledialog1.setHeader("Second User Login Detected"); // Render the Dialog YAHOO.example.container.simpledialog1.render("container"); } function mailWindowMax() { if (browser.isIE) { var winWidth = winEmail.getWidth() - 172; var wEmHi = winEmail.getHeight(); var frameHeight = wEmHi - 59; var winHeight = wEmHi - 69; winEmail.container.document.getElementById('mailWin').height = winHeight; winEmail.container.document.getElementById('mailWin').width = winWidth; winEmail.container.document.getElementById('mailDiv').style.height = frameHeight + 'px'; } else { var wEmHi = winEmail.getHeight(); var winHeight = wEmHi - 69; var frameHeight = wEmHi - 49; var winWidth = winEmail.getWidth() - 155; // adjust the height of the div framing the iframe winEmail.container.ownerDocument.getElementById('mailDiv').style.height = frameHeight + 'px'; // adjust the height of the iframe winEmail.container.ownerDocument.getElementById('mailWin').height = winHeight; winEmail.container.ownerDocument.getElementById('mailWin').width = winWidth; } } function mailWindowResized() { if (browser.isIE) { var winWidth = winEmail.getWidth() - 168; var wEmHi = winEmail.getHeight(); var frameHeight = wEmHi - 38; var winHeight = wEmHi - 50; winEmail.container.document.getElementById('mailWin').height = winHeight; winEmail.container.document.getElementById('mailWin').width = winWidth; winEmail.container.document.getElementById('mailDiv').style.height = frameHeight + 'px'; } else { var wEmHi = winEmail.getHeight(); var winHeight = wEmHi - 47; var frameHeight = wEmHi - 27; var winWidth = winEmail.getWidth() - 158; // adjust the height of the div framing the iframe winEmail.container.ownerDocument.getElementById('mailDiv').style.height = frameHeight + 'px'; // adjust the height of the iframe winEmail.container.ownerDocument.getElementById('mailWin').height = winHeight; winEmail.container.ownerDocument.getElementById('mailWin').width = winWidth; } } function mailShow() { if (!browser.isIE) { winEmail.container.ownerDocument.getElementById('mailDiv').style.height = '498px'; winEmail.container.ownerDocument.getElementById('mailWin').style.left = '140px'; winEmail.container.ownerDocument.getElementById('mailWin').height = '478px'; winEmail.container.ownerDocument.getElementById('mailWin').width = '495px'; } }