Unnamed Fossil Project

Check-in [e934a7b77e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Zaloha pred pejskem. Move to sourceMakeup.
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:e934a7b77e681b94b75d72344c24c76b74e686c1
User & Date: Hry 2013-04-07 15:13:58
Context
2013-04-07
15:13
Zaloha pred pejskem. Move to sourceMakeup. Leaf check-in: e934a7b77e user: Hry tags: trunk
2013-04-06
14:38
Serializace. check-in: 957d8787c3 user: Spravce tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to brickyard.php.

1


2
3

4
5


























6
7
8
9
10
11
12
<?php


//
// Brickyard framework by Severak

//
//I am not yet decided about license. But I prefer WTFPL.


























class brickyard
{
	public $inDevelMode = false;
	public $router = null;
	public $view = null;
	public $logger = null;
	public $libPath = '.';

>
>
|
<
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4

5
6

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
// Brickyard framework
// ===================
// 

// Because reinventing the wheel is fun.
// 

// It aims to be simpler and smaller than others. Not suitable for enterprise.
// 
// Note that source of this documentation is source of framework itself.
//
// ##Usage
// 
// The usage is really simple. Minimal index.php file (an entry point and setup) look like this:
// 
// Firstly you need to include framework file and get one instance.
// 
//     <?php
//     require "brickyard.php";
//     $f=new brickyard();
// 
// Init function enables autoloading and exception handling.
// 
//     $f->init();
// 
// Finally run function will call router and start right controller and method.
// 
//     $f->run();
//

// ##How it works?
// 
// Here follows brickyard core explained.
class brickyard
{
	public $inDevelMode = false;
	public $router = null;
	public $view = null;
	public $logger = null;
	public $libPath = '.';

Added sourceMakeup/README.md.







































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# sourceMakeup

sourceMakeup is a source code viewer written in PHP on the backend, and jQuery and jKit
on the frontend. sourceMakeup was heavely inspired by the first versions of 
[Docco](http://jashkenas.github.com/docco/), with some additional features that enhance
the frontend visually and feature wise. It was mainly developed as a source code viewer
for the jQuery based UI toolkit [jKit](http://jquery-jkit.com/). It's main use is to
create beautiful source documentation for JavaScript libraries and plugins, but it can
be used to document small PHP code and CSS markup as well, however, with some limitations. 

/Comments for sourceMakeup should be written in Markdown. This way sourceMakeup can correctly
and beautifully format the code and add a navigation menu linked to the different parts of your code.

- Version: `0.5`
- Release date: `14. 3. 2013`
- [Documentation & Demos](http://jquery-jkit.com/sourcemakeup/)
- [Download](https://github.com/FrediBach/sourceMakeup/archive/master.zip)

## Copyright

- (c) 2013 by *Fredi Bach*
- [Home](http://fredibach.ch/)

## License

sourceMakeup is open source and MIT licensed. For more informations read the **license.txt** file 

## Settings

- **$dir** contains the path to the documented files
- **$file** is the main file
- **$files** contains all the files, leave it empty if you don't want to restrict the list to certain files
- **$extensions** contains a comma separated list of allowed file extensions
- **$filter** filters out any files that contain a certain string
- **$dev** mode ignores the cache file and always generates a new one

Added sourceMakeup/cache/5b93faddf437ec95745edc897fea871b.txt.



























































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<tr class="docu"><td class="comment">
</td><td class="code"><pre class="linenumbers">1
2</pre><pre class="prettyprint">&lt;?php 
error_reporting(E_ALL ^ E_NOTICE);</pre></td></tr><tr class="docu"><td class="comment"><h1 id="sourcemakeup">sourceMakeup</h1>

<p>sourceMakeup is a source code viewer written in PHP on the backend, and jQuery and jKit
on the frontend. sourceMakeup was heavely inspired by the first versions of
<a href="http://jashkenas.github.com/docco/">Docco</a>, with some additional features that enhance
the frontend visually and feature wise. It was mainly developed as a source code viewer
for the jQuery based UI toolkit <a href="http://jquery-jkit.com/">jKit</a>. It's main use is to
create beautiful source documentation for JavaScript libraries and plugins, but it can
be used to document small PHP code and CSS markup as well, however, with some limitations.</p>

<p>Comments for sourceMakeup should be written in Markdown. This way sourceMakeup can correctly
and beautifully format the code and add a navigation menu linked to the different parts of your code.</p>

<ul>
<li>Version: <code>0.7</code></li>
<li>Release date: <code>19. 3. 2013</code></li>
<li><a href="http://jquery-jkit.com/sourcemakeup/">Documentation &amp; Demos</a></li>
<li><a href="https://github.com/FrediBach/sourceMakeup/archive/master.zip">Download</a></li>
</ul>

<h2 id="copyright">Copyright</h2>

<ul>
<li>(c) 2013 by <em>Fredi Bach</em></li>
<li><a href="http://fredibach.ch/">Home</a></li>
</ul>

<h2 id="license">License</h2>

<p>sourceMakeup is open source and MIT licensed. For more informations read the <strong>license.txt</strong> file</p>
</td><td class="code"><pre class="linenumbers"></pre><pre class="prettyprint"></pre></td></tr><tr class="docu"><td class="comment"><h2 id="settings">Settings</h2>
</td><td class="code"><pre class="linenumbers"></pre><pre class="prettyprint"></pre></td></tr><tr class="docu"><td class="comment"><ul>
<li><strong>$dir</strong> contains the path to the documented files</li>
<li><strong>$file</strong> is the main file</li>
<li><strong>$files</strong> contains all the files, leave it empty if you don't want to restrict the list to certain files</li>
<li><strong>$extensions</strong> contains a comma separated list of allowed file extensions</li>
<li><strong>$filter</strong> filters out any files that contain a certain string</li>
<li><strong>$dev</strong> mode ignores the cache file and always generates a new one</li>
</ul>
</td><td class="code"><pre class="linenumbers">39
40
41
42
43
44
45
46
47
48
49
50</pre><pre class="prettyprint">    $dir = './';
    $file = 'sourcemakeup.php';
    $files = array(
                '../brickyard.php',
                'sourcemakeup.php',
                'js/jquery.jkit.1.1.29.js',
                'js/sourcemakeup.js',
                'css/sourcemakeup.css'
    );
    $extensions = 'js,php,css';
    $filter = '.min.js';
    $dev = true;</pre></td></tr><tr class="docu"><td class="comment"><h2 id="the-source">The Source</h2>
</td><td class="code"><pre class="linenumbers"></pre><pre class="prettyprint"></pre></td></tr><tr class="docu"><td class="comment"><p>Is the main file the one from the settings or another one?</p>
</td><td class="code"><pre class="linenumbers">56
57
58</pre><pre class="prettyprint">    if (isset($_GET['file']) &amp;&amp; $_GET['file'] != ''){
        $file = $_GET['file'];
    }</pre></td></tr><tr class="docu"><td class="comment"><p>Define the path for our cached file:</p>
</td><td class="code"><pre class="linenumbers">62</pre><pre class="prettyprint">    $cachefile = 'cache/'.md5($file).'.txt';</pre></td></tr><tr class="docu"><td class="comment"><p>Create a list of all files we want to document. In case <strong>$files</strong> is not empty, those files will be used and
the following code block will be ignored.</p>
</td><td class="code"><pre class="linenumbers">67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83</pre><pre class="prettyprint">    if (count($files) == 0){
        if ($dir != ''){
            $tempfiles = scandir($dir);
            $files = array();
            foreach($tempfiles as $f){
                if ($f != '.' &amp;&amp; $f != '..' &amp;&amp; stripos($f, $filter) === false){
                    $allowed = explode(',', $extensions);
                    $ext = pathinfo($f, PATHINFO_EXTENSION);
                    if (in_array($ext, $allowed)) {
                        $files[] = $f;
                    }
                }
            }
        } else {
            $files = array($file);
        }
    }</pre></td></tr><tr class="docu"><td class="comment"><p>Do we have to load the cahed file or create a new one?</p>
</td><td class="code"><pre class="linenumbers">87</pre><pre class="prettyprint">    if (file_exists($cachefile) &amp;&amp; !$dev){</pre></td></tr><tr class="docu"><td class="comment"><p>Load the cached file:</p>
</td><td class="code"><pre class="linenumbers">91
92
93</pre><pre class="prettyprint">        $output = file_get_contents($cachefile);
    
    } else {</pre></td></tr><tr class="docu"><td class="comment"><p>Ok, so we need to create new output. To do that we first need to include the Markdown class:</p>
</td><td class="code"><pre class="linenumbers">97</pre><pre class="prettyprint">        include_once &quot;libs/markdown/markdown.php&quot;;</pre></td></tr><tr class="docu"><td class="comment"><p>Load the file and create an array of all lines:</p>
</td><td class="code"><pre class="linenumbers">101
102</pre><pre class="prettyprint">        $data = file_get_contents($file);
        $lines = explode(&quot;\n&quot;, $data);</pre></td></tr><tr class="docu"><td class="comment"><p>Create some variables we need later:</p>
</td><td class="code"><pre class="linenumbers">106
107
108
109</pre><pre class="prettyprint">        $blocks = array();
        $iscomment = false;
        $currentblock = 0;
        $linenumber = 0;</pre></td></tr><tr class="docu"><td class="comment"><p>Step through all lines and combine them into codeblocks. Each codeblock can have following contents:</p>

<ul>
<li><strong>comment</strong> contains all comments of this codeblock</li>
<li><strong>code</strong> contains all code of this block</li>
<li><strong>lnr</strong> contains the original linenumbers for the above code</li>
</ul>
</td><td class="code"><pre class="linenumbers">117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138</pre><pre class="prettyprint">        foreach($lines as $line){
        
            $linenumber++;
        
            if (substr(trim($line),0,2) == '//'){
                if (!$iscomment){
                    $currentblock++;
                }
                $blocks[$currentblock]['comment'] .= &quot;\n&quot;.substr(trim($line),3);
                $blocks[$currentblock]['code'] .= &quot;&quot;;
                $iscomment = true;
                if (substr(trim(substr(trim($line),3)),0,3) == '{!}'){
                    $currentblock++;
                }
            } else {
                $blocks[$currentblock]['code'] .= &quot;\n&quot;.str_replace(&quot;\t&quot;, &quot;    &quot;, $line);
                $blocks[$currentblock]['lnr'] .= &quot;\n&quot;.$linenumber;
                $blocks[$currentblock]['comment'] .= &quot;&quot;;
                $iscomment = false;
            }
    
        }</pre></td></tr><tr class="docu"><td class="comment"><p>If this is a PHP script with <strong>&lt;?php</strong> on the first line, we're going to remove it as it's only ruining our design:</p>
</td><td class="code"><pre class="linenumbers">142
143
144</pre><pre class="prettyprint">        if (trim($blocks[0]['code']) == '&lt;?php'){
            $blocks[0]['code'] = '';
        }</pre></td></tr><tr class="docu"><td class="comment"><p>We have now all we need to construct the table tbody content that contains all of our code. The table
has two columns, the first contains all the comments and the second one contains all the code.</p>
</td><td class="code"><pre class="linenumbers">149</pre><pre class="prettyprint">        $output = '';</pre></td></tr><tr class="docu"><td class="comment"><p>Loop through all blocks and construct the rows of our table:</p>
</td><td class="code"><pre class="linenumbers">153</pre><pre class="prettyprint">        foreach($blocks as $block){</pre></td></tr><tr class="docu"><td class="comment"><p>Each block is a row with a comment and a code column. Sometimes only one of them actually has content and
if both have no content, simply skip this block.</p>
</td><td class="code"><pre class="linenumbers">158
159
160
161
162</pre><pre class="prettyprint">            if (trim($block['comment']) != '' || trim($block['code']) != ''){
                
                $output .= '&lt;tr class=&quot;docu&quot;&gt;';
                
                if (substr(trim($block['comment']),0,3) == '{!}'){</pre></td></tr><tr class="docu"><td class="comment"><p>This block is an instruction block. Instruction blocks can be created like this:</p>

<pre><code>{!} instructiontype: instruction
</code></pre>
</td><td class="code"><pre class="linenumbers"></pre><pre class="prettyprint"></pre></td></tr><tr class="docu"><td class="comment"><p>Instructions are normally hidden, but can be made visible. They are ment to contain special
instructions either for a script or for code contributors. If you use them, make sure to supply the
icons for each of your instruction type. They have to ba named like this:</p>

<pre><code>sourcemakeup.instructiontype.png
</code></pre>
</td><td class="code"><pre class="linenumbers">175
176
177
178
179
180
181
182
183
184</pre><pre class="prettyprint">                    $split = explode(':', substr(trim($block['comment']),3));
                    
                    $block['comment'] = '&lt;span class=&quot;itype&quot;&gt;';
                    $block['comment'] .= '&lt;img src=&quot;imgs/sourcemakeup.'.trim($split[0]).'.png&quot;&gt; '.$split[0].'&lt;/span&gt;';
                    $block['comment'] .= ':&lt;span class=&quot;iopt&quot;&gt;'.$split[1].'&lt;/span&gt;';
                    
                    $output .= '&lt;td class=&quot;comment instruction&quot;&gt;&amp;nbsp;&lt;/td&gt;';
                    $output .= '&lt;td class=&quot;code instruction&quot;&gt;'.$block['comment'].'&lt;/td&gt;';
                    
                } else {</pre></td></tr><tr class="docu"><td class="comment"><p>This is a regular codeblock. As we don't want to display any uneeded linebreaks, we
use a special funtion to strip them away. The function returns an array that not only
contains the stripped code, it tells us exactly how many lines where removed from the
beginning and from the end. This way we can strip exactly the same number of lines from
the linenumber string.</p>
</td><td class="code"><pre class="linenumbers">192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208</pre><pre class="prettyprint">                    $codedata = trimLinebreaks($block['code']);
                
                    $templines = explode(&quot;\n&quot;, $block['lnr']);
                
                    if ($codedata['shifted'] &gt; 0){
                        for ($i=1; $i&lt;=$codedata['shifted']; $i++){
                            array_shift($templines);
                        }
                    }
                
                    if ($codedata['popped'] &gt; 0){
                        for ($i=1; $i&lt;=$codedata['popped']; $i++){
                            array_pop($templines);
                        }
                    }
                
                    $lnr = implode(&quot;\n&quot;, $templines);</pre></td></tr><tr class="docu"><td class="comment"><p>For the comment column, we basically do two things. We parse the Markdown formatting into nice HTML
with the Markdown library, and we than add ids to all HTML headers so that we can create an anchor navigation.</p>
</td><td class="code"><pre class="linenumbers">213</pre><pre class="prettyprint">                    $output .= '&lt;td class=&quot;comment&quot;&gt;'.addHeaderAnchors(Markdown(trim($block['comment']))).'&lt;/td&gt;';</pre></td></tr><tr class="docu"><td class="comment"><p>All we need to do for the code is escape the HTML special chars. The formatting is done by the Google Code Prettifier JavaScript.</p>
</td><td class="code"><pre class="linenumbers">217
218
219
220
221
222
223
224</pre><pre class="prettyprint">                    $output .= '&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;linenumbers&quot;&gt;'.$lnr.'&lt;/pre&gt;';
                    $output .= '&lt;pre class=&quot;prettyprint&quot;&gt;'.htmlspecialchars($codedata['code']).'&lt;/pre&gt;&lt;/td&gt;';
                }
                
                $output .= '&lt;/tr&gt;';
                
            }
        }</pre></td></tr><tr class="docu"><td class="comment"><p>Now as we created our output, we save it in a cache for later use:</p>
</td><td class="code"><pre class="linenumbers">228
229
230
231
232</pre><pre class="prettyprint">        $fh = fopen($cachefile, 'w') or die(&quot;can't open file&quot;);
        fwrite($fh, $output);
        fclose($fh);
    
    }</pre></td></tr><tr class="docu"><td class="comment"><p>And lastly, we inlude the template to generate our output:</p>
</td><td class="code"><pre class="linenumbers">236</pre><pre class="prettyprint">    include 'sourcemakeup.template.php';</pre></td></tr><tr class="docu"><td class="comment"><h2 id="functions">Functions</h2>
</td><td class="code"><pre class="linenumbers"></pre><pre class="prettyprint"></pre></td></tr><tr class="docu"><td class="comment"><p>The <strong>addHeaderAnchors</strong> function and the regex callback function <strong>addHeaderAnchorsCallback</strong>
add ids to each header in the supplied HTML based on the title of the header.</p>
</td><td class="code"><pre class="linenumbers">244
245
246
247
248
249
250</pre><pre class="prettyprint">    function addHeaderAnchors($text){
        return preg_replace_callback('/\&lt;h([0-6]{1})\&gt;(.+)\&lt;\/h[0-6]{1}\&gt;/', 'addHeaderAnchorsCallback', $text);
    }
    
    function addHeaderAnchorsCallback($matches){
        return '&lt;h'.$matches[1].' id=&quot;'.createURLSlug($matches[2]).'&quot;&gt;'.$matches[2].'&lt;/h'.$matches[1].'&gt;';
    }</pre></td></tr><tr class="docu"><td class="comment"><p>The <strong>createURLSlug</strong> function makes a nice url slug where all special characters are removed and spaces replaced with
the "-" character.</p>
</td><td class="code"><pre class="linenumbers">255
256
257
258
259
260
261
262
263
264
265
266</pre><pre class="prettyprint">    function createURLSlug($str, $replace=array(), $delimiter='-'){
        if( !empty($replace) ) {
            $str = str_replace((array)$replace, ' ', $str);
        }

        $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
        $clean = preg_replace(&quot;/[^a-zA-Z0-9\/_|+ -]/&quot;, '', $clean);
        $clean = strtolower(trim($clean, '-'));
        $clean = preg_replace(&quot;/[\/_|+ -]+/&quot;, $delimiter, $clean);

        return $clean;
    }</pre></td></tr><tr class="docu"><td class="comment"><p>The <strong>trimLinebreaks</strong> function removes all unneaded linebreaks before an after a string and tells
us in the return array exactly how many of them.</p>
</td><td class="code"><pre class="linenumbers">271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292</pre><pre class="prettyprint">    function trimLinebreaks($string){
    
        $lines = explode(&quot;\n&quot;, $string);
    
        $shifted = 0;
        $popped = 0;
    
        while(trim($lines[0]) == '' &amp;&amp; count($lines) &gt; 0){
            array_shift($lines);
            $shifted++;
        }
    
        while( trim( $lines[count($lines)-1] ) == '' &amp;&amp; count($lines) &gt; 0){
            array_pop($lines);
            $popped++;
        }
    
        $arr = array('code' =&gt; implode(&quot;\n&quot;, $lines), 'shifted' =&gt; $shifted, 'popped' =&gt; $popped);
    
        return $arr;
    
    }</pre></td></tr>

Added sourceMakeup/cache/c0eb62efca758267c66fe3944eb1e1e3.txt.

























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
<tr class="docu"><td class="comment"><h1 id="brickyard-framework">Brickyard framework</h1>

<p>Because reinventing the wheel is fun.</p>

<p>It aims to be simpler and smaller than others. Not suitable for enterprise.</p>

<p>Note that source of this documentation is source of framework itself.</p>

<h2 id="usage">Usage</h2>

<p>The usage is really simple. Minimal index.php file (an entry point and setup) look like this:</p>

<p>Firstly you need to include framework file and get one instance.</p>

<pre><code>&lt;?php
require "brickyard.php";
$f=new brickyard();
</code></pre>

<p>Init function enables autoloading and exception handling.</p>

<pre><code>$f-&gt;init();
</code></pre>

<p>Finally run function will call router and start right controller and method.</p>

<pre><code>$f-&gt;run();
</code></pre>
</td><td class="code"><pre class="linenumbers"></pre><pre class="prettyprint"></pre></td></tr><tr class="docu"><td class="comment"><h2 id="how-it-works">How it works?</h2>

<p>Here follows brickyard core explained.</p>
</td><td class="code"><pre class="linenumbers">33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407</pre><pre class="prettyprint">class brickyard
{
    public $inDevelMode = false;
    public $router = null;
    public $view = null;
    public $logger = null;
    public $libPath = '.';
    public $indexPath = '.';
    public function __construct(){
        $this-&gt;router = new brickyard_router_default;
        $this-&gt;logger = new brickyard_logger_null;
        $this-&gt;libPath = dirname(__FILE__);
        $this-&gt;view = new brickyard_view_default(dirname(__FILE__) . DIRECTORY_SEPARATOR . &quot;tpl&quot;);
    }
    
    public function getRouter()
    {
        return $this-&gt;router;
    }
    public function getView()
    {
        return $this-&gt;view;
    }
    public function getLogger()
    {
        return $this-&gt;logger;
    }
    public function getIndexPath()
    {
        return $this-&gt;indexPath;
    }
    
    public function setRouter(brickyard_router_interface $router)
    {
        $this-&gt;router = $router;
    }
    public function setView(brickyard_view_interface $view)
    {
        $this-&gt;view = $view;
    }
    public function setLogger(brickyard_logger_interface $logger)
    {
        $this-&gt;logger = $logger;
    }
    public function setIndexPath($indexFilePath)
    {
        $this-&gt;indexPath = dirname($indexFilePath);
    }
    
    
    public function autoload($className){
        $filename=$this-&gt;libPath . DIRECTORY_SEPARATOR;
        $filename.=str_replace(&quot;_&quot;, DIRECTORY_SEPARATOR, $className);
        $filename.=&quot;.php&quot;;
        if (file_exists($filename)){
            require $filename;
            if (!class_exists($className, false)){
                throw new brickyard_exception_autoload('Class ' . $className . ' expected to be in ' . $filename . '!');
            }
        } else {
            throw new brickyard_exception_autoload('Class ' . $className . ' not found! Tried to find it in ' . $filename . '.');
        }
        
    }
    
    function error_handler($errno, $errstr, $errfile, $errline )
    {
        throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
        
    }
    
    public function exception_handler($e)
    {
        if ($this-&gt;inDevelMode){
            $this-&gt;bluescreen($e);
        } else {
            $this-&gt;logger-&gt;logException($e);
            
            if ($e instanceof brickyard_exception_404){
                $err = 404;
            } elseif ($e instanceof brickyard_exception_403){
                $err = 403;
            } else {
                $err = 'error';
            }    
            
            if (file_exists($this-&gt;libPath . DIRECTORY_SEPARATOR . $err . '.html')){
                ob_clean();
                echo file_get_contents($this-&gt;libPath . DIRECTORY_SEPARATOR . $err . '.html');
                exit; //to prevent more errors
            }else{
                echo &quot;An error occured. Also error page is missing.&quot;;
            }
            
        }
        
    }
    
    public function shutdown_handler()
    {
        $error = error_get_last();
        if ($error['type'] &amp; (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE)) {
            $fatal = new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
            $this-&gt;exception_handler($fatal);
        }
        
    }
    
    public function bluescreen($e)
    {
        ob_clean();
        $out=&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;error&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;:-(&lt;/h1&gt;&quot;;
        $out.=&quot;&lt;div&gt;at &quot; . $e-&gt;getFile() . ':' . $e-&gt;getLine() . &quot;&lt;/div&gt;&quot;;
        $out.=&quot;&lt;div&gt;&quot; . nl2br( $e-&gt;getMessage() ) . &quot;&lt;/div&gt;&quot;;
        $out.=&quot;&lt;pre&gt;&quot; . $e-&gt;getTraceAsString() . &quot;&lt;/pre&gt;&quot;;
        $out.=&quot;&lt;/body&gt;&lt;/html&gt;&quot;;
        echo $out;
        exit;
        
    }
    
    public function init(){
        spl_autoload_register(array($this,&quot;autoload&quot;));
        set_error_handler(array($this,&quot;error_handler&quot;));
        register_shutdown_function(array($this, &quot;shutdown_handler&quot;));
        set_exception_handler(array($this,&quot;exception_handler&quot;));
        
    }
    
    public function run(){
        ob_start();
        $controllerName = &quot;c_&quot; . $this-&gt;router-&gt;getController();
        $methodName = $this-&gt;router-&gt;getMethod();
        $args = $this-&gt;router-&gt;getArgs();
        try {
            $controllerInstance = new $controllerName;
        } catch(brickyard_exception_autoload $e) {
            throw new brickyard_exception_404($e-&gt;getMessage() );
        }
        $controllerInstance-&gt;framework=$this;
        $call=array($controllerInstance, $methodName);
        if (is_callable($call)){
            call_user_func_array($call,$args);
        }else{
            throw new brickyard_exception_404('Method ' . $methodName . ' is invalid!');
        }
        
    }
}

class brickyard_exception_autoload extends Exception{}

class brickyard_exception_404 extends Exception{}

class brickyard_exception_403 extends Exception{}

interface brickyard_router_interface

{

    public function getController();

    public function getMethod();

    public function getArgs();

    public function getLink($controller = null, $method = null, $args=array() );

    

}

class brickyard_router_default implements brickyard_router_interface

{

    public $controller = &quot;home&quot;;

    public $method = &quot;index&quot;;

    public $args = array();

    

    function analyze()

    {

        $path=( isset($_SERVER[&quot;PATH_INFO&quot;]) ? explode(&quot;/&quot;,$_SERVER[&quot;PATH_INFO&quot;]) : array() );

        if (count($path)&gt;1 and $path[1]!=''){$this-&gt;controller=$path[1];}

        if (count($path)&gt;2  and $path[2]!=''){$this-&gt;method=$path[2];}

        if (count($path)&gt;3){$this-&gt;args=array_slice($path,3);}

    }

    

    public function getController()

    {

        $this-&gt;analyze();

        return $this-&gt;controller;

    }

    

    public function getMethod()

    {

        $this-&gt;analyze();

        return $this-&gt;method;

    }

    

    public function getArgs()

    {

        $this-&gt;analyze();

        return $this-&gt;args;

    }

    

    public function getLink($controller = null, $method = null, $args=array() )

    {

        $url = $_SERVER[&quot;SCRIPT_NAME&quot;];

        if ($controller){

            $url .= '/' . $controller;

            if ($method){

                $url .= '/' . $method;

                if (count($args)&gt;0){

                    $url .= '/' . implode('/', $args);

                }

            }

        }

        return $url;

    }

}

interface brickyard_view_interface

{

    public function show($templateName, array $data);

}

class brickyard_view_default implements brickyard_view_interface

{

    private $tplPath=&quot;tpl&quot;;

    

    function __construct($tplPath)

    {

        $this-&gt;tplPath = $tplPath;

    }

    

    public function show($tplName, array $data)

    {

        $tplFile = $this-&gt;tplPath . DIRECTORY_SEPARATOR . $tplName . &quot;.php&quot;;

        if (file_exists($tplFile)) {

            $data['view'] = $this;

            extract($data, EXTR_SKIP);

            ob_start();

            include $tplFile;

            $output = ob_get_contents();

            ob_end_clean();

            return $output;

        } else {

            throw new Exception('Template '.$tplName.' not found in file '.$tplFile);

        }

    }

}

interface brickyard_logger_interface

{

    public function logException(Exception $e);

}

class brickyard_logger_null implements brickyard_logger_interface

{

    function logException(Exception $e) {}

}

class brickyard_logger_file implements brickyard_logger_interface

{

    private $logFileName=&quot;log.txt&quot;;



    function __construct($logFileName)

    {

        $this-&gt;logFileName = $logFileName;

    }

    

    function logException(Exception $e)

    {

        $logged = '== ' . date('Y-m-d H:i:s') . PHP_EOL .

        $e-&gt;getMessage() . PHP_EOL .

        $e-&gt;getFile() . ':' . $e-&gt;getLine() . PHP_EOL .

        $e-&gt;getTraceAsString() . PHP_EOL;

        file_put_contents($this-&gt;logFileName, $logged, FILE_APPEND);

    }

}</pre></td></tr>

Added sourceMakeup/css/sourcemakeup.css.















































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
body {
	color:#252519;
	font-family:'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
	font-size:15px;
	line-height:22px;
	margin: 0px;
	padding: 0px;
}
a {
  color: #65bae2;
}
  a:visited {
    color: #459ad2;
  }
p {
  margin: 0 0 15px 0;
}
blockquote {
	color: #9bb15c;
	font-size: 14px;
}
h1, h2, h3, h4, h5, h6 {
  margin: 0px 0 15px 0;
}
h4 {
	color: #333;
	font-size: 1.15em;
}
h5 {
	color: #555;
	font-size: 1.13em;
}
h6 {
	color: #777;
	font-size: 1.11em;
}
h1 {
	margin-top: 10px;
	color: #c8285b;
}
hr {
    border: 0 none;
    border-top: 1px solid #e5e5ee;
    height: 1px;
    margin: 20px 0;
}
#options {
	position: fixed;
	right: 9px;
	top: 7px;
	border-top: 0px;
	padding: 2px;
	padding-bottom: 4px;
	padding-left: 5px;
	padding-right: 5px;
	height: 26px;
	background: #f9fbfb;
	color: #65bae2;
	border-radius: 3px;
	border: 1px #bbd17c solid;
}
#overview {
	position: fixed;
	right: 159px;
	top: 0px;
	border-top: 0px;
	padding: 7px; 
}
#overview select {
	background: #f9fbfb;
	color: #65bae2;
	padding: 5px;
	padding-left: 12px;
	height: 34px;
	font-size: 13px;
	line-height: 140%;
	border-radius: 3px;
	border: 1px #bbd17c solid;
	-webkit-appearance: none;
}
#search {
	position: fixed;
	right: 37px;
	top: 0px;
	border-top: 0px;
	padding: 7px; 
}
#search input {
	background: #f9fbfb;
	color: #65bae2;
	padding: 5px;
	padding-left: 12px;
	height: 22px;
	font-size: 13px;
	line-height: 140%;
	border-radius: 3px;
	border: 1px #bbd17c solid;
	width: 100px;
}
#spinner {
	position: fixed;
	left: 555px;
	top: 12px;
	width: 28px;
	height: 28px;
	z-index: 100;
	display: none;
}
table.container {
	width: 100%;
}
table.container td.comment, table.container th.comment {
	background-color:#f9fbfb;
	max-width:425px;
	min-height:5px;
	min-width:425px;
	overflow-x:hidden;
	padding:14px 25px 1px 25px;
	text-align:left;
	vertical-align:top;
	border-bottom: 1px #ededed dotted;
}
table.container td.code, table.container th.code {
	background-color:#fff;
	border-left-color:#eee;
	border-left-style:solid;
	border-left-width:1px;
	padding: 16px 15px 16px 18px;
	vertical-align:top;
	width:100%;
	border-bottom: 1px #efefef dotted;
}
table.container th.comment {
	text-transform: uppercase;
	padding:14px 28px 12px 25px;
	color: #999;
	border-bottom: 1px #e8e8e8 solid;
	font-weight: normal;
	font-size: 11px;
	text-align: right;
}
#files {
	position: absolute;
	top: 16px;
	left: 23px;
	background: transparent;
	color: #999;
	font-size: 11px;
	border: none;
	-webkit-appearance: none;
}
table.container th.code {
	text-transform: uppercase;
	padding:14px 14px 12px 25px;
	text-align:left;
	vertical-align:baseline;
	color: #999;
	border-bottom: 1px #eee solid;
	font-size: 11px;
	font-weight: normal;
}
table.container td.instruction {
	font-family: Arial, Helvetica, sans;
	color: #bbb;
	font-size: 9px;
	text-transform: uppercase;
	letter-spacing: 2px;
	padding: 0px;
	padding-top: 1px;
	padding-left: 10px;
	border-bottom: 1px #f2f2f2 solid;
}
table.container td.instruction.code {
	background: #f9fbfb;
}
table.container td.instruction.code img {
	vertical-align: -20%;
}
span.itype {
	color: #9E6464;
}
span.iopt {
	color: #64889E;
}
pre, tt, code {
	font-family:Menlo, Monaco, Consolas, 'Lucida Console', monospace;
	font-size:12px;
	line-height:18px;
	margin:0;
	padding:0;
}
pre.linenumbers {
	float: left;
	width: 40px;
	color: #ddd;
	margin-left: 0px;
}

table.container td.comment pre {
	padding-top: 4px;
	padding-bottom: 20px;
	color: #E01B6A;
}

/* Hemisu Light */
/* Original theme - http://noahfrederick.com/vim-color-scheme-hemisu/ */
/* Pretty printing styles. Used with prettify.js. */
/* SPAN elements with the classes below are added by prettyprint. */
/* plain text */
.pln {
  color: #111111;
}

@media screen {
  /* string content */
  .str {
    color: #739200;
  }

  /* a keyword */
  .kwd {
    color: #739200;
  }

  /* a comment */
  .com {
    color: #999999;
  }

  /* a type name */
  .typ {
    color: #ff0055;
  }

  /* a literal value */
  .lit {
    color: #538192;
  }

  /* punctuation */
  .pun {
    color: #111111;
  }

  /* lisp open bracket */
  .opn {
    color: #111111;
  }

  /* lisp close bracket */
  .clo {
    color: #111111;
  }

  /* a markup tag name */
  .tag {
    color: #111111;
  }

  /* a markup attribute name */
  .atn {
    color: #739200;
  }

  /* a markup attribute value */
  .atv {
    color: #ff0055;
  }

  /* a declaration */
  .dec {
    color: #111111;
  }

  /* a variable name */
  .var {
    color: #111111;
  }

  /* a function name */
  .fun {
    color: #538192;
  }
}
/* Use higher contrast and text-weight for printable form. */
@media print, projection {
  .str {
    color: #006600;
  }

  .kwd {
    color: #006;
    font-weight: bold;
  }

  .com {
    color: #600;
    font-style: italic;
  }

  .typ {
    color: #404;
    font-weight: bold;
  }

  .lit {
    color: #004444;
  }

  .pun, .opn, .clo {
    color: #444400;
  }

  .tag {
    color: #006;
    font-weight: bold;
  }

  .atn {
    color: #440044;
  }

  .atv {
    color: #006600;
  }
}
/* Style */
pre.prettyprint {
  font-family: Menlo, "Bitstream Vera Sans Mono", "DejaVu Sans Mono", Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
  margin-top: 0;
  margin-bottom: 0;
}

/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
  /* */
}

/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
  /* */
}





div#jkit-tooltip {
	padding: 3px;
	padding-left: 7px;
	padding-right: 7px;
	position: fixed;
	font-family: Arial, Helvetica, sans;
	font-size: 12px;
}

.mytooltip {
	background: #333;
	color: #fff;
	padding: 6px;
	padding-bottom: 5px;
	
	opacity: 0.9;
	
	border: 1px #E01B49 solid;
	-moz-border-radius: 3px;
	border-radius: 3px;
	
	-webkit-box-shadow:0 0 5px #aaa; 
	-moz-box-shadow: 0 0 5px #aaa; 
	box-shadow:0 0 5px #aaa;
}

Added sourceMakeup/imgs/sourcemakeup.codeblock.png.

cannot compute difference between binary files

Added sourceMakeup/imgs/sourcemakeup.task.png.

cannot compute difference between binary files

Added sourceMakeup/imgs/spinner.gif.

cannot compute difference between binary files

Added sourceMakeup/index.php.



>
1
<?php include 'sourcemakeup.php';

Added sourceMakeup/js/jquery-1.9.1.min.js.

cannot compute difference between binary files

Added sourceMakeup/js/jquery.easing.1.3.js.



























































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

Added sourceMakeup/js/jquery.jkit.1.1.29.js.



























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
//
// # jQuery Plugin: jKit
//
// > A very easy to use, cross platform jQuery UI toolkit that's still small in size, has the 
// > features you need and doesn't get in your way.
//
// Put jQuery and jKit on all your pages and HTML becomes so much better. And the best thing?
// You really don't have to be a programmer to create a trully amazing website!
//
// jKit has 99% of all the features you ever need. You don't have to check out dozens of plugins,
// learn how to use them, only to find out they don't work in a specific browser.
//
// And even if jKit doesn't have that one feature you need right now, jKit is fully extendable
// with plugins and command replacements, all that and your API always stays the same.
//
// - Version: `1.1.29`
// - Release date: `19. 3. 2013`
// - [API Documentation & Demos](http://jquery-jkit.com/)
// - [Source Documentation](http://jquery-jkit.com/sourcemakeup/?file=js/jquery.jkit.1.1.28.js) (made 
//	 with [sourceMakeup](http://jquery-jkit.com/sourcemakeup))
// - [Download](https://github.com/FrediBach/jQuery-jKit/archive/master.zip)
//
// ## Copyright
//
// - (c) 2012/2013 by *Fredi Bach*
// - [Home](http://fredibach.ch/)
//
// ## License
//
// jKit is open source and MIT licensed. For more informations read the **license.txt** file
//
// ## Basic Usage
//
// Inside your head tag or at the bottom of your page before the closing body tag:
//
//     <script src="js/jquery-1.9.1.min.js"></script>
//     <script src="js/jquery.easing.1.3.js"></script>
//     <script src="js/jquery.jkit.1.1.29.min.js"></script>
//
//     <script type="text/javascript">
//         $(document).ready(function(){
//         	$('body').jKit();
//         });
//     </script>
//
// On your HTML elements:
//
//     <p data-jkit="[hide:delay=2000;speed=500]">
//         Hidden after two seconds
//     </p>
//
//
// ## The Source

// Create our plugins local scope, make sure **$** is mapped to jQuery and guarantee that **undefined** really is **undefined**.

(function($, undefined) {
	
	// Create our main function with the following parameters:
	//
	// - **element** contains the DOM element where jKit is applied to
	// - **options** is either a string with a single command name or a JavaScript object with all options or undefined
	// - **moreoptions** is optionally used in case options contains the a command string and contains the options object
	
	$.jKit = function(element, options, moreoptions) {
		
		// Define all plugin defaults. These can be overwritten by the plugins options set on init.
		
		var defaults = {
			
			// First we set some general defaults:
			
			prefix: 'jkit',
			dataAttribute: 'data-jkit',
			activeClass: 'active',
			errorClass: 'error',
			successClass: 'success',
			ignoreFocus: false,
			ignoreViewport: false,
			keyNavigation: true,
			touchNavigation: true,
			plugins: {},
			replacements: {},
			delimiter: ',',
			
			// {!} codeblock: macros
			
			// Now we set some default macros for often used command/parameter combinations:
			
			macros: {
				'hide-if-empty': 'binding:selector=this;source=text;mode=css.display',
				'smooth-blink': 'loop:speed1=2000;duration1=250;speed2=250;duration2=2000'
			},
			
			// {!} codeblock: /macros
			
			// Next we're defining all the default options for each command. You can get a good overview of them 
			// on the official [cheat sheet](http://jquery-jkit.com/pages/cheatsheet.php).
			
			commands: {
				
				// {!} codeblock: command.template
				
				'template': {
					'action': 			'set',
					'name':				'template',
					'dynamic': 			'no',
					'addhtml': 			'+'
				},
				
				// {!} codeblock: /command.template, command.lightbox
				
				'lightbox': {
					'speed': 			500,
					'opacity': 			0.7,
					'clearance': 		200,
					'closer': 			'x',
					'next': 			'>',
					'prev': 			'<',
					'modal': 			'no',
					'width': 			'',
					'height': 			'',
					'titleHeight': 		20,
					'group': 			''
				},
				
				// {!} codeblock: /command.lightbox, command.scroll
				
				'scroll': {
					'speed': 			500,
					'dynamic': 			'yes',
					'easing': 			'linear'
				},
				
				// {!} codeblock: /command.scroll, command.hide
				
				'hide': {
					'delay': 			0,
					'speed': 			500,
					'animation': 		'fade',
					'easing': 			'linear'
				},
				
				// {!} codeblock: /command.hide, command.remove
				
				'remove': {
					'delay':			0
				},
				
				// {!} codeblock: /command.remove, command.show
				
				'show': {
					'delay':			0,
					'speed':			500,
					'animation':		'fade',
					'easing':			'linear'
				},
				
				// {!} codeblock: /command.show, command.showandhide
				
				'showandhide': {
					'delay':			0,
					'speed':			500,
					'duration':			10000,
					'animation':		'fade',
					'easing':			'linear'
				},
				
				// {!} codeblock: /command.showandhide, command.loop
				
				'loop': {
					'speed1':			500,
					'speed2':			500,
					'duration1':		2000,
					'duration2':		2000,
					'easing1':			'linear',
					'easing2':			'linear',
					'animation':		'fade'
				},
				
				// {!} codeblock: /command.loop, command.random
				
				'random': {
					'count': 			1,
					'remove': 			'yes'
				},
				
				// {!} codeblock: /command.random, command.partially
				
				'partially': {
					'height':			200,
					'text':				'more ...',
					'speed':			250,
					'easing':			'linear',
					'on': 				'mouseover'
				},
				
				// {!} codeblock: /command.partially, command.slideshow
				
				'slideshow': {
					'shuffle':			'no',
					'interval':			3000,
					'speed':			250,
					'animation':		'fade',
					'easing':			'linear',
					'on': 				''
				},
				
				// {!} codeblock: /command.slideshow, command.animation
				
				'animation': {
					'fps':				25,
					'loop':				'no',
					'from': 			'',
					'to': 				'',
					'speed': 			'500',
					'easing': 			'linear',
					'delay':			0,
					'on': 				''
				},
				
				// {!} codeblock: /command.animation, command.gallery
				
				'gallery': {
					'active':			1,
					'event':			'click',
					'showcaptions':		'yes',
					'animation':		'none',
					'speed':			500,
					'easing':			'linear',
					'lightbox': 		'no'
				},
				
				// {!} codeblock: /command.gallery, command.tabs
				
				'tabs': {
					'active':			1,
					'animation':		'none',
					'speed':			250,
					'easing':			'linear'
				},
				
				// {!} codeblock: /command.tabs, command.accordion
				
				'accordion': {
					'active':			1,
					'animation':		'slide',
					'speed':			250,
					'easing':			'linear'
				},
				
				// {!} codeblock: /command.accordion, command.carousel
				
				'carousel': {
					'autoplay': 		"yes",
					'limit': 			5,
					'animation':		'grow',
					'speed':			250,
					'easing':			'linear',
					'interval':			5000,
					'prevhtml':			'&lt;',
					'nexthtml':			'&gt;'
				},
				
				// {!} codeblock: /command.carousel, command.parallax
				
				'parallax': {
					'strength':			5,
					'axis':				'x',
					'scope':			'global',
					'detect': 			'mousemove'
				},
				
				// {!} codeblock: /command.parallax, command.form
				
				'form': {
					'validateonly':		'no'
				},
				
				// {!} codeblock: /command.form, command.plugin
				
				'plugin': {
					'script': 			''
				},
				
				// {!} codeblock: /command.plugin, command.tooltip
				
				'tooltip': {
					'text':				'',
					'color':			'#fff',
					'background':		'#000',
					'classname':		''
				},
				
				// {!} codeblock: /command.tooltip, command.background
				
				'background': {
					'distort':			'no'
				},
				
				// {!} codeblock: /command.background, command.lorem
				
				'lorem': {
					'paragraphs':		0,
					'length':			'',
					'random':			'no'
				},
				
				// {!} codeblock: /command.lorem, command.binding
				
				'binding': {
					'selector':			'',
					'source':			'val',
					'variable':			'',
					'mode':				'text',
					'interval':			100,
					'math':				'',
					'condition': 		'',
					'if':				'',
					'else':				'',
					'speed':			0,
					'easing':			'linear',
					'search': 			'',
					'trigger': 			'no',
					'accuracy': 		'',
					'min': 				'',
					'max': 				'' 
				},
				
				// {!} codeblock: /command.binding, command.limit
				
				'limit': {
					'elements':			'children',
					'count':			5,
					'animation':		'none',
					'speed':			250,
					'easing':			'linear',
					'endstring':		'...'
				},
				
				// {!} codeblock: /command.limit, command.chart
				
				'chart': {
					'max':				0,
					'delaysteps':		100,
					'speed':			500,
					'easing':			'linear'
				},
				
				// {!} codeblock: /command.chart, command.encode
				
				'encode': {
					'format':			'code',
					'fix': 				'yes'
				},
				
				// {!} codeblock: /command.encode, command.split
				
				'split': {
					'separator': 		'',
					'container': 		'span',
					'before':			'',
					'after':			''
				},
				
				// {!} codeblock: /command.split, command.live
				
				'live': {
					'interval': 		60
				},
				
				// {!} codeblock: /command.live, command.key
				
				'key': {},
				
				// {!} codeblock: /command.key, command.ajax
				
				'ajax': {
					'animation':		'slide',
					'speed':			250,
					'easing':			'linear',
					'when': 			'click'
				},
				
				// {!} codeblock: /command.ajax, command.replace
				
				'replace': {
					'modifier': 		'g',
					'search': 			'',
					'replacement': 		''
				},
				
				// {!} codeblock: /command.replace, command.cycle
				
				'cycle': {
					'what': 			'class',
					'where': 			'li',
					'scope': 			'children',
					'sequence': 		'odd,even'
				},
				
				// {!} codeblock: /command.cycle, command.fontsize
				
				'fontsize': {
					'steps': 			2,
					'min': 				6,
					'max': 				72,
					'affected':			'p',
					'style': 			'font-size'
				},
				
				// {!} codeblock: /command.fontsize, command.swap
				
				'swap': {
					'versions': 		'_off,_on',
					'attribute': 		'src'
				},
				
				// {!} codeblock: /command.swap, command.ticker
				
				'ticker': {
					'speed': 			100,
					'delay': 			2000,
					'loop': 			'yes'
				},
				
				// {!} codeblock: /command.ticker, command.sort
				
				'sort': {
					'what': 			'text',
					'by': 				'',
					'start':			0,
					'end':				0
				},
				
				// {!} codeblock: /command.sort, command.zoom
				
				'zoom': {
					'scale': 			2,
					'speed': 			150,
					'lightbox':			'no'
				},
				
				// {!} codeblock: /command.zoom, command.api
				
				'api': {
					'format': 			'json',
					'value': 			'',
					'url': 				'',
					'interval': 		-1,
					'template': 		''
				},
				
				// {!} codeblock: /command.api, command.filter
				
				'filter': {
					'by': 				'class',
					'affected': 		'',
					'animation':		'slide',
					'speed':			250,
					'easing':			'linear',
					'logic': 			'and',
					'global': 			'no'
				},
				
				// {!} codeblock: /command.filter, command.summary
				
				'summary': {
					'what': 			'',
					'linked': 			'yes',
					'from': 			'',
					'scope': 			'children',
					'style': 			'ul',
					'indent': 			'no'
				},
				
				// {!} codeblock: /command.summary, command.paginate
				
				'paginate': {
					'limit': 			'25',
					'by': 				'node',
					'container': 		'',
					'animation':		'none',
					'speed':			250,
					'easing':			'linear',
					'pos': 				'after'
				},
				
				// {!} codeblock: /command.paginate, command.menu
				
				'menu': {
					'autoactive': 		'no'
				},
				
				// {!} codeblock: /command.menu
				
				// To make our code block funtionalllity not brake anything, we have to add an empty entry at the end:
				
				'':{}
				
			}
		};
		
		// Set an alias to **this** so that we can use it everywhere inside our plugin:
		
		var plugin = this;
		
		// Create an object for the plugin settings:
		
		plugin.settings = {};
		
		// And while were're at it, cache the DOM element:
		
		var $element = $(element),
			element = element;
		
		// In case we are just applying a single command, we need to take the options from the **moreoptions** parameter:
		
		if (typeof options == 'string'){
			var singlecommand = options;
			if (moreoptions == undefined){
				moreoptions = {};
			}
			options = moreoptions;
		}
		
		// For a few things, we need some local plugin variables and objects, let's set them now:
		
		var startX, startY;
		var windowhasfocus = true;
		var uid = 0;
		var lightboxes = {};
		var templates = {};
		var commandkeys = {};
		
		// We want to know if the current window is in focus or not, we can do this with the **window** object (just not in IE7 & 8):
		
		if ($.support.htmlSerialize || $.support.opacity){
			$(window).focus(function() {
				windowhasfocus = true;
			}).blur(function() {
				windowhasfocus = false;
			});
		}
		
		// ## Plugin Functions
		
		// The following collection of functions are internally used. There is a way to call them with an external script,
		// **but you should know what you're doing!** Here's an exmaple:
		//
		//     $('body').data('jKit').executeCommand('body', 'lightbox');
		//
		// The above code would call the **plugin.executeCommand()** function.
		
		// ### init
		//
		// The **init** function is called on plugin init and sets up all the stuff we need.
		
		plugin.init = function($el){
			
			// In case this function is called without a specific DOM node, use the plugins main DOM element:
			
			if ($el == undefined) $el = $element;
			
			// Extend the plugin defaults with the applied options:
			
			plugin.settings = $.extend({}, defaults, options);
			var s = plugin.settings;
			
			if (singlecommand != undefined){
				
				// If this is an initialization of a single command, all we have to do is execute that one command:
				
				plugin.executeCommand($el, singlecommand, options);
			
			} else {
				
				// It's now time to find all DOM nodes that want to execute a jKit command. You can either use the **data-jkit** attribute,
				// or the **rel** attribute. **However, we strongly recommend to use the data-jkit attribute!** The rel attribute support 
				// will probably removed at some point.
				
				$el.find("*[rel^=jKit], *["+s.dataAttribute+"]").each( function(){
					
					var that = this;
					
					// Get the rel or data-jkit attribute and extract all individual commands (they have to be inside square brackets):
					
					var rel = $(this).attr('rel');
					var data = $(this).attr(s.dataAttribute);
					
					if (data != undefined){
						rel = $.trim(data).substring(1);
					} else {
						rel = $.trim(rel).substring(5);
					}
					rel = rel.substring(0, rel.length-1);
					rel = rel.replace(/\]\s+\[/g, "][");
					relsplit = rel.split('][');
					
					// Now look at each command seperately:
					
					$.each( relsplit, function(index, value){
						
						// First convert all the escaped characters into internal jKit strings. Later we convert them back and unescape them.
						
						value = value
									.replace(/\\=/g,'|jkit-eq|')
									.replace(/\\:/g,'|jkit-dp|')
									.replace(/\\;/g,'|jkit-sc|')
									.replace(/\\\[/g,'|jkit-sbo|')
									.replace(/\\\]/g,'|jkit-sbc|')
									.replace(/\\\*/g,'|jkit-st|')
									.replace(/\\ /g,'|jkit-sp|');
						
						value = $.trim(value);
						
						// Is this a macro call? Let's check if we find a macro with this name:
						
						if (s.macros[value] != undefined) value = s.macros[value];
						
						// Now it's time to parse the options:
						
						var options = plugin.parseOptions(value);
						
						// It's still possible that this is a macro, just with changed options. Let's check that and apply the macro if needed:
						
						if (s.macros[options.type] != undefined){
							var macrooptions = plugin.parseOptions(s.macros[options.type]);
							options.type = macrooptions.type;
							options = $.extend({}, macrooptions, options);
						}
						
						// If this is a macro definition, add the current command string to the macros array:
						
						if (options.type == 'macro' && relsplit[index-1] != undefined){
							
							plugin.settings.macros[options.name] = relsplit[index-1];
						
						// If this is the special repeat command, parse the options and than add it to the delivered event handler:
						
						} else if (options.type == 'repeat' && relsplit[index-1] != undefined){
							
							var prevoptions = plugin.parseOptions(relsplit[index-1]);
							
							$el.on( options.onevent, function(){
								if (options.delay == undefined) options.delay = 0;
								setTimeout( function(){
									plugin.executeCommand($(that), prevoptions.type, prevoptions);
								}, options.delay);
							});
						
						} else {
							
							// Looks like this isn't one of the special use commands, so lets execute one of the regular ones.
							
							// If the targets option is set, we first have to find out to which target nodes we have to apply the command:
							
							var targets = [];
							if (options.target != undefined){
								
								var targetsplit = options.target.split('.');
								targetsplit = [targetsplit.shift(), targetsplit.join('.')]
								if (targetsplit[1] == undefined){
									targetsplit[1] = '*';
								}
								
								switch(targetsplit[0]){
									case 'children':
										$(that).children(targetsplit[1]).each( function(){
											targets.push(this);
										});
										break;
									case 'each':
										$(that).find(targetsplit[1]).each( function(){
											targets.push(this);
										});
										break;
									default:
										targets.push(that);
								}
							} else {
								targets.push(that);
							}
							
							$.each( targets, function(i,v){
								
								// First parse all dynamic options. They are declared like this:
								//
								//     [command:myoption={rand|0-1000}]
								//
								
								var thisoptions = plugin.parseDynamicOptions(options);
								
								// Now it's time to find out what the command key is for this specific command call. 
								// This can be set either by the commandkey option, the dot syntax or if both are not
								// set, we take the elements id attribute or as a last option, we just generate an unique id.
								
								if (thisoptions.commandkey == undefined){
									var id = $(v).attr("id");
									if (id != undefined){
										thisoptions.commandkey = id;
									} else {
										thisoptions.commandkey = s.prefix+'-uid-'+(++uid);
									}
								}
								
								// Now as we have the commandkey, we store it in the plugins commandkey array together 
								// with some other useful information for later use:
								
								if (thisoptions.commandkey != undefined){
									commandkeys[thisoptions.commandkey] = {
										'el': v,
										'options': thisoptions,
										'execs': 0
									};
								}
								
								// Next we need to check if we have to immediately execute the command or if we have to 
								// execute it later on a specific event:
								
								if (thisoptions.onevent !== undefined || thisoptions.andonevent !== undefined){
									
									var events = [];
									if (thisoptions.onevent !== undefined) events.push(thisoptions.onevent);
									if (thisoptions.andonevent !== undefined) events.push(thisoptions.andonevent);
									var e = events.join(' ');
									
									$el.on( e, function(){
										if (s.replacements[thisoptions.type] != undefined && typeof(s.replacements[thisoptions.type]) === "function"){
											s.replacements[thisoptions.type].call(plugin, v, thisoptions.type, thisoptions);
										} else {
											plugin.executeCommand(v, thisoptions.type, thisoptions);
										}
									});
								
								}
								
								// If we don't have an event set, we execute it immediately:
								
								if (thisoptions.onevent === undefined){
									
									// Check if a command replacement for this command is available and if yes, call it.
									
									if (s.replacements[thisoptions.type] != undefined && typeof(s.replacements[thisoptions.type]) === "function"){
										s.replacements[thisoptions.type].call(plugin, v, thisoptions.type, thisoptions);
									} else {
										plugin.executeCommand(v, thisoptions.type, thisoptions);
									}
								
								}
							
							});
						
						}
					
					});
				
				});
			
			}
		
		};
		
		// ### applyMacro
		//
		// The **applyMacro** function lets us execute predefined macros.
		
		plugin.applyMacro = function($el, macro){
			
			var s = plugin.settings;
			
			if (s.macros[macro] != undefined){
				var value = s.macros[macro];
				var options = plugin.parseOptions(value);
				
				if (s.replacements[options.type] != undefined && typeof(s.replacements[options.type]) === "function"){
					s.replacements[options.type].call(plugin, $el, options.type, options);
				} else {
					plugin.executeCommand($el, options.type, options);
				}
			}
		
		};
		
		// ### parseOptions
		//
		// The **parseOptions** function takes a command string and creates an array out of it with all options. 
		// It automatically detects the command type and command key. An input string can look like this 
		// (optionally with additional spaces and newlines):
		// 
		//     mycommand.mykey:firstoption=value1;secondoption=value2
		//
		
		plugin.parseOptions = function(string){
			
			var relsplit = string.split(':');
			var commandsplit = relsplit[0].split('.');
			
			var options = { 'type': $.trim(commandsplit[0]) };
			
			if (commandsplit[1] !== undefined){
				options['commandkey'] = commandsplit[1];
			}
			
			if (options.execute == undefined){
				options.execute = 'always';
			}
			
			if (relsplit.length > 1){
				var optionssplit = relsplit[1].split(';');
				
				$.each( optionssplit, function(key, value){
					var optionssplit2 = value.split('=');
					options[$.trim(optionssplit2[0])] = $.trim(optionssplit2[1]);
				});
			}
			
			return options;
		
		};
		
		
		// ### fixSpeed
		//
		// The **fixSpeed** function is used to make sure that a speed option has a correct value, either
		// "slow", "fast" or an integer.
		
		plugin.fixSpeed = function(speed){
			
			if (speed != 'fast' && speed != 'slow'){
				speed = parseInt(speed);
			}
			
			return speed;
		};
		
		
		// ### parseDynamicOptions
		//
		// The **parseDynamicOptions** looks for dynamic options that look like this:
		// 
		//     [command:myoption={rand|0-1000}]
		//
		// Currently only the random options are supported, but more stuff is planned, like increase or decrease.
		
		plugin.parseDynamicOptions = function(options){
			
			var parsedoptions = {};
			
			for (index in options){
				var v = options[index];
				
				if (v !== undefined && v.indexOf("{") > -1 && v.indexOf("|") > 0 && v.indexOf("}") > 1){
					
					var option = '';
					var dyn = false;
					var dynstr = '';
					var parse = false;
					
					for (var i=0; i<=(v.length-1);i++){
						
						if (!dyn && v.charAt(i) == '{'){
							dyn = true;
						} else if (dyn && v.charAt(i) == '}'){
							dyn = false;
							parse = true;
						}
						
						if (dyn || parse){
							dynstr += v.charAt(i);
							if (parse){
								dynstr = dynstr.slice(1, -1);
								var dynsplit = dynstr.split('|');
								
								if (dynsplit[0] == 'rand'){
									var valsplit = dynsplit[1].split('-');
									option += plugin.getRandom(Number(valsplit[0]), Number(valsplit[1]));
								}
								
								parse = false;
								dynstr = '';
							}
						} else {
							option += v.charAt(i);
						}
						
					}
					
					parsedoptions[index] = option;
					
				} else {
					parsedoptions[index] = v;
				}
			}
			
			return parsedoptions;
		}
		
		// ### getRandom
		//
		// The **getRandom** function simply generates a random number between a minimum number and a maximum number.
		
		plugin.getRandom = function(min, max) {
			if(min > max) {
				return -1;
			}
			
			if(min == max) {
				return min;
			}
			
			var r;
			do {
				r = Math.random();
			}
			while(r == 1.0);
			
			return min + parseInt(r * (max-min+1));
		}
		
		// ### findElementTag
		//
		// The **findElementTag** function makes it possible to find the tag name of a specific element in a 
		// previously defined structure. This makes it possible to write agnostic HTML for tab or similar structures.
		// For example on the tab command, both this structures would be succesfully detected:
		//
		//     div (container)
		//         div (element)
		//             h3 (title)
		//             div (content)
		//
		//     ul (container)
		//         li (element)
		//             h2 (title)
		//             p (content)
		//
		// Check the tab command to get an example of how to use the function.
		
		plugin.findElementTag = function($container, selector, pos, defaultval){
			
			var output = '';
			
			if ( pos !== undefined && !isNaN(pos) && parseInt(pos) == pos ){
				if ($container.find(selector).length > pos){
					output = $($container.find(selector).get(pos)).prop('tagName');
				}
			} else { 
				
				var tags = {};
				
				$container.find(selector).each( function(i){
					if (i < 25){
						var tag = $(this).prop('tagName');
						if (tag[0] != ''){
							if (tags[tag] !== undefined){
								tags[tag]++;
							} else {
								tags[tag] = 1;
							}
						}
					} else {
						return false;
					}
				});
				
				var max = 0;
				var maxkey = '';
				for (var key in tags){
					if (tags[key] > max){
						max = tags[key];
						maxkey = key;
					}
				}
				output = maxkey;
			}
			
			if (output !== undefined && output != ''){
				return output;
			} else {
				return defaultval;
			}
			
		};
		
		// ### addDefaults
		//
		// The **addDefaults** function adds all the default options to the options array. Additionally 
		// all speed options are fixed if needed.
		
		plugin.addDefaults = function(command, options){
			
			if (plugin.settings.commands[command] != undefined){
				var c = plugin.settings.commands[command];
				
				$.each(c, function(i, v){
					if (options[i] == undefined) options[i] = v;
					if (i.indexOf('speed') > -1) options[i] = plugin.fixSpeed(options[i]);
				});
			}
			
			return options;
		};
		
		// ### executeCommand
		//
		// The **executeCommand** function is used to execute a command on a specific DOM node with an array of options.
		
		plugin.executeCommand = function(that, type, options){
			
			var s = plugin.settings;
			var $that = $(that);
			
			// Trigger the **jkit-commandinit** event on the main element with all useful information attached to it. 
			// This event is currently not used internally, but can of course be listened to from outside the plugin.
			
			$element.trigger('jkit-commandinit', { 'element': $that, 'type': type, 'options': options });
			
			// Check if there is a limit set on how many times we're allowed to execute this command (based on the command key)
			
			if (options.commandkey !== undefined){
				commandkeys[options.commandkey]['execs']++;
				if ((options.execute == 'once' && commandkeys[options.commandkey]['execs'] > 1) || (!isNaN(options.execute) && commandkeys[options.commandkey]['execs'] > options.execute)){
					return $that;
				}
			}
			
			// Add all default options where there isn't an option set:
			
			options = plugin.addDefaults(type, options);
			
			$.each( options, function(i,v){
				
				// Convert jKit's special escaping strings to their regular characters:
				
				if (typeof v == 'string'){
					options[i] = v = v
						.replace(/\|jkit\-eq\|/g,'=')
						.replace(/\|jkit\-dp\|/g,':')
						.replace(/\|jkit\-sc\|/g,';')
						.replace(/\|jkit\-sbo\|/g,'[')
						.replace(/\|jkit\-sbc\|/g,']')
						.replace(/\|jkit\-st\|/g,'*')
						.replace(/\|jkit\-sp\|/g,' ');
				}
				
				// Call or get all dynamic options (those with an asterix at the end):
				
				if (typeof v == 'string' && v.slice(-1) == '*'){
					options[i] = window[v.slice(0, -1)];
					if (typeof options[i] == 'function'){
						options[i] = options[i].call(that);
					}
				}
			});
			
			// #### Commands
			//
			// Depending on the type of command, different actions are executed.
			
			switch(type){
				
				// {!} codeblock: command-paginate
				
				// ##### Paginate Command
				//
				// The [paginate command](http://jquery-jkit.com/commands/paginate.html) lets you create paginated content.
				
				case 'paginate':
					
					if (options.container != ''){
						var $container = $that.find(options.container);
					} else {
						var $container = $that;
					}
					
					if ($that.attr('id') !== undefined){
						var paginateid = s.prefix+'-'+type+'-'+$that.attr('id');
					} else {
						var paginateid = s.prefix+'-'+type+'-uid-'+(++uid);
					}
					
					var pages = [];
					var page = [];
					
					// Paginate has two ways to operate, either by node count or by actual element height in pixels.
					// In the **node mode** we put a specific amount of DOM nodes into each entry of the pages array. 
					// In the **height mode** we actually measure the height of each element and only put DOM nodes into the current page 
					// that actually fit into the maximum height the user has set. 
					
					if (options.by == 'node'){
						
						var cnt = 1;
						
						$container.children().each( function(){
							
							cnt++;
							page.push($(this).detach());
							
							if (cnt > Number(options.limit)){
								cnt = 1;
								pages.push(page);
								page = [];
							}
							
						});
						
					} else {
						
						var height = 0;
						
						$container.children().each( function(){
							
							height += $(this).outerHeight();
							
							if (height > Number(options.limit)){
								height = $(this).outerHeight();
								if (page.length > 0){
									pages.push(page);
								}
								page = [];
							}
							
							page.push($(this).detach());
							
						});
						
					}
					
					if (page.length > 0){
						pages.push(page);
					}
					
					if (pages.length > 1){
						
						// Now as we have the pages set up correctly and we actually have more than one, it's time 
						// to create the output DOM structure. The main element always gets the page data and the 
						// actuall pagination is an unordered list we insert after that element.
						
						var $pagination = $('<ul/>', { 'id': paginateid, 'class': s.prefix+'-pagination' });
						
						$.each( pages, function(i,v){
							
							var $pnav = $('<li/>').html(i+1).on( 'click', function(){
								
								plugin.triggerEvent('showpage showpage'+(i+1), $that, options);
								
								$pagination.find('li').removeClass(s.activeClass);
								$(this).addClass(s.activeClass);
								
								$container.jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
									$container.html('');
									$.each(v, function(index, value){
										value.clone().appendTo($container);
									});
									$container.jKit_effect(true, options.animation, options.speed, options.easing, 0);
								});
								
							});
							
							if (i == 0){
								$pnav.addClass(s.activeClass);
							}
							$pnav.appendTo($pagination);
							
						});
						
						if (options.pos == 'after'){
							$pagination.insertAfter($that);
						} else {
							$pagination.insertBefore($that);
						}
						
						$container.html('');
						$.each(pages[0], function(index, value){
							value.clone().appendTo($container);
						});
						
					}
					
					break;
				
				
				// {!} codeblock: /command-paginate, command-filter
				
				
				// ##### Filter Command
				//
				// The [filter command](http://jquery-jkit.com/commands/filter.html) lets you filter DOM nodes based on some input.
					
				case 'filter':
				
					// The filter has to run on init and after every change of elements that have the **jkit-filter** class, 
					// so we have our own function we can call on all those events, the **filterElements** function, and 
					// let that function do all the hard work.
					
					$that.find('.jkit-filter').each( function(){
						$(this)
							.data('oldval', $.trim( $(this).val() ) )
							.on( 'change click input', function(){
								
								if ( $.trim( $(this).val() ) != $(this).data('oldval') ){
									
									$(this).data('oldval', $.trim( $(this).val() ) );
									
									if (options.loader !== undefined) $(options.loader).show();
									plugin.triggerEvent('clicked', $that, options);
									
									plugin.filterElements($that, options);
									
								}
								
							});
					});
					
					// In case there's already a filter value set, we need to trigger the filtering right now:
					
					$that.find('.jkit-filter').each( function(){
						if ($.trim($(this).val()) != ''){
							
							if (options.loader !== undefined) $(options.loader).show();
							plugin.triggerEvent('clicked', $that, options);
							plugin.filterElements($that, options);
							
							return false;
						}
					});
					
					break;
				
				
				// {!} codeblock: /command-paginate, command-summary
				
				
				// ##### Summary Command
				//
				// The [summary command](http://jquery-jkit.com/commands/summary.html) creates a summary on specific content, for example the headers in a content div.
				// The summary itself is either a linked list or a dropdown with automated events.
					
				case 'summary':
					
					var output = '';
					var jumpid = '';
					
					var pre = ''
					if (options.scope == 'children'){
						pre = '> ';
					}
					
					if (options.what == 'headers'){
						options.what = ':header';
					}
					
					$(options.from).find(pre+options.what).each( function(){
						
						var $current = $(this);
						
						// If we're using all headers for our summary, than we have to do some extra work to get them
						// indented correctly.
						
						var space = '';
						if (options.what == ':header' && options.indent == 'yes'){
							var tag = $current.prop('tagName');
							if (tag.length == 2 && tag[1] != ''){
								var spaces = tag[1]-1;
								for (var i=1; i<=spaces;i++){
									space += '&nbsp; &nbsp; ';
								}
							}
						}
						
						// A summary can either be linked or just text:
						
						if (options.linked == 'yes'){
							
							if ($current.attr('id') !== undefined){
								var id = $current.attr('id');
							} else {
								var id = s.prefix+'-uid-'+(++uid);
								$current.attr('id', id);
							}
							
							if (window.location.hash == '#'+id){
								jumpid = id;
							}
							
							if (options.style == 'select'){
								output += '<option value="'+id+'">'+space+$(this).text()+'</option>';
							} else {
								output += '<li><a href="#'+id+'">'+space+$(this).text()+'</a></li>';
							}
							
						} else {
							if (options.style == 'select'){
								output += '<option value="">'+space+$(this).text()+'</option>';
							} else {
								output += '<li>'+space+$(this).text()+'</li>';
							}
						}
					});
					
					if (output != ''){
						
						$that.html('<'+options.style+'>'+output+'</'+options.style+'>');
						
						// In case this is a dropdown summary that is linked, we have to manually add 
						// an event on change so we can jump to the anchors as needed:
						
						if (options.style == 'select' && options.linked == 'yes'){
							$that.find('select').on( 'change', function(){
								window.location.hash = '#'+$(this).val();
								$(this).blur();
							});
						}
						
						// And lastly if we create a select and have detected a hash, we need to set that select to the correct value
						// and jump to the correct element:
						
						if (options.style == 'select' && options.linked == 'yes' && jumpid != ''){
							
							$that.find('select').val(jumpid);
							
							if ($that.find('#'+jumpid).offset() !== undefined){
								var ypos = $that.find('#'+jumpid).offset().top;
								$('html, body').css({ scrollTop: ypos+'px' });
							}
							
						}
						
					}
					
					break;
				
				
				// {!} codeblock: /command-summary, command-api
				
					
				// ##### API Command
				//
				// The [API command](http://jquery-jkit.com/commands/api.html) lets you use JSON based API's to display external data. Check the **plugin.readAPI** for how it's done.
						
				case 'api':
					
					if (options.url != ''){
						plugin.readAPI($that, options);
					}
					
					break;
					
				
				// {!} codeblock: /command-api, command-zoom
				
				
				// ##### Zoom Command
				//
				// The [zoom command](http://jquery-jkit.com/commands/zoom.html) makes it possible to zoom into images on mouseover. To do that it 
				// overlays the selected image with a div that has that image as its background.
					
				case 'zoom':
					
					$that.parent().css('position', 'relative');
					
					$that.on( 'mouseover', function(){
						
						var pos = $that.position();
						var height = $that.height();
						var width = $that.width();
						
						$zoom = $('<div/>', {
							'class': s.prefix+'-'+type+'-overlay'
						}).css( {
							'position': 'absolute',
							'height': height+'px',
							'width': width+'px',
							'left': pos.left + 'px',
							'top': pos.top + 'px',
							'overflow': 'hidden',
							'background-image': 'url('+$that.attr('src')+')',
							'background-repeat': 'no-repeat',
							'background-color': '#000',
							'opacity': 0
						}).on( 'mouseout', function(){
							$zoom.fadeTo(options.speed, 0, function(){
								$zoom.remove();
								plugin.triggerEvent('zoomout', $that, options);
							});
						}).mousemove(function(e){
							
							// Detect the mouse poition relative to the selected image:
							
							var offset = $(this).offset();
							
							var x = (e.pageX - offset.left) * (options.scale-1);
							var y = (e.pageY - offset.top) * (options.scale-1);
							
							// And than move the background image of the overlayed div:
							
							$zoom.css('background-position', '-'+x+'px -'+y+'px');
						
						}).fadeTo(options.speed, 1, function(){
							plugin.triggerEvent('zoomin', $that, options);
						}).insertAfter($that);
						
						// Optionally add a lightbox to the overlay image:
						
						if (options.lightbox == 'yes'){
							plugin.executeCommand($zoom, 'lightbox', {});
						}
					
					});
					
					break;
				
				
				// {!} codeblock: /command-zoom, command-sort
				
				
				// ##### Sort Command
				//
				// The [sort command](http://jquery-jkit.com/commands/sort.html) helps you convert a normal table into a sortable table
				// by converting TH elements of a table into clickable buttons that sort the
				// table based on the data inside the same column as the TH.
					
				case 'sort':
					
					// First we need to know the exact position of the current TH inside the heading TR, the index:
					
					var index = $that.parent().children().index($that);
					
					$that.on('click', function(){
						
						plugin.triggerEvent('clicked', $that, options);
						
						// First we have to create an array with the content we need to base the sort on:
						
						var rows = [];
						$that.parent().parent().parent().find('tbody > tr').each( function(){
							
							var $td = $(this).find('td:nth-child('+(index+1)+')');
							
							switch(options.what){
								case 'html':
									var str = $td.html();
									break;
								case 'class':
									var str = $td.attr('class');
									break;
								default:
									var str = $td.text();
									break;
							}
							
							if (options.start > 0 || options.end > 0){
								if (options.end > options.start){
									str = str.substring(options.start, options.end);
								} else {
									str = str.substring(options.start);
								}
							}
							
							rows.push({ 'content': $(this).html(), 'search': str });
						
						});
						
						// {!} task: It should be possible to use way less code in the code below! 
						
						// Now sort the array. There are currently three different ways to sort:
						//
						// - **alpha**: Will sort the array by the alphabetically
						// - **num**: Will sort the array numerically
						// - **date**: Will sort the array as a date
						//
						// Depending on the current class of the TH, we either sort ascending or descending.
						
						if ($that.hasClass(s.prefix+'-'+type+'-down')){
							$that.parent().find('th').removeClass(s.prefix+'-'+type+'-down').removeClass(s.prefix+'-'+type+'-up');
							$that.addClass(s.prefix+'-'+type+'-up');
							rows.sort( function(a,b){
								if (options.by == 'num'){
									a.search = Number(a.search);
									b.search = Number(b.search);
								}
								if (options.by == 'date'){
									var a = new Date(a.search);
									var b = new Date(b.search);
									return (a.getTime() - b.getTime());
								} else {
									if (a.search > b.search) return -1;
									if (a.search < b.search) return 1;
									return 0;
								}
							});
						} else {
							$that.parent().find('th').removeClass(s.prefix+'-'+type+'-down').removeClass(s.prefix+'-'+type+'-up');
							$that.addClass(s.prefix+'-'+type+'-down');
							rows.sort( function(a,b){
								if (options.by == 'num'){
									a.search = Number(a.search);
									b.search = Number(b.search);
								}
								if (options.by == 'date'){
									var a = new Date(a.search);
									var b = new Date(b.search);
									return (b.getTime() - a.getTime());
								} else {
									if (a.search < b.search) return -1;
									if (a.search > b.search) return 1;
									return 0;
								}
							});
						}
						
						// Everything is ready, let's clear the whole TBODY of the table and add the sorted rows:
						
						var $body = $that.parent().parent().parent().find('tbody');
						$body.html('');
						
						var tbody = '';
						$.each( rows, function(i,v){
							tbody += '<tr>'+v.content+'</tr>';
						});
						
						$body.html(tbody);
						
						plugin.triggerEvent('complete', $that, options);
					
					});
					
					break;
				
				
				// {!} codeblock: /command-sort, command-ticker


				// ##### Ticker Command
				//
				// The [ticker command](http://jquery-jkit.com/commands/ticker.html) goes through each item of a list and reveals 
				// the item one character at a time.
					
				case 'ticker':
					
					var containerTag = plugin.findElementTag($that, '>', 'max', 'li');
					
					// Create an array with objects that contain all useful information of a single ticker item:
					
					var messages = [];
					
					$that.find(containerTag).each( function(){
						messages.push({
							'href': $(this).find('a').attr('href'),
							'target': $(this).find('a').attr('target'),
							'text': $(this).text()
						});
					});
					
					// Replace the target element with a DIV and start the ticker function:
					
					var $newThat = $('<div/>');
					$that.replaceWith($newThat);
					window.setTimeout( function() { plugin.ticker($newThat, options, messages, 0, 0); }, 0);
					
					break;

				
				// {!} codeblock: /command-ticker, command-swap


				// ##### Swap Command
				//
				// The [swap command](http://jquery-jkit.com/commands/swap.html) replaces a DOM node attribute, for 
				// example an image, with another value on hover.
					
				case 'swap':
					
					var versions = options.versions.split(s.delimiter);
					
					// We have to store the original attributes value to swap the attribute back on mouseleave:
					
					var original = $that.attr(options.attribute);
					var replacement = $that.attr(options.attribute).replace(versions[0],versions[1]);
					
					// In case the attribute is an image source, we have to preload the image or the swapping could have a delay:
					
					if (options.attribute == 'src'){
						$('<img/>')[0].src = replacement;
					}
					
					// Finally, add the two event handlers with the swapping code:
					
					$that.mouseenter(function(){
						$that.attr(options.attribute, replacement );
						plugin.triggerEvent('active', $that, options);
					}).mouseleave(function(){
						$that.attr(options.attribute, original );
						plugin.triggerEvent('inactive', $that, options);
					});
					
					break;
				
					
				// {!} codeblock: /command-swap, command-fontsize

				
				// ##### Fontsize Command
				//
				// The [fontsize command](http://jquery-jkit.com/commands/fontsize.html) can be used to change the size of text. 
				// It can be limited to specific elements. You can even use it to change other CSS related sizes, for example the 
				// width of an element, with the **style** option.
					
				case 'fontsize':
					
					$that.on( 'click', function(){
						
						$element.find(options.affected).each( function(){
							
							var newsize = parseInt($(this).css(options.style)) + parseInt(options.steps);
							
							if (newsize >= parseInt(options.min) && newsize <= parseInt(options.max) ){
								$(this).css(options.style, newsize );
							}
						
						});
						
						plugin.triggerEvent('changed', $that, options);
						
						return false;
					});
					
					break;
				
					
				// {!} codeblock: /command-fontsize, command-fontsize


				// ##### Cycle Command
				//
				// The [cycle command](http://jquery-jkit.com/commands/cycle.html) let's you "cycle" through
				// a sequence of values and apply them to a set of DOM nodes. This can be classes, html, attributes or css.
					
				case 'cycle':
					
					var seq = options.sequence.split(s.delimiter);
					var pos = 0;
					
					var sel = options.where;
					if (options.scope == 'children'){
						sel = '> '+sel;
					}
					
					$that.find(sel).each( function(){
						if (seq[pos] != undefined && seq[pos] != ''){
							switch(options.what){
								case 'class':
									$(this).addClass(seq[pos]);
									break;
								case 'html':
									$(this).html(seq[pos]);
									break;
								default:
									
									// If it's not a class or html, it has to be a dot separated combination like for exmaple
									// **css.color** or **attr.id**, so split it:
								
									var what = options.what.split('.');
									if (what[0] == 'attr'){
										$(this).attr(what[1], seq[pos]);
									} else if (what[0] == 'css'){
										$(this).css(what[1], seq[pos]);
									}
							}
						}
						pos++;
						if (pos > seq.length-1) pos = 0;
					});
					
					break;
				
				
				// {!} codeblock: /command-cycle, command-replace


				// ##### Replace Command
				//
				// The [replace command](http://jquery-jkit.com/commands/replace.html) makes it possible to replace content 
				// based on a regex pattern. It acts on the HTML level, so not only text is replacable!
					
				case 'replace':
					
					var str = new RegExp(options.search, options.modifier);
					$that.html($that.html().replace(str,options.replacement));
					
					break;
				
				
				// {!} codeblock: /command-replace, command-replace


				// ##### Ajax Command
				//
				// The [ajax command](http://jquery-jkit.com/commands/ajax.html) can do a few thing. The normal use case is a link 
				// that loads some extra content through an ajax call on click. But the command can be used to lazy load images, too.
					
				case 'ajax':
					
					// If the href option is set, take it from the option, if not, take it from our element: 
					
					if (options.href != undefined && options.href != ''){
						var href = options.href;
					} else {
						var href = $that.attr('href');
					}
					
					if (options.when == 'load' || options.when == 'viewport'){
						
						// If the option **when** is **load*, than we're just loading the content:
						
						if (options.when == 'load'){
							$that.load(href, function(){
								plugin.triggerEvent('complete', $that, options);
							});
							
						// If it's **viewport**, we're going to wait till the content enters the viewport before 
						// we load the content or the image (lazy load), whatever our options say:
							
						} else {
							var myInterval = setInterval(function(){
								if ($that.jKit_inViewport() || !$that.jKit_inViewport() && s.ignoreViewport){
									if (options.src != undefined){
										$that.attr('src', options.src);
										plugin.triggerEvent('complete', $that, options);
									} else {
										$that.load(href, function(){
											plugin.triggerEvent('complete', $that, options);
										});
									}
									window.clearInterval(myInterval);
								}
							},100);
						}
					
					// This is our default use case, load the content on click:
						
					} else {
						$that.on('click', function(){
							plugin.loadAndReplace(href, options, $that);
							return false;
						});
					}
					
					break;
				
				
				// {!} codeblock: /command-ajax, command-key


				// ##### Key Command
				//
				// The [key command](http://jquery-jkit.com/commands/key.html) let's us create hotkeys 
				// for links. If thge link has an **onclick** attribute, we fire that one, if not, we're just 
				// going to open the href, either as a popup or inside the same window, whatever the target 
				// attribute tells us.
					
				case 'key':
					
					if (options.code != undefined){
						
						// First we need to add the event handling for this keycode to the element ...
						
						plugin.addKeypressEvents($that, options.code);
						
						// Because only now we can listen to it:
						
						$that.on( options.code, function(){
							if ($that.attr('onclick') !== undefined){
								$that.click();
							} else {
								if ($that.attr('target') !== undefined && $that.attr('target') == '_blank'){
									
									// Sadly we can't open pages in a new tab or regular window, so we have to open it in a popup instead:
									
									window.open($that.attr('href'), '_blank', false);
								} else {
									window.location.href = $that.attr('href');
								}
							}
							if (options.macro != undefined) plugin.applyMacro($that, options.macro);
							plugin.triggerEvent('pressed', $that, options);
						});
					
					}
					
					break;
				
				
				// {!} codeblock: /command-key, command-live


				// ##### Live Command
				//
				// The [live command](http://jquery-jkit.com/commands/live.html) is very simple. All it does is reload 
				// the source of an image or iframe in a certain interval and making sure that it doesn't load the cashed version.
					
				case 'live':
					
					if ($that.attr('src') !== undefined) {
						window.setInterval( function() {
							plugin.updateSrc($that, options);
							plugin.triggerEvent('reloaded', $that, options);
						}, options.interval*1000);
					}
					
					break;
				
				
				// {!} codeblock: /command-live, command-split


				// ##### Split Command
				//
				// The [split command](http://jquery-jkit.com/commands/split.html) can take a string, for example a comma separeted one, 
				// and create new HTML elements out of the individual parts. This way a simple comma separated list can be transformed 
				// into an unordered list.
				
				case 'split':
					
					var parts = $that.text().split(options.separator);
					$that.html('');
					
					$.each( parts, function(i,v){
						$('<'+options.container+'/>').text(v).appendTo($that);
					});
					
					$that.html(options.before+$that.html()+options.after);
					
					break;
				
				
				// {!} codeblock: /command-split, command-encode


				// ##### Encode Command
				//
				// The [encode command](http://jquery-jkit.com/commands/encode.html) apply various encodings to the content of an element.
				// If the option is code, the content is not only HTML encoded, it can even remove the extra tab whitespace you get if you 
				// have that content indented inside the code element.
					
				case 'encode':
					
					switch(options.format) {
						case 'code':
							var src = $that.html();
							if (options.fix == 'yes'){
								src = plugin.preFix(src);
							}
							$that.html(src.replace(/</g, '&lt;').replace(/>/g, '&gt;'));
							break;
						case 'text':
							$that.html($that.text());
							break;
						case 'esc':
							$that.html(escape($that.html()));
							break;
						case 'uri':
							$that.html(encodeURI($that.html()));
							break;
					}
					
					break;
				
				
				// {!} codeblock: /command-encode, command-chart


				// ##### Chart Command
				//
				// The [chart command](http://jquery-jkit.com/commands/chart.html) let's us create simple horizontal bar charts using 
				// different sized divs. This is definitely a good candidate for a command replacement using the canvas element to draw
				// different charts.
					
				case 'chart':
					
					// First get the main label from the THEAD and the main element id:
					
					var label = $that.find('thead > tr > th.label').text();
					var id = $that.attr('id');
					
					// Now get all data column labels from the THEAD
					
					var datalabels = [];
					
					$that.find('thead > tr > th').each( function(){
						if (!$(this).hasClass('label')){
							datalabels.push( $(this).text() );
						}
					});
					
					// And the last thing we need is all the data from the tbody:
					
					// {!} task: Why do we get the TH from TBODY? This should be TDs!
					
					var max = 0;
					var plots = [];
					
					$that.find('tbody tr').each( function(){
						var plot = { 'label': $(this).find('th.label').text(), 'data': [] };
						$(this).find('th').each( function(){
							if (!$(this).hasClass('label')){
								var val = Number($(this).text());
								max = Math.max(val, max);
								plot.data.push(val);
							}
						});
						plots.push(plot);
					});
					
					// Set the maximum value for our chart either from the options or from all the data values:
					
					if (options.max > 0 && max < options.max){
						max = options.max;
					}
					
					// Time to construct our chart element:
					
					var $chart = $('<div/>', {
						id: id,
						'class': s.prefix+'-'+type
					});
					
					// Now loop through each data label and add the data from each plot to it. We are using a delay for each
					// plot and increase that delay with each new data label. This way we get a nice animation where every plot
					// is shown a little bit later.
					
					var steps = 0;
					var delay = 0;
					
					$.each(datalabels, function(i,v){
						
						steps++;
						var $step = $('<div/>', { 'class': s.prefix+'-'+type+'-step' }).html('<label>'+v+'</label>').appendTo($chart);
						
						$.each( plots, function(i2,v2){
							
							if (plots[i2].data[i] > 0){
								
								var $plot = $('<div/>', { 'class': s.prefix+'-'+type+'-plot '+s.prefix+'-'+type+'-plot'+i2 }).appendTo($step);
								
								$('<div/>')
									.text(plots[i2].label)
									.delay(delay)
									.animate({ 'width': (plots[i2].data[i]/max*100)+'%' }, options.speed, options.easing)
									.appendTo($plot);
								
								$('<span/>', { 'class': s.prefix+'-'+type+'-info' })
									.text(label+' '+plots[i2].label+': '+plots[i2].data[i]+' '+options.units)
									.appendTo($plot);
							
							}
						
						});
						
						if (steps == datalabels.length){
							setTimeout( function(){
								plugin.triggerEvent('complete', $that, options);
							}, options.speed+delay);
						}
						
						delay += Number(options.delaysteps);
					});
					
					// Evyerything is set up, so replace the original element with our new chart:
					
					$that.replaceWith($chart);
					
					break;
				
				
				// {!} codeblock: /command-chart, command-lightbox


				// ##### Lightbox Command
				//
				// The [lightbox command](http://jquery-jkit.com/commands/lightbox.html) can be used to overlay a
				// bigger version of an image on click, content in an overlayed iframe or to display a modal dialog 
				// box above the content.
					
				case 'lightbox':
					
					// First we need to find out what the source is we're going to display in the lightbox.
					// If the href is set, we take that one, if not we check the src attribute and if that's 
					// not set, we check if the element has a background image:
					
					var src = '';
					if ($that.attr('href') !== undefined) src = $that.attr('href');
					if (src == '' && $that.attr('src') !== undefined) src = $that.attr('src');
					if (src == '' && $that.css('background-image') !== undefined){
						src = $that.css('background-image').replace('"','').replace('"','').replace('url(','').replace(')','');
					}
					
					// In case we didn't find a source, we just ignore this command:
					
					if (src != ''){
						
						// A lightbox can be part of a group of lightbox content, for example to display a gallery of image.
						// To achive this feature, we're using an array that is set on plugin init and available thoughout
						// the whole plugin. 
						
						if (options.group != ''){
							if (lightboxes[options.group] == undefined){
								lightboxes[options.group] = [];
							}
							lightboxes[options.group].push(that);
						}
						
						// A lightbox will always open on click:
						
						$that.on( 'click', function() {
							
							plugin.triggerEvent('clicked', $that, options);
							
							// If this is not a modal window, we have to create an overlay that darkens the 
							// whole content:
							
							if (options.modal == 'no'){
								var $overlay = $('<div/>', {
									id: s.prefix+'-'+type+'-bg',
									'class': s.prefix+'-'+type+'-closer '+s.prefix+'-'+type+'-el'
								}).fadeTo(options.speed, options.opacity).appendTo('body');
							}
							
							// We need another DIV for the content that's placed right above the overlay:
						
							var $content = $('<div/>', {
								id: s.prefix+'-'+type+'-content',
								'class': s.prefix+'-'+type+'-el'
							}).fadeTo(0,0.01).appendTo('body');
							
							// iOS devices need a small hack to display the content correctly in case the
							// page is scrolled:
							
							if ($.fn.jKit_iOS()) $content.css('top', $(window).scrollTop()+'px');
							
							// If there's a fixed width or height set in the options, we have to overwrite the default
							// css values and fix the alignement:
							
							if (options.width != ''){
								$content.css({ 'width': options.width });
								$content.css({ 'left': (($(window).width() - $content.outerWidth()) / 2) + 'px' });
							}
							if (options.height != ''){
								$content.css({ 'height': options.height });
								$content.css({ 'top': (($(window).height() - $content.outerHeight()) / 2) + 'px' });
							}
							
							// Time to create the DOM nodes that contain the navigational elements and close button:
							
							var $nav = $('<div/>', {
								id: s.prefix+'-'+type+'-nav',
								'class': s.prefix+'-'+type+'-el'
							}).hide().fadeTo(options.speed, 1).appendTo('body');
						
							var $closer = $('<span/>', {
								'class': s.prefix+'-'+type+'-closer'
							}).html(options.closer).prependTo($nav);
							
							// The navigational element has to be placed based on the content element:
							
							var offset = $content.offset();
						
							$nav.css({
								'top': (offset.top-options.titleHeight-$(window).scrollTop())+'px',
								'left': (offset.left+$content.outerWidth()-$nav.width())+'px'
							});
							
							// In case this one is part of a group, we need to create the navigation and
							// bind all the needed events to it. Both, the left and the right navigation isn't 
							// always needed, so we have to check for those cases, as well.
						
							if (options.group != ''){
								var $next = $('<span/>', {
									id: s.prefix+'-'+type+'-nav-next'
								}).prependTo($nav);
							
								var $prev = $('<span/>', {
									id: s.prefix+'-'+type+'-nav-prev'
								}).prependTo($nav);
							
								plugin.addKeypressEvents($next, 'right');
								plugin.addKeypressEvents($prev, 'left');
							
								if (lightboxes[options.group][lightboxes[options.group].length-1] != that){
									$next.html(options.next).on( 'click right', function(){
										$.each(lightboxes[options.group], function(i,v){
											if (v == that){
												$('.'+plugin.settings.prefix+'-'+type+'-el').fadeTo(options.speed, 0, function(){
													$(this).remove();
												});
												lightboxes[options.group][i+1].click();
											}
										});
									});
								}
								if (lightboxes[options.group][0] != that){
									$prev.html(options.prev).on( 'click left', function(){
										$.each(lightboxes[options.group], function(i,v){
											if (v == that){
												$('.'+plugin.settings.prefix+'-'+type+'-el').fadeTo(options.speed, 0, function(){
													$(this).remove();
												});
												lightboxes[options.group][i-1].click();
											}
										});
									});
								}
							}
							
							// The last element we have to create and poistion corrently is the optional content title: 
						
							$title = $('<div/>', {
								id: s.prefix+'-'+type+'-title',
								'class': s.prefix+'-'+type+'-el'
							}).css({
								'top': (offset.top-options.titleHeight-$(window).scrollTop())+'px',
								'left': (offset.left)+'px',
								'width': $content.width()+'px'
							}).hide().text($that.attr('title')).fadeTo(options.speed, 1).appendTo('body');
							
							// Because IE is a stupid browser and doesn't fire the load element correctly in older versions
							// if the image is already in the cash, we have to force load a new version of the image:
							
							if (!$.support.leadingWhitespace){
								src = src+ "?" + new Date().getTime();
							}
							
							// Time to load the image or iframe content. The little trick here is to always try to load 
							// an image, even if there isn't one supplied, because this way we can use the error callback 
							// to find out if we actually have an image or not. As soon as the load event has fired, we
							// can get the width an height and will be able to calculate all the placement and scaling 
							// information we need.
							
							var img = new Image();
							$(img)
								.load(function () {
								
									var scalex = ($(this).outerWidth() + options.clearance) / $(window).width();
									var scaley = ($(this).outerHeight() + options.clearance) / $(window).height();
									var scale = Math.max(scalex,scaley);
									if (scale > 1){
										var oh = $(this).height();
										$(this).width($(this).width() / scale);
										$(this).height(oh / scale);
									}
									
									var xmargin = ( $(window).width() - $(this).outerWidth() ) / 2;
									var ymargin = ( $(window).height() - $(this).outerHeight() ) / 2;
									
									$content
										.width($(this).width())
										.height($(this).height())
										.css({ 'left': xmargin+'px', 'top': ymargin+'px' })
										.fadeTo(options.speed, 1);
									$(this).hide().fadeTo(options.speed, 1);
									
									if ($that.attr('title') != ''){
										$title.css({
											'top': (ymargin-options.titleHeight)+'px',
											'left': xmargin+'px',
											'width': $(this).width()+'px'
										});
									}
								
									$nav.css({
										'top': (ymargin-options.titleHeight)+'px',
										'left': (xmargin+$content.outerWidth()-$nav.width())+'px'
									});
							
								})
								.attr('src', src)
								.appendTo($content)
								.error(function(){
									$content.html('<iframe id="'+s.prefix+'-'+type+'-iframe" src="'+src+'" style="border:none;width:100%;height:100%"></iframe>').fadeTo(options.speed, 1);
								});
							
							// And finally, we make our closing button functional:
							
							$('.'+s.prefix+'-'+type+'-closer').click(function(){
								$('.'+s.prefix+'-'+type+'-el').fadeTo(options.speed, 0, function(){
									$(this).remove();
								});
							});
							
							// Return false so that we stay on the current page:
						
							return false;
					
						});
						
					}
					
					break;
				
				
				// {!} codeblock: /command-lightbox, command-scroll


				// ##### Scroll Command
				//
				// The [scroll command](http://jquery-jkit.com/commands/scroll.html) let's us scroll smoothly to
				// an anchor on the page or if the HREF attribute is empty, we just scroll to the top.
					
				case 'scroll':
					
					$that.click(function() {
						
						plugin.triggerEvent('clicked', $that, options);
						
						// Get the position of our target element:
						
						if ($(this).attr("href") == ''){
							var ypos = 0;
						} else {
							var ypos = $($that.attr("href")).offset().top;
						}
						
						// The dynamic option changes the scroll animation duration based on the distance between 
						// us and the target element:
						
						if (options.dynamic == 'yes'){
							options.speed = Math.abs($(document).scrollTop() - ypos) / 1000 * options.speed;
						}
						
						// Finally animate the **scrollTop** of the whole HTML page to scroll inside the current window:
						
						$('html, body').animate({ scrollTop: ypos+'px' }, options.speed, options.easing, function(){
							plugin.triggerEvent('complete', $that, options);
						});
						
						return false;
						
					});
					
					break;
				
				
				// {!} codeblock: /command-scroll, command-hide


				// ##### Hide Command
				//
				// The [hide command](http://jquery-jkit.com/commands/hide.html) is used to hide an element, animated or not.
					
				case 'hide':
					
					$that.jKit_effect(false, options.animation, options.speed, options.easing, options.delay, function(){
						plugin.triggerEvent('complete', $that, options);
					});
					
					break;
				
				
				// {!} codeblock: /command-hide, command-remove


				// ##### Remove Command
				//
				// The [remove command](http://jquery-jkit.com/commands/remove.html) is used to completely remove the element 
				// from the DOM.
					
				case 'remove':
					
					$that.delay(options.delay).hide(0, function(){
						$that.remove();
						plugin.triggerEvent('complete', $that, options);
					});
					
					break;
				
				
				// {!} codeblock: /command-remove, command-show


				// ##### Show Command
				//
				// The [show command](http://jquery-jkit.com/commands/show.html) is used to reveal an element, animated or not.
					
				case 'show':
					
					$that.hide().jKit_effect(true, options.animation, options.speed, options.easing, options.delay, function(){
						plugin.triggerEvent('complete', $that, options);
					});
					
					break;
				
				
				// {!} codeblock: /command-show, command-showandhide


				// ##### Showandhide Command
				//
				// The [showandhide command](http://jquery-jkit.com/commands/showandhide.html) is used to reveal an element
				// and than hide it again, animated or not.
					
				case 'showandhide':
					
					$that.hide().jKit_effect(true, options.animation, options.speed, options.easing, options.delay, function(){
						plugin.triggerEvent('shown', $that, options);
						$that.jKit_effect(false, options.animation, options.speed, options.easing, options.duration, function(){
							plugin.triggerEvent('complete', $that, options);
						});
					});
					
					break;
				
				
				// {!} codeblock: /command-showandhide, command-loop


				// ##### Loop Command
				//
				// The [loop command](http://jquery-jkit.com/commands/loop.html) does the sam thing as the **showandhide** command,
				// but repeats itself again, and again ... actually, pretty much forever. **Oh, and lease don't use it as a blink tag!!!**
					
				case 'loop':
					
					plugin.loop($that.hide(), options);
					
					break;
				
				
				// {!} codeblock: /command-loop, command-random


				// ##### Random Command
				//
				// The [random command](http://jquery-jkit.com/commands/random.html) can be used to randomly select a 
				// specific amount of elements from a collection of elements. All not selected ones will either be hidden 
				// or completely removed from the DOM.
					
				case 'random':
					
					var childs = $that.children().size();
					var shownrs = [];
					
					// Create an array of index numbers of our randomly selected elements:
					
					while(shownrs.length < options.count){
						var shownr = Math.floor(Math.random() * childs);
						if ($.inArray(shownr, shownrs) == -1){
							shownrs.push(shownr);
						}
					}
					
					// Now loop through all elements and only show those we just slected:
					
					var i = 0;
					$that.children().each( function(){
						if ($.inArray(i, shownrs) == -1){
							if (options.remove == 'yes'){
								$(this).remove();
							} else {
								$(this).hide();
							}
						} else {
							$(this).show();
						}
						i++;
					});
					
					break;
				
				
				// {!} codeblock: /command-random, command-partially


				// ##### Partially Command
				//
				// The [partially command](http://jquery-jkit.com/commands/partially.html) let's us display an element
				// only partially in case it is bigger than our supplied maximum height. The whole height is shown only 
				// on specific user action (hover over element or click of the *down* key)
					
				case 'partially':
					
					// First store the original height, we need it later.
					
					var originalHeight = $that.height();
					
					// Only add the magic is we need, in other words, if the lement is higher than our maximum height:
					
					if (originalHeight > options.height){
						
						// We can only add our *more div* if it's relatively positioned, so force that one on it:
						
						$that.css('position', 'relative');
						
						// Create the *more div*:
						
						var $morediv = $('<div/>')
								.addClass(s.prefix+'-morediv')
								.appendTo(that)
								.html(options.text)
								.css( { width: $that.outerWidth()+'px', opacity: 0.9 });
						
						// Add the event handlers and animations:
						
						plugin.addKeypressEvents($that, 'down');
						plugin.addKeypressEvents($that, 'up');
						
						if (options.on == 'click' || $.fn.jKit_iOS()){
							var openEvent = 'click';
							var closeEvent = 'click';
						} else {
							var openEvent = 'mouseenter';
							var closeEvent = 'mouseleave';
						}
						
						$that.css({ 'height': options.height+'px', 'overflow': 'hidden' }).on( openEvent+' down', function() {
							if ($that.height() < originalHeight){
								$morediv.fadeTo(options.speed, 0);
								$that.animate({ 'height': originalHeight+'px' }, options.speed, options.easing, function(){
									plugin.triggerEvent('open', $that, options);
								});
							}
						}).on( closeEvent+' up',  function(){
							if ($that.height() == originalHeight){
								$morediv.fadeTo(options.speed, 0.9);
								$that.animate({ 'height': options.height+'px' }, options.speed, options.easing, function(){
									plugin.triggerEvent('closed', $that, options);
								});
							}
						});
						
					}
					
					break;
				
				
				// {!} codeblock: /command-partially, command-slideshow


				// ##### Slideshow Command
				//
				// The [slideshow command](http://jquery-jkit.com/commands/slideshow.html) is being used to create 
				// slideshows of either images or any other kind of HTML content.
					
				case 'slideshow':
					
					// Get all slides:
					
					var slides = $that.children();
					
					// If needed, shuffle the slides into a random order:
					
					if (options.shuffle == 'yes'){
						var tmp, rand;
						var slidecount = slides.length;
						for(var i =0; i < slidecount; i++){
							rand = Math.floor(Math.random() * slidecount);
							tmp = slides[i];
							slides[i] = slides[rand];
							slides[rand] = tmp;
						}
					}
					
					$that.css( { 'position': 'relative' } );
					
					// Add the first slide and set a hidden data attribute so we know
					// if the slideshow is running or not.
					
					$that.html(slides[0]);
					$.data($that, 'anim', false);
					
					if (options.on != ''){
						
						// In case the **on** option is set to **mouseover**, we have to set an
						// additional **mouseleave** event.
						
						if (options.on == 'mouseover'){
							$that.on( 'mouseleave', function(){
								$.data($that, 'anim', false);
							});
						}
						
						// Set the correct events and use a setTimeout function to call the slideshow function:
						
						$that.on( options.on, function(){
							if (options.on == 'click'){
								if ($.data($that, 'anim')){
									$.data($that, 'anim', false);
								} else {
									$.data($that, 'anim', true);
									window.setTimeout( function() { plugin.slideshow(slides, 0, $that, options); }, 0);
								}
							} else if (options.on == 'mouseover'){
								if (!$.data($that, 'anim')){
									$.data($that, 'anim', true);
									window.setTimeout( function() { plugin.slideshow(slides, 0, $that, options); }, 0);
								}
							}
						});
					
					} else {
						
						// No event is set, so we just run the slideshow right now:
						
						$.data($that, 'anim', true);
						window.setTimeout( function() { plugin.slideshow(slides, 0, $that, options); }, options.interval);
						
					}
					
					break;
				
				
				// {!} codeblock: /command-slideshow, command-carousel


				// ##### Carousel Command
				//
				// The [carousel command](http://jquery-jkit.com/commands/carousel.html) is used to display a
				// subset of elements like a carousel, new one in, old one out.
					
				case 'carousel':
					
					var cnt = 0;
					
					// First hide all elements that are over our limit of elements we want to show:
					
					$that.children().each( function(){
						cnt++;
						if (cnt > options.limit){
							$(this).hide();
						}
					});
					
					// Add our **prev** and **next** button elements so the user can control the carousel:
					
					var $prevdiv = $('<a/>', {
						'class': s.prefix+'-'+type+'-prev'
					}).html(options.prevhtml).on( 'click left', function(){
						plugin.carousel($that, options, 'prev');
					}).insertAfter(that);
					
					var $nextdiv = $('<a/>', {
						'class': s.prefix+'-'+type+'-next'
					}).html(options.nexthtml).on( 'click right', function(){
						plugin.carousel($that, options, 'next');
					}).insertAfter(that);
					
					// Add some additional keyboard events:
					
					plugin.addKeypressEvents($prevdiv, 'left');
					plugin.addKeypressEvents($nextdiv, 'right');
					
					// Start autoplay if needed:
					
					if (options.autoplay == 'yes'){
						window.setTimeout( function() { plugin.carousel($that, options); }, options.interval);
					}
					
					break;
				
				
				// {!} codeblock: /command-carousel, command-animation


				// ##### Animation Command
				//
				// The [animation command](http://jquery-jkit.com/commands/animation.html) has two uses. Either it can be used
				// to animate the CSS of an element or it can be used to animated a kind of keyframe animation with attribute
				// tweenings.
				
				case 'animation':
					
					// First check if this is a CSS animation:
					
					if (options.to != ''){
						
						// If the **from** option is set, we first have to set the initial CSS:
						
						if (options.from != ''){
							$that.css( plugin.cssFromString(options.from) );
						}
						
						// use setTimeout to delay the animation, even if the delay is zero:
						
						setTimeout(function() {
							
							// Either add an event that starts the animation or start it right away:
							
							// {!} task: Dublicate code and the delay doesn't make much sense with an event like this.
							
							if (options.on != ''){
								$that.on( options.on, function(){
									$that.animate( plugin.cssFromString(options.to), options.speed, options.easing, function(){
										if (options.macro != undefined) plugin.applyMacro($that, options.macro);
										plugin.triggerEvent('complete', $that, options);
									});
								});
							} else {
								$that.animate( plugin.cssFromString(options.to), options.speed, options.easing, function(){
									if (options.macro != undefined) plugin.applyMacro($el, options.macro);
									plugin.triggerEvent('complete', $that, options);
								});
							}
						}, options.delay);
					
					} else {
						
						// This is a keyframe animation. Let's first set some initial variables:
						
						options.interval = 1000 / options.fps;
						
						var frames = [];
						
						var pos = 0;
						var lastframe = 0;
						
						// Loop through each keyframe and collect all the useful information
						// we can find and parse the frame command that sets each frames options.
						
						$that.children().each( function(){
							var rel = $(this).attr('rel');
							var data = $(this).attr(s.dataAttribute);
							
							if (data != undefined){
								var start = data.indexOf('[');
								var end = data.indexOf(']');
								var optionstring = data.substring(start+1, end);
							} else {
								var start = rel.indexOf('[');
								var end = rel.indexOf(']');
								var optionstring = rel.substring(start+1, end);
							}
							
							var frame = plugin.parseOptions(optionstring);
							
							frame.el = $(this);
							if (frame.easing == undefined) frame.easing = 'linear';
							
							frame.start = pos;
							pos += parseInt(frame.steps);
							frame.end = pos;
							lastframe = pos;
							pos++;
							
							frames.push(frame);
						});
						
						options.lastframe = lastframe;
						
						$that.css('overflow', 'hidden');
						
						// Replace the original elements content with the first frame only:
						
						$that.html(frames[0].el);
						
						// And now start the animation:
						
						window.setTimeout( function() { plugin.animation(frames, -1, $that, options); }, 0);
					
					}
					
					break;
				
				
				// {!} codeblock: /command-animation, command-gallery
				
				
				// ##### Gallery Command
				//
				// The [gallery command](http://jquery-jkit.com/commands/gallery.html) takes a bunch of images and creates
				// a gallery out of it.
					
				case 'gallery':
					
					// First get all images into an array:
					
					var images = $that.children();
					
					// Now put the active image only into the original element:
					
					$that.html($that.children(':nth-child('+options.active+')').clone());
					
					// In case we need additional lightbox functionality, add it:
					
					if (options.lightbox == 'yes'){
						plugin.executeCommand($that.find('img'), 'lightbox', {});
					}
					
					// Create the element that will contain the thumbnails and insert it after the gallery:
					
					var $thumbdiv = $('<div/>', {
						id: s.prefix+'-'+$that.attr('id')+'-'+type+'-thumbs'
					}).addClass(s.prefix+'-'+type+'-thumbs').insertAfter(that);
					
					// In case we want to show image captions, create an element for it:
					
					if (options.showcaptions == 'yes'){
						var $captiondiv = $('<div/>', {
							id: s.prefix+'-'+$that.attr('id')+'-'+type+'-captions'
						}).addClass(s.prefix+'-'+type+'-captions').text($(images[options.active-1]).attr('title')).insertAfter(that);
					}
					
					// Now loop through all images and add them to the thumbnail div. Add the correct events and 
					// animations to each of them and optionally the lightbox functionality.
					
					$.each( images, function(index, value){
						
						if (options.event != 'click' && options.lightbox == 'yes'){
							plugin.executeCommand($(value), 'lightbox', { 'group': s.prefix+'-'+$that.attr('id')+'-'+type });
						}
						
						if (options.active-1 == index){
							$(value).addClass(s.activeClass);
						}
						
						$(value)
							.on( options.event, function() {
								
								plugin.triggerEvent('hideentry', $that, options);
								
								$that.jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
									$that.find('img').attr('src', $(value).attr('src'));
									
									if (options.lightbox == 'yes'){
										plugin.executeCommand($that.find('img').unbind('click'), 'lightbox', {});
									}
									
									plugin.triggerEvent('showentry showentry'+(index+1), $that, options);
									
									$that.jKit_effect(true, options.animation, options.speed, options.easing, 0);
									$thumbdiv.find('img').removeClass(s.activeClass);
									$(value).addClass(s.activeClass);
									
									if (options.showcaptions == 'yes'){
										$captiondiv.text($(value).attr('title'));
									}
								});
									
							})
							.css({ 'cursor': 'pointer' })
							.appendTo($thumbdiv);
					});
					
					break;
				
				
				// {!} codeblock: /command-gallery, command-tabs


				// ##### Tabs Command
				//
				// The [tabs command](http://jquery-jkit.com/commands/tabs.html) is used to create a tab navigation
				// of different content elements.
				
				case 'tabs':
					
					// First try to find out which kind of HTML elements are used to structure the data:
					
					var containerTag = plugin.findElementTag($that, '>', 'max', 'div');
					var titleTag = plugin.findElementTag($that, '> '+containerTag+' >', 0, 'h3');
					var contentTag = plugin.findElementTag($that, '> '+containerTag+' >', 1, 'div');
					
					// Next we need to create an array the contains all the tab titles and content:
					
					var tabs = [];
					$that.children(containerTag).each( function(){
						tabs.push({ 'title': $(this).children(titleTag).html(), 'content': $(this).children(contentTag).detach() });
					});
					
					// Prepare the original element so that we can add the navigation:
					
					$that.html('');
					var $tabnav = $('<ul/>', { }).appendTo(that);
					
					// We need a jQuery element right now but can only set it after the following loop has finished:  
					
					var $tabcontent = $;
					
					$.each( tabs, function(index, value){
						
						// Create a list element and add it to the tab naviagtion:
						
						var $litemp = $('<li/>', { }).html(value.title).css('cursor', 'pointer').appendTo($tabnav);
						
						// Is this tab active? If yes, add the "active" class:
						
						if (options.active-1 == index){
							$litemp.addClass(s.activeClass);
						}
						
						// Create a callback for each list and fire it on the click event:
						
						// {!} task: Was there a reason for this callback variable? Can't we just use an anonymos function inside the event?
						
						var callback = function(){
							plugin.triggerEvent('showentry showentry'+(index+1), $that, options);
							
							$tabcontent.jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
								$(this).remove();
								$tabcontent = tabs[index].content.appendTo($that).hide();
								$tabcontent.jKit_effect(true, options.animation, options.speed, options.easing);
							});
							
							$tabnav.find('li').removeClass(s.activeClass);
							$tabnav.find('li:nth-child('+(index+1)+')').addClass(s.activeClass);
						};
						
						$litemp.on( 'click ', function(){
							callback();
						});
						
					});
					
					// Do we have to display an initial content or do we start without a tab selected?
					
					if (tabs[options.active-1] != undefined){
						$tabcontent = tabs[options.active-1].content.appendTo($that);
					}
					
					break;
				
				
				// {!} codeblock: /command-tabs, command-accordion

				
				// ##### Accordion Command
				//
				// The [accordion command](http://jquery-jkit.com/commands/accordion.html) creates a content navigation
				// that acts like an accordion.
					
				case 'accordion':
					
					// First try to find out which kind of HTML elements are used to structure the data:
					
					var containerTag = plugin.findElementTag($that, '>', 'max', 'div');
					var titleTag = plugin.findElementTag($that, '> '+containerTag+' >', 0, 'h3');
					var contentTag = plugin.findElementTag($that, '> '+containerTag+' >', 1, 'div');
					
					// Next we need to create an array that contains all the titles and content (yes, this
					// is so similar to the tabs command, that even the array is called "tabs"):
					
					// {!} task: Can we save code if we combine this one and the tab command? They are very similar!
					
					var tabs = [];
					$that.children(containerTag).each( function(){
						tabs.push({
							'title': $(this).children(titleTag).detach(),
							'content': $(this).children(contentTag).detach()
						});
					});
					
					// Prepare the original element so that we can add the navigation:
					
					$that.html('');
					var $tabnav = $('<ul/>', { }).appendTo(that);
					
					var current = 1;
					if (options.active == 0) current = -1;
					
					// Loop through each element and create the correct data structure with all events and animations:
					
					$.each( tabs, function(index, value){
						
						var $litemp = $('<li/>', { }).append(value.title).css('cursor', 'pointer').appendTo($tabnav);
						
						if (options.active-1 == index){
							$litemp.append(value.content).children(titleTag).addClass(s.activeClass);
							current = index;
						} else {
							$litemp.append(value.content.hide());
						}
						
						$litemp.find('> '+titleTag).on( 'click', function(e){
							if (index != current){
								plugin.triggerEvent('showentry showentry'+(index+1), $that, options);
								$tabnav.find('> li > '+titleTag).removeClass(s.activeClass);
								$(this).addClass(s.activeClass);
								if (options.animation == 'slide'){
									$tabnav.find('> li:nth-child('+(current+1)+') > '+contentTag).slideUp(options.speed, options.easing);
									$tabnav.find('> li:nth-child('+(index+1)+') > '+contentTag).slideDown(options.speed, options.easing);
								} else {
									$tabnav.find('> li:nth-child('+(current+1)+') > '+contentTag).hide();
									$tabnav.find('> li:nth-child('+(index+1)+') > '+contentTag).show();
								}
								current = index;
							} else {
								plugin.triggerEvent('hideentry hideentry'+(index+1), $that, options);
								$(this).removeClass(s.activeClass).next().slideUp(options.speed, options.easing);
								current = -1;
							}
						});
					
					});
					
					break;
				
				
				// {!} codeblock: /command-accordion, command-parallax


				// ##### Parallax Command
				//
				// The [parallax command](http://jquery-jkit.com/commands/parallax.html) is used to create a parallax scrolling
				// effect with different layers that look like a 3D scenery. Sidescrolling games in the old days used this kind 
				// of faked 3D effect quite a lot.
					
				case 'parallax':
					
					var strength = options.strength / 10;
					
					// We have to attach our event to different DOM elements based on the the type of parallax we want.
					// The first option will use window scrolling to set the position of each layer, the other two use
					// the mouse position for that.
					
					if (options.detect == 'scroll'){
						var $capture = $(window);
					} else if (options.scope == 'global'){
						var $capture = $(document);
					} else {
						var $capture = $that;
					}
					
					// Set the correct event:
					
					$capture.on( options.detect, function(event) {
						
						// We only want to go through all calculations if needed, so check if our element is inside the viewport 
						// and that the window has focus:
						
						if ((windowhasfocus || !windowhasfocus && s.ignoreFocus) && ($that.jKit_inViewport() || !$that.jKit_inViewport() && s.ignoreViewport)){
							var cnt = 1;
							
							// Get either the scroll or the mouse position:
							
							if (options.detect == 'scroll'){
								var xaxis = $(window).scrollLeft() + $(window).width() / 2;
								var yaxis = $(window).scrollTop() + $(window).height() / 2;
							} else {
								var xaxis = event.pageX;
								var yaxis = event.pageY;
							}
							
							// Loop through each layer and set the correct positions of each one of them:
							
							$that.children().each( function(){
								
								var box = $that.offset();
								
								if (options.axis == 'x' || options.axis == 'both'){
									var offsetx = (xaxis-box.left-($that.width()/2))*strength*cnt*-1 - $(this).width()/2 + $that.width()/2;
									$(this).css({ 'left': offsetx+'px' });
								}
								if (options.axis == 'y' || options.axis == 'both'){
									var offsety = (yaxis-box.top-($that.height()/2))*strength*cnt*-1 - $(this).height()/2 + $that.height()/2;
									$(this).css({ 'top': offsety+'px' });
								}
								
								cnt++;
							
							});
						}
					
					});
					
					break;
				
				
				// {!} codeblock: /command-parallax, command-menu


				// ##### Menu Command
				//
				// The [menu command](http://jquery-jkit.com/commands/menu.html) adds some additional features 
				// to a CSS based menu.
					
				case 'menu':
					
					// Add an active class to the menu link that matches the current page url:
					
					if (options.autoactive == 'yes'){
						
						var path = window.location.toString().split('#')[0].split("/");
						
						$that.find("a").filter(function() {
							return $(this).attr("href") == path[path.length-1];
						}).addClass(s.activeClass);
						
					}
					
					// Add mouseover events and a click event for touch devices:
					
					$that.find("li").hover(function(){
						
						$(this).addClass("hover");
						$('ul:first',this).css('visibility', 'visible');
					
					}, function(){
						
						$(this).removeClass("hover");
						$('ul:first',this).css('visibility', 'hidden');
					
					}).on( 'click', function(){
						
						$(this).addClass("hover");
						$('ul:first',this).css('visibility', 'visible');
					
					});
					
					break;
				
				
				// {!} codeblock: /command-menu, command-form


				// ##### Form Command
				//
				// The [form command](http://jquery-jkit.com/commands/form.html) can convert a regular web form into
				// an ajax submitted form. Additionally it adds various validation options.
				
				case 'form':
					
					// Add a hidden field that will contain a list of required fileds so that our PHP script can check
					// against them.
					
					$that.append('<input type="hidden" name="'+s.prefix+'-requireds" id="'+s.prefix+'-requireds">');
					
					if (options.error != undefined) options.formerror = options.error;
					
					var requireds = [];
					
					// Add an on submit event so that we can do our work before the form is being submitted:
					
					$that.on('submit', function() {
						
						// Create an error array and remove all error nodes previously set:
						
						var errors = [];
						$(this).find('span.'+s.errorClass).remove();
						
						// Parse the validation commands:
						
						// {!} task: Can't we use the default parsing here so that we save code and get all features?
						
						$(this).find("*[rel^=jKit], *["+s.dataAttribute+"]").each( function(){
							
							var rel = $(this).attr('rel');
							var data = $(this).attr(s.dataAttribute);
							
							if (data != undefined){
								var start = data.indexOf('[');
								var end = data.indexOf(']');
								var optionstring = data.substring(start+1, end);
							} else {
								var start = rel.indexOf('[');
								var end = rel.indexOf(']');
								var optionstring = rel.substring(start+1, end);
							}
							
							var options = plugin.parseOptions(optionstring);
							
							var type = options.type;
							var elerror = false;
							var required = false;
							
							if (options.required == undefined) options.required = false;
							
							// Check if this form element is required and if yes, check if there is something entered:
							
							if (options.required == 'true'){
								if ($(this).val() == ''){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'required' } );
								}
								required = true;
								if ($.inArray($(this).attr('name'), requireds) == -1){
									requireds.push($(this).attr('name'));
								}
							}
							
							// Check if we really have to go through all validation checks:
							
							if ((required || $(this).val() != '') || options.type == 'group'){
								
								// Is this a valid email?
								if (options.type == 'email' && !$.fn.jKit_emailCheck($(this).val())){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'email' } );
								}
								
								// Is this a valid url (http:// or https://)?
								if (options.type == 'url' && !$.fn.jKit_urlCheck($(this).val())){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'url' } );
								}
								
								// Is this a valid date?
								if (options.type == 'date' && !$.fn.jKit_dateCheck($(this).val())){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'date' } );
								}
								
								// Is this date older than some other date?
								if (options.type == 'date' &&  (new Date($(this).val()).getTime() <= new Date($(options.older).val()).getTime()) ){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'older' } );
								}
								
								// Is this date younger than some other date?
								if (options.type == 'date' &&  (new Date($(this).val()).getTime() >= new Date($(options.younger).val()).getTime()) ){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'younger' } );
								}
								
								// Is this a valid time?
								if (options.type == 'time' && !$.fn.jKit_timeCheck($(this).val())){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'time' } );
								}
								
								// Is this a valid phone number?
								if (options.type == 'phone' && !$.fn.jKit_phoneCheck($(this).val())){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'phone' } );
								}
								
								// Is this a float?
								if (options.type == 'float' && isNaN($(this).val())){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'float' } );
								}
								
								// Is this a int?
								if (options.type == 'int' && parseInt($(this).val()) != $(this).val()){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'int' } );
								}
								
								// min (numeric)?
								if ((options.type == 'int' || options.type == 'float') && options.min != undefined && $(this).val() < options.min && options.type != 'group'){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'min' } );
								}
								
								// max (numeric)?
								if ((options.type == 'int' || options.type == 'float') && options.max != undefined && $(this).val() > options.max && options.type != 'group'){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'max' } );
								}
								
								// Is this bigger than x (numeric)?
								if ((options.type == 'int' || options.type == 'float') && options.bigger != undefined && $(this).val() > $(options.bigger).val()){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'bigger' } );
								}
								
								// Is this smaller than x (numeric)?
								if ((options.type == 'int' || options.type == 'float') && options.smaller != undefined && $(this).val() < $(options.smaller).val()){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'smaller' } );
								}
								
								// min (length)?
								if ((options.type != 'int' && options.type != 'float') && options.min != undefined && $(this).val().length < options.min && options.type != 'group'){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'minlength' } );
								}
								
								// max (length)?
								if ((options.type != 'int' && options.type != 'float') && options.max != undefined && $(this).val().length > options.max && options.type != 'group'){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'maxlength' } );
								}
								
								// Is the length of the entered string exactly the specified value?
								if (options.length != undefined && $(this).val().length != options.length){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'length' } );
								}
								
								// Is this longer than x (length)?
								if ((options.type != 'int' && options.type != 'float') && options.longer != undefined && $(this).val().length > $(options.longer).val().length){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'longer' } );
								}
								
								// Is this shorter than x (length)?
								if ((options.type != 'int' && options.type != 'float') && options.shorter != undefined && $(this).val().length < $(options.shorter).val().length){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'shorter' } );
								}
								
								// Check password strength (0=bad, 100=perfect)?
								if (options.strength != undefined && $.fn.jKit_passwordStrength($(this).val()) < options.strength){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'strength' } );
								}
								
								// Is this the same as x?
								if (options.same != undefined && $(this).val() != $(options.same).val()){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'same' } );
								}
								
								// Is this different than x?
								if (options.different != undefined && $(this).val() != $(options.different).val()){
									elerror = true;
									errors.push( { 'element': $(this), 'error': 'different' } );
								}
								
								// Has this file the correct extension?
								if (options.type == 'extension'){
									var opts = options.options.split(s.delimiter);
									var filesplit = $(this).val().split('.');
									var ext = filesplit[filesplit.length-1];
									if ($.inArray(ext,opts) == -1) {
										elerror = true;
										errors.push( { 'element': $(this), 'error': 'ext' } );
									}
								}
								
								// Is the correct amount of elements checked in this group?
								if (options.type == 'group'){
									if (options.min != undefined || options.max != undefined){
										var checked = 0;
										$(this).children('input[type=checkbox][checked]').each( function(){
											checked++;
										});
										if ((options.min != undefined && options.min > checked) || (options.max != undefined && checked > options.max)){
											elerror = true;
											errors.push( { 'element': $(this), 'error': 'group' } );
										}
									} else {
										if ($(this).find("input[name='"+options.name+"']:checked").val() == undefined){
											elerror = true;
											errors.push( { 'element': $(this), 'error': 'group' } );
										}
									}
								}
								
								// Call a custom function that checks this field:
								if (options.type == 'custom' && options.checkfunction != undefined){
									var fn = window[options.checkfunction];
									if(typeof fn === 'function') {
										if ( !fn( $(this).val() ) ){
											elerror = true;
											errors.push( { 'element': $(this), 'error': 'custom' } );
										}
									}
								}
							
							}
							
							// Display and error if anything didn't validate correctly:
							
							if (elerror){
								if (options.error != undefined){
									$(this).after('<span class="'+s.errorClass+'">'+options.error+'</span>');
								}
								$(this).addClass(s.errorClass);
							} else {
								$(this).removeClass(s.errorClass);
							}
						
						});
						
						// No errors? Than go on ...
						
						if (errors.length == 0){
							
							// If this form doesn't use an ajax submit, than just fire  the "complete" event:
							
							if (options.validateonly == "yes"){
								
								plugin.triggerEvent('complete', $that, options);
								
								return true;
							
							// This is an ajax submit:
							
							} else {
								
								var action = $(this).attr('action');
								
								$that.removeClass(s.errorClass);
								
								if (options.success == undefined) options.success = 'Your form has been sent.';
								
								// Put all the required fields, comma separated, into the hidden field: 
								
								$that.find('input#'+s.prefix+'-requireds').val(requireds.join(s.delimiter));
								
								// Post send the serialized data to our form script: 
								
								$.post(action, $that.serialize(), function(data, textStatus, jqXHR) {
									$that.find('.'+s.errorClass).hide();
									
									// Check if everything got through correctly:
									
									if (data.sent != undefined && data.sent == true){
										if (options.success.charAt(0) == '#'){
											$that.html($(options.success).show());
										} else {
											$that.html('<p class="'+s.successClass+'">'+options.success+'</p>');
										}
										plugin.triggerEvent('complete', $that, options);
										if (options.macro != undefined) plugin.applyMacro($that, options.macro);
									} else {
										for (x in data.error){
											var field = data.error[x];
											$that.find('*[name='+field+']').addClass(s.errorClass).after('<span class="'+s.errorClass+'">'+options.error+'</span>');
										}
										plugin.triggerEvent('error', $that, options);
									}
								
								// Something didn't really work. Is there even a compatible form script? Show error:
									
								}).error(function(xhr, ajaxOptions, thrownError){
									alert(thrownError);
									$that.append('<span class="'+s.errorClass+'">There was an error submitting the form: Error Code '+xhr.status+'</span>');
								});
								
								// Return **false** so that the browser doesn't submit the form himself:
								
								return false;
							
							}
						
						} else {
							
							// Do we have to display an error for the whole form?
							
							$that.addClass(s.errorClass);
							if (options.formerror != undefined){
								$that.append('<span class="'+s.errorClass+'">'+options.formerror+'</span>');
							}
							plugin.triggerEvent('error', $that, options);
							
							// Return **false** so that the browser doesn't submit the form himself:
							
							return false;
						}
					
					});
					
					break;
				
				
				// {!} codeblock: /command-form, command-plugin


				// ##### Plugin Command
				//
				// The [plugin command](http://jquery-jkit.com/commands/plugin.html) makes it possible to add jQuery plugins
				// that can be used the same way as jKit commands.
					
				case 'plugin':
					
					// First check if this is a plugin we registered on plugin init:
					
					if (s.plugins[options.script] != undefined){
						
						options.functioncall = s.plugins[options.script]['fn'];
						if (s.plugins[options.script]['option'] != undefined){
							options.option = s.plugins[options.script]['option'];
						}
						
						options.script = s.plugins[options.script]['path'];
					}
					
					// Temporarly enable ajax caching:
					
					$.ajaxSetup({ cache: true });
					
					// 
					
					if (options.script != undefined){
						
						// Load the script from the server:
						
						$.getScript(options.script, function() {
							
							// The plugin has loaded, now all we need to do is correctly initialize it
							// by calling the correct function name with the correct set of parameters:
							
							if (options.option != undefined){
								$that[ options.functioncall ]( options[options.option] );
							} else {
								delete(options.type);
								delete(options.script);
								$that[ options.functioncall ]( options );
							}
							
							plugin.triggerEvent('complete', $that, options);
						
						});
					}
					
					// Stop ajax caching again:
					
					$.ajaxSetup({ cache: false });
					
					break;
				
				
				// {!} codeblock: /command-plugin, command-tooltip


				// ##### Tooltip Command
				//
				// The [tooltip command](http://jquery-jkit.com/commands/tooltip.html) displays additional information for
				// an element on mouseover.
					
				case 'tooltip':
					
					// Create the tooltip div if it doesn't already exist:
					
					if ($('div#'+s.prefix+'-tooltip').length == 0){
						$('<div/>', {
							id: s.prefix+'-'+type
						}).hide().appendTo('body');
					}
					
					$tip = $('div#'+s.prefix+'-'+type);
					
					// Display the tooltip on mouseenter:
					
					$that.on('mouseenter', function(e){
						
						// Has this tooltip custom styling either by class or by supplying color values?
						
						if (options.classname != ''){
							$tip.html(options.text).removeClass().css({ 'background': '', 'color': '' }).addClass(options.classname);
						} else {
							$tip.html(options.text).removeClass().css({ 'background': options.background, 'color': options.color });
						}
						
						// Correctly position the tooltip based on the mouse position:
						
						$tip.css('top', (e.pageY+15-$(window).scrollTop())).css('left', e.pageX);
						
						// Fix the tooltip position so that we don't get tooltips we can't read because their outside
						// the window:
						
						if ( parseInt($tip.css('left')) > $(window).width() / 2 ){
							$tip.css('left', '0px').css('left', e.pageX - $tip.width());
						}
						
						// Stop any possible previous animations and start fading it in:
						
						$tip.stop(true, true).fadeIn(200);
						
						plugin.triggerEvent('open', $that, options);
					
					
					// Fade out the tooltip on mouseleave:
					
					}).on('mouseleave click', function(e){
						
						var speed = 200;
						if ($tip.is(':animated')){
							speed = 0;
						}
						
						$tip.stop(true, true).fadeOut(speed);
						
						plugin.triggerEvent('closed', $that, options);
					
					});
					
					break;
				
				
				// {!} codeblock: /command-tooltip, command-background


				// ##### Background Command
				//
				// The [background command](http://jquery-jkit.com/commands/background.html) adds an image to the background
				// that is scaled to the full width and height of the window, either skewed or just zoomed.
					
				case 'background':
					
					// Create a background element with a negative z-index that is scaled to the full size of the window:
					
					var $bg = $('<div/>', {
						id: s.prefix+'-'+type
					}).css({
						'position': 'fixed',
						'right': '0px',
						'top': '0px',
						'overflow': 'hidden',
						'z-index': '-1',
						'width': $(window).width(),
						'height': $(window).height()
					}).appendTo('body');
					
					$bg.append($that);
					
					var ow = $that.attr('width');
					var oh = $that.attr('height');
					
					// Do the correct scaling of the image:
					
					plugin.scaleFit($bg, $that, ow, oh, options.distort);
					
					// Rescale the image in case the window size changes:
					
					$(window).resize(function() {
						plugin.scaleFit($bg, $that, ow, oh, options.distort);
						plugin.triggerEvent('resized', $that, options);
					});
					
					break;
				
				
				// {!} codeblock: /command-background, command-lorem
				

				// ##### Lorem Command
				//
				// The [lorem command](http://jquery-jkit.com/commands/lorem.html) adds lorem ipsum text or paragraphs to 
				// your element, very usefull for "work in progress" projects.
					
				case 'lorem':
					
					// The lorem ipsum text:
					
					var lorem = [
						'Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
						'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.',
						'Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.',
						'Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.',
						'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.',
						'At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.',
						'Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
					];
					
					var text = '';
					
					// Randomize the paragraphs first?
					
					if (options.random == "yes"){
						lorem = $.fn.jKit_arrayShuffle(lorem);
					}
					
					// Add a specific number of paragraphs:
					
					if (options.paragraphs > 0){
					
						for ( var i=1; i<=options.paragraphs; i++ ) {
							text += '<p>'+lorem[(i-1)%7]+'</p>';
						}
					
					// Or add a specific number of characters: 	
						
					} else {
						if (options.length != undefined && options.length != ''){
							
							var i=1;
							
							while(text.length < options.length-1){
								text += lorem[(i-1)%7]+' ';
								text = text.substring(0, options.length-1);
								i++;
							}
						
						} else {
							text = lorem[0];
						}
					}
					
					$that.html(text);
					
					break;
				
				
				// {!} codeblock: /command-lorem, command-binding
				

				// ##### Binding Command
				//
				// The [binding command](http://jquery-jkit.com/commands/binding.html) lets you bind different 
				// kind of values and even functions to different things, for example attributes. It's a very
				// powerfull command with tons of options.
				
				case 'binding':
					
					window.setTimeout( function() { plugin.binding($that, options); }, 0);
					
					break;
				
				
				// {!} codeblock: /command-binding, command-limit

				
				// ##### Limit Command
				//
				// The [limit command](http://jquery-jkit.com/commands/limit.html) either limts the
				// characters of a string or the elements inside a container by a set number.
				
				case 'limit':
					
					// Limit the number of elements. Set speed to zero if you want to hide them immediately
					// or use an animation:
					
					if (options.elements == 'children'){
						
						$that.children(':gt('+(options.count-1)+')').each(function(){
							$(this).jKit_effect(false, options.animation, options.speed, options.easing);
						});
						
						setTimeout( function(){
							plugin.triggerEvent('complete', $that, options);
						}, options.speed);
					
					// Limit the number of characters in a string:
					
					} else {
						
						var newtext = $that.text().substr(0,options.count);
						
						// Add an endstring if needed:
						
						if (newtext != $that.text()){
							newtext = newtext.substr(0,newtext.length-options.endstring.length)+options.endstring;
							$that.text(newtext);
						}
						
					}
					
					break;
				
				
				// {!} codeblock: /command-limit, command-template


				// ##### Template Command
				//
				// The [template command](http://jquery-jkit.com/commands/template.html) implements a simple 
				// templating engine.
					
				case 'template':
				
					// Apply a template or define a new one?
					
					if (options.action == 'apply'){
						
						$el = $that;
						
						// Do we have to apply the template to more than one element?
						
						if (options.children != undefined && options.children != ''){
							
							$el = $that.children(options.children);
							
							var cnt = 0;
							$el.each( function(){
								cnt++;
								plugin.applyTemplate($(this), options, cnt, $el.length);
							});
						} else {
							plugin.applyTemplate($that, options);
						}
						
						// If this is a dynamic template, we need to create the *add div* that
						// acts like a button and adds a new element with the correct options:
						
						if (options.dynamic == 'yes'){
							var $addDiv = $('<a/>', {
								'class': s.prefix+'-'+type+'-add'
							}).html(options.addhtml).on( 'click', function(){
								
								$el = $($that.get(0));
								
								var cnt = $el.children(options.children).length + 1;
								
								$el.find('.if-entry-last').hide();
								plugin.applyTemplate($('<'+options.children+'/>').appendTo($el), options, cnt, cnt);
								
								plugin.triggerEvent('added', $that, options);
							
							}).insertAfter($that);
						
						}
					
					} else {
						
						// Templates are stored in a "global" plugin array:
						
						if (templates[options.name] == undefined){
							templates[options.name] = [];
						}
						
						// Define the dynamic variables:
						
						if (options.vars == undefined){
							var vars = [];
						} else {
							var vars = options.vars.split(s.delimiter);
						}
						
						// Add the template to the "global" array:
						
						templates[options.name] = { 'template': $that.detach(), 'vars': vars };
					
					}
					
					break;
					
					// {!} codeblock: /command-template
			
			}
			
			return $that;
		
		};
		
		
		// ### filterElements
		//
		// The **filterElements** function is used by the filter command. It's doing the heavy lifting for the command.
		
		plugin.filterElements = function($el, options){
			
			// First we need to go through each filter element to find out by what we have to filter the affected
			// elemnts. We're splitting each elements value to get the separate words into an array.
			
			var selections = [];
			
			$el.find('.jkit-filter').each( function(){
				var vals = [];
				var valsplit = $(this).val().split(' ');
				$.each( valsplit, function(i,v){
					v = $.trim(v);
					if (v != '') vals.push(v);
				});
				selections = selections.concat(vals);
			});
			
			// Where do we have to look for our affected DOM nodes? Inside the body or inside the current element?
			
			if (options.global == 'yes'){
				$container = $('body');
			} else {
				$container = $el;
			}
			
			// Loop through all affected elements and check if they have to be displayed or not.
			
			$container.find(options.affected).each( function(){
				
				// First create a few cashes to speed up the following loop through the filter selections:
				
				var $current = $(this);
				
				if (options.by == 'text'){
					var currentText = $current.text().toLowerCase();
				}
				
				if (selections.length > 0){
					
					// As we have two options, one where we need to find each selection and one where we
					// only have to find one of the selections, we first have to create an array with all
					// found selections:
					
					var found = [];
					
					$.each( selections, function(i,v){
						if (options.by == 'class'){
							if ($current.hasClass(v)){
								found.push(v);
							}
						} else if (options.by == 'text'){
							if (currentText.indexOf(v.toLowerCase()) > -1){
								found.push(v);
							}
						}
					});
					
					// Hide or show the element based on our search result:
					
					if ( found.length == selections.length || (found.length > 0 && options.logic == 'or') ){
						$current.jKit_effect(true, options.animation, options.speed, options.easing, 0);
					} else {
						$current.jKit_effect(false, options.animation, options.speed, options.easing, 0);
					}
				
				} else {
					$current.jKit_effect(true, options.animation, options.speed, options.easing, 0);
				}
			
			});
			
			// Fire the complete event at the right time and hide the optional loader animation:
			
			setTimeout( function(){
				if (options.loader !== undefined) $(options.loader).hide();
				plugin.triggerEvent('complete', $el, options);
			}, options.speed);
		
		};
		
		
		// ### readAPI
		//
		// The **readAPI** function is used by the API command. It is currently able to read JSONP APIs and
		// use an optional template to display the result.
		
		plugin.readAPI = function($el, options){
			
			if (options.format == 'json'){
				
				// Create an ajax jsonp request:
				
				$.ajax({
					type: "GET",
					url: options.url,
					contentType: "application/json; charset=utf-8",
					dataType: "jsonp",
					error: function(){
						plugin.triggerEvent('error', $el, options);
					},
					success: function(data) {
						
						// If a template is supplied in the options, use it to display the data we just received:
						
						if (options.template != ''){
							
							// First we add the template HTML to our element:
							
							$el.html(templates[options.template].template.clone().show());
							
							// Than we add the data to each element that has the **data-jkit-api** attribute:
							
							$el.find('[data-jkit-api]').each(function(){
								var value = $(this).attr('data-jkit-api');
								try {
									$(this).text(eval('data.'+value.replace(/[^a-zA-Z0-9\.\[\]\_]+/g, '')));
								} catch(err) { }
							});
							
							// And lastly, we remove all elements that have the **data-jkit-api-if** attribute, but
							// didn't get a value from the API:
							
							$el.find('[data-jkit-api-if]').each(function(){
								var value = $(this).attr('data-jkit-api-if');
								var test = undefined;
								try {
									eval('test = data.'+value.replace(/[^a-zA-Z0-9\.\[\]\_]+/g, ''));
								} catch(err) { }
								if (test == undefined){
									$(this).remove();
								}
							});
							
						// In case we don't use a template, just add the specified value as text to the element:
						
						} else {
							
							if (options.value != ''){
								try {
									$el.text(eval('data.'+options.value.replace(/[^a-zA-Z0-9\.\[\]\_]+/g, '')));
								} catch(err) { }
							} else {
								$el.text(data);
							}
						
						}
						
						// Trigger some stuff now as everythimng is set up:
						
						if (options.macro != undefined) plugin.applyMacro($el, options.macro);
						plugin.triggerEvent('complete', $el, options);
						
						// Do we have to read the API in a specific interval? If yes, set a timeout:
						
						if (options.interval > -1){
							setTimeout( function(){
								plugin.readAPI($el, options);
							}, options.interval*1000);
						}
					
					}
				});
			}
		
		};
		
		
		// ### triggerEvent
		//
		// The **triggerEvent** function is used by various commands to trigger an event on an element with
		// the commands options added to it:
		
		plugin.triggerEvent = function(event, $el, options){
			
			if (options.commandkey !== undefined){
				
				var eventsplit = event.split(' ');
				
				$.each( eventsplit, function(i,v){
					$element.trigger(options.commandkey+'.'+v, { 'element': $el, 'options': options });
				});
			
			}
		
		};
		
		
		// ### cssFromString
		//
		// The **cssFromString** function is used by the animation command. It parses a specially formated string
		// and creates an object that contains all CSS data. Here's an exmaple of the string format:
		//
		//     width(50%),height(50px)
		//
		
		plugin.cssFromString = function(css){
			
			var partsplit = css.split(',');
			var cssdata = {};
			
			$.each( partsplit, function(i,v){
				
				var innersplit = v.split('(');
				
				if (innersplit.length == 2){
					var property = innersplit[0];
					var value = innersplit[1].slice(0,-1);
					cssdata[property] = value;
				}
				
			});
			
			return cssdata;
		};
		
		
		// ### preFix
		//
		// The **preFix** function is used by the encode command to remove unneaded tab stops from
		// the beginning of each line of a code block.
		
		plugin.preFix = function(str){
			
			var lines = str.split("\n");
			var min = 9999;
			
			$.each( lines, function(i,v){
				if ($.trim(v) != ''){
					
					var cnt = -1;
					
					while(v.charAt(cnt+1) == "\t"){
						cnt++;
					}
					cnt++;
					
					if (cnt < min){
						min = cnt;
					}
				
				}
			});
			
			$.each( lines, function(i,v){
				lines[i] = v.substr(min);
			});
			
			return lines.join("\n");
		};
		
		
		// ### ticker
		//
		// The **ticker** function is used by the ticker command.
		
		plugin.ticker = function($el, options, messages, currentmessage, currentchar){
			
			// The **stopped** variable is used in case the ticker isn't looped:
			
			var stopped = false;
			
			// We only run the ticker animation if the element is inside the viewport and the window in focus:
			
			if ((windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus) && ($el.jKit_inViewport() || !$el.jKit_inViewport() && plugin.settings.ignoreViewport)){
				
				var timer =  options.speed;
				currentchar++;
				
				// Check if we're at the end of the current ticker message. If yes, start with the next message:
				
				if (currentchar > messages[currentmessage].text.length){
					
					timer = options.delay;
					
					currentmessage++;
					if (currentmessage >= messages.length){
						if (options.loop == 'yes' && messages.length > 1){
							currentmessage = 0;
						} else {
							stopped = true;
						}
					}
					
					if (!stopped){
						setTimeout( function(){
							plugin.triggerEvent('showentry showentry'+(currentmessage+1), $el, options);
						}, timer);
					
						currentchar = 0;
					}
				
				// We are still on the same message, so just display the current amaount of characters, either inside a link or
				// as text:
				
				} else {
					if (messages[currentmessage].href != undefined){
						$el.html('<a href="'+messages[currentmessage].href+'" target="'+messages[currentmessage].target+'">'+messages[currentmessage].text.substr(0,currentchar)+'</a>');
					} else {
						$el.html(messages[currentmessage].text.substr(0,currentchar));
					}
				}
			}
			
			// Set a timeout that starts the next step:
			
			if (!stopped){
				window.setTimeout( function() { plugin.ticker($el, options, messages, currentmessage, currentchar); }, timer);
			}
		
		};
		
		
		// ### loadAndReplace
		//
		// The **loadAndReplace** function is used by the ajax command. It basically loads an urls full data and than
		// looks for a specific element isnide that data. It than replaces that element with the same element on the 
		// current page.
		
		plugin.loadAndReplace = function(href, options, $el){
			
			// Create an unique temporary id we can use to store and access our loaded content.
			
			var tempid = plugin.settings.prefix+'_ajax_temp_'+$.fn.jKit_getUnixtime();
			
			// Hide the affected element:
			
			$(options.element).jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
				
				// Prepare the current element and create a div we use to store the loaded content:
				
				$(options.element).html('');
				
				jQuery('<div/>', {
					id: tempid
				}).appendTo('body');
				
				// Load the content from the supplied url and tell jQuery which element we need from it:
				
				$('#'+tempid).load(href+' '+options.element, function() {
					
					// Add the content from our temporary div to our real element and initialize the content
					// in case there are an jKit commands on it:
					
					$(options.element).html( $('#'+tempid+' '+options.element).html() );
					plugin.init($(options.element));
					
					// Trigger some stuff and show the content we just added:
					
					plugin.triggerEvent('complete', $el, options);
					
					$(options.element).jKit_effect(true, options.animation, options.speed, options.easing);
					
					if (options.macro != undefined) plugin.applyMacro($(options.element), options.macro);
					
					// Remove our temporary item:
					
					$('#'+tempid).remove();
				
				});
			
			});
		
		};
		
		
		// ### updateSrc
		//
		// The **updateSrc** function is used by the live command. It changes the src url in a way that forces the browser
		// to reload the src from the server.
		
		plugin.updateSrc = function($el, options){
			
			if ((windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus) && ($el.jKit_inViewport() || !$el.jKit_inViewport() && plugin.settings.ignoreViewport)){
				
				var srcSplit = $el.attr('src').split('?');
				
				$el.attr('src', srcSplit[0]+'?t='+$.fn.jKit_getUnixtime());
			
			}
		
		};
		
		
		// ### applyTemplate
		//
		// The **applyTemplate** function is used by the template command. It adds the template with all it's
		// options to the suoplied element.
		
		plugin.applyTemplate = function($el, options, cnt, entries){
			
			// Loop through each template variable, find the correct element inside the supplied content element,
			// init each of the elements in case there are any jKit commands on them and finally store the value or HTML
			// in an array.
			
			var content = {};
			$.each( templates[options.name].vars, function(i,v){
				var $subEls = $el.find('.'+v);
				plugin.init($subEls);
				if ($subEls.val() != ''){
					content[v] = $subEls.val();
				} else {
					content[v] = $subEls.html();
				}
			});
			
			// Now add the template to the container element:
			
			$el.html(templates[options.name].template.clone().show());
			
			// Hide all elements that have an **if-entry-x** class. We later show them again if needed.
			
			$el.find('[class^="if-entry-"]').hide();
			
			// Rename dynamic attributes so that we don't get dublicate ids:
			
			plugin.renameDynamicAttributes($el, cnt);
			
			// Add the content and show hidden elements if needed:
			
			$.each( templates[options.name].vars, function(i,v){
				
				var $subEl = $el.find('.'+v);
				
				if ($subEl.is("input") || $subEl.is("select") || $subEl.is("textarea")){
					$subEl.val(content[v]);
				} else {
					$subEl.html(content[v]);
				}
				
				if (content[v] == undefined && $el.find('.if-'+v).length > 0){
					$el.find('.if-'+v).remove();
				}
				
				if (cnt == 1) $el.find('.if-entry-first').show();
				if (cnt == entries) $el.find('.if-entry-last').show();
				$el.find('.if-entry-nr-'+cnt).show();
			
			});
		
		};
		
		
		// ### renameDynamicAttributes
		//
		// The **renameDynamicAttributes** function is used by the **plugin.applyTemplate** function. It's 
		// used to rename attributes on dynamic elements so that we get unique elements.
		
		plugin.renameDynamicAttributes = function($el, cnt){
			$el.find('[class^="dynamic-"]').each( function(){
				
				var $subEl = $(this);
				var classList = $(this).attr('class').split(/\s+/);
				
				$.each( classList, function(i,v){
					
					var attribute = v.substr(8);
					
					if (attribute != '' && $subEl.attr(attribute)){
						
						var currentAttr = $subEl.attr(attribute);
						var pos = currentAttr.lastIndexOf('_');
						if (pos > -1){
							currentAttr = currentAttr.substr(0,pos);
						}
						
						$subEl.attr(attribute, currentAttr+'_'+cnt);
					
					}
				
				});
			
			});
		};
		
		
		// ### binding
		//
		// The **binding** function is used by the binding command. It connects different things to other things.
		// It's a really powerfull function with many options.
		
		plugin.binding = function(el, options){
			
			// Only run the code if the window has focus:
			
			if (windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus){
				
				// First we need to get our value or multiple values that we later convert into one. 
				// Only run the following code if we didn't bind to a function already.
				
				if (options.value == undefined){
					
					// If the selector option is set, we don't use a variable for our source, that means
					// we have to get our variable from the selector element:
					
					if (options.selector != ''){
						
						// The selector can have multiple elements that we have to check. And the source option
						// can be separated with a dot, so prepare those two things first:
						
						var selsplit = options.selector.split('|');
						var sourcesplit = options.source.split('.');
						
						// Now create an array that holds one or all of our values and run through each selector:
						
						var values = [];
						$.each(selsplit, function(i, v) {
							
							// The selector is either a jQuery selector string or "this" that references the 
							// current element or "parent" that references the parent of the current element.
							
							if (v == 'this'){
								v = el;
							} else if (v == 'parent'){
								v = $(el).parent().get(0);
							}
							
							// A jQuery selector string can match more than one string, so run through all of them:
							
							$(v).each( function(){
								
								// The source option defines from where exactly we get our value. There are quite
								// a few options.
								
								switch(sourcesplit[0]){
									
									// We can trigger this binding by an event. This will simply call this function again
									// as soon as the event fires with the value set to 1.
									
									case 'event':
										
										$(this).on( sourcesplit[1], function(e){
											options.value = 1;
											plugin.binding(el, options);
											if (options.macro != undefined) plugin.applyMacro($(el), options.macro);
										});
										
										break;
									
									// "html" will get the HTML of the element:
										
									case 'html':
										
										var temp = $(this).html();
										
										break;
									
									// "text" will get the putre text of the element:
									
									case 'text':
										
										var temp = $(this).text();
										
										break;
									
									// "attr" will get a specific attribute that is specified after the dot, for example
									// **attr.id**:
									
									case 'attr':
										
										var temp = $(this).attr(sourcesplit[1]);
										
										break;
									
									// "css" will get a specific css value that is specified after the dot, for example
									// **css.width**. Many of the options will be calculated by jQuery so that we get
									// the correct result in any browser.
									
									case 'css':
										if (sourcesplit[1] == 'height'){
											var temp = $(this).height();
										} else if (sourcesplit[1] == 'innerHeight'){
											var temp = $(this).innerHeight();
										} else if (sourcesplit[1] == 'outerHeight'){
											var temp = $(this).outerHeight();
										} else if (sourcesplit[1] == 'width'){
											var temp = $(this).width();
										} else if (sourcesplit[1] == 'innerWidth'){
											var temp = $(this).innerWidth();
										} else if (sourcesplit[1] == 'outerWidth'){
											var temp = $(this).outerWidth();
										} else if (sourcesplit[1] == 'scrollTop'){
											var temp = $(this).scrollTop();
										} else if (sourcesplit[1] == 'scrollLeft'){
											var temp = $(this).scrollLeft();
										} else {
											var temp = $(this).css(sourcesplit[1]);
										}
										
										break;
									
									// "scroll" will get the page scroll offset, either from top or from the left side: 
									
									case 'scroll':
										
										switch(sourcesplit[1]){
											case 'top':
												var temp = $(window).scrollTop();
												break;
											case 'left':
												var temp = $(window).scrollLeft();
												break;
										}
										
										break;
										
									// "clearance" will calculate the clearence around an element in relation to the window. If
									// nothing is supplied after the dot, each side will be checked.
										
									case 'clearance':
										
										var cTop = el.offset().top-$(window).scrollTop();
										var cBottom = $(window).scrollTop() + $(window).height() - ( el.offset().top + el.height() );
										
										var cRight = ($(window).width() + $(window).scrollLeft()) - (el.offset().left + el.width());
										var cLeft = el.offset().left - $(window).scrollLeft();
										
										switch(sourcesplit[1]){
											case 'bottom':
												var temp = cBottom;
												break;
											case 'top':
												var temp = cTop;
												break;
											case 'right':
												var temp = cRight;
												break;
											case 'left':
												var temp = cLeft;
												break;
											default:
												var temp = Math.min.apply(Math, [ cBottom, cTop, cRight, cLeft ]);
										}
										
										break;
									
									// "has" tries to find out if the element has a specific thing and gives back either
									// true or false:
										
									case 'has':
										
										switch(sourcesplit[1]){
											case 'class':
												var temp = $(this).hasClass(options.search);
												break;
											case 'text':
												var temp = $.fn.jKit_stringOccurrences($(this).text().toLowerCase(), options.search.toLowerCase());
												break;
											case 'attribute':
												var temp = ($(this).attr(options.search) !== undefined);
												break;
											case 'val':
												var temp = $.fn.jKit_stringOccurrences($(this).val().toLowerCase(), options.search.toLowerCase());
												break;
											case 'element':
												var temp = $(this).find(options.search).length;
												break;
											case 'children':
												var temp = $(this).children(options.search).length;
												break;
											case 'hash':
												var temp = (window.location.hash == options.search);
												break;
										}
										
										break;
										
									// "location" needs the second option after the dot and gets something from the location
									// object, for example the hash, like this: **location.hash**
									
									case 'location':
										
										var temp = window.location[sourcesplit[1]];
										
										break;
									
									// "val" will get the value of the element:
									
									case 'val':
									default:
										var temp = $(this).val();
								}
								
								values.push(temp);
							
							});
						});
						
						// If there's a third option supplied with the source, for example **css.height.max**, we use 
						// that to calculate the final valus from all values in the array. If the fird option isn't 
						// supplied, we just take the first value.
						
						if (sourcesplit[2] != undefined){
							var value = '';
							
							switch(sourcesplit[2]){
								case 'max':
									value = Math.max.apply(Math, values);
									break;
								case 'min':
									value = Math.min.apply(Math, values);
									break;
								case 'sum':
									value = values.reduce(function(a,b){return a+b;});
									break;
								case 'avg':
									value = values.reduce(function(a,b){return a+b;}) / values.length;
									break;
							}
						
						} else {
							var value = values[0];
						}
					
					} else if (options.variable != ''){
						var value = window[options.variable];
					}
					
				} else {
					value = options.value;
				}
				
				// In case we have a numeric value, there are a few options more we can apply. The **accuracy**
				// option reduces the accuracy of the value down to this number. The **min** and **max** options
				// limit the value to either a minimum or a maximum value.
				
				if (!isNaN(value) && parseInt(value) == value){
					
					if (options.accuracy != ''){
						value = Math.round(value / options.accuracy) * options.accuracy;
					}
			
					if (options.min != '' && value < options.min){
						value = options.min;
					}
					
					if (options.max != '' && value > options.max){
						value = options.max;
					}
					
				}
				
				// If the **condition** option is set or the current value is a boolean, we have to decide if either the
				// **if** option will be used (if supllied) or the value in the **else** option (if supllied).
				
				var doit;
				var rev = false;
				
				if (options.condition != ''){
					doit = false;
					eval('if ('+options.condition.replace(/[^a-zA-Z 0-9#\<\>\=\.\!\']+/g, '')+') doit = true;');
				} else {
					if (value === false){
						doit = false;
						rev = true;
					} else {
						doit = true;
					}
				}
				
				// Next we add some logic that either fires the **true** or **false** event in case our value changes.
				// To make this possible, we store the value in the "global" commandkeys array entry for the current command call.
				
				if (commandkeys[options.commandkey]['condition'] == undefined || commandkeys[options.commandkey]['condition'] != doit){
					
					if (doit){
						plugin.triggerEvent('true', $(el), options);
					} else {
						plugin.triggerEvent('false', $(el), options);
					}
					
					commandkeys[options.commandkey]['condition'] = doit;
					
				}
				
				if (rev){
					doit = true;
				}
				
				// Use the **if** or **else** value if supplied:
				
				if (!doit && options['else'] != ''){
					doit = true;
					value = options['else'];
				} else if (doit && options['if'] != ''){
					doit = true;
					value = options['if'];
				}
				
				// Time to use the value to set something, but only if the condition wasn't false:
				
				if (doit){
					
					// The math option lets us do some additional calculation on our value:
					
					if (options.math != ''){
						eval('value = '+options.math.replace(/[^a-zA-Z 0-9\+\-\*\/\.]+/g, '')+';');
					}
					
					// Do we have to trigger some additional events?
					
					if (options.trigger == 'yes'){
						if (commandkeys[options.commandkey]['triggervalue'] == undefined || commandkeys[options.commandkey]['triggervalue'] != value){
							if (commandkeys[options.commandkey]['triggervalue'] !== undefined){
								plugin.triggerEvent('notvalue'+commandkeys[options.commandkey]['triggervalue'], $(el), options);
							}
							plugin.triggerEvent('value'+value, $(el), options);
							commandkeys[options.commandkey]['triggervalue'] = value;
						}
					}
					
					// The **mode** option defines what we have to do with our value. There are quite a few options.
					// The **attr** and **css** modes take a second option that is separated with a dot.
					
					var modesplit = options.mode.split('.');
					switch(modesplit[0]){
						case 'text':
							el.text(value);
							break;
						case 'html':
							el.html(value);
							break;
						case 'val':
							el.val(value);
							break;
						case 'attr':
							el.attr(modesplit[1], value);
							break;
						case 'css':
							if (modesplit[1] == 'display'){
								if ($.trim(value) == '' || $.trim(value) == 0 || !value){
									value = 'none';
								} else {
									if (modesplit[2] !== undefined){
										value = modesplit[2];
									}
								}
							}
							
							// CSS values can be animated if needed:
							
							if (options.speed > 0){
								var style = {};
								style[modesplit[1]] =  value;
								el.animate(style, options.speed, options.easing);
							} else {
								el.css(modesplit[1], value);
							}
							break;
						case 'none':
							break;
						default:
							
							// The default behavior is to call a custom function if one exits with that name:
						
							if (modesplit[0] != undefined){
								var fn = window[modesplit[0]];
								if(typeof fn === 'function') {
									fn(value,el);
								}
							}
					}
				}
			
			}
			
			// Do we have to set an interval?
			
			if (options.interval != -1){
				window.setTimeout( function() { plugin.binding(el, options); }, options.interval);
			}
		
		};
		
		
		// ### loop
		//
		// The **loop** function is used by the loop command and basically just shows and hides and element and than starts
		// the next interval.
		
		plugin.loop = function($that, options){
			
			if ((windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus) && ($that.jKit_inViewport() || !$that.jKit_inViewport && plugin.settings.ignoreViewport)){
				
				plugin.triggerEvent('show', $that, options);
				
				$that.jKit_effect(true, options.animation, options.speed1, options.easing1, options.duration1, function(){
					plugin.triggerEvent('hide', $that, options);
					$that.jKit_effect(false, options.animation, options.speed2, options.easing2, options.duration2, plugin.loop($that, options));
				});
			
			} else {
				window.setTimeout( function() { plugin.loop($that, options); }, 100);
			}
		
		};
		
		
		// ### scaleFit
		//
		// The **scaleFit** function is used by the background command. It calculates the correct
		// with, height of the image relative to the window and the correct position inside that
		// window based on those dimensions.
		
		plugin.scaleFit = function(bg, element, originalWidth, originalHeight, distort){
			
			// First set some basic values. We basically just scale the image to the 
			// full width and height of the window.
			
			var w = $(window).width();
			var h = $(window).height();
			
			bg.css({
				'width': w+'px',
				'height': h+'px'
			});
			
			var top = 0;
			var left = 0;
			
			// If we don't want to distort the image, we now have to do some additional calculations:
			
			if (distort == 'no'){
				
				var imgRatio = originalWidth / originalHeight;
				var screenRatio = w / h;
				
				if (imgRatio > screenRatio){
					w = h * imgRatio;
					left = (w - $(window).width()) / 2 * -1;
				} else {
					h = w / imgRatio;
					top = (h - $(window).height()) / 2 * -1;
				}
			
			}
			
			element.css({
				'position': 'fixed',
				'top': top+'px',
				'left': left+'px',
				'width': w+'px',
				'height': h+'px'
			});
		
		};
		
		
		// ### carousel
		//
		// The **carousel** function is used by the carousel command. It moves the carousel either one forward, or
		// one backward.
		
		plugin.carousel = function($el, options, dir){
			
			// Every manual interaction stops the autoplay:
			
			if (dir != undefined){
				options.autoplay = false;
			}
			
			// Only run the carousel if we're inside the viewport and the window has focus:
			
			if ((windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus) && ($el.jKit_inViewport() || !$el.jKit_inViewport() && plugin.settings.ignoreViewport)){
				
				// Check if we're in the middle of an animation:
				
				var isAnimated = false;
				$el.children().each( function(){
					if ( $(this).is(':animated') ) {
						isAnimated = true;
					}
				});
				
				// We only move the carousel if it isn't animating right now:
				
				if (!isAnimated) {
					
					// What number is the last element?
					
					var pos = Math.min(options.limit, $el.children().length);
					
					// Step one forward:
					
					if (dir == 'next' || dir == undefined) {

						plugin.triggerEvent('shownext', $el, options);

						$el.children(':first-child').jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
							$el.append($el.children(':nth-child(1)'));
							$el.children(':nth-child('+pos+')').jKit_effect(true, options.animation, options.speed, options.easing, 0);
						});
					
					// Step one backward:
						
					} else if (dir == 'prev') {

						plugin.triggerEvent('showprev', $el, options);

						$el.children(':nth-child('+pos+')').jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
							$el.prepend( $el.children(':last-child') );
							$el.children(':first-child').jKit_effect(true, options.animation, options.speed, options.easing, 0);
						});
						     
					}
					
				}
				
				// Is autoplay is on? Than set the interval: 
				
				if (options.autoplay == 'yes'){
					window.setTimeout( function() { plugin.carousel($el, options); }, options.interval);
				}
			
			} else {
				window.setTimeout( function() { plugin.carousel($el, options); }, options.interval);
			}
		
		};
		
		
		// ### slideshow
		//
		// The **slideshow** function is used by the slideshow command. It replaces one slide with the next one. This one is
		// is really simple, so not much to comment, just that the old element is first being hidden and than the new one shown,
		// with or whitout an animation.
		
		plugin.slideshow = function(slides, current, el, options){
			
			if ($.data(el, 'anim')){
				if ((windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus) && (el.jKit_inViewport() || !el.jKit_inViewport() && plugin.settings.ignoreViewport)){
					
					if (current < (slides.length-1)){
						current++;
					} else {
						current = 0;
					}
					
					plugin.triggerEvent('hideentry hideentry'+(current+1), el, options);
					
					el.jKit_effect(false, options.animation, options.speed, options.easing, 0, function(){
						el.html(slides[current]);
						
						plugin.triggerEvent('showentry showentry'+(current+1), el, options);
						
						el.jKit_effect(true, options.animation, options.speed, options.easing, 0, function(){
							window.setTimeout( function() { plugin.slideshow(slides, current, el, options); }, options.interval);
						});
					});
				
				} else {
					window.setTimeout( function() { plugin.slideshow(slides, current, el, options); }, options.interval);
				}
			}
		
		};
		
		
		// ### animation
		//
		// The **animation** function is used by the animation command, but only in case it's a keyframe animation.
		
		plugin.animation = function(frames, current, el, options){
			
			if ((windowhasfocus || !windowhasfocus && plugin.settings.ignoreFocus) && (el.jKit_inViewport() || !el.jKit_inViewport() && plugin.settings.ignoreViewport)){
				
				plugin.triggerEvent('showframe showframe'+(current+1), el, options);
				
				// Loop through each frame and run the frames action in case it matches the current frame number:
				
				$.each( frames, function(index, value){
					if (value.start == current){
						
						// First add the new element by cloning it from the frames object and calculate the duration
						// this frame is visible:
						
						el.html(value.el.clone());
						var duration = (value.end - value.start) * options.interval;
						
						// Depending on the action that is set for this frame, we need to start different kind of animations:
						
						if (value.action == 'fadeout'){
							el.children(":first").show().fadeTo(duration, 0, value.easing);
						} else if (value.action == 'fadein'){
							el.children(":first").hide().fadeTo(duration, 1, value.easing);
						} else if (value.action == 'fadeinout'){
							el.children(":first").hide().fadeTo(duration/2, 1, value.easing).fadeTo(duration/2, 0, value.easing);
						} else if (value.action == 'tween'){
							var next = frames[index+1].el;
							el.children(":first").animate({
								'font-size': next.css('font-size'),
								'letter-spacing': next.css('letter-spacing'),
								'color': next.css('color'),
								'opacity': next.css('opacity'),
								'background-color': next.css('background-color'),
								'padding-top': next.css('padding-top'),
								'padding-bottom': next.css('padding-bottom'),
								'padding-left': next.css('padding-left'),
								'padding-right': next.css('padding-right')
							}, duration, value.easing);
						}
					
					}
				})
				
				// Move one step forward:
				
				current++;
				var nextloop = false;
				if (current > options.lastframe){
					current = 0;
					nextloop = true;
				}
				
				// Is the animation finsihes or do we have to go to the next step?
				
				if ((nextloop && options.loop == "yes") || !nextloop){
					window.setTimeout( function() { plugin.animation(frames, current, el, options); }, options.interval);
				}
				
				// Some additional stuff to trigger in case the animation is finished:
				
				if (options.loop == "no"){
					if (options.macro != undefined) plugin.applyMacro(el, options.macro);
					plugin.triggerEvent('complete', el, options);
				}
			
			} else {
				window.setTimeout( function() { plugin.animation(frames, current, el, options); }, options.interval);
			}
		
		};
		
		
		// ### closeLightbox
		//
		// The **closeLightbox** function is used by the lightbox command to close the active lightbox programmatically
		// from inside the lightbox content.
		
		plugin.closeLightbox = function(){
			$('.'+plugin.settings.prefix+'-lightbox-el').fadeTo('fast', 0, function(){
				$(this).remove();
			});
		};
		
		
		// ### addKeypressEvents
		//
		// The **addKeypressEvents** function is used by the key command and adds a specific keycode event 
		// to an element.
		
		plugin.addKeypressEvents = function($el, code){
			
			// Check first if key navigations aren't globally switched off:
			
			if (plugin.settings.keyNavigation){
				
				// Listen to the documents keydown event:
				
				$(document).keydown(function(e){
					
					// Only add the event if this isn't a textaream, select or text input:
					
					if ( this !== e.target && (/textarea|select/i.test( e.target.nodeName ) || e.target.type === "text") ) return;
					
					// Map keycodes to their identifiers:
					
					var keys = {
						8: "backspace",
						9: "tab",
						13: "return",
						16: "shift",
						17: "ctrl",
						18: "alt",
						19: "pause",
						20: "capslock",
						27: "esc",
						32: "space",
						33: "pageup",
						34: "pagedown",
						35: "end",
						36: "home",
						37: "left",
						38: "up",
						39: "right",
						40: "down",
						45: "insert",
						46: "del",
						96: "0",
						97: "1",
						98: "2",
						99: "3",
						100: "4",
						101: "5",
						102: "6",
						103: "7",
						104: "8",
						105: "9",
						106: "*",
						107: "+",
						109: "-",
						110: ".",
						111 : "/",
						112: "f1",
						113: "f2",
						114: "f3",
						115: "f4",
						116: "f5",
						117: "f6",
						118: "f7",
						119: "f8",
						120: "f9",
						121: "f10",
						122: "f11",
						123: "f12",
						144: "numlock",
						145: "scroll",
						191: "/",
						224: "meta"
					};
					
					// Add the alphabet:
					
					for(var i=48; i<=90; i++){
						keys[i] = String.fromCharCode(i).toLowerCase();
					}
					
					if ($.inArray(e.which, keys)){
						
						// Add special keys:
						
						var special = '';
						if (e.altKey) special += 'alt+';
						if (e.ctrlKey) special += 'ctrl+';
						if (e.metaKey) special += 'meta+';
						if (e.shiftKey) special += 'shift+';
						
						var keycode = special+keys[e.which];
						
						// If the code matches, trigger the event:
						
						if (keycode == code){
							$el.trigger(special+keys[e.which]);
							e.preventDefault();
						}
					
					}
				
				});
			}
		}
		
		// Start the plugin by running the initialization function:
		
		plugin.init();
	
	};
	
	
	// ## jQuery Plugin Functions
	//
	// The following functions act as jQuery plugins.
	
	
	// ### jKit_effect
	//
	// The **jKit_effect** plugin function is used by all kind of jKit commands that perform animations. 
	
	$.fn.jKit_effect = function(show, type, speed, easing, delay, fn){
		
		// This is a real jQuery plugin, so make sure chaining works:
		
		return this.each(function() {
			
			// Do we have to call a callback function? If not, just create an empty one:
			
			if (fn == undefined) fn = function(){};
			
			// If we didn't set a delay, set the delay variable to zero:
			
			if (delay == undefined) delay = 0;
			
			// We now have all we need, so run the animation we need:
			
			if (type == 'fade'){
				if (show){
					$(this).delay(delay).fadeTo(speed, 1.0, easing, fn);
				} else {
					$(this).delay(delay).fadeTo(speed, 0, easing, fn);
				}
			} else if (type == 'slide'){
				if (show){
					$(this).delay(delay).slideDown(speed, easing, fn);
				} else {
					$(this).delay(delay).slideUp(speed, easing, fn);
				}
			} else if (type == 'none'){
				if (show){
					$(this).delay(delay).show();
				} else {
					$(this).delay(delay).hide();
				}
				fn();
			} else {
				if (show){
					$(this).delay(delay).show(speed, easing, fn);
				} else {
					$(this).delay(delay).hide(speed, easing, fn);
				}
			}
		});
	};
	
	
	// ### jKit_getUnixtime
	//
	// The **jKit_getUnixtime** plugin function returns an unix timestamp based on the current date.
	
	$.fn.jKit_getUnixtime = function(){
		var now = new Date;
		var unixtime_ms = now.getTime();
		return parseInt(unixtime_ms / 1000);
	};
	
	
	// ### jKit_arrayShuffle
	//
	// The **jKit_arrayShuffle** plugin function is used to shuffle an array randomly.
	
	$.fn.jKit_arrayShuffle = function(arr){
		var tmp, rand;
		for(var i =0; i < arr.length; i++){
			rand = Math.floor(Math.random() * arr.length);
			tmp = arr[i];
			arr[i] = arr[rand];
			arr[rand] = tmp;
		}
		return arr;
	};
	
	// ### jKit_stringOccurrences
	//
	// The **jKit_stringOccurrences** plugin function is used to count the times a string is found inside
	// another string.
	
	$.fn.jKit_stringOccurrences = function(string, substring){
		
		var n = 0;
		var pos = 0;
		
		while (true){
			pos = string.indexOf(substring, pos);
			if (pos != -1) {
				n++;
				pos += substring.length;
			} else {
				break;
			}
		}
		
		return (n);
	
	};
	
	
	// ### jKit_emailCheck
	//
	// The **jKit_emailCheck** plugin function is used by the validation command to check if an
	// email address is valid.
	
	$.fn.jKit_emailCheck = function(string){
		var filter = /^[a-z0-9\._-]+@([a-z0-9_-]+\.)+[a-z]{2,6}$/i;
		return filter.test(string);
	};
	
	
	// ### jKit_urlCheck
	//
	// The **jKit_urlCheck** plugin function is used by the validation command to check if an
	// url is valid.
	
	$.fn.jKit_urlCheck = function(string){
		var filter = /^(?:(ftp|http|https):\/\/)?(?:[\w\-]+\.)+[a-z]{2,6}$/i;
		return filter.test(string);
	};
	
	
	// ### jKit_dateCheck
	//
	// The **jKit_dateCheck** plugin function is used by the validation command to check if the
	// date string is valid.
	
	$.fn.jKit_dateCheck = function(string){
		var filter = /^[0-9]{2}\.[0-9]{2}\.[0-9]{2}$/i;
		return filter.test(string);
	};
	
	
	// ### jKit_timeCheck
	//
	// The **jKit_timeCheck** plugin function is used by the validation command to check if the
	// time string is valid.
	
	$.fn.jKit_timeCheck = function(string){
		var filter = /^[0-9]{1,2}\:[0-9]{2}$/i;
		return filter.test(string);
	};
	
	
	// ### jKit_phoneCheck
	//
	// The **jKit_phoneCheck** plugin function is used by the validation command to check if the
	// phone string is valid.
	
	$.fn.jKit_phoneCheck = function(string){
		var filter = /^(\+|0)[\d ]+(-\d*)?\d$/;
		return filter.test(string);
	};
	
	
	// ### jKit_passwordStrength
	//
	// The **jKit_passwordStrength** plugin function is used by the validation command to check if the
	// password strength is good enough. The function calculates a score from 0 to 100 based on various
	// checks.
	
	$.fn.jKit_passwordStrength = function(passwd){
		var intScore = 0
		
		if (passwd.length < 5){
			intScore = intScore + 5;
		} else if (passwd.length > 4 && passwd.length < 8){
			intScore = intScore + 15;
		} else if (passwd.length >= 8){
			intScore = intScore + 30;
		}
		
		if (passwd.match(/[a-z]/)) intScore = intScore + 5;
		if (passwd.match(/[A-Z]/)) intScore = intScore + 10;
		if (passwd.match(/\d+/)) intScore = intScore + 10;
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)) intScore = intScore + 10;
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) intScore = intScore + 10;
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) intScore = intScore + 10;
		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) intScore = intScore + 5;
		if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) intScore = intScore + 5;
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) intScore = intScore + 5;
		
		return intScore;
	};
	
	
	// ### jKit_getAttributes
	//
	// The **jKit_getAttributes** plugin function returns an array with all attributes that are 
	// set on a specific DOM node.
	
	$.fn.jKit_getAttributes = function(){
		return this.each(function() {
			var map = {};
			var attributes = $(this)[0].attributes;
			var aLength = attributes.length;
			
			for (var a = 0; a < aLength; a++) {
					map[attributes[a].name.toLowerCase()] = attributes[a].value;
			}
			
			return map;
		});
	};
	
	
	// ### jKit_setAttributes
	//
	// The **jKit_setAttributes** plugin function creates a set of supplied attributes on an emelemnt.
	
	$.fn.jKit_setAttributes = function(attr){
		return this.each(function() {
			$.each( attr, function(i,v){
				try {
					$(this).attr(String(i),String(v));
				} catch(err) {}
			});
		});
	};
	
	
	// ### jKit_iOS
	//
	// The **jKit_iOS** plugin function checks the user agent if the current device runs iOS.
	
	$.fn.jKit_iOS = function(){
		return navigator.userAgent.match(/(iPod|iPhone|iPad)/i);
	};
	
	
	// ### jKit_belowTheFold
	//
	// The **jKit_belowTheFold** plugin function checks if the supplied element is below the page fold.
	
	$.fn.jKit_belowTheFold = function(){
		var fold = $(window).height() + $(window).scrollTop();
		return fold <= $(this).offset().top;
	};
	
	
	// ### jKit_aboveTheTop
	//
	// The **jKit_aboveTheTop** plugin function checks if the supplied element is above the top of the currently visible part of the page.
	
	$.fn.jKit_aboveTheTop = function(){
		var top = $(window).scrollTop();
		return top >= $(this).offset().top + $(this).height();
	};
	
	
	// ### jKit_rightOfScreen
	//
	// The **jKit_rightOfScreen** plugin function checks if the supplied element is right from the current voiewport.
	
	$.fn.jKit_rightOfScreen = function(){
		var fold = $(window).width() + $(window).scrollLeft();
		return fold <= $(this).offset().left;
	};
	
	
	// ### jKit_leftOfScreen
	//
	// The **jKit_leftOfScreen** plugin function checks if the supplied element is left from the current voiewport.
	
	$.fn.jKit_leftOfScreen = function(){
		var left = $(window).scrollLeft();
		return left >= $(this).offset().left + $(this).width();
	};
	
	
	// ### jKit_inViewport
	//
	// The **jKit_inViewport** plugin function checks if the supplied element is inside the viewport.
	
	$.fn.jKit_inViewport = function(){
		return !$(this).jKit_belowTheFold() && !$(this).jKit_aboveTheTop() && !$(this).jKit_rightOfScreen() && !$(this).jKit_leftOfScreen();
	};
	
	
	// ### jKit
	//
	// The **jKit** function registers jKit as a jQuery plugin.
	
	$.fn.jKit = function(options, moreoptions) {
		
		return this.each(function() {
			var plugin = new $.jKit(this, options, moreoptions);
			$(this).data('jKit', plugin);
		});
	
	};

})(jQuery);

Added sourceMakeup/js/jquery.jkit.1.1.29.min.js.

cannot compute difference between binary files

Added sourceMakeup/js/sourcemakeup.js.







































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$(document).ready(function(){
	$('body').jKit();

	$('td.instruction').hide();
	$('#showinstructions').on( 'change', function(){
		if ($(this).is(':checked')){
			$('td.instruction').show();
		} else {
			$('td.instruction').hide();
		}
	});

	$('#files').on( 'change', function(){
		if (!window.location.origin) window.location.origin = window.location.protocol+"//"+window.location.host;
		window.location = window.location.origin + window.location.pathname + '?file=' + $(this).val();
	});

	prettyPrint(); // Google Code Prettify
});

Added sourceMakeup/libs/google-code-prettify/lang-apollo.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\n\r]*/,null,"#"],["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,
null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[ES]?BANK=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]);

Added sourceMakeup/libs/google-code-prettify/lang-clj.js.





































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 Copyright (C) 2011 Google Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,a],
["typ",/^:[\dA-Za-z-]+/]]),["clj"]);

Added sourceMakeup/libs/google-code-prettify/lang-css.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);

Added sourceMakeup/libs/google-code-prettify/lang-go.js.



>
1
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["pln",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])+(?:'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\/\*[\S\s]*?\*\/)/],["pln",/^(?:[^"'/`]|\/(?![*/]))+/]]),["go"]);

Added sourceMakeup/libs/google-code-prettify/lang-hs.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n \r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^\n\f\r'\\]|\\[^&])'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:--+[^\n\f\r]*|{-(?:[^-]|-+[^}-])*-})/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^\d'A-Za-z]|$)/,
null],["pln",/^(?:[A-Z][\w']*\.)*[A-Za-z][\w']*/],["pun",/^[^\d\t-\r "'A-Za-z]+/]]),["hs"]);

Added sourceMakeup/libs/google-code-prettify/lang-lisp.js.







>
>
>
1
2
3
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,a],
["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","scm"]);

Added sourceMakeup/libs/google-code-prettify/lang-lua.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\S\s]*?(?:]\1]|$)|[^\n\r]*)/],["str",/^\[(=*)\[[\S\s]*?(?:]\1]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],
["pln",/^[_a-z]\w*/i],["pun",/^[^\w\t\n\r \xa0][^\w\t\n\r "'+=\xa0-]*/]]),["lua"]);

Added sourceMakeup/libs/google-code-prettify/lang-ml.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["com",/^#(?:if[\t\n\r \xa0]+(?:[$_a-z][\w']*|``[^\t\n\r`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])(?:'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\(\*[\S\s]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^(?:[_a-z][\w']*[!#?]?|``[^\t\n\r`]*(?:``|$))/i],["pun",/^[^\w\t\n\r "'\xa0]+/]]),["fs","ml"]);

Added sourceMakeup/libs/google-code-prettify/lang-n.js.









>
>
>
>
1
2
3
4
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\xa0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/,
a],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/,
a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]);

Added sourceMakeup/libs/google-code-prettify/lang-proto.js.



>
1
PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]);

Added sourceMakeup/libs/google-code-prettify/lang-scala.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["str",/^"(?:""(?:""?(?!")|[^"\\]|\\.)*"{0,3}|(?:[^\n\r"\\]|\\.)*"?)/,null,'"'],["lit",/^`(?:[^\n\r\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&(--:-@[-^{-~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\n\r'\\]|\\(?:'|[^\n\r']+))'/],["lit",/^'[$A-Z_a-z][\w$]*(?![\w$'])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/],
["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:0(?:[0-7]+|x[\da-f]+)l?|(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:e[+-]?\d+)?f?|l?)|\\.\d+(?:e[+-]?\d+)?f?)/i],["typ",/^[$_]*[A-Z][\d$A-Z_]*[a-z][\w$]*/],["pln",/^[$A-Z_a-z][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]);

Added sourceMakeup/libs/google-code-prettify/lang-sql.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["str",/^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\n\r]*|\/\*[\S\s]*?(?:\*\/|$))/],["kwd",/^(?:add|all|alter|and|any|as|asc|authorization|backup|begin|between|break|browse|bulk|by|cascade|case|check|checkpoint|close|clustered|coalesce|collate|column|commit|compute|constraint|contains|containstable|continue|convert|create|cross|current|current_date|current_time|current_timestamp|current_user|cursor|database|dbcc|deallocate|declare|default|delete|deny|desc|disk|distinct|distributed|double|drop|dummy|dump|else|end|errlvl|escape|except|exec|execute|exists|exit|fetch|file|fillfactor|for|foreign|freetext|freetexttable|from|full|function|goto|grant|group|having|holdlock|identity|identitycol|identity_insert|if|in|index|inner|insert|intersect|into|is|join|key|kill|left|like|lineno|load|match|merge|national|nocheck|nonclustered|not|null|nullif|of|off|offsets|on|open|opendatasource|openquery|openrowset|openxml|option|or|order|outer|over|percent|plan|precision|primary|print|proc|procedure|public|raiserror|read|readtext|reconfigure|references|replication|restore|restrict|return|revoke|right|rollback|rowcount|rowguidcol|rule|save|schema|select|session_user|set|setuser|shutdown|some|statistics|system_user|table|textsize|then|to|top|tran|transaction|trigger|truncate|tsequal|union|unique|update|updatetext|use|user|using|values|varying|view|waitfor|when|where|while|with|writetext)(?=[^\w-]|$)/i,
null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^[_a-z][\w-]*/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'+\xa0-]*/]]),["sql"]);

Added sourceMakeup/libs/google-code-prettify/lang-tex.js.



>
1
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"],["com",/^%[^\n\r]*/,null,"%"]],[["kwd",/^\\[@-Za-z]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[()=[\]{}]+/]]),["latex","tex"]);

Added sourceMakeup/libs/google-code-prettify/lang-vb.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0\u2028\u2029]+/,null,"\t\n\r \xa0

"],["str",/^(?:["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})(?:["\u201c\u201d]c|$)|["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})*(?:["\u201c\u201d]|$))/i,null,'"“”'],["com",/^['\u2018\u2019].*/,null,"'‘’"]],[["kwd",/^(?:addhandler|addressof|alias|and|andalso|ansi|as|assembly|auto|boolean|byref|byte|byval|call|case|catch|cbool|cbyte|cchar|cdate|cdbl|cdec|char|cint|class|clng|cobj|const|cshort|csng|cstr|ctype|date|decimal|declare|default|delegate|dim|directcast|do|double|each|else|elseif|end|endif|enum|erase|error|event|exit|finally|for|friend|function|get|gettype|gosub|goto|handles|if|implements|imports|in|inherits|integer|interface|is|let|lib|like|long|loop|me|mod|module|mustinherit|mustoverride|mybase|myclass|namespace|new|next|not|notinheritable|notoverridable|object|on|option|optional|or|orelse|overloads|overridable|overrides|paramarray|preserve|private|property|protected|public|raiseevent|readonly|redim|removehandler|resume|return|select|set|shadows|shared|short|single|static|step|stop|string|structure|sub|synclock|then|throw|to|try|typeof|unicode|until|variant|wend|when|while|with|withevents|writeonly|xor|endif|gosub|let|variant|wend)\b/i,
null],["com",/^rem.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\s+(?:\d+[/-]\d+[/-]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:am|pm))?)?|\d+:\d+(?::\d+)?(\s*(?:am|pm))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*|\[(?:[a-z]|_\w)\w*])/i],["pun",/^[^\w\t\n\r "'[\]\xa0\u2018\u2019\u201c\u201d\u2028\u2029]+/],["pun",/^(?:\[|])/]]),["vb","vbs"]);

Added sourceMakeup/libs/google-code-prettify/lang-vhdl.js.







>
>
>
1
2
3
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \xa0"]],[["str",/^(?:[box]?"(?:[^"]|"")*"|'.')/i],["com",/^--[^\n\r]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i,
null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^'(?:active|ascending|base|delayed|driving|driving_value|event|high|image|instance_name|last_active|last_event|last_value|left|leftof|length|low|path_name|pos|pred|quiet|range|reverse_range|right|rightof|simple_name|stable|succ|transaction|val|value)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w.\\]+#(?:[+-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:e[+-]?\d+(?:_\d+)*)?)/i],
["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'\xa0-]*/]]),["vhdl","vhd"]);

Added sourceMakeup/libs/google-code-prettify/lang-wiki.js.





>
>
1
2
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\d\t a-gi-z\xa0]+/,null,"\t \xa0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[*=[\]^~]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^[A-Z][a-z][\da-z]+[A-Z][a-z][^\W_]+\b/],["lang-",/^{{{([\S\s]+?)}}}/],["lang-",/^`([^\n\r`]+)`/],["str",/^https?:\/\/[^\s#/?]*(?:\/[^\s#?]*)?(?:\?[^\s#]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\S\s])[^\n\r#*=A-[^`h{~]*/]]),["wiki"]);
PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]);

Added sourceMakeup/libs/google-code-prettify/lang-xq.js.

cannot compute difference between binary files

Added sourceMakeup/libs/google-code-prettify/lang-yaml.js.





>
>
1
2
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^\w+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]);

Added sourceMakeup/libs/google-code-prettify/prettify.css.



>
1
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:0px;}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}

Added sourceMakeup/libs/google-code-prettify/prettify.js.

























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

Added sourceMakeup/libs/markdown/markdown.php.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
<?php
#
# Markdown  -  A text-to-HTML conversion tool for web writers
#
# PHP Markdown  
# Copyright (c) 2004-2013 Michel Fortin  
# <http://michelf.ca/projects/php-markdown/>
#
# Original Markdown  
# Copyright (c) 2004-2006 John Gruber  
# <http://daringfireball.net/projects/markdown/>
#


define( 'MARKDOWN_VERSION',  "1.0.1p" ); # Sun 13 Jan 2013


#
# Global default settings:
#

# Change to ">" for HTML output
@define( 'MARKDOWN_EMPTY_ELEMENT_SUFFIX',  " />");

# Define the width of a tab for code blocks.
@define( 'MARKDOWN_TAB_WIDTH',     4 );


#
# WordPress settings:
#

# Change to false to remove Markdown from posts and/or comments.
@define( 'MARKDOWN_WP_POSTS',      true );
@define( 'MARKDOWN_WP_COMMENTS',   true );



### Standard Function Interface ###

@define( 'MARKDOWN_PARSER_CLASS',  'Markdown_Parser' );

function Markdown($text) {
#
# Initialize the parser and return the result of its transform method.
#
	# Setup static parser variable.
	static $parser;
	if (!isset($parser)) {
		$parser_class = MARKDOWN_PARSER_CLASS;
		$parser = new $parser_class;
	}

	# Transform text using parser.
	return $parser->transform($text);
}


### WordPress Plugin Interface ###

/*
Plugin Name: Markdown
Plugin URI: http://michelf.ca/projects/php-markdown/
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://michelf.ca/projects/php-markdown/">More...</a>
Version: 1.0.1p
Author: Michel Fortin
Author URI: http://michelf.ca/
*/

if (isset($wp_version)) {
	# More details about how it works here:
	# <http://michelf.ca/weblog/2005/wordpress-text-flow-vs-markdown/>
	
	# Post content and excerpts
	# - Remove WordPress paragraph generator.
	# - Run Markdown on excerpt, then remove all tags.
	# - Add paragraph tag around the excerpt, but remove it for the excerpt rss.
	if (MARKDOWN_WP_POSTS) {
		remove_filter('the_content',     'wpautop');
        remove_filter('the_content_rss', 'wpautop');
		remove_filter('the_excerpt',     'wpautop');
		add_filter('the_content',     'Markdown', 6);
        add_filter('the_content_rss', 'Markdown', 6);
		add_filter('get_the_excerpt', 'Markdown', 6);
		add_filter('get_the_excerpt', 'trim', 7);
		add_filter('the_excerpt',     'mdwp_add_p');
		add_filter('the_excerpt_rss', 'mdwp_strip_p');
		
		remove_filter('content_save_pre',  'balanceTags', 50);
		remove_filter('excerpt_save_pre',  'balanceTags', 50);
		add_filter('the_content',  	  'balanceTags', 50);
		add_filter('get_the_excerpt', 'balanceTags', 9);
	}
	
	# Comments
	# - Remove WordPress paragraph generator.
	# - Remove WordPress auto-link generator.
	# - Scramble important tags before passing them to the kses filter.
	# - Run Markdown on excerpt then remove paragraph tags.
	if (MARKDOWN_WP_COMMENTS) {
		remove_filter('comment_text', 'wpautop', 30);
		remove_filter('comment_text', 'make_clickable');
		add_filter('pre_comment_content', 'Markdown', 6);
		add_filter('pre_comment_content', 'mdwp_hide_tags', 8);
		add_filter('pre_comment_content', 'mdwp_show_tags', 12);
		add_filter('get_comment_text',    'Markdown', 6);
		add_filter('get_comment_excerpt', 'Markdown', 6);
		add_filter('get_comment_excerpt', 'mdwp_strip_p', 7);
	
		global $mdwp_hidden_tags, $mdwp_placeholders;
		$mdwp_hidden_tags = explode(' ',
			'<p> </p> <pre> </pre> <ol> </ol> <ul> </ul> <li> </li>');
		$mdwp_placeholders = explode(' ', str_rot13(
			'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR '.
			'ML5IjmbRol ulANi1NsGY J7zRLJqPul liA8ctl16T K9nhooUHli'));
	}
	
	function mdwp_add_p($text) {
		if (!preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) {
			$text = '<p>'.$text.'</p>';
			$text = preg_replace('{\n{2,}}', "</p>\n\n<p>", $text);
		}
		return $text;
	}
	
	function mdwp_strip_p($t) { return preg_replace('{</?p>}i', '', $t); }

	function mdwp_hide_tags($text) {
		global $mdwp_hidden_tags, $mdwp_placeholders;
		return str_replace($mdwp_hidden_tags, $mdwp_placeholders, $text);
	}
	function mdwp_show_tags($text) {
		global $mdwp_hidden_tags, $mdwp_placeholders;
		return str_replace($mdwp_placeholders, $mdwp_hidden_tags, $text);
	}
}


### bBlog Plugin Info ###

function identify_modifier_markdown() {
	return array(
		'name'			=> 'markdown',
		'type'			=> 'modifier',
		'nicename'		=> 'Markdown',
		'description'	=> 'A text-to-HTML conversion tool for web writers',
		'authors'		=> 'Michel Fortin and John Gruber',
		'licence'		=> 'BSD-like',
		'version'		=> MARKDOWN_VERSION,
		'help'			=> '<a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://michelf.ca/projects/php-markdown/">More...</a>'
	);
}


### Smarty Modifier Interface ###

function smarty_modifier_markdown($text) {
	return Markdown($text);
}


### Textile Compatibility Mode ###

# Rename this file to "classTextile.php" and it can replace Textile everywhere.

if (strcasecmp(substr(__FILE__, -16), "classTextile.php") == 0) {
	# Try to include PHP SmartyPants. Should be in the same directory.
	@include_once 'smartypants.php';
	# Fake Textile class. It calls Markdown instead.
	class Textile {
		function TextileThis($text, $lite='', $encode='') {
			if ($lite == '' && $encode == '')    $text = Markdown($text);
			if (function_exists('SmartyPants'))  $text = SmartyPants($text);
			return $text;
		}
		# Fake restricted version: restrictions are not supported for now.
		function TextileRestricted($text, $lite='', $noimage='') {
			return $this->TextileThis($text, $lite);
		}
		# Workaround to ensure compatibility with TextPattern 4.0.3.
		function blockLite($text) { return $text; }
	}
}



#
# Markdown Parser Class
#

class Markdown_Parser {

	### Configuration Variables ###

	# Change to ">" for HTML output.
	var $empty_element_suffix = MARKDOWN_EMPTY_ELEMENT_SUFFIX;
	var $tab_width = MARKDOWN_TAB_WIDTH;
	
	# Change to `true` to disallow markup or entities.
	var $no_markup = false;
	var $no_entities = false;
	
	# Predefined urls and titles for reference links and images.
	var $predef_urls = array();
	var $predef_titles = array();


	### Parser Implementation ###

	# Regex to match balanced [brackets].
	# Needed to insert a maximum bracked depth while converting to PHP.
	var $nested_brackets_depth = 6;
	var $nested_brackets_re;
	
	var $nested_url_parenthesis_depth = 4;
	var $nested_url_parenthesis_re;

	# Table of hash values for escaped characters:
	var $escape_chars = '\`*_{}[]()>#+-.!';
	var $escape_chars_re;


	function Markdown_Parser() {
	#
	# Constructor function. Initialize appropriate member variables.
	#
		$this->_initDetab();
		$this->prepareItalicsAndBold();
	
		$this->nested_brackets_re = 
			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth).
			str_repeat('\])*', $this->nested_brackets_depth);
	
		$this->nested_url_parenthesis_re = 
			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth).
			str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth);
		
		$this->escape_chars_re = '['.preg_quote($this->escape_chars).']';
		
		# Sort document, block, and span gamut in ascendent priority order.
		asort($this->document_gamut);
		asort($this->block_gamut);
		asort($this->span_gamut);
	}


	# Internal hashes used during transformation.
	var $urls = array();
	var $titles = array();
	var $html_hashes = array();
	
	# Status flag to avoid invalid nesting.
	var $in_anchor = false;
	
	
	function setup() {
	#
	# Called before the transformation process starts to setup parser 
	# states.
	#
		# Clear global hashes.
		$this->urls = $this->predef_urls;
		$this->titles = $this->predef_titles;
		$this->html_hashes = array();
		
		$in_anchor = false;
	}
	
	function teardown() {
	#
	# Called after the transformation process to clear any variable 
	# which may be taking up memory unnecessarly.
	#
		$this->urls = array();
		$this->titles = array();
		$this->html_hashes = array();
	}


	function transform($text) {
	#
	# Main function. Performs some preprocessing on the input text
	# and pass it through the document gamut.
	#
		$this->setup();
	
		# Remove UTF-8 BOM and marker character in input, if present.
		$text = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $text);

		# Standardize line endings:
		#   DOS to Unix and Mac to Unix
		$text = preg_replace('{\r\n?}', "\n", $text);

		# Make sure $text ends with a couple of newlines:
		$text .= "\n\n";

		# Convert all tabs to spaces.
		$text = $this->detab($text);

		# Turn block-level HTML blocks into hash entries
		$text = $this->hashHTMLBlocks($text);

		# Strip any lines consisting only of spaces and tabs.
		# This makes subsequent regexen easier to write, because we can
		# match consecutive blank lines with /\n+/ instead of something
		# contorted like /[ ]*\n+/ .
		$text = preg_replace('/^[ ]+$/m', '', $text);

		# Run document gamut methods.
		foreach ($this->document_gamut as $method => $priority) {
			$text = $this->$method($text);
		}
		
		$this->teardown();

		return $text . "\n";
	}
	
	var $document_gamut = array(
		# Strip link definitions, store in hashes.
		"stripLinkDefinitions" => 20,
		
		"runBasicBlockGamut"   => 30,
		);


	function stripLinkDefinitions($text) {
	#
	# Strips link definitions from text, stores the URLs and titles in
	# hash references.
	#
		$less_than_tab = $this->tab_width - 1;

		# Link defs are in the form: ^[id]: url "optional title"
		$text = preg_replace_callback('{
							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
							  [ ]*
							  \n?				# maybe *one* newline
							  [ ]*
							(?:
							  <(.+?)>			# url = $2
							|
							  (\S+?)			# url = $3
							)
							  [ ]*
							  \n?				# maybe one newline
							  [ ]*
							(?:
								(?<=\s)			# lookbehind for whitespace
								["(]
								(.*?)			# title = $4
								[")]
								[ ]*
							)?	# title is optional
							(?:\n+|\Z)
			}xm',
			array(&$this, '_stripLinkDefinitions_callback'),
			$text);
		return $text;
	}
	function _stripLinkDefinitions_callback($matches) {
		$link_id = strtolower($matches[1]);
		$url = $matches[2] == '' ? $matches[3] : $matches[2];
		$this->urls[$link_id] = $url;
		$this->titles[$link_id] =& $matches[4];
		return ''; # String that will replace the block
	}


	function hashHTMLBlocks($text) {
		if ($this->no_markup)  return $text;

		$less_than_tab = $this->tab_width - 1;

		# Hashify HTML blocks:
		# We only want to do this for block-level HTML tags, such as headers,
		# lists, and tables. That's because we still want to wrap <p>s around
		# "paragraphs" that are wrapped in non-block-level tags, such as anchors,
		# phrase emphasis, and spans. The list of tags we're looking for is
		# hard-coded:
		#
		# *  List "a" is made of tags which can be both inline or block-level.
		#    These will be treated block-level when the start tag is alone on 
		#    its line, otherwise they're not matched here and will be taken as 
		#    inline later.
		# *  List "b" is made of tags which are always block-level;
		#
		$block_tags_a_re = 'ins|del';
		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
						   'script|noscript|form|fieldset|iframe|math|svg|'.
						   'article|section|nav|aside|hgroup|header|footer|'.
						   'figure';

		# Regular expression for the content of a block tag.
		$nested_tags_level = 4;
		$attr = '
			(?>				# optional tag attributes
			  \s			# starts with whitespace
			  (?>
				[^>"/]+		# text outside quotes
			  |
				/+(?!>)		# slash not followed by ">"
			  |
				"[^"]*"		# text inside double quotes (tolerate ">")
			  |
				\'[^\']*\'	# text inside single quotes (tolerate ">")
			  )*
			)?	
			';
		$content =
			str_repeat('
				(?>
				  [^<]+			# content without tag
				|
				  <\2			# nested opening tag
					'.$attr.'	# attributes
					(?>
					  />
					|
					  >', $nested_tags_level).	# end of opening tag
					  '.*?'.					# last level nested tag content
			str_repeat('
					  </\2\s*>	# closing nested tag
					)
				  |				
					<(?!/\2\s*>	# other tags with a different name
				  )
				)*',
				$nested_tags_level);
		$content2 = str_replace('\2', '\3', $content);

		# First, look for nested blocks, e.g.:
		# 	<div>
		# 		<div>
		# 		tags for inner block must be indented.
		# 		</div>
		# 	</div>
		#
		# The outermost tags must start at the left margin for this to match, and
		# the inner nested divs must be indented.
		# We need to do this before the next, more liberal match, because the next
		# match will start at the first `<div>` and stop at the first `</div>`.
		$text = preg_replace_callback('{(?>
			(?>
				(?<=\n\n)		# Starting after a blank line
				|				# or
				\A\n?			# the beginning of the doc
			)
			(						# save in $1

			  # Match from `\n<tag>` to `</tag>\n`, handling nested tags 
			  # in between.
					
						[ ]{0,'.$less_than_tab.'}
						<('.$block_tags_b_re.')# start tag = $2
						'.$attr.'>			# attributes followed by > and \n
						'.$content.'		# content, support nesting
						</\2>				# the matching end tag
						[ ]*				# trailing spaces/tabs
						(?=\n+|\Z)	# followed by a newline or end of document

			| # Special version for tags of group a.

						[ ]{0,'.$less_than_tab.'}
						<('.$block_tags_a_re.')# start tag = $3
						'.$attr.'>[ ]*\n	# attributes followed by >
						'.$content2.'		# content, support nesting
						</\3>				# the matching end tag
						[ ]*				# trailing spaces/tabs
						(?=\n+|\Z)	# followed by a newline or end of document
					
			| # Special case just for <hr />. It was easier to make a special 
			  # case than to make the other regex more complicated.
			
						[ ]{0,'.$less_than_tab.'}
						<(hr)				# start tag = $2
						'.$attr.'			# attributes
						/?>					# the matching end tag
						[ ]*
						(?=\n{2,}|\Z)		# followed by a blank line or end of document
			
			| # Special case for standalone HTML comments:
			
					[ ]{0,'.$less_than_tab.'}
					(?s:
						<!-- .*? -->
					)
					[ ]*
					(?=\n{2,}|\Z)		# followed by a blank line or end of document
			
			| # PHP and ASP-style processor instructions (<? and <%)
			
					[ ]{0,'.$less_than_tab.'}
					(?s:
						<([?%])			# $2
						.*?
						\2>
					)
					[ ]*
					(?=\n{2,}|\Z)		# followed by a blank line or end of document
					
			)
			)}Sxmi',
			array(&$this, '_hashHTMLBlocks_callback'),
			$text);

		return $text;
	}
	function _hashHTMLBlocks_callback($matches) {
		$text = $matches[1];
		$key  = $this->hashBlock($text);
		return "\n\n$key\n\n";
	}
	
	
	function hashPart($text, $boundary = 'X') {
	#
	# Called whenever a tag must be hashed when a function insert an atomic 
	# element in the text stream. Passing $text to through this function gives
	# a unique text-token which will be reverted back when calling unhash.
	#
	# The $boundary argument specify what character should be used to surround
	# the token. By convension, "B" is used for block elements that needs not
	# to be wrapped into paragraph tags at the end, ":" is used for elements
	# that are word separators and "X" is used in the general case.
	#
		# Swap back any tag hash found in $text so we do not have to `unhash`
		# multiple times at the end.
		$text = $this->unhash($text);
		
		# Then hash the block.
		static $i = 0;
		$key = "$boundary\x1A" . ++$i . $boundary;
		$this->html_hashes[$key] = $text;
		return $key; # String that will replace the tag.
	}


	function hashBlock($text) {
	#
	# Shortcut function for hashPart with block-level boundaries.
	#
		return $this->hashPart($text, 'B');
	}


	var $block_gamut = array(
	#
	# These are all the transformations that form block-level
	# tags like paragraphs, headers, and list items.
	#
		"doHeaders"         => 10,
		"doHorizontalRules" => 20,
		
		"doLists"           => 40,
		"doCodeBlocks"      => 50,
		"doBlockQuotes"     => 60,
		);

	function runBlockGamut($text) {
	#
	# Run block gamut tranformations.
	#
		# We need to escape raw HTML in Markdown source before doing anything 
		# else. This need to be done for each block, and not only at the 
		# begining in the Markdown function since hashed blocks can be part of
		# list items and could have been indented. Indented blocks would have 
		# been seen as a code block in a previous pass of hashHTMLBlocks.
		$text = $this->hashHTMLBlocks($text);
		
		return $this->runBasicBlockGamut($text);
	}
	
	function runBasicBlockGamut($text) {
	#
	# Run block gamut tranformations, without hashing HTML blocks. This is 
	# useful when HTML blocks are known to be already hashed, like in the first
	# whole-document pass.
	#
		foreach ($this->block_gamut as $method => $priority) {
			$text = $this->$method($text);
		}
		
		# Finally form paragraph and restore hashed blocks.
		$text = $this->formParagraphs($text);

		return $text;
	}
	
	
	function doHorizontalRules($text) {
		# Do Horizontal Rules:
		return preg_replace(
			'{
				^[ ]{0,3}	# Leading space
				([-*_])		# $1: First marker
				(?>			# Repeated marker group
					[ ]{0,2}	# Zero, one, or two spaces.
					\1			# Marker character
				){2,}		# Group repeated at least twice
				[ ]*		# Tailing spaces
				$			# End of line.
			}mx',
			"\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", 
			$text);
	}


	var $span_gamut = array(
	#
	# These are all the transformations that occur *within* block-level
	# tags like paragraphs, headers, and list items.
	#
		# Process character escapes, code spans, and inline HTML
		# in one shot.
		"parseSpan"           => -30,

		# Process anchor and image tags. Images must come first,
		# because ![foo][f] looks like an anchor.
		"doImages"            =>  10,
		"doAnchors"           =>  20,
		
		# Make links out of things like `<http://example.com/>`
		# Must come after doAnchors, because you can use < and >
		# delimiters in inline links like [this](<url>).
		"doAutoLinks"         =>  30,
		"encodeAmpsAndAngles" =>  40,

		"doItalicsAndBold"    =>  50,
		"doHardBreaks"        =>  60,
		);

	function runSpanGamut($text) {
	#
	# Run span gamut tranformations.
	#
		foreach ($this->span_gamut as $method => $priority) {
			$text = $this->$method($text);
		}

		return $text;
	}
	
	
	function doHardBreaks($text) {
		# Do hard breaks:
		return preg_replace_callback('/ {2,}\n/', 
			array(&$this, '_doHardBreaks_callback'), $text);
	}
	function _doHardBreaks_callback($matches) {
		return $this->hashPart("<br$this->empty_element_suffix\n");
	}


	function doAnchors($text) {
	#
	# Turn Markdown link shortcuts into XHTML <a> tags.
	#
		if ($this->in_anchor) return $text;
		$this->in_anchor = true;
		
		#
		# First, handle reference-style links: [link text] [id]
		#
		$text = preg_replace_callback('{
			(					# wrap whole match in $1
			  \[
				('.$this->nested_brackets_re.')	# link text = $2
			  \]

			  [ ]?				# one optional space
			  (?:\n[ ]*)?		# one optional newline followed by spaces

			  \[
				(.*?)		# id = $3
			  \]
			)
			}xs',
			array(&$this, '_doAnchors_reference_callback'), $text);

		#
		# Next, inline-style links: [link text](url "optional title")
		#
		$text = preg_replace_callback('{
			(				# wrap whole match in $1
			  \[
				('.$this->nested_brackets_re.')	# link text = $2
			  \]
			  \(			# literal paren
				[ \n]*
				(?:
					<(.+?)>	# href = $3
				|
					('.$this->nested_url_parenthesis_re.')	# href = $4
				)
				[ \n]*
				(			# $5
				  ([\'"])	# quote char = $6
				  (.*?)		# Title = $7
				  \6		# matching quote
				  [ \n]*	# ignore any spaces/tabs between closing quote and )
				)?			# title is optional
			  \)
			)
			}xs',
			array(&$this, '_doAnchors_inline_callback'), $text);

		#
		# Last, handle reference-style shortcuts: [link text]
		# These must come last in case you've also got [link text][1]
		# or [link text](/foo)
		#
		$text = preg_replace_callback('{
			(					# wrap whole match in $1
			  \[
				([^\[\]]+)		# link text = $2; can\'t contain [ or ]
			  \]
			)
			}xs',
			array(&$this, '_doAnchors_reference_callback'), $text);

		$this->in_anchor = false;
		return $text;
	}
	function _doAnchors_reference_callback($matches) {
		$whole_match =  $matches[1];
		$link_text   =  $matches[2];
		$link_id     =& $matches[3];

		if ($link_id == "") {
			# for shortcut links like [this][] or [this].
			$link_id = $link_text;
		}
		
		# lower-case and turn embedded newlines into spaces
		$link_id = strtolower($link_id);
		$link_id = preg_replace('{[ ]?\n}', ' ', $link_id);

		if (isset($this->urls[$link_id])) {
			$url = $this->urls[$link_id];
			$url = $this->encodeAttribute($url);
			
			$result = "<a href=\"$url\"";
			if ( isset( $this->titles[$link_id] ) ) {
				$title = $this->titles[$link_id];
				$title = $this->encodeAttribute($title);
				$result .=  " title=\"$title\"";
			}
		
			$link_text = $this->runSpanGamut($link_text);
			$result .= ">$link_text</a>";
			$result = $this->hashPart($result);
		}
		else {
			$result = $whole_match;
		}
		return $result;
	}
	function _doAnchors_inline_callback($matches) {
		$whole_match	=  $matches[1];
		$link_text		=  $this->runSpanGamut($matches[2]);
		$url			=  $matches[3] == '' ? $matches[4] : $matches[3];
		$title			=& $matches[7];

		$url = $this->encodeAttribute($url);

		$result = "<a href=\"$url\"";
		if (isset($title)) {
			$title = $this->encodeAttribute($title);
			$result .=  " title=\"$title\"";
		}
		
		$link_text = $this->runSpanGamut($link_text);
		$result .= ">$link_text</a>";

		return $this->hashPart($result);
	}


	function doImages($text) {
	#
	# Turn Markdown image shortcuts into <img> tags.
	#
		#
		# First, handle reference-style labeled images: ![alt text][id]
		#
		$text = preg_replace_callback('{
			(				# wrap whole match in $1
			  !\[
				('.$this->nested_brackets_re.')		# alt text = $2
			  \]

			  [ ]?				# one optional space
			  (?:\n[ ]*)?		# one optional newline followed by spaces

			  \[
				(.*?)		# id = $3
			  \]

			)
			}xs', 
			array(&$this, '_doImages_reference_callback'), $text);

		#
		# Next, handle inline images:  ![alt text](url "optional title")
		# Don't forget: encode * and _
		#
		$text = preg_replace_callback('{
			(				# wrap whole match in $1
			  !\[
				('.$this->nested_brackets_re.')		# alt text = $2
			  \]
			  \s?			# One optional whitespace character
			  \(			# literal paren
				[ \n]*
				(?:
					<(\S*)>	# src url = $3
				|
					('.$this->nested_url_parenthesis_re.')	# src url = $4
				)
				[ \n]*
				(			# $5
				  ([\'"])	# quote char = $6
				  (.*?)		# title = $7
				  \6		# matching quote
				  [ \n]*
				)?			# title is optional
			  \)
			)
			}xs',
			array(&$this, '_doImages_inline_callback'), $text);

		return $text;
	}
	function _doImages_reference_callback($matches) {
		$whole_match = $matches[1];
		$alt_text    = $matches[2];
		$link_id     = strtolower($matches[3]);

		if ($link_id == "") {
			$link_id = strtolower($alt_text); # for shortcut links like ![this][].
		}

		$alt_text = $this->encodeAttribute($alt_text);
		if (isset($this->urls[$link_id])) {
			$url = $this->encodeAttribute($this->urls[$link_id]);
			$result = "<img src=\"$url\" alt=\"$alt_text\"";
			if (isset($this->titles[$link_id])) {
				$title = $this->titles[$link_id];
				$title = $this->encodeAttribute($title);
				$result .=  " title=\"$title\"";
			}
			$result .= $this->empty_element_suffix;
			$result = $this->hashPart($result);
		}
		else {
			# If there's no such link ID, leave intact:
			$result = $whole_match;
		}

		return $result;
	}
	function _doImages_inline_callback($matches) {
		$whole_match	= $matches[1];
		$alt_text		= $matches[2];
		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
		$title			=& $matches[7];

		$alt_text = $this->encodeAttribute($alt_text);
		$url = $this->encodeAttribute($url);
		$result = "<img src=\"$url\" alt=\"$alt_text\"";
		if (isset($title)) {
			$title = $this->encodeAttribute($title);
			$result .=  " title=\"$title\""; # $title already quoted
		}
		$result .= $this->empty_element_suffix;

		return $this->hashPart($result);
	}


	function doHeaders($text) {
		# Setext-style headers:
		#	  Header 1
		#	  ========
		#  
		#	  Header 2
		#	  --------
		#
		$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
			array(&$this, '_doHeaders_callback_setext'), $text);

		# atx-style headers:
		#	# Header 1
		#	## Header 2
		#	## Header 2 with closing hashes ##
		#	...
		#	###### Header 6
		#
		$text = preg_replace_callback('{
				^(\#{1,6})	# $1 = string of #\'s
				[ ]*
				(.+?)		# $2 = Header text
				[ ]*
				\#*			# optional closing #\'s (not counted)
				\n+
			}xm',
			array(&$this, '_doHeaders_callback_atx'), $text);

		return $text;
	}
	function _doHeaders_callback_setext($matches) {
		# Terrible hack to check we haven't found an empty list item.
		if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
			return $matches[0];
		
		$level = $matches[2]{0} == '=' ? 1 : 2;
		$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
		return "\n" . $this->hashBlock($block) . "\n\n";
	}
	function _doHeaders_callback_atx($matches) {
		$level = strlen($matches[1]);
		$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
		return "\n" . $this->hashBlock($block) . "\n\n";
	}


	function doLists($text) {
	#
	# Form HTML ordered (numbered) and unordered (bulleted) lists.
	#
		$less_than_tab = $this->tab_width - 1;

		# Re-usable patterns to match list item bullets and number markers:
		$marker_ul_re  = '[*+-]';
		$marker_ol_re  = '\d+[\.]';
		$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";

		$markers_relist = array(
			$marker_ul_re => $marker_ol_re,
			$marker_ol_re => $marker_ul_re,
			);

		foreach ($markers_relist as $marker_re => $other_marker_re) {
			# Re-usable pattern to match any entirel ul or ol list:
			$whole_list_re = '
				(								# $1 = whole list
				  (								# $2
					([ ]{0,'.$less_than_tab.'})	# $3 = number of spaces
					('.$marker_re.')			# $4 = first list item marker
					[ ]+
				  )
				  (?s:.+?)
				  (								# $5
					  \z
					|
					  \n{2,}
					  (?=\S)
					  (?!						# Negative lookahead for another list item marker
						[ ]*
						'.$marker_re.'[ ]+
					  )
					|
					  (?=						# Lookahead for another kind of list
					    \n
						\3						# Must have the same indentation
						'.$other_marker_re.'[ ]+
					  )
				  )
				)
			'; // mx
			
			# We use a different prefix before nested lists than top-level lists.
			# See extended comment in _ProcessListItems().
		
			if ($this->list_level) {
				$text = preg_replace_callback('{
						^
						'.$whole_list_re.'
					}mx',
					array(&$this, '_doLists_callback'), $text);
			}
			else {
				$text = preg_replace_callback('{
						(?:(?<=\n)\n|\A\n?) # Must eat the newline
						'.$whole_list_re.'
					}mx',
					array(&$this, '_doLists_callback'), $text);
			}
		}

		return $text;
	}
	function _doLists_callback($matches) {
		# Re-usable patterns to match list item bullets and number markers:
		$marker_ul_re  = '[*+-]';
		$marker_ol_re  = '\d+[\.]';
		$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
		
		$list = $matches[1];
		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
		
		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
		
		$list .= "\n";
		$result = $this->processListItems($list, $marker_any_re);
		
		$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
		return "\n". $result ."\n\n";
	}

	var $list_level = 0;

	function processListItems($list_str, $marker_any_re) {
	#
	#	Process the contents of a single ordered or unordered list, splitting it
	#	into individual list items.
	#
		# The $this->list_level global keeps track of when we're inside a list.
		# Each time we enter a list, we increment it; when we leave a list,
		# we decrement. If it's zero, we're not in a list anymore.
		#
		# We do this because when we're not inside a list, we want to treat
		# something like this:
		#
		#		I recommend upgrading to version
		#		8. Oops, now this line is treated
		#		as a sub-list.
		#
		# As a single paragraph, despite the fact that the second line starts
		# with a digit-period-space sequence.
		#
		# Whereas when we're inside a list (or sub-list), that line will be
		# treated as the start of a sub-list. What a kludge, huh? This is
		# an aspect of Markdown's syntax that's hard to parse perfectly
		# without resorting to mind-reading. Perhaps the solution is to
		# change the syntax rules such that sub-lists must start with a
		# starting cardinal number; e.g. "1." or "a.".
		
		$this->list_level++;

		# trim trailing blank lines:
		$list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);

		$list_str = preg_replace_callback('{
			(\n)?							# leading line = $1
			(^[ ]*)							# leading whitespace = $2
			('.$marker_any_re.'				# list marker and space = $3
				(?:[ ]+|(?=\n))	# space only required if item is not empty
			)
			((?s:.*?))						# list item text   = $4
			(?:(\n+(?=\n))|\n)				# tailing blank line = $5
			(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
			}xm',
			array(&$this, '_processListItems_callback'), $list_str);

		$this->list_level--;
		return $list_str;
	}
	function _processListItems_callback($matches) {
		$item = $matches[4];
		$leading_line =& $matches[1];
		$leading_space =& $matches[2];
		$marker_space = $matches[3];
		$tailing_blank_line =& $matches[5];

		if ($leading_line || $tailing_blank_line || 
			preg_match('/\n{2,}/', $item))
		{
			# Replace marker with the appropriate whitespace indentation
			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
			$item = $this->runBlockGamut($this->outdent($item)."\n");
		}
		else {
			# Recursion for sub-lists:
			$item = $this->doLists($this->outdent($item));
			$item = preg_replace('/\n+$/', '', $item);
			$item = $this->runSpanGamut($item);
		}

		return "<li>" . $item . "</li>\n";
	}


	function doCodeBlocks($text) {
	#
	#	Process Markdown `<pre><code>` blocks.
	#
		$text = preg_replace_callback('{
				(?:\n\n|\A\n?)
				(	            # $1 = the code block -- one or more lines, starting with a space/tab
				  (?>
					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
					.*\n+
				  )+
				)
				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
			}xm',
			array(&$this, '_doCodeBlocks_callback'), $text);

		return $text;
	}
	function _doCodeBlocks_callback($matches) {
		$codeblock = $matches[1];

		$codeblock = $this->outdent($codeblock);
		$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);

		# trim leading newlines and trailing newlines
		$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);

		$codeblock = "<pre><code>$codeblock\n</code></pre>";
		return "\n\n".$this->hashBlock($codeblock)."\n\n";
	}


	function makeCodeSpan($code) {
	#
	# Create a code span markup for $code. Called from handleSpanToken.
	#
		$code = htmlspecialchars(trim($code), ENT_NOQUOTES);
		return $this->hashPart("<code>$code</code>");
	}


	var $em_relist = array(
		''  => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![\.,:;]\s)',
		'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
		'_' => '(?<=\S|^)(?<!_)_(?!_)',
		);
	var $strong_relist = array(
		''   => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![\.,:;]\s)',
		'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
		'__' => '(?<=\S|^)(?<!_)__(?!_)',
		);
	var $em_strong_relist = array(
		''    => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![\.,:;]\s)',
		'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
		'___' => '(?<=\S|^)(?<!_)___(?!_)',
		);
	var $em_strong_prepared_relist;
	
	function prepareItalicsAndBold() {
	#
	# Prepare regular expressions for searching emphasis tokens in any
	# context.
	#
		foreach ($this->em_relist as $em => $em_re) {
			foreach ($this->strong_relist as $strong => $strong_re) {
				# Construct list of allowed token expressions.
				$token_relist = array();
				if (isset($this->em_strong_relist["$em$strong"])) {
					$token_relist[] = $this->em_strong_relist["$em$strong"];
				}
				$token_relist[] = $em_re;
				$token_relist[] = $strong_re;
				
				# Construct master expression from list.
				$token_re = '{('. implode('|', $token_relist) .')}';
				$this->em_strong_prepared_relist["$em$strong"] = $token_re;
			}
		}
	}
	
	function doItalicsAndBold($text) {
		$token_stack = array('');
		$text_stack = array('');
		$em = '';
		$strong = '';
		$tree_char_em = false;
		
		while (1) {
			#
			# Get prepared regular expression for seraching emphasis tokens
			# in current context.
			#
			$token_re = $this->em_strong_prepared_relist["$em$strong"];
			
			#
			# Each loop iteration search for the next emphasis token. 
			# Each token is then passed to handleSpanToken.
			#
			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
			$text_stack[0] .= $parts[0];
			$token =& $parts[1];
			$text =& $parts[2];
			
			if (empty($token)) {
				# Reached end of text span: empty stack without emitting.
				# any more emphasis.
				while ($token_stack[0]) {
					$text_stack[1] .= array_shift($token_stack);
					$text_stack[0] .= array_shift($text_stack);
				}
				break;
			}
			
			$token_len = strlen($token);
			if ($tree_char_em) {
				# Reached closing marker while inside a three-char emphasis.
				if ($token_len == 3) {
					# Three-char closing marker, close em and strong.
					array_shift($token_stack);
					$span = array_shift($text_stack);
					$span = $this->runSpanGamut($span);
					$span = "<strong><em>$span</em></strong>";
					$text_stack[0] .= $this->hashPart($span);
					$em = '';
					$strong = '';
				} else {
					# Other closing marker: close one em or strong and
					# change current token state to match the other
					$token_stack[0] = str_repeat($token{0}, 3-$token_len);
					$tag = $token_len == 2 ? "strong" : "em";
					$span = $text_stack[0];
					$span = $this->runSpanGamut($span);
					$span = "<$tag>$span</$tag>";
					$text_stack[0] = $this->hashPart($span);
					$$tag = ''; # $$tag stands for $em or $strong
				}
				$tree_char_em = false;
			} else if ($token_len == 3) {
				if ($em) {
					# Reached closing marker for both em and strong.
					# Closing strong marker:
					for ($i = 0; $i < 2; ++$i) {
						$shifted_token = array_shift($token_stack);
						$tag = strlen($shifted_token) == 2 ? "strong" : "em";
						$span = array_shift($text_stack);
						$span = $this->runSpanGamut($span);
						$span = "<$tag>$span</$tag>";
						$text_stack[0] .= $this->hashPart($span);
						$$tag = ''; # $$tag stands for $em or $strong
					}
				} else {
					# Reached opening three-char emphasis marker. Push on token 
					# stack; will be handled by the special condition above.
					$em = $token{0};
					$strong = "$em$em";
					array_unshift($token_stack, $token);
					array_unshift($text_stack, '');
					$tree_char_em = true;
				}
			} else if ($token_len == 2) {
				if ($strong) {
					# Unwind any dangling emphasis marker:
					if (strlen($token_stack[0]) == 1) {
						$text_stack[1] .= array_shift($token_stack);
						$text_stack[0] .= array_shift($text_stack);
					}
					# Closing strong marker:
					array_shift($token_stack);
					$span = array_shift($text_stack);
					$span = $this->runSpanGamut($span);
					$span = "<strong>$span</strong>";
					$text_stack[0] .= $this->hashPart($span);
					$strong = '';
				} else {
					array_unshift($token_stack, $token);
					array_unshift($text_stack, '');
					$strong = $token;
				}
			} else {
				# Here $token_len == 1
				if ($em) {
					if (strlen($token_stack[0]) == 1) {
						# Closing emphasis marker:
						array_shift($token_stack);
						$span = array_shift($text_stack);
						$span = $this->runSpanGamut($span);
						$span = "<em>$span</em>";
						$text_stack[0] .= $this->hashPart($span);
						$em = '';
					} else {
						$text_stack[0] .= $token;
					}
				} else {
					array_unshift($token_stack, $token);
					array_unshift($text_stack, '');
					$em = $token;
				}
			}
		}
		return $text_stack[0];
	}


	function doBlockQuotes($text) {
		$text = preg_replace_callback('/
			  (								# Wrap whole match in $1
				(?>
				  ^[ ]*>[ ]?			# ">" at the start of a line
					.+\n					# rest of the first line
				  (.+\n)*					# subsequent consecutive lines
				  \n*						# blanks
				)+
			  )
			/xm',
			array(&$this, '_doBlockQuotes_callback'), $text);

		return $text;
	}
	function _doBlockQuotes_callback($matches) {
		$bq = $matches[1];
		# trim one level of quoting - trim whitespace-only lines
		$bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq);
		$bq = $this->runBlockGamut($bq);		# recurse

		$bq = preg_replace('/^/m', "  ", $bq);
		# These leading spaces cause problem with <pre> content, 
		# so we need to fix that:
		$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx', 
			array(&$this, '_doBlockQuotes_callback2'), $bq);

		return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
	}
	function _doBlockQuotes_callback2($matches) {
		$pre = $matches[1];
		$pre = preg_replace('/^  /m', '', $pre);
		return $pre;
	}


	function formParagraphs($text) {
	#
	#	Params:
	#		$text - string to process with html <p> tags
	#
		# Strip leading and trailing lines:
		$text = preg_replace('/\A\n+|\n+\z/', '', $text);

		$grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);

		#
		# Wrap <p> tags and unhashify HTML blocks
		#
		foreach ($grafs as $key => $value) {
			if (!preg_match('/^B\x1A[0-9]+B$/', $value)) {
				# Is a paragraph.
				$value = $this->runSpanGamut($value);
				$value = preg_replace('/^([ ]*)/', "<p>", $value);
				$value .= "</p>";
				$grafs[$key] = $this->unhash($value);
			}
			else {
				# Is a block.
				# Modify elements of @grafs in-place...
				$graf = $value;
				$block = $this->html_hashes[$graf];
				$graf = $block;
//				if (preg_match('{
//					\A
//					(							# $1 = <div> tag
//					  <div  \s+
//					  [^>]*
//					  \b
//					  markdown\s*=\s*  ([\'"])	#	$2 = attr quote char
//					  1
//					  \2
//					  [^>]*
//					  >
//					)
//					(							# $3 = contents
//					.*
//					)
//					(</div>)					# $4 = closing tag
//					\z
//					}xs', $block, $matches))
//				{
//					list(, $div_open, , $div_content, $div_close) = $matches;
//
//					# We can't call Markdown(), because that resets the hash;
//					# that initialization code should be pulled into its own sub, though.
//					$div_content = $this->hashHTMLBlocks($div_content);
//					
//					# Run document gamut methods on the content.
//					foreach ($this->document_gamut as $method => $priority) {
//						$div_content = $this->$method($div_content);
//					}
//
//					$div_open = preg_replace(
//						'{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open);
//
//					$graf = $div_open . "\n" . $div_content . "\n" . $div_close;
//				}
				$grafs[$key] = $graf;
			}
		}

		return implode("\n\n", $grafs);
	}


	function encodeAttribute($text) {
	#
	# Encode text for a double-quoted HTML attribute. This function
	# is *not* suitable for attributes enclosed in single quotes.
	#
		$text = $this->encodeAmpsAndAngles($text);
		$text = str_replace('"', '&quot;', $text);
		return $text;
	}
	
	
	function encodeAmpsAndAngles($text) {
	#
	# Smart processing for ampersands and angle brackets that need to 
	# be encoded. Valid character entities are left alone unless the
	# no-entities mode is set.
	#
		if ($this->no_entities) {
			$text = str_replace('&', '&amp;', $text);
		} else {
			# Ampersand-encoding based entirely on Nat Irons's Amputator
			# MT plugin: <http://bumppo.net/projects/amputator/>
			$text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', 
								'&amp;', $text);;
		}
		# Encode remaining <'s
		$text = str_replace('<', '&lt;', $text);

		return $text;
	}


	function doAutoLinks($text) {
		$text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i', 
			array(&$this, '_doAutoLinks_url_callback'), $text);

		# Email addresses: <address@domain.foo>
		$text = preg_replace_callback('{
			<
			(?:mailto:)?
			(
				(?:
					[-!#$%&\'*+/=?^_`.{|}~\w\x80-\xFF]+
				|
					".*?"
				)
				\@
				(?:
					[-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+
				|
					\[[\d.a-fA-F:]+\]	# IPv4 & IPv6
				)
			)
			>
			}xi',
			array(&$this, '_doAutoLinks_email_callback'), $text);

		return $text;
	}
	function _doAutoLinks_url_callback($matches) {
		$url = $this->encodeAttribute($matches[1]);
		$link = "<a href=\"$url\">$url</a>";
		return $this->hashPart($link);
	}
	function _doAutoLinks_email_callback($matches) {
		$address = $matches[1];
		$link = $this->encodeEmailAddress($address);
		return $this->hashPart($link);
	}


	function encodeEmailAddress($addr) {
	#
	#	Input: an email address, e.g. "foo@example.com"
	#
	#	Output: the email address as a mailto link, with each character
	#		of the address encoded as either a decimal or hex entity, in
	#		the hopes of foiling most address harvesting spam bots. E.g.:
	#
	#	  <p><a href="&#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;&#x66;o&#111;
	#        &#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;&#101;&#46;&#x63;&#111;
	#        &#x6d;">&#x66;o&#111;&#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;
	#        &#101;&#46;&#x63;&#111;&#x6d;</a></p>
	#
	#	Based by a filter by Matthew Wickline, posted to BBEdit-Talk.
	#   With some optimizations by Milian Wolff.
	#
		$addr = "mailto:" . $addr;
		$chars = preg_split('/(?<!^)(?!$)/', $addr);
		$seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed.
		
		foreach ($chars as $key => $char) {
			$ord = ord($char);
			# Ignore non-ascii chars.
			if ($ord < 128) {
				$r = ($seed * (1 + $key)) % 100; # Pseudo-random function.
				# roughly 10% raw, 45% hex, 45% dec
				# '@' *must* be encoded. I insist.
				if ($r > 90 && $char != '@') /* do nothing */;
				else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
				else              $chars[$key] = '&#'.$ord.';';
			}
		}
		
		$addr = implode('', $chars);
		$text = implode('', array_slice($chars, 7)); # text without `mailto:`
		$addr = "<a href=\"$addr\">$text</a>";

		return $addr;
	}


	function parseSpan($str) {
	#
	# Take the string $str and parse it into tokens, hashing embeded HTML,
	# escaped characters and handling code spans.
	#
		$output = '';
		
		$span_re = '{
				(
					\\\\'.$this->escape_chars_re.'
				|
					(?<![`\\\\])
					`+						# code span marker
			'.( $this->no_markup ? '' : '
				|
					<!--    .*?     -->		# comment
				|
					<\?.*?\?> | <%.*?%>		# processing instruction
				|
					<[!$]?[-a-zA-Z0-9:_]+	# regular tags
					(?>
						\s
						(?>[^"\'>]+|"[^"]*"|\'[^\']*\')*
					)?
					>
				|
					<[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
				|
					</[-a-zA-Z0-9:_]+\s*> # closing tag
			').'
				)
				}xs';

		while (1) {
			#
			# Each loop iteration seach for either the next tag, the next 
			# openning code span marker, or the next escaped character. 
			# Each token is then passed to handleSpanToken.
			#
			$parts = preg_split($span_re, $str, 2, PREG_SPLIT_DELIM_CAPTURE);
			
			# Create token from text preceding tag.
			if ($parts[0] != "") {
				$output .= $parts[0];
			}
			
			# Check if we reach the end.
			if (isset($parts[1])) {
				$output .= $this->handleSpanToken($parts[1], $parts[2]);
				$str = $parts[2];
			}
			else {
				break;
			}
		}
		
		return $output;
	}
	
	
	function handleSpanToken($token, &$str) {
	#
	# Handle $token provided by parseSpan by determining its nature and 
	# returning the corresponding value that should replace it.
	#
		switch ($token{0}) {
			case "\\":
				return $this->hashPart("&#". ord($token{1}). ";");
			case "`":
				# Search for end marker in remaining text.
				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', 
					$str, $matches))
				{
					$str = $matches[2];
					$codespan = $this->makeCodeSpan($matches[1]);
					return $this->hashPart($codespan);
				}
				return $token; // return as text since no ending marker found.
			default:
				return $this->hashPart($token);
		}
	}


	function outdent($text) {
	#
	# Remove one level of line-leading tabs or spaces
	#
		return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text);
	}


	# String length function for detab. `_initDetab` will create a function to 
	# hanlde UTF-8 if the default function does not exist.
	var $utf8_strlen = 'mb_strlen';
	
	function detab($text) {
	#
	# Replace tabs with the appropriate amount of space.
	#
		# For each line we separate the line in blocks delemited by
		# tab characters. Then we reconstruct every line by adding the 
		# appropriate number of space between each blocks.
		
		$text = preg_replace_callback('/^.*\t.*$/m',
			array(&$this, '_detab_callback'), $text);

		return $text;
	}
	function _detab_callback($matches) {
		$line = $matches[0];
		$strlen = $this->utf8_strlen; # strlen function for UTF-8.
		
		# Split in blocks.
		$blocks = explode("\t", $line);
		# Add each blocks to the line.
		$line = $blocks[0];
		unset($blocks[0]); # Do not add first block twice.
		foreach ($blocks as $block) {
			# Calculate amount of space, insert spaces, insert block.
			$amount = $this->tab_width - 
				$strlen($line, 'UTF-8') % $this->tab_width;
			$line .= str_repeat(" ", $amount) . $block;
		}
		return $line;
	}
	function _initDetab() {
	#
	# Check for the availability of the function in the `utf8_strlen` property
	# (initially `mb_strlen`). If the function is not available, create a 
	# function that will loosely count the number of UTF-8 characters with a
	# regular expression.
	#
		if (function_exists($this->utf8_strlen)) return;
		$this->utf8_strlen = create_function('$text', 'return preg_match_all(
			"/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", 
			$text, $m);');
	}


	function unhash($text) {
	#
	# Swap back in all the tags hashed by _HashHTMLBlocks.
	#
		return preg_replace_callback('/(.)\x1A[0-9]+\1/', 
			array(&$this, '_unhash_callback'), $text);
	}
	function _unhash_callback($matches) {
		return $this->html_hashes[$matches[0]];
	}

}

/*

PHP Markdown
============

Description
-----------

This is a PHP translation of the original Markdown formatter written in
Perl by John Gruber.

Markdown is a text-to-HTML filter; it translates an easy-to-read /
easy-to-write structured text format into HTML. Markdown's text format
is mostly similar to that of plain text email, and supports features such
as headers, *emphasis*, code blocks, blockquotes, and links.

Markdown's syntax is designed not as a generic markup language, but
specifically to serve as a front-end to (X)HTML. You can use span-level
HTML tags anywhere in a Markdown document, and you can use block level
HTML tags (like <div> and <table> as well).

For more information about Markdown's syntax, see:

<http://daringfireball.net/projects/markdown/>


Bugs
----

To file bug reports please send email to:

<michel.fortin@michelf.ca>

Please include with your report: (1) the example input; (2) the output you
expected; (3) the output Markdown actually produced.


Version History
--------------- 

See the readme file for detailed release notes for this version.


Copyright and License
---------------------

PHP Markdown  
Copyright (c) 2004-2013 Michel Fortin  
<http://michelf.ca/>  
All rights reserved.

Based on Markdown  
Copyright (c) 2003-2006 John Gruber   
<http://daringfireball.net/>   
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

*	Redistributions of source code must retain the above copyright notice,
	this list of conditions and the following disclaimer.

*	Redistributions in binary form must reproduce the above copyright
	notice, this list of conditions and the following disclaimer in the
	documentation and/or other materials provided with the distribution.

*	Neither the name "Markdown" nor the names of its contributors may
	be used to endorse or promote products derived from this software
	without specific prior written permission.

This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.

*/
?>

Added sourceMakeup/license.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Copyright (c) 2012 Fredi Bach, 
http://fredibach.ch/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Added sourceMakeup/sourcemakeup.php.









































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<?php 
error_reporting(E_ALL ^ E_NOTICE);
	// # sourceMakeup
	//
	// sourceMakeup is a source code viewer written in PHP on the backend, and jQuery and jKit
	// on the frontend. sourceMakeup was heavely inspired by the first versions of 
	// [Docco](http://jashkenas.github.com/docco/), with some additional features that enhance
	// the frontend visually and feature wise. It was mainly developed as a source code viewer
	// for the jQuery based UI toolkit [jKit](http://jquery-jkit.com/). It's main use is to
	// create beautiful source documentation for JavaScript libraries and plugins, but it can
	// be used to document small PHP code and CSS markup as well, however, with some limitations. 
	//
	// Comments for sourceMakeup should be written in Markdown. This way sourceMakeup can correctly
	// and beautifully format the code and add a navigation menu linked to the different parts of your code.
	//
	// - Version: `0.7`
	// - Release date: `19. 3. 2013`
	// - [Documentation & Demos](http://jquery-jkit.com/sourcemakeup/)
	// - [Download](https://github.com/FrediBach/sourceMakeup/archive/master.zip)
	//
	// ## Copyright
	//
	// - (c) 2013 by *Fredi Bach*
	// - [Home](http://fredibach.ch/)
	//
	// ## License
	//
	// sourceMakeup is open source and MIT licensed. For more informations read the **license.txt** file 

	// ## Settings

	// - **$dir** contains the path to the documented files
	// - **$file** is the main file
	// - **$files** contains all the files, leave it empty if you don't want to restrict the list to certain files
	// - **$extensions** contains a comma separated list of allowed file extensions
	// - **$filter** filters out any files that contain a certain string
	// - **$dev** mode ignores the cache file and always generates a new one

	$dir = './';
	$file = 'sourcemakeup.php';
	$files = array(
				'../brickyard.php',
				'sourcemakeup.php',
				'js/jquery.jkit.1.1.29.js',
				'js/sourcemakeup.js',
				'css/sourcemakeup.css'
	);
	$extensions = 'js,php,css';
	$filter = '.min.js';
	$dev = true;

	// ## The Source

	// Is the main file the one from the settings or another one?

	if (isset($_GET['file']) && $_GET['file'] != ''){
		$file = $_GET['file'];
	}

	// Define the path for our cached file:
	
	$cachefile = 'cache/'.md5($file).'.txt';

	// Create a list of all files we want to document. In case **$files** is not empty, those files will be used and 
	// the following code block will be ignored.

	if (count($files) == 0){
		if ($dir != ''){
			$tempfiles = scandir($dir);
			$files = array();
			foreach($tempfiles as $f){
				if ($f != '.' && $f != '..' && stripos($f, $filter) === false){
					$allowed = explode(',', $extensions);
					$ext = pathinfo($f, PATHINFO_EXTENSION);
					if (in_array($ext, $allowed)) {
						$files[] = $f;
					}
				}
			}
		} else {
			$files = array($file);
		}
	}
	
	// Do we have to load the cahed file or create a new one?

	if (file_exists($cachefile) && !$dev){
		
		// Load the cached file:
		
		$output = file_get_contents($cachefile);
	
	} else {
		
		// Ok, so we need to create new output. To do that we first need to include the Markdown class:
		
		include_once "libs/markdown/markdown.php";
		
		// Load the file and create an array of all lines:
		
		$data = file_get_contents($file);
		$lines = explode("\n", $data);
		
		// Create some variables we need later:
		
		$blocks = array();
		$iscomment = false;
		$currentblock = 0;
		$linenumber = 0;
		
		// Step through all lines and combine them into codeblocks. Each codeblock can have following contents:
		//
		// - **comment** contains all comments of this codeblock
		// - **code** contains all code of this block
		// - **lnr** contains the original linenumbers for the above code
		
		foreach($lines as $line){
		
			$linenumber++;
		
			if (substr(trim($line),0,2) == '//'){
				if (!$iscomment){
					$currentblock++;
				}
				$blocks[$currentblock]['comment'] .= "\n".substr(trim($line),3);
				$blocks[$currentblock]['code'] .= "";
				$iscomment = true;
				if (substr(trim(substr(trim($line),3)),0,3) == '{!}'){
					$currentblock++;
				}
			} else {
				$blocks[$currentblock]['code'] .= "\n".str_replace("\t", "    ", $line);
				$blocks[$currentblock]['lnr'] .= "\n".$linenumber;
				$blocks[$currentblock]['comment'] .= "";
				$iscomment = false;
			}
	
		}
		
		// If this is a PHP script with **<?php** on the first line, we're going to remove it as it's only ruining our design:
		
		if (trim($blocks[0]['code']) == '<?php'){
			$blocks[0]['code'] = '';
		}
		
		// We have now all we need to construct the table tbody content that contains all of our code. The table 
		// has two columns, the first contains all the comments and the second one contains all the code.
	
		$output = '';
		
		// Loop through all blocks and construct the rows of our table:
	
		foreach($blocks as $block){
			
			// Each block is a row with a comment and a code column. Sometimes only one of them actually has content and 
			// if both have no content, simply skip this block.
			
			if (trim($block['comment']) != '' || trim($block['code']) != ''){
				
				$output .= '<tr class="docu">';
				
				if (substr(trim($block['comment']),0,3) == '{!}'){
					
					// This block is an instruction block. Instruction blocks can be created like this:
					//
					//     {!} instructiontype: instruction
					//
					// Instructions are normally hidden, but can be made visible. They are ment to contain special 
					// instructions either for a script or for code contributors. If you use them, make sure to supply the
					// icons for each of your instruction type. They have to ba named like this:
					//
					//     sourcemakeup.instructiontype.png
					//
					
					$split = explode(':', substr(trim($block['comment']),3));
					
					$block['comment'] = '<span class="itype">';
					$block['comment'] .= '<img src="imgs/sourcemakeup.'.trim($split[0]).'.png"> '.$split[0].'</span>';
					$block['comment'] .= ':<span class="iopt">'.$split[1].'</span>';
					
					$output .= '<td class="comment instruction">&nbsp;</td>';
					$output .= '<td class="code instruction">'.$block['comment'].'</td>';
					
				} else {
					
					// This is a regular codeblock. As we don't want to display any uneeded linebreaks, we
					// use a special funtion to strip them away. The function returns an array that not only
					// contains the stripped code, it tells us exactly how many lines where removed from the 
					// beginning and from the end. This way we can strip exactly the same number of lines from 
					// the linenumber string.
					
					$codedata = trimLinebreaks($block['code']);
				
					$templines = explode("\n", $block['lnr']);
				
					if ($codedata['shifted'] > 0){
						for ($i=1; $i<=$codedata['shifted']; $i++){
							array_shift($templines);
						}
					}
				
					if ($codedata['popped'] > 0){
						for ($i=1; $i<=$codedata['popped']; $i++){
							array_pop($templines);
						}
					}
				
					$lnr = implode("\n", $templines);
					
					// For the comment column, we basically do two things. We parse the Markdown formatting into nice HTML
					// with the Markdown library, and we than add ids to all HTML headers so that we can create an anchor navigation.
				
					$output .= '<td class="comment">'.addHeaderAnchors(Markdown(trim($block['comment']))).'</td>';
					
					// All we need to do for the code is escape the HTML special chars. The formatting is done by the Google Code Prettifier JavaScript.
					
					$output .= '<td class="code"><pre class="linenumbers">'.$lnr.'</pre>';
					$output .= '<pre class="prettyprint">'.htmlspecialchars($codedata['code']).'</pre></td>';
				}
				
				$output .= '</tr>';
				
			}
		}
		
		// Now as we created our output, we save it in a cache for later use:
		
		$fh = fopen($cachefile, 'w') or die("can't open file");
		fwrite($fh, $output);
		fclose($fh);
	
	}
	
	// And lastly, we inlude the template to generate our output:

	include 'sourcemakeup.template.php';

	
	// ## Functions
	
	// The **addHeaderAnchors** function and the regex callback function **addHeaderAnchorsCallback**
	// add ids to each header in the supplied HTML based on the title of the header.
	
	function addHeaderAnchors($text){
		return preg_replace_callback('/\<h([0-6]{1})\>(.+)\<\/h[0-6]{1}\>/', 'addHeaderAnchorsCallback', $text);
	}
	
	function addHeaderAnchorsCallback($matches){
		return '<h'.$matches[1].' id="'.createURLSlug($matches[2]).'">'.$matches[2].'</h'.$matches[1].'>';
	}
	
	// The **createURLSlug** function makes a nice url slug where all special characters are removed and spaces replaced with 
	// the "-" character.

	function createURLSlug($str, $replace=array(), $delimiter='-'){
		if( !empty($replace) ) {
			$str = str_replace((array)$replace, ' ', $str);
		}

		$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
		$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
		$clean = strtolower(trim($clean, '-'));
		$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);

		return $clean;
	}
	
	// The **trimLinebreaks** function removes all unneaded linebreaks before an after a string and tells 
	// us in the return array exactly how many of them.

	function trimLinebreaks($string){
	
		$lines = explode("\n", $string);
	
		$shifted = 0;
		$popped = 0;
	
		while(trim($lines[0]) == '' && count($lines) > 0){
			array_shift($lines);
			$shifted++;
		}
	
		while( trim( $lines[count($lines)-1] ) == '' && count($lines) > 0){
			array_pop($lines);
			$popped++;
		}
	
		$arr = array('code' => implode("\n", $lines), 'shifted' => $shifted, 'popped' => $popped);
	
		return $arr;
	
	}

Added sourceMakeup/sourcemakeup.template.php.



















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<title>sourceMakeup - File <?php echo $file; ?></title>

	<meta name="viewport" content="width=1280, initial-scale=1, maximum-scale=1">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

	<link rel="shortcut icon" type="image/x-icon" href="http://jquery-jkit.com/favicon.ico" />

	<script src="js/jquery-1.9.1.min.js"></script>
	<script src="js/jquery.easing.1.3.js"></script>
	<script src="js/jquery.jkit.1.1.29.min.js"></script>
	<script src="js/sourcemakeup.js"></script>

	<script type="text/javascript" src="libs/google-code-prettify/prettify.js"></script>
	<link href="libs/google-code-prettify/prettify.css" type="text/css" rel="stylesheet" />

	<link href="css/sourcemakeup.css" type="text/css" rel="stylesheet" />

</head>
<body>
	
	<div id="options" data-jkit="[tooltip:text=Show compiler instructions?]"><input type="checkbox" id="showinstructions" value="1"></div>
	<div id="search" data-jkit="[filter:global=yes;by=text;affected=tr.docu;loader=#spinner]"><input class="jkit-filter" placeholder="search ..." type="text" value=""></div>
	<div id="overview" data-jkit="[summary:what=headers;linked=yes;from=table.container;scope=all;style=select;indent=yes]"></div>
	
	<table class="container" cellpadding="0" cellspacing="0">
		<thead>
			<tr>
				<th class="comment">
					<select id="files">
					<?php foreach($files as $f) : ?>
						<?php if(conditions) { ?>
							<option selected><?=$f?></option>
						<?php } else { ?>
							<option><?=$f?></option>
						<?php } ?>
					<?php endforeach; ?>
					</select>Documentation
				</th>
				<th class="code">
					Code
				</th>
			</tr>
		</thead>
		<tbody>
			<?=$output?>
		</tbody>
	</table>
	
	<div id="spinner"><img src="imgs/spinner.gif"></div>
	
</body>
</html>