$('a:contains(Sign Out)').after(" [Switch!]"); $('#switch_users').after("
"); $('#switch_users').click(function (e) { e.preventDefault ? e.preventDefault() : e.returnvalue = false; $('#switch_user').slideToggle(500); $('#switch_user_name').val(''); setTimeout(function () { $('#switch_user_name')[0].focus(); }, 600); }); $('#switch_user_sub').live('click', function (e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; $.get(main_url + 'login/logout', function (d) { $('#switch_status').text("Changing accounts..."); $.post(main_url + 'login/logout', { xc: $('input[name=xc]', d).val() }, function (d) { var name = $('#switch_user_name').val(); $('#switch_status').text("Logged out of " + $('#top_info strong').text() + "... trying to log in as " + name + "..."); $.post(main_url + 'login/log_in', { uname: name, pw: $('#switch_user_pass').val() }, function (d) { if ($('a:contains([Sign Out])', d).length) { $('#switch_status').text("Logged in as " + name + "! Reloading the page now."); setTimeout(function () { location.reload(); }, 1500); } else { $('#switch_status').text("Login failed. Please try again."); $('#switch_user_pass').val(''); } }); }); }); });