// dibuat oleh penulis blogmenjerit (http://blogmenjerit.blogspot.com/)
//diedit oleh http://topotato.com
//setinggi2 penghargaan kepada upindanipin.com.my

// FEATURES
// Works only in Compose modes
// Add the emoticons at the end of the text

// TODO
// modify the script to insert the emoticon directly after the cursor

// ==UserScript==
// @name           upin dan ipin smiley
// @namespace      http://blogmenjerit.blogspot.com
//
// ==/UserScript==

window.addEventListener("load", function(e) {


function setemoticons(domname) 
{
var editbar = document.getElementById(domname);
  if (editbar) {

    var buttons = "<br />";
	buttons += emoticonButton("@upin01", "http://i299.photobucket.com/albums/mm312/topotato/upin01.gif");
	buttons += emoticonButton("@upin02", "http://i299.photobucket.com/albums/mm312/topotato/upin02.gif");
	buttons += emoticonButton("@ipin01", "http://i299.photobucket.com/albums/mm312/topotato/ipin01.gif");
	buttons += emoticonButton("@ipin02", "http://i299.photobucket.com/albums/mm312/topotato/ipin02.gif");
	buttons += emoticonButton("@kakros01", "http://i299.photobucket.com/albums/mm312/topotato/kakros01.gif");
	buttons += emoticonButton("@kakros02", "http://i299.photobucket.com/albums/mm312/topotato/kakros02.gif");
	buttons += emoticonButton("@mail01", "http://i299.photobucket.com/albums/mm312/topotato/mail01.gif");
	buttons += emoticonButton("@ehsan01", "http://i299.photobucket.com/albums/mm312/topotato/ehsan01.gif");
	buttons += emoticonButton("@ehsan02", "http://i299.photobucket.com/albums/mm312/topotato/ehsan02.gif");
	buttons += emoticonButton("@fizi01", "http://i299.photobucket.com/albums/mm312/topotato/fizi01.gif");
	



	
    buttons += separator();

    editbar.innerHTML += buttons;
  }
}


function emoticonButton(name, url) {
  return "<span class='' style='display: block;' id='htmlbar_undefined' title='" + name + "' onmouseover='ButtonHoverOn(this);' onmouseout='ButtonHoverOff(this);' onmouseup='' onmousedown='CheckFormatting(event);(function() {var rich_edit = document.getElementById(\"richeditorframe\");var rich_body = rich_edit.contentDocument.getElementsByTagName(\"body\");rich_body[0].innerHTML+=\"<img  class=\\\"emoticon\\\"  src=\\\""+url+"\\\" alt=\\\"" + name + "\\\" title=\\\"" + name + "\\\" />\";})();ButtonMouseDown(this);'><img src='" + url + "' alt='" + name + "' border='0'></span>\n";
}

function separator() {
  return "<div style=\"display: block;\" class=\"vertbar\"><span style=\"display: block;\" class=\"g\">&nbsp;</span><span style=\"display: block;\" class=\"w\">&nbsp;</span></div>\n";
}

setemoticons("formatbar");

 }, false);