radiant-forum-extension 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/README.md +37 -56
  2. data/VERSION +1 -1
  3. data/app/controllers/forum_base_controller.rb +78 -0
  4. data/app/controllers/forums_controller.rb +5 -34
  5. data/app/controllers/posts_controller.rb +61 -153
  6. data/app/controllers/topics_controller.rb +6 -63
  7. data/app/helpers/forum_helper.rb +24 -48
  8. data/app/models/forum.rb +5 -18
  9. data/app/models/post.rb +53 -55
  10. data/app/models/post_attachment.rb +9 -6
  11. data/app/models/topic.rb +20 -113
  12. data/app/views/admin/reader_configuration/_edit_forum.html.haml +4 -2
  13. data/app/views/admin/reader_configuration/_forum.html.haml +6 -2
  14. data/app/views/forums/_forum.html.haml +14 -20
  15. data/app/views/forums/_latest.html.haml +12 -0
  16. data/app/views/forums/_standard_parts.html.haml +49 -0
  17. data/app/views/forums/index.html.haml +16 -24
  18. data/app/views/forums/show.html.haml +18 -28
  19. data/app/views/pages/_comment.html.haml +1 -1
  20. data/app/views/posts/_attachments.html.haml +13 -0
  21. data/app/views/posts/_confirm_delete.html.haml +10 -0
  22. data/app/views/posts/_context.html.haml +16 -0
  23. data/app/views/posts/_edit_links.html.haml +11 -0
  24. data/app/views/posts/_form.html.haml +40 -2
  25. data/app/views/posts/_latest.html.haml +10 -17
  26. data/app/views/posts/_new_attachment.html.haml +2 -0
  27. data/app/views/posts/_post.html.haml +25 -60
  28. data/app/views/posts/{_search.html.haml → _search_form.html.haml} +1 -1
  29. data/app/views/posts/_uploader.html.haml +2 -2
  30. data/app/views/posts/edit.html.haml +26 -13
  31. data/app/views/posts/index.html.haml +19 -27
  32. data/app/views/posts/new.html.haml +27 -7
  33. data/app/views/posts/remove.html.haml +27 -0
  34. data/app/views/posts/show.html.haml +20 -7
  35. data/app/views/readers/_forum_messages.html.haml +20 -0
  36. data/app/views/readers/_messages_summary.html.haml +3 -0
  37. data/app/views/topics/_context.html.haml +12 -0
  38. data/app/views/topics/_latest.html.haml +14 -16
  39. data/app/views/topics/_locked.html.haml +1 -1
  40. data/app/views/topics/_replies.html.haml +6 -0
  41. data/app/views/topics/_reply.html.haml +23 -0
  42. data/app/views/topics/_topic.html.haml +14 -43
  43. data/app/views/topics/_voices.html.haml +5 -0
  44. data/app/views/topics/index.html.haml +11 -24
  45. data/app/views/topics/show.html.haml +25 -38
  46. data/config/initializers/radiant_config.rb +5 -1
  47. data/config/locales/en.yml +73 -27
  48. data/config/routes.rb +3 -4
  49. data/db/migrate/20101222160900_page_posts.rb +21 -0
  50. data/db/migrate/20101222163605_no_comment_forum.rb +10 -0
  51. data/db/migrate/20110105103827_topic_merely_associative.rb +23 -0
  52. data/db/migrate/20110111080550_detach_observer.rb +11 -0
  53. data/db/migrate/20110127113852_import_attachments.rb +9 -0
  54. data/forum_extension.rb +12 -13
  55. data/lib/commentable_model.rb +98 -0
  56. data/lib/forum_page.rb +2 -22
  57. data/lib/forum_reader_sessions_controller.rb +14 -0
  58. data/lib/forum_readers_controller.rb +2 -9
  59. data/lib/forum_red_cloth3.rb +23 -4
  60. data/lib/forum_red_cloth4.rb +23 -4
  61. data/lib/forum_tags.rb +298 -194
  62. data/lib/sanitize/config/forum.rb +47 -0
  63. data/public/images/furniture/blank.png +0 -0
  64. data/public/images/furniture/emoticons.png +0 -0
  65. data/public/javascripts/forum.js +349 -93
  66. data/public/javascripts/jquery.tools.min.js +195 -0
  67. data/public/punymce/blank.htm +1 -0
  68. data/public/punymce/css/content.css +4 -0
  69. data/public/punymce/css/editor.css +58 -0
  70. data/public/punymce/i18n/sv.js +28 -0
  71. data/public/punymce/img/icons.gif +0 -0
  72. data/public/punymce/img/icons_uncompressed.png +0 -0
  73. data/public/punymce/plugins/bbcode.js +1 -0
  74. data/public/punymce/plugins/bbcode_src.js +50 -0
  75. data/public/punymce/plugins/editsource/css/editor.css +3 -0
  76. data/public/punymce/plugins/editsource/editsource.js +1 -0
  77. data/public/punymce/plugins/editsource/editsource_src.js +81 -0
  78. data/public/punymce/plugins/editsource/img/icons.gif +0 -0
  79. data/public/punymce/plugins/emoticons/css/content.css +13 -0
  80. data/public/punymce/plugins/emoticons/css/editor.css +17 -0
  81. data/public/punymce/plugins/emoticons/emoticons.js +1 -0
  82. data/public/punymce/plugins/emoticons/emoticons_src.js +303 -0
  83. data/public/punymce/plugins/emoticons/img/emoticons.gif +0 -0
  84. data/public/punymce/plugins/emoticons/img/emoticons.png +0 -0
  85. data/public/punymce/plugins/emoticons/img/trans.gif +0 -0
  86. data/public/punymce/plugins/entities.js +1 -0
  87. data/public/punymce/plugins/entities_src.js +37 -0
  88. data/public/punymce/plugins/forceblocks.js +1 -0
  89. data/public/punymce/plugins/forceblocks_src.js +465 -0
  90. data/public/punymce/plugins/forcenl.js +1 -0
  91. data/public/punymce/plugins/forcenl_src.js +26 -0
  92. data/public/punymce/plugins/image/css/editor.css +1 -0
  93. data/public/punymce/plugins/image/image.js +1 -0
  94. data/public/punymce/plugins/image/image_src.js +30 -0
  95. data/public/punymce/plugins/image/img/icons.gif +0 -0
  96. data/public/punymce/plugins/link/css/editor.css +2 -0
  97. data/public/punymce/plugins/link/img/icons.gif +0 -0
  98. data/public/punymce/plugins/link/link.js +1 -0
  99. data/public/punymce/plugins/link/link_src.js +36 -0
  100. data/public/punymce/plugins/paste.js +1 -0
  101. data/public/punymce/plugins/paste_src.js +169 -0
  102. data/public/punymce/plugins/protect.js +1 -0
  103. data/public/punymce/plugins/protect_src.js +30 -0
  104. data/public/punymce/plugins/safari2x.js +1 -0
  105. data/public/punymce/plugins/safari2x_src.js +284 -0
  106. data/public/punymce/plugins/tabfocus.js +1 -0
  107. data/public/punymce/plugins/tabfocus_src.js +45 -0
  108. data/public/punymce/plugins/textcolor/css/editor.css +7 -0
  109. data/public/punymce/plugins/textcolor/img/icons.gif +0 -0
  110. data/public/punymce/plugins/textcolor/textcolor.js +1 -0
  111. data/public/punymce/plugins/textcolor/textcolor_src.js +73 -0
  112. data/public/punymce/puny_mce.js +1 -0
  113. data/public/punymce/puny_mce_full.js +1 -0
  114. data/public/punymce/puny_mce_src.js +1460 -0
  115. data/public/stylesheets/sass/forum.sass +175 -169
  116. data/radiant-forum-extension.gemspec +81 -19
  117. data/spec/controllers/admin/forums_controller_spec.rb +2 -2
  118. data/spec/controllers/forums_controller_spec.rb +3 -6
  119. data/spec/controllers/posts_controller_spec.rb +76 -59
  120. data/spec/controllers/topics_controller_spec.rb +4 -95
  121. data/spec/datasets/forum_readers_dataset.rb +1 -0
  122. data/spec/datasets/forums_dataset.rb +91 -10
  123. data/spec/lib/commentable_model_spec.rb +88 -0
  124. data/spec/lib/forum_page_spec.rb +2 -34
  125. data/spec/lib/forum_site_spec.rb +2 -3
  126. data/spec/lib/forum_tags_spec.rb +35 -0
  127. data/spec/models/forum_spec.rb +31 -20
  128. data/spec/models/post_spec.rb +40 -39
  129. data/spec/models/topic_spec.rb +29 -71
  130. data/spec/spec_helper.rb +10 -1
  131. metadata +84 -22
  132. data/app/views/posts/_reply.html.haml +0 -35
  133. data/app/views/posts/_upload.html.haml +0 -2
  134. data/app/views/posts/preview.html.haml +0 -32
  135. data/app/views/posts/search.html.haml +0 -63
  136. data/app/views/posts/search.rss.builder +0 -14
  137. data/app/views/topics/_form.html.haml +0 -30
  138. data/app/views/topics/_help.html.haml +0 -8
  139. data/app/views/topics/comments.html.haml +0 -6
  140. data/app/views/topics/edit.html.haml +0 -26
  141. data/app/views/topics/new.html.haml +0 -56
  142. data/spec/datasets/forum_pages_dataset.rb +0 -11
  143. data/spec/datasets/posts_dataset.rb +0 -31
  144. data/spec/datasets/topics_dataset.rb +0 -37
@@ -0,0 +1 @@
1
+ (function(a){function b(f,d){var e,c;e=d.parentNode;c=d.nextSibling;if(c){e.insertBefore(f,c)}else{e.appendChild(f)}return f}a.plugins.TabFocus=function(d){var c=a.Event,e=a.DOM;d.onInit.add(function(){var g,f,h;h=b(e.create("a",{href:"#"}),e.get(d.settings.id+"_c"));c.add(h,"focus",function(i){d.getWin().focus()});c.add(d.getDoc(),"keydown",function(i){if(i.keyCode==9){return c.cancel(i)}});c.add(d.getDoc(),"keydown",function(i){if(i.keyCode==9){window.focus();e.get(d.settings.tabfocus_id).focus()}})})}})(punymce);
@@ -0,0 +1,45 @@
1
+ (function(punymce) {
2
+ function insertAfter(n, r) {
3
+ var p, ns;
4
+
5
+ p = r.parentNode;
6
+ ns = r.nextSibling;
7
+
8
+ if (ns)
9
+ p.insertBefore(n, ns);
10
+ else
11
+ p.appendChild(n);
12
+
13
+ return n;
14
+ };
15
+
16
+ punymce.plugins.TabFocus = function(ed) {
17
+ var Event = punymce.Event, DOM = punymce.DOM;
18
+
19
+ ed.onInit.add(function() {
20
+ var p, ns, n;
21
+
22
+ // Append an anchor element after the editor container ones this gets focused it will
23
+ // focus the editor instead this makes it possible to shift tab into the editor
24
+ n = insertAfter(DOM.create('a', {href : '#'}), DOM.get(ed.settings.id + '_c'));
25
+
26
+ Event.add(n, 'focus', function(e) {
27
+ ed.getWin().focus();
28
+ });
29
+
30
+ Event.add(ed.getDoc(), 'keydown', function(e) {
31
+ if (e.keyCode == 9)
32
+ return Event.cancel(e);
33
+ });
34
+
35
+ Event.add(ed.getDoc(), 'keydown', function(e) {
36
+ if (e.keyCode == 9) {
37
+ window.focus();
38
+
39
+ // Focus the specified element
40
+ DOM.get(ed.settings.tabfocus_id).focus();
41
+ }
42
+ });
43
+ });
44
+ };
45
+ })(punymce);
@@ -0,0 +1,7 @@
1
+ .punymce a.textcolor { background: url('../img/icons.gif') 0 0; }
2
+
3
+ /* Color picker */
4
+ div.punymce_color { position: absolute; display: none; background: #FFF; }
5
+ div.punymce_color table { background: #FFF; }
6
+ div.punymce_color td { width: 8px; height: 8px; }
7
+ div.punymce_color a { display: block; width: 8px; height: 8px; border: 1px solid #808080; overflow: hidden; }
@@ -0,0 +1 @@
1
+ (function(a){a.plugins.TextColor=function(d){var c="000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF";var f=a.DOM,b=a.Event,g=a.each,h=a.extend,e;if(!d.settings.textcolor||d.settings.textcolor.skip_css){f.loadCSS(a.baseURL+"/plugins/textcolor/css/editor.css")}e=h({colors:c},d.settings.textcolor);h(d.commands,{mceColor:function(w,s,o){var k,x=this,i=d.settings.id,j=f.getPos(o.target),q,l;if(d.hideMenu){return d.hideMenu()}function m(n){d.hideMenu=null;b.remove(document,"click",m);b.remove(d.getDoc(),"click",m);f.get(i+"_mcolor").style.display="none";return 1}k=f.get(i+"_mcolor");if(!k){k=f.get(i+"_t");k=f.add(document.body,"div",{id:i+"_mcolor","class":"punymce_color punymce"});k=f.add(k,"table",{"class":"punymce"});k=f.add(k,"tbody");q=8;g(e.colors.split(","),function(n){if(q==8){r=f.add(k,"tr");q=0}q++;b.add(f.add(f.add(r,"td"),"a",{href:"#",style:"background:#"+n}),"mousedown",function(p){m.call(x);d.execCommand("forecolor",0,"#"+n);return b.cancel(p)})})}b.add(document,"click",m,x);b.add(d.getDoc(),"click",m,x);d.hideMenu=m;e=f.get(i+"_mcolor").style;e.left=j.x+"px";e.top=(j.y+o.target.clientHeight+2)+"px";e.display="block"}});h(d.tools,{textcolor:{cmd:"mceColor",title:a.I18n.textcolor}})};a.extend(a.I18n,{textcolor:"Text color"})})(punymce);
@@ -0,0 +1,73 @@
1
+ (function(punymce) {
2
+ punymce.plugins.TextColor = function(ed) {
3
+ var colors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF';
4
+ var DOM = punymce.DOM, Event = punymce.Event, each = punymce.each, extend = punymce.extend, s;
5
+
6
+ if (!ed.settings.textcolor || ed.settings.textcolor.skip_css)
7
+ DOM.loadCSS(punymce.baseURL + '/plugins/textcolor/css/editor.css');
8
+
9
+ s = extend({
10
+ colors : colors
11
+ }, ed.settings.textcolor);
12
+
13
+ extend(ed.commands, {
14
+ mceColor : function(u, v, e) {
15
+ var n, t = this, id = ed.settings.id, p = DOM.getPos(e.target), co, cb;
16
+
17
+ if (ed.hideMenu)
18
+ return ed.hideMenu();
19
+
20
+ function hide(e) {
21
+ ed.hideMenu = null;
22
+ Event.remove(document, 'click', hide);
23
+ Event.remove(ed.getDoc(), 'click', hide);
24
+ DOM.get(id + '_mcolor').style.display = 'none';
25
+ return 1;
26
+ };
27
+
28
+ n = DOM.get(id + '_mcolor');
29
+ if (!n) {
30
+ n = DOM.get(id + '_t');
31
+ n = DOM.add(document.body, 'div', {id : id + '_mcolor', 'class' : 'punymce_color punymce'});
32
+ n = DOM.add(n, 'table', {'class' : 'punymce'});
33
+ n = DOM.add(n, 'tbody');
34
+ co = 8;
35
+ each(s.colors.split(','), function(c) {
36
+ if (co == 8) {
37
+ r = DOM.add(n, 'tr');
38
+ co = 0;
39
+ }
40
+
41
+ co++;
42
+
43
+ Event.add(DOM.add(DOM.add(r, 'td'), 'a', {href : '#', style : 'background:#' + c}), 'mousedown', function(e) {
44
+ hide.call(t);
45
+
46
+ ed.execCommand('forecolor', 0, '#' + c);
47
+
48
+ return Event.cancel(e);
49
+ });
50
+ });
51
+ }
52
+
53
+ Event.add(document, 'click', hide, t);
54
+ Event.add(ed.getDoc(), 'click', hide, t);
55
+ ed.hideMenu = hide;
56
+
57
+ s = DOM.get(id + '_mcolor').style;
58
+ s.left = p.x + 'px';
59
+ s.top = (p.y + e.target.clientHeight + 2) + 'px';
60
+ s.display = 'block';
61
+ }
62
+ });
63
+
64
+ extend(ed.tools, {
65
+ textcolor : {cmd : 'mceColor', title : punymce.I18n.textcolor}
66
+ });
67
+ };
68
+
69
+ // English i18n strings
70
+ punymce.extend(punymce.I18n, {
71
+ textcolor : 'Text color'
72
+ });
73
+ })(punymce);
@@ -0,0 +1 @@
1
+ (function(p){var n,f,s,j,b,i,t,d,k;var a,h,g,q,m,r,l;l=navigator.userAgent;p.isOpera=q=window.opera&&opera.buildNumber;p.isWebKit=m=/WebKit/.test(l);p.isOldWebKit=r=m&&!window.getSelection().getRangeAt;p.isIE=h=!m&&!q&&(/MSIE/gi).test(l)&&(/Explorer/gi).test(navigator.appName);p.isGecko=g=!m&&/Gecko/.test(l);p.plugins={};function e(v,u){v=typeof(v);if(!u){return v!="undefined"}return v==u}function c(w,u,v){var x;if(!w){return 0}v=!v?w:v;if(e(w.length)){for(x=0;x<w.length;x++){if(u.call(v,w[x],x,w)===false){return 0}}}else{for(x in w){if(w.hasOwnProperty(x)){if(u.call(v,w[x],x,w)===false){return 0}}}}return 1}function o(v,u){c(u,function(w,x){v[x]=w});return v}o(p,{is:e,each:c,extend:o});p.I18n=k={bold:"Bold (Ctrl+B)",italic:"Italic (Ctrl+I)",underline:"Underline (Ctrl+U)",strike:"Striketrough",ul:"Insert unordered list",ol:"Insert ordered list",indent:"Indent",outdent:"Outdent",left:"Align left",center:"Align center",right:"Align right",style:"Font style",removeformat:"Remove format",increasefontsize:"Increase text size",decreasefontsize:"Decrease text size"};p.DOMUtils=n=function(v){this.files=[];try{v.execCommand("BackgroundImageCache",0,1)}catch(u){}o(this,{get:function(w){return w&&(!w.nodeType&&!w.location?v.getElementById(w):w)},add:function(A,B,w,y){var x=this,z;z=v.createElement(B);c(w,function(C,D){x.setAttr(z,D,C)});if(y){if(y.nodeType){z.appendChild(y)}else{z.innerHTML=y}}return A?A.appendChild(z):z},create:function(y,w,x){return this.add(0,y,w,x)},setAttr:function(x,y,w){x=this.get(x);if(!x){return 0}if(y=="style"){x.setAttribute("mce_style",w);x.style.cssText=w}if(y=="class"){x.className=w}if(w!=null&&w!=""){x.setAttribute(y,""+w)}else{x.removeAttribute(y)}return 1},getAttr:function(y,z,x){var w;y=this.get(y);if(!y){return false}if(!e(x)){x=""}if(/^(src|href|style)$/.test(z)){w=this.getAttr(y,"mce_"+z);if(w){return w}}w=y.getAttribute(z,2);if(z=="class"&&!w){w=y.className}if(z=="style"&&!w){w=y.style.cssText}else{if(!w){w=y.attributes[z];w=w&&e(w.nodeValue)?w.nodeValue:w}}if(m&&z=="class"&&w){w=w.replace(/(apple|webkit)\-[a-z\-]+/gi,"")}return(w&&w!="")?""+w:x},select:function(w,z,x){var y=[];z=this.get(z);z=!z?v:z;c(w.split(","),function(A){c(z.getElementsByTagName(A),function(B){if(!x||x(B)){y.push(B)}})});return y},getPos:function(C,B){var w=0,x=0,z,y,A;C=this.get(C);if(p.isIE&&C){y=C.getBoundingClientRect();A=document;C=A.compatMode=="CSS1Compat"?A.documentElement:A.body;return{x:y.left+(C.scrollLeft||0),y:y.top+(C.scrollTop||0)}}while(C&&C!=B){w+=C.offsetLeft||0;x+=C.offsetTop||0;C=C.offsetParent}return{x:w,y:x}},loadCSS:function(w){var x=this;if(w){c(w.split(","),function(z){var y=-1;c(x.files,function(B,A){if(B==z){y=A;return false}});if(y!=-1){return}x.files.push(z);if(!v.createStyleSheet){x.add(x.select("head")[0],"link",{rel:"stylesheet",href:z})}else{v.createStyleSheet(z)}})}},addClass:function(x,z,w){var y;x=this.get(x);if(!x){return 0}y=this.removeClass(x,z);return x.className=w?z+(y!=""?(" "+y):""):(y!=""?(y+" "):"")+z},removeClass:function(w,x){w=this.get(w);if(!w){return 0}x=w.className.replace(new RegExp("(^|\\s+)"+x+"(\\s+|$)","g")," ");return w.className=x!=" "?x:""},hasClass:function(x,w){x=this.get(x);return new RegExp("\\b"+w+"\\b","g").test(x.className)},getParent:function(y,x,w){while(y){if(y==w){return null}if(x(y)){return y}y=y.parentNode}return null},keep:function(w){if(g){w=w.replace(/<(\/?)strong>|<strong( [^>]+)>/gi,"<$1b$2>");w=w.replace(/<(\/?)em>|<em( [^>]+)>/gi,"<$1i$2>");w=w.replace(/<(\/?)del|<del( [^>]+)>/gi,"<$1strike$2>")}w=w.replace(/ (src|href|style)=\"([^\"]+)\"/gi,' $1="$2" mce_$1="$2"');return w}})};p.DOM=a=new n(document);p.Event=t={events:[],inits:[],unloads:[],add:function(z,A,y,x){var u,v=this,w=v.events;z=a.get(z);u=function(B){B=B||window.event;if(B&&!B.target&&h){B.target=B.srcElement}if(!x){return y(B)}return y.call(x,B)};if(A=="unload"){v.unloads.push(u);return u}if(A=="init"){if(v._init){u()}else{v.inits.push(u)}return u}w.push({obj:z,name:A,func:y,cfunc:u,scope:x});v._add(z,A,u);if(h&&w.length==1){t._add(window,"unload",v._unload,t)}return u},remove:function(x,y,w){var v=this,u=v.events;x=a.get(x);c(u,function(A,z){if(A.obj==x&&A.name==y&&(!w||A.func==w)){u.splice(z,1);v._remove(x,y,A.cfunc);return false}})},cancel:function(u){this.stop(u);return this.prevent(u)},stop:function(u){if(u.stopPropagation){u.stopPropagation()}else{u.cancelBubble=true}return false},prevent:function(u){if(u.preventDefault){u.preventDefault()}else{u.returnValue=false}return false},_unload:function(){var u=t;c(u.events,function(v){u._remove(v.obj,v.name,v.cfunc)});u._remove(window,"unload",u._unload);u.events=[];c(u.unloads,function(v){v()})},_add:function(v,w,u){if(v.attachEvent){v.attachEvent("on"+w,u)}else{if(v.addEventListener){v.addEventListener(w,u,false)}else{v["on"+w]=u}}},_remove:function(v,w,u){if(v.detachEvent){v.detachEvent("on"+w,u)}else{if(v.removeEventListener){v.removeEventListener(w,u,false)}else{v["on"+w]=null}}},_pageInit:function(){var u=t;u._remove(window,"DOMContentLoaded",u._pageInit);u._init=true;c(u.inits,function(v){v()});u.inits=[]},_wait:function(){var u;if(h&&document.location.protocol!="https:"){document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");a.get("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){t._pageInit();a.get("__ie_onload").onreadystatechange=null}}}else{t._add(window,"DOMContentLoaded",t._pageInit,t);if(h||m){u=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(u);t._pageInit()}},10)}}}};p.Dispatcher=i=function(u){var v=[];if(!u){u=this}o(this,{add:function(w,x){v.push({cb:w,scope:!x?u:x});return w},remove:function(w){c(v,function(y,x){if(w==y.cb){v.splice(x,1)}return false});return w},dispatch:function(){var x,w=arguments;c(v,function(y){return x=y.cb.apply(y.scope,w)});return x}})};p.Editor=j=function(B){var y,z,w=this;if(!p.baseURL){c(a.select("script"),function(C){if(/puny_mce/g.test(""+C.src)){p.baseURL=C.src.replace(/^(.+)\/puny_mce.+$/,"$1/")}})}this.settings=y=o({content_css:p.baseURL+"/css/content.css",editor_css:p.baseURL+"/css/editor.css",width:0,height:0,min_width:260,min_height:50,max_width:800,max_height:600,entities:"raw",spellcheck:0,resize:true,plugins:"",styles:[{title:"H1",cls:"h1",cmd:"FormatBlock",val:"<h1>"},{title:"H2",cls:"h2",cmd:"FormatBlock",val:"<h2>"},{title:"H3",cls:"h3",cmd:"FormatBlock",val:"<h3>"},{title:"Pre",cls:"pre",cmd:"FormatBlock",val:"<pre>"},{title:"Times",cls:"times",cmd:"FontName",val:"Times"},{title:"Arial",cls:"arial",cmd:"FontName",val:"Arial"},{title:"Courier",cls:"courier",cmd:"FontName",val:"Courier"}],toolbar:"bold,italic,underline,strike,increasefontsize,decreasefontsize,ul,ol,indent,outdent,left,center,right,style,removeformat"},B);w.tools={bold:{cmd:"Bold",title:k.bold},italic:{cmd:"Italic",title:k.italic},underline:{cmd:"Underline",title:k.underline},strike:{cmd:"Strikethrough",title:k.strike},ul:{cmd:"InsertUnorderedList",title:k.ul},ol:{cmd:"InsertOrderedList",title:k.ol},indent:{cmd:"Indent",title:k.indent},outdent:{cmd:"Outdent",title:k.outdent},left:{cmd:"JustifyLeft",title:k.left},center:{cmd:"JustifyCenter",title:k.center},right:{cmd:"JustifyRight",title:k.right},style:{cmd:"mceStyle",title:k.style},removeformat:{cmd:"RemoveFormat",title:k.removeformat},increasefontsize:{cmd:"IncreaseFontSize",title:k.increasefontsize},decreasefontsize:{cmd:"DecreaseFontSize",title:k.decreasefontsize}};a.loadCSS(y.editor_css);this.commands={mceStyle:function(J,I,H){var E,K=this,L=K.settings,C=L.id,D=a.getPos(H.target),F;if(K.hideMenu){return K.hideMenu()}function G(M){K.hideMenu=null;t.remove(document,"click",G);t.remove(K.getDoc(),"click",G);a.get(C+"_mstyle").style.display="none"}E=a.get(C+"_mstyle");if(!E){E=a.get(C+"_t");E=a.add(document.body,"div",{id:C+"_mstyle","class":"punymce_style punymce"});c(L.styles,function(M){t.add(a.add(E,"a",{href:"#","class":M.cls},M.title),"mousedown",function(N){G.call(K);K.execCommand(M.cmd,M.ui,M.val);if(q){K.getIfr().focus()}return t.cancel(N)})})}K.hideMenu=G;t.add(document,"click",G,K);t.add(K.getDoc(),"click",G,K);L=E.style;L.left=D.x+"px";L.top=(D.y+H.target.clientHeight+2)+"px";L.display="block"},FormatBlock:function(D,C,E){if(g&&/<(div|blockquote|code|dt|dd|dl|samp)>/gi.test(C)){C=C.replace(/[^a-z]/gi,"")}w.getDoc().execCommand("FormatBlock",0,C)},CreateLink:function(E,D){var F=w.dom,C="javascript:mox();";w.getDoc().execCommand("CreateLink",0,C);c(F.select("A"),function(G){if(F.getAttr(G,"href")==C){F.setAttr(G,"href",D);F.setAttr(G,"mce_href",D)}})},mceFontSizeDelta:function(E,D){var I=w.getDoc(),C,H,F,G=w.selection;C=parseInt(I.queryCommandValue("FontSize")||3);if(m){c([10,13,16,18,24,32,48],function(K,J){if(C==K){C=J+1;return false}})}if(C+D<=1){return}I.execCommand("FontSize",false,C+D)},IncreaseFontSize:function(){w.execCommand("mceFontSizeDelta",0,1)},DecreaseFontSize:function(){w.execCommand("mceFontSizeDelta",0,-1)},Indent:function(D,C,E){w.getDoc().execCommand("Indent",0,0);if(h){w.dom.getParent(w.selection.getNode(),function(F){if(F.nodeName=="BLOCKQUOTE"){F.dir=F.style.marginRight=""}})}},mceSetClass:function(D,C,F){var E=w.selection;if(e(C,"string")){C={element:"span","class":C}}if(E.isCollapsed()){w.dom.setAttr(E.getNode(),"class",C["class"])}else{E.setContent("<"+C.element+' class="'+C["class"]+'">'+E.getContent()+"</"+C.element+">")}},RemoveFormat:function(D,C,F){var E=w.selection;w.getDoc().execCommand("RemoveFormat",D,C);if(h){C=E.getContent();C=C.replace(/ (class|style)=\"[^\"]+\"/g,"");C=C.replace(/<\/?(font|strong|em|b|i|u|strike)>/g,"");C=C.replace(/<(font|strong|em|b|i|u|strike) [^>]+>/g,"");E.setContent(C)}}};function x(F){var G,E,C,D;G=a.get(y.id+"_c");C=G.clientWidth-2;D=G.clientHeight-2;E=a.get(y.id+"_p");E.style.width=C+"px";E.style.height=D+"px";G.style.display="none";E.style.display="block";w.resize={x:F.screenX,y:F.screenY,w:C,h:D};t.add(document,"mousemove",v,this);t.add(document,"mouseup",A,this);w.onResizeStart.dispatch(w,F,C,D)}function v(G){var E=w.resize,F,C,D;E.dx=G.screenX-E.x;E.dy=G.screenY-E.y;C=Math.max(y.min_width,E.w+E.dx);D=Math.max(y.min_height,E.h+E.dy);C=Math.min(y.max_width,C);D=Math.min(y.max_height,D);F=a.get(y.id+"_p");F.style.width=C+"px";F.style.height=D+"px";return t.cancel(G)}function A(D){var C=w.resize;t.remove(document,"mousemove",v,this);t.remove(document,"mouseup",A,this);a.get(y.id+"_c").style.display="";a.get(y.id+"_p").style.display="none";w.resizeBy(C.dx,C.dy);w.onResizeEnd.dispatch(w,D,C.dx,C.dy)}function u(){var C=a.get(y.id),D=w.getDoc();if(g){w.getDoc().designMode="On"}D.open();D.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body id="punymce"></body></html>');D.close();w.dom=z=new n(w.getDoc());z.loadCSS(y.content_css);w.onPreInit.dispatch(w);if(!y.spellcheck){w.getBody().spellcheck=0}t.add(w.getDoc(),"mouseup",w.nodeChanged,w);t.add(w.getDoc(),"keyup",w.nodeChanged,w);t.add(g?w.getDoc():w.getWin(),"focus",function(F){var E;if((E=p.focusEditor)!=null){E.onBlur.dispatch(E,w)}w.onFocus.dispatch(w,E);p.focusEditor=w},this);if(!h){w.getDoc().designMode="On"}else{w.getBody().contentEditable=true}w.setContent(e(C.value)?C.value:C.innerHTML,{load:true});a.get(y.id+"_c").style.display=w.orgDisplay;a.get(y.id).style.display="none";w.onInit.dispatch(w)}o(this,{serializer:new d(w),selection:new b(w),plugins:[]});c(["onPreInit","onInit","onFocus","onBlur","onResizeStart","onResizeEnd","onPreProcess","onPostProcess","onSetContent","onBeforeGetContent","onGetContent","onNodeChange"],function(C){w[C]=new i(w)});o(this,{init:function(){var H=a.get(y.id),J=H.parentNode,L,F,K,I,D,C,G,E=["bold","italic","underline","left","center","right"];c(y.plugins.split(","),function(M){if(M){w.plugins.push(new p.plugins[M](w))}});w.onNodeChange.add(function(){c(E,function(O){var N;try{N=w.getDoc().queryCommandState(w.tools[O].cmd)?a.addClass:a.removeClass;N.call(a,y.id+"_"+O,"active")}catch(M){}})});if(y.entities=="numeric"){w.onGetContent.add(function(M,N){if(N.format=="html"){N.content=N.content.replace(/[\u007E-\uFFFF]/g,function(O){return"&#"+O.charCodeAt(0)+";"})}})}L=!y.width?H.offsetWidth:y.width;F=!y.height?H.offsetHeight:y.height;w.orgDisplay=H.style.display;H.style.display="none";if(H.form){G=H.form;w._submit=G.submit;G.submit=function(){var N=a.get(y.id),M=N.form;w.save();M.submit=w._submit;M.submit()};t.add(0,"unload",function(){var M=a.get(y.id).form;w._submit=w.submit=null});t.add(G,"submit",w.save,w)}K='<div id="'+y.id+'_w" class="punymce"><table id="'+y.id+'_c" class="punymce"><tr class="mceToolbar">';K+='<td id="'+y.id+'_t"></td></tr><tr class="mceBody"><td></div><div id="'+y.id+'_b" class="mceBody">';if(y.resize){K+='<div id="'+y.id+'_r" class="mceResize"></div>'}K+="</td></tr></table>";K+='<div id="'+y.id+'_p" class="mcePlaceholder"></div></div>';if(!H.insertAdjacentHTML){C=H.ownerDocument.createRange();C.setStartBefore(H);J.insertBefore(C.createContextualFragment(K),H)}else{H.insertAdjacentHTML("beforeBegin",K)}D=a.get(y.id+"_t");I=a.add(D,"ul",{id:y.id+"_tb","class":"punymce"});c(y.toolbar.split(","),function(M){var N=w.tools[M];D=a.add(a.add(I,"li",{id:y.id+"_"+M,"class":M}),"a",{href:"javascript:void(0);","class":M,title:N.title,tabIndex:-1,onmousedown:"return false;"});t.add(D,"click",function(O){if(!a.hasClass(O.target.parentNode,"disabled")){w.execCommand(N.cmd,0,0,O)}return t.cancel(O)})});D=a.get(y.id+"_b");D=a.add(D,"iframe",{id:y.id+"_f",src:'javascript:""',frameBorder:"0","class":"punymce",style:"width:"+L+"px;height:"+F+"px"});w.resizeTo(L,F);if(m){t.add(D,"load",u,w);D.src=p.baseURL+"blank.htm"}else{u()}if(y.resize){t.add(y.id+"_r","mousedown",function(M){return x(M,y.id)},this)}I=G=H=D=null},getSize:function(){var C=a.get(y.id+"_f");return{w:C.clientWidth,h:C.clientHeight}},resizeTo:function(C,E){var D=a.get(y.id+"_f").style;C=Math.max(y.min_width,C);E=Math.max(y.min_height,E);C=Math.min(y.max_width,C);E=Math.min(y.max_height,E);w.width=C;w.height=E;D.width=C+"px";D.height=E+"px"},resizeBy:function(C,D){var E=w.getSize();w.resizeTo(E.w+C,E.h+D)},show:function(){a.get(y.id+"_w").style.display="block";a.get(y.id).style.display="none";w.load()},hide:function(){if(h){w.execCommand("SelectAll")}a.get(y.id+"_w").style.display="none";a.get(y.id).style.display=w.orgDisplay;w.save()},load:function(){var C=a.get(y.id);w.setContent(e(C.value)?C.value:C.innerHTML,{load:true})},save:function(){var D=a.get(y.id),C=w.getContent({save:true});if(/TEXTAREA|INPUT/.test(D.nodeName)){D.value=C}else{D.innerHTML=C}},setUseCSS:function(C){var E=w.getDoc(),D;try{E.execCommand("styleWithCSS",0,false)}catch(D){try{E.execCommand("useCSS",0,true)}catch(D){}}},execCommand:function(H,E,D,G){var C=w.commands,F;w.getWin().focus();w.setUseCSS(0);if(C[H]){F=C[H].call(w,E,D,G)}else{F=w.getDoc().execCommand(H,E,D)}if(F!==false){w.nodeChanged()}},getContent:function(D){var C;D=D||{};D.format=D.format||"html";w.onBeforeGetContent.dispatch(this,D);C=w.serializer.serialize(w.getBody(),D);C=C.replace(/^\s*|\s*$/g,"");D.content=C;w.onGetContent.dispatch(this,D);return D.content},setContent:function(C,D){D=D||{};D.content=C;w.onSetContent.dispatch(this,D);C=D.content;C=a.keep(C);w.getBody().innerHTML=C;if(D.format!="raw"){w.setContent(C=w.getContent(D),{format:"raw"})}else{w.getBody().innerHTML=C}return C},getIfr:function(){return a.get(y.id+"_f")},getWin:function(){return w.getIfr().contentWindow},getDoc:function(){return w.getWin().document},getBody:function(){return w.getDoc().body},nodeChanged:function(){w.setUseCSS(0);w.onNodeChange.dispatch(w,w.selection.getNode())}});t.add(window,"init",w.init,this)};p.Selection=b=function(u){var v=this;o(v,{getContent:function(z){var w,x=v.getRng(),y=document.createElement("body");z=z||{};if(v.isCollapsed()){return""}if(x.cloneContents){y.appendChild(x.cloneContents())}else{if(e(x.item)||e(x.htmlText)){y.innerHTML=x.item?x.item(0).outerHTML:x.htmlText}else{y.innerHTML=x.toString()}}if(z.format!="raw"){z.content=w;u.serializer.serialize(y,z);z.content=z.content.replace(/^\s*|\s*$/g,"");u.onGetContent.dispatch(w,z);w=z.content}else{w=y.innerHTML}return w},getText:function(){var x=v.getRng(),w=v.getSel();if(r){return w}return v.isCollapsed()?"":x.text||w.toString()},setContent:function(y,A){var z=v.getRng(),w,B,z,x;A=A||{format:"raw"};y=a.keep(y);if(A.format!="raw"){A.content=y;y=u.onSetContent.dispatch(this,A);y=A.content;w=u.dom.create("body");w.innerHTML=y}if(z.insertNode){z.deleteContents();z.insertNode(z.createContextualFragment(y+'<span id="__caret">_</span>'));B=u.dom.get("__caret");z=u.getDoc().createRange();z.setStartBefore(B);z.setEndBefore(B);x=v.getSel();x.removeAllRanges();x.addRange(z);B.parentNode.removeChild(B)}else{if(z.pasteHTML){z.pasteHTML(y)}else{z.item(0).outerHTML=y}}},select:function(A,z){var y=v.getRng(),x=v.getSel();if(y.moveToElementText){try{y.moveToElementText(A);y.select()}catch(w){}}else{if(x.addRange){z?y.selectNodeContents(A):y.selectNode(A);x.removeAllRanges();x.addRange(y)}else{x.setBaseAndExtent(A,0,A,1)}}return A},isCollapsed:function(){var w=v.getRng();if(w.item){return false}return w.boundingWidth==0||v.getSel().isCollapsed},collapse:function(w){var y=v.getRng(),x=v.getSel();if(y.select){y.collapse(w);y.select()}else{if(w){x.collapseToStart()}else{x.collapseToEnd()}}},getSel:function(){var x=u.getWin();return x.getSelection?x.getSelection():u.getDoc().selection},getRng:function(){var w=v.getSel(),C=u.getDoc(),y,A,B,x;if(!w){return null}try{return w.rangeCount>0?w.getRangeAt(0):(w.createRange?w.createRange():null)}catch(z){return C.body.createTextRange()}},setRng:function(x){var w=v.getSel();w.removeAllRanges();w.addRange(x)},setNode:function(w){v.setContent(u.dom.create("div",null,w).innerHTML)},getNode:function(){var x=v.getRng(),w=v.getSel(),y;if(!h){if(x){y=x.commonAncestorContainer;if(!x.collapsed){if(x.startContainer==x.endContainer){if(x.startOffset-x.endOffset<2){if(x.startContainer.hasChildNodes()){y=x.startContainer.childNodes[x.startOffset]}}}}}return a.getParent(y,function(z){return z.nodeType==1})}return x.item?x.item(0):x.parentElement()}})};p.Serializer=d=function(v){var x,y=0,z;function w(){var C=document.implementation;if(!C||!C.createDocument){try{return new ActiveXObject("MSXML2.DOMDocument")}catch(B){}try{return new ActiveXObject("Microsoft.XmlDom")}catch(B){}}else{return C.createDocument("","",null)}}x=w();this.settings=z=o({valid_nodes:0,invalid_nodes:/(BODY)/,valid_attrs:0,node_filter:0,root_node:0,pi:0,invalid_attrs:/(^mce_|^_moz_|^contenteditable$)/,closed:/(BR|HR|INPUT|META|IMG)/},v.settings.serializer);function A(C){var B=[];C.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(E,D){B.push({specified:1,nodeName:D})});return B}function u(D,G){var H,B,I,F,E,J,C,L,K;if((!z.valid_nodes||z.valid_nodes.test(D.nodeName))&&(!z.invalid_nodes||!z.invalid_nodes.test(D.nodeName))&&(!z.node_filter||z.node_filter(D,G))){switch(D.nodeType){case 1:if(h){if(D.mce_serialized==y){return}D.mce_serialized=y}H=D.hasChildNodes();B=x.createElement(D.nodeName.toLowerCase());C=h?A(D):D.attributes;for(F=C.length-1;F>-1;F--){L=C[F];if(L.specified){J=L.nodeName.toLowerCase();if(z.invalid_attrs&&z.invalid_attrs.test(J)){continue}if(z.valid_attrs&&!z.valid_attrs.test(J)){continue}K=a.getAttr(D,J);if(K!==""){B.setAttribute(J,K)}}}if(!H&&!z.closed.test(D.nodeName)){B.appendChild(x.createTextNode(""))}G=G.appendChild(B);break;case 3:return G.appendChild(x.createTextNode(D.nodeValue));case 8:return G.appendChild(x.createComment(D.nodeValue))}}else{if(D.nodeType==1){H=D.hasChildNodes()}}if(H){I=D.firstChild;while(I){u(I,G);I=I.nextSibling}}}o(this,{serialize:function(D,C){var B;y=""+(parseInt(y)+1);if(x.firstChild){x.removeChild(x.firstChild)}D=C.node=D.cloneNode(1);v.onPreProcess.dispatch(this,C);u(D,x.appendChild(x.createElement("html")));B=x.xml||new XMLSerializer().serializeToString(x);if(!z.pi){B=B.replace(/<\?[^?]+\?>/g,"")}if(!z.root_node){B=B.replace(/<html>|<\/html>/g,"")}C.content=B;v.onPostProcess.dispatch(this,C);return C.content}})};t._wait();window.punymce=p})({});
@@ -0,0 +1 @@
1
+ (function(q){var o,g,v,k,c,j,w,e,l;var a,i,h,t,n,u,m;m=navigator.userAgent;q.isOpera=t=window.opera&&opera.buildNumber;q.isWebKit=n=/WebKit/.test(m);q.isOldWebKit=u=n&&!window.getSelection().getRangeAt;q.isIE=i=!n&&!t&&(/MSIE/gi).test(m)&&(/Explorer/gi).test(navigator.appName);q.isGecko=h=!n&&/Gecko/.test(m);q.plugins={};function f(y,x){y=typeof(y);if(!x){return y!="undefined"}return y==x}function d(z,x,y){var A;if(!z){return 0}y=!y?z:y;if(f(z.length)){for(A=0;A<z.length;A++){if(x.call(y,z[A],A,z)===false){return 0}}}else{for(A in z){if(z.hasOwnProperty(A)){if(x.call(y,z[A],A,z)===false){return 0}}}}return 1}function p(y,x){d(x,function(z,A){y[A]=z});return y}p(q,{is:f,each:d,extend:p});q.I18n=l={bold:"Bold (Ctrl+B)",italic:"Italic (Ctrl+I)",underline:"Underline (Ctrl+U)",strike:"Striketrough",ul:"Insert unordered list",ol:"Insert ordered list",indent:"Indent",outdent:"Outdent",left:"Align left",center:"Align center",right:"Align right",style:"Font style",removeformat:"Remove format",increasefontsize:"Increase text size",decreasefontsize:"Decrease text size"};q.DOMUtils=o=function(y){this.files=[];try{y.execCommand("BackgroundImageCache",0,1)}catch(x){}p(this,{get:function(z){return z&&(!z.nodeType&&!z.location?y.getElementById(z):z)},add:function(D,E,z,B){var A=this,C;C=y.createElement(E);d(z,function(F,G){A.setAttr(C,G,F)});if(B){if(B.nodeType){C.appendChild(B)}else{C.innerHTML=B}}return D?D.appendChild(C):C},create:function(B,z,A){return this.add(0,B,z,A)},setAttr:function(A,B,z){A=this.get(A);if(!A){return 0}if(B=="style"){A.setAttribute("mce_style",z);A.style.cssText=z}if(B=="class"){A.className=z}if(z!=null&&z!=""){A.setAttribute(B,""+z)}else{A.removeAttribute(B)}return 1},getAttr:function(B,C,A){var z;B=this.get(B);if(!B){return false}if(!f(A)){A=""}if(/^(src|href|style)$/.test(C)){z=this.getAttr(B,"mce_"+C);if(z){return z}}z=B.getAttribute(C,2);if(C=="class"&&!z){z=B.className}if(C=="style"&&!z){z=B.style.cssText}else{if(!z){z=B.attributes[C];z=z&&f(z.nodeValue)?z.nodeValue:z}}if(n&&C=="class"&&z){z=z.replace(/(apple|webkit)\-[a-z\-]+/gi,"")}return(z&&z!="")?""+z:A},select:function(z,C,A){var B=[];C=this.get(C);C=!C?y:C;d(z.split(","),function(D){d(C.getElementsByTagName(D),function(E){if(!A||A(E)){B.push(E)}})});return B},getPos:function(F,E){var z=0,A=0,C,B,D;F=this.get(F);if(q.isIE&&F){B=F.getBoundingClientRect();D=document;F=D.compatMode=="CSS1Compat"?D.documentElement:D.body;return{x:B.left+(F.scrollLeft||0),y:B.top+(F.scrollTop||0)}}while(F&&F!=E){z+=F.offsetLeft||0;A+=F.offsetTop||0;F=F.offsetParent}return{x:z,y:A}},loadCSS:function(z){var A=this;if(z){d(z.split(","),function(C){var B=-1;d(A.files,function(E,D){if(E==C){B=D;return false}});if(B!=-1){return}A.files.push(C);if(!y.createStyleSheet){A.add(A.select("head")[0],"link",{rel:"stylesheet",href:C})}else{y.createStyleSheet(C)}})}},addClass:function(A,C,z){var B;A=this.get(A);if(!A){return 0}B=this.removeClass(A,C);return A.className=z?C+(B!=""?(" "+B):""):(B!=""?(B+" "):"")+C},removeClass:function(z,A){z=this.get(z);if(!z){return 0}A=z.className.replace(new RegExp("(^|\\s+)"+A+"(\\s+|$)","g")," ");return z.className=A!=" "?A:""},hasClass:function(A,z){A=this.get(A);return new RegExp("\\b"+z+"\\b","g").test(A.className)},getParent:function(B,A,z){while(B){if(B==z){return null}if(A(B)){return B}B=B.parentNode}return null},keep:function(z){if(h){z=z.replace(/<(\/?)strong>|<strong( [^>]+)>/gi,"<$1b$2>");z=z.replace(/<(\/?)em>|<em( [^>]+)>/gi,"<$1i$2>");z=z.replace(/<(\/?)del|<del( [^>]+)>/gi,"<$1strike$2>")}z=z.replace(/ (src|href|style)=\"([^\"]+)\"/gi,' $1="$2" mce_$1="$2"');return z}})};q.DOM=a=new o(document);q.Event=w={events:[],inits:[],unloads:[],add:function(C,D,B,A){var x,y=this,z=y.events;C=a.get(C);x=function(E){E=E||window.event;if(E&&!E.target&&i){E.target=E.srcElement}if(!A){return B(E)}return B.call(A,E)};if(D=="unload"){y.unloads.push(x);return x}if(D=="init"){if(y._init){x()}else{y.inits.push(x)}return x}z.push({obj:C,name:D,func:B,cfunc:x,scope:A});y._add(C,D,x);if(i&&z.length==1){w._add(window,"unload",y._unload,w)}return x},remove:function(A,B,z){var y=this,x=y.events;A=a.get(A);d(x,function(D,C){if(D.obj==A&&D.name==B&&(!z||D.func==z)){x.splice(C,1);y._remove(A,B,D.cfunc);return false}})},cancel:function(x){this.stop(x);return this.prevent(x)},stop:function(x){if(x.stopPropagation){x.stopPropagation()}else{x.cancelBubble=true}return false},prevent:function(x){if(x.preventDefault){x.preventDefault()}else{x.returnValue=false}return false},_unload:function(){var x=w;d(x.events,function(y){x._remove(y.obj,y.name,y.cfunc)});x._remove(window,"unload",x._unload);x.events=[];d(x.unloads,function(y){y()})},_add:function(y,z,x){if(y.attachEvent){y.attachEvent("on"+z,x)}else{if(y.addEventListener){y.addEventListener(z,x,false)}else{y["on"+z]=x}}},_remove:function(y,z,x){if(y.detachEvent){y.detachEvent("on"+z,x)}else{if(y.removeEventListener){y.removeEventListener(z,x,false)}else{y["on"+z]=null}}},_pageInit:function(){var x=w;x._remove(window,"DOMContentLoaded",x._pageInit);x._init=true;d(x.inits,function(y){y()});x.inits=[]},_wait:function(){var x;if(i&&document.location.protocol!="https:"){document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");a.get("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){w._pageInit();a.get("__ie_onload").onreadystatechange=null}}}else{w._add(window,"DOMContentLoaded",w._pageInit,w);if(i||n){x=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(x);w._pageInit()}},10)}}}};q.Dispatcher=j=function(x){var y=[];if(!x){x=this}p(this,{add:function(z,A){y.push({cb:z,scope:!A?x:A});return z},remove:function(z){d(y,function(B,A){if(z==B.cb){y.splice(A,1)}return false});return z},dispatch:function(){var A,z=arguments;d(y,function(B){return A=B.cb.apply(B.scope,z)});return A}})};q.Editor=k=function(E){var B,C,z=this;if(!q.baseURL){d(a.select("script"),function(F){if(/puny_mce/g.test(""+F.src)){q.baseURL=F.src.replace(/^(.+)\/puny_mce.+$/,"$1/")}})}this.settings=B=p({content_css:q.baseURL+"/css/content.css",editor_css:q.baseURL+"/css/editor.css",width:0,height:0,min_width:260,min_height:50,max_width:800,max_height:600,entities:"raw",spellcheck:0,resize:true,plugins:"",styles:[{title:"H1",cls:"h1",cmd:"FormatBlock",val:"<h1>"},{title:"H2",cls:"h2",cmd:"FormatBlock",val:"<h2>"},{title:"H3",cls:"h3",cmd:"FormatBlock",val:"<h3>"},{title:"Pre",cls:"pre",cmd:"FormatBlock",val:"<pre>"},{title:"Times",cls:"times",cmd:"FontName",val:"Times"},{title:"Arial",cls:"arial",cmd:"FontName",val:"Arial"},{title:"Courier",cls:"courier",cmd:"FontName",val:"Courier"}],toolbar:"bold,italic,underline,strike,increasefontsize,decreasefontsize,ul,ol,indent,outdent,left,center,right,style,removeformat"},E);z.tools={bold:{cmd:"Bold",title:l.bold},italic:{cmd:"Italic",title:l.italic},underline:{cmd:"Underline",title:l.underline},strike:{cmd:"Strikethrough",title:l.strike},ul:{cmd:"InsertUnorderedList",title:l.ul},ol:{cmd:"InsertOrderedList",title:l.ol},indent:{cmd:"Indent",title:l.indent},outdent:{cmd:"Outdent",title:l.outdent},left:{cmd:"JustifyLeft",title:l.left},center:{cmd:"JustifyCenter",title:l.center},right:{cmd:"JustifyRight",title:l.right},style:{cmd:"mceStyle",title:l.style},removeformat:{cmd:"RemoveFormat",title:l.removeformat},increasefontsize:{cmd:"IncreaseFontSize",title:l.increasefontsize},decreasefontsize:{cmd:"DecreaseFontSize",title:l.decreasefontsize}};a.loadCSS(B.editor_css);this.commands={mceStyle:function(M,L,K){var H,N=this,O=N.settings,F=O.id,G=a.getPos(K.target),I;if(N.hideMenu){return N.hideMenu()}function J(P){N.hideMenu=null;w.remove(document,"click",J);w.remove(N.getDoc(),"click",J);a.get(F+"_mstyle").style.display="none"}H=a.get(F+"_mstyle");if(!H){H=a.get(F+"_t");H=a.add(document.body,"div",{id:F+"_mstyle","class":"punymce_style punymce"});d(O.styles,function(P){w.add(a.add(H,"a",{href:"#","class":P.cls},P.title),"mousedown",function(Q){J.call(N);N.execCommand(P.cmd,P.ui,P.val);if(t){N.getIfr().focus()}return w.cancel(Q)})})}N.hideMenu=J;w.add(document,"click",J,N);w.add(N.getDoc(),"click",J,N);O=H.style;O.left=G.x+"px";O.top=(G.y+K.target.clientHeight+2)+"px";O.display="block"},FormatBlock:function(G,F,H){if(h&&/<(div|blockquote|code|dt|dd|dl|samp)>/gi.test(F)){F=F.replace(/[^a-z]/gi,"")}z.getDoc().execCommand("FormatBlock",0,F)},CreateLink:function(H,G){var I=z.dom,F="javascript:mox();";z.getDoc().execCommand("CreateLink",0,F);d(I.select("A"),function(J){if(I.getAttr(J,"href")==F){I.setAttr(J,"href",G);I.setAttr(J,"mce_href",G)}})},mceFontSizeDelta:function(H,G){var L=z.getDoc(),F,K,I,J=z.selection;F=parseInt(L.queryCommandValue("FontSize")||3);if(n){d([10,13,16,18,24,32,48],function(N,M){if(F==N){F=M+1;return false}})}if(F+G<=1){return}L.execCommand("FontSize",false,F+G)},IncreaseFontSize:function(){z.execCommand("mceFontSizeDelta",0,1)},DecreaseFontSize:function(){z.execCommand("mceFontSizeDelta",0,-1)},Indent:function(G,F,H){z.getDoc().execCommand("Indent",0,0);if(i){z.dom.getParent(z.selection.getNode(),function(I){if(I.nodeName=="BLOCKQUOTE"){I.dir=I.style.marginRight=""}})}},mceSetClass:function(G,F,I){var H=z.selection;if(f(F,"string")){F={element:"span","class":F}}if(H.isCollapsed()){z.dom.setAttr(H.getNode(),"class",F["class"])}else{H.setContent("<"+F.element+' class="'+F["class"]+'">'+H.getContent()+"</"+F.element+">")}},RemoveFormat:function(G,F,I){var H=z.selection;z.getDoc().execCommand("RemoveFormat",G,F);if(i){F=H.getContent();F=F.replace(/ (class|style)=\"[^\"]+\"/g,"");F=F.replace(/<\/?(font|strong|em|b|i|u|strike)>/g,"");F=F.replace(/<(font|strong|em|b|i|u|strike) [^>]+>/g,"");H.setContent(F)}}};function A(I){var J,H,F,G;J=a.get(B.id+"_c");F=J.clientWidth-2;G=J.clientHeight-2;H=a.get(B.id+"_p");H.style.width=F+"px";H.style.height=G+"px";J.style.display="none";H.style.display="block";z.resize={x:I.screenX,y:I.screenY,w:F,h:G};w.add(document,"mousemove",y,this);w.add(document,"mouseup",D,this);z.onResizeStart.dispatch(z,I,F,G)}function y(J){var H=z.resize,I,F,G;H.dx=J.screenX-H.x;H.dy=J.screenY-H.y;F=Math.max(B.min_width,H.w+H.dx);G=Math.max(B.min_height,H.h+H.dy);F=Math.min(B.max_width,F);G=Math.min(B.max_height,G);I=a.get(B.id+"_p");I.style.width=F+"px";I.style.height=G+"px";return w.cancel(J)}function D(G){var F=z.resize;w.remove(document,"mousemove",y,this);w.remove(document,"mouseup",D,this);a.get(B.id+"_c").style.display="";a.get(B.id+"_p").style.display="none";z.resizeBy(F.dx,F.dy);z.onResizeEnd.dispatch(z,G,F.dx,F.dy)}function x(){var F=a.get(B.id),G=z.getDoc();if(h){z.getDoc().designMode="On"}G.open();G.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body id="punymce"></body></html>');G.close();z.dom=C=new o(z.getDoc());C.loadCSS(B.content_css);z.onPreInit.dispatch(z);if(!B.spellcheck){z.getBody().spellcheck=0}w.add(z.getDoc(),"mouseup",z.nodeChanged,z);w.add(z.getDoc(),"keyup",z.nodeChanged,z);w.add(h?z.getDoc():z.getWin(),"focus",function(I){var H;if((H=q.focusEditor)!=null){H.onBlur.dispatch(H,z)}z.onFocus.dispatch(z,H);q.focusEditor=z},this);if(!i){z.getDoc().designMode="On"}else{z.getBody().contentEditable=true}z.setContent(f(F.value)?F.value:F.innerHTML,{load:true});a.get(B.id+"_c").style.display=z.orgDisplay;a.get(B.id).style.display="none";z.onInit.dispatch(z)}p(this,{serializer:new e(z),selection:new c(z),plugins:[]});d(["onPreInit","onInit","onFocus","onBlur","onResizeStart","onResizeEnd","onPreProcess","onPostProcess","onSetContent","onBeforeGetContent","onGetContent","onNodeChange"],function(F){z[F]=new j(z)});p(this,{init:function(){var K=a.get(B.id),M=K.parentNode,O,I,N,L,G,F,J,H=["bold","italic","underline","left","center","right"];d(B.plugins.split(","),function(P){if(P){z.plugins.push(new q.plugins[P](z))}});z.onNodeChange.add(function(){d(H,function(R){var Q;try{Q=z.getDoc().queryCommandState(z.tools[R].cmd)?a.addClass:a.removeClass;Q.call(a,B.id+"_"+R,"active")}catch(P){}})});if(B.entities=="numeric"){z.onGetContent.add(function(P,Q){if(Q.format=="html"){Q.content=Q.content.replace(/[\u007E-\uFFFF]/g,function(R){return"&#"+R.charCodeAt(0)+";"})}})}O=!B.width?K.offsetWidth:B.width;I=!B.height?K.offsetHeight:B.height;z.orgDisplay=K.style.display;K.style.display="none";if(K.form){J=K.form;z._submit=J.submit;J.submit=function(){var Q=a.get(B.id),P=Q.form;z.save();P.submit=z._submit;P.submit()};w.add(0,"unload",function(){var P=a.get(B.id).form;z._submit=z.submit=null});w.add(J,"submit",z.save,z)}N='<div id="'+B.id+'_w" class="punymce"><table id="'+B.id+'_c" class="punymce"><tr class="mceToolbar">';N+='<td id="'+B.id+'_t"></td></tr><tr class="mceBody"><td></div><div id="'+B.id+'_b" class="mceBody">';if(B.resize){N+='<div id="'+B.id+'_r" class="mceResize"></div>'}N+="</td></tr></table>";N+='<div id="'+B.id+'_p" class="mcePlaceholder"></div></div>';if(!K.insertAdjacentHTML){F=K.ownerDocument.createRange();F.setStartBefore(K);M.insertBefore(F.createContextualFragment(N),K)}else{K.insertAdjacentHTML("beforeBegin",N)}G=a.get(B.id+"_t");L=a.add(G,"ul",{id:B.id+"_tb","class":"punymce"});d(B.toolbar.split(","),function(P){var Q=z.tools[P];G=a.add(a.add(L,"li",{id:B.id+"_"+P,"class":P}),"a",{href:"javascript:void(0);","class":P,title:Q.title,tabIndex:-1,onmousedown:"return false;"});w.add(G,"click",function(R){if(!a.hasClass(R.target.parentNode,"disabled")){z.execCommand(Q.cmd,0,0,R)}return w.cancel(R)})});G=a.get(B.id+"_b");G=a.add(G,"iframe",{id:B.id+"_f",src:'javascript:""',frameBorder:"0","class":"punymce",style:"width:"+O+"px;height:"+I+"px"});z.resizeTo(O,I);if(n){w.add(G,"load",x,z);G.src=q.baseURL+"blank.htm"}else{x()}if(B.resize){w.add(B.id+"_r","mousedown",function(P){return A(P,B.id)},this)}L=J=K=G=null},getSize:function(){var F=a.get(B.id+"_f");return{w:F.clientWidth,h:F.clientHeight}},resizeTo:function(F,H){var G=a.get(B.id+"_f").style;F=Math.max(B.min_width,F);H=Math.max(B.min_height,H);F=Math.min(B.max_width,F);H=Math.min(B.max_height,H);z.width=F;z.height=H;G.width=F+"px";G.height=H+"px"},resizeBy:function(F,G){var H=z.getSize();z.resizeTo(H.w+F,H.h+G)},show:function(){a.get(B.id+"_w").style.display="block";a.get(B.id).style.display="none";z.load()},hide:function(){if(i){z.execCommand("SelectAll")}a.get(B.id+"_w").style.display="none";a.get(B.id).style.display=z.orgDisplay;z.save()},load:function(){var F=a.get(B.id);z.setContent(f(F.value)?F.value:F.innerHTML,{load:true})},save:function(){var G=a.get(B.id),F=z.getContent({save:true});if(/TEXTAREA|INPUT/.test(G.nodeName)){G.value=F}else{G.innerHTML=F}},setUseCSS:function(F){var H=z.getDoc(),G;try{H.execCommand("styleWithCSS",0,false)}catch(G){try{H.execCommand("useCSS",0,true)}catch(G){}}},execCommand:function(K,H,G,J){var F=z.commands,I;z.getWin().focus();z.setUseCSS(0);if(F[K]){I=F[K].call(z,H,G,J)}else{I=z.getDoc().execCommand(K,H,G)}if(I!==false){z.nodeChanged()}},getContent:function(G){var F;G=G||{};G.format=G.format||"html";z.onBeforeGetContent.dispatch(this,G);F=z.serializer.serialize(z.getBody(),G);F=F.replace(/^\s*|\s*$/g,"");G.content=F;z.onGetContent.dispatch(this,G);return G.content},setContent:function(F,G){G=G||{};G.content=F;z.onSetContent.dispatch(this,G);F=G.content;F=a.keep(F);z.getBody().innerHTML=F;if(G.format!="raw"){z.setContent(F=z.getContent(G),{format:"raw"})}else{z.getBody().innerHTML=F}return F},getIfr:function(){return a.get(B.id+"_f")},getWin:function(){return z.getIfr().contentWindow},getDoc:function(){return z.getWin().document},getBody:function(){return z.getDoc().body},nodeChanged:function(){z.setUseCSS(0);z.onNodeChange.dispatch(z,z.selection.getNode())}});w.add(window,"init",z.init,this)};q.Selection=c=function(x){var y=this;p(y,{getContent:function(C){var z,A=y.getRng(),B=document.createElement("body");C=C||{};if(y.isCollapsed()){return""}if(A.cloneContents){B.appendChild(A.cloneContents())}else{if(f(A.item)||f(A.htmlText)){B.innerHTML=A.item?A.item(0).outerHTML:A.htmlText}else{B.innerHTML=A.toString()}}if(C.format!="raw"){C.content=z;x.serializer.serialize(B,C);C.content=C.content.replace(/^\s*|\s*$/g,"");x.onGetContent.dispatch(z,C);z=C.content}else{z=B.innerHTML}return z},getText:function(){var A=y.getRng(),z=y.getSel();if(u){return z}return y.isCollapsed()?"":A.text||z.toString()},setContent:function(B,D){var C=y.getRng(),z,E,C,A;D=D||{format:"raw"};B=a.keep(B);if(D.format!="raw"){D.content=B;B=x.onSetContent.dispatch(this,D);B=D.content;z=x.dom.create("body");z.innerHTML=B}if(C.insertNode){C.deleteContents();C.insertNode(C.createContextualFragment(B+'<span id="__caret">_</span>'));E=x.dom.get("__caret");C=x.getDoc().createRange();C.setStartBefore(E);C.setEndBefore(E);A=y.getSel();A.removeAllRanges();A.addRange(C);E.parentNode.removeChild(E)}else{if(C.pasteHTML){C.pasteHTML(B)}else{C.item(0).outerHTML=B}}},select:function(D,C){var B=y.getRng(),A=y.getSel();if(B.moveToElementText){try{B.moveToElementText(D);B.select()}catch(z){}}else{if(A.addRange){C?B.selectNodeContents(D):B.selectNode(D);A.removeAllRanges();A.addRange(B)}else{A.setBaseAndExtent(D,0,D,1)}}return D},isCollapsed:function(){var z=y.getRng();if(z.item){return false}return z.boundingWidth==0||y.getSel().isCollapsed},collapse:function(z){var B=y.getRng(),A=y.getSel();if(B.select){B.collapse(z);B.select()}else{if(z){A.collapseToStart()}else{A.collapseToEnd()}}},getSel:function(){var z=x.getWin();return z.getSelection?z.getSelection():x.getDoc().selection},getRng:function(){var z=y.getSel(),F=x.getDoc(),B,D,E,A;if(!z){return null}try{return z.rangeCount>0?z.getRangeAt(0):(z.createRange?z.createRange():null)}catch(C){return F.body.createTextRange()}},setRng:function(A){var z=y.getSel();z.removeAllRanges();z.addRange(A)},setNode:function(z){y.setContent(x.dom.create("div",null,z).innerHTML)},getNode:function(){var A=y.getRng(),z=y.getSel(),B;if(!i){if(A){B=A.commonAncestorContainer;if(!A.collapsed){if(A.startContainer==A.endContainer){if(A.startOffset-A.endOffset<2){if(A.startContainer.hasChildNodes()){B=A.startContainer.childNodes[A.startOffset]}}}}}return a.getParent(B,function(C){return C.nodeType==1})}return A.item?A.item(0):A.parentElement()}})};q.Serializer=e=function(y){var A,B=0,C;function z(){var F=document.implementation;if(!F||!F.createDocument){try{return new ActiveXObject("MSXML2.DOMDocument")}catch(E){}try{return new ActiveXObject("Microsoft.XmlDom")}catch(E){}}else{return F.createDocument("","",null)}}A=z();this.settings=C=p({valid_nodes:0,invalid_nodes:/(BODY)/,valid_attrs:0,node_filter:0,root_node:0,pi:0,invalid_attrs:/(^mce_|^_moz_|^contenteditable$)/,closed:/(BR|HR|INPUT|META|IMG)/},y.settings.serializer);function D(F){var E=[];F.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(H,G){E.push({specified:1,nodeName:G})});return E}function x(G,J){var K,E,L,I,H,M,F,O,N;if((!C.valid_nodes||C.valid_nodes.test(G.nodeName))&&(!C.invalid_nodes||!C.invalid_nodes.test(G.nodeName))&&(!C.node_filter||C.node_filter(G,J))){switch(G.nodeType){case 1:if(i){if(G.mce_serialized==B){return}G.mce_serialized=B}K=G.hasChildNodes();E=A.createElement(G.nodeName.toLowerCase());F=i?D(G):G.attributes;for(I=F.length-1;I>-1;I--){O=F[I];if(O.specified){M=O.nodeName.toLowerCase();if(C.invalid_attrs&&C.invalid_attrs.test(M)){continue}if(C.valid_attrs&&!C.valid_attrs.test(M)){continue}N=a.getAttr(G,M);if(N!==""){E.setAttribute(M,N)}}}if(!K&&!C.closed.test(G.nodeName)){E.appendChild(A.createTextNode(""))}J=J.appendChild(E);break;case 3:return J.appendChild(A.createTextNode(G.nodeValue));case 8:return J.appendChild(A.createComment(G.nodeValue))}}else{if(G.nodeType==1){K=G.hasChildNodes()}}if(K){L=G.firstChild;while(L){x(L,J);L=L.nextSibling}}}p(this,{serialize:function(G,F){var E;B=""+(parseInt(B)+1);if(A.firstChild){A.removeChild(A.firstChild)}G=F.node=G.cloneNode(1);y.onPreProcess.dispatch(this,F);x(G,A.appendChild(A.createElement("html")));E=A.xml||new XMLSerializer().serializeToString(A);if(!C.pi){E=E.replace(/<\?[^?]+\?>/g,"")}if(!C.root_node){E=E.replace(/<html>|<\/html>/g,"")}F.content=E;y.onPostProcess.dispatch(this,F);return F.content}})};w._wait();window.punymce=q})({});(function(a){a.plugins.ForceBlocks=function(e){var y=a.Event,w,h=this;var o,l,x,u;var d,v,q;o=a.isIE;l=a.isGecko;x=a.isOpera;u=a.isWebKit;d=a.each;v=a.extend;this.settings=q=v({element:"P"},e.settings.forceblocks);e.onPreInit.add(n,h);if(!o){e.onSetContent.add(function(t,z){if(z.format=="html"){z.content=z.content.replace(/<p>[\s\u00a0]+<\/p>/g,"<p><br /></p>")}})}e.onPostProcess.add(function(t,z){z.content=z.content.replace(/<p><\/p>/g,"<p>\u00a0</p>")});function n(){w=e.dom;y.add(e.getDoc(),"keyup",k);e.onSetContent.add(k);e.onBeforeGetContent.add(k);if(!o){e.onPreProcess.add(function(t,z){d(z.node.getElementsByTagName("br"),function(B){var A=B.parentNode;if(A&&A.nodeName=="p"&&(A.childNodes.length==1||A.lastChild==B)){A.replaceChild(t.getDoc().createTextNode("\u00a0"),B)}})});y.add(e.getDoc(),"keypress",function(t){if(t.keyCode==13&&!t.shiftKey){if(!p(t)){return y.cancel(t)}}});if(l){y.add(e.getDoc(),"keydown",function(t){if((t.keyCode==8||t.keyCode==46)&&!t.shiftKey){i(t,t.keyCode==8)}})}}}function c(z){var A,t;A=z.document;t=A.compatMode=="CSS1Compat"?A.documentElement:A.body;return{x:z.pageXOffset||t.scrollLeft,y:z.pageYOffset||t.scrollTop,w:z.innerWidth||t.clientWidth,h:z.innerHeight||t.clientHeight}}function m(D,A,B){var z=e.getDoc().createTreeWalker(D,4,null,false),D,C=-1;while(D=z.nextNode()){C++;if(A==0&&D==B){return C}if(A==1&&C==B){return D}}return -1}function k(){var F=this,R=e.getBody(),O=e.getDoc(),U=e.selection,G=U.getSel(),H=U.getRng(),S=-2,D,M,z,A,P=-16777215;var Q,B,T,L,I,C=R.childNodes,K,J,E;for(K=C.length-1;K>=0;K--){Q=C[K];if(Q.nodeType==3||(!g(Q)&&Q.nodeType!=8)){if(!B){if(Q.nodeType!=3||/[^\s]/g.test(Q.nodeValue)){if(S==-2&&H){if(!o){if(H.startContainer.nodeType==1&&(J=H.startContainer.childNodes[H.startOffset])&&J.nodeType==1){E=J.getAttribute("id");J.setAttribute("id","__mce")}else{if(e.dom.getParent(H.startContainer,function(t){return t===R})){M=H.startOffset;z=H.endOffset;S=m(R,0,H.startContainer);D=m(R,0,H.endContainer)}}}else{A=O.body.createTextRange();A.moveToElementText(R);A.collapse(1);T=A.move("character",P)*-1;A=H.duplicate();A.collapse(1);L=A.move("character",P)*-1;A=H.duplicate();A.collapse(0);I=(A.move("character",P)*-1)-L;S=L-T;D=I}}B=e.dom.create(q.element);B.appendChild(Q.cloneNode(1));Q.parentNode.replaceChild(B,Q)}}else{if(B.hasChildNodes()){B.insertBefore(Q,B.firstChild)}else{B.appendChild(Q)}}}else{B=null}}if(S!=-2){if(!o){B=R.getElementsByTagName(q.element)[0];H=O.createRange();if(S!=-1){H.setStart(m(R,1,S),M)}else{H.setStart(B,0)}if(D!=-1){H.setEnd(m(R,1,D),z)}else{H.setEnd(B,0)}if(G){G.removeAllRanges();G.addRange(H)}}else{try{H=G.createRange();H.moveToElementText(R);H.collapse(1);H.moveStart("character",S);H.moveEnd("character",D);H.select()}catch(N){}}}else{if(!o&&(J=e.dom.get("__mce"))){if(E){J.setAttribute("id",E)}else{J.removeAttribute("id")}H=O.createRange();H.setStartBefore(J);H.setEndBefore(J);U.setRng(H)}}}function g(t){return t.nodeType==1&&/^(H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CODE|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(t.nodeName)}function f(t){return w.getParent(t,function(z){return g(z)})}function j(t){t=t.innerHTML;t=t.replace(/<img|hr|table/g,"d");t=t.replace(/<[^>]+>/g,"");return t.replace(/[ \t\r\n]+/g,"")==""}function p(Q){var R=e.getDoc(),I=e.selection.getSel(),J=e.selection.getRng(),S=R.body;var M,N,K,P,O,B,z,C,E,t,G,T,A,D,L,F,H;if(a.isOldWebKit){return true}M=R.createRange();M.setStart(I.anchorNode,I.anchorOffset);M.collapse(true);N=R.createRange();N.setStart(I.focusNode,I.focusOffset);N.collapse(true);K=M.compareBoundaryPoints(M.START_TO_END,N)<0;P=K?I.anchorNode:I.focusNode;O=K?I.anchorOffset:I.focusOffset;B=K?I.focusNode:I.anchorNode;z=K?I.focusOffset:I.anchorOffset;P=P.nodeName=="BODY"?P.firstChild:P;B=B.nodeName=="BODY"?B.firstChild:B;C=f(P);E=f(B);t=C?C.nodeName:q.element;if(w.getParent(C,function(U){return/OL|UL/.test(U.nodeName)})){return true}if(C&&(C.nodeName=="CAPTION"||/absolute|relative|static/gi.test(C.style.position))){t=q.element;C=null}if(E&&(E.nodeName=="CAPTION"||/absolute|relative|static/gi.test(E.style.position))){t=q.element;E=null}if(/(TD|TABLE|TH|CAPTION)/.test(t)||(C&&t=="DIV"&&/left|right/gi.test(C.style.cssFloat))){t=q.element;C=E=null}G=(C&&C.nodeName==t)?C.cloneNode(0):R.createElement(t);T=(E&&E.nodeName==t)?E.cloneNode(0):R.createElement(t);T.id="";if(/^(H[1-6])$/.test(t)&&P.nodeValue&&O==P.nodeValue.length){T=R.createElement(q.element)}L=A=P;do{if(L==S||L.nodeType==9||g(L)||/(TD|TABLE|TH|CAPTION)/.test(L.nodeName)){break}A=L}while((L=L.previousSibling?L.previousSibling:L.parentNode));L=D=B;do{if(L==S||L.nodeType==9||g(L)||/(TD|TABLE|TH|CAPTION)/.test(L.nodeName)){break}D=L}while((L=L.nextSibling?L.nextSibling:L.parentNode));if(A.nodeName==t){M.setStart(A,0)}else{M.setStartBefore(A)}M.setEnd(P,O);G.appendChild(M.cloneContents());N.setEndAfter(D);N.setStart(B,z);T.appendChild(N.cloneContents());J=R.createRange();if(!A.previousSibling&&A.parentNode.nodeName==t){J.setStartBefore(A.parentNode)}else{if(M.startContainer.nodeName==t&&M.startOffset==0){J.setStartBefore(M.startContainer)}else{J.setStart(M.startContainer,M.startOffset)}}if(!D.nextSibling&&D.parentNode.nodeName==t){J.setEndAfter(D.parentNode)}else{J.setEnd(N.endContainer,N.endOffset)}J.deleteContents();if(G.firstChild&&G.firstChild.nodeName==t){G.innerHTML=G.firstChild.innerHTML}if(T.firstChild&&T.firstChild.nodeName==t){T.innerHTML=T.firstChild.innerHTML}if(j(G)){G.innerHTML=x?" <br />":"<br />"}if(j(T)){T.innerHTML=x?" <br />":"<br />"}if(x){J.insertNode(G);J.insertNode(T)}else{J.insertNode(T);J.insertNode(G)}T.normalize();G.normalize();J=R.createRange();J.selectNodeContents(T);J.collapse(1);I.removeAllRanges();I.addRange(J);vp=c(e.getWin());F=e.dom.getPos(T).y;H=T.clientHeight;if(F<vp.y||F+H>vp.y+vp.h){e.getWin().scrollTo(0,F<vp.y?F:F-vp.h+25)}return false}function i(A,G){var D=e.getBody(),z,B=e.selection,t=B.getRng(),C=t.startContainer,z,E,F;if(C&&g(C)&&!/^(TD|TH)$/.test(C.nodeName)&&G){if(C.childNodes.length==0||(C.childNodes.length==1&&C.firstChild.nodeName=="BR")){z=C;while((z=z.previousSibling)&&!g(z)){}if(z){if(C!=D.firstChild){E=e.getDoc().createTreeWalker(z,NodeFilter.SHOW_TEXT,null,false);while(F=E.nextNode()){z=F}t=e.getDoc().createRange();t.setStart(z,z.nodeValue?z.nodeValue.length:0);t.setEnd(z,z.nodeValue?z.nodeValue.length:0);B.getSel().removeAllRanges();B.getSel().addRange(t);C.parentNode.removeChild(C)}return y.cancel(A)}}}function H(I){var J;I=I.target;if(I&&I.parentNode&&I.nodeName=="BR"&&(z=f(I))){J=I.previousSibling;y.remove(D,"DOMNodeInserted",H);if(J&&J.nodeType==3&&/\s+$/.test(J.nodeValue)){return}if(I.previousSibling||I.nextSibling){I.parentNode.removeChild(I)}}}y._add(D,"DOMNodeInserted",H);window.setTimeout(function(){y._remove(D,"DOMNodeInserted",H)},1)}}})(punymce);(function(a){a.plugins.Emoticons=function(f){var l=a.Event,j,i,d,c,n,k,m,e;j=a.each;i=a.extend;d=a.isIE;c=a.isGecko;m=a.DOM;this.settings=n=i({emoticons:{happy:[":)","=)"],unhappy:[":|","=|"],sad:[":(","=("],grin:[":D","=D"],surprised:[":o",":O","=o","=O"],wink:[";)"],halfhappy:[":/","=/"],tounge:[":P",":p","=P","=p"],lol:[],mad:[],rolleyes:[],cool:[]},row_length:4,trans_img:a.baseURL+"plugins/emoticons/img/trans.gif",skip_css:0,auto_convert:1},f.settings.emoticons);if(!n.skip_css){m.loadCSS(a.baseURL+"/plugins/emoticons/css/editor.css")}k="";j(n.emoticons,function(h){j(h,function(o){if(k.length!=0){k+="|"}k+=o.replace(/([^a-zA-Z0-9])/g,"\\$1")})});k=new RegExp(k,"g");i(f.commands,{mceEmoticons:function(B,A,y){var q,C=this,h=f.settings.id,o=m.getPos(y.target),z,w;if(f.hideMenu){return f.hideMenu()}function x(p){f.hideMenu=null;l.remove(document,"click",x);l.remove(f.getDoc(),"click",x);m.get(h+"_memoticons").style.display="none";return 1}q=m.get(h+"_memoticons");if(!q){q=m.get(h+"_t");q=m.add(document.body,"div",{id:h+"_memoticons","class":"punymce_emoticons punymce"});q=m.add(q,"table",{"class":"punymce"});q=m.add(q,"tbody");z=n.row_length;j(n.emoticons,function(t,p){if(z==n.row_length){r=m.add(q,"tr");z=0}z++;l.add(m.add(m.add(r,"td"),"a",{href:"#","class":"emoticon "+p}),"mousedown",function(u){x.call(C);f.selection.setNode(f.dom.create("img",{title:t[0]||p,src:n.trans_img,"class":"emoticon "+p}));return l.cancel(u)})})}l.add(document,"click",x,C);l.add(f.getDoc(),"click",x,C);f.hideMenu=x;s=m.get(h+"_memoticons").style;s.left=o.x+"px";s.top=(o.y+y.target.clientHeight+2)+"px";s.display="block"}});function g(h){var o;j(n.emoticons,function(q,p){j(q,function(t){if(t==h){o=p;return false}});return !o});return o}f.onPreProcess.add(function(q,t){var p=t.node.getElementsByTagName("img"),h=[];j(p,function(o){h.push(o)});j(h,function(u){var o=f.dom.getAttr(u,"class");if(o&&o.indexOf("emoticon")!=-1){u.parentNode.replaceChild(f.getDoc().createTextNode(u.getAttribute("title")),u)}})});f.onSetContent.add(function(p,q){var h=[];e=q.content.replace(/(<\/?[^>]+>|:\/\/)/g,function(o){return o.replace(k,function(t){var u=g(t);if(u){h.push(t);return"�"+h.length+"�"}return t})});e=e.replace(k,function(o){return'<img src="'+n.trans_img+'" title="'+o+'" class="emoticon '+g(o)+'" />'});e=e.replace(/�([^�]+)�/g,function(t,o){return h[parseInt(o)-1]});q.content=e});f.onInit.add(function(){var h=f.dom;if(!n.skip_css){h.loadCSS(a.baseURL+"/plugins/emoticons/css/content.css")}l.add(f.getDoc(),"controlselect",function(o){if(h.getAttr(o.target,"class").indexOf("emoticon")!=-1){return l.cancel(o)}});if(c){l.add(f.getDoc(),"mousedown",function(o){if(h.getAttr(o.target,"class").indexOf("emoticon")!=-1){f.getDoc().execCommand("enableObjectResizing",false,false);return l.cancel(o)}else{f.getDoc().execCommand("enableObjectResizing",false,true)}});l.add(f.getDoc(),"keydown",function(u){var y=f.selection,v=y.getSel(),w=f.getDoc(),o=y.getRng(),x,p,q,t;x=o.startContainer;p=o.startOffset;if(x.nodeType==1){return}if(x){if(u.keyCode==39&&p==x.nodeValue.length){q=x.nextSibling;if(q&&q.nodeName=="IMG"){q=q.nextSibling;o=w.createRange();o.setStart(q,0);o.setEnd(q,0);v.removeAllRanges();v.addRange(o);return l.cancel(u)}}if(u.keyCode==37&&p==0){q=x.previousSibling;if(q&&q.nodeName=="IMG"){q=q.previousSibling;t=q.nodeValue.length;o=w.createRange();o.setStart(q,t);o.setEnd(q,t);v.removeAllRanges();v.addRange(o);return l.cancel(u)}}}})}l.add(f.getDoc(),"keypress",function(u){var q,y,p,x,w=f.getDoc(),v=f.selection,z=v.getSel(),o=v.getRng();function t(D){var C,B,A;if(!d){C=o.startContainer;B=o.startOffset;A=o.endOffset;if(B>0&&C.nodeType==3){return C.nodeValue.substring(Math.max(0,B+D),A)}}else{o=o.duplicate();o.moveStart("character",D);return o.text}}if(a.isOldWebKit||!n.auto_convert){return true}if(/(ttp|ftp):/i.test(t(-4))){return}p=t(-1);q=p+String.fromCharCode(u.charCode||u.keyCode);k.lastIndex=0;if(!p||!k.test(q)||x=="/"){return}if(y=g(q)){if(!d){o.setStart(o.startContainer,o.startOffset-1);z.removeAllRanges();z.addRange(o)}else{o=f.selection.getRng();o.moveStart("character",-1);o.select()}f.selection.setNode(h.create("img",{id:"emoticon",title:q,src:n.trans_img,"class":"emoticon "+y}));q=h.get("emoticon");h.setAttr(q,"id","");f.selection.select(q);f.selection.collapse(0);return l.cancel(u)}})});i(f.tools,{emoticons:{cmd:"mceEmoticons",title:a.I18n.emoticons}})};a.extend(a.I18n,{emoticons:"Insert emoticon"})})(punymce);(function(a){a.plugins.EditSource=function(d){var e=a.DOM,h=a.extend,g=a.each,f=a.isWebKit;var c=0;if(!d.settings.editsource||d.settings.editsource.skip_css){e.loadCSS(a.baseURL+"/plugins/editsource/css/editor.css")}d.onBeforeGetContent.add(function(i,j){if(j.save&&c){i.setContent(e.get(i.settings.id+"_editsourcearea").value,{load:true})}});h(d.commands,{mceEditSource:function(t,q,o){var k,j=d.getIfr(),i=d.settings.id,p=d.width,l=d.height,n,m=e.get(i+"_editsource");if(!c){e.addClass(m,"active");g(e.select("li",i+"_c"),function(u){if(u!=m){e.addClass(u,"disabled")}});k=e.add(j.parentNode,"textarea",{id:i+"_editsourcearea","class":"editsource",style:"width:"+p+"px;height:"+l+"px;"});k.value=d.getContent({save:true});k.focus();if(!f){e.add(j.parentNode,"div",{id:i+"_edspacer","class":"spacer",style:"width:"+p+"px;height:"+l+"px;"});j.style.display="none"}c=1;return false}c=0;e.removeClass(m,"active");if(!f){j.style.display="block";k=e.get(i+"_edspacer");k.parentNode.removeChild(k)}k=e.get(i+"_editsourcearea");d.setContent(k.value,{load:true});k.parentNode.removeChild(k);g(e.select("li",i+"_c"),function(u){e.removeClass(u,"disabled")});return false}});h(d.tools,{editsource:{cmd:"mceEditSource",title:a.I18n.editsource}})};a.extend(a.I18n,{editsource:"Edit HTML source"})})(punymce);(function(a){a.plugins.Image=function(c){var d=a.I18n;if(!c.settings.image||c.settings.image.skip_css){a.DOM.loadCSS(a.baseURL+"/plugins/image/css/editor.css")}a.extend(c.commands,{mceInsertImage:function(i,h,k){var g,j=c.selection.getNode();g=prompt(d.entersrc,j.nodeName=="IMG"?c.dom.getAttr(j,"src"):"");if(g){c.selection.setNode(c.dom.create("img",{src:g}))}}});a.extend(c.tools,{image:{cmd:"mceInsertImage",title:d.insertimage}})};a.extend(a.I18n,{insertimage:"Insert image",entersrc:"Enter the URL of the image"})})(punymce);(function(a){a.plugins.Link=function(c){var d=a.I18n;if(!c.settings.link||c.settings.link.skip_css){a.DOM.loadCSS(a.baseURL+"/plugins/link/css/editor.css")}a.extend(c.commands,{mceInsertLink:function(i,h,k){var g,j=c.selection.getNode();g=prompt(d.enterhref,j.nodeName=="A"?c.dom.getAttr(j,"href"):"");if(g){if(c.selection.isCollapsed()){c.selection.setContent('<a href="'+g+'">'+g+"</a>")}else{c.execCommand("CreateLink",0,g)}}}});a.extend(c.tools,{link:{cmd:"mceInsertLink",title:d.link},unlink:{cmd:"Unlink",title:d.unlink}})};a.extend(a.I18n,{link:"Insert link",unlink:"Unlink",enterhref:"Enter the URL of the link"})})(punymce);(function(a){a.plugins.TextColor=function(e){var d="000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF";var g=a.DOM,c=a.Event,h=a.each,i=a.extend,f;if(!e.settings.textcolor||e.settings.textcolor.skip_css){g.loadCSS(a.baseURL+"/plugins/textcolor/css/editor.css")}f=i({colors:d},e.settings.textcolor);i(e.commands,{mceColor:function(y,x,q){var l,z=this,j=e.settings.id,k=g.getPos(q.target),w,m;if(e.hideMenu){return e.hideMenu()}function o(n){e.hideMenu=null;c.remove(document,"click",o);c.remove(e.getDoc(),"click",o);g.get(j+"_mcolor").style.display="none";return 1}l=g.get(j+"_mcolor");if(!l){l=g.get(j+"_t");l=g.add(document.body,"div",{id:j+"_mcolor","class":"punymce_color punymce"});l=g.add(l,"table",{"class":"punymce"});l=g.add(l,"tbody");w=8;h(f.colors.split(","),function(n){if(w==8){r=g.add(l,"tr");w=0}w++;c.add(g.add(g.add(r,"td"),"a",{href:"#",style:"background:#"+n}),"mousedown",function(p){o.call(z);e.execCommand("forecolor",0,"#"+n);return c.cancel(p)})})}c.add(document,"click",o,z);c.add(e.getDoc(),"click",o,z);e.hideMenu=o;f=g.get(j+"_mcolor").style;f.left=k.x+"px";f.top=(k.y+q.target.clientHeight+2)+"px";f.display="block"}});i(e.tools,{textcolor:{cmd:"mceColor",title:a.I18n.textcolor}})};a.extend(a.I18n,{textcolor:"Text color"})})(punymce);(function(c){var a=c.Event;function d(i,g){var h,f;h=g.parentNode;f=g.nextSibling;if(f){h.insertBefore(i,f)}else{h.appendChild(i)}return i}function e(h,j,i){var f,g=h.getDoc().createTreeWalker(j,NodeFilter.SHOW_TEXT,null,false);if(i){return g.nextNode()}while(f=g.nextNode()){j=f}return j}c.plugins.Paste=function(g){var j=c.DOM,h;g.onPaste=new c.Dispatcher(g);function i(w){var x,u=[],n,t,m=g.selection,l,o,q,k,p;g.getWin().focus();if(h){r=g.selection.getRng();r.moveToBookmark(h);r.select()}x=w.split(/\r?\n/);if(x.length>1){w="";c.each(x,function(v){w+="<p>"+v+"</p>"});if(!c.isIE){g.execCommand("Delete");m.setContent('<span id="marker"></span>');n=g.dom.getParent(g.dom.get("marker").parentNode,function(v){u.push(v);if(/^(p|h[1-6]|div)$/i.test(v.nodeName)){return true}});if(n){g.onPaste.dispatch({text:w});l=o="";for(q=0;q<u.length;q++){l+="</"+u[q].nodeName.toLowerCase()+">"}for(q=u.length-1;q>=0;q--){o+="<"+u[q].nodeName.toLowerCase()+">"}w=l+w+o+'<span id="_caret">&nbsp;</span>';g.getBody().innerHTML=g.getBody().innerHTML.replace(/<span id=\"marker\"><\/span>/gi,w);t=g.dom.get("_caret");if(!c.isGecko){t.scrollIntoView()}k=g.getDoc().createRange();k.setStartBefore(t);k.setEndAfter(t);m.setRng(k);g.execCommand("Delete");return}else{p=g.dom.get("marker");p.parentNode.removeChild(p)}}}g.selection.setContent(w);g.onPaste.dispatch({text:w})}function f(q){var t,l,o=g.selection,m=o.getSel(),p,k=g.getBody();t=g.dom.add(k,"div",{id:"_mcePaste",style:"position:absolute;left:-10000px;top:"+k.scrollTop},"&nbsp;");p=o.getRng();t=t.firstChild;l=g.getDoc().createRange();l.setStart(t,0);l.setEnd(t,1);m.removeAllRanges();m.addRange(l);window.setTimeout(function(){var v=g.dom.get("_mcePaste"),u;u=v.innerHTML;v.parentNode.removeChild(v);if(p){o.setRng(p)}i(u.replace(/[\r\n]/g,"").replace(/<(\/p|br\s*\/?)>/g,"\n").replace(/<!--.*?-->/g,"").replace(/<[^>]+>/g,""))},0)}g.onInit.add(function(){if(c.isOpera){return}if(/Firefox\/2/.test(navigator.userAgent)){a.add(g.getDoc(),"keydown",function(k){if(((k.metaKey||k.ctrlKey)&&k.keyCode==86)||(k.shiftKey&&k.keyCode==45)){if(c.isIE){h=g.selection.getRng().getBookmark()}f(k)}},this)}else{a.add(c.isIE?g.getBody():g.getDoc(),"paste",function(k){var l;if(g.getWin().clipboardData){i(g.getWin().clipboardData.getData("Text"));return a.cancel(k)}if(k.clipboardData){i(k.clipboardData.getData("text/plain"));return a.cancel(k)}f(k)})}})}})(punymce);(function(a){a.plugins.BBCode=function(c){c.onGetContent.add(function(d,e){if(e.format=="bbcode"||e.save){a.each([[/<a href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"],[/<font.*?color=\"([^\"]+)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"],[/<img.*?src=\"([^\"]+)\".*?\/>/gi,"[img]$1[/img]"],[/<(br\s*\/)>/gi,"\n"],[/<(\/?)(strong|b)[^>]*>/gi,"[$1b]"],[/<(\/?)(em|i)[^>]*>/gi,"[$1i]"],[/<(\/?)u[^>]*>/gi,"[$1u]"],[/<(\/?)(code|pre)[^>]*>/gi,"[$1code]"],[/<(\/?)(span.*?class=\"quote\")[^>]*>(.*?)<\/span>/gi,"[$1quote]$3[/quote]"],[/<p>/gi,""],[/<\/p>/gi,"\n"],[/&quot;/gi,'"'],[/&lt;/gi,"<"],[/&gt;/gi,">"],[/&amp;/gi,"&"],[/<[^>]+>/gi,""]],function(f){e.content=e.content.replace(f[0],f[1])})}});c.onSetContent.add(function(d,e){if(e.format=="bbcode"||e.load){a.each([[/\n/gi,"<br />"],[/\[(\/?)b\]/gi,"<$1strong>"],[/\[(\/?)i\]/gi,"<$1em>"],[/\[(\/?)u\]/gi,"<$1u>"],[/\[(\/?)code\]/gi,"<$1pre>"],[/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'],[/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'],[/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'],[/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'],[/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quote">$1</span>']],function(f){e.content=e.content.replace(f[0],f[1])})}})}})(punymce);(function(a){a.plugins.Entities=function(f){var k,d,j="",c={},g,e,h;k=f.settings;k.entities="named";h=k.entity_list;if(!h){h="160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro"}d=h.split(",");for(g=0;g<d.length;g+=2){c[String.fromCharCode(d[g])]=d[g+1];e=parseInt(d[g]).toString(16);j+="\\u"+"0000".substring(e.length)+e}j=new RegExp("["+j+"]","g");f.onGetContent.add(function(i,l){if(l.format=="html"){l.content=l.content.replace(j,function(m){var n;if(n=c[m]){m="&"+n+";"}return m})}})}})(punymce);(function(a){a.plugins.Protect=function(c){var f=[],d,e;e=c.settings.protect||{};if(!e.list){e.list=[/<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g]}c.onSetContent.add(function(g,h){a.each(e.list,function(i){h.content=h.content.replace(i,function(j){f.push(j);return"<!-- pro:"+(f.length-1)+" -->"})})});c.onGetContent.add(function(g,h){h.content=h.content.replace(/<!-- pro:([0-9]+) -->/g,function(j,i){return f[parseInt(i)]})})}})(punymce);(function(a){function c(g,e){var f,d;f=e.parentNode;d=e.nextSibling;if(d){f.insertBefore(g,d)}else{f.appendChild(g)}return g}a.plugins.TabFocus=function(e){var d=a.Event,f=a.DOM;e.onInit.add(function(){var h,g,i;i=c(f.create("a",{href:"#"}),f.get(e.settings.id+"_c"));d.add(i,"focus",function(j){e.getWin().focus()});d.add(e.getDoc(),"keydown",function(j){if(j.keyCode==9){return d.cancel(j)}});d.add(e.getDoc(),"keydown",function(j){if(j.keyCode==9){window.focus();f.get(e.settings.tabfocus_id).focus()}})})}})(punymce);(function(a){a.plugins.Safari2x=function(h){var k=a.each,l=a.Event,g,f,j;if(!a.isOldWebKit){return}h.selection.getRng=function(){var n=this,o=n.getSel(),w=h.getDoc(),q,u,v,p;if(o.anchorNode){q=w.createRange();try{u=w.createRange();u.setStart(o.anchorNode,o.anchorOffset);u.collapse(1);v=w.createRange();v.setStart(o.focusNode,o.focusOffset);v.collapse(1);p=u.compareBoundaryPoints(u.START_TO_END,v)<0;q.setStart(p?o.anchorNode:o.focusNode,p?o.anchorOffset:o.focusOffset);q.setEnd(p?o.focusNode:o.anchorNode,p?o.focusOffset:o.anchorOffset)}catch(m){}}return q};f=h.selection.setContent;h.selection.setContent=function(o,n){var p=this.getRng();try{f.call(this,o,n)}catch(m){b=h.dom.create("body");b.innerHTML=o;k(b.childNodes,function(q){p.insertNode(q.cloneNode(true))})}};j=h.selection.collapse;h.selection.collapse=function(m){try{j.call(this,m)}catch(n){}};h.onInit.add(function(){a.DOM.get(h.settings.id+"_r").style.display="none"});h.onPreInit.add(function(){l.add(h.getDoc(),"click",function(m){if(m.target.nodeName=="A"){h.selection.select(m.target);return l.cancel(m)}});l.add(h.getDoc(),"keydown",function(q){var m=h.selection,v,t,p,u;if(q.charCode>32||q.keyCode==13){v=h.dom.getParent(m.getNode(),function(o){return o.nodeName=="LI"});if(v){t=m.getRng().startOffset;if(q.keyCode==13){if(!v.hasChildNodes()){if(!v.nextSibling||v.nextSibling.nodeName!="LI"){p=h.dom.getParent(m.getNode(),function(o){return/(UL|OL)/.test(o.nodeName)});v.parentNode.removeChild(v);m.select(p.nextSibling);return}return l.cancel(q)}u=h.getDoc().createTextNode("\u00a0");v.appendChild(u);window.setTimeout(function(){var o=m.getNode();if(o.firstChild&&o.firstChild.nodeValue.charAt(0)=="\u00a0"){o.removeChild(o.firstChild);m.select(o)}},1)}else{u=String.fromCharCode(q.charCode);if(!/^\w$/.test(u)){return}m.setContent(u);p=m.getRng();m=m.getSel();v=m.anchorNode;if(v.nodeName=="LI"){m.setBaseAndExtent(v,1,v,1)}else{v=v.nextSibling;m.setBaseAndExtent(v,1,v,1)}return l.cancel(q)}}}})});function c(t,m){var q=h.getDoc(),p,o;m=m||{};q.execCommand("FontName",false,"_tmp");k(h.dom.select("span"),function(n){if(n.style.fontFamily=="_tmp"){p=d(n,t,m);if(!o){o=p}}});p=p.firstChild;h.selection.getSel().setBaseAndExtent(o,0,p,p.nodeValue.length)}function i(p){var o=h.selection,m;o.setContent("<"+p+'><li id="_tmp"></li></'+p+">");m=h.dom.get("_tmp");m.id="";o.select(m);o.collapse(1)}function e(m){return h.dom.getParent(m,function(o){return/^(H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CODE|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(o.nodeName)})}function d(p,t,m){var q=h.getDoc(),o;m=m||{};o=q.createElement(t);k(p.attributes,function(u){if(u.specified&&u.nodeValue){o.setAttribute(u.nodeName,u.nodeValue)}});k(m,function(u,n){o.setAttribute(n,u)});k(p.childNodes,function(u){o.appendChild(u.cloneNode(true))});p.parentNode.replaceChild(o,p);return o}a.extend(h.commands,{IncreaseFontSize:function(){var n=h.getDoc(),m=parseInt(n.queryCommandValue("FontSize"));n.execCommand("FontSize",false,(m+1)+"px")},DecreaseFontSize:function(){var n=h.getDoc(),m=parseInt(n.queryCommandValue("FontSize"));if(m>0){n.execCommand("FontSize",false,(m-1)+"px")}},Strikethrough:function(){c("strike")},CreateLink:function(n,m){c("a",{href:m,mce_href:m})},Unlink:function(){var m=h.selection;m.setContent(m.getContent().replace(/(<a[^>]+>|<\/a>)/,""))},RemoveFormat:function(){var m=h.selection;m.setContent(m.getContent().replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,""))},FormatBlock:function(o,m){var p=h.selection,q;q=e(h.selection.getNode());if(q){r=d(q,m.replace(/<|>/g,""))}p.select(r);p.collapse(1)},InsertUnorderedList:function(){i("ul")},InsertOrderedList:function(){i("ol")},Indent:function(){var o=e(h.selection.getNode()),m;if(o){m=parseInt(o.style.paddingLeft)||0;o.style.paddingLeft=(m+10)+"px"}},Outdent:function(){var o=e(h.selection.getNode()),m;if(o){m=parseInt(o.style.paddingLeft)||0;if(m>=10){o.style.paddingLeft=(m-10)+"px"}}}})}})(punymce);
@@ -0,0 +1,1460 @@
1
+ (function(punymce) {
2
+ var DOMUtils, Engine, Control, Editor, Selection, Dispatcher, Event, Serializer, I18n; // Shorten class names
3
+ var pageDOM, isIE, isGecko, isOpera, isWebKit, isOldWebKit, ua; // Global objects
4
+
5
+ // Browser checks
6
+ ua = navigator.userAgent;
7
+ punymce.isOpera = isOpera = window['opera'] && opera.buildNumber;
8
+ punymce.isWebKit = isWebKit = /WebKit/.test(ua);
9
+ punymce.isOldWebKit = isOldWebKit = isWebKit && !window.getSelection().getRangeAt;
10
+ punymce.isIE = isIE = !isWebKit && !isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName);
11
+ punymce.isGecko = isGecko = !isWebKit && /Gecko/.test(ua);
12
+
13
+ // Plugins namespace
14
+ punymce.plugins = {};
15
+
16
+ // Global functions
17
+
18
+ function is(o, t) {
19
+ o = typeof(o);
20
+
21
+ if (!t)
22
+ return o != 'undefined';
23
+
24
+ return o == t;
25
+ };
26
+
27
+ function each(o, cb, s) {
28
+ var n;
29
+
30
+ if (!o)
31
+ return 0;
32
+
33
+ s = !s ? o : s;
34
+
35
+ if (is(o.length)) {
36
+ // Indexed arrays, needed for Safari
37
+ for (n=0; n<o.length; n++) {
38
+ if (cb.call(s, o[n], n, o) === false)
39
+ return 0;
40
+ }
41
+ } else {
42
+ // Hashtables
43
+ for (n in o) {
44
+ if (o.hasOwnProperty(n)) {
45
+ if (cb.call(s, o[n], n, o) === false)
46
+ return 0;
47
+ }
48
+ }
49
+ }
50
+
51
+ return 1;
52
+ };
53
+
54
+ function extend(o, e) {
55
+ each(e, function(v, n) {
56
+ o[n] = v;
57
+ });
58
+
59
+ return o;
60
+ };
61
+
62
+ // Store them in API as well for plugin use
63
+ extend(punymce, {
64
+ is : is,
65
+ each : each,
66
+ extend : extend
67
+ });
68
+
69
+ // English language pack
70
+ punymce.I18n = I18n = {
71
+ bold : 'Bold (Ctrl+B)',
72
+ italic : 'Italic (Ctrl+I)',
73
+ underline : 'Underline (Ctrl+U)',
74
+ strike : 'Striketrough',
75
+ ul : 'Insert unordered list',
76
+ ol : 'Insert ordered list',
77
+ indent : 'Indent',
78
+ outdent : 'Outdent',
79
+ left : 'Align left',
80
+ center : 'Align center',
81
+ right : 'Align right',
82
+ style : 'Font style',
83
+ removeformat : 'Remove format',
84
+ increasefontsize : 'Increase text size',
85
+ decreasefontsize : 'Decrease text size'
86
+ };
87
+
88
+ // Static DOM class
89
+ punymce.DOMUtils = DOMUtils = function(d) {
90
+ this.files = [];
91
+
92
+ // Fix IE6SP2 flicker
93
+ try {d.execCommand('BackgroundImageCache', 0, 1);} catch (e) {}
94
+
95
+ // Public methods
96
+ extend(this, {
97
+ get : function(e) {
98
+ return e && (!e.nodeType && !e.location ? d.getElementById(e) : e);
99
+ },
100
+
101
+ add : function(p, n, a, h) {
102
+ var t = this, e;
103
+
104
+ e = d.createElement(n);
105
+
106
+ each(a, function(v, n) {
107
+ t.setAttr(e, n, v);
108
+ });
109
+
110
+ if (h) {
111
+ if (h.nodeType)
112
+ e.appendChild(h);
113
+ else
114
+ e.innerHTML = h;
115
+ }
116
+
117
+ return p ? p.appendChild(e) : e;
118
+ },
119
+
120
+ create : function(n, a, h) {
121
+ return this.add(0, n, a, h);
122
+ },
123
+
124
+ setAttr : function(e, n, v) {
125
+ e = this.get(e);
126
+
127
+ if (!e)
128
+ return 0;
129
+
130
+ if (n == "style") {
131
+ e.setAttribute('mce_style', v);
132
+ e.style.cssText = v;
133
+ }
134
+
135
+ if (n == "class")
136
+ e.className = v;
137
+
138
+ if (v != null && v != "")
139
+ e.setAttribute(n, '' + v);
140
+ else
141
+ e.removeAttribute(n);
142
+
143
+ return 1;
144
+ },
145
+
146
+ getAttr : function(e, n, dv) {
147
+ var v;
148
+
149
+ e = this.get(e);
150
+
151
+ if (!e)
152
+ return false;
153
+
154
+ if (!is(dv))
155
+ dv = "";
156
+
157
+ // Try the mce variant for these
158
+ if (/^(src|href|style)$/.test(n)) {
159
+ v = this.getAttr(e, "mce_" + n);
160
+
161
+ if (v)
162
+ return v;
163
+ }
164
+
165
+ v = e.getAttribute(n, 2);
166
+
167
+ if (n == "class" && !v)
168
+ v = e.className;
169
+
170
+ if (n == "style" && !v)
171
+ v = e.style.cssText;
172
+ else if (!v) {
173
+ v = e.attributes[n];
174
+ v = v && is(v.nodeValue) ? v.nodeValue : v;
175
+ }
176
+
177
+ // Remove Apple and WebKit stuff
178
+ if (isWebKit && n == "class" && v)
179
+ v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, '');
180
+
181
+ return (v && v != "") ? '' + v : dv;
182
+ },
183
+
184
+ select : function(k, n, f) {
185
+ var o = [];
186
+
187
+ n = this.get(n);
188
+ n = !n ? d : n;
189
+
190
+ each(k.split(','), function(v) {
191
+ each(n.getElementsByTagName(v), function(v) {
192
+ if (!f || f(v))
193
+ o.push(v);
194
+ });
195
+ });
196
+
197
+ return o;
198
+ },
199
+
200
+ getPos : function(n, cn) {
201
+ var l = 0, t = 0, p, r, d;
202
+
203
+ n = this.get(n);
204
+
205
+ // IE specific method (less quirks in IE6)
206
+ if (punymce.isIE && n) {
207
+ r = n.getBoundingClientRect();
208
+ d = document;
209
+ n = d.compatMode == 'CSS1Compat' ? d.documentElement : d.body;
210
+
211
+ return { x : r.left + (n.scrollLeft || 0), y : r.top + (n.scrollTop || 0) };
212
+ }
213
+
214
+ while (n && n != cn) {
215
+ l += n.offsetLeft || 0;
216
+ t += n.offsetTop || 0;
217
+ n = n.offsetParent;
218
+ }
219
+
220
+ return {x : l, y : t};
221
+ },
222
+
223
+ loadCSS : function(u) {
224
+ var t = this;
225
+
226
+ if (u) {
227
+ each(u.split(','), function(u) {
228
+ var l = -1;
229
+
230
+ each(t.files, function(c, i) {
231
+ if (c == u) {
232
+ l = i;
233
+ return false;
234
+ }
235
+ });
236
+
237
+ if (l != -1)
238
+ return;
239
+
240
+ t.files.push(u);
241
+
242
+ if (!d.createStyleSheet)
243
+ t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : u});
244
+ else
245
+ d.createStyleSheet(u);
246
+ });
247
+ }
248
+ },
249
+
250
+ addClass : function(e, c, b) {
251
+ var o;
252
+
253
+ e = this.get(e);
254
+
255
+ if (!e)
256
+ return 0;
257
+
258
+ o = this.removeClass(e, c);
259
+
260
+ return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
261
+ },
262
+
263
+ removeClass : function(e, c) {
264
+ e = this.get(e);
265
+
266
+ if (!e)
267
+ return 0;
268
+
269
+ c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g"), ' ');
270
+
271
+ return e.className = c != ' ' ? c : '';
272
+ },
273
+
274
+ hasClass : function(n, c) {
275
+ n = this.get(n);
276
+
277
+ return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
278
+ },
279
+
280
+ getParent : function(n, f, r) {
281
+ while (n) {
282
+ if (n == r)
283
+ return null;
284
+
285
+ if (f(n))
286
+ return n;
287
+
288
+ n = n.parentNode;
289
+ }
290
+
291
+ return null;
292
+ },
293
+
294
+ keep : function(h) {
295
+ // Convert strong and em to b and i in FF since it can't handle them
296
+ if (isGecko) {
297
+ h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
298
+ h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
299
+ h = h.replace(/<(\/?)del|<del( [^>]+)>/gi, '<$1strike$2>');
300
+ }
301
+
302
+ // Store away src and href in mce_src and mce_href since browsers mess them up
303
+ h = h.replace(/ (src|href|style)=\"([^\"]+)\"/gi, ' $1="$2" mce_$1="$2"');
304
+
305
+ return h;
306
+ }
307
+ });
308
+ };
309
+
310
+ // Global DOM instance
311
+ punymce.DOM = pageDOM = new DOMUtils(document);
312
+
313
+ // Static Event class
314
+ punymce.Event = Event = {
315
+ events : [],
316
+ inits : [],
317
+ unloads : [],
318
+
319
+ add : function(o, n, f, s) {
320
+ var cb, t = this, el = t.events;
321
+
322
+ o = pageDOM.get(o);
323
+
324
+ // Setup event callback
325
+ cb = function(e) {
326
+ e = e || window.event;
327
+
328
+ // Patch in target in IE it's W3C valid
329
+ if (e && !e.target && isIE)
330
+ e.target = e.srcElement;
331
+
332
+ if (!s)
333
+ return f(e);
334
+
335
+ return f.call(s, e);
336
+ };
337
+
338
+ if (n == 'unload') {
339
+ t.unloads.push(cb);
340
+ return cb;
341
+ }
342
+
343
+ if (n == 'init') {
344
+ if (t._init)
345
+ cb();
346
+ else
347
+ t.inits.push(cb);
348
+
349
+ return cb;
350
+ }
351
+
352
+ // Store away listener reference
353
+ el.push({
354
+ obj : o,
355
+ name : n,
356
+ func : f,
357
+ cfunc : cb,
358
+ scope : s
359
+ });
360
+
361
+ t._add(o, n, cb);
362
+
363
+ // Cleanup memory leaks in IE
364
+ if (isIE && el.length == 1)
365
+ Event._add(window, 'unload', t._unload, Event);
366
+
367
+ return cb;
368
+ },
369
+
370
+ remove : function(o, n, f) {
371
+ var t = this, a = t.events;
372
+
373
+ o = pageDOM.get(o);
374
+
375
+ each(a, function(e, i) {
376
+ if (e.obj == o && e.name == n && (!f || e.func == f)) {
377
+ a.splice(i, 1);
378
+ t._remove(o, n, e.cfunc);
379
+ return false;
380
+ }
381
+ });
382
+ },
383
+
384
+ cancel : function(e) {
385
+ this.stop(e);
386
+ return this.prevent(e);
387
+ },
388
+
389
+ stop : function(e) {
390
+ if (e.stopPropagation)
391
+ e.stopPropagation();
392
+ else
393
+ e.cancelBubble = true;
394
+
395
+ return false;
396
+ },
397
+
398
+ prevent : function(e) {
399
+ if (e.preventDefault)
400
+ e.preventDefault();
401
+ else
402
+ e.returnValue = false;
403
+
404
+ return false;
405
+ },
406
+
407
+ _unload : function() {
408
+ var t = Event;
409
+
410
+ each(t.events, function(e) {
411
+ t._remove(e.obj, e.name, e.cfunc);
412
+ });
413
+
414
+ t._remove(window, 'unload', t._unload);
415
+ t.events = [];
416
+
417
+ each(t.unloads, function(e) {
418
+ e();
419
+ });
420
+ },
421
+
422
+ _add : function(o, n, f) {
423
+ if (o.attachEvent)
424
+ o.attachEvent('on' + n, f);
425
+ else if (o.addEventListener)
426
+ o.addEventListener(n, f, false);
427
+ else
428
+ o['on' + n] = f;
429
+ },
430
+
431
+ _remove : function(o, n, f) {
432
+ if (o.detachEvent)
433
+ o.detachEvent('on' + n, f);
434
+ else if (o.removeEventListener)
435
+ o.removeEventListener(n, f, false);
436
+ else
437
+ o['on' + n] = null;
438
+ },
439
+
440
+ _pageInit : function() {
441
+ var e = Event;
442
+
443
+ e._remove(window, 'DOMContentLoaded', e._pageInit);
444
+ e._init = true;
445
+
446
+ each(e.inits, function(c) {
447
+ c();
448
+ });
449
+
450
+ e.inits = [];
451
+ },
452
+
453
+ _wait : function() {
454
+ var t;
455
+
456
+ if (isIE && document.location.protocol != 'https:') {
457
+ // Fake DOMContentLoaded on IE when not running under HTTPs
458
+ document.write('<script id=__ie_onload defer src=javascript:void(0)><\/script>');
459
+ pageDOM.get("__ie_onload").onreadystatechange = function() {
460
+ if (this.readyState == "complete") {
461
+ Event._pageInit();
462
+ pageDOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
463
+ }
464
+ };
465
+ } else {
466
+ Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
467
+
468
+ if (isIE || isWebKit) {
469
+ t = setInterval(function() {
470
+ if (/loaded|complete/.test(document.readyState)) {
471
+ clearInterval(t);
472
+ Event._pageInit();
473
+ }
474
+ }, 10);
475
+ }
476
+ }
477
+ }
478
+ };
479
+
480
+ punymce.Dispatcher = Dispatcher = function(ds) {
481
+ var cbl = [];
482
+
483
+ if (!ds)
484
+ ds = this;
485
+
486
+ // Public methods
487
+ extend(this, {
488
+ add : function(cb, s) {
489
+ cbl.push({cb : cb, scope : !s ? ds : s});
490
+
491
+ return cb;
492
+ },
493
+
494
+ remove : function(cb) {
495
+ each(cbl, function(c, i) {
496
+ if (cb == c.cb)
497
+ cbl.splice(i, 1);
498
+
499
+ return false;
500
+ });
501
+
502
+ return cb;
503
+ },
504
+
505
+ dispatch : function() {
506
+ var s, a = arguments;
507
+
508
+ each(cbl, function(c) {
509
+ return s = c.cb.apply(c.scope, a);
510
+ });
511
+
512
+ return s;
513
+ }
514
+ });
515
+ };
516
+
517
+ punymce.Editor = Editor = function(e) {
518
+ var s, DOM, t = this;
519
+
520
+ // Setup baseURL
521
+ if (!punymce.baseURL) {
522
+ each(pageDOM.select('script'), function(n) {
523
+ if (/puny_mce/g.test('' + n.src))
524
+ punymce.baseURL = n.src.replace(/^(.+)\/puny_mce.+$/, '$1/');
525
+ });
526
+ }
527
+
528
+ // Default settings
529
+ this.settings = s = extend({
530
+ content_css : punymce.baseURL + '/css/content.css',
531
+ editor_css : punymce.baseURL + '/css/editor.css',
532
+ width : 0,
533
+ height : 0,
534
+ min_width : 260,
535
+ min_height : 50,
536
+ max_width : 800,
537
+ max_height : 600,
538
+ entities : 'raw',
539
+ spellcheck : 0,
540
+ resize : true,
541
+ plugins : '',
542
+
543
+ styles : [
544
+ { title : 'H1', cls : 'h1', cmd : 'FormatBlock', val : '<h1>' },
545
+ { title : 'H2', cls : 'h2', cmd : 'FormatBlock', val : '<h2>' },
546
+ { title : 'H3', cls : 'h3', cmd : 'FormatBlock', val : '<h3>' },
547
+ { title : 'Pre', cls : 'pre', cmd : 'FormatBlock', val : '<pre>' },
548
+ { title : 'Times', cls : 'times', cmd : 'FontName', val : 'Times'},
549
+ { title : 'Arial', cls : 'arial', cmd : 'FontName', val : 'Arial'},
550
+ { title : 'Courier', cls : 'courier', cmd : 'FontName', val : 'Courier'}
551
+ ],
552
+
553
+ toolbar : 'bold,italic,underline,strike,increasefontsize,decreasefontsize,ul,ol,indent,outdent,left,center,right,style,removeformat'
554
+ }, e);
555
+
556
+ // Default tools
557
+ t.tools = {
558
+ bold : {cmd : 'Bold', title : I18n.bold},
559
+ italic : {cmd : 'Italic', title : I18n.italic},
560
+ underline : {cmd : 'Underline', title : I18n.underline},
561
+ strike : {cmd : 'Strikethrough', title : I18n.strike},
562
+ ul : {cmd : 'InsertUnorderedList', title : I18n.ul},
563
+ ol : {cmd : 'InsertOrderedList', title : I18n.ol},
564
+ indent : {cmd : 'Indent', title : I18n.indent},
565
+ outdent : {cmd : 'Outdent', title : I18n.outdent},
566
+ left : {cmd : 'JustifyLeft', title : I18n.left},
567
+ center : {cmd : 'JustifyCenter', title : I18n.center},
568
+ right : {cmd : 'JustifyRight', title : I18n.right},
569
+ style : {cmd : 'mceStyle', title : I18n.style},
570
+ removeformat : {cmd : 'RemoveFormat', title : I18n.removeformat},
571
+ increasefontsize : {cmd : 'IncreaseFontSize', title : I18n.increasefontsize},
572
+ decreasefontsize : {cmd : 'DecreaseFontSize', title : I18n.decreasefontsize}
573
+ };
574
+
575
+ pageDOM.loadCSS(s.editor_css);
576
+
577
+ // Default commands
578
+ this.commands = {
579
+ mceStyle : function(u, v, e) {
580
+ var n, t = this, s = t.settings, id = s.id, p = pageDOM.getPos(e.target), cb;
581
+
582
+ if (t.hideMenu)
583
+ return t.hideMenu();
584
+
585
+ function hide(e) {
586
+ t.hideMenu = null;
587
+ Event.remove(document, 'click', hide);
588
+ Event.remove(t.getDoc(), 'click', hide);
589
+ pageDOM.get(id + '_mstyle').style.display = 'none';
590
+ };
591
+
592
+ n = pageDOM.get(id + '_mstyle');
593
+ if (!n) {
594
+ n = pageDOM.get(id + '_t');
595
+ n = pageDOM.add(document.body, 'div', {id : id + '_mstyle', 'class' : 'punymce_style punymce'});
596
+ each(s.styles, function(r) {
597
+ Event.add(pageDOM.add(n, 'a', {href : '#', 'class' : r.cls}, r.title), 'mousedown', function(e) {
598
+ hide.call(t);
599
+
600
+ t.execCommand(r.cmd, r.ui, r.val);
601
+
602
+ // Opera looses focus (could not be placed in execCommand)
603
+ if (isOpera)
604
+ t.getIfr().focus();
605
+
606
+ return Event.cancel(e);
607
+ });
608
+ });
609
+ }
610
+
611
+ t.hideMenu = hide;
612
+ Event.add(document, 'click', hide, t);
613
+ Event.add(t.getDoc(), 'click', hide, t);
614
+
615
+ s = n.style;
616
+ s.left = p.x + 'px';
617
+ s.top = (p.y + e.target.clientHeight + 2) + 'px';
618
+ s.display = 'block';
619
+ },
620
+
621
+ FormatBlock : function(u, v, e) {
622
+ // Gecko can't handle <> correctly on some elements
623
+ if (isGecko && /<(div|blockquote|code|dt|dd|dl|samp)>/gi.test(v))
624
+ v = v.replace(/[^a-z]/gi, '');
625
+
626
+ t.getDoc().execCommand("FormatBlock", 0, v);
627
+ },
628
+
629
+ CreateLink : function(u, v) {
630
+ var dom = t.dom, k = 'javascript:mox();';
631
+
632
+ t.getDoc().execCommand("CreateLink", 0, k);
633
+ each(dom.select('A'), function(n) {
634
+ if (dom.getAttr(n, 'href') == k) {
635
+ dom.setAttr(n, 'href', v);
636
+ dom.setAttr(n, 'mce_href', v);
637
+ }
638
+ });
639
+ },
640
+
641
+ mceFontSizeDelta : function(u, v) {
642
+ var d = t.getDoc(), cv, sp, fo, s = t.selection;
643
+
644
+ cv = parseInt(d.queryCommandValue('FontSize') || 3);
645
+
646
+ // WebKit returns pixel value, convert it to a size value
647
+ if (isWebKit) {
648
+ each([10, 13, 16, 18, 24, 32, 48], function(c, i) {
649
+ if (cv == c) {
650
+ cv = i + 1;
651
+ return false;
652
+ }
653
+ });
654
+ }
655
+
656
+ if (cv + v <= 1)
657
+ return;
658
+
659
+ d.execCommand('FontSize', false, cv + v);
660
+ },
661
+
662
+ IncreaseFontSize : function() {
663
+ t.execCommand('mceFontSizeDelta', 0, 1);
664
+ },
665
+
666
+ DecreaseFontSize : function() {
667
+ t.execCommand('mceFontSizeDelta', 0, -1);
668
+ },
669
+
670
+ Indent : function(u, v, e) {
671
+ t.getDoc().execCommand("Indent", 0, 0);
672
+
673
+ if (isIE) {
674
+ // IE adds strange ltr and margin right when making a blockquote
675
+ t.dom.getParent(t.selection.getNode(), function(n) {
676
+ if (n.nodeName == 'BLOCKQUOTE')
677
+ n.dir = n.style.marginRight = '';
678
+ });
679
+ }
680
+ },
681
+
682
+ mceSetClass : function(u, v, e) {
683
+ var s = t.selection;
684
+
685
+ // Wrap it
686
+ if (is(v, 'string')) {
687
+ v = {
688
+ element : 'span',
689
+ 'class' : v
690
+ };
691
+ }
692
+
693
+ if (s.isCollapsed())
694
+ t.dom.setAttr(s.getNode(), 'class', v['class']);
695
+ else
696
+ s.setContent('<' + v.element + ' class="' + v['class'] + '">' + s.getContent() + '</' + v.element + '>');
697
+ },
698
+
699
+ RemoveFormat : function(u, v, e) {
700
+ var s = t.selection;
701
+
702
+ t.getDoc().execCommand('RemoveFormat', u, v);
703
+
704
+ // Extra format removal for IE 6
705
+ if (isIE) {
706
+ v = s.getContent();
707
+
708
+ v = v.replace(/ (class|style)=\"[^\"]+\"/g, '');
709
+ v = v.replace(/<\/?(font|strong|em|b|i|u|strike)>/g, '');
710
+ v = v.replace(/<(font|strong|em|b|i|u|strike) [^>]+>/g, '');
711
+
712
+ s.setContent(v);
713
+ }
714
+ }
715
+ };
716
+
717
+ // Private methods
718
+
719
+ function startResize(e) {
720
+ var c, p, w, h;
721
+
722
+ // Measure container
723
+ c = pageDOM.get(s.id + '_c');
724
+ w = c.clientWidth - 2;
725
+ h = c.clientHeight - 2;
726
+
727
+ // Setup placeholder
728
+ p = pageDOM.get(s.id + '_p');
729
+ p.style.width = w + 'px';
730
+ p.style.height = h + 'px';
731
+
732
+ // Replace with placeholder
733
+ c.style.display = 'none';
734
+ p.style.display = 'block';
735
+
736
+ // Create internal resize obj
737
+ t.resize = {
738
+ x : e.screenX,
739
+ y : e.screenY,
740
+ w : w,
741
+ h : h
742
+ };
743
+
744
+ // Start listening
745
+ Event.add(document, 'mousemove', resizeMove, this);
746
+ Event.add(document, 'mouseup', endResize, this);
747
+
748
+ t.onResizeStart.dispatch(t, e, w, h);
749
+ };
750
+
751
+ function resizeMove(e) {
752
+ var r = t.resize, p, w, h;
753
+
754
+ // Calc delta values
755
+ r.dx = e.screenX - r.x;
756
+ r.dy = e.screenY - r.y;
757
+
758
+ // Boundery fix box
759
+ w = Math.max(s.min_width, r.w + r.dx);
760
+ h = Math.max(s.min_height, r.h + r.dy);
761
+ w = Math.min(s.max_width, w);
762
+ h = Math.min(s.max_height, h);
763
+
764
+ // Resize placeholder
765
+ p = pageDOM.get(s.id + '_p');
766
+ p.style.width = w + 'px';
767
+ p.style.height = h + 'px';
768
+
769
+ return Event.cancel(e);
770
+ };
771
+
772
+ function endResize(e) {
773
+ var r = t.resize;
774
+
775
+ // Stop listening
776
+ Event.remove(document, 'mousemove', resizeMove, this);
777
+ Event.remove(document, 'mouseup', endResize, this);
778
+
779
+ // Replace with editor
780
+ pageDOM.get(s.id + '_c').style.display = '';
781
+ pageDOM.get(s.id + '_p').style.display = 'none';
782
+
783
+ // Resize it to new size
784
+ t.resizeBy(r.dx, r.dy);
785
+
786
+ t.onResizeEnd.dispatch(t, e, r.dx, r.dy);
787
+ };
788
+
789
+ function setup() {
790
+ var e = pageDOM.get(s.id), d = t.getDoc();
791
+
792
+ // Design mode needs to be added here Ctrl+A will fail otherwise
793
+ if (isGecko)
794
+ t.getDoc().designMode = 'On';
795
+
796
+ // Setup body
797
+ d.open();
798
+ d.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body id="punymce"></body></html>');
799
+ d.close();
800
+
801
+ t.dom = DOM = new DOMUtils(t.getDoc());
802
+ DOM.loadCSS(s.content_css);
803
+
804
+ t.onPreInit.dispatch(t);
805
+
806
+ if (!s.spellcheck)
807
+ t.getBody().spellcheck = 0;
808
+
809
+ // Add node change handlers
810
+ Event.add(t.getDoc(), 'mouseup', t.nodeChanged, t);
811
+ Event.add(t.getDoc(), 'keyup', t.nodeChanged, t );
812
+
813
+ // Add focus event
814
+ Event.add(isGecko ? t.getDoc() : t.getWin(), 'focus', function(e) {
815
+ var ed;
816
+
817
+ if ((ed = punymce.focusEditor) != null)
818
+ ed.onBlur.dispatch(ed, t);
819
+
820
+ t.onFocus.dispatch(t, ed);
821
+ punymce.focusEditor = t;
822
+ }, this);
823
+
824
+ // IE fired load event twice if designMode is set
825
+ if (!isIE)
826
+ t.getDoc().designMode = 'On';
827
+ else
828
+ t.getBody().contentEditable = true;
829
+
830
+ t.setContent(is(e.value) ? e.value : e.innerHTML, {load : true});
831
+
832
+ pageDOM.get(s.id + '_c').style.display = t.orgDisplay;
833
+ pageDOM.get(s.id).style.display = 'none';
834
+
835
+ t.onInit.dispatch(t);
836
+ };
837
+
838
+ // Public fields
839
+ extend(this, {
840
+ serializer : new Serializer(t),
841
+ selection : new Selection(t),
842
+ plugins : []
843
+ });
844
+
845
+ // Add events
846
+ each(['onPreInit', 'onInit', 'onFocus', 'onBlur', 'onResizeStart', 'onResizeEnd', 'onPreProcess', 'onPostProcess', 'onSetContent', 'onBeforeGetContent', 'onGetContent', 'onNodeChange'], function(e) {
847
+ t[e] = new Dispatcher(t);
848
+ });
849
+
850
+ // Public methods
851
+ extend(this, {
852
+ init : function() {
853
+ var e = pageDOM.get(s.id), pe = e.parentNode, w, h, ht, ul, n, r, f, sta = ['bold', 'italic', 'underline', 'left', 'center', 'right'];
854
+
855
+ // Create plugins
856
+ each(s.plugins.split(','), function(p) {
857
+ if (p)
858
+ t.plugins.push(new punymce.plugins[p](t));
859
+ });
860
+
861
+ // Handle common states
862
+ t.onNodeChange.add(function() {
863
+ each(sta, function(n) {
864
+ var f;
865
+
866
+ try {
867
+ f = t.getDoc().queryCommandState(t.tools[n].cmd) ? pageDOM.addClass : pageDOM.removeClass;
868
+ f.call(pageDOM, s.id + '_' + n, 'active');
869
+ } catch (ex) {
870
+ // Might fail
871
+ }
872
+ });
873
+ });
874
+
875
+ // Setup numeric entities
876
+ if (s.entities == 'numeric') {
877
+ t.onGetContent.add(function(ed, o) {
878
+ if (o.format == 'html') {
879
+ o.content = o.content.replace(/[\u007E-\uFFFF]/g, function(a) {
880
+ return '&#' + a.charCodeAt(0) + ';';
881
+ });
882
+ }
883
+ });
884
+ }
885
+
886
+ w = !s.width ? e.offsetWidth : s.width;
887
+ h = !s.height ? e.offsetHeight : s.height;
888
+ t.orgDisplay = e.style.display;
889
+ e.style.display = 'none';
890
+
891
+ // Add submit handlers
892
+ if (e.form) {
893
+ f = e.form;
894
+
895
+ // Piggy back
896
+ t._submit = f.submit;
897
+ f.submit = function() {
898
+ var e = pageDOM.get(s.id), f = e.form;
899
+ t.save();
900
+ f.submit = t._submit;
901
+ f.submit();
902
+ };
903
+
904
+ // Prevent IE from memory leaking
905
+ Event.add(0, 'unload', function() {
906
+ var f = pageDOM.get(s.id).form;
907
+ t._submit = t.submit = null;
908
+ });
909
+
910
+ // Submit event
911
+ Event.add(f, 'submit', t.save, t);
912
+ }
913
+
914
+ // Setup UI table, could not use DOM since IE couldn't add the table this method is smaller in size anyway
915
+ ht = '<div id="' + s.id + '_w" class="punymce"><table id="' + s.id + '_c" class="punymce"><tr class="mceToolbar">';
916
+ ht += '<td id="' + s.id + '_t"></td></tr><tr class="mceBody"><td></div><div id="' + s.id + '_b" class="mceBody">';
917
+
918
+ if (s.resize)
919
+ ht += '<div id="' + s.id + '_r" class="mceResize"></div>';
920
+
921
+ ht += '</td></tr></table>';
922
+ ht += '<div id="' + s.id + '_p" class="mcePlaceholder"></div></div>';
923
+
924
+ if (!e.insertAdjacentHTML) {
925
+ r = e.ownerDocument.createRange();
926
+ r.setStartBefore(e);
927
+ pe.insertBefore(r.createContextualFragment(ht), e);
928
+ } else
929
+ e.insertAdjacentHTML("beforeBegin", ht);
930
+
931
+ // Add tools to toolbar
932
+ n = pageDOM.get(s.id + '_t');
933
+ ul = pageDOM.add(n, 'ul', {id : s.id + '_tb', 'class' : 'punymce'});
934
+
935
+ each(s.toolbar.split(','), function(v) {
936
+ var to = t.tools[v];
937
+
938
+ n = pageDOM.add(pageDOM.add(ul, 'li', {id : s.id + '_' + v, 'class' : v}), 'a', {'href' : 'javascript:void(0);', 'class' : v, title : to.title, tabIndex : -1, onmousedown : 'return false;'});
939
+
940
+ Event.add(n, 'click', function(e) {
941
+ if (!pageDOM.hasClass(e.target.parentNode, 'disabled'))
942
+ t.execCommand(to.cmd, 0, 0, e);
943
+
944
+ return Event.cancel(e);
945
+ });
946
+ });
947
+
948
+ // Add iframe to body
949
+ n = pageDOM.get(s.id + '_b');
950
+
951
+ // Create iframe
952
+ n = pageDOM.add(n, 'iframe', {
953
+ id : s.id + "_f",
954
+ src : 'javascript:""', // Workaround for HTTPs warning in IE6/7
955
+ frameBorder : '0',
956
+ 'class' : 'punymce',
957
+ style : 'width:' + w + 'px;height:' + h + 'px'
958
+ });
959
+
960
+ t.resizeTo(w, h);
961
+
962
+ // WebKit needs to be loaded this way to force it in to quirksmode to get <b> instead of <span>
963
+ if (isWebKit) {
964
+ Event.add(n, 'load', setup, t);
965
+ n.src = punymce.baseURL + 'blank.htm';
966
+ } else
967
+ setup();
968
+
969
+ // Add resize event
970
+ if (s.resize) {
971
+ Event.add(s.id + '_r', 'mousedown', function(e) {
972
+ return startResize(e, s.id);
973
+ }, this);
974
+ }
975
+
976
+ ul = f = e = n = null; // Prevent IE memory leak
977
+ },
978
+
979
+ getSize : function() {
980
+ var e = pageDOM.get(s.id + '_f');
981
+
982
+ return {
983
+ w : e.clientWidth,
984
+ h : e.clientHeight
985
+ };
986
+ },
987
+
988
+ resizeTo : function(w, h) {
989
+ var st = pageDOM.get(s.id + '_f').style;
990
+
991
+ // Fix size
992
+ w = Math.max(s.min_width, w);
993
+ h = Math.max(s.min_height, h);
994
+ w = Math.min(s.max_width, w);
995
+ h = Math.min(s.max_height, h);
996
+
997
+ // Store away size
998
+ t.width = w;
999
+ t.height = h;
1000
+
1001
+ // Resize container
1002
+ st.width = w + 'px';
1003
+ st.height = h + 'px';
1004
+ },
1005
+
1006
+ resizeBy : function(w, h) {
1007
+ var r = t.getSize();
1008
+
1009
+ t.resizeTo(r.w + w, r.h + h);
1010
+ },
1011
+
1012
+ show : function() {
1013
+ pageDOM.get(s.id + '_w').style.display = 'block';
1014
+ pageDOM.get(s.id).style.display = 'none';
1015
+ t.load();
1016
+ },
1017
+
1018
+ hide : function() {
1019
+ // Fixed bug where IE has a blinking cursor left from the editor
1020
+ if (isIE)
1021
+ t.execCommand('SelectAll');
1022
+
1023
+ pageDOM.get(s.id + '_w').style.display = 'none';
1024
+ pageDOM.get(s.id).style.display = t.orgDisplay;
1025
+ t.save();
1026
+ },
1027
+
1028
+ load : function() {
1029
+ var e = pageDOM.get(s.id);
1030
+
1031
+ t.setContent(is(e.value) ? e.value : e.innerHTML, {load : true});
1032
+ },
1033
+
1034
+ save : function() {
1035
+ var e = pageDOM.get(s.id), h = t.getContent({save : true});
1036
+ // Fixed bug where empty boxes return '<html/>' as content
1037
+ h = h.replace(/<(\/?)html(\/?)>/gi, "");
1038
+ if (/TEXTAREA|INPUT/.test(e.nodeName))
1039
+ e.value = h;
1040
+ else
1041
+ e.innerHTML = h;
1042
+ },
1043
+
1044
+ setUseCSS : function(s) {
1045
+ var d = t.getDoc(), e;
1046
+
1047
+ try {
1048
+ // Try new Gecko method
1049
+ d.execCommand("styleWithCSS", 0, false);
1050
+ } catch (e) {
1051
+ try {
1052
+ // Use old
1053
+ d.execCommand("useCSS", 0, true);
1054
+ } catch (e) {
1055
+ // Ignore
1056
+ }
1057
+ }
1058
+ },
1059
+
1060
+ execCommand : function(c, u, v, e) {
1061
+ var cl = t.commands, s;
1062
+
1063
+ t.getWin().focus();
1064
+ t.setUseCSS(0);
1065
+
1066
+ if (cl[c])
1067
+ s = cl[c].call(t, u, v, e);
1068
+ else
1069
+ s = t.getDoc().execCommand(c, u, v);
1070
+
1071
+ if (s !== false)
1072
+ t.nodeChanged();
1073
+ },
1074
+
1075
+ getContent : function(o) {
1076
+ var h;
1077
+
1078
+ o = o || {};
1079
+ o.format = o.format || 'html';
1080
+ t.onBeforeGetContent.dispatch(this, o);
1081
+ h = t.serializer.serialize(t.getBody(), o);
1082
+ h = h.replace(/^\s*|\s*$/g, '');
1083
+ o.content = h;
1084
+ t.onGetContent.dispatch(this, o);
1085
+
1086
+ return o.content;
1087
+ },
1088
+
1089
+ setContent : function(h, o) {
1090
+ o = o || {};
1091
+ o.content = h;
1092
+ t.onSetContent.dispatch(this, o);
1093
+ h = o.content;
1094
+ h = pageDOM.keep(h);
1095
+
1096
+ t.getBody().innerHTML = h;
1097
+
1098
+ if (o.format != "raw") {
1099
+ t.setContent(h = t.getContent(o), {format : 'raw'});
1100
+ } else
1101
+ t.getBody().innerHTML = h;
1102
+
1103
+ return h;
1104
+ },
1105
+
1106
+ getIfr : function() {
1107
+ return pageDOM.get(s.id + "_f");
1108
+ },
1109
+
1110
+ getWin : function() {
1111
+ return t.getIfr().contentWindow;
1112
+ },
1113
+
1114
+ getDoc : function() {
1115
+ return t.getWin().document;
1116
+ },
1117
+
1118
+ getBody : function() {
1119
+ return t.getDoc().body;
1120
+ },
1121
+
1122
+ nodeChanged : function() {
1123
+ t.setUseCSS(0);
1124
+ t.onNodeChange.dispatch(t, t.selection.getNode());
1125
+ }
1126
+ });
1127
+
1128
+ // Call init when page loads
1129
+ Event.add(window, 'init', t.init, this);
1130
+ };
1131
+
1132
+ punymce.Selection = Selection = function(ed) {
1133
+ var t = this;
1134
+
1135
+ // Public methods
1136
+ extend(t, {
1137
+ getContent : function(o) {
1138
+ var h, r = t.getRng(), e = document.createElement("body");
1139
+
1140
+ o = o || {};
1141
+
1142
+ if (t.isCollapsed())
1143
+ return '';
1144
+
1145
+ if (r.cloneContents)
1146
+ e.appendChild(r.cloneContents());
1147
+ else if (is(r.item) || is(r.htmlText))
1148
+ e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
1149
+ else
1150
+ e.innerHTML = r.toString();
1151
+
1152
+ if (o.format != "raw") {
1153
+ o.content = h;
1154
+ ed.serializer.serialize(e, o);
1155
+ o.content = o.content.replace(/^\s*|\s*$/g, '');
1156
+ ed.onGetContent.dispatch(h, o);
1157
+ h = o.content;
1158
+ } else
1159
+ h = e.innerHTML;
1160
+
1161
+ return h;
1162
+ },
1163
+
1164
+ getText : function() {
1165
+ var r = t.getRng(), s = t.getSel();
1166
+
1167
+ if (isOldWebKit)
1168
+ return s;
1169
+
1170
+ return t.isCollapsed() ? '' : r.text || s.toString();
1171
+ },
1172
+
1173
+ setContent : function(h, o) {
1174
+ var r = t.getRng(), b, c, r, s;
1175
+
1176
+ o = o || {format : 'raw'};
1177
+ h = pageDOM.keep(h);
1178
+
1179
+ if (o.format != "raw") {
1180
+ o.content = h;
1181
+ h = ed.onSetContent.dispatch(this, o);
1182
+ h = o.content;
1183
+ b = ed.dom.create('body');
1184
+ b.innerHTML = h;
1185
+ }
1186
+
1187
+ if (r.insertNode) {
1188
+ r.deleteContents();
1189
+ r.insertNode(r.createContextualFragment(h + '<span id="__caret">_</span>'));
1190
+
1191
+ // Move to caret marker
1192
+ c = ed.dom.get('__caret');
1193
+
1194
+ // Make sure we wrap it compleatly, Opera fails with a simple select call
1195
+ r = ed.getDoc().createRange();
1196
+ r.setStartBefore(c);
1197
+ r.setEndBefore(c);
1198
+ s = t.getSel();
1199
+ s.removeAllRanges();
1200
+ s.addRange(r);
1201
+
1202
+ // Remove the caret
1203
+ c.parentNode.removeChild(c);
1204
+ } else {
1205
+ // Handle text and control range
1206
+ if (r.pasteHTML)
1207
+ r.pasteHTML(h);
1208
+ else
1209
+ r.item(0).outerHTML = h;
1210
+ }
1211
+ },
1212
+
1213
+ select : function(n, c) {
1214
+ var r = t.getRng(), s = t.getSel();
1215
+
1216
+ if (r.moveToElementText) {
1217
+ try {
1218
+ r.moveToElementText(n);
1219
+ r.select();
1220
+ } catch (ex) {
1221
+ // Throws illigal agrument in IE some times
1222
+ }
1223
+ } else if (s.addRange) {
1224
+ c ? r.selectNodeContents(n) : r.selectNode(n);
1225
+ s.removeAllRanges();
1226
+ s.addRange(r);
1227
+ } else
1228
+ s.setBaseAndExtent(n, 0, n, 1);
1229
+
1230
+ return n;
1231
+ },
1232
+
1233
+ isCollapsed : function() {
1234
+ var r = t.getRng();
1235
+
1236
+ if (r.item)
1237
+ return false;
1238
+
1239
+ return r.boundingWidth == 0 || t.getSel().isCollapsed;
1240
+ },
1241
+
1242
+ collapse : function(b) {
1243
+ var r = t.getRng(), s = t.getSel();
1244
+
1245
+ if (r.select) {
1246
+ r.collapse(b);
1247
+ r.select();
1248
+ } else {
1249
+ if (b)
1250
+ s.collapseToStart();
1251
+ else
1252
+ s.collapseToEnd();
1253
+ }
1254
+ },
1255
+
1256
+ getSel : function() {
1257
+ var w = ed.getWin();
1258
+
1259
+ return w.getSelection ? w.getSelection() : ed.getDoc().selection;
1260
+ },
1261
+
1262
+ getRng : function() {
1263
+ var s = t.getSel(), d = ed.getDoc(), r, rb, ra, di;
1264
+
1265
+ if (!s)
1266
+ return null;
1267
+
1268
+ try {
1269
+ return s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : null);
1270
+ } catch (e) {
1271
+ // IE bug when used in frameset
1272
+ return d.body.createTextRange();
1273
+ }
1274
+ },
1275
+
1276
+ setRng : function(r) {
1277
+ var s = t.getSel();
1278
+
1279
+ s.removeAllRanges();
1280
+ s.addRange(r);
1281
+ },
1282
+
1283
+ setNode : function(n) {
1284
+ t.setContent(ed.dom.create('div', null, n).innerHTML);
1285
+ },
1286
+
1287
+ getNode : function() {
1288
+ var r = t.getRng(), s = t.getSel(), e;
1289
+
1290
+ if (!isIE) {
1291
+ if (r) {
1292
+ e = r.commonAncestorContainer;
1293
+
1294
+ // Handle selection a image or other control like element such as anchors
1295
+ if (!r.collapsed) {
1296
+ if (r.startContainer == r.endContainer) {
1297
+ if (r.startOffset - r.endOffset < 2) {
1298
+ if (r.startContainer.hasChildNodes())
1299
+ e = r.startContainer.childNodes[r.startOffset];
1300
+ }
1301
+ }
1302
+ }
1303
+ }
1304
+
1305
+ return pageDOM.getParent(e, function(n) {
1306
+ return n.nodeType == 1;
1307
+ });
1308
+ }
1309
+
1310
+ return r.item ? r.item(0) : r.parentElement();
1311
+ }
1312
+ });
1313
+ };
1314
+
1315
+ punymce.Serializer = Serializer = function(ed) {
1316
+ var xml, key = 0, s;
1317
+
1318
+ // Get XML document
1319
+ function getXML() {
1320
+ var i = document.implementation;
1321
+
1322
+ if (!i || !i.createDocument) {
1323
+ // Try IE objects
1324
+ try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {}
1325
+ try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {}
1326
+ } else
1327
+ return i.createDocument('', '', null);
1328
+ };
1329
+
1330
+ xml = getXML();
1331
+
1332
+ // Default settings
1333
+ this.settings = s = extend({
1334
+ valid_nodes : 0,
1335
+ invalid_nodes : /(BODY)/,
1336
+ valid_attrs : 0,
1337
+ node_filter : 0,
1338
+ root_node : 0,
1339
+ pi : 0,
1340
+ invalid_attrs : /(^mce_|^_moz_|^contenteditable$)/,
1341
+ closed : /(BR|HR|INPUT|META|IMG)/
1342
+ }, ed.settings.serializer);
1343
+
1344
+ // Returns only attribites that have values not all attributes in IE
1345
+ function getIEAtts(n) {
1346
+ var o = [];
1347
+
1348
+ n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
1349
+ o.push({specified : 1, nodeName : b});
1350
+ });
1351
+
1352
+ return o;
1353
+ };
1354
+
1355
+ // Private methods
1356
+ function serializeNode(n, xn) {
1357
+ var hc, el, cn, i, l, a, at, no, v;
1358
+
1359
+ if ((!s.valid_nodes || s.valid_nodes.test(n.nodeName)) && (!s.invalid_nodes || !s.invalid_nodes.test(n.nodeName)) && (!s.node_filter || s.node_filter(n, xn))) {
1360
+ switch (n.nodeType) {
1361
+ case 1: // Element
1362
+ // Fix IE content duplication (DOM can have multiple copies of the same node)
1363
+ if (isIE) {
1364
+ if (n.mce_serialized == key)
1365
+ return;
1366
+
1367
+ n.mce_serialized = key;
1368
+ }
1369
+
1370
+ hc = n.hasChildNodes();
1371
+ el = xml.createElement(n.nodeName.toLowerCase());
1372
+
1373
+ // Add attributes
1374
+ at = isIE ? getIEAtts(n) : n.attributes;
1375
+ for (i=at.length-1; i>-1; i--) {
1376
+ no = at[i];
1377
+
1378
+ if (no.specified) {
1379
+ a = no.nodeName.toLowerCase();
1380
+
1381
+ if (s.invalid_attrs && s.invalid_attrs.test(a))
1382
+ continue;
1383
+
1384
+ if (s.valid_attrs && !s.valid_attrs.test(a))
1385
+ continue;
1386
+
1387
+ v = pageDOM.getAttr(n, a);
1388
+
1389
+ if (v !== '')
1390
+ el.setAttribute(a, v);
1391
+ }
1392
+ }
1393
+
1394
+ if (!hc && !s.closed.test(n.nodeName))
1395
+ el.appendChild(xml.createTextNode(""));
1396
+
1397
+ xn = xn.appendChild(el);
1398
+ break;
1399
+
1400
+ case 3: // Text
1401
+ return xn.appendChild(xml.createTextNode(n.nodeValue));
1402
+
1403
+ case 8: // Comment
1404
+ return xn.appendChild(xml.createComment(n.nodeValue));
1405
+ }
1406
+ } else if (n.nodeType == 1)
1407
+ hc = n.hasChildNodes();
1408
+
1409
+ if (hc) {
1410
+ cn = n.firstChild;
1411
+
1412
+ while (cn) {
1413
+ serializeNode(cn, xn);
1414
+ cn = cn.nextSibling;
1415
+ }
1416
+ }
1417
+ };
1418
+
1419
+ // Public methods
1420
+ extend(this, {
1421
+ serialize : function(n, o) {
1422
+ var h;
1423
+
1424
+ key = '' + (parseInt(key) + 1);
1425
+
1426
+ if (xml.firstChild)
1427
+ xml.removeChild(xml.firstChild);
1428
+
1429
+ n = o.node = n.cloneNode(1);
1430
+
1431
+ // Call preprocess
1432
+ ed.onPreProcess.dispatch(this, o);
1433
+
1434
+ // Serialize HTML DOM into XML DOM
1435
+ serializeNode(n, xml.appendChild(xml.createElement("html")));
1436
+ h = xml.xml || new XMLSerializer().serializeToString(xml);
1437
+
1438
+ // Remove PI
1439
+ if (!s.pi)
1440
+ h = h.replace(/<\?[^?]+\?>/g, '');
1441
+
1442
+ // Remove root element
1443
+ if (!s.root_node)
1444
+ h = h.replace(/<html>|<\/html>/g, '');
1445
+
1446
+ // Call post process
1447
+ o.content = h;
1448
+ ed.onPostProcess.dispatch(this, o);
1449
+
1450
+ return o.content;
1451
+ }
1452
+ });
1453
+ };
1454
+
1455
+ // Wait for DOM loaded
1456
+ Event._wait();
1457
+
1458
+ // Expose punymce
1459
+ window.punymce = punymce;
1460
+ })({});