// Gator functions var GATOR = { switch_tab: function(p) { var i, e, t; if (typeof(p) == 'string') { show_panel = p; } var panels = $$('.panels'); for (i=0; i 3) { if (GATOR._postTimer) { clearTimeout(GATOR._postTimer); } GATOR._postTimer = setTimeout('GATOR.request_post();', 500); } else { $('post_message').update(''); } }, request_post: function () { var s = ''; var m = ''; if ($('post_subject')) { s = $F('subject'); } if ($('post_message')) { m = $F('message'); } if (m) { new Ajax.Request(root_path+'ajax/preview.php',{ method: 'post', parameters: { mode: 'body', subject: s, message: m } }) } }, update_subject: function (s) { if ($('post_subject')) { $('post_subject').update(s); if (s) { $('post_subject').show(); } else { $('post_subject').hide(); } } }, update_post: function (s) { if ($('post_message')) { $('post_message').update(s); } }, get_coords: function (event, id) { var y; // avoid the annoying scroll issue if (typeof(window.pageYOffset) == 'number') { y = window.pageYOffset; } else if (document.body && (document.body.scrollTop)) { y = document.body.scrollTop; } else if (document.documentElement && (document.documentElement.scrollTop)) { y = document.body.scrollTop; } var textarea = $('message'); var theSelection = false; textarea.focus(); var t = parseInt($(id).style.top); var l = parseInt($(id).style.left); var caret_pos = getCaretPosition(textarea).start; // Center the cursor when we don't have a selection // Gecko and proper browsers if (!isNaN(textarea.selectionStart)) { var scrollTop = textarea.scrollTop; textarea.value = textarea.value.replace('='+$(id).t+','+$(id).l+',','='+t+','+l+','); textarea.selectionStart = caret_pos; textarea.selectionEnd = caret_pos; textarea.scrollTop = scrollTop; } // IE else if (document.selection) { var range = textarea.createTextRange(); range.move("character", caret_pos); textarea.value = textarea.value.replace('='+$(id).t+','+$(id).l+',','='+t+','+l+','); range.select(); storeCaret(textarea); } $(id).t = t; $(id).l = l; textarea.focus(); if (document.body && (document.body.scrollTop)) { document.body.scrollTop = y; } else if (document.documentElement && (document.documentElement.scrollTop)) { document.documentElement.scrollTop = y; } return; // prevent 'clicking' Event.stop(event); } };