// ==UserScript==
// @name          SoftPedia Extra Smilies
// @author        Ciuly  
// @namespace     http://www.ciuly.com
// @description   adds extra smilies
// @include       http://forum.softpedia.com/index.php?showtopic=*
// @include       http://forum.softpedia.com/index.php?act=post&do=reply_post&f=*&t=*
// @include       http://forum.softpedia.com/index.php?s=*&act=post&do=reply_post&f=*&t=*
// @include       http://forum.softpedia.com/index.php?act=Post&CODE=02&f=*&t=*&qpid=*
// @require       http://www.ciuly.com/greasemonkey/aa_all_common.user.js
// @require       http://www.ciuly.com/greasemonkey/aa_sp_common.user.js
// ==/UserScript==

(function(wnd){

  var table, tables, div, uid, text, forms, form, ak, s;

  wnd.ciuly_extra_smilies = function(){
    if (!wnd.ciuly_textarea.value)
      wnd.ciuly_textarea.value = document.getElementById("fast-reply_textarea");
    post = wnd.ciuly_textarea.value;
    post = post.replace(/:ploo:/gi,"[img]http://www.invision.smileyville.net/smilies/sad%20(11).gif[/img]");
    post = post.replace(/:tady:/gi,"[img]http://www.invision.smileyville.net/smilies/lnr%20(54).gif[/img]");
    post = post.replace(/:chuck:/gi,"[img]http://forum.softpedia.com/uploads/monthly_06_2008/post-15661-1213355426.gif[/img]");
    wnd.ciuly_textarea.value = post;
 }

  forms = document.body.getElementsByTagName("form");
  for (var j=0; j<forms.length; j++){
    form = forms.item(j);
    if ( form.name == "REPLIER" ) {
      if (form.id != "" && form.id != "postingform")
        continue;
      found = false;
      for (var l=0; l<form.elements.length; l++){
        if (form.elements[l].name == "submit" || form.elements[l].name == "dosubmit"){
          if (wnd.is_opera)
            form.elements[l].onclick = wnd.ciuly_extra_smilies;
	  else{
//            form.elements[l].addEventListener("Click", wnd.ciuly_extra_smilies, true);
            form.elements[l].setAttribute("onClick", "ciuly_extra_smilies()");
	  }
	  found = true;
        }
        if (form.elements[l].name == "Post"){
          wnd.ciuly_textarea = form.elements[l];
        }
      }
      if (found == true)
        break;
    }
  }

})(window.wrappedJSObject || window);