Jump to content

User:Odie5533/SnipManager.user.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Odie5533 (talk | contribs) at 19:12, 20 May 2009 (refactoring to make code easier to read). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <pre><nowiki>
// ==UserScript==
// @name           SnippetManager
// @namespace      http://en.wikipedia.org/*
// @include        http://en.wikipedia.org/*
// @include        https://secure.wikipedia.org/*
// ==/UserScript==
//
// This script is based off of [[User:Mr.Z-man/refToolbar.js]]
// It would have been a lot harder without the work he did
//
// Credit also to wikiEd for coding examples

window.SnippetManagerWrapper = function() {

if (typeof(smConfig) == 'undefined') { window.smConfig = new Object(); }
if (typeof(smConfig['smColumns']) == 'undefined') { window.smConfig['smColumns'] = 2; }
if (typeof(smConfig['smTextWidth']) == 'undefined') { window.smConfig['smTextWidth'] = '220px'; }
if (typeof(smConfig['smSingleForm']) == 'undefined') { window.smConfig['smSingleForm'] = true; }
if (typeof(smConfig['smMenus']) == 'undefined') {
  window.smConfig['smMenus'] = { '+Citations &or;':{ 'Web':'Cite web', 'News':'citenews',
    'Book':'citebook', 'Journal':'citejournal', 'Video':'Cite video',
    'Show Refs':'showrefs','Ref Errors':'referrs', 'DOI Bot':'doicite' },
    'General &or;':{ 'Cleanup':'cleanup', 'Copy Edit':'copyedit'},
    'Intro &or;':{ 'Too long':'intro-toolong', 'Too short':'intro-tooshort',
    'Rewrite':'intro-rewrite', 'Missing':'intro-missing' },
    'References &or;':{ 'No refs':'unreferenced', 'More refs':'Refimprove',
                        'No notes':'No footnotes', 'More notes':'More footnotes',
                        'Cite check':'citecheck', 'Prim Sources':'Primarysources'
                       },
    'Fact':'fact',
    'Weasel term':'weasel-inline',
    'uw-csd':'uw-csd'
  };
}
if (typeof(smConfig['smForms']) == 'undefined') {
    window.smConfig['smForms'] = {
        'doicite' : [ { 'httpeval':[ 'http://tools.wikimedia.de/~verisimilus/Bot/DOI_bot/doibot.php?edit=false&slow=1&page=%s', "escape(wgPageName).replace('&', '%26');" ] } ],
        'cleanup' : [ { 'inserttext':'{{Cleanup}}' } ],
        'copyedit' : [ { 'inserttext':'{{Copyedit}}' } ],
        'intro-toolong' : [ { 'inserttext':'{{Intro-toolong}}' } ],
        'intro-tooshort' : [ { 'inserttext':'{{Intro-tooshort}}' } ],
        'intro-rewrite' : [ { 'inserttext':'{{Intro-rewrite}}' } ],
        'intro-missing' : [ { 'inserttext':'{{Intro-missing}}' } ],
        'No footnotes' : [ { 'inserttext':'{{No footnotes|{{subst:DATE}}}}' } ],
        'More footnotes' : [ { 'inserttext':'{{More footnotes|{{subst:DATE}}}}' } ],
        'Refimprove' : [ { 'inserttext':'{{Refimprove|{{subst:DATE}}}}' } ],
        'unreferenced' : [ { 'inserttext':'{{Unreferenced|{{subst:DATE}}}}' } ],
        'citecheck' : [ { 'inserttext':'{{Citecheck|article|{{subst:DATE}}}}' } ],
        'Review' : [ { 'inserttext':'{{Review|article|{{subst:DATE}}}}' } ],
        'Advert' : [ { 'inserttext':'{{Advert|article|{{subst:DATE}}}}' } ],
        'Howto' : [ { 'inserttext':'{{Howto|article|{{subst:DATE}}}}' } ],
        'Plot' : [ { 'inserttext':'{{Plot|article|{{subst:DATE}}}}' } ],
        'Crystal' : [ { 'inserttext':'{{Crystal|article|{{subst:DATE}}}}' } ],
        'fact' : [ { 'inserttext':'{{Fact|{{subst:DATE}}}}' } ],
        'weasel-inline' : [ { 'inserttext':'{{Weasel-inline|{{subst:DATE}}}}' } ],
        'Primarysources' : [ { 'inserttext':'{{Primarysources|{{subst:DATE}}}}' } ],
        'showrefs' : [ { 'evaluate':'easyCiteMain();citeNamedRef();' } ],
        'referrs' : [ { 'evaluate':'easyCiteMain();dispErrors();' } ],
        'uw-csd' : [ { 'prepend':'{{subst:uw-csd', 'append':'}}' },
                    {'title':'Page name', 'code':'1' },
                    {'title':'Criterion', 'code':'2' },
                    {'title':'Concern/reason', 'code':'3' },
                    {'title':'Additional text', 'code':'4' }
                    ],
        'Cite web' : [ { 'prepend':'<ref>{{Cite web', 'append':'}}</ref>', 'description':'This template is used to cite online sources in Wikipedia articles. {{<a href="/wiki/Template:Cite_news" title="Template:Cite news">Cite news</a>}} can also be used when citing a news source; for general information about citations in Wikipedia articles, see <a href="/wiki/Wikipedia:CITE" title="" class="mw-redirect">Wikipedia:cite sources</a>.' },
                    {'title':'Title:', 'code':'title', 'help':'title of the web article'},
                    {'title':'URL:', 'code':'url', 'help':'url of the web source'},
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when item was accessed, in ISO 8601 YYYY-MM-DD format, for example "accessdate = 2009-03-13". Must not be wikilinked.'},
                    {'title':'Author:', 'code':'author', 'help':'Author'},
                    {'title':'Last name:', 'code':'last', 'help':'Last name of the author'},
                    {'title':'First name:', 'code':'first', 'help':'First name of author'},
                    {'title':'Author link:', 'code':'authorlink', 'help':'works either with author or with last & first to link to the appropriate wikipedia article. Does not work with URLs.'},
                    {'title':'Coauthors:', 'code':'coauthors', 'help':'allows additional authors'},
                    {'title':'Publication date:', 'code':'date', 'help':'date the article was published'},
                    {'title':'Publication year:', 'code':'year', 'help':'year of publication'},
                    {'title':'Publication month:', 'code':'month', 'help':'month of publication'},
                    {'title':'Format:', 'code':'format', 'help':'e.g. PDF. HTML is implied'},
                    {'title':'Work:', 'code':'work', 'help':'If this item is part of a larger "work", such as a book, periodical or website, write the name of that work.'},
                    {'title':'Publisher:', 'code':'publisher', 'help':'Publisher, if any—for example if the website is hosted by a government service, educational institution, or company'},
                    {'title':'Location:', 'code':'location', 'help':'Geographical place of publication.'},
                    {'title':'Pages:', 'code':'pages', 'help':'pp. 5–7: first page and optional last page. This is for listing the pages relevant to the citation, not the total number of pages in the book.'},
                    {'title':'Language:', 'code':'language', 'help':'language of publication (don\'t specify "English" as this is the default).'},
                    {'title':'DOI:', 'code':'doi', 'help':'A digital object identifier for the document, such as 10.1038/news070508-7'},
                    {'title':'Archive url:', 'code':'archiveurl', 'help':'The URL of an archived copy of the page, if (or in case) the url becomes unavailable. Typically used to refer to services like WebCite and The Internet Archive. Requires archivedate.'},
                    {'title':'Archive date:', 'code':'archivedate', 'help':'Date when the item was archived (requires archiveurl), in ISO 8601 YYYY-MM-DD format, e.g. 2006-02-17. Must not be wikilinked.'},
                    {'title':'Date format:', 'code':'dateformat', 'help':'Formats the date in a consistent fashion. Possible values: none, dmy, ymd, mdy, iso. Preceding the value with an \'l\' (e.g. liso, ldmy) will wikilink the date. See Template:Date.'},
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant quote from online item.'}
                  ],
        'citenews' : [ { 'prepend':'<ref>{{cite news', 'append':'}}</ref>' },
                    {'title':'First name:', 'code':'first', 'help':'First name of author'},
                    {'title':'Last name:', 'code':'last', 'help':'Last name of the author'},
                    {'title':'Author link:', 'code':'authorlink', 'help':'works either with author or with last & first to link to the appropriate Wikipedia article. Does not work with URLs.'},
                    {'title':'Author:', 'code':'author', 'help':'Author'},
                    {'title':'Coauthors:', 'code':'coauthors', 'help':'Allows additional authors.'},
                    {'title':'Title:', 'code':'title', 'help':'required, rest is optional. Note that title must be on one line in order for the hyperlink to display properly. Do not enclose it in quotations marks, italics or other formatting, though it may be wikilinked.'},
                    {'title':'URL:', 'code':'url', 'help':'Link to the news item if available online (note this is not for a link to the main web page of the work of publisher, but only to a copy of the item specified in title). Start the url with the communications protocol e.g. http://. '},
                    {'title':'Format:', 'code':'format', 'help':'e.g. PDF. HTML is implied. Specify as "fee required" if free access is no longer available. Specify as "Reprint" if you use a full original version but not hosted by the original publisher.'},
                    {'title':'Agency:', 'code':'agency', 'help':'The news agency (wire service) that provided the content, e.g. Associated Press, Reuters, etc. Spell out and link the full name.'},
                    {'title':'Larger work:', 'code':'work', 'help':'The publication that ran the item, e.g. Newsweek. Can also be used for the name of a column or subpart of an issue. Do not italicize.'},
                    {'title':'Publisher:', 'code':'publisher', 'help':'The company or organization that publishes the news source. Not necessary for major publications like The New York Times, but may add credibility for local papers that are part of a family of publications like The McClatchy Company.'},
                    {'title':'Location:', 'code':'location', 'help':'Place of the publication, e.g. Toronto for The Globe and Mail. For student newspapers, include the name of the school.'},
                    {'title':'Identifier:', 'code':'id', 'help':'A unique identifier, used if none of the above are applicable. In this case, you need to specify the kind of identifier you are using, preferably with a template like {{ASIN}} or {{ISSN}}. (Use one of the more specialized parameters if possible; they are linked automatically. In other words, don\'t use id = ISBN 1-111-22222-9 anymore. Use isbn = 1-111-22222-9.)'},
                    {'title':'Pages:', 'code':'pages', 'help':'The page(s) on which the article is found. page inserts the abbreviation "p." before the number; pages inserts "pp." Use only one of these parameters. If numbers are entered for both, pages overrides page.'},
                    {'title':'Page:', 'code':'page', 'help':'The page(s) on which the article is found. page inserts the abbreviation "p." before the number; pages inserts "pp." Use only one of these parameters. If numbers are entered for both, pages overrides page.'},
                    {'title':'Publication date:', 'code':'date', 'help':'Date of publication. Use the same format as the main text of the article.'},
                    {'title':'Publication year:', 'code':'year', 'help':'year of publication'},
                    {'title':'Publication month:', 'code':'month', 'help':'month of publication'},
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when item was accessed, in ISO 8601 YYYY-MM-DD format, for example "accessdate = 2009-03-13". Must not be wikilinked.'},
                    {'title':'Language:', 'code':'language', 'help':'The language in which the source is written. If English (the default) do not use this parameter.'},
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant quotation. Adding a quotation can help locate online copies of the item using a text search, especially if the original link goes dead.'},
                    {'title':'Archive url:', 'code':'archiveurl', 'help':'URL of the archive location of the item; this is for archives (such archive.org and WebCite); for back-issues and the like that are on file at the publisher\'s site, use the "url" parameter (requires archivedate).'},
                    {'title':'Archive date:', 'code':'archivedate', 'help':'Date when the item was archived (requires archiveurl), in ISO 8601 YYYY-MM-DD format, e.g. 2006-02-17. Must not be wikilinked.'},
                    {'title':'Curly Quotes:', 'code':'curly', 'help':'y causes the title to be enclosed in true curved quotes, not typewriter quotes. Currently has no effect on the quotation specified in quote.'}
                  ],
        'citebook' : [ { 'prepend':'<ref>{{cite book', 'append':'}}</ref>' },
                    {'title':'Last name:', 'code':'last', 'help':'Surname of author. Don\'t wikilink (use authorlink instead).'},
                    {'title':'First name:', 'code':'first', 'help':'First name(s) of author, including title(s) (e.g. Firstname Middlename or Firstname M. or Dr. Firstname M., Snr.). Don\'t wikilink (use authorlink instead). '},
                    {'title':'Author link:', 'code':'authorlink', 'help':'Title of Wikipedia article about author. Article should already exist. Must not be wikilinked itself. Do not use this on its own, but along with "author" or "first" and "last".'},
                    {'title':'Coauthors:', 'code':'coauthors', 'help':'Full name of additional author or authors, separated by ", " (e.g. Joe Bloggs, John F. Kennedy, H. R. Dent).'},
                    {'title':'Editor:', 'code':'editor', 'help':'Name of editor/editors. Do not Wikilink any values in the editor field but use "editor-link" instead. The template automatically adds "ed." after the editor\'s name unless the "chapter" parameter is used in which case the template adds "in" before the editor\'s name which appears after the chapter and before the title.'},
                    {'title':'Other Contribs:', 'code':'others', 'help':'To record other contributors to the work, such as "illustrated by Smith" or "trans. Smith".'},
                    {'title':'title:', 'code':'title', 'help':'Title of book. This is the only required parameter. Can be wikilinked only to an existing Wikipedia article. Do not use italics.'},
                    {'title':'URL:', 'code':'url', 'help':'URL of an online location where the book can be found. Cannot be used if you wikilinked title. If applicable, can point to the specific page(s) referenced.'},
                    {'title':'Format:', 'code':'format', 'help':'Format, e.g. PDF. HTML implied if not specified.'},
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when url was accessed. Required when url field is used. Must not be wikilinked.'},
                    {'title':'Edition:', 'code':'edition', 'help':'When the book has more than one edition. e.g.: "2nd." (note that " ed." is placed after this field, so edition=2nd produces "2nd ed.").'},
                    {'title':'Series:', 'code':'series', 'help':'When the book is part of a series of publications'},
                    {'title':'Volume:', 'code':'volume', 'help':'For one book published in several volumes. However, this template displays the text in this field in bold type after the "title" and "series" parameters. An alternative is to include the volume information in the "title" field after the main title (see example below). (NB: there is a separate {{Cite encyclopedia}} template).'},
                    {'title':'Publication date:', 'code':'date', 'help':'Full date of publication edition being referenced, in the same format as the main text of the article. Must not be wikilinked.'},
                    {'title':'Orig publication year:', 'code':'origyear', 'help':'Original publication year, for display alongside the date or year. For clarity, please specify as much information as possible, for instance "First published 1859" or "Composed 1904". This parameter only displays if a there is a value for "year" or "date".'},
                    {'title':'Publication year:', 'code':'year', 'help':'Year of publication edition being referenced, and month: Name of the month of publication. If you also have the day, use date instead. Must not be wikilinked.'},
                    {'title':'Publication month:', 'code':'month', 'help':'Year of publication edition being referenced, and month: Name of the month of publication. If you also have the day, use date instead. Must not be wikilinked.'},
                    {'title':'Publisher:', 'code':'publisher', 'help':'Publisher should not include corporate designation such as "Ltd" or "Inc". '},
                    {'title':'Location:', 'code':'location', 'help':'Geographical place of publication.'},
                    {'title':'Language:', 'code':'language', 'help':'The language the book is written in, if it is not English. The template automatically puts parentheses around the text and adds "in" before the language name.'},
                    {'title':'ISBN:', 'code':'isbn', 'help':'International Standard Book Number such as 1-111-22222-9. Note that "isbn", like all field names, must be in lowercase.'},
                    {'title':'OCLC:', 'code':'oclc', 'help':'Online Computer Library Center ID number, such as 3185581'},
                    {'title':'DOI:', 'code':'doi', 'help':'A digital object identifier such as 10.1016/j.coi.2004.08.001.'},
                    {'title':'Bibcode:', 'code':'bibcode', 'help':'A nineteen character Bibcode identifier.'},
                    {'title':'ID:', 'code':'id', 'help':'A unique identifier, used if none of the above are applicable. In this case, you need to specify the kind of identifier you are using, preferably with a template like {{ASIN}} or {{ISSN}}. (Use one of the more specialized parameters if possible; they are linked automatically. In other words, don\'t use id = ISBN 1-111-22222-9 anymore. Use isbn = 1-111-22222-9.)'},
                    {'title':'Page:', 'code':'page', 'help':'"|pages= 5–7" produces pp. 5–7, while "|page= 5" produces p. 5. The "pp." notation indicating multiple pages, and "p." notation indicating a single page, are placed automatically when you choose between the plural (pages) or singular (page) form of the parameter. These parameters are for listing the pages relevant to the citation, not the total number of pages in the book.'},
                    {'title':'Pages:', 'code':'pages', 'help':'"|pages= 5–7" produces pp. 5–7, while "|page= 5" produces p. 5. The "pp." notation indicating multiple pages, and "p." notation indicating a single page, are placed automatically when you choose between the plural (pages) or singular (page) form of the parameter. These parameters are for listing the pages relevant to the citation, not the total number of pages in the book.'},
                    {'title':'No PP.:', 'code':'nopp', 'help':'using "page" or "pages", automatically places the p. or pp. notations. If this is inappropriate—for instance, if page=Front cover, placing any value after nopp will hide the p. or pp. notation.'},
                    {'title':'Chapter:', 'code':'chapter', 'help':'The chapter of the book, written in full. Punctuation other than quotes should be included in the value passed to the parameter, e.g. chapter = Meet Dick and Jane. produces "Meet Dick and Jane." ahead of title.'},
                    {'title':'Chapter URL:', 'code':'chapterurl', 'help':'URL of an individual chapter of online book. Should be at the same site as url, if any.'},
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant quote from the book.'},
                    {'title':'Link Ref:', 'code':'ref', 'help':'use this parameter to make the reference linkable. The variable is placed after the # in a hyperlink (the fragment identifier). Such a linkable reference can be made the target of wikilinks to full references, especially useful in short citations like shortened notes and author-date referencing. See an example for using ref field in citation templates below.'},
                    {'title':'Lay summary URL:', 'code':'laysummary', 'help':'Link to a non-technical summary (or review) of the book '},
                    {'title':'Lay summary date:', 'code':'laydate', 'help':'Date of summary'},
                    {'title':'Separator:', 'code':'separator', 'help':'The separator to use in lists of authors, editors, etc. Defaults to ".", but "," may be useful also.'}, 
                    {'title':'Postscript:', 'code':'postscript', 'help':'The closing punctuation for the citation. Defaults to ".", but "" may be useful also.'}, 
                    {'title':'Last Author Sep (&):', 'code':'lastauthoramp', 'help':'The separator to use between the last two names in lists of authors. Defaults to "", but "&" may be useful also.'}
                  ],
        'citejournal' : [ { 'prepend':'<ref>{{cite journal', 'append':'}}</ref>' },
                    {'title':'Last name:', 'code':'last', 'help':'last works with first to produce last, first'}, 
                    {'title':'First name:', 'code':'first', 'help':'last works with first to produce last, first'}, 
                    {'title':'Author Wikilink:', 'code':'authorlink', 'help':'authorlink works either with author or with last & first to link to the appropriate article (interwiki link)'}, 
                    {'title':'Coauthors:', 'code':'coauthors', 'help':'allows additional authors'}, 
                    {'title':'Publication date:', 'code':'date', 'help':'January 1, 2006. Full date of publication.'}, 
                    {'title':'Publication year:', 'code':'year', 'help':'2006. Year of publication (ignored if the date field is used).'}, 
                    {'title':'Publication month:', 'code':'month', 'help':'January. Month of publication (ignored if the date field is used, or if the year field is not used).'}, 
                    {'title':'Publication day:', 'code':'day', 'help':'31. Day of month of publication (ignored if the date field is used, or if the month field is not used).'}, 
                    {'title':'Title:', 'code':'title', 'help':'Title of article. This is the only required parameter. All other parameters are optional.'}, 
                    {'title':'Journal:', 'code':'journal', 'help':'Name of the journal or periodical.'}, 
                    {'title':'Volume:', 'code':'volume', 'help':'Volume number of the journal in which the article is found'}, 
                    {'title':'Issue:', 'code':'issue', 'help':'Journal\'s issue number, or issue name.'}, 
                    {'title':'Series:', 'code':'series', 'help':'According to the 14th edition of Chicago Manual of Style p. 576, "As in the case of book series, some journals have attained such longevity that they have begun a new series of volumes or issues. Identification of the series (n.s., 2d ser., 3d ser., ser. b) must be made in citations to these journals."'},
                    {'title':'Pages:', 'code':'pages', 'help':'45–47: first page, and optional last page (separated by an en dash –). Manually prepend with p. or pp. if desired.'}, 
                    {'title':'Publisher:', 'code':'publisher', 'help':'Publisher of journal or periodical; should not include corporate designation such as "Ltd" or "Inc". Only include if ISSN and DOI are unavailable.'}, 
                    {'title':'Location:', 'code':'location', 'help':'Place of publication for journal or periodical.'}, 
                    {'title':'ISSN:', 'code':'issn', 'help':'The publication\'s International Standard Serial Number such as 1111-2220. Only include if a DOI is unavailable.'}, 
                    {'title':'PMID:', 'code':'pmid', 'help':'The document\'s PubMed Unique Identifier, such as 15128012'}, 
                    {'title':'PMC:', 'code':'pmc', 'help':'The document\'s PubMed Central article number for full-text free repository of an article, such as 246835'}, 
                    {'title':'DOI:', 'code':'doi', 'help':'A digital object identifier for the document, such as 10.1130/0091-7613(1990)018<1153:TAFSIA>2.3.CO;2.'}, 
                    {'title':'Bibcode:', 'code':'bibcode', 'help':'The document\'s bibcode in the Astrophysics Data System, e.g., 1924MNRAS..84..308E'}, 
                    {'title':'OCLC:', 'code':'oclc', 'help':'The periodical\'s Online Computer Library Center ID number, such as 3185581'}, 
                    {'title':'Id:', 'code':'id', 'help':'A unique identifier, used if none of the above are applicable. In this case, you need to specify the kind of identifier you are using, preferably with a template like {{US patent}}, {{MR}} / {{MathSciNet}}, {{Zbl}}, {{arXiv}} or {{JFM}}. (Use one of the more specialized parameters if possible; they are linked automatically. In other words, don\'t use id = PMID 15128012 anymore. Use pmid = 15128012.)'}, 
                    {'title':'URL:', 'code':'url', 'help':'This should point to, in descending order of preference: 1. A free online version of the full text  2. An online version of the full text, for which subscription is required  3. An abstract or information page, if no DOI or PMID record is available. If a DOI or PMID is available, the URL should only be specified if it would point to a different page to that which a DOI or PMID would redirect to.'}, 
                    {'title':'Language:', 'code':'language', 'help':'Language, e.g. Finnish. (English is assumed and should not be specified.)'}, 
                    {'title':'Format:', 'code':'format', 'help':'Format, e.g. PDF. Don\'t specify for HTML (implied as default). Specify as "fee required" if free access no longer available. Specify as "Reprint" if a full original version but not hosted by the original publisher.'}, 
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when URL was last checked.'}, 
                    {'title':'Lay summary URL:', 'code':'laysummary', 'help':'URL of a lay summary, which could be in a popular science magazine or newspaper. '}, 
                    {'title':'Lay source:', 'code':'laysource', 'help':'Name of the source, e.g. The Guardian (UK newspaper) or New Scientist.'}, 
                    {'title':'Lay summary date:', 'code':'laydate', 'help':'Date of publication or, where this is not available, date of retrieval of the lay summary.'}, 
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant excerpt from the journal.'}
                ],
        'Cite video' : [ { 'prepend':'<ref>{{Cite video', 'append':'}}</ref>' },
                    {'title':'People:', 'code':'people', 'help':'May be anyone associated with the film. Add role in parentheses (Producer, Director, Actor, etc).'},
                    {'title':'ISO Date:', 'code':'date2', 'help':'Full date when production was first released or aired, in ISO 8601 YYYY-MM-DD format, eg. 2000-01-31 (January 01, 2000). Use only if full date is known. Must not be wikilinked.'},
                    {'title':'Year:', 'code':'year2', 'help':'Year when production was first released or aired. Use if full date is not known. '},
                    {'title':'Month:', 'code':'month2', 'help':'Month when production was first released or aired. May only be used with year2.'},
                    {'title':'Title:', 'code':'title', 'help':'Title of the production. This is the only required field.'},
                    {'title':'Url:', 'code':'url', 'help':'Provides a link to either the production\'s website or to its entry at IMDb. May wikilink to an article rather than provide a URL.'},
                    {'title':'Format:', 'code':'format', 'help':'File format of the URL link if containing digital media. For example, "mov" or "avi".'},
                    {'title':'Medium:', 'code':'medium', 'help':'Type of production being sourced. (Motion picture, Television production, Documentary, Videotape, DVD, Trailer, Video game.)'},
                    {'title':'Publisher:', 'code':'publisher', 'help':'Name of the individual or group releasing the production, or airing the broadcast. For example, "Paramount Pictures" or "Disney" or "History Channel International". '},
                    {'title':'Location:', 'code':'location', 'help':'Physical location of the publisher, formatted as either "City, State" or "City, Country". For example, "New York, NY" or "London, England".'},
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when url was accessed, in ISO 8601 YYYY-MM-DD format, eg. 2005-01-31 (January 01, 2005). Required when url field is used to link a url. (Must not be wikilinked.) '},
                    {'title':'Access year:', 'code':'accessyear', 'help':'Year of access, and accessmonth: Name of the month of access. If you also have the day, use accessdate instead. Must not be wikilinked.'},
                    {'title':'Access month:', 'code':'accessmonth', 'help':'Year of access, and accessmonth: Name of the month of access. If you also have the day, use accessdate instead. Must not be wikilinked.'},
                    {'title':'Time:', 'code':'time', 'help':'Roughly what time, if accessible, a scene occurs with-in a production. Useful for citing specific scenes, quotations or data.'},
                    {'title':'Id:', 'code':'id', 'help':'A unique identifier, used if none of the above are applicable. In this case, you need to specify the kind of identifier you are using, preferably with a template like {{ISSN}}. (Use one of the more specialized parameters if possible; they are linked automatically. In other words, don\'t use id = ISBN 1-111-22222-9 anymore. Use isbn = 1-111-22222-9.)'},
                    {'title':'ISBN:', 'code':'isbn', 'help':'International Standard Book Number such as 1-111-22222-9.'},
                    {'title':'OCLC:', 'code':'oclc', 'help':'Online Computer Library Center ID number, such as 3185581.'},
                    {'title':'Quote:', 'code':'quote', 'help':'information source quotation of pertinent data like is the likely reason for citing the media in the first place!'},
                ]
    };
}
if (smConfig['smCustomForms'] != 'undefined') {
	for (key in smConfig['smCustomForms']) {
		smConfig['smForms'][key] = smConfig['smCustomForms'][key];
	}
}

window.smRibbon = new Ribbon('smRibbon',{
	"Rows":"2",
	"defaultItemImage":"/media/wikipedia/commons/thumb/5/5a/Button_Icon_BlueSky.svg/10px-Button_Icon_BlueSky.svg.png",
	"MainClass":"HStrip",
	"GroupClass":"HStripB",
	"LeftClass":"HStripL",
	"CenterClass":"HStripP",
	"CenterImageClass":"HStripPC",
	"RightClass":"HStripR",
	"SingleClass":"HStripLR",
	"SelectedClass":"selected",
	"HoverClass":"hover",
	"ItemHoverClass":"hover",
	"GapClass":"HStripS",
	"MenuBarClass":"HMenuParent",
	"MenuClass":"HMenuItem",
	"onItem":"'smClickOption(\\'' + item.code + '\\',\\'' + item.value + '\\')'",
	"Menu":[
		{
			"Name":"References",
			"Groups":["Citations","References"],
			"show":"", "onShow":"", "onHide":"", "Default":"false"
		},
        {
            "Name":"Cleanup",
            "Groups":["Cleanup","Intro","Style"],
            "show":"", "onShow":"", "onHide":""
        }
		],
	"Groups":
		{
			"Citations": 
			{
				"Name":"Citations",
				"onClick":"",
				"Tabs": 
					[
						{
							"Image":"/media/wikipedia/en/thumb/9/99/Question_book-new.svg/35px-Question_book-new.svg.png",
							"Items":["Web","Book","News","Journal","Video","DOI Bot"],
                            "ItemCodes":["Cite web","citebook","citenews","citejournal","Cite video","doicite"]
						}
					]
			},
            "References":
            {
                "Name":"References",
                "onClick":"",
                "Tabs": [
                    {
                        "Items":["No refs","More refs","No notes","More notes","Cite check","Prim sources"],
                        "ItemCodes":["unreferenced","Refimprove","No footnotes","More footnotes","citecheck","Primarysources"]
                    }
                ]
            },
			"Cleanup": 
			{
				"Name":"Cleanup",
				"onClick":"",
				"Tabs": 
					[
						{
                            "Image":"/media/wikipedia/commons/thumb/2/2c/Broom_icon.svg/35px-Broom_icon.svg.png",
							"Items":["Cleanup","Copy Edit"],
                            "ItemCodes":["cleanup","copyedit"]
						}
					]
			},
			"Intro": 
			{
				"Name":"Intro",
				"onClick":"",
				"Tabs": 
					[
						{
							"Items":["Too long","Too short","Rewrite","Missing"],
                            "ItemCodes":["intro-toolong","intro-tooshort","intro-rewrite","intro-missing"]
						}
					]
			},
            "Style":{
                "Name":"Style",
                "Tabs":[{
                        "Items":["Review","Advert","Howto","Plot","Crystal"],
                        "ItemCodes":["Review","Advert","Howto","Plot","Crystal"]
                }]
            }
		}
},'');

// Taken from [[User:Mr.Z-man/refToolbar.js]]
// All credit for this function goes to him
window.smGetTime = function() {
  var time = new Date();
  var nowdate = time.getUTCDate();
  if (nowdate<10) { nowdate = "0"+ nowdate.toString(); }
  var nowmonth = time.getUTCMonth()+1;
  if (nowmonth<10) { nowmonth = "0"+ nowmonth.toString(); }
  var nowyear = time.getUTCFullYear();
  newtime =  nowyear + '-' + nowmonth + '-' + nowdate;
  return (newtime);
}

window.smVisibleMenu = 0;

function createLi() {
  var option = document.createElement('li');
  option.style.cssFloat = 'left';
  option.style.listStyle = 'none';
  option.style.backgroundColor = '#EEEEEE';
  option.style.textAlign = 'center';
  option.style.padding = '0 8px';
  option.style.border = '1px solid #555555';
  option.style.marginRight = '-1px';
  option.style.cursor = "pointer";
  option.setAttribute('onmouseover', "this.style.backgroundColor='#CCCCCC';");
  option.setAttribute('onmouseout', "this.style.backgroundColor='#EEEEEE';");
  return option;
}

function addButton(text) {
  var anchor = document.createElement('a');
  anchor.style.color = '#000000';
  anchor.innerHTML = text;
  anchor.style.textDecoration = 'none';

  var li = createLi();
  li.appendChild(anchor);
  return li;
}

window.smMenuHover = function(menuItem) {
	if (window['smVisibleMenu'] != 0) {
		smVisibleMenu.style.visibility="hidden";
	}
	smVisibleMenu = menuItem.childNodes[1];
	smVisibleMenu.style.visibility = 'visible';
}

window.smMenuOut = function(menuItem) {
  menuItem.childNodes[1].style.visibility = 'hidden';
}

// called when a button in a drop-down is clicked so that it can hide the drop-down
window.smSubMenuClickOption = function(subMenuItem, code, name) {
	subMenuItem.parentNode.style.visibility = 'hidden';
	smClickOption(code, name);
}

// creates a button with a drop-down menu
function addMenu(text, menu, menuIndex) {
  var hiddenLinks = document.createElement('div');
  hiddenLinks.id = 'smHidden' + String(menuIndex);
  hiddenLinks.style.zIndex = 3;
  hiddenLinks.style.position = 'absolute';
  hiddenLinks.style.visibility = 'hidden';
  hiddenLinks.style.margin = '0';
  hiddenLinks.style.marginLeft = '-9px';
  hiddenLinks.style.padding = '0';
  hiddenLinks.style.border = '1px solid #555555';
  
  for (var key in menu) {
	var anchor = document.createElement('a');
	anchor.innerHTML = key;
	anchor.style.display = 'block';
	anchor.style.position = 'relative';
	anchor.style.margin = '0';
	anchor.style.padding = '3px 10px';
	anchor.style.width = 'auto';
	anchor.style.textAlign = 'left';
	anchor.style.textDecoration = 'none';
	anchor.style.background = '#FFFFEE';
	anchor.style.color = '#000000';
    anchor.setAttribute('onmouseover', "this.style.backgroundColor='#6699CC'");
    anchor.setAttribute('onmouseout', "this.style.backgroundColor='#FFFFEE'");
	anchor.setAttribute('onclick', 'smClickOption("'+menu[key]+'", "'+key+'");this.parentNode.style.visibility = "hidden";');
	hiddenLinks.appendChild(anchor);
  }
  
  var li = addButton(text);
  li.appendChild(hiddenLinks);
  var mover = li.getAttribute('onmouseover');
  li.setAttribute('onmouseover', mover + 'smMenuHover(this);');
  var mout = li.getAttribute('onmouseout');
  li.setAttribute('onmouseout', mout + 'smMenuOut(this);');
  return li;
}

// Creates the menu on the page
function createMenu() {
  var toolbar = document.getElementById('toolbar');
  if (toolbar) {
    var menulist = document.createElement('ul');
	menulist.style.display = 'block';
	menulist.style.zIndex = 30;
	menulist.style.padding = '0';
	menulist.style.margin = '0';
	
	var smMenus = smConfig['smMenus'];
	var menuCount = 0;
	for (var key in smMenus) {
		if (typeof(smMenus[key]) == 'string') {
			var button = addButton(key);
			button.setAttribute('onclick', "smClickOption('"+smMenus[key]+"','"+key+"')");
			menulist.appendChild(button);
		} else {
			menuCount++;
			menulist.appendChild( addMenu(key, smMenus[key], menuCount) );
		}
	}

	window.smFormPanel = document.createElement('div');
	smFormPanel.style.clear = 'both';
	var cleardiv = document.createElement('div');
	cleardiv.style.clear = 'both';
    
    var ribbonStrip = document.createElement('div');
    ribbonStrip.className = 'HStrip';
    var ribbonMenu = document.createElement('div');
    ribbonMenu.className = 'HMenu';
    
    toolbar.insertBefore(smFormPanel, toolbar.childNodes[0]);
    //toolbar.insertBefore(cleardiv, toolbar.childNodes[0]);
    toolbar.insertBefore(ribbonStrip, toolbar.childNodes[0]);
    toolbar.insertBefore(ribbonMenu, toolbar.childNodes[0]);
    
	//toolbar.insertBefore(menulist, toolbar.childNodes[0]);
    toolbar.style.height = 'auto';
    
    smRibbon.configuration.Menu[0].Default='true';
    smRibbon.Initialize(ribbonStrip,ribbonMenu);
    smRibbon.state = 'load';
    smRibbon.Render();
  }
}

// closes the form that calls it (called from the Close Form button)
window.smCloseForm = function(sender) {
	var closeThisForm = sender.parentNode.parentNode;
	closeThisForm.parentNode.removeChild(closeThisForm);
}

// adds the template to the edit box using insertTags
// called form the add template button on the form
window.smAddTemplate = function(sender) {
	var templTable = sender.parentNode.childNodes[1];
	var inputs = templTable.getElementsByTagName('input');
	
	var formName = sender.id;
	var form = smConfig['smForms'][formName];
	
	var insertText = form[0]['prepend'];
	for (var i in inputs) {
		var inp = inputs[i];
		if (inp.value && inp.value.length > 0) {
			insertText += '|' + inp.id + '=' + inp.value;
		}
	}
	insertText += form[0]['append'];
	insertTags(insertText, '', '');
}

// Replaces %s tokens in a string with replacements
function textEval(haystack, replacements) {
    for (var i = 1; i < replacements.length; i++) {
        var sub = eval(replacements[i]);
        haystack = haystack.replace('%s', sub);
    }
    return haystack;
}

// Called when a button is clicked
// code refers to a form or function
// and name is the name of the form displayed at the top of the form
window.smClickOption = function(code, name) {
	var form = smConfig['smForms'][code];
    if (!form || !form['length'] || form['length'] < 1) {
        return;
    }
    if (form[0]['inserttext']) {
        insertTags(form[0]['inserttext'], '', '');
    } else if (form[0]['httplink']) {
        window.open(form[0]['httplink']);
    } else if (form[0]['httpeval']) {
        var url = textEval(form[0]['httpeval'][0], form[0]['httpeval']);
        window.open(url);
    } else if (form[0]['inserteval']) {
        var text = textEval(form[0]['inserteval'][0], form[0]['inserteval']);
        insertTags(text, '', '');
    } else if (form[0]['evaluate']) {
        eval(form[0]['evaluate']);
    } else {
        smShowForm(code, name);
    }
}

// Display a template form in the div
window.smShowForm = function(formName, title) {
    // If the smSingleForm option is set, close all previously open forms
    if (smConfig['smSingleForm']) {
        for (var i = 0; i < smFormPanel.childNodes.length; i++) {
            smFormPanel.removeChild(smFormPanel.childNodes[i]);
        }
    }

    var form = smConfig['smForms'][formName];
	var formFields = smGetFormFields(form);
	
	var formDiv = document.createElement('div');
    var titleLink = '<a href="http://en.wikipedia.org/wiki/Template:'+formName+'" target="_blank">'+title+'</a>';
	formDiv.innerHTML = '<fieldset><legend>'+titleLink+'</legend></fieldset>';
    smFormPanel.appendChild(formDiv);
	var table = document.createElement('table');
	table.cellspacing = 5;
    if (typeof(form[0]['description']) != 'undefined') {
        var formDesc = document.createElement('div');
        formDesc.innerHTML = form[0]['description'];
        formDiv.childNodes[0].appendChild(formDesc);
    }
    formDiv.childNodes[0].appendChild(table);
	
	var maxcols = smConfig['smColumns'];
	
	var col = 99;
	var currentTr = 0;
	
    // loop creates the table cells going from left to right maxcols
    // and then top to bottom
	for (var i = 0; i < formFields.length; i++) {
		if (col++ >= maxcols) {
			col = 1;
			currentTr = document.createElement('tr');
			table.appendChild(currentTr);
		}
		var td1 = document.createElement('td');
		td1.innerHTML = formFields[i]['title'];

		var td2 = document.createElement('td');
		var textField = createTextField(formFields[i]['code']);
		if (formFields[i]['defeval']) {
			textField.value = eval(formFields[i]['defeval']);
		} else if (formFields[i]['default']) {
			textField.value = formFields[i]['default'];
		}
		textField.title = formFields[i]['help'];
		td2.appendChild(textField);
		
        // each field has two TDs: one for the title and one for the text field
		currentTr.appendChild(td1);
		currentTr.appendChild(td2);
	}
	
    // adds buttons to the bottom of the form for add and close
	var addTemplateButton = addOption("smAddTemplate(this)", "Add Template");
	addTemplateButton.id = formName;
	addTemplateButton.style.cssFloat = 'left';
	formDiv.childNodes[0].appendChild(addTemplateButton);
	
	var closeButton = addOption("smCloseForm(this)", "Close Form");
	closeButton.style.cssFloat = "right";
	formDiv.childNodes[0].appendChild(closeButton);
}

// Takes a form template and returns an array of fields which have values filled
// Called when showing a form
function smGetFormFields(form) {
	var formFields = new Array();
	for (var i in form) {
		if (!form[i]['title'] || !form[i]['code']) continue;
		formFields.push(form[i]);
	}
	return formFields;
}

// Creates a text field for display on the form
// Called while showing a form
function createTextField(id) {
	var inp = document.createElement('input');
	inp.type = 'text';
	inp.id = id;
	inp.tabIndex = 1;
	inp.style.width = smConfig['smTextWidth'];
	return inp;
}

// Creates a button for display on the form
// Called when showing a form
function addOption(script, text) {
  option = document.createElement('input');
  option.setAttribute('type', 'button');
  option.setAttribute('onclick', script);
  option.setAttribute('value', text);
  option.setAttribute('tabIndex', 1);
  return option;
}

// The following code is from http://code.google.com/p/jribbon/
// It is listed as GNU GPL, both on the Google Code page and on
// the author's website at http://www.openwebstudio.com/
// WebCite archive: http://www.webcitation.org/5gpjSnfj8
function Ribbon(callerobj,Config) {
	this.configuration = Config;
	this.caller = callerobj;
	this.target = null;
	this.menutarget = null;
	this.selected = null;
	this.state=null;
	this.Editors = new Array();
	
	function RibbonEditor(editor,helper)
	{
		this.cEditor = editor;
		this.cHelper = helper;
		this.RibbonTab = false;
		this.RibbonMenu = false;
		this.Editor = function()
		{
			if (this.cEditor!=undefined && this.cEditor.id==undefined)
			{
				this.cEditor = $(this.cEditor);
			}
			return this.cEditor;
		}
		this.Helper = function()
		{
			if (this.cHelper!=undefined && this.cHelper.id==undefined)
			{
				this.cHelper = $(this.cHelper);
			}
			return this.cHelper;
		}
	}
	
	this.Initialize = function (target,menutarget,editorIndex)
	{
		this.target = target;
		this.menutarget = menutarget;
		if (this.selected==null&&this.configuration.Menu!=undefined)
		{
			for (var i=0;i<this.configuration.Menu.length;i++)
			{
				if (this.configuration.Menu[i].Default!=undefined && this.configuration.Menu[i].Default.toUpperCase() == 'TRUE')
				{
					this.selected = this.configuration.Menu[i];
					i = this.configuration.Menu.length+1;
				}
			}
		}
		this.Render(editorIndex);
	}
	this.Regenerate = function(txtobj) {
		this.Render(txtobj.EditorIndex);
	}
	this.Toggle = function(groupname,txtobj) {
		var canLoad = true;
		if (typeof this.Editors[groupname] != 'undefined')
		{
			if (txtobj.id == this.Editors[groupname].cEditor.id)
			{
				canLoad = false;
			}
			else
				this.Remove(this.Editors[groupname].cEditor);
		}
		if (canLoad) this.Editors[groupname]=this.Generate(txtobj);
	}
	this.Remove = function(txtobj) {
			if (typeof txtobj.EditorIndex != 'undefined' && txtobj.EditorIndex != null)
			{
				var rEditor = this.Editors[txtobj.EditorIndex];
				this.Editors[txtobj.EditorIndex]=null;
				txtobj.EditorIndex = null;
				txtobj.onkeydown=false;
				txtobj.setAttribute('isLoaded','false');
				txtobj.parentNode.removeChild(rEditor.RibbonTab);
				txtobj.parentNode.removeChild(rEditor.RibbonMenu);
				rEditor.RibbonTab = false;
				rEditor.RibbonMenu = false;
			}
	}
	this.Generate = function(txtobj) {
		var randomnumber=Math.floor(Math.random()*32767)
		//this.HelpTabID='RibbonHelp' + randomnumber;
		
		var editorIndex = 0;
		
		var rEditor = new RibbonEditor(txtobj,'RibbonHelp' + randomnumber);
		this.Editors.push(rEditor);
		editorIndex=this.Editors.length-1;
		txtobj.EditorIndex = editorIndex;
				
		var override=true;
		var rtext = true;
		var isLoadedObj = txtobj.getAttribute('isLoaded');
		if (typeof isLoadedObj=='undefined' || isLoadedObj==null)
			isLoadedObj = false;
		else
			if (isLoadedObj =='false')
				isLoaded=false;
			else
				isLoaded=true;
			
		if(isLoadedObj==true)
			rtext=false;
			
		if(rtext){
			txtobj.setAttribute('isLoaded','true');
			this.EditorSetup(txtobj);
			eval('txtobj.onkeydown=function(event){return window.' + this.caller + '.EditorKeyDown(this,event)};');
			var dv=document.createElement('div');
			dv.className=this.configuration.MainClass;

			txtobj.parentNode.insertBefore(dv,txtobj);
			var dvm = document.createElement('div');
			dvm.className=this.configuration.EditorMenuBarClass;
			
			this.Initialize(dv,dvm,editorIndex);
			
			txtobj.parentNode.insertBefore(dvm,dv);		
			
			rEditor.RibbonTab = dv;
			rEditor.RibbonMenu = dvm;
		}
		return rEditor;
	}		
	this.EditorSetup = function(item)
	{
		var iMinHeight=50;var iHitHeight=50;var iMinWidth=50;var iHitWidth=50;
		var cookiei=0;
		if(lxGetCookie(this.caller)!=null)
		cookiei=parseInt(lxGetCookie(this.caller).replace('px',''));
		var itemi=parseInt(item.style.height.replace('px',''));
		if(itemi<iMinHeight||cookiei<iMinHeight){itemi=iMinHeight;lxtxtUp(item);}
		else{item.style.height=lxGetCookie(this.caller);}		
	}
	this.EditorReplaceSelection = function (input,replaceString,replaceValue,itemCursor){
		if (itemCursor==null)
				itemCursor = 0;	
		if (!isNaN(input))
			input = this.Editors[input].Editor();
	input.focus();		
		if(input.setSelectionRange)
			{	
				var selectionStart=input.selectionStart;
				var selectionEnd=input.selectionEnd;
				var scrollTop=input.scrollTop;
				if(replaceValue!=undefined&&selectionEnd>selectionStart){
					var result=input.value.substring(selectionStart,selectionEnd);
					replaceString=this.EditorReplace(replaceValue,result);
				}
				input.value=input.value.substring(0,selectionStart)+replaceString+input.value.substring(selectionEnd);
				input.scrollTop=scrollTop;
				if(selectionStart !=selectionEnd){
					this.EditorSelectionRange(input,selectionStart,selectionStart+replaceString.length-itemCursor);
				}
				else
				{
					this.EditorSelectionRange(input,selectionStart+replaceString.length,selectionStart+replaceString.length-itemCursor);
				}
			}
		else if(document.selection)
				{ 
					var range=document.selection.createRange();
					if(range.parentElement()==input)
					{
						if(replaceValue!=undefined)
						{
							var result=range.text;
							replaceString=this.EditorReplace(replaceValue,result);
						}
						var isCollapsed=range.text=='';
						range.text=replaceString;
						if(!isCollapsed){
							range.moveStart('character',-replaceString.length-itemCursor);range.select();
						}
					}
				}
	}	
	this.EditorGetSelection = function (input){
	
		if (!isNaN(input))
			input = this.Editors[input].Editor();
	input.focus();		
		if(input.setSelectionRange)
			{	
				var selectionStart=input.selectionStart;
				var selectionEnd=input.selectionEnd;
				var scrollTop=input.scrollTop;
					var result=input.value.substring(selectionStart,selectionEnd);
					return result;
			}
		else if(document.selection)
				{ 
					var range=document.selection.createRange();
					if(range.parentElement()==input)
					{
							var result=range.text;
							return result;
					}
				}
	}	
	this.EditorReplace = function (replaceValue,input)
		{
			if (!isNaN(input))
				input = this.Editors[input].Editor();
				
			var result=input;
			if(replaceValue==true)
			{	var re=new RegExp("\\\\+","g");var s='';var lindex=0;var m=re.exec(result);
				while(m!=null){
					if(m.index>lindex)
					{s=s+result.substring(lindex,m.index);}
					s=s+result.substring(m.index,m.index+m.length);
					lindex=m.index+m.length;
					m=re.exec(result);
				}
				if(lindex<result.length)
					{s=s+result.substring(lindex);}
				result=s;
				re=new RegExp("[\"]","g");
				result=result.replace(re,"\\\"");
				re=new RegExp("[\[]","g");
				result=result.replace(re,"\\[");
				re=new RegExp("[\]]","g");
				result=result.replace(re,"\\]");
				re=new RegExp("[\{]","g");
				result=result.replace(re,'\\{');
				re=new RegExp("[\}]","g");
				result=result.replace(re,'\\}');
			}
			else
			{
				var re=new RegExp("\\\\+","g");
				var s='';
				var lindex=0;
				var m=re.exec(result);
				while(m!=null){
					if(m.index>lindex)
						{s=s+result.substring(lindex,m.index);}
					s=s+result.substring(m.index,m.index+m.length-1);lindex=m.index+m.length;m=re.exec(result);
				}
				if(lindex<result.length){s=s+result.substring(lindex);}
				result=s;
			}
		return result;
	}
	this.EditorSelectionRange = function(input,selectionStart,selectionEnd)
	{
		if (!isNaN(input))
			input = this.Editors[input].Editor();
		if(input.setSelectionRange)
		{
			input.focus();
			input.setSelectionRange(selectionStart,selectionEnd);
		}
		else if(input.createTextRange)
		{
			var range=input.createTextRange();
			range.collapse(true);
			range.moveEnd('character',selectionEnd);
			range.moveStart('character',selectionStart);
			range.select();
		}
	}	
	this.EditorKeyDown = function (item,e)
	{
	
			if(!e)
				e=window.event;
			c=e.which?e.which:e.keyCode;
			if(c==9){
				return this.EditorKeyDownHandler(item,'TAB');}
			else if(c==40&&e.ctrlKey){
				return this.EditorKeyDownHandler(item,'UP');}
			else if(c==38&&e.ctrlKey){
				return this.EditorKeyDownHandler(item,'DOWN');}
			else if(c==39&&e.ctrlKey&&e.altKey){
				return this.EditorKeyDownHandler(item,'RIGHT');}
			else if(c==37&&e.ctrlKey&&e.altKey){
				return this.EditorKeyDownHandler(item,'LEFT');}
			else if(c==69&&e.ctrlKey){
				return this.EditorKeyDownHandler(item,'ESCAPE');}
			else if(c==82&&e.ctrlKey){
				return this.EditorKeyDownHandler(item,'UNESCAPE');}
			else if(c==192&&e.ctrlKey){
				return this.EditorKeyDownHandler(item,'AUTOPASTE');}
			else if(c==192&&e.altKey){
				return this.EditorKeyDownHandler(item,'AUTOCOPY');}
		}
	this.onItemClick = function (input,group,tab,item)
	{
		if (!isNaN(input))
		input = this.Editors[input].Editor();
		
		tab = eval('this.configuration.Groups.' + group + '.Tabs[' + tab + ']');
		if (tab!=undefined && tab!=null)
		{
			item = tab.ItemEditor[item];
			if (item.length!=undefined && item.length > 0)
			{
				this.EditorReplaceSelection(input,item);
			}
			else
			{
				if (item.Cursor!=undefined)
				{
					var itemCursor = item.Cursor;
					item = item.Text;
					if (item.length!=undefined && item.length > 0)
					{
						this.EditorReplaceSelection(input,item,null,itemCursor);
					}					
				}
			}
		}
		return false;
	}
	var txtClip = '';
	var txtPasteItem = null;
	this.PasteHandler = function (lastPosition, sl)
	{
		/* settings values */
		var delayMax = 100;
		var ta; 
		ta = this.txtPasteItem;
		var mt = "";
		//var sl = 0;
		if (sl == undefined || sl==null)
		{
			sl = 0;
		}
		var charWidth = 7;
		var tabWidth = 8 * charWidth;
		/* this should be charWidth * the width of the textarea */
		var slStart = - ta.clientWidth;//-30 * charWidth;

		
		
		var c;
		c = this.txtClip[lastPosition];
		ta.value = ta.value + c
		
		if (c=="\n")
		{
			sl = slStart;
		}
		else if (c=="\t")
		{
			sl+= tabWidth;
		}
		else
		{
			sl+= charWidth;
		}
		ta.scrollLeft = (sl>0?sl:0);
		ta.scrollTop = 5000;	
		
		
		lastPosition++;
		if (lastPosition < this.txtClip.length)
		{
			var waiter = Math.round(delayMax*Math.random());
			//window.setTimeout('RibbonEditor.PasteHandler(' + lastPosition + ');',waiter);
			window.setTimeout('RibbonEditor.PasteHandler(' + lastPosition + ',' + sl + ');',waiter);
		}
	}
	this.EditorKeyDownHandler = function(item,code)
	{
		var iMinHeight=50;var iHitHeight=50;var iMinWidth=50;var iHitWidth=50;
		switch(code.toUpperCase())
		{
			case 'TAB':
				this.EditorReplaceSelection(item,String.fromCharCode(9));
				return false;
				break;
			case 'AUTOPASTE':
				this.txtPasteItem = item;
				this.PasteHandler(0);
				return false;
				break;				
			case 'AUTOCOPY':
				this.txtClip = this.EditorGetSelection(item);
				return false;
				break;				
			case 'UP':
				var itemi=parseInt(item.style.height.replace('px',''));
				if(itemi>=iMinHeight){item.style.height=(itemi+iHitHeight)+'px';}
				else{item.style.height=iMinHeight+'px';}
				lxSetCookie(this.caller,item.style.height);
				return false;
				break;
			case 'DOWN':
				var itemi=parseInt(item.style.height.replace('px',''));
				if(itemi>iMinHeight){item.style.height=(itemi-iHitHeight)+'px';}
				else{item.style.height=iMinHeight+'px';}
				lxSetCookie(this.caller,item.style.height);
				return false;
				break;
			case 'RIGHT':
				var itemi=parseInt(item.style.width.replace('px',''));
				if(itemi>=iMinWidth){item.style.width=(itemi+iHitWidth)+'px';}
				else{item.style.width=iMinWidth+'px';}
				break;
			case 'LEFT':
				var itemi=parseInt(item.style.width.replace('px',''));
				if(itemi>iMinWidth){item.style.width=(itemi-iHitWidth)+'px';}
				else{item.style.width=iMinWidth+'px';}
				return false;
				break;
			case 'ESCAPE':
				this.EditorReplaceSelection(item,'',true);
				return false;
				break;
			case 'UNESCAPE':
				this.EditorReplaceSelection(item,'',false);
				return false;
				break;
		}
	}
	this.onMenu = function (menuindex,editorIndex)
	{
		if (this.configuration.Menu!=undefined&&this.configuration.Menu.length > menuindex)
		{
			this.selected = this.configuration.Menu[menuindex];
			if (this.selected.onShow!=undefined && this.selected.onShow.length>0)
			{
				eval(this.selected.onShow);
			}
		}	
		this.Render(editorIndex);
	}
	this.onMenuHover = function (o)
	{
		o.xclassName = o.className;
		if (o.className!=this.configuration.SelectedClass)
			o.className= this.configuration.HoverClass;
	}
	this.onMenuBlur = function (o)
	{
	 o.className=o.xclassName;
	}	
	this.onItemHover = function (o,group,iindex,tindex,editorIndex)
	{
		o.xclassName = o.className;
		o.className=this.configuration.ItemHoverClass;
		if (group!=undefined && group!=null)
		{
			var helptxt = eval('this.configuration.Groups.' + group + '.Tabs[' + tindex + '].ItemHelp[' + iindex + ']');
			if (helptxt!=null && this.Editors[editorIndex]!=null && typeof this.Editors[editorIndex].Helper != 'undefined' && this.Editors[editorIndex].Helper !=null && this.Editors[editorIndex].Helper() != null)
				this.Editors[editorIndex].Helper().innerHTML = helptxt;
		}
	}
	this.onItemBlur = function (o,group,iindex,tindex)
	{
		o.className=o.xclassName;
	}
	this.Render = function (editorIndex)
	{
		arr = new Array();
		if (this.menutarget!=null && this.configuration!=null)
		{
			if (this.configuration.Menu!=null && this.configuration.Menu.length > 0)
				this.renderMenu(arr,editorIndex);
			this.menutarget.innerHTML = arr.join('');
		}
		arr = new Array();
		if (this.target!=null  && this.configuration!=null && this.selected!=null)
		{
			var groups = this.selected.Groups;
			arr.push('<table cellpadding=0 cellspacing=0>');
			if (groups!=null && groups.length > 0)
			{
				arr.push('<TR>');			
				for (var i=0;i<groups.length;i++)
				{
					//RENDER GROUP 
					var group = false;
					eval('group=this.configuration.Groups.' + groups[i]);
					this.renderGroup(this.configuration.Rows,group,arr,editorIndex);
					if (i<groups.length-1)
					{
						arr.push('<TD class="' + this.configuration.GapClass + '"></TD>');
					}
				}
				arr.push('</TR>');							
				arr.push('<TR>');			
				for (var i=0;i<groups.length;i++)
				{
					//RENDER FOOTER
					this.renderGroupFooter(this.configuration.Rows,eval('this.configuration.Groups.' + groups[i]),arr,editorIndex);
					if (i<groups.length-1)
					{
						arr.push('<TD class="' + this.configuration.GapClass + '"></TD>');
					}
				}
				arr.push('</TR>');							
			}
			arr.push('</table>');	
			this.target.innerHTML = arr.join('');
		}
	}
	this.renderGroupFooter = function (rows,group,arr,editorIndex)
	{
		colspan = 0;
		if (group.Tabs != null && group.Tabs.length > 0)
		{
			for (var tti = 0; tti < group.Tabs.length; tti++)
			{
				tabcolumns = 0;
				itemcounter = 0;			
				if (group.Tabs[tti].Columns!=undefined)
					tabcolumns=1;
				else
				{
					if (group.Tabs[tti].Image!=undefined && group.Tabs[tti].Image.length > 0)
					{	itemcounter++;itemcounter++; }
					if (group.Tabs[tti].ImageMap!=undefined && group.Tabs[tti].ImageMap.length > 0)
						itemcounter++;
					if (group.Tabs[tti].Items!=undefined)
						itemcounter = itemcounter + group.Tabs[tti].Items.length;
					tabcolumns = parseInt(itemcounter / rows);
					if (itemcounter / rows > tabcolumns)
						tabcolumns++;				
				}
				colspan = colspan + tabcolumns;
			}
		}		
		if (colspan > 0)
		{
			arr.push('<td class="' + this.configuration.GroupClass + '" colspan=' + colspan + '>' + group.Name + '</td>');
		}
	}
	this.renderMenu = function (arr,editorIndex)
	{
		if (this.configuration.Menu != null && this.configuration.Menu.length > 0)
		{
			arr.push('<div class="' + this.configuration.MenuBarClass + '">');
			for (var mnuI = 0; mnuI < this.configuration.Menu.length; mnuI++)
			{
				if (this.state!=null && this.configuration.Menu[mnuI].show==this.state || this.configuration.Menu[mnuI].show=='')
					this.renderMenuItem(this.configuration.Menu[mnuI],mnuI,arr,editorIndex);
			}
			arr.push('</div>');
		}	
	}
	this.renderMenuItem = function (group,index,arr,editorIndex)
	{
		arr.push('<div ' + (this.selected!=null&&group.Name==this.selected.Name?'class="' + this.configuration.SelectedClass+'"':'class=' + this.configuration.MenuClass + '"') + ' onclick="' + this.caller + '.onMenu(' + index + ',' + (editorIndex==null?'null':editorIndex)  + ');" onmouseover="' + this.caller + '.onMenuHover(this);" onmouseout="' + this.caller + '.onMenuBlur(this);">' + group.Name + '</div>');
	}
	this.renderGroup = function (rows,group,arr,editorIndex)
	{
		if (group.Tabs != null && group.Tabs.length > 0)
		{
			for (var tabI = 0; tabI < group.Tabs.length; tabI++)
			{
				group.Tabs[tabI].Index=tabI;
				this.renderTab(rows,group,group.Tabs[tabI],(tabI==0?true:false),(tabI==group.Tabs.length-1?true:false),arr,editorIndex,tabI);
			}
		}
	}
	this.renderTab = function (rows,group,tab,firsttab,lasttab,arr,editorIndex)
	{
		var thisEditorIndex = -1;
		var classname = '';
		var isLastTab = lasttab;
		var crow = 0;
		if (tab.Image!=undefined && tab.Image.length > 0)
		{ crow+=2; 
		  if (tab.ImageMap!=undefined && tab.ImageMap.length > 0)
			crow++;	
		}
		if ((tab.Columns==undefined && rows-crow < (tab.Items!=undefined?tab.Items.length:0)) || tab.Columns!=undefined && rows-crow < tab.Columns )
		{
			lasttab=false;
		}	
		crow = 0;
		if (editorIndex!=undefined)
			thisEditorIndex = editorIndex;	
		
		if (lasttab && firsttab)
			classname = this.configuration.SingleClass;
		else if (lasttab)
			classname = this.configuration.RightClass;
		else if (firsttab)
			classname = this.configuration.LeftClass;
		else
			classname = this.configuration.CenterClass;
		if (tab.Items==undefined || tab.Items.length == 0)
			classname = this.configuration.CenterImageClass;
			
		var tdc = '<div>';
		var tde = '</div>';
		var tc = 'div';
		if (tab!=null)
		{
			var style = '';
			if (tab.Style!=undefined)
				style = ' style="' + tab.Style + '" ';
				
			if (tab.Image!=undefined && tab.Image.length > 0)
			{
				arr.push('<td class="' + classname + '"' + style + '>' + tdc);
				crow = crow + 2;
				if (tab.ImageMap!=undefined && tab.ImageMap.length > 0)
				{
					arr.push('<img src="' + tab.Image + '" border=0 useMap="' + tab.ImageMap + '">');
					crow++;
				}
				else
				{
					arr.push('<img src="' + tab.Image + '">');
				}
				if (crow == rows)
				{ arr.push(tde + '</td>'); crow = 0; }
			}
			else
			{
				//tdc = '<UL>';
				//tde = '</UL>';
				//tc = 'li';
			}

			if (tab.Columns!=undefined)
			{
				arr.push('<td class="' + classname + '"' + style + '>');
				if (tab.Help==undefined || tab.Help.toUpperCase()!='TRUE')
				{
					arr.push('<div class="' + tab.ColumnClass + '">');
					arr.push('<table width=100% border=0 cellpadding=0 cellspacing=0>');
				}
				else
				{
					if (editorIndex!=undefined)
					{
						var chelper=this.Editors[editorIndex].cHelper;

						arr.push('<div class="' + tab.ColumnClass + '" id="' + chelper + '">');
						arr.push(tab.DefaultHelp);
					}
				}
			}
			if (tab.Items!=undefined && tab.Items.length > 0)
			{
				for (var ti = 0;tab.Items!=undefined && ti < tab.Items.length; ti++)
				{
					lasttab=false;
					if (tab.Columns==undefined && isLastTab && rows-crow > tab.Items.length-ti-1)
						lasttab=true;
					if (lasttab && firsttab)
						classname = this.configuration.SingleClass;
					else if (lasttab)
						classname = this.configuration.RightClass;
					else if (firsttab && tab.Columns==undefined)
						classname = this.configuration.LeftClass;
					else
						classname = this.configuration.CenterClass;
						
					if (tab.Columns!=undefined)
					{
						if (crow==0)
						{arr.push('<tr>');}
						if (crow >=0)
						{arr.push('<td class="' + classname + '">' + tdc); }
						classname = this.configuration.CenterClass;
					}
					else
					{
						if (crow==0)
						{arr.push('<td class="' + classname + '"' + style + '>' + tdc); }
					}
						
					var item = new function() {
                        this.value = tab.Items[ti];
                        this.code = tab.ItemCodes[ti];
                    }
					var onclick = '';
					var onclickparameters = '()';
					
					if (tab.onclick==undefined||tab.onclick==null||tab.onclick.length==0)
					{
						if (this.configuration.onItem!=undefined && this.configuration.onItem!=null)
						{
							onclick= eval(this.configuration.onItem);
							onclickparameters =	'(' + thisEditorIndex + ')';
						}
					}
					else
					{
						onclick=  eval(tab.onclick);
						onclickparameters = '(' + thisEditorIndex + ')';
					}
					//onclick = onclick.replace(' ','_').replace('-','_').replace('\'','_');
					
					if (editorIndex!=undefined && tab.ItemEditor!=undefined && tab.ItemEditor!=null && tab.ItemEditor.length == tab.Items.length)
					{
						if (tab.ItemEditor[ti]!=null && (tab.ItemEditor[ti].length != undefined || tab.ItemEditor[ti].Text != undefined))
						{
							onclick = this.caller + '.onItemClick';
							onclickparameters = '(' + editorIndex + ',\'' + group.Abbr + '\',' + tab.Index + ',' + ti + ')';
						}
					}
					/*else
					{
						if (eval('!window.' + onclick) && this.configuration.debug!=undefined)
							alert('The Ribbon control requires a definition for function: ' + onclick);
					}*/

					var image = null;
					if (this.configuration.defaultItemImage!=undefined)
						image = this.configuration.defaultItemImage;
					if (tab.ItemImages!=undefined && tab.ItemImages[ti].length > 0)
						image = tab.ItemImages[ti];
                    
                    /* start odie5533's changes */
                    onclickparameters = '';
                    /* end odie5533's changes */
					if (tab.ItemHelp==undefined)
						arr.push('<' + tc + ' onclick="' + onclick + onclickparameters + '" onmouseover="' + this.caller + '.onItemHover(this);" onmouseout="' + this.caller + '.onItemBlur(this);">' + (image!=null?'<img src=' + image + '>':'') + tab.Items[ti] + '</' + tc + '>');	
					else
						arr.push('<' + tc + ' onclick="' + onclick + onclickparameters + '" onmouseover="' + this.caller + '.onItemHover(this,\'' + group.Abbr + '\',' + ti + ',' + tab.Index + ',' + thisEditorIndex + ');" onmouseout="' + this.caller + '.onItemBlur(this,\'' + group.Name + '\',' + ti + ',' + tab.Index + ');">' + (image!=null?'<img src=' + image + '>':'') + tab.Items[ti] + '</' + tc + '>');	
					crow++;
					if (tab.Columns!=undefined)
					{ arr.push(tde + '</td>'); }
					
					if (crow == rows && tab.Columns==undefined)
					{ arr.push(tde + '</td>'); crow = 0; firsttab=false;}
					else if (tab.Columns!=undefined && crow==tab.Columns)
					{ arr.push('</tr>'); crow = 0; firsttab=false; }
				}
			}
			if (crow!=0 && tab.Columns==undefined)
				arr.push(tde + '</td>');
			else if (tab.Columns!=undefined)
			{	
				if (tab.Help==undefined || tab.Help.toUpperCase()!='TRUE')
				{
					var bcrow = false;
					while (crow != tab.Columns && crow > 0)
					{
						bcrow=true;
						arr.push('<td>&nbsp;</td>');
						crow++;
					}
					if (bcrow)
						arr.push('</tr>');
					arr.push('</table>');
				}
				arr.push('</div>');
				arr.push('</td>');
			}
		}
	}
}





var cssNode = document.createElement('style');
cssNode.type = 'text/css';
cssNode.innerHTML = 'div.HMenuParent{clear:both;font-size:8pt;background-color:#eee;width:100%;height:25px;border-bottom:2px solid #bbb}div.HMenuParent div{float:left;padding-top:4px;margin:3px 3px -3px 3px;text-align:center;width:94px;height:18px}div.HMenuParent div.selected{padding-top:3px;margin:3px 2px -3px 2px;background-color:#ccc;border:1px solid black;border-bottom:0}div.HMenuParent div.hover{padding-top:3px;margin:3px 2px -3px 2px;border:1px dashed black;border-bottom:0;background-color:#ddd}div.HStrip table tr td div{text-align:center}div.HStrip table tr td{vertical-align:middle}div.HStrip table tr td.HStripPC{vertical-align:middle}div.HStrip table tr td div div{height:18px;text-align:left;margin-bottom:1px;padding-left:5px;padding-right:8px;white-space:nowrap}div.HStrip table tr td div div img{margin-right:4px}div.HStrip table tr td div div.hover{background-color:#ddd}div.HStrip{clear:both;border:1px solid #ccc;border-top:0;margin-bottom:1px}div.HStrip table{background:#eee !important;margin:2px 0 2px 2px}div.HStrip{background:#eee}td.HStripS{width:2px}td.HStripP{padding:0 15px 0 5px;margin:0}td.HStripPC{padding:0 0 0 5px;margin:0}td.HStripLR{border-right:1px solid #ccc;padding-left:5px;margin-left:8px}td.HStripL{ border-left:1px solid #ccc;padding:0 5px 0 5px;margin:0}td.HStripR{border-right:1px solid #ccc;padding:0 0 0 5px;margin:0}td.HStripB{font-size:0.8em; background:#ccc;border-top:1px solid #ccc;text-align:center;color:black}.HStripE td.HStripPC{vertical-align:middle; font-family:arial,helvetica;font-size:8pt; padding:0px 0px 0px 0px;margin:0px 0px 0px 0px}';
document.getElementsByTagName("head")[0].appendChild(cssNode);
hookEvent("load", createMenu);
}

if (window.parent == window) {
    // append wrapper to head if run under Greasemonkey
	if (typeof(GM_getValue) == 'function') {
        var script = document.createElement('script');
        script.id = 'SnippetManager';
        script.type = 'text/javascript';
        script.text = 'smHeadWrapper = ' + SnippetManagerWrapper.toString() + '; smHeadWrapper();';
        document.getElementsByTagName('head')[0].appendChild(script);
	}
    // otherwise run installation directly
	else {
		SnippetManagerWrapper();
	}
}

// </nowiki></pre>