//**************************
//
//    EMOTICONS
//
//**************************

(function($){



$.extend({

                  smileMsg: function(msg){
            	   var msg;
            	   var imgOpenTag  = "<img src=\"images/emotions/";
            	   var imgCloseTag = "\" />";

                   /* WARNING: DO NOT RE-ARRANGE THE ORDER */
                  /* if you re-arrange the order, the order is not in the order anymore*/

                  msg = msg.replace(/\>\|/g,   imgOpenTag + "emoticon-angry.gif"    + imgCloseTag);

                  msg = msg.replace(/o:\)/ig,   imgOpenTag + "emoticon-19.gif"       + imgCloseTag);
            	   msg = msg.replace(/\(:\)/g,  imgOpenTag + "emoticon-love.gif"     + imgCloseTag);
            	   msg = msg.replace(/:\*/g,   imgOpenTag + "emoticons_pout.gif"    + imgCloseTag);
            	   msg = msg.replace(/\<:\)/g, imgOpenTag + "emoticons_party.gif"       + imgCloseTag);
                  msg = msg.replace(/\<:D/ig, imgOpenTag + "emoticons_clown.gif"       + imgCloseTag);
            	   msg = msg.replace(/:\)\)/g, imgOpenTag + "emoticon-11.gif"    + imgCloseTag);
                  msg = msg.replace(/:\)/ig,    imgOpenTag + "emoticon-smile.gif"    + imgCloseTag);
                  msg = msg.replace(/:-\)/ig,   imgOpenTag + "emoticon-smile.gif"    + imgCloseTag);
                  msg = msg.replace(/:\(\(/ig,    imgOpenTag + "emoticon-cry.gif"      + imgCloseTag);
           	      msg = msg.replace(/:\(/ig,    imgOpenTag + "emoticon-sad.gif"      + imgCloseTag);
            		msg = msg.replace(/:-\(/ig,   imgOpenTag + "emoticon-sad.gif"      + imgCloseTag);
            		msg = msg.replace(/;\)/ig,    imgOpenTag + "emoticon-wink.gif"     + imgCloseTag);
                  msg = msg.replace(/:dd/ig,   imgOpenTag + "emoticon-11.gif"       + imgCloseTag);
            		msg = msg.replace(/:D/ig,    imgOpenTag + "emoticon-laugh.gif"    + imgCloseTag);
                  msg = msg.replace(/:e/ig,    imgOpenTag + "emoticons_pout.gif"    + imgCloseTag);



                  msg = msg.replace(/\>\(\|/ig, imgOpenTag + "emoticon-cry.gif"      + imgCloseTag);


                  msg = msg.replace(/:\"\>/ig,   imgOpenTag + "emoticon-13.gif"       + imgCloseTag);
                  msg = msg.replace(/:ooo/ig, imgOpenTag + "emoticon-17.gif"       + imgCloseTag);
                  msg = msg.replace(/:oo/ig,   imgOpenTag + "emoticon-13.gif"       + imgCloseTag);
                  msg = msg.replace(/:o/ig,    imgOpenTag + "emoticon-surprise.gif" + imgCloseTag);
                  msg = msg.replace(/:P/ig,    imgOpenTag + "emoticon-tongue.gif"   + imgCloseTag);
                  msg = msg.replace(/:\>/ig,    imgOpenTag + "emoticon-tongue.gif"   + imgCloseTag);

                  msg = msg.replace(/o\//ig,    imgOpenTag + "emoticon-12.gif"       + imgCloseTag);
                  msg = msg.replace(/\>,/ig,    imgOpenTag + "emoticon-14.gif"       + imgCloseTag);
                  msg = msg.replace(/:\|/ig,    imgOpenTag + "emoticon-15.gif"       + imgCloseTag);
                  msg = msg.replace(/:B,/ig,    imgOpenTag + "emoticon-16.gif"       + imgCloseTag);
                  msg = msg.replace(/B-\)/ig,    imgOpenTag + "emoticon-16.gif"       + imgCloseTag);
                  msg = msg.replace(/B\)/ig,    imgOpenTag + "emoticon-16.gif"       + imgCloseTag);
                  msg = msg.replace(/:zz./ig,   imgOpenTag + "emoticon-18A.gif"      + imgCloseTag);
                  msg = msg.replace(/\)\)\(/ig, imgOpenTag + "emoticon-20.gif"       + imgCloseTag);
                  msg = msg.replace(/\>\>\<\)/ig, imgOpenTag + "emoticon-47.gif"       + imgCloseTag);
                  msg = msg.replace(/\(cU\)/ig, imgOpenTag + "emoticons_cheers.gif"       + imgCloseTag);
                  msg = msg.replace(/@};-/ig, imgOpenTag + "emoticons_rose.gif"       + imgCloseTag);
                  msg = msg.replace(/\(\+\)/ig, imgOpenTag + "emoticons_sick.gif"       + imgCloseTag);
                  return msg;
            	}

});


$.extend({
            popEmotikols : function(){

            var pop_content;
            pop_content = "";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon1\"><img src=\"images/emotions/emoticon-smile.gif\" alt=\"\" title=\"  :)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon2\"><img src=\"images/emotions/emoticon-wink.gif\" alt=\"\" title=\"  ;)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon3\"><img src=\"images/emotions/emoticon-sad.gif\" alt=\"\" title=\"  :(  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon4\"><img src=\"images/emotions/emoticon-laugh.gif\" alt=\"\" title=\"  :D  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon5\"><img src=\"images/emotions/emoticons_pout.gif\" alt=\"\" title=\"  :e  or  :*  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon6\"><img src=\"images/emotions/emoticon-love.gif\" alt=\"\" title=\"  (:)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon7\"><img src=\"images/emotions/emoticon-angry.gif\" alt=\"\" title=\"  >|  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon8\"><img src=\"images/emotions/emoticon-surprise.gif\" alt=\"\" title=\"  :o  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon9\"><img src=\"images/emotions/emoticon-tongue.gif\" alt=\"\" title=\"  :>  or  :P  \"></div>";

            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon10\"><img src=\"images/emotions/emoticon-cry.gif\" alt=\"\" title=\"  >(|  or  :((  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon11\"><img src=\"images/emotions/emoticon-11.gif\" alt=\"\" title=\"  :DD  or  :))  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon12\"><img src=\"images/emotions/emoticon-12.gif\" alt=\"\" title=\"  o/  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon13\"><img src=\"images/emotions/emoticon-13.gif\" alt=\"\" title=\"  :Oo  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon14\"><img src=\"images/emotions/emoticon-14.gif\" alt=\"\" title=\"  >,  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon15\"><img src=\"images/emotions/emoticon-15.gif\" alt=\"\" title=\"  :|  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon16\"><img src=\"images/emotions/emoticon-16.gif\" alt=\"\" title=\"  :B,  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon17\"><img src=\"images/emotions/emoticon-17.gif\" alt=\"\" title=\"  :OOo  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon18\"><img src=\"images/emotions/emoticon-18A.gif\" alt=\"\" title=\"  :Zz. \"></div>";

            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon19\"><img src=\"images/emotions/emoticon-19.gif\" alt=\"\" title=\"  o:)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon20\"><img src=\"images/emotions/emoticon-20.gif\" alt=\"\" title=\"  ))(  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon21\"><img src=\"images/emotions/emoticon-47.gif\" alt=\"\" title=\"  >><)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon22\"><img src=\"images/emotions/emoticons_party.gif\" alt=\"\" title=\"  <:)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon23\"><img src=\"images/emotions/emoticons_cheers.gif\" alt=\"\" title=\"  (cU)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon24\"><img src=\"images/emotions/emoticons_clown.gif\" alt=\"\" title=\"  <:D  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon25\"><img src=\"images/emotions/emoticons_sick.gif\" alt=\"\" title=\"  (+)  \"></div>";
            pop_content += "<div class=\"emo-wrap\" id=\"emoIcon26\"><img src=\"images/emotions/emoticons_rose.gif\" alt=\"\" title=\"  @};-  \"></div>";

           // alert(pop_content);

            $("#emotikols-icons").html(pop_content);
            $("#emotikols").fadeIn("fast");

             // EMOTIKOLS
      //
      // Notes:
      //
      // Do not use append to textarea just use this:
      // $("#message").val($("#message").val() + ":)");
      //
      // $.hideEmotikols(); is in the jquery.process.js

      $("#emoIcon1").click(function(){
               $("#message").val($("#message").val() + ":)");
               $("#emotikols").hide();
               $("#message").focus();
            });

            $("#emoIcon2").click(function(){
               $("#message").val($("#message").val() + ";)");
               $("#emotikols").hide();
               emo_toggle = 0;

               $("#message").focus();
            });

            $("#emoIcon3").click(function(){
               $("#message").val($("#message").val() + ":(");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon4").click(function(){
               $("#message").val($("#message").val() + ":D");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon5").click(function(){
               $("#message").val($("#message").val() + ":e");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon6").click(function(){
               $("#message").val($("#message").val() + "(:)");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon7").click(function(){
               $("#message").val($("#message").val() + ">|");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon8").click(function(){
               $("#message").val($("#message").val() + ":o");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon9").click(function(){
               $("#message").val($("#message").val() + ":>");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });


            $("#emoIcon10").click(function(){
               $("#message").val($("#message").val() + ">(|");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon11").click(function(){
               $("#message").val($("#message").val() + ":DD");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();

            });

            $("#emoIcon12").click(function(){
               $("#message").val($("#message").val() + "o/");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon13").click(function(){
               $("#message").val($("#message").val() + ":Oo");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon14").click(function(){
               $("#message").val($("#message").val() + "\>,");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon15").click(function(){
               $("#message").val($("#message").val() + ":|");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon16").click(function(){
               $("#message").val($("#message").val() + ":B,");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon17").click(function(){
               $("#message").val($("#message").val() + ":OOo");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon18").click(function(){
               $("#message").val($("#message").val() + ":Zz.");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon19").click(function(){
               $("#message").val($("#message").val() + "O:)");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon20").click(function(){
               $("#message").val($("#message").val() + "))(");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon21").click(function(){
               $("#message").val($("#message").val() + ">><)");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();

            });

            $("#emoIcon22").click(function(){
               $("#message").val($("#message").val() + "<:)");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon23").click(function(){
               $("#message").val($("#message").val() + "(cU)");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon24").click(function(){
               $("#message").val($("#message").val() + "<:D");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon25").click(function(){
               $("#message").val($("#message").val() + "(+)");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

            $("#emoIcon26").click(function(){
               $("#message").val($("#message").val() + "@};-");
               $("#emotikols").hide();
               emo_toggle = 0;
               $("#message").focus();
            });

 }

});


})(jQuery);
