function emoticons(){this.icons=new Array();this.add=function(icon){this.icons.push(icon);};this.replace=function(message){for(var i=0;i<this.icons.length;i=i+1){var oldMessage=message;message=message.replace(this.icons[i].regex,"<span class='"+this.icons[i].id+"'></span><span>");if(oldMessage!=message){message=message+"</span>";}}return message;};this.getTable=function(inputText){this.inputText=inputText;var html='<div id="emoticons_selection">';html=html+'<div class="dropdown_menu">';var emoticonsArr=emoticons.icons;var nbCol=9;var nbLine=emoticonsArr.length/nbCol;var emoticonIndex=0;for(var lineIndex=0;lineIndex<nbLine;lineIndex=lineIndex+1){html=html+'<div class="dropdown_menu_row">';for(var colIndex=0;colIndex<nbCol;colIndex=colIndex+1){if(emoticonIndex<emoticonsArr.length){html=html+'<div class="emoticon_holder"><a href="javascript:emoticons.printIcon(\''+emoticonsArr[emoticonIndex].id+'\')" title="'+emoticonsArr[emoticonIndex].expression+'" class="'+emoticonsArr[emoticonIndex].id+'"></a></div>';}emoticonIndex=emoticonIndex+1;}html=html+'<br class="clear" />';html=html+"</div>";}html=html+"</div></div>";jQuery("#emoticonsTable").html(html);jQuery("#emoticonsTable").show();};this.printIcon=function(iconId){var text=jQuery(this.inputText).val();var textEl=jQuery(this.inputText).get(0);for(var i=0;i<this.icons.length;i=i+1){if(iconId==this.icons[i].id){var expression=this.icons[i].expression;if(textEl.selectionStart||textEl.selectionStart=="0"){textEl.focus();var cursorPosition=textEl.selectionStart;textBegin=text.substring(0,cursorPosition);textEnd=text.substring(cursorPosition);if(textEnd!=""){text=textBegin+" "+expression+textEnd;}else{text+=" "+expression;}jQuery(this.inputText).val(text);}else{textEl.focus();sel=document.selection.createRange();sel.text=" "+expression;}}}jQuery("#emoticonsTable").hide();};}function doGetCaretPosition(ctrl){var CaretPos=0;if(ctrl.selectionStart||ctrl.selectionStart=="0"){CaretPos=ctrl.selectionStart;}else{CaretPos=ctrl.value.length;}return(CaretPos);}function emoticon(labelEn,labelFr,regex,id,expression){this.labelEn=labelEn;this.labelFr=labelFr;this.regex=regex;this.id=id;this.expression=expression;}var emoticons=new emoticons();var icon=new emoticon("love","amour",/(<3:\)|&lt;3:\)|\[3:\))/g,"amour_2-04","[3:)");emoticons.add(icon);icon=new emoticon("blind love","amour aveugle",/(<3\)|&lt;3\)|\[3\))/g,"amour-aveugle_4-06","[3)");emoticons.add(icon);icon=new emoticon("smile","sourire",/(:\))/g,"sourire_3-01",":)");emoticons.add(icon);icon=new emoticon("smile with big eyes","sourire avec gros yeux",/(8-\))/g,"sourire_2-01","8-)");emoticons.add(icon);icon=new emoticon("annoyed++","agacé++",/(>:\(|&gt;:\()/g,"annoyed_2-03",">:(");emoticons.add(icon);icon=new emoticon("annoyed","agacé",/(>:-\(|&gt;:-\()/g,"annoyed_4-02",">:-(");emoticons.add(icon);icon=new emoticon("big smile big eyes","grand sourire gros yeux",/(8-D)/g,"big-smile-1_1-09","8-D");emoticons.add(icon);icon=new emoticon("nice teeth","belle dents",/(\|:D)/g,"belles-dents_3-06","|:D");emoticons.add(icon);icon=new emoticon("nice teeth","belle dents",/(B-D)/g,"belles-dents_4-04","B-D");emoticons.add(icon);icon=new emoticon("big smile","grand sourire",/(:D)/g,"big-smile_3-02",":D");emoticons.add(icon);icon=new emoticon("big smile 2","grand sourire 2",/(:-D)/g,"big-smile_3-08",":-D");emoticons.add(icon);icon=new emoticon("big smile 3","grand sourire 3",/(\|-D)/g,"big-smile_5-03","|-D");emoticons.add(icon);icon=new emoticon("wink","clin d'oeil",/(;\))/g,"wink_4-03",";)");emoticons.add(icon);icon=new emoticon("wink 2","clin d'oeil 2",/(;-\))/g,"wink_5-07",";-)");emoticons.add(icon);icon=new emoticon("surprise","surpris",/(8-O)/g,"surprise_4-05","8-O");emoticons.add(icon);icon=new emoticon("wince","grimace",/(:P)/g,"grimace_3-09",":P");emoticons.add(icon);icon=new emoticon("wince big eyes","grimace gros yeux",/(8-P)/g,"grimace_5-08","8-P");emoticons.add(icon);icon=new emoticon("crazy","fou",/(&amp;-P|&-P)/g,"fou_5-06","&-P");emoticons.add(icon);icon=new emoticon("hot","suffisant",/(\(H\))/g,"cool_4-01","(H)");emoticons.add(icon);icon=new emoticon("angry","colère",/(:@)/g,"angry_6-01",":@");emoticons.add(icon);icon=new emoticon("angry++","colère++",/(B-@)/g,"angry_6-02","B-@");emoticons.add(icon);icon=new emoticon("confused","confus",/(:S)/g,"confus_1-02",":S");emoticons.add(icon);icon=new emoticon("unhappy","malheureux",/(:\()/g,"malheureux-1_3-03",":(");emoticons.add(icon);icon=new emoticon("unhappy big eyes","malheureux gros yeux",/(8-\()/g,"malheureux-3_5-02","8-(");emoticons.add(icon);icon=new emoticon("disappointed","déçu",/(:L)/g,"disappointed_4-08",":L");emoticons.add(icon);icon=new emoticon("cry++","pleure++",/(;\'\()/g,"triste_1-06",";'(");emoticons.add(icon);icon=new emoticon("cry","pleure",/(:\'\()/g,"triste_5-09",":'(");emoticons.add(icon);icon=new emoticon("grumpy","grognon",/(:\|)/g,"grognon_1-04",":|");emoticons.add(icon);icon=new emoticon("bored","ennuyé",/(B-\|)/g,"bored_5-05","B-|");emoticons.add(icon);icon=new emoticon("afraid","apeuré",/(8o\|)/g,"peureux_1-03","8o|");emoticons.add(icon);icon=new emoticon("demon","démon",/(]8\|)/g,"demon_1-05","]8|");emoticons.add(icon);icon=new emoticon("pain","douleur",/(\|\'\,)/g,"pain_1-07","|',");emoticons.add(icon);icon=new emoticon("half-smile","sourire en coin",/(:\^\))/g,"half-smile_1-08",":^)");emoticons.add(icon);icon=new emoticon("half-smile++","sourire en coin++",/(:J)/g,"half-smile_5-04",":J");emoticons.add(icon);icon=new emoticon("half-smile big eyes","sourire en coin gros yeux",/(8\^\))/g,"half-smile_5-01","8^)");emoticons.add(icon);icon=new emoticon("angel","ange",/(O:-\))/g,"ange_2-02","O:-)");emoticons.add(icon);icon=new emoticon("puzzled","perplexe",/(8-\|)/g,"perplexe_2-05","8-|");emoticons.add(icon);icon=new emoticon("cry out loud","crise larmes",/(:\'@)/g,"crise-larmes_2-06",":'@");emoticons.add(icon);icon=new emoticon("whistle","siffle",/(:whistle)/g,"siffle_2-07",":whistle");emoticons.add(icon);icon=new emoticon("blink","cligner des yeux",/(\^_\^)/g,"blink_2-08","^_^");emoticons.add(icon);icon=new emoticon("blink big smile","clignement gros sourire",/(\^v\^)/g,"blink-big-smile_3-04","^v^");emoticons.add(icon);icon=new emoticon("kiss","bisou",/(:-\*)/g,"bisou_2-09",":-*");emoticons.add(icon);icon=new emoticon("sweat","sueur",/(:\'\|)/g,"sueur_3-05",":'|");emoticons.add(icon);icon=new emoticon("silenced","muselé",/(8-X)/g,"musele_3-07","8-X");emoticons.add(icon);icon=new emoticon("silenced 2","muselé 2",/(8-#)/g,"musele_4-09","8-#");emoticons.add(icon);icon=new emoticon("sleep","dormir",/(\(Z\))/g,"dodo_4-07","(Z)");emoticons.add(icon);icon=new emoticon("sick","malade",/(B-S)/g,"malade_6-03","B-S");emoticons.add(icon);icon=new emoticon("crazy sick","fou malade",/(B-Q)/g,"fou-malade_6-06","B-Q");emoticons.add(icon);icon=new emoticon("shy","gêné",/(8-\$)/g,"gene_6-04","8-$");emoticons.add(icon);icon=new emoticon("shy 2","gêné 2",/(:\$)/g,"gene_6-05",":$");emoticons.add(icon);
