Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 457)
+++ trunk/CHANGELOG	(revision 458)
@@ -14,6 +14,11 @@
 24-Jan-2007 Christian Sommer
 !	Replaced some core files to allow configuration of wbmailer via admin settings panel
 ------------------------------------- 2.6.6 -------------------------------------
+12-May-2007 Christian Sommer
++	Replaced functions page_css and page_javascript by register_frontend_modfiles
++	Added function register_backend_modfiles to allow backend modules to use optional CSS and JS files
++	Added the JS framework codepress to allow syntax highlighting for JS, HTML, PHP code (textarea)
++	Added the new function register_frontend_modfiles to the built in templates
 08-May-2007 Matthias Gallas
 +	Added wrapper to functions.php if mb_string is not available (Thanks to thorn)
 +	Added new functions page_css and page_javascript to the built in templates
Index: trunk/wb/include/codepress/license.txt
===================================================================
--- trunk/wb/include/codepress/license.txt	(nonexistent)
+++ trunk/wb/include/codepress/license.txt	(revision 458)
@@ -0,0 +1,458 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
Index: trunk/wb/include/codepress/codepress.js
===================================================================
--- trunk/wb/include/codepress/codepress.js	(nonexistent)
+++ trunk/wb/include/codepress/codepress.js	(revision 458)
@@ -0,0 +1,139 @@
+/*
+ * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
+ * 
+ * Copyright (C) 2006 Fernando M.A.d.S. <fermads@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the 
+ * GNU Lesser General Public License as published by the Free Software Foundation.
+ * 
+ * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php
+ */
+
+CodePress = function(obj) {
+	var self = document.createElement('iframe');
+	self.textarea = obj;
+	self.textarea.disabled = true;
+	self.textarea.style.overflow = 'hidden';
+	self.style.height = self.textarea.clientHeight +'px';
+	self.style.width = self.textarea.clientWidth +'px';
+	self.textarea.style.overflow = 'auto';
+	self.style.border = '1px solid gray';
+	self.style.visibility = 'hidden';
+	self.style.position = 'absolute';
+	self.options = self.textarea.className;
+	
+	self.initialize = function() {
+		self.editor = self.contentWindow.CodePress;
+		self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0];
+		self.editor.setCode(self.textarea.value);
+		self.setOptions();
+		self.editor.syntaxHighlight('init');
+		self.textarea.style.display = 'none';
+		self.style.position = 'static';
+		self.style.visibility = 'visible';
+		self.style.display = 'inline';
+	}
+	
+	self.edit = function(id,language) {
+		if(id) self.textarea.value = document.getElementById(id).value;
+		if(!self.textarea.disabled) return;
+		self.language = language ? language : self.options.replace(/ ?codepress ?| ?readonly-on ?| ?autocomplete-off ?| ?linenumbers-off ?/g,'');
+		if(!CodePress.languages[self.language]) self.language = 'generic';
+		self.src = CodePress.path+'codepress.html?engine='+CodePress.engine+'&language='+self.language+'&ts='+(new Date).getTime();
+		if(self.attachEvent) self.attachEvent('onload',self.initialize);
+		else self.addEventListener('load',self.initialize,false);
+	}
+
+	self.setOptions = function() {
+		if(self.options.match('autocomplete-off')) self.toggleAutoComplete();
+		if(self.options.match('readonly-on')) self.toggleReadOnly();
+		if(self.options.match('linenumbers-off')) self.toggleLineNumbers();
+	}
+	
+	self.getCode = function() {
+		return self.textarea.disabled ? self.editor.getCode() : self.textarea.value;
+	}
+
+	self.setCode = function(code) {
+		self.textarea.disabled ? self.editor.setCode(code) : self.textarea.value = code;
+	}
+
+	self.toggleAutoComplete = function() {
+		self.editor.autocomplete = (self.editor.autocomplete) ? false : true;
+	}
+	
+	self.toggleReadOnly = function() {
+		self.textarea.readOnly = (self.textarea.readOnly) ? false : true;	
+		if(self.style.display != 'none') // prevent exception on FF + iframe with display:none
+			self.editor.readOnly(self.textarea.readOnly ? true : false);
+	}
+	
+	self.toggleLineNumbers = function() {
+		var cn = self.editor.body.className;
+		self.editor.body.className = (cn==''||cn=='show-line-numbers') ? 'hide-line-numbers' : 'show-line-numbers';
+	}
+	
+	self.toggleEditor = function() {
+		if(self.textarea.disabled) {
+			self.textarea.value = self.getCode();
+			self.textarea.disabled = false;
+			self.style.display = 'none';
+			self.textarea.style.display = 'inline';
+		}
+		else {
+			self.textarea.disabled = true;
+			self.setCode(self.textarea.value);
+			self.editor.syntaxHighlight('init');
+			self.style.display = 'inline';
+			self.textarea.style.display = 'none';
+		}
+	}
+
+	self.edit();
+	return self;
+}
+
+CodePress.languages = {	
+	css : 'CSS', 
+	generic : 'Generic',
+	html : 'HTML',
+	java : 'Java', 
+	javascript : 'JavaScript', 
+	perl : 'Perl', 
+	ruby : 'Ruby',	
+	php : 'PHP', 
+	text : 'Text', 
+	sql : 'SQL'
+}
+
+CodePress.getEngine = function()	{
+	var engine = 'older';
+	var ua = navigator.userAgent;
+	if(ua.match('MSIE')) engine = 'msie';
+	else if(ua.match('KHTML')) engine = 'khtml'; 
+	else if(ua.match('Opera')) engine = 'opera'; 
+	else if(ua.match('Gecko')) engine = 'gecko';
+	return engine;
+}
+
+CodePress.run = function() {
+	CodePress.engine = CodePress.getEngine();
+	s = document.getElementsByTagName('script');
+	for(var i=0,n=s.length;i<n;i++) {
+		if(s[i].src.match('codepress.js')) {
+			CodePress.path = s[i].src.replace('codepress.js','');
+		}
+	}
+	t = document.getElementsByTagName('textarea');
+	for(var i=0,n=t.length;i<n;i++) {
+		if(t[i].className.match('codepress')) {
+			id = t[i].id;
+			t[i].id = id+'_cp';
+			eval(id+' = new CodePress(t[i])');
+			t[i].parentNode.insertBefore(eval(id), t[i]);
+		} 
+	}
+}
+
+if(window.attachEvent) window.attachEvent('onload',CodePress.run);
+else window.addEventListener('DOMContentLoaded',CodePress.run,false);
Index: trunk/wb/include/codepress/images/line-numbers.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/codepress/images/line-numbers.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/wb/include/codepress/languages/css.css
===================================================================
--- trunk/wb/include/codepress/languages/css.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/css.css	(revision 458)
@@ -0,0 +1,10 @@
+/*
+ * CodePress color styles for CSS syntax highlighting
+ */
+
+b, b a, b u {color:#000080;} /* tags, ids, classes */
+i, i b, i s, i a, i u {color:gray;} /* comments */
+s, s b {color:#a0a0dd;} /* parameters */
+a {color:#0000ff;} /* keys */
+u {color:red;} /* values */
+
Index: trunk/wb/include/codepress/languages/html.js
===================================================================
--- trunk/wb/include/codepress/languages/html.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/html.js	(revision 458)
@@ -0,0 +1,79 @@
+/*
+ * CodePress regular expressions for HTML syntax highlighting
+ */
+
+Language.syntax = [ // HTML
+	{
+	input : /(&lt;[^!]*?&gt;)/g,
+	output : '<b>$1</b>' // all tags
+	},{
+	input : /(&lt;a .*?&gt;|&lt;\/a&gt;)/g,
+	output : '<a>$1</a>' // links
+	},{
+	input : /(&lt;img .*?&gt;)/g,
+	output : '<big>$1</big>' // images
+	},{
+	input : /(&lt;\/?(button|textarea|form|input|select|option|label).*?&gt;)/g,
+	output : '<u>$1</u>' // forms
+	},{
+	input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g,
+	output : '<em>$1</em><em>$2</em><em>$3</em>' // style tags
+	},{
+	input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g,
+	output : '<strong>$1</strong><tt>$2</tt><strong>$3</strong>' // script tags
+	},{
+	input : /=(".*?")/g,
+	output : '=<s>$1</s>' // atributes double quote
+	},{
+	input : /=('.*?')/g,
+	output : '=<s>$1</s>' // atributes single quote
+	},{
+	input : /(&lt;!--.*?--&gt.)/g,
+	output : '<ins>$1</ins>' // comments 
+	},{
+	input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g,
+	output : '<i>$1</i>' // script reserved words
+	}	
+];
+
+Language.snippets = [
+	{input : 'aref', output : '<a href="$0"></a>' },
+	{input : 'h1', output : '<h1>$0</h1>' },
+	{input : 'h2', output : '<h2>$0</h2>' },
+	{input : 'h3', output : '<h3>$0</h3>' },
+	{input : 'h4', output : '<h4>$0</h4>' },
+	{input : 'h5', output : '<h5>$0</h5>' },
+	{input : 'h6', output : '<h6>$0</h6>' },
+	{input : 'html', output : '<html>\n\t$0\n</html>' },
+	{input : 'head', output : '<head>\n\t<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n\t<title>$0</title>\n\t\n</head>' },
+	{input : 'img', output : '<img src="$0" alt="" />' },
+	{input : 'input', output : '<input name="$0" id="" type="" value="" />' },
+	{input : 'label', output : '<label for="$0"></label>' },
+	{input : 'legend', output : '<legend>\n\t$0\n</legend>' },
+	{input : 'link', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },		
+	{input : 'base', output : '<base href="$0" />' }, 
+	{input : 'body', output : '<body>\n\t$0\n</body>' }, 
+	{input : 'css', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
+	{input : 'div', output : '<div>\n\t$0\n</div>' },
+	{input : 'divid', output : '<div id="$0">\n\t\n</div>' },
+	{input : 'dl', output : '<dl>\n\t<dt>\n\t\t$0\n\t</dt>\n\t<dd></dd>\n</dl>' },
+	{input : 'fieldset', output : '<fieldset>\n\t$0\n</fieldset>' },
+	{input : 'form', output : '<form action="$0" method="" name="">\n\t\n</form>' },
+	{input : 'meta', output : '<meta name="$0" content="" />' },
+	{input : 'p', output : '<p>$0</p>' },
+	{input : 'script', output : '<script type="text/javascript" language="javascript" charset="utf-8">\n\t$0\t\n</script>' },
+	{input : 'scriptsrc', output : '<script src="$0" type="text/javascript" language="javascript" charset="utf-8"></script>' },
+	{input : 'span', output : '<span>$0</span>' },
+	{input : 'table', output : '<table border="$0" cellspacing="" cellpadding="">\n\t<tr><th></th></tr>\n\t<tr><td></td></tr>\n</table>' },
+	{input : 'style', output : '<style type="text/css" media="screen">\n\t$0\n</style>' }
+];
+	
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'',output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+];
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/javascript.js
===================================================================
--- trunk/wb/include/codepress/languages/javascript.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/javascript.js	(revision 458)
@@ -0,0 +1,42 @@
+/*
+ * CodePress regular expressions for JavaScript syntax highlighting
+ */
+ 
+Language.syntax = [ // JavaScript
+	{ 
+	input : /\"(.*?)(\"|<br>|<\/P>)/g, 
+	output : '<s>"$1$2</s>' // strings double quote
+	},{ 
+	input : /\'(.*?)(\'|<br>|<\/P>)/g,
+	output : '<s>\'$1$2</s>' // strings single quote
+	},{ 
+	input : /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g,
+	output : '<b>$1</b>' // reserved words
+	},{ 
+	input : /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover)\b/g,
+	output : '<u>$1</u>' // special words
+	},{
+	input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g,
+	output : '$1<i>//$2</i>$3' // comments //
+	},{ 
+	input : /\/\*(.*?)\*\//g,
+	output : '<i>/*$1*/</i>' // comments /* */
+	}
+]
+
+Language.snippets = [
+	{ input : 'dw', output : 'document.write(\'$0\');' },
+	{ input : 'getid', output : 'document.getElementById(\'$0\')' },
+	{ input : 'fun', output : 'function $0(){\n\t\n}' },
+	{ input : 'func', output : 'function $0(){\n\t\n}' }
+];
+
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'',output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+];
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/sql.css
===================================================================
--- trunk/wb/include/codepress/languages/sql.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/sql.css	(revision 458)
@@ -0,0 +1,10 @@
+/*
+ * CodePress color styles for SQL syntax highlighting
+ * By Merlin Moncure
+ */
+ 
+b {color:#0000FF;font-style:normal;font-weight:bold;} /* reserved words */
+u {color:#FF0000;font-style:normal;} /* types */
+a {color:#CD6600;font-style:normal;font-weight:bold;} /* commands */
+i, i b, i u, i a, i s  {color:#A9A9A9;font-weight:normal;font-style:italic;} /* comments */
+s, s b, s u, s a, s i {color:#2A00FF;font-weight:normal;} /* strings */
Index: trunk/wb/include/codepress/languages/generic.js
===================================================================
--- trunk/wb/include/codepress/languages/generic.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/generic.js	(revision 458)
@@ -0,0 +1,37 @@
+/*
+ * CodePress regular expressions for generic syntax highlighting
+ */
+ 
+Language.syntax = [ // generic languages
+	{
+	input : /\"(.*?)(\"|<br>|<\/P>)/g,
+	output : '<s>"$1$2</s>' // strings double quote
+	},{
+	input : /\'(.*?)(\'|<br>|<\/P>)/g,
+	output : '<s>\'$1$2</s>' // strings single quote
+	},{
+	input : /\b(abstract|continue|for|new|switch|default|goto|boolean|do|if|private|this|break|double|protected|throw|byte|else|import|public|throws|case|return|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|const|float|while|function|label)\b/g,
+	output : '<b>$1</b>' // reserved words
+	},{
+	input : /([\(\){}])/g,
+	output : '<em>$1</em>' // special chars;
+	},{
+	input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g,
+	output : '$1<i>//$2</i>$3' // comments //
+	},{
+	input : /\/\*(.*?)\*\//g,
+	output : '<i>/*$1*/</i>' // comments /* */
+	}
+];
+
+Language.snippets = [];
+
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'', output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+]
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/perl.css
===================================================================
--- trunk/wb/include/codepress/languages/perl.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/perl.css	(revision 458)
@@ -0,0 +1,11 @@
+/*
+ * CodePress color styles for Perl syntax highlighting
+ * By J. Nick Koston
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */
+s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */
+a {color:#006700;font-weight:bold;} /* variables */
+em {color:darkblue;font-weight:bold;} /* functions */
+u {font-weight:bold;} /* special chars */
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/html.css
===================================================================
--- trunk/wb/include/codepress/languages/html.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/html.css	(revision 458)
@@ -0,0 +1,13 @@
+/*
+ * CodePress color styles for HTML syntax highlighting
+ */
+
+b {color:#000080;} /* tags */
+ins, ins b, ins s, ins em {color:gray;} /* comments */
+s, s b {color:#7777e4;} /* attribute values */
+a {color:green;} /* links */
+u {color:#E67300;} /* forms */
+big {color:#db0000;} /* images */
+em, em b {color:#800080;} /* style */
+strong {color:#800000;} /* script */
+tt i {color:darkblue;font-weight:bold;} /* script reserved words */
Index: trunk/wb/include/codepress/languages/java.js
===================================================================
--- trunk/wb/include/codepress/languages/java.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/java.js	(revision 458)
@@ -0,0 +1,34 @@
+/*
+ * CodePress regular expressions for Java syntax highlighting
+ */
+ 
+Language.syntax = [ // Java
+	{
+	input : /\"(.*?)(\"|<br>|<\/P>)/g,
+	output : '<s>"$1$2</s>' // strings double quote
+	},{
+	input : /\'(.*?)(\'|<br>|<\/P>)/g,
+	output : '<s>\'$1$2</s>' // strings single quote
+	},{
+	input : /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/g,
+	output : '<b>$1</b>' // reserved words
+	},{
+	input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g,
+	output : '$1<i>//$2</i>$3' // comments //	
+	},{
+	input : /\/\*(.*?)\*\//g,
+	output : '<i>/*$1*/</i>' // comments /* */
+	}
+];
+
+Language.snippets = [];
+
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'',output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+];
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/ruby.js
===================================================================
--- trunk/wb/include/codepress/languages/ruby.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/ruby.js	(revision 458)
@@ -0,0 +1,40 @@
+/*
+ * CodePress regular expressions for Perl syntax highlighting
+ */
+
+Language.syntax = [ // Ruby
+	{
+	input  : /\"(.*?)(\"|<br>|<\/P>)/g,
+	output : '<s>"$1$2</s>', // strings double quote
+	},{
+	input  : /\'(.*?)(\'|<br>|<\/P>)/g,
+	output : '<s>\'$1$2</s>', // strings single quote
+	},{
+	input  : /([\$\@\%]+)([\w\.]*)/g,
+	output : '<a>$1$2</a>', // vars
+	},{
+	input  : /(def\s+)([\w\.]*)/g,
+	output : '$1<em>$2</em>', // functions
+	},{    
+	input  : /\b(alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\b/g,
+	output : '<b>$1</b>', // reserved words
+	},{
+    input  : /([\(\){}])/g,
+	output : '<u>$1</u>', // special chars
+	},{
+    input  : /#(.*?)(<br>|<\/P>)/g,
+	output : '<i>#$1</i>$2' // comments
+	}
+];
+
+Language.snippets = [];
+
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'',output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+];
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/javascript.css
===================================================================
--- trunk/wb/include/codepress/languages/javascript.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/javascript.css	(revision 458)
@@ -0,0 +1,8 @@
+/*
+ * CodePress color styles for JavaScript syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+u {color:darkblue;font-weight:bold;} /* special words */
+i, i b, i s, i u {color:green;font-weight:normal;} /* comments */
+s, s b, s u {color:#2A00FF;font-weight:normal;} /* strings */
Index: trunk/wb/include/codepress/languages/text.js
===================================================================
--- trunk/wb/include/codepress/languages/text.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/text.js	(revision 458)
@@ -0,0 +1,9 @@
+/*
+ * CodePress regular expressions for Text syntax highlighting
+ */
+
+// do nothing, as expected 
+Language.syntax = []
+Language.snippets = []
+Language.complete = []
+Language.shortcuts = []
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/php.js
===================================================================
--- trunk/wb/include/codepress/languages/php.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/php.js	(revision 458)
@@ -0,0 +1,62 @@
+/*
+ * CodePress regular expressions for PHP syntax highlighting
+ */
+
+Language.syntax = [ // PHP
+	{ input : /(&lt;[^!\?]*?&gt;)/g, output : '<b>$1</b>' }, // all tags
+	{ input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' }, // style tags
+	{ input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g, output : '<ins>$1</ins><ins>$2</ins><ins>$3</ins>' }, // script tags
+	{ input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
+	{ input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>'}, // strings single quote
+	{ input : /(&lt;\?)/g, output : '<strong>$1' }, // <?.*
+	{ input : /(\?&gt;)/g, output : '$1</strong>' }, // .*?>
+	{ input : /(&lt;\?php|&lt;\?=|&lt;\?|\?&gt;)/g, output : '<cite>$1</cite>' }, // php tags
+	{ input : /(\$[\w\.]*)/g, output : '<a>$1</a>' }, // vars
+	{ input : /\b(false|true|and|or|xor|__FILE__|exception|__LINE__|array|as|break|case|class|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|for|foreach|function|global|if|include|include_once|isset|list|new|print|require|require_once|return|static|switch|unset|use|while|__FUNCTION__|__CLASS__|__METHOD__|final|php_user_filter|interface|implements|extends|public|private|protected|abstract|clone|try|catch|throw|this)\b/g, output : '<u>$1</u>' }, // reserved words
+	{ input : /([^:])\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3' }, // php comments //
+	{ input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' }, // php comments /* */
+	{ input : /(&lt;!--.*?--&gt.)/g, output : '<big>$1</big>' } // html comments
+]
+
+// activated with tab
+Language.snippets = [
+	{ input : 'if', output : 'if($0){\n\t\n}' },
+	{ input : 'ifelse', output : 'if($0){\n\t\n}\nelse{\n\t\n}' },
+	{ input : 'else', output : '}\nelse {\n\t' },
+	{ input : 'elseif', output : '}\nelseif($0) {\n\t' },
+	{ input : 'do', output : 'do{\n\t$0\n}\nwhile();' },
+	{ input : 'inc', output : 'include_once("$0");' },
+	{ input : 'fun', output : 'function $0(){\n\t\n}' },	
+	{ input : 'func', output : 'function $0(){\n\t\n}' },	
+	{ input : 'while', output : 'while($0){\n\t\n}' },
+	{ input : 'for', output : 'for($0,,){\n\t\n}' },
+	{ input : 'fore', output : 'foreach($0 as ){\n\t\n}' },
+	{ input : 'foreach', output : 'foreach($0 as ){\n\t\n}' },
+	{ input : 'echo', output : 'echo \'$0\';' },
+	{ input : 'switch', output : 'switch($0) {\n\tcase "": break;\n\tdefault: ;\n}' },
+	{ input : 'case', output : 'case "$0" : break;' },
+	{ input : 'ret0', output : 'return false;' },
+	{ input : 'retf', output : 'return false;' },
+	{ input : 'ret1', output : 'return true;' },
+	{ input : 'rett', output : 'return true;' },
+	{ input : 'ret', output : 'return $0;' },
+	{ input : 'def', output : 'define(\'$0\',\'\');' },
+	{ input : '<?', output : 'php\n$0\n?>' }
+],
+
+// only 1 character auto-complete
+Language.complete = [
+	{ input : '\'', output : '\'$0\'' },
+	{ input : '"', output : '"$0"' },
+	{ input : '(', output : '\($0\)' },
+	{ input : '[', output : '\[$0\]' },
+	{ input : '{', output : '{\n\t$0\n}' }		
+]
+
+// ctrl+shift+inputKey
+Language.shortcuts = [
+	{ input : '[space]', output : '&nbsp;' },
+	{ input : '[enter]', output : '<br />' } ,
+	{ input : '[j]', output : 'testing' },
+	{ input : '[7]', output : '&amp;' }
+]
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/css.js
===================================================================
--- trunk/wb/include/codepress/languages/css.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/css.js	(revision 458)
@@ -0,0 +1,22 @@
+/*
+ * CodePress regular expressions for CSS syntax highlighting
+ */
+
+Language.syntax = [ // CSS
+	{ input : /(.*?){(.*?)}/g,output : '<b>$1</b>{<u>$2</u>}' },	// tags, ids, classes, values
+	{ input : /([\w-]*?):([^\/])/g,output : '<a>$1</a>:$2' },		// keys
+	{ input : /\((.*?)\)/g,output : '(<s>$1</s>)' }, 				// parameters
+	{ input : /\/\*(.*?)\*\//g,output : '<i>/*$1*/</i>'}			// comments
+];
+
+Language.snippets = [];
+
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'',output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+];
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/generic.css
===================================================================
--- trunk/wb/include/codepress/languages/generic.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/generic.css	(revision 458)
@@ -0,0 +1,9 @@
+/*
+ * CodePress color styles for generic syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+u {color:darkblue;font-weight:bold;} /* special words */
+i, i b, i s, i u, i em {color:green;font-weight:normal;} /* comments */
+s, s b, s em {color:#2A00FF;font-weight:normal;} /* strings */
+em {font-weight:bold;} /* special chars */
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/java.css
===================================================================
--- trunk/wb/include/codepress/languages/java.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/java.css	(revision 458)
@@ -0,0 +1,7 @@
+/*
+ * CodePress color styles for Java syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */
+i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */
+s, s b {color:#2A00FF;font-weight:normal;} /* strings */
Index: trunk/wb/include/codepress/languages/ruby.css
===================================================================
--- trunk/wb/include/codepress/languages/ruby.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/ruby.css	(revision 458)
@@ -0,0 +1,10 @@
+/*
+ * CodePress color styles for Ruby syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */
+s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */
+a {color:#006700;font-weight:bold;} /* variables */
+em {color:darkblue;font-weight:bold;} /* functions */
+u {font-weight:bold;} /* special chars */
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/sql.js
===================================================================
--- trunk/wb/include/codepress/languages/sql.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/sql.js	(revision 458)
@@ -0,0 +1,33 @@
+/*
+ * CodePress regular expressions for SQL syntax highlighting
+ * By Merlin Moncure
+ */
+ 
+Language.syntax = [ // SQL
+	{ input : /\'(.*?)(\')/g, output : '<s>\'$1$2</s>' }, // strings single quote
+	{ input : /\b(add|after|aggregate|alias|all|and|as|authorization|between|by|cascade|cache|cache|called|case|check|column|comment|constraint|createdb|createuser|cycle|database|default|deferrable|deferred|diagnostics|distinct|domain|each|else|elseif|elsif|encrypted|except|exception|for|foreign|from|from|full|function|get|group|having|if|immediate|immutable|in|increment|initially|increment|index|inherits|inner|input|intersect|into|invoker|is|join|key|language|left|limit|local|loop|match|maxvalue|minvalue|natural|nextval|no|nocreatedb|nocreateuser|not|null|of|offset|oids|on|only|operator|or|order|outer|owner|partial|password|perform|plpgsql|primary|record|references|replace|restrict|return|returns|right|row|rule|schema|security|sequence|session|sql|stable|statistics|table|temp|temporary|then|time|to|transaction|trigger|type|unencrypted|union|unique|user|using|valid|value|values|view|volatile|when|where|with|without|zone)\b/gi, output : '<b>$1</b>' }, // reserved words
+	{ input : /\b(bigint|bigserial|bit|boolean|box|bytea|char|character|cidr|circle|date|decimal|double|float4|float8|inet|int2|int4|int8|integer|interval|line|lseg|macaddr|money|numeric|oid|path|point|polygon|precision|real|refcursor|serial|serial4|serial8|smallint|text|timestamp|varbit|varchar)\b/gi, output : '<u>$1</u>' }, // types
+	{ input : /\b(abort|alter|analyze|begin|checkpoint|close|cluster|comment|commit|copy|create|deallocate|declare|delete|drop|end|execute|explain|fetch|grant|insert|listen|load|lock|move|notify|prepare|reindex|reset|restart|revoke|rollback|select|set|show|start|truncate|unlisten|update)\b/gi, output : '<a>$1</a>' }, // commands
+	{ input : /([^:]|^)\-\-(.*?)(<br|<\/P)/g, output: '$1<i>--$2</i>$3' } // comments //	
+]
+
+// activated with tab
+Language.snippets = [
+	{ input : 'select', output : 'select $0 from  where ' }
+],
+
+// only 1 character auto-complete
+Language.complete = [
+	{ input : '\'', output : '\'$0\'' },
+	{ input : '"', output : '"$0"' },
+	{ input : '(', output : '\($0\)' },
+	{ input : '[', output : '\[$0\]' },
+	{ input : '{', output : '{\n\t$0\n}' }		
+]
+
+// ctrl+shift+inputKey
+Language.shortcuts = [
+]
+
+
+
Index: trunk/wb/include/codepress/languages/text.css
===================================================================
--- trunk/wb/include/codepress/languages/text.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/text.css	(revision 458)
@@ -0,0 +1,5 @@
+/*
+ * CodePress color styles for Text syntax highlighting
+ */
+
+/* do nothing as expected */
Index: trunk/wb/include/codepress/languages/perl.js
===================================================================
--- trunk/wb/include/codepress/languages/perl.js	(nonexistent)
+++ trunk/wb/include/codepress/languages/perl.js	(revision 458)
@@ -0,0 +1,41 @@
+/*
+ * CodePress regular expressions for Perl syntax highlighting
+ * By J. Nick Koston
+ */
+
+Language.syntax = [ // Perl
+	{
+	input  : /\"(.*?)(\"|<br>|<\/P>)/g,
+	output : '<s>"$1$2</s>' // strings double quote
+	},{
+	input  : /\'(.*?)(\'|<br>|<\/P>)/g,
+	output : '<s>\'$1$2</s>' // strings single quote
+	},{
+    input  : /([\$\@\%][\w\.]*)/g,
+	output : '<a>$1</a>' // vars
+	},{
+    input  : /(sub\s+)([\w\.]*)/g,
+	output : '$1<em>$2</em>' // functions
+	},{
+    input  : /\b(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|do|dump|each|else|elsif|endgrent|endhostent|endnetent|endprotoent|endpwent|eof|eval|exec|exists|exit|fcntl|fileno|find|flock|for|foreach|fork|format|formlinegetc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyaddr|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|goto|grep|hex|hostname|if|import|index|int|ioctl|join|keys|kill|last|lc|lcfirst|length|link|listen|LoadExternals|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgrcv|msgsnd|my|next|no|oct|open|opendir|ordpack|package|pipe|pop|pos|print|printf|push|pwd|qq|quotemeta|qw|rand|read|readdir|readlink|recv|redo|ref|rename|require|reset|return|reverse|rewinddir|rindex|rmdir|scalar|seek|seekdir|select|semctl|semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|stty|study|sub|substr|symlink|syscall|sysopen|sysread|system|syswritetell|telldir|tie|tied|time|times|tr|truncate|uc|ucfirst|umask|undef|unless|unlink|until|unpack|unshift|untie|use|utime|values|vec|waitpid|wantarray|warn|while|write)\b/g,
+	output : '<b>$1</b>' // reserved words
+	},{
+    input  : /([\(\){}])/g,
+	output : '<u>$1</u>' // special chars
+	},{
+    input  : /#(.*?)(<br>|<\/P>)/g,
+	output : '<i>#$1</i>$2' // comments
+	}
+]
+
+Language.snippets = [];
+
+Language.complete = [ // Auto complete only for 1 character
+	{input : '\'',output : '\'$0\'' },
+	{input : '"', output : '"$0"' },
+	{input : '(', output : '\($0\)' },
+	{input : '[', output : '\[$0\]' },
+	{input : '{', output : '{\n\t$0\n}' }		
+];
+
+Language.shortcuts = [];
\ No newline at end of file
Index: trunk/wb/include/codepress/languages/php.css
===================================================================
--- trunk/wb/include/codepress/languages/php.css	(nonexistent)
+++ trunk/wb/include/codepress/languages/php.css	(revision 458)
@@ -0,0 +1,12 @@
+/*
+ * CodePress color styles for PHP syntax highlighting
+ */
+
+b {color:#000080;} /* tags */
+big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {color:gray;font-weight:normal;} /* comments */
+s, s b, strong s u, strong s cite {color:#5656fa;font-weight:normal;} /* attributes and strings */
+strong a, strong a u {color:#006700;font-weight:bold;} /* variables */
+em {color:#800080;font-style:normal;} /* style */
+ins {color:#800000;} /* script */
+strong u {color:#7F0055;font-weight:bold;} /* reserved words */
+cite, s cite {color:red;font-weight:bold;} /* <?php and ?> */
Index: trunk/wb/include/codepress/engines/opera.js
===================================================================
Index: trunk/wb/include/codepress/engines/gecko.js
===================================================================
--- trunk/wb/include/codepress/engines/gecko.js	(nonexistent)
+++ trunk/wb/include/codepress/engines/gecko.js	(revision 458)
@@ -0,0 +1,240 @@
+/*
+ * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
+ * 
+ * Copyright (C) 2007 Fernando M.A.d.S. <fermads@gmail.com>
+ *
+ * Contributors :
+ *
+ * 	Michael Hurni <michael.hurni@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the 
+ * GNU Lesser General Public License as published by the Free Software Foundation.
+ * 
+ * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php
+ */
+
+
+CodePress = {
+	scrolling : false,
+	autocomplete : true,
+
+	// set initial vars and start sh
+	initialize : function() {
+		if(typeof(editor)=='undefined' && !arguments[0]) return;
+		chars = '|32|46|62|'; // charcodes that trigger syntax highlighting
+		cc = '\u2009'; // control char
+		editor = document.getElementsByTagName('body')[0];
+		document.designMode = 'on';
+		document.addEventListener('keypress', this.keyHandler, true);
+		window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false);
+		completeChars = this.getCompleteChars();
+//		CodePress.syntaxHighlight('init');
+	},
+
+	// treat key bindings
+	keyHandler : function(evt) {
+    	keyCode = evt.keyCode;	
+		charCode = evt.charCode;
+
+		if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
+			CodePress.shortcuts(charCode?charCode:keyCode);
+		}
+		else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete
+			CodePress.complete(String.fromCharCode(charCode));
+		}
+	    else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting
+		 	CodePress.syntaxHighlight('generic');
+		}
+		else if(keyCode==9 || evt.tabKey) {  // snippets activation (tab)
+			CodePress.snippets(evt);
+		}
+		else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed
+		 	CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML;
+		}
+		else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo
+			(charCode==121||evt.shiftKey) ? CodePress.actions.redo() :  CodePress.actions.undo(); 
+			evt.preventDefault();
+		}
+		else if(keyCode==86 && evt.ctrlKey)  { // paste
+			// TODO: pasted text should be parsed and highlighted
+		}
+	},
+
+	// put cursor back to its original position after every parsing
+	findString : function() {
+		if(self.find(cc))
+			window.getSelection().getRangeAt(0).deleteContents();
+	},
+	
+	// split big files, highlighting parts of it
+	split : function(code,flag) {
+		if(flag=='scroll') {
+			this.scrolling = true;
+			return code;
+		}
+		else {
+			this.scrolling = false;
+			mid = code.indexOf(cc);
+			if(mid-2000<0) {ini=0;end=4000;}
+			else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;}
+			else {ini=mid-2000;end=mid+2000;}
+			code = code.substring(ini,end);
+			return code;
+		}
+	},
+	
+	// syntax highlighting parser
+	syntaxHighlight : function(flag) {
+		//if(document.designMode=='off') document.designMode='on'
+		if(flag!='init') window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));
+
+		o = editor.innerHTML;
+		o = o.replace(/<br>/g,'\n');
+		o = o.replace(/<.*?>/g,'');
+		x = z = this.split(o,flag);
+		x = x.replace(/\n/g,'<br>');
+
+		if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]);
+	
+		for(i=0;i<Language.syntax.length;i++) 
+			x = x.replace(Language.syntax[i].input,Language.syntax[i].output);
+
+		editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.split(z).join(x); 
+		if(flag!='init') this.findString();
+	},
+	
+	getLastWord : function() {
+		var rangeAndCaret = CodePress.getRangeAndCaret();
+		var words = rangeAndCaret[0].substring(rangeAndCaret[1]-40,rangeAndCaret[1]).split(/[\s\r\n\);]/);
+		return words[words.length-1].replace(/_/g,'');
+	},
+	
+	snippets : function(evt) {
+		var snippets = Language.snippets;	
+		var trigger = this.getLastWord();
+		for (var i=0; i<snippets.length; i++) {
+			if(snippets[i].input == trigger) {
+				var content = snippets[i].output.replace(/</g,'&lt;');
+				content = content.replace(/>/g,'&gt;');
+				if(content.indexOf('$0')<0) content += cc;
+				else content = content.replace(/\$0/,cc);
+				content = content.replace(/\n/g,'<br>');
+				var pattern = new RegExp(trigger+cc,'g');
+				evt.preventDefault(); // prevent the tab key from being added
+				this.syntaxHighlight('snippets',pattern,content);
+			}
+		}
+	},
+	
+	readOnly : function() {
+		document.designMode = (arguments[0]) ? 'off' : 'on';
+	},
+
+	complete : function(trigger) {
+		window.getSelection().getRangeAt(0).deleteContents();
+		var complete = Language.complete;
+		for (var i=0; i<complete.length; i++) {
+			if(complete[i].input == trigger) {
+				var pattern = new RegExp('\\'+trigger+cc);
+				var content = complete[i].output.replace(/\$0/g,cc);
+				parent.setTimeout(function () { CodePress.syntaxHighlight('complete',pattern,content)},0); // wait for char to appear on screen
+			}
+		}
+	},
+
+	getCompleteChars : function() {
+		var cChars = '';
+		for(var i=0;i<Language.complete.length;i++)
+			cChars += '|'+Language.complete[i].input;
+		return cChars+'|';
+	},
+
+	shortcuts : function() {
+		var cCode = arguments[0];
+		if(cCode==13) cCode = '[enter]';
+		else if(cCode==32) cCode = '[space]';
+		else cCode = '['+String.fromCharCode(charCode).toLowerCase()+']';
+		for(var i=0;i<Language.shortcuts.length;i++)
+			if(Language.shortcuts[i].input == cCode)
+				this.insertCode(Language.shortcuts[i].output,false);
+	},
+	
+	getRangeAndCaret : function() {	
+		var range = window.getSelection().getRangeAt(0);
+		var range2 = range.cloneRange();
+		var node = range.endContainer;			
+		var caret = range.endOffset;
+		range2.selectNode(node);	
+		return [range2.toString(),caret];
+	},
+	
+	insertCode : function(code,replaceCursorBefore) {
+		var range = window.getSelection().getRangeAt(0);
+		var node = window.document.createTextNode(code);
+		var selct = window.getSelection();
+		var range2 = range.cloneRange();
+		// Insert text at cursor position
+		selct.removeAllRanges();
+		range.deleteContents();
+		range.insertNode(node);
+		// Move the cursor to the end of text
+		range2.selectNode(node);		
+		range2.collapse(replaceCursorBefore);
+		selct.removeAllRanges();
+		selct.addRange(range2);
+	},
+	
+	// get code from editor
+	getCode : function() {
+		var code = editor.innerHTML;
+		code = code.replace(/<br>/g,'\n');
+		code = code.replace(/\u2009/g,'');
+		code = code.replace(/<.*?>/g,'');
+		code = code.replace(/&lt;/g,'<');
+		code = code.replace(/&gt;/g,'>');
+		code = code.replace(/&amp;/gi,'&');
+		return code;
+	},
+
+	// put code inside editor
+	setCode : function() {
+		var code = arguments[0];
+		code = code.replace(/\u2009/gi,'');
+		code = code.replace(/&/gi,'&amp;');
+       	code = code.replace(/</g,'&lt;');
+        code = code.replace(/>/g,'&gt;');
+		editor.innerHTML = code;
+	},
+
+	// undo and redo methods
+	actions : {
+		pos : -1, // actual history position
+		history : [], // history vector
+		
+		undo : function() {
+			if(editor.innerHTML.indexOf(cc)==-1){
+				window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));
+			 	this.history[this.pos] = editor.innerHTML;
+			}
+			this.pos--;
+			if(typeof(this.history[this.pos])=='undefined') this.pos++;
+			editor.innerHTML = this.history[this.pos];
+			CodePress.findString();
+		},
+		
+		redo : function() {
+			this.pos++;
+			if(typeof(this.history[this.pos])=='undefined') this.pos--;
+			editor.innerHTML = this.history[this.pos];
+			CodePress.findString();
+		},
+		
+		next : function() { // get next vector position and clean old ones
+			if(this.pos>20) this.history[this.pos-21] = undefined;
+			return ++this.pos;
+		}
+	}
+}
+
+Language={};
+window.addEventListener('load', function() { CodePress.initialize('new'); }, true);
\ No newline at end of file
Index: trunk/wb/include/codepress/engines/msie.js
===================================================================
--- trunk/wb/include/codepress/engines/msie.js	(nonexistent)
+++ trunk/wb/include/codepress/engines/msie.js	(revision 458)
@@ -0,0 +1,263 @@
+/*
+ * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
+ * 
+ * Copyright (C) 2007 Fernando M.A.d.S. <fermads@gmail.com>
+ *
+ * Contributors :
+ *
+ * 	Michael Hurni <michael.hurni@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the 
+ * GNU Lesser General Public License as published by the Free Software Foundation.
+ * 
+ * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php
+ */
+
+
+CodePress = {
+	scrolling : false,
+	autocomplete : true,
+	
+	// set initial vars and start sh
+	initialize : function() {
+		if(typeof(editor)=='undefined' && !arguments[0]) return;
+		chars = '|32|46|62|'; // charcodes that trigger syntax highlighting
+		cc = '\u2009'; // control char
+		editor = document.getElementsByTagName('body')[0];
+		editor.contentEditable = 'true';
+		document.getElementsByTagName('body')[0].onfocus = function() {editor.focus();}
+		document.attachEvent('onkeydown', this.metaHandler);
+		document.attachEvent('onkeypress', this.keyHandler);
+		window.attachEvent('onscroll', function() { if(!CodePress.scrolling) setTimeout(function(){CodePress.syntaxHighlight('scroll')},1)});
+		completeChars = this.getCompleteChars();
+//		CodePress.syntaxHighlight('init');
+		setTimeout(function() { window.scroll(0,0) },50); // scroll IE to top
+	},
+	
+	// treat key bindings
+	keyHandler : function(evt) {
+		charCode = evt.keyCode;
+		if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete
+			CodePress.complete(String.fromCharCode(charCode))
+		}
+	    else if(chars.indexOf('|'+charCode+'|')!=-1||charCode==13) { // syntax highlighting
+		 	CodePress.syntaxHighlight('generic');
+		}
+	},
+
+	metaHandler : function(evt) {
+		keyCode = evt.keyCode;
+		if(keyCode==9 || evt.tabKey) { 
+			CodePress.snippets();
+		}
+		else if((keyCode==122||keyCode==121||keyCode==90) && evt.ctrlKey) { // undo and redo
+			(keyCode==121||evt.shiftKey) ? CodePress.actions.redo() :  CodePress.actions.undo(); 
+			evt.returnValue = false;
+		}
+		else if(keyCode==34||keyCode==33) { // handle page up/down for IE
+			self.scrollBy(0, (keyCode==34) ? 200 : -200); 
+			evt.returnValue = false;
+		}
+		else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed
+		 	CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML;
+		}
+		else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && keyCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
+			CodePress.shortcuts(keyCode);
+			evt.returnValue = false;
+		}
+		else if(keyCode==86 && evt.ctrlKey)  { // paste
+			// TODO: pasted text should be parsed and highlighted
+		}
+	},
+
+	// put cursor back to its original position after every parsing
+	findString : function() {
+	    range = self.document.body.createTextRange();
+		if(range.findText(cc)){
+			range.select();
+			range.text = '';
+		}
+	},
+	
+	// split big files, highlighting parts of it
+	split : function(code,flag) {
+		if(flag=='scroll') {
+			this.scrolling = true;
+			return code;
+		}
+		else {
+			this.scrolling = false;
+			mid = code.indexOf(cc);
+			if(mid-2000<0) {ini=0;end=4000;}
+			else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;}
+			else {ini=mid-2000;end=mid+2000;}
+			code = code.substring(ini,end);
+			return code.substring(code.indexOf('<P>'),code.lastIndexOf('</P>')+4);
+		}
+	},
+	
+	// syntax highlighting parser
+	syntaxHighlight : function(flag) {
+		if(flag!='init') document.selection.createRange().text = cc;
+		o = editor.innerHTML;
+		o = o.replace(/<P>/g,'\n');
+		o = o.replace(/<\/P>/g,'\r');
+		o = o.replace(/<.*?>/g,'');
+		o = o.replace(/&nbsp;/g,'');			
+		o = '<PRE><P>'+o+'</P></PRE>';
+		o = o.replace(/\n\r/g,'<P></P>');
+		o = o.replace(/\n/g,'<P>');
+		o = o.replace(/\r/g,'<\/P>');
+		o = o.replace(/<P>(<P>)+/,'<P>');
+		o = o.replace(/<\/P>(<\/P>)+/,'</P>');
+		o = o.replace(/<P><\/P>/g,'<P><BR/></P>');
+		x = z = this.split(o,flag);
+
+		if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]);
+	
+		for(i=0;i<Language.syntax.length;i++) 
+			x = x.replace(Language.syntax[i].input,Language.syntax[i].output);
+			
+		editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.replace(z,x);
+		if(flag!='init') this.findString();
+	},
+
+	snippets : function(evt) {
+		var snippets = Language.snippets;
+		var trigger = this.getLastWord();
+		for (var i=0; i<snippets.length; i++) {
+			if(snippets[i].input == trigger) {
+				var content = snippets[i].output.replace(/</g,'&lt;');
+				content = content.replace(/>/g,'&gt;');
+				if(content.indexOf('$0')<0) content += cc;
+				else content = content.replace(/\$0/,cc);
+				content = content.replace(/\n/g,'</P><P>');
+				var pattern = new RegExp(trigger+cc);
+				this.syntaxHighlight('snippets',pattern,content);
+			}
+		}
+	},
+	
+	readOnly : function() {
+		editor.contentEditable = (arguments[0]) ? 'true' : 'false';
+	},
+	
+	complete : function(trigger) {
+		var complete = Language.complete;
+		for (var i=0; i<complete.length; i++) {
+			if(complete[i].input == trigger) {
+				var pattern = new RegExp('\\'+trigger+cc);
+				var content = complete[i].output.replace(/\$0/g,cc);
+				setTimeout(function () { CodePress.syntaxHighlight('complete',pattern,content)},0); // wait for char to appear on screen
+			}
+		}
+	},
+	
+	getCompleteChars : function() {
+		var cChars = '';
+		for(var i=0;i<Language.complete.length;i++)
+			cChars += '|'+Language.complete[i].input;
+		return cChars+'|';
+	},
+
+	shortcuts : function() {
+		var cCode = arguments[0];
+		if(cCode==13) cCode = '[enter]';
+		else if(cCode==32) cCode = '[space]';
+		else cCode = '['+String.fromCharCode(keyCode).toLowerCase()+']';
+		for(var i=0;i<Language.shortcuts.length;i++)
+			if(Language.shortcuts[i].input == cCode)
+				this.insertCode(Language.shortcuts[i].output,false);
+	},
+	
+	getLastWord : function() {
+		var rangeAndCaret = CodePress.getRangeAndCaret();
+		words = rangeAndCaret[0].substring(rangeAndCaret[1]-40,rangeAndCaret[1]);
+		words = words.replace(/[\s\r\);]/g,'\n').split('\n');
+		return words[words.length-1];
+	},
+
+	getRangeAndCaret : function() {	
+		var range = document.selection.createRange();
+		var caret = Math.abs(range.moveStart('character', -1000000)+1);
+		range = this.getCode();
+		range = range.replace(/\n\r/gi,'  ');
+		range = range.replace(/\n/gi,'');
+		return [range.toString(),caret];
+	},
+	
+	insertCode : function(code,replaceCursorBefore) {
+		var repdeb = '';
+		var repfin = '';
+		
+		if(replaceCursorBefore) { repfin = code; }
+		else { repdeb = code; }
+		
+		if(typeof document.selection != 'undefined') {
+			var range = document.selection.createRange();
+			range.text = repdeb + repfin;
+			range = document.selection.createRange();
+			range.move('character', -repfin.length);
+			range.select();	
+		}	
+	},
+
+	// get code from editor	
+	getCode : function() {
+		var code = editor.innerHTML;
+		code = code.replace(/<br>/g,'\n');
+		code = code.replace(/<\/p>/gi,'\r');
+		code = code.replace(/<p>/i,''); // IE first line fix
+		code = code.replace(/<p>/gi,'\n');
+		code = code.replace(/&nbsp;/gi,'');
+		code = code.replace(/\u2009/g,'');
+		code = code.replace(/<.*?>/g,'');
+		code = code.replace(/&lt;/g,'<');
+		code = code.replace(/&gt;/g,'>');
+		code = code.replace(/&amp;/gi,'&');
+		return code;
+	},
+
+	// put code inside editor
+	setCode : function() {
+		var code = arguments[0];
+		code = code.replace(/\u2009/gi,'');
+		code = code.replace(/&/gi,'&amp;');		
+       	code = code.replace(/</g,'&lt;');
+        code = code.replace(/>/g,'&gt;');
+		editor.innerHTML = '<pre>'+code+'</pre>';
+	},
+
+	
+	// undo and redo methods
+	actions : {
+		pos : -1, // actual history position
+		history : [], // history vector
+		
+		undo : function() {
+			if(editor.innerHTML.indexOf(cc)==-1){
+				document.selection.createRange().text = cc;
+			 	this.history[this.pos] = editor.innerHTML;
+			}
+			this.pos--;
+			if(typeof(this.history[this.pos])=='undefined') this.pos++;
+			editor.innerHTML = this.history[this.pos];
+			CodePress.findString();
+		},
+		
+		redo : function() {
+			this.pos++;
+			if(typeof(this.history[this.pos])=='undefined') this.pos--;
+			editor.innerHTML = this.history[this.pos];
+			CodePress.findString();
+		},
+		
+		next : function() { // get next vector position and clean old ones
+			if(this.pos>20) this.history[this.pos-21] = undefined;
+			return ++this.pos;
+		}
+	}
+}
+
+Language={};
+window.attachEvent('onload', function() { CodePress.initialize('new');});
\ No newline at end of file
Index: trunk/wb/include/codepress/engines/khtml.js
===================================================================
Index: trunk/wb/include/codepress/codepress.html
===================================================================
--- trunk/wb/include/codepress/codepress.html	(nonexistent)
+++ trunk/wb/include/codepress/codepress.html	(revision 458)
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+	<title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
+	<meta name="description" content="CodePress - source code editor window" />
+	
+	<script type="text/javascript">
+	var L=location.href;
+	var d=L.substring(L.indexOf("?")+1);
+	var c=v=new Array(); c=d.split("&");
+	for(i=0;i<c.length&&c.length>0;i++) {
+	v=c[i].split("="); if(v.length>1)
+	eval(v[0]+"=unescape('"+v[1].replace(/\+/g," ")+"')");} 
+	
+	if(language==null||language=='') language = 'generic';
+	
+	ts = (new Date).getTime(); // timestamp to avoid cache
+	document.write('<link type="text/css" href="codepress.css?ts='+ts+'" rel="stylesheet" />');
+	document.write('<link type="text/css" href="languages/'+language+'.css?ts='+ts+'" rel="stylesheet" id="cp-lang-style" />');
+	document.write('<scr'+'ipt type="text/javascript" src="engines/'+engine+'.js?ts='+ts+'"></scr'+'ipt>');
+	document.write('<scr'+'ipt type="text/javascript" src="languages/'+language+'.js?ts='+ts+'"></scr'+'ipt>');
+	</script>
+
+</head>
+
+<script type="text/javascript">
+if (engine == "gecko") document.write('<body> </body>');
+else if(engine == "msie") document.write('<body><pre></pre></body>');
+</script>
+
+</html>
Index: trunk/wb/include/codepress/codepress.css
===================================================================
--- trunk/wb/include/codepress/codepress.css	(nonexistent)
+++ trunk/wb/include/codepress/codepress.css	(revision 458)
@@ -0,0 +1,8 @@
+html {border:none;} /*remove ie frameborder */
+body {margin-top:13px;_margin-top:14px;background:white;font-family:monospace;font-size:13px;margin-left:32px;white-space:pre;background-image:url("images/line-numbers.png");background-repeat:repeat-y;background-position:0 3px;line-height:16px;}
+html>body{background-position:0 2px;}
+P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;}
+b, i, s, u, a, em, tt, ins, big, cite, strong {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
+
+body.hide-line-numbers {background:white;margin-left:16px;}
+body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;}
\ No newline at end of file
Index: trunk/wb/admin/interface/header.html
===================================================================
--- trunk/wb/admin/interface/header.html	(revision 457)
+++ trunk/wb/admin/interface/header.html	(revision 458)
@@ -5,6 +5,9 @@
 <title>{WEBSITE_TITLE} >> {TEXT_ADMINISTRATION} - {SECTION_NAME}</title>
 <link href="{INTERFACE_DIR}/stylesheet.css" rel="stylesheet" type="text/css" />
 <meta http-equiv="content-type" content="text/html; charset={CHARSET}" />
+{BACKEND_MODULE_CSS}
+{BACKEND_MODULE_JS}
+<script type="text/javascript" src="{WB_URL}/include/codepress/codepress.js"></script>
 <script language="javascript" type="text/javascript">
 function confirm_link(message, url) {
 	if(confirm(message)) location.href = url;
Index: trunk/wb/framework/class.admin.php
===================================================================
--- trunk/wb/framework/class.admin.php	(revision 457)
+++ trunk/wb/framework/class.admin.php	(revision 458)
@@ -102,7 +102,10 @@
 													'WEBSITE_TITLE' => ($title['value']),
 													'TEXT_ADMINISTRATION' => $TEXT['ADMINISTRATION'],
 													'CHARSET' => $charset,
-													'VERSION' => VERSION
+													'VERSION' => VERSION,
+													'WB_URL' => WB_URL,
+													'BACKEND_MODULE_CSS' => $this->register_backend_modfiles('css'),	// adds backend.css
+													'BACKEND_MODULE_JS'  => $this->register_backend_modfiles('js')		// adds backend.js
 													)
 											);
 		// Create the menu
@@ -257,6 +260,64 @@
 			}
 		}
 	}
+
+	// Function to add optional module Javascript or CSS stylesheets into the <head> section of the backend
+	function register_backend_modfiles($file_id="css") {
+		// sanity check of parameter passed to the function
+		$file_id = strtolower($file_id);
+		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") { 
+			return;
+		}
+
+		global $database;
+		// define default baselink and filename for optional module javascript and stylesheet files
+		$head_links = "";
+		if($file_id == "css") {
+      	$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.css"'; 
+			$base_link.= 'rel="stylesheet" type="text/css" media="screen" />';
+			$base_file = "backend.css";
+		} else {
+			$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js"></script>';
+			$base_file = "backend.js";
+		}
+
+		// check if backend.js or backend.css files needs to be included to the <head></head> section of the backend
+		if(isset($_GET['tool'])) {
+			// check if displayed page contains a installed admin tool
+			$result = $database->query("SELECT * FROM " .TABLE_PREFIX ."addons 
+				WHERE type = 'module' AND function = 'tool' AND directory = '".$_GET['tool']."'");
+
+			if($result->numRows()) {
+				// check if admin tool directory contains a backend.js or backend.css file to include
+				$tool = $result->fetchRow();
+				if(file_exists(WB_PATH ."/modules/" .$tool['directory'] ."/$base_file")) {
+        			// return link to the backend.js or backend.css file
+					return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link);
+				}
+			}
+		} elseif(isset($_GET['page_id'])) {
+			// check if displayed page in the backend contains a page module
+			$page_id = (int) $_GET['page_id'];
+
+    		// gather information for all models embedded on actual page
+			$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections 
+				WHERE page_id=$page_id AND module<>'wysiwyg'");
+
+    		while($row = $query_modules->fetchRow()) {
+				// check if page module directory contains a backend.js or backend.css file
+      		if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
+					// create link with backend.js or backend.css source for the current module
+					$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
+        			// ensure that backend.js or backend.css is only added once per module type
+        			if(strpos($head_links, $tmp_link) === false) {
+						$head_links .= $tmp_link ."\n";
+					}
+				}
+    		}
+    		// write out links with all external module javascript/CSS files, remove last line feed
+			return rtrim($head_links);
+		}
+	}
 }
 
 ?>
\ No newline at end of file
Index: trunk/wb/framework/frontend.functions.php
===================================================================
--- trunk/wb/framework/frontend.functions.php	(revision 457)
+++ trunk/wb/framework/frontend.functions.php	(revision 458)
@@ -290,57 +290,45 @@
 	}
 }
 
-// Function to include optional module CSS stylesheets (module.css) into the <head> section
-if (!function_exists('page_css')) {
-	function page_css() {
-    global $wb, $database;
-    $css_head = "";
+// Function to add optional module Javascript or CSS stylesheets into the <head> section of the frontend
+if(!function_exists('register_frontend_modfiles')) {
+	function register_frontend_modfiles($file_id="css") {
+		// sanity check of parameter passed to the function
+		$file_id = strtolower($file_id);
+		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") { 
+			return;
+		}
 
-    // obtain list of modules used for actual displayed page
-		$page_id=$wb->page_id;
-    $query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections WHERE page_id=$page_id AND module<>'wysiwyg'");
-    while($row = $query_modules->fetchRow()) {
-      if(file_exists(WB_PATH .'/modules/' .$row['module'] .'/module.css')) {
-        // build css link for current module.css
-        $css_link = "<link href=\"" .WB_URL ."/modules/" .$row['module'];
-        $css_link .= "/module.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n";
-        // ensure that module.css is not added twice (e.g. if 2 sections include the same module)
-        $css_head = str_replace($css_link, "", $css_head);
-        $css_head .= $css_link;
-      }
-    }
-    // write out links to all external module stylesheets (module.css)
-    if($css_head != "") {
-      $css_head = "<!-- Include external module CSS stylesheets -->\n" .$css_head;
-      echo $css_head;
-    }
-	}
-}
+		global $wb, $database;
+		// define default baselink and filename for optional module javascript and stylesheet files
+		$head_links = "";
+		if($file_id == "css") {
+      	$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"'; 
+			$base_link.= 'rel="stylesheet" type="text/css" media="screen" />';
+			$base_file = "frontend.css";
+		} else {
+			$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js"></script>';
+			$base_file = "frontend.js";
+		}
 
-// Function to include optional module javascript files (module.js) into the <head> section
-if (!function_exists('page_javascript')) {
-	function page_javascript() {
-    global $wb, $database;
-    $js_head = "";
+  		// gather information for all models embedded on actual page
+		$page_id = $wb->page_id;
+    	$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections 
+			WHERE page_id=$page_id AND module<>'wysiwyg'");
 
-    // obtain list of modules used for actual displayed page
-		$page_id=$wb->page_id;
-    $query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections WHERE page_id=$page_id AND module<>'wysiwyg'");
-    while($row = $query_modules->fetchRow()) {
-      if(file_exists(WB_PATH .'/modules/' .$row['module'] .'/module.js')) {
-        // build javascript link for current module.js
-        $js_link = "<script type=\"text/javascript\" src=\"" .WB_URL ."/modules/" .$row['module'];
-        $js_link .= "/module.js\"></script>\n";
-        // ensure that module.js is not added twice (e.g. if 2 sections include the same module)
-        $js_head = str_replace($js_link, "", $js_head);
-        $js_head .= $js_link;
-      }
-    }
-    // write out links to all external module javascript files (module.js)
-    if($js_head != "") {
-      $js_head = "<!-- Include external module javascript files -->\n" .$js_head;
-      echo $js_head;
-    }
+    	while($row = $query_modules->fetchRow()) {
+			// check if page module directory contains a frontend.js or frontend.css file
+      	if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
+				// create link with frontend.js or frontend.css source for the current module
+				$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
+        		// ensure that frontend.js or frontend.css is only added once per module type
+        		if(strpos($head_links, $tmp_link) === false) {
+					$head_links .= $tmp_link ."\n";
+				}
+			}
+    	}
+  		// write out links with all external module javascript/CSS files, remove last line feed
+		echo $head_links;
 	}
 }
 
Index: trunk/wb/templates/allcss/index.php
===================================================================
--- trunk/wb/templates/allcss/index.php	(revision 457)
+++ trunk/wb/templates/allcss/index.php	(revision 458)
@@ -38,8 +38,11 @@
 <meta name="keywords" content="<?php page_keywords(); ?>" />
 <link href="<?php echo TEMPLATE_DIR; ?>/screen.css" rel="stylesheet" type="text/css" media="screen" />
 <link href="<?php echo TEMPLATE_DIR; ?>/print.css" rel="stylesheet" type="text/css" media="print" />
-<?php page_css(); ?>
-<?php page_javascript(); ?>
+<?php
+if(function_exists('register_frontend_modfiles')) {
+  register_frontend_modfiles('css');
+  register_frontend_modfiles('js');
+} ?>
 </head>
 <body>
 
Index: trunk/wb/templates/round/index.php
===================================================================
--- trunk/wb/templates/round/index.php	(revision 457)
+++ trunk/wb/templates/round/index.php	(revision 458)
@@ -38,8 +38,11 @@
 <meta name="keywords" content="<?php page_keywords(); ?>" />
 <link href="<?php echo TEMPLATE_DIR; ?>/screen.css" rel="stylesheet" type="text/css" media="screen" />
 <link href="<?php echo TEMPLATE_DIR; ?>/print.css" rel="stylesheet" type="text/css" media="print" />
-<?php page_css(); ?>
-<?php page_javascript(); ?>
+<?php
+if(function_exists('register_frontend_modfiles')) {
+  register_frontend_modfiles('css');
+  register_frontend_modfiles('js');
+} ?>
 </head>
 <body>
 
Index: trunk/wb/templates/simple/index.php
===================================================================
--- trunk/wb/templates/simple/index.php	(revision 457)
+++ trunk/wb/templates/simple/index.php	(revision 458)
@@ -38,8 +38,11 @@
 <meta name="keywords" content="<?php page_keywords(); ?>" />
 <link href="<?php echo TEMPLATE_DIR; ?>/screen.css" rel="stylesheet" type="text/css" media="screen" />
 <link href="<?php echo TEMPLATE_DIR; ?>/print.css" rel="stylesheet" type="text/css" media="print" />
-<?php page_css(); ?>
-<?php page_javascript(); ?>
+<?php
+if(function_exists('register_frontend_modfiles')) {
+  register_frontend_modfiles('css');
+  register_frontend_modfiles('js');
+} ?>
 </head>
 <body>
 
