');
}
$ak_prototype = true;
}
}
}
function wp_grins_head() {
print(''."\n");
ak_prototype();
print('
');
}
function wp_grins_js() {
if (function_exists('wp_enqueue_script')) {
wp_enqueue_script('prototype');
}
if (isset($_GET['ak_action']) && $_GET['ak_action'] == 'wp_grins_js') {
global $wpsmiliestrans;
header("Content-type: text/javascript");
$grins = '';
$smiled = array();
foreach ($wpsmiliestrans as $tag => $grin) {
if (!in_array($grin, $smiled)) {
$smiled[] = $grin;
$tag = str_replace(' ', '', $tag);
$grins .= '
';
}
}
?>
function insertAfter(node, referenceNode) {
referenceNode.parentNode.insertBefore(node, referenceNode.nextSibling);
}
function loadGrins() {
var grinsDiv = document.createElement('div');
grinsDiv.id = 'wp_grins';
grinsDiv.innerHTML = '';
if ($('postdiv')) {
var type = 'child';
var node = $('postdiv');
}
else if (document.getElementById('postdivrich')) {
var type = 'child';
var node = $('postdivrich');
}
else if (document.getElementById('comment')) {
var type = 'before';
var node = $('comment');
}
else {
return;
}
switch (type) {
case 'child':
grinsDiv.style.paddingTop = '5px';
node.appendChild(grinsDiv);
break;
case 'before':
node.parentNode.insertBefore(grinsDiv, node);
break;
}
}
Event.observe(window, 'load', loadGrins, false);
function grin(tag) {
var myField;
if ($('content') && $('content').type == 'textarea') {
myField = document.getElementById('content');
if ($('postdivrich') && typeof tinyMCE != 'undefined' && (!$('edButtons') || $('quicktags').style.display == 'none')) {
tinyMCE.execInstanceCommand('mce_editor_0', 'mceInsertContent', false, ' ' + tag + ' ');
tinyMCE.selectedInstance.repaint();
return;
}
}
else if ($('comment') && $('comment').type == 'textarea') {
myField = $('comment');
}
else {
return false;
}
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = ' ' + tag + ' ';
myField.focus();
}
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
var cursorPos = endPos;
myField.value = myField.value.substring(0, startPos)
+ ' ' + tag + ' '
+ myField.value.substring(endPos, myField.value.length);
cursorPos += tag.length + 2;
myField.focus();
myField.selectionStart = cursorPos;
myField.selectionEnd = cursorPos;
}
else {
myField.value += tag;
myField.focus();
}
}