Head Cleaner - Version 1.0.0

Version Description

Download this release

Release Info

Developer wokamoto
Plugin Icon wp plugin Head Cleaner
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

head-cleaner.php ADDED
@@ -0,0 +1,1790 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Head Cleaner
4
+ Version: 1.0.0
5
+ Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
+ Description: Cleaning tags from your WordPress header and footer.
7
+ Author: wokamoto
8
+ Author URI: http://dogmap.jp/
9
+
10
+ License:
11
+ Released under the GPL license
12
+ http://www.gnu.org/copyleft/gpl.html
13
+
14
+ Copyright 2009 wokamoto (email : wokamoto1973@gmail.com)
15
+
16
+ This program is free software; you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation; either version 2 of the License, or
19
+ (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
+
30
+ Includes:
31
+ PHP Simple HTML DOM Parser Ver.1.11
32
+ http://sourceforge.net/projects/simplehtmldom/
33
+ Licensed under The MIT License
34
+
35
+ jsmin.php - PHP implementation of Douglas Crockford's JSMin. Ver.1.1.1 (2008-03-02)
36
+ Copyright (c) 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
37
+ Copyright (c) 2008 Ryan Grove <ryan@wonko.com> (PHP port)
38
+ License http://opensource.org/licenses/mit-license.php MIT License
39
+
40
+ CSSTidy - CSS Parser and Optimiser Ver.1.3
41
+ @author Florian Schmitz (floele at gmail dot com) 2005-2006
42
+ @license http://opensource.org/licenses/gpl-license.php GNU Public License
43
+ */
44
+
45
+ //**************************************************************************************
46
+ // Defines
47
+ //**************************************************************************************
48
+ define('HC_PRIORITY', 10000);
49
+ define('HC_XMLNS', 'http://www.w3.org/1999/xhtml');
50
+
51
+
52
+ //**************************************************************************************
53
+ if (version_compare(phpversion(), "5.0.0", ">=")) :
54
+
55
+ if (!defined('ABSPATH') && strstr($_SERVER['PHP_SELF'], '/head-cleaner.php')) {
56
+ define('HC_EXPIRED_JS_CSS', 60 * 60 * 24 * 30);
57
+ define('HC_CACHE_DIR', '/../../cache/head-cleaner');
58
+
59
+ if (isset($_GET['f']) && isset($_GET['t'])) {
60
+ $cache_path = realpath(dirname(__FILE__) . HC_CACHE_DIR) . '/';
61
+ $filename_hash = trim(stripslashes($_GET['f']));
62
+ $type = trim(stripslashes($_GET['t']));
63
+
64
+ if (strlen($filename_hash) == 32 && ($type == 'js' || $type == 'css')) {
65
+ $is_gzip = (strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== FALSE);
66
+ $filename = "{$cache_path}{$type}/{$filename_hash}.{$type}" . ($is_gzip ? '.gz' : '');
67
+ if (file_exists($filename)) {
68
+ $offset = (!defined('HC_EXPIRED_JS_CSS') ? HC_EXPIRED_JS_CSS : 60 * 60 * 24 * 30);
69
+ $content_type = 'text/' . ($type == 'js' ? 'javascript' : $type);
70
+
71
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($filename)).' GMT');
72
+ header('Expires: '.gmdate('D, d M Y H:i:s', time() + $offset).' GMT');
73
+ header("Content-type: $content_type");
74
+
75
+ if ($is_gzip)
76
+ header('Content-Encoding: gzip');
77
+
78
+ readfile($filename);
79
+ exit();
80
+ } else {
81
+ header('HTTP/1.1 404 Not Found');
82
+ echo "404 : Not Found";
83
+ die();
84
+ }
85
+ } else {
86
+ header("HTTP/1.0 403 Forbidden");
87
+ echo "403 : Forbidden";
88
+ die();
89
+ }
90
+ } else {
91
+ header("HTTP/1.0 403 Forbidden");
92
+ echo "403 : Forbidden";
93
+ die();
94
+ }
95
+ }
96
+
97
+ //**************************************************************************************
98
+ // Require
99
+ //**************************************************************************************
100
+ if (!class_exists('wokController') || !class_exists('wokScriptManager'))
101
+ require(dirname(__FILE__).'/includes/common-controller.php');
102
+
103
+ //**************************************************************************************
104
+ // Head Cleaner
105
+ //**************************************************************************************
106
+ class HeadCleanerController extends wokController {
107
+ public $plugin_name = 'head-cleaner';
108
+ public $plugin_ver = '1.0.0';
109
+
110
+ // Deafault Options
111
+ private $options_default = array(
112
+ 'foot_js' => false
113
+ , 'dynamic' => false
114
+ , 'js_move_foot' => false
115
+ , 'cache_enabled' => true
116
+ , 'combined_css' => true
117
+ , 'combined_js' => true
118
+ , 'js_minify' => false
119
+ , 'css_optimise' => false
120
+ , 'csstidy_option' => array(
121
+ 'optimise_shorthands' => 1
122
+ , 'compress_colors' => true
123
+ , 'compress_font_weight' => true
124
+ , 'remove_bslash' => true
125
+ , 'template' => 1
126
+ )
127
+ , 'default_media' => 'screen'
128
+ , 'debug_mode' => false
129
+ , 'filters' => array('wp_head' => array(), 'wp_footer' => array())
130
+ , 'priority' => array('wp_head' => array(), 'wp_footer' => array())
131
+ );
132
+ private $csstidy_template = array(
133
+ 'low_compression'
134
+ , 'default'
135
+ , 'high_compression'
136
+ , 'highest_compression'
137
+ );
138
+
139
+ private $wp_url = '';
140
+ private $self_url = '';
141
+ private $cache_path = '';
142
+ private $cache_url = '';
143
+
144
+ private $lang;
145
+ private $foot_js_src;
146
+
147
+ private $mtime_start;
148
+
149
+ private $filters;
150
+
151
+ /**********************************************************
152
+ * Constructor
153
+ ***********************************************************/
154
+ public function HeadCleanerController() {
155
+ $this->__construct();
156
+ }
157
+ public function __construct() {
158
+ $this->init(__FILE__);
159
+ $this->options = $this->_init_options($this->getOptions());
160
+ $this->filters = $this->options['filters'];
161
+
162
+ $this->wp_url = trailingslashit(get_bloginfo('wpurl'));
163
+ $this->self_url = str_replace(ABSPATH, $this->wp_url, __FILE__);
164
+ $this->lang = (defined('WPLANG') ? WPLANG : 'ja');
165
+ $this->charset = get_option('blog_charset');
166
+ $this->_get_filters('wp_head');
167
+ $this->_get_filters('wp_footer');
168
+
169
+ // Create Directory for Cache
170
+ if ( $this->options['cache_enabled'] ) {
171
+ $this->cache_path = $this->_create_cache_dir();
172
+ if ($this->cache_path !== FALSE) {
173
+ $this->cache_url = str_replace(ABSPATH, $this->wp_url, $this->cache_path);
174
+ } else {
175
+ $this->options['cache_enabled'] = false;
176
+
177
+ $this->options['combined_css'] = false;
178
+ $this->options['combined_js'] = false;
179
+
180
+ $this->options['js_minify'] = false;
181
+ $this->options['css_optimise'] = false;
182
+ }
183
+ }
184
+
185
+ // Require PHP Libraries
186
+ $this->_require_libraries();
187
+ }
188
+
189
+ /**********************************************************
190
+ * Init Options
191
+ ***********************************************************/
192
+ private function _init_options($wk_options = '') {
193
+ if (!is_array($wk_options))
194
+ $wk_options = array();
195
+
196
+ foreach ($this->options_default as $key => $val) {
197
+ $wk_options[$key] = (isset($wk_options[$key]) ? $wk_options[$key] : $val);
198
+ }
199
+
200
+ return $wk_options;
201
+ }
202
+
203
+ /**********************************************************
204
+ * Require Libraries
205
+ ***********************************************************/
206
+ private function _require_libraries(){
207
+ $includes = dirname(__FILE__) . '/includes/';
208
+
209
+ // PHP Simple HTML DOM Parser
210
+ if (!function_exists('str_get_html'))
211
+ require($includes . 'simple_html_dom.php' );
212
+
213
+ // jsmin.php - PHP implementation of Douglas Crockford's JSMin.
214
+ if ($this->options['js_minify']) {
215
+ require($includes . 'jsmin-1.1.1.php');
216
+ $this->options['js_minify'] = class_exists('JSMin') && $this->options['js_minify'];
217
+ }
218
+
219
+ // CSSTidy - CSS Parser and Optimiser
220
+ if ($this->options['css_optimise']) {
221
+ require($includes . 'csstidy-1.3/class.csstidy.php');
222
+ $this->options['css_optimise'] = class_exists('csstidy') && $this->options['css_optimise'];
223
+ }
224
+ }
225
+
226
+ //**************************************************************************************
227
+ // plugin activation
228
+ //**************************************************************************************
229
+ public function activation(){
230
+ $cache_dir = $this->_create_cache_dir();
231
+ $this->_create_htaccess($cache_dir);
232
+ $this->_create_htaccess(dirname(__FILE__) . '/includes/js');
233
+ }
234
+
235
+ //**************************************************************************************
236
+ // plugin deactivation
237
+ //**************************************************************************************
238
+ public function deactivation(){
239
+ // $this->_remove_cache_file();
240
+ }
241
+
242
+ //**************************************************************************************
243
+ // ob_start for Header
244
+ //**************************************************************************************
245
+ public function head_start(){
246
+ if (! $this->_is_ktai() ) {
247
+ ob_start(array(&$this, 'head_cleaner'));
248
+ $this->mtime_start = microtime();
249
+ add_action('wp_head', array(&$this, 'end'), HC_PRIORITY);
250
+ $this->_get_filters('wp_head');
251
+ $this->_change_filters_priority('wp_head');
252
+ if ($this->options['foot_js'])
253
+ add_action('wp_footer', array(&$this, 'footer_start'), 1);
254
+ }
255
+ }
256
+
257
+ //**************************************************************************************
258
+ // ob_start for footer
259
+ //**************************************************************************************
260
+ public function footer_start(){
261
+ if (! $this->_is_ktai() && $this->options['foot_js'] ) {
262
+ ob_start(array(&$this, 'footer_cleaner'));
263
+ $this->mtime_start = microtime();
264
+ add_action('wp_footer', array(&$this, 'end'), HC_PRIORITY);
265
+ $this->_get_filters('wp_footer');
266
+ $this->_change_filters_priority('wp_footer');
267
+ }
268
+ }
269
+
270
+ //**************************************************************************************
271
+ // ob_end_flush
272
+ //**************************************************************************************
273
+ public function end(){
274
+ ob_end_flush();
275
+ }
276
+
277
+ //**************************************************************************************
278
+ // filters info save
279
+ //**************************************************************************************
280
+ public function filters_save(){
281
+ if ($this->_chk_filters_update()) {
282
+ $this->options['filters'] = $this->filters;
283
+ $this->updateOptions();
284
+ }
285
+ }
286
+
287
+ //**************************************************************************************
288
+ // head cleaner
289
+ //**************************************************************************************
290
+ public function head_cleaner($buffer) {
291
+ if (!function_exists('str_get_html'))
292
+ return trim($buffer) . "\n";
293
+
294
+ $url = $this->_get_permalink();
295
+
296
+ $xml_head = "<?xml version=\"1.0\" encoding=\"{$this->charset}\"?>\n";
297
+ $html_tag = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"{$this->lang}\" lang=\"{$this->lang}\">\n";
298
+ $head_tag = "<head profile=\"http://gmpg.org/xfn/11\">\n";
299
+ $head_txt = trim($buffer);
300
+
301
+ $ret_val = '';
302
+ $meta_tag = ''; $title_tag = ''; $base_tag = '';
303
+ $link_tag = ''; $object_tag = ''; $other_tag = '';
304
+ $css_tag = ''; $inline_css = '';
305
+ $script_tag = ''; $inline_js = '';
306
+
307
+ $ua = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
308
+ $ie = (strpos($ua, 'msie') !== false)
309
+ && (! preg_match('/(gecko|applewebkit|opera|sleipnir|chrome)/i', $ua));
310
+ $ie_ver = ($ie ? preg_replace('/^.*msie +([\d\.]+);.*$/i', '$1', $ua) : false);
311
+ $ie6 = ($ie ? version_compare($ie_ver, '7.0', '<') : false);
312
+ if ($ie) {
313
+ // for IE conditional tag
314
+ $replace_pattern = '/<\!-+[ \t]*\[if IE%s[ \t]*?\][ \t]*>(.*?)<\![ \t]*\[endif\][ \t]*-+>/ism';
315
+ $head_txt = preg_replace(sprintf($replace_pattern, ''), '$1', $head_txt);
316
+
317
+ if (version_compare($ie_ver, '5.5', '<')) // IE 5
318
+ $replace_pattern = sprintf($replace_pattern, ' 5\.0');
319
+ elseif (version_compare($ie_ver, '6.0', '<')) // IE 5.5
320
+ $replace_pattern = sprintf($replace_pattern, ' 5\.5');
321
+ elseif (version_compare($ie_ver, '7.0', '<')) // IE 6
322
+ $replace_pattern = sprintf($replace_pattern, ' 6\.?0?');
323
+ elseif (version_compare($ie_ver, '8.0', '<')) // IE 7
324
+ $replace_pattern = sprintf($replace_pattern, ' 7\.?0?');
325
+ elseif (version_compare($ie_ver, '9.0', '<')) // IE 8
326
+ $replace_pattern = sprintf($replace_pattern, ' 8\.?0?');
327
+ else
328
+ $replace_pattern = '';
329
+
330
+ if (!empty($replace_pattern))
331
+ $head_txt = preg_replace($replace_pattern, '$1', $head_txt);
332
+ }
333
+
334
+ if (preg_match('/^(.*)(<html[^>]*>[^<]*)(<head[^>]*>[^<]*)(.*)$/ism', $head_txt, $matches)) {
335
+ $ret_val = trim($matches[1]) . "\n";
336
+ $html_tag = trim($matches[2]) . "\n";
337
+ $head_tag = trim($matches[3]) . "\n";
338
+ $head_txt = trim($matches[4]) . "\n";
339
+ }
340
+ unset($matches);
341
+ $html_txt = $xml_head . $html_tag . $head_tag
342
+ . $head_txt
343
+ . '</head><body></body></html>';
344
+
345
+ // Get Simple DOM Object
346
+ $dom = str_get_html($html_txt);
347
+ if ($dom === false)
348
+ return (trim($buffer)."\n");
349
+
350
+ $xmlns = (defined('HC_XMLNS') ? HC_XMLNS : 'http://www.w3.org/1999/xhtml');
351
+ $xml_lang = $this->lang;
352
+ $lang = $this->lang;
353
+ if (preg_match_all('/ +([^ ]*)=[\'"]([^\'"]*)[\'"]/', $html_tag, $mathes, PREG_SET_ORDER)) {
354
+ foreach ($matches as $matche) {
355
+ switch ($matche[1]){
356
+ case 'xmlns': $xmlns = $matche[2]; break;
357
+ case 'xml:lang': $xml_lang = $matche[2]; break;
358
+ case 'lang': $lang = $matche[2]; break;
359
+ }
360
+ }
361
+ unset($matche);
362
+ }
363
+ unset($matches);
364
+ $html_tag = "<html xmlns=\"{$xmlns}\" xml:lang=\"{$xml_lang}\" lang=\"{$lang}\">\n";
365
+
366
+ $meta_tag = $this->_dom_to_html($dom->find("meta"));
367
+ $title_tag = $this->_dom_to_html($dom->find("title"), 1);
368
+ $base_tag = $this->_dom_to_html($dom->find("base"), 1);
369
+ $link_tag = $this->_dom_to_html($dom->find("link[rel!='stylesheet']"));
370
+ if (count($dom->find("link[rel='canonical']")) <= 0)
371
+ $link_tag .= '<link rel="canonical" href="' . htmlspecialchars($url, ENT_QUOTES) . '" />'."\n";
372
+
373
+ $css_tag = ''; $inner_css = ''; $css_src = array();
374
+ $elements = $dom->find("link[rel='stylesheet']");
375
+ foreach ((array)$elements as $element) {
376
+ $tag = trim($element);
377
+ if (isset($element->href)) {
378
+ $src = str_replace($this->wp_url, ABSPATH, trim(preg_replace('/\.css\?.*$/i', '.css', $element->href)));
379
+ $this->_file_gzip($src);
380
+ }
381
+
382
+ if (strpos($css_tag, $tag) === FALSE) {
383
+ if (strpos($element->href, $this->wp_url) === FALSE) {
384
+ $css_tag .= $tag . "\n";
385
+ } else {
386
+ $media = trim(isset($element->media) ? $element->media : $this->options['default_media']);
387
+ $media = (empty($media) ? $this->options['default_media'] : $media);
388
+ $inner_css .= trim($tag) . "\n";
389
+ $css_src[$media][] = $element->href;
390
+ }
391
+ }
392
+ }
393
+ unset($element); unset($elements);
394
+
395
+ $elements = $dom->find("style");
396
+ $wk_inline_css = array();
397
+ foreach ((array)$elements as $element) {
398
+ $media = trim(isset($element->media) ? $element->media : $this->options['default_media']);
399
+ $media = (empty($media) ? $this->options['default_media'] : $media);
400
+ $wk_inline_css[$media] .= $this->_remove_comment($element->innertext, 'css');
401
+ }
402
+ $inline_css = '';
403
+ if ($this->options['cache_enabled']) {
404
+ if ($this->options['combined_css']) {
405
+ $css_tag = trim($css_tag) . "\n";
406
+ foreach ($css_src as $key => $val) {
407
+ $inner_css = $this->_combined_css($val, trim(isset($wk_inline_css[$key]) ? $wk_inline_css[$key] : '' ), $key);
408
+ $css_tag .= trim($inner_css) . "\n";
409
+ if (isset($wk_inline_css[$key])) $wk_inline_css[$key] = '';
410
+ }
411
+ foreach ($wk_inline_css as $key => $val) {
412
+ if (!empty($val)) {
413
+ $inner_css = $this->_combined_css(array(), $val, $key);
414
+ $css_tag .= trim($inner_css) . "\n";
415
+ }
416
+ }
417
+ } else {
418
+ $css_tag = trim(trim($css_tag) . "\n" . trim($inner_css)) . "\n";
419
+ foreach ($wk_inline_css as $key => $val) {
420
+ if (!empty($val)) {
421
+ $inner_css = $this->_combined_inline_css(trim($val), $key);
422
+ $inline_css .= trim($inner_css) . "\n";
423
+ }
424
+ }
425
+ }
426
+ } else {
427
+ $css_tag = trim(trim($css_tag) . "\n" . trim($inner_css)) . "\n";
428
+ foreach ($wk_inline_css as $key => $val) {
429
+ if (!empty($val)) {
430
+ $inline_css .= "<style type=\"text/css\" media=\"{$key}\">/*<![CDATA[ */\n"
431
+ . trim($val)
432
+ . "\n/* ]]>*/</style>\n";
433
+ }
434
+ }
435
+ }
436
+ $css_tag = trim($css_tag) . (!empty($css_tag) ? "\n" : '');
437
+ $inner_css = trim($inner_css) . (!empty($inner_css) ? "\n" : '');
438
+ $inline_css = trim($inline_css) . (!empty($inline_css) ? "\n" : '');
439
+ unset($wk_inline_css);
440
+ unset($element); unset($elements);
441
+
442
+ if ($this->_is_javascript()) {
443
+ $inner_js = ''; $js_src = array();
444
+ $elements = $dom->find("script");
445
+ $js_libs = array();
446
+ foreach ((array)$elements as $element) {
447
+ if (!isset($element->src)) {
448
+ $inline_js .= $this->_remove_comment($element->innertext, 'js');
449
+ } else {
450
+ $src = trim($element->src);
451
+ if (preg_match('/\/((prototype|jquery|mootools)\.js)\?ver=([\.\d]+)[^\?]*$/i', $src, $matches)) {
452
+ list($find, $filename, $product, $version) = $matches;
453
+ $version = trim(substr($version, -1) === '.' ? substr($version, 0, -1) : $version);
454
+ if (empty($version) || $version == 'min')
455
+ $version = preg_replace('/^.*\/([\.\d]+)\/.*$/', '$1', $src);
456
+ if (!preg_match('/^[\.\d]*\d$/', $version))
457
+ $version = '1';
458
+ $js_libs[$product][$version] = $src;
459
+ } elseif (preg_match('/\/((prototype|jquery|mootools)[\-\.](min|[\.\d]+)[^\/]*\.js)\?[^\?]*$/i', $src, $matches)) {
460
+ list($find, $filename, $product, $version) = $matches;
461
+ $version = trim(substr($version, -1) === '.' ? substr($version, 0, -1) : $version);
462
+ if (empty($version) || $version == 'min')
463
+ $version = preg_replace('/^.*\/([\.\d]+)\/.*$/', '$1', $src);
464
+ if (!preg_match('/^[\.\d]*\d$/', $version))
465
+ $version = '1';
466
+ $js_libs[$product][$version] = $src;
467
+ } elseif (strpos($element->src, $this->wp_url) === FALSE) {
468
+ $script_tag .= trim($element) . "\n";
469
+ } else {
470
+ $inner_js .= trim($element) . "\n";
471
+ $js_src[] = $element->src;
472
+ }
473
+ unset($matches);
474
+ }
475
+ }
476
+ unset($element); unset($elements);
477
+
478
+ // JavaScript FrameWork (Prototype.js > jQuery > mootools)
479
+ if (count($js_libs) > 0) {
480
+ list($js_libs_src, $wk_inner_js, $wk_outer_js) = $this->_js_framework($js_libs);
481
+
482
+ if (count($js_libs_src) > 0)
483
+ $js_src = array_merge($js_libs_src, $js_src);
484
+
485
+ $script_tag = $script_tag . $wk_outer_js;
486
+ $inner_js = $wk_inner_js . $inner_js;
487
+
488
+ unset($js_libs_src); unset($js_libs);
489
+ }
490
+
491
+ $inline_js = trim($inline_js);
492
+ if ($this->options['cache_enabled']) {
493
+ if ($this->options['combined_js']) {
494
+ $inner_js = $this->_combined_javascript($js_src, trim($inline_js));
495
+ $script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
496
+ $inline_js = '';
497
+ } else {
498
+ $script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
499
+ $inline_js = $this->_combined_inline_javascript(trim($inline_js));
500
+ }
501
+ } else {
502
+ $script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
503
+ $inline_js = (!empty($inline_js) ? "<script type=\"text/javascript\">//<![CDATA[\n{$inline_js}\n//]]></script>\n" : '');
504
+ }
505
+ $script_tag = trim($script_tag) . (!empty($script_tag) ? "\n" : '');
506
+ $inner_js = trim($inner_js) . (!empty($inner_js) ? "\n" : '');
507
+ $inline_js = trim($inline_js) . (!empty($inline_js) ? "\n" : '');
508
+ }
509
+
510
+ $object_tag = $this->_dom_to_html($dom->find("object"));
511
+
512
+ $dom->clear(); unset($dom);
513
+
514
+ $ret_val .=
515
+ $html_tag
516
+ . $head_tag
517
+ . $meta_tag
518
+ . $title_tag
519
+ . $base_tag
520
+ . $link_tag
521
+ . $css_tag
522
+ . $inline_css
523
+ . (!$this->options['js_move_foot'] ? $script_tag : '')
524
+ . (!$this->options['js_move_foot'] ? $inline_js : '')
525
+ . $object_tag
526
+ ;
527
+ $ret_val = str_replace('\'', '"', $ret_val);
528
+
529
+ if ($this->options['js_move_foot']) {
530
+ $this->foot_js_src = trim($script_tag . $inline_js);
531
+ if (!empty($this->foot_js_src))
532
+ $this->foot_js_src .= "\n";
533
+ add_action('wp_footer', array(&$this, 'footer'), 9);
534
+ }
535
+
536
+ $ret_val = ($ie6
537
+ ? preg_replace('/^<\?xml[^>]*>/i', '', $ret_val)
538
+ : (strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
539
+ );
540
+ $ret_val = trim($ret_val) . "\n";
541
+
542
+ if ($this->options['debug_mode'])
543
+ $ret_val .= $this->_get_debug_info($buffer);
544
+
545
+ return $ret_val;
546
+ }
547
+
548
+ //**************************************************************************************
549
+ // JavaScript Moved bottom
550
+ //**************************************************************************************
551
+ public function footer(){
552
+ echo $this->foot_js_src;
553
+ }
554
+
555
+ //**************************************************************************************
556
+ // footer cleaner
557
+ //**************************************************************************************
558
+ public function footer_cleaner($buffer) {
559
+ if (!function_exists('str_get_html'))
560
+ return trim($buffer) . "\n";
561
+
562
+ $ret_val = '';
563
+ $script_tag = ''; $inline_js = '';
564
+ $other_tag = '';
565
+
566
+ $html_txt = '<html><head></head><body>'
567
+ . '<div id="footer">' . trim($buffer) . '</div>'
568
+ . '</body></html>';
569
+
570
+ // Get Simple DOM Object
571
+ $dom = str_get_html($html_txt);
572
+ if ($dom === false)
573
+ return (trim($buffer)."\n");
574
+
575
+ $inner_js = ''; $js_src = array();
576
+ $elements = $dom->find("div#footer *");
577
+ foreach ((array)$elements as $element) {
578
+ switch ($element->tag) {
579
+ case 'script':
580
+ if ($this->_is_javascript()) {
581
+ if (!isset($element->src)) {
582
+ $inline_js .= $this->_remove_comment($element->innertext, 'js');
583
+ } else {
584
+ if (strpos($element->src, $this->wp_url) === FALSE) {
585
+ $script_tag .= trim($element) . "\n";
586
+ } else {
587
+ $inner_js .= trim($element) . "\n";
588
+ $js_src[] = preg_replace('/\.gz$/i', '', $element->src);
589
+ }
590
+ }
591
+ }
592
+ break;
593
+ default:
594
+ $tag = trim($element);
595
+ if (strpos($other_tag, $tag) === FALSE && ! preg_match('/^<\!\-+/', $tag))
596
+ $other_tag .= $tag . "\n";
597
+ break;
598
+ }
599
+ }
600
+ unset($element); unset($elements);
601
+
602
+ $inline_js = trim($inline_js);
603
+ if ($this->options['cache_enabled']) {
604
+ if ($this->options['combined_js']) {
605
+ $inner_js = $this->_combined_javascript($js_src, trim($inline_js));
606
+ $script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
607
+ $inline_js = '';
608
+ } else {
609
+ $script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
610
+ $inline_js = $this->_combined_inline_javascript(trim($inline_js));
611
+ }
612
+ } else {
613
+ $script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
614
+ $inline_js = (!empty($inline_js) ? "<script type=\"text/javascript\">//<![CDATA[\n{$inline_js}\n//]]></script>\n" : '');
615
+ }
616
+
617
+ $dom->clear(); unset($dom);
618
+
619
+ $ret_val .=
620
+ $other_tag
621
+ . $script_tag
622
+ . $inline_js
623
+ ;
624
+ $ret_val = str_replace('\'', '"', $ret_val);
625
+ $ret_val = trim($ret_val) . "\n";
626
+
627
+ if ($this->options['debug_mode'])
628
+ $ret_val .= $this->_get_debug_info($buffer);
629
+
630
+ return $ret_val;
631
+ }
632
+
633
+ //**************************************************************************************
634
+ // WP_CONTENT_DIR
635
+ //**************************************************************************************
636
+ private function _wp_content_dir($path = '') {
637
+ return (!defined('WP_CONTENT_DIR')
638
+ ? WP_CONTENT_DIR
639
+ : ABSPATH . 'wp-content'
640
+ ) . $path;
641
+ }
642
+
643
+ //**************************************************************************************
644
+ // is login?
645
+ //**************************************************************************************
646
+ private function _is_user_logged_in() {
647
+ if (function_exists('is_user_logged_in')) {
648
+ return is_user_logged_in();
649
+ } else {
650
+ global $user;
651
+ if (!isset($user)) $user = wp_get_current_user();
652
+ return (!empty($user->ID));
653
+ }
654
+ }
655
+
656
+ //**************************************************************************************
657
+ // Is JavaScript ?
658
+ //**************************************************************************************
659
+ private function _is_javascript($ua = '') {
660
+ if (function_exists('get_browser')) {
661
+ $browser = get_browser(null, true);
662
+ if ($browser[javascript])
663
+ return true;
664
+ }
665
+
666
+ $ua = strtolower(empty($ua) ? $_SERVER['HTTP_USER_AGENT'] : $ua);
667
+ $pattern = '/(msie|gecko|applewebkit|opera|safari|sleipnir|chrome)/i';
668
+ if (preg_match($pattern, $ua))
669
+ //return !$this->_is_bot($ua);
670
+ return true;
671
+ else
672
+ return false;
673
+ }
674
+
675
+ //**************************************************************************************
676
+ // Is bot ?
677
+ //**************************************************************************************
678
+ private function _is_bot( $ua = '', $bots = '' ){
679
+ $bots = "Crawler"
680
+ .",libwww-perl"
681
+ .",TrackBack"
682
+ .",libghttp"
683
+ .",Google"
684
+ .",http://www.google.com/bot.html"
685
+ .",Yahoo"
686
+ .",http://help.yahoo.com/help/us/ysearch/slurp"
687
+ .",http://help.yahoo.co.jp/help/jp/blog-search/"
688
+ .",http://publisher.yahoo.com/rssguide"
689
+ .",http://help.yahoo.co.jp/help/jp/search/indexing/indexing-27.html"
690
+ .",http://misc.yahoo.com.cn/help.html"
691
+ .",msnbot"
692
+ .",http://search.msn.com/msnbot.htm"
693
+ .",Ask.jp"
694
+ .",http://ask.jp/"
695
+ .",FunWebProducts-AskJeevesJapan"
696
+ .",BlogFan.ORG"
697
+ .",blogoonbot"
698
+ .",BlogPeople"
699
+ .",BlogRanking"
700
+ .",Bulkfeeds"
701
+ .",DrecomBot"
702
+ .",gooRSSreader"
703
+ .",Hatena"
704
+ .",ichiro"
705
+ .",Infoseek"
706
+ .",Livedoor"
707
+ .",Captain NAMAAN"
708
+ .",MaplogCrawler"
709
+ .",So-net"
710
+ .",Technoratibot"
711
+ .",Accelatech"
712
+ .",AppleSyndication"
713
+ .",Baiduspider"
714
+ .",Biz360"
715
+ .",BLOG360"
716
+ .",blogWatcher"
717
+ .",Feedster"
718
+ .",Feed::Find"
719
+ .",Moreoverbot"
720
+ .",wadaino.jp"
721
+ .",http://www.accelobot.com"
722
+ .",ndl-japan-warp"
723
+ .",http://about.ask.com/en/docs/about/webmasters.shtml"
724
+ .",FreshDownload"
725
+ .",Celestial"
726
+ .",http://express.nime.ac.jp/"
727
+ .(!empty($bots) ? ',' . $bots : '')
728
+ ;
729
+ $pattern = '/(' . str_replace(',', '|', preg_quote(strtolower($bots), '/')) . ')/i';
730
+ $ua = strtolower(empty($ua) ? $_SERVER['HTTP_USER_AGENT'] : $ua);
731
+
732
+ if (preg_match($pattern, $ua))
733
+ return true;
734
+ else
735
+ return false;
736
+ }
737
+
738
+ //**************************************************************************************
739
+ // Is mobile ?
740
+ //**************************************************************************************
741
+ private function _is_ktai() {
742
+ return ($this->isKtai());
743
+ }
744
+
745
+ //**************************************************************************************
746
+ // Get permalink
747
+ //**************************************************************************************
748
+ private function _get_permalink() {
749
+ $url = get_bloginfo('url');
750
+ if (! preg_match('|^(https?://[^/]*)|', $url, $host))
751
+ $host[1] = (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://' . $_SERVER['SERVER_NAME'];
752
+ $url = preg_replace( '/\?[^s].*$/i', '', $host[1] . $_SERVER['REQUEST_URI']);
753
+ unset($host);
754
+ return ($url);
755
+ }
756
+
757
+ //**************************************************************************************
758
+ // DOM Element -> html tag
759
+ //**************************************************************************************
760
+ private function _dom_to_html($elements, $limit = false) {
761
+ $html = ''; $count = 0;
762
+ $type = '';
763
+ $tags = array();
764
+ foreach ((array) $elements as $element) {
765
+ $tag = trim($element);
766
+ $type = strtolower($element->tag);
767
+ if (strpos($html, $tag) === FALSE) {
768
+ switch($type) {
769
+ case 'meta':
770
+ if (isset($element->name)) {
771
+ $name = strtolower($element->name);
772
+
773
+ $content = trim(isset($tags[$type][$name]) && isset($tags[$type][$name]['content'])
774
+ ? $tags[$type][$name]['content']
775
+ : '');
776
+ $content = trim($content
777
+ . (!empty($content) ? ', ' : '')
778
+ . (isset($element->content) ? $element->content : '')
779
+ );
780
+
781
+ $tags[$type][$name] = array(
782
+ 'name' => $name
783
+ ,'content' => $content
784
+ );
785
+ } else {
786
+ $html .= $tag . "\n";
787
+ }
788
+ break;
789
+ default:
790
+ $html .= $tag . "\n";
791
+ break;
792
+ }
793
+ }
794
+ if ($limit !== false && $count++ >= $limit) break;
795
+ }
796
+ unset($element); unset($elements);
797
+
798
+ foreach ((array) $tags as $tag_types) {
799
+ foreach ((array) $tag_types as $tag) {
800
+ $html .= "<$type";
801
+ foreach((array)$tag as $key => $val) {
802
+ $html .= " $key=\"$val\"";
803
+ }
804
+ $html .= " />\n";
805
+ }
806
+ unset($tag);
807
+ }
808
+ unset($tags); unset($tag_types);
809
+
810
+ $html = trim($html);
811
+
812
+ return $html . (!empty($html) ? "\n" : '');
813
+ }
814
+
815
+ //**************************************************************************************
816
+ // Get absolute url
817
+ //**************************************************************************************
818
+ private function _abs_url($path, $base_path){
819
+ if (preg_match('/^https?:\/\//i', $base_path))
820
+ $base_path = str_replace($this->wp_url, ABSPATH, $base_path);
821
+ $absolute_path = realpath($base_path . '/' . $path);
822
+ if(!$absolute_path)
823
+ $absolute_path = $base_path . '/' . $path;
824
+
825
+ $url = str_replace(ABSPATH, $this->wp_url, $absolute_path);
826
+ return $url;
827
+ }
828
+
829
+ //**************************************************************************************
830
+ // Read file
831
+ //**************************************************************************************
832
+ private function _file_read($filename) {
833
+ if (preg_match('/^https?:\/\//i', $filename)) {
834
+ $content = file_get_contents($filename);
835
+ } else {
836
+ if (file_exists($filename)) {
837
+ $handle = @fopen($filename, 'r');
838
+ $content = trim(@fread($handle, filesize($filename)));
839
+ @fclose($handle);
840
+ } else {
841
+ $content = false;
842
+ }
843
+ }
844
+
845
+ return $content;
846
+ }
847
+
848
+ //**************************************************************************************
849
+ // Read files
850
+ //**************************************************************************************
851
+ private function _files_read($files, $type = 'js') {
852
+ $text = '';
853
+ foreach ($files as $filename) {
854
+ $content = trim($this->_file_read($filename));
855
+ switch ($type) {
856
+ case 'css':
857
+ if (preg_match_all('/url[ \t]*\([\'"]?([^\)]*)[\'"]?\)/i', $content, $matches, PREG_SET_ORDER)) {
858
+ $base_path = dirname($filename);
859
+ $search = array(); $replace = array();
860
+ foreach ($matches as $matche) {
861
+ if (! preg_match('/^https?:\/\//i', trim($matche[1]))) {
862
+ $abs_url = $this->_abs_url(trim($matche[1]), $base_path);
863
+ $search[] = $matche[0];
864
+ $replace[] = str_replace(trim($matche[1]), $abs_url, $matche[0]);
865
+ }
866
+ }
867
+ $content = str_replace($search, $replace, $content);
868
+ unset($matche); unset($search); unset($replace);
869
+ }
870
+ unset ($matches);
871
+ break;
872
+ case 'js':
873
+ $content = 'try{'
874
+ . trim($content . (substr($content, -1) !== ';' ? ';' : '')) . "\n"
875
+ . ($this->options['debug_mode']
876
+ ? '}catch(e){alert("error(' . basename($filename) . '): " + e.toString());}'
877
+ : '}finally{};');
878
+ break;
879
+ }
880
+ $text .= $content . "\n\n";
881
+ }
882
+ unset($filename);
883
+ $text = trim($text);
884
+
885
+ return $text . (!empty($text) ? "\n" : '');
886
+ }
887
+
888
+ //**************************************************************************************
889
+ // Write file
890
+ //**************************************************************************************
891
+ private function _file_write($filename, $content = '', $gzip = true) {
892
+ if (!empty($content)) {
893
+ $handle = @fopen($filename, 'w');
894
+ @fwrite($handle, $content);
895
+ @fclose($handle);
896
+
897
+ return ($gzip
898
+ ? $this->_file_gzip($filename, $content)
899
+ : file_exists($filename)
900
+ );
901
+ } else {
902
+ return false;
903
+ }
904
+ }
905
+
906
+ //**************************************************************************************
907
+ // Write gzip file
908
+ //**************************************************************************************
909
+ private function _file_gzip($filename, $content = '') {
910
+ if (file_exists($filename) && file_exists($filename . '.gz'))
911
+ if (filemtime($filename) < filemtime($filename . '.gz'))
912
+ return true;
913
+
914
+ if (function_exists('gzopen')) {
915
+ if (empty($content)) {
916
+ $handle = @fopen($filename, 'r');
917
+ $content = @fread($handle, filesize($filename));
918
+ @fclose($handle);
919
+ }
920
+
921
+ if (!empty($content)) {
922
+ $handle = @gzopen($filename . '.gz', 'w9');
923
+ @gzwrite($handle, $content);
924
+ @gzclose($handle);
925
+ }
926
+
927
+ return (file_exists($filename . '.gz'));
928
+ } else {
929
+ return false;
930
+ }
931
+ }
932
+
933
+ //**************************************************************************************
934
+ // JavaScript FrameWork (Prototype.js > jQuery > jQuery.noConflict > mootools)
935
+ //**************************************************************************************
936
+ private function _js_framework($js_libs) {
937
+ $prototype = isset($js_libs['prototype']);
938
+ $jquery = isset($js_libs['jquery']);
939
+ $mootools = isset($js_libs['mootools']);
940
+ $js_libs_src = array();
941
+ $wk_inner_js = '';
942
+ $wk_outer_js = '';
943
+
944
+ // Prototype.js 1.6.0.3
945
+ if ($prototype) {
946
+ list($src, $ver) = $this->_newer_version_src($js_libs['prototype']);
947
+ if (!empty($src)) {
948
+ if (version_compare($ver, '1.6.0.3', '<='))
949
+ $src = $this->plugin_url . 'includes/js/prototype-1.6.0.3.min.js';
950
+
951
+ $wk_outer_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
952
+ }
953
+ }
954
+
955
+ // jQuery 1.2.6 or 1.3.2
956
+ if ($jquery) {
957
+ list($src, $ver) = $this->_newer_version_src($js_libs['jquery']);
958
+ if (!empty($src)) {
959
+ if ($prototype)
960
+ $src = $this->plugin_url . 'includes/js/jquery-1.2.6.min.js';
961
+ elseif (version_compare($ver, '1.3.2', '<='))
962
+ $src = $this->plugin_url . 'includes/js/jquery-1.3.2.min.js';
963
+
964
+ if ($prototype || $mootools || strpos($src, $this->wp_url) === FALSE) {
965
+ $wk_outer_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
966
+ } else {
967
+ $js_libs_src[] = $src;
968
+ $wk_inner_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
969
+ }
970
+
971
+ // jQuery noConflict
972
+ if ($prototype || $mootools) {
973
+ $src = $this->plugin_url . 'includes/js/jquery.noconflict.js';
974
+ if (strpos($src, $this->wp_url) === FALSE) {
975
+ $wk_outer_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
976
+ } else {
977
+ $js_libs_src[] = $src;
978
+ $wk_inner_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
979
+ }
980
+ }
981
+ }
982
+ }
983
+
984
+ // mootools 1.2.1
985
+ if ($mootools) {
986
+ list($src, $ver) = $this->_newer_version_src($js_libs['mootools']);
987
+ if (!empty($src)) {
988
+ if (version_compare($ver, '1.2.1', '<='))
989
+ $src = $this->plugin_url . 'includes/js/mootools-1.2.1-core-yc.js';
990
+
991
+ if ($prototype || $jquery || strpos($src, $this->wp_url) === FALSE) {
992
+ $wk_outer_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
993
+ } else {
994
+ $js_libs_src[] = $src;
995
+ $wk_inner_js .= "<script type=\"text/javascript\" src=\"$src\"></script>\n";
996
+ }
997
+ }
998
+ }
999
+
1000
+ return array($js_libs_src, $wk_inner_js, $wk_outer_js);
1001
+ }
1002
+
1003
+ //**************************************************************************************
1004
+ // Combined CSS
1005
+ //**************************************************************************************
1006
+ private function _combined_css($styles, $css = '', $media = 'all') {
1007
+ $html = '';
1008
+ $longfilename = ''; $files = array();
1009
+
1010
+ foreach ((array)$styles as $style) {
1011
+ $src = trim(preg_replace('/(\.css|\.php)(\?[^\?]*)$/i', '$1', str_replace($this->wp_url, ABSPATH, $style)));
1012
+ if (file_exists($src)) {
1013
+ $filename = (preg_match('/\.css$/i', $src) ? $src : $style);
1014
+ $longfilename .= $filename . filemtime($src);
1015
+ $files[] = $filename;
1016
+ } else {
1017
+ $html .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$style}\" media=\"{$media}\" />\n";
1018
+ }
1019
+ }
1020
+
1021
+ $md5_filename = md5($longfilename . $css);
1022
+ $longfilename = 'css/' . $md5_filename . '.css';
1023
+ $filename = $this->cache_path . $longfilename;
1024
+ if (! file_exists($filename) ) {
1025
+ if (count($files) > 0 && !empty($longfilename))
1026
+ $css = $this->_files_read($files, 'css') . "\n\n" . $css;
1027
+
1028
+ // Optimise CSS
1029
+ $css = $this->_css_optimise($css);
1030
+
1031
+ if (!empty($css))
1032
+ $this->_file_write($filename, $css);
1033
+ }
1034
+
1035
+ $fileurl = ($this->options['dynamic']
1036
+ ? $this->self_url . '?f=' . $md5_filename . '&amp;t=css'
1037
+ : $this->cache_url . $longfilename
1038
+ );
1039
+ if (file_exists($filename))
1040
+ $html .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$fileurl}\" media=\"{$media}\" />\n";
1041
+
1042
+ return $html;
1043
+ }
1044
+
1045
+ //**************************************************************************************
1046
+ // Combined inline CSS
1047
+ //**************************************************************************************
1048
+ private function _combined_inline_css($css, $media = 'all') {
1049
+ if (empty($css))
1050
+ return '';
1051
+
1052
+ $html = '';
1053
+ $md5_filename = md5($css);
1054
+ $longfilename = 'css/'. $md5_filename . '.css';
1055
+
1056
+ // Optimise CSS
1057
+ $css = $this->_css_optimise($css);
1058
+
1059
+ $filename = $this->cache_path . $longfilename;
1060
+ if (!file_exists($filename) && !empty($css))
1061
+ $this->_file_write($filename, $css);
1062
+
1063
+ $fileurl = ($this->options['dynamic']
1064
+ ? $this->self_url . '?f=' . $md5_filename . '&amp;t=css'
1065
+ : $this->cache_url . $longfilename
1066
+ );
1067
+ if (file_exists($filename))
1068
+ $html .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$fileurl}\" media=\"{$media}\" />\n";
1069
+
1070
+ return $html;
1071
+ }
1072
+
1073
+ //**************************************************************************************
1074
+ // Combined JavaScript
1075
+ //**************************************************************************************
1076
+ private function _combined_javascript($javascripts, $script = '') {
1077
+ $html = '';
1078
+ $longfilename = ''; $files = array();
1079
+
1080
+ foreach ((array)$javascripts as $javascript) {
1081
+ $src = trim(preg_replace('/(\.js|\.php)(\?[^\?]*)$/i', '$1', str_replace($this->wp_url, ABSPATH, $javascript)));
1082
+ if (file_exists($src)) {
1083
+ $filename = (preg_match('/\.js$/i', $src) ? $src : $javascript);
1084
+ $longfilename .= $filename . filemtime($src);
1085
+ $files[] = $filename;
1086
+ } else {
1087
+ $html .= "<script type=\"text/javascript\" src=\"{$javascript}\"></script>\n";
1088
+ }
1089
+ }
1090
+
1091
+ $md5_filename = md5($longfilename . $script);
1092
+ $longfilename = 'js/' . $md5_filename . '.js';
1093
+ $filename = $this->cache_path . $longfilename;
1094
+ if (! file_exists($filename) ) {
1095
+ if (count($files) > 0 && !empty($longfilename))
1096
+ $script = $this->_files_read($files, 'js') . "\n\n" . $script;
1097
+
1098
+ // Minified JavaScript
1099
+ $script = $this->_js_minify($script);
1100
+
1101
+ if (!empty($script))
1102
+ $this->_file_write($filename, $script);
1103
+ }
1104
+
1105
+ $fileurl = ($this->options['dynamic']
1106
+ ? $this->self_url . '?f=' . $md5_filename . '&amp;t=js'
1107
+ : $this->cache_url . $longfilename
1108
+ );
1109
+ if (file_exists($filename))
1110
+ $html .= "<script type=\"text/javascript\" src=\"{$fileurl}\"></script>\n";
1111
+
1112
+ return $html;
1113
+ }
1114
+
1115
+ //**************************************************************************************
1116
+ // Combined inline JavaScript
1117
+ //**************************************************************************************
1118
+ private function _combined_inline_javascript($script) {
1119
+ if (empty($script))
1120
+ return '';
1121
+
1122
+ $html = '';
1123
+ $md5_filename = md5($script);
1124
+ $longfilename = 'js/' . $md5_filename . '.js';
1125
+
1126
+ // Minified JavaScript
1127
+ $script = $this->_js_minify($script);
1128
+
1129
+ $filename = $this->cache_path . $longfilename;
1130
+ if (!file_exists($filename) && !empty($script) )
1131
+ $this->_file_write($filename, $script);
1132
+
1133
+ $fileurl = ($this->options['dynamic']
1134
+ ? $this->self_url . '?f=' . $md5_filename . '&amp;t=js'
1135
+ : $this->cache_url . $longfilename
1136
+ );
1137
+ if (file_exists($filename))
1138
+ $html .= "<script type=\"text/javascript\" src=\"{$fileurl}\"></script>\n";
1139
+
1140
+ return $html;
1141
+ }
1142
+
1143
+ //**************************************************************************************
1144
+ // Remove comment
1145
+ //**************************************************************************************
1146
+ private function _remove_comment($text, $type) {
1147
+ $text = trim($text);
1148
+
1149
+ $comment_pattern = '/^[ \t]*\/(?:\*(?:.|\n)*?\*\/|\/.*)/m';
1150
+
1151
+ switch ($type) {
1152
+ case 'css': // inline CSS
1153
+ $text = trim(preg_replace(
1154
+ array($comment_pattern, '/^[ \t]+/m', '/[ \t]+$/m')
1155
+ , array('', '', '')
1156
+ , $text));
1157
+ break;
1158
+
1159
+ case 'js': // inline JavaScript
1160
+ $text = trim(preg_replace(
1161
+ array($comment_pattern, '/^[ \t]+/m', '/[ \t]+$/m', '/^<\!\-+/', '/-+>$/')
1162
+ , array('', '', '', '', '')
1163
+ , $text));
1164
+ $text = 'try{'
1165
+ . $text . (substr($text, -1) !== ';' ? ';' : '') . "\n"
1166
+ . ($this->options['debug_mode']
1167
+ ? '}catch(e){alert("error: " + e.toString());}'
1168
+ : '}finally{};')
1169
+ ;
1170
+ break;
1171
+ }
1172
+
1173
+ return ($text . "\n");
1174
+ }
1175
+
1176
+ //**************************************************************************************
1177
+ // Get Newer version
1178
+ //**************************************************************************************
1179
+ private function _newer_version_src($js_libs, $limit_ver = '') {
1180
+ $src = ''; $ver = '0.0';
1181
+ foreach ((array)$js_libs as $key => $val) {
1182
+ if ( version_compare( $key, $ver, '>') ) {
1183
+ $src = $val; $ver = $key;
1184
+ }
1185
+ }
1186
+
1187
+ return array($src, $ver);
1188
+ }
1189
+
1190
+ //**************************************************************************************
1191
+ // Minified JavaScript
1192
+ //**************************************************************************************
1193
+ private function _js_minify($buffer) {
1194
+ $js = trim($buffer . "\n");
1195
+ if ($this->options['js_minify']) {
1196
+ $js = JSMin::minify($js);
1197
+ }
1198
+ $js = trim($js);
1199
+
1200
+ return $js . (!empty($js) ? "\n" : '');
1201
+ }
1202
+
1203
+ //**************************************************************************************
1204
+ // Optimise CSS
1205
+ //**************************************************************************************
1206
+ private function _css_optimise($buffer) {
1207
+ $css = trim($buffer . "\n");
1208
+ if ($this->options['css_optimise']) {
1209
+ $csstidy = new csstidy();
1210
+ $csstidy->set_cfg('optimise_shorthands', $this->options['csstidy_option']['optimise_shorthands']);
1211
+ $csstidy->set_cfg('compress_colors', $this->options['csstidy_option']['compress_colors']);
1212
+ $csstidy->set_cfg('compress_font-weight', $this->options['csstidy_option']['compress_font_weight']);
1213
+ $csstidy->set_cfg('remove_bslash', $this->options['csstidy_option']['remove_bslash']);
1214
+ $csstidy->load_template($this->csstidy_template[$this->options['csstidy_option']['template']]);
1215
+ $csstidy->parse($css);
1216
+ $css = $csstidy->print->plain();
1217
+ unset($csstidy);
1218
+ }
1219
+ $css = trim($css);
1220
+
1221
+ return $css . (!empty($css) ? "\n" : '');
1222
+ }
1223
+
1224
+
1225
+ //**************************************************************************************
1226
+ // Create cache dir
1227
+ //**************************************************************************************
1228
+ private function _create_cache_dir($cache = 'cache', $plugin = 'head-cleaner') {
1229
+ $cache_dir = $this->_wp_content_dir("/$cache/$plugin/");
1230
+
1231
+ $mode = 0777;
1232
+ if( !file_exists($this->_wp_content_dir("/$cache/")) )
1233
+ @mkdir($this->_wp_content_dir("/$cache/"), $mode);
1234
+ if( !file_exists($cache_dir) )
1235
+ @mkdir($cache_dir, $mode);
1236
+ if( !file_exists($cache_dir) . '/css/' )
1237
+ @mkdir($cache_dir . '/css/', $mode);
1238
+ if( !file_exists($cache_dir) . '/js/' )
1239
+ @mkdir($cache_dir . '/js/', $mode);
1240
+
1241
+ return (file_exists($cache_dir) ? $cache_dir : FALSE);
1242
+ }
1243
+
1244
+ //**************************************************************************************
1245
+ // Remove cache file
1246
+ //**************************************************************************************
1247
+ private function _remove_cache_file($cache = 'cache', $plugin = 'head-cleaner') {
1248
+ $cache_dir = ( !empty($this->cache_path)
1249
+ ? $this->cache_path
1250
+ : $this->_wp_content_dir("/$cache/$plugin/")
1251
+ );
1252
+ $this->_remove_all_file($cache_dir . 'css');
1253
+ $this->_remove_all_file($cache_dir . 'js');
1254
+ }
1255
+
1256
+ //**************************************************************************************
1257
+ // Remove files
1258
+ //**************************************************************************************
1259
+ private function _remove_all_file($dir, $rmdir = false) {
1260
+ if(file_exists($dir)) {
1261
+ if($objs = glob($dir."/*")) {
1262
+ foreach($objs as $obj) {
1263
+ is_dir($obj)
1264
+ ? $this->_remove_all_file($obj, true)
1265
+ : @unlink($obj);
1266
+ }
1267
+ unset($objs);
1268
+ }
1269
+ if ($rmdir) rmdir($dir);
1270
+ }
1271
+ }
1272
+
1273
+ //**************************************************************************************
1274
+ // Create .htaccess
1275
+ //**************************************************************************************
1276
+ private function _create_htaccess($dir) {
1277
+ if (!file_exists($dir))
1278
+ return false;
1279
+
1280
+ $text = '# BEGIN Head Cleaner' . "\n"
1281
+ . '<IfModule mod_rewrite.c>' . "\n"
1282
+ . 'RewriteEngine On' . "\n"
1283
+ . 'RewriteCond %{HTTP:Accept-Encoding} gzip' . "\n"
1284
+ . 'RewriteCond %{REQUEST_FILENAME} "\.(css|js)$"' . "\n"
1285
+ . 'RewriteCond %{REQUEST_FILENAME} !"\.gz$"' . "\n"
1286
+ . 'RewriteCond %{REQUEST_FILENAME}.gz -s' . "\n"
1287
+ . 'RewriteRule .+ %{REQUEST_URI}.gz [L]' . "\n"
1288
+ . '</IfModule>' . "\n"
1289
+ . '# END Head Cleaner' . "\n";
1290
+ $filename = trailingslashit($dir) . '.htaccess';
1291
+
1292
+ if (!file_exists($filename)) {
1293
+ return $this->_file_write($filename, $text, false);
1294
+ } else {
1295
+ $content = $this->_file_read($filename);
1296
+ if ($content !== FALSE) {
1297
+ if (strpos($content, '# BEGIN Head Cleaner') === FALSE && strpos($content, 'RewriteRule .+ %{REQUEST_URI}.gz') === FALSE) {
1298
+ $text = $content . "\n" . $text;
1299
+ return $this->_file_write($filename, $text, false);
1300
+ } else {
1301
+ return TRUE;
1302
+ }
1303
+ } else {
1304
+ return FALSE;
1305
+ }
1306
+ }
1307
+ }
1308
+
1309
+ //**************************************************************************************
1310
+ // Add Admin Menu
1311
+ //**************************************************************************************
1312
+ public function admin_menu() {
1313
+ $this->addOptionPage(__('Head Cleaner'), array($this, 'option_page'));
1314
+ }
1315
+
1316
+ public function plugin_setting_links($links, $file) {
1317
+ if (method_exists($this, 'addPluginSettingLinks')) {
1318
+ $links = $this->addPluginSettingLinks($links, $file);
1319
+ } else {
1320
+ $this_plugin = plugin_basename(__FILE__);
1321
+ if ($file == $this_plugin) {
1322
+ $settings_link = '<a href="options-general.php?page=' . $this->plugin_file . '">' . __('Settings') . '</a>';
1323
+ array_unshift($links, $settings_link); // before other links
1324
+ }
1325
+ }
1326
+ return $links;
1327
+ }
1328
+
1329
+ //**************************************************************************************
1330
+ // Show Option Page
1331
+ //**************************************************************************************
1332
+ public function option_page() {
1333
+ if ($this->_chk_filters_update())
1334
+ $this->options['filters'] = $this->filters;
1335
+
1336
+ if (isset($_POST['options_update'])) {
1337
+ if ($this->wp25)
1338
+ check_admin_referer("update_options", "_wpnonce_update_options");
1339
+
1340
+ // strip slashes array
1341
+ $head_filters = $this->stripArray(isset($_POST['head_filters']) ? $_POST['head_filters'] : array());
1342
+ $head_remove = $this->stripArray(isset($_POST['head_remove']) ? $_POST['head_remove'] : array());
1343
+ $foot_filters = $this->stripArray(isset($_POST['foot_filters']) ? $_POST['foot_filters'] : array());
1344
+ $foot_remove = $this->stripArray(isset($_POST['foot_remove']) ? $_POST['foot_remove'] : array());
1345
+ $_POST = $this->stripArray($_POST);
1346
+
1347
+ // get options
1348
+ $this->options['foot_js'] = (isset($_POST['foot_js']) && $_POST['foot_js'] == 'on' ? true : false);
1349
+ $this->options['dynamic'] = (isset($_POST['dynamic']) && $_POST['dynamic'] == 'on' ? true : false);
1350
+ $this->options['js_move_foot'] = (isset($_POST['js_move_foot']) && $_POST['js_move_foot'] == 'on' ? true : false);
1351
+ $this->options['cache_enabled'] = (isset($_POST['cache_enabled']) && $_POST['cache_enabled'] == 'on' ? true : false);
1352
+ $this->options['combined_css'] = (isset($_POST['combined_css']) && $_POST['combined_css'] == 'on' ? true : false);
1353
+ $this->options['combined_js'] = (isset($_POST['combined_js']) && $_POST['combined_js'] == 'on' ? true : false);
1354
+ $this->options['js_minify'] = (isset($_POST['js_minify']) && $_POST['js_minify'] == 'on' ? true : false);
1355
+ $this->options['css_optimise'] = (isset($_POST['css_optimise']) && $_POST['css_optimise'] == 'on' ? true : false);
1356
+ $this->options['default_media'] = trim($_POST['default_media']);
1357
+ $this->options['debug_mode'] = (isset($_POST['debug_mode']) && $_POST['debug_mode'] == 'on' ? true : false);
1358
+ $this->options['csstidy_option']['template'] = (int) $_POST['template'];
1359
+ $this->options['csstidy_option']['optimise_shorthands'] = (int) $_POST['optimise_shorthands'];
1360
+ $this->options['csstidy_option']['compress_colors'] = (isset($_POST['compress_colors']) && $_POST['compress_colors'] == 'on' ? true : false);
1361
+ $this->options['csstidy_option']['compress_font_weight'] = (isset($_POST['compress_font_weight']) && $_POST['compress_font_weight'] == 'on' ? true : false);
1362
+ $this->options['csstidy_option']['remove_bslash'] = (isset($_POST['remove_bslash']) && $_POST['remove_bslash'] == 'on' ? true : false);
1363
+
1364
+ $tag = 'wp_head';
1365
+ foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
1366
+ if (count($head_filters) > 0 && array_search($function_name, $head_filters) !== FALSE)
1367
+ $this->options['priority'][$tag][$function_name] = HC_PRIORITY + 1;
1368
+ elseif (count($head_remove) > 0 && array_search($function_name, $head_remove) !== FALSE)
1369
+ $this->options['priority'][$tag][$function_name] = -1;
1370
+ elseif (isset($this->options['priority'][$tag][$function_name]))
1371
+ $this->options['priority'][$tag][$function_name] = $priority;
1372
+ }
1373
+ unset($head_filters);
1374
+
1375
+ $tag = 'wp_footer';
1376
+ foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
1377
+ if (count($foot_filters) > 0 && array_search($function_name, $foot_filters) !== FALSE)
1378
+ $this->options['priority'][$tag][$function_name] = HC_PRIORITY + 1;
1379
+ elseif (count($foot_remove) > 0 && array_search($function_name, $foot_remove) !== FALSE)
1380
+ $this->options['priority'][$tag][$function_name] = -1;
1381
+ elseif (isset($this->options['priority'][$tag][$function_name]))
1382
+ $this->options['priority'][$tag][$function_name] = $priority;
1383
+ }
1384
+ unset($foot_filters);
1385
+
1386
+ // options update
1387
+ $this->updateOptions();
1388
+
1389
+ // Done!
1390
+ $this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
1391
+
1392
+ } elseif(isset($_POST['remove_cache'])) {
1393
+ if ($this->wp25)
1394
+ check_admin_referer("remove_cache", "_wpnonce_remove_cache");
1395
+
1396
+ // Remove all cache files
1397
+ $this->_remove_cache_file();
1398
+
1399
+ // Done!
1400
+ $this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
1401
+
1402
+ } elseif(isset($_POST['options_delete'])) {
1403
+ if ($this->wp25)
1404
+ check_admin_referer("delete_options", "_wpnonce_delete_options");
1405
+
1406
+ // options delete
1407
+ $this->_delete_settings();
1408
+
1409
+ // Done!
1410
+ $this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
1411
+ $this->error++;
1412
+
1413
+ } else {
1414
+ $this->activation();
1415
+ }
1416
+
1417
+ $out = '';
1418
+
1419
+ // Add Options
1420
+ $out .= "<div class=\"wrap\">\n";
1421
+ $out .= "<form method=\"post\" id=\"update_options\" action=\"".$this->admin_action."\">\n";
1422
+ $out .= "<h2>".__('Head Cleaner Options', $this->textdomain_name)."</h2><br />\n";
1423
+ if ($this->wp25) $out .= $this->makeNonceField("update_options", "_wpnonce_update_options", true, false);
1424
+
1425
+ $out .= "<table class=\"optiontable form-table\" style=\"margin-top:0;\"><tbody>\n";
1426
+
1427
+ $out .= "<tr>";
1428
+ $out .= "<td>";
1429
+ $out .= "<input type=\"checkbox\" name=\"cache_enabled\" id=\"cache_enabled\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['cache_enabled'] === true ? " checked=\"true\"" : "")." />";
1430
+ $out .= __('CSS and JavaScript are cached on the server.', $this->textdomain_name);
1431
+ $out .= "</td>";
1432
+ $out .= "<td>";
1433
+ $out .= "<input type=\"checkbox\" name=\"js_move_foot\" id=\"js_move_foot\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['js_move_foot'] === true ? " checked=\"true\"" : "")." />";
1434
+ $out .= __('Put JavaScripts at the Bottom.', $this->textdomain_name);
1435
+ $out .= "</td>";
1436
+ $out .= "<td>";
1437
+ $out .= "<input type=\"checkbox\" name=\"dynamic\" id=\"dynamic\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['dynamic'] === true ? " checked=\"true\"" : "")." />";
1438
+ $out .= __('CSS and JS are dynamically generated.', $this->textdomain_name);
1439
+ $out .= "</td>";
1440
+ $out .= "</tr>\n";
1441
+
1442
+ if ($this->options['cache_enabled']) {
1443
+ $out .= "<tr>";
1444
+ $out .= "<td>";
1445
+ $out .= "<input type=\"checkbox\" name=\"combined_css\" id=\"combined_css\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['combined_css'] === true ? " checked=\"true\"" : "")." />";
1446
+ $out .= __('Two or more CSS is combined.', $this->textdomain_name);
1447
+ $out .= "</td>";
1448
+ $out .= "<td>";
1449
+ $out .= "<input type=\"checkbox\" name=\"css_optimise\" id=\"css_optimise\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['css_optimise'] === true ? " checked=\"true\"" : "")." />";
1450
+ $out .= __('CSS is optimized.', $this->textdomain_name);
1451
+ $out .= "</td>";
1452
+ $out .= "<td>";
1453
+ $out .= __('Default media attribute applied to CSS.', $this->textdomain_name);
1454
+ $out .= "<input type=\"text\" name=\"default_media\" id=\"default_media\" value=\"{$this->options['default_media']}\" style=\"margin-left:0.5em;\" />";
1455
+ $out .= "</td>";
1456
+ $out .= "<td>";
1457
+ $out .= "</tr>\n";
1458
+
1459
+ $out .= "<tr>";
1460
+ $out .= "<td>";
1461
+ $out .= "<input type=\"checkbox\" name=\"combined_js\" id=\"combined_js\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['combined_js'] === true ? " checked=\"true\"" : "")." />";
1462
+ $out .= __('Two or more JavaScript is combined.', $this->textdomain_name);
1463
+ $out .= "</td>";
1464
+ $out .= "<td>";
1465
+ $out .= "<input type=\"checkbox\" name=\"js_minify\" id=\"js_minify\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['js_minify'] === true ? " checked=\"true\"" : "")." />";
1466
+ $out .= __('JavaScript is minified.', $this->textdomain_name);
1467
+ $out .= "</td>";
1468
+ $out .= "<td>";
1469
+ $out .= "<input type=\"checkbox\" name=\"foot_js\" id=\"foot_js\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['foot_js'] === true ? " checked=\"true\"" : "")." />";
1470
+ $out .= __('Bottom JavaScript is combined, too.', $this->textdomain_name);
1471
+ $out .= "</td>";
1472
+ $out .= "</tr>\n";
1473
+ }
1474
+
1475
+ $out .= "<tr>";
1476
+ $out .= "<td>";
1477
+ $out .= "<input type=\"checkbox\" name=\"debug_mode\" id=\"debug_mode\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['debug_mode'] === true ? " checked=\"true\"" : "")." />";
1478
+ $out .= __('Debug mode', $this->textdomain_name);
1479
+ $out .= "</td>";
1480
+ $out .= "<td>";
1481
+ $out .= "</td>";
1482
+ $out .= "<td>";
1483
+ $out .= "</td>";
1484
+ $out .= "</tr>\n";
1485
+
1486
+ $out .= "</tbody></table>";
1487
+
1488
+ // CSS Tidy Options
1489
+ if ($this->options['css_optimise']) {
1490
+ $out .= "<div style=\"margin-top:2em;\" id=\"csstidy_option\">\n";
1491
+ $out .= "<h3>" . __('The CSS optimization settings', $this->textdomain_name) . "</h3>" ;
1492
+
1493
+ $out .= __('Compression (code layout):', $this->textdomain_name) . '&nbsp;&nbsp;';
1494
+ $out .= '<select name="template" id="template">';
1495
+ $out .= '<option value="3"' . ($this->options['csstidy_option']['template']==3 ? ' selected="selected"' : '') . '>' . __('Highest (no readability, smallest size)', $this->textdomain_name) .'</option>';
1496
+ $out .= '<option value="2"' . ($this->options['csstidy_option']['template']==2 ? ' selected="selected"' : '') . '>' . __('High (moderate readability, smaller size)', $this->textdomain_name) .')</option>';
1497
+ $out .= '<option value="1"' . ($this->options['csstidy_option']['template']==1 ? ' selected="selected"' : '') . '>' . __('Standard (balance between readability and size)', $this->textdomain_name) .'</option>';
1498
+ $out .= '<option value="0"' . ($this->options['csstidy_option']['template']==0 ? ' selected="selected"' : '') . '>' . __('Low (higher readability)', $this->textdomain_name) .'</option>';
1499
+ $out .= '</select>';
1500
+ $out .= '&nbsp;&nbsp;&nbsp;&nbsp;';
1501
+ $out .= __('Optimise shorthands', $this->textdomain_name) . '&nbsp;&nbsp;';
1502
+ $out .= '<select name="optimise_shorthands" id="optimise_shorthands">';
1503
+ $out .= '<option value="2"' . ($this->options['csstidy_option']['optimise_shorthands']==2 ? ' selected="selected"' : '') . '>' . __('All optimisations', $this->textdomain_name) .')</option>';
1504
+ $out .= '<option value="1"' . ($this->options['csstidy_option']['optimise_shorthands']==1 ? ' selected="selected"' : '') . '>' . __('Safe optimisations', $this->textdomain_name) .'</option>';
1505
+ $out .= '<option value="0"' . ($this->options['csstidy_option']['optimise_shorthands']==0 ? ' selected="selected"' : '') . '>' . __("Don't optimise", $this->textdomain_name) .'</option>';
1506
+ $out .= '</select>';
1507
+ $out .= "<br />\n";
1508
+
1509
+ $out .= "<input type=\"checkbox\" name=\"compress_colors\" id=\"compress_colors\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['csstidy_option']['compress_colors'] === true ? " checked=\"true\"" : "")." />";
1510
+ $out .= __('Compress colors', $this->textdomain_name);
1511
+ $out .= '&nbsp;&nbsp;&nbsp;&nbsp;';
1512
+ $out .= "<input type=\"checkbox\" name=\"compress_font_weight\" id=\"compress_font_weight\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['csstidy_option']['compress_font_weight'] === true ? " checked=\"true\"" : "")." />";
1513
+ $out .= __('Compress font-weight', $this->textdomain_name);
1514
+ $out .= '&nbsp;&nbsp;&nbsp;&nbsp;';
1515
+ $out .= "<input type=\"checkbox\" name=\"remove_bslash\" id=\"remove_bslash\" value=\"on\" style=\"margin-right:0.5em;\"".($this->options['csstidy_option']['remove_bslash'] === true ? " checked=\"true\"" : "")." />";
1516
+ $out .= __('Remove unnecessary backslashes', $this->textdomain_name);
1517
+ $out .= "<br />\n";
1518
+
1519
+ $out .= "</div>\n";
1520
+ }
1521
+
1522
+ // Active Filters
1523
+ $out .= "<div style=\"margin-top:2em;\" id=\"active_filters\">\n";
1524
+ $out .= "<h3>" . __('Active Filters', $this->textdomain_name) . "</h3>" ;
1525
+ $out .= "<table><tbody>\n";
1526
+ $out .= "<tr>";
1527
+ $out .= "<th>" . __('Off the subject', $this->textdomain_name) . "</th>\n";
1528
+ $out .= "<th>" . __('Remove', $this->textdomain_name) . "</th>\n";
1529
+ $out .= "<th>" . __('Head filters', $this->textdomain_name) . "</th>\n";
1530
+ if ($this->options['debug_mode'])
1531
+ $out .= "<th>" . __('Priority', $this->textdomain_name) . "</th>\n";
1532
+ $out .= "</tr>\n";
1533
+ $head_filters = array();
1534
+ foreach ((array) $this->options['filters']['wp_head'] as $function_name => $priority) {
1535
+ if ($priority < HC_PRIORITY) {
1536
+ if (isset($this->options['priority']['wp_head'][$function_name]))
1537
+ $priority = (int) $this->options['priority']['wp_head'][$function_name];
1538
+ if (!isset($head_filters[$priority]))
1539
+ $head_filters[$priority] = array();
1540
+ $head_filters[$priority][] = $function_name;
1541
+ }
1542
+ }
1543
+ ksort($head_filters, SORT_NUMERIC);
1544
+ $i = 0;
1545
+ foreach ($head_filters as $priority => $filters) {
1546
+ foreach ($filters as $function_name){
1547
+ if (strpos($function_name, 'HeadCleanerController') === FALSE && strpos($function_name, 'noindex') === FALSE) {
1548
+ $out .= "<tr>";
1549
+ $out .= "<th><input type=\"checkbox\" name=\"head_filters[$i]\" value=\"$function_name\"".($priority > HC_PRIORITY ? " checked=\"true\"" : "")." /></th>";
1550
+ $out .= "<th><input type=\"checkbox\" name=\"head_remove[$i]\" value=\"$function_name\"".($priority <= 0 ? " checked=\"true\"" : "")." /></th>";
1551
+ $out .= "<td>$function_name</td>";
1552
+ if ($this->options['debug_mode'])
1553
+ $out .= "<td>( $priority )</td>";
1554
+ $out .= "</tr>\n";
1555
+ $i++;
1556
+ }
1557
+ }
1558
+ }
1559
+ unset($filters); unset($head_filters);
1560
+
1561
+ if ($this->options['foot_js'] === true) {
1562
+ $out .= "<tr><td colspan='3'>&nbsp;</td></tr>\n";
1563
+ $out .= "<tr>";
1564
+ $out .= "<th>" . __('Off the subject', $this->textdomain_name) . "</th>\n";
1565
+ $out .= "<th>" . __('Remove', $this->textdomain_name) . "</th>\n";
1566
+ $out .= "<th>" . __('Bottom filters', $this->textdomain_name) . "</th>\n";
1567
+ if ($this->options['debug_mode'])
1568
+ $out .= "<th>" . __('Priority', $this->textdomain_name) . "</th>\n";
1569
+ $out .= "</tr>\n";
1570
+ $footer_filters = array();
1571
+ foreach ((array) $this->options['filters']['wp_footer'] as $function_name => $priority) {
1572
+ if ($priority < HC_PRIORITY) {
1573
+ if (isset($this->options['priority']['wp_footer'][$function_name]))
1574
+ $priority = (int) $this->options['priority']['wp_footer'][$function_name];
1575
+ if (!isset($footer_filters[$priority]))
1576
+ $footer_filters[$priority] = array();
1577
+ $footer_filters[$priority][] = $function_name;
1578
+ }
1579
+ }
1580
+ ksort($footer_filters, SORT_NUMERIC);
1581
+ $i = 0;
1582
+ foreach ($footer_filters as $priority => $filters) {
1583
+ foreach ($filters as $function_name){
1584
+ if (strpos($function_name, 'HeadCleanerController') === FALSE && strpos($function_name, 'noindex') === FALSE) {
1585
+ $out .= "<tr>";
1586
+ $out .= "<th><input type=\"checkbox\" name=\"foot_filters[$i]\" value=\"$function_name\"".($priority > HC_PRIORITY ? " checked=\"true\"" : "")." /></th>";
1587
+ $out .= "<th><input type=\"checkbox\" name=\"foot_remove[$i]\" value=\"$function_name\"".($priority <= 0 ? " checked=\"true\"" : "")." /></th>";
1588
+ $out .= "<td>$function_name</td>";
1589
+ if ($this->options['debug_mode'])
1590
+ $out .= "<td>( $priority )</td>";
1591
+ $out .= "</tr>\n";
1592
+ $i++;
1593
+ }
1594
+ }
1595
+ }
1596
+ unset($filters); unset($footer_filters);
1597
+ }
1598
+ $out .= "</tbody></table>";
1599
+ $out .= "</div>\n";
1600
+
1601
+ // Add Update Button
1602
+ $out .= "<p style=\"margin-top:1em\"><input type=\"submit\" name=\"options_update\" value=\"".__('Update Options', $this->textdomain_name)." &raquo;\" class=\"button\" /></p>";
1603
+ $out .= "</form></div>\n";
1604
+
1605
+ // Cache Delete
1606
+ $out .= "<div class=\"wrap\" style=\"margin-top:2em;\">\n";
1607
+ $out .= "<h2>" . __('Remove all cache files', $this->textdomain_name) . "</h2><br />\n";
1608
+ $out .= "<form method=\"post\" id=\"remove_cache\" action=\"".$this->admin_action."\">\n";
1609
+ if ($this->wp25) $out .= $this->makeNonceField("remove_cache", "_wpnonce_remove_cache", true, false);
1610
+ $out .= "<p>" . __('All cache files are removed.', $this->textdomain_name) . "</p>";
1611
+ $out .= "<input type=\"submit\" name=\"remove_cache\" value=\"".__('Remove All Cache Files', $this->textdomain_name)." &raquo;\" class=\"button\" />";
1612
+ $out .= "</form></div>\n";
1613
+
1614
+ // Options Delete
1615
+ $out .= "<div class=\"wrap\" style=\"margin-top:2em;\">\n";
1616
+ $out .= "<h2>" . __('Uninstall', $this->textdomain_name) . "</h2><br />\n";
1617
+ $out .= "<form method=\"post\" id=\"delete_options\" action=\"".$this->admin_action."\">\n";
1618
+ if ($this->wp25) $out .= $this->makeNonceField("delete_options", "_wpnonce_delete_options", true, false);
1619
+ $out .= "<p>" . __('All the settings of &quot;Head Cleaner&quot; are deleted.', $this->textdomain_name) . "</p>";
1620
+ $out .= "<input type=\"submit\" name=\"options_delete\" value=\"".__('Delete Options', $this->textdomain_name)." &raquo;\" class=\"button\" />";
1621
+ $out .= "</form></div>\n";
1622
+
1623
+ // Output
1624
+ echo (!empty($this->note) ? "<div id=\"message\" class=\"updated fade\"><p>{$this->note}</p></div>\n" : '') . "\n";
1625
+ echo ($this->error == 0 ? $out : '') . "\n";
1626
+ }
1627
+
1628
+ //**************************************************************************************
1629
+ // Delete Settings
1630
+ //**************************************************************************************
1631
+ private function _delete_settings() {
1632
+ $this->deleteOptions();
1633
+ $this->_remove_cache_file();
1634
+ $this->options = $this->_init_options();
1635
+ }
1636
+
1637
+ //**************************************************************************************
1638
+ // Get Filters
1639
+ //**************************************************************************************
1640
+ private function _get_filters($tag = '') {
1641
+ global $wp_filter;
1642
+
1643
+ if (empty($tag) && function_exists('current_filter'))
1644
+ $tag = current_filter();
1645
+
1646
+ if (!isset($this->filters[$tag]))
1647
+ $this->filters[$tag] = array();
1648
+
1649
+ $active_filters = (isset($wp_filter[$tag])
1650
+ ? $wp_filter[$tag]
1651
+ : array());
1652
+ foreach ($active_filters as $priority => $filters) {
1653
+ foreach ($filters as $filter) {
1654
+ $function_name = (is_array($filter['function'])
1655
+ ? get_class($filter['function'][0]) . '::' . $filter['function'][1]
1656
+ : $filter['function']
1657
+ );
1658
+ $this->filters[$tag][$function_name] = $priority;
1659
+ }
1660
+ }
1661
+ unset($active_filters);
1662
+
1663
+ return $this->filters;
1664
+ }
1665
+
1666
+ //**************************************************************************************
1667
+ // Filters update Check
1668
+ //**************************************************************************************
1669
+ private function _chk_filters_update(){
1670
+ $retval = false;
1671
+ foreach ( $this->filters as $tag => $filters ) {
1672
+ if ( isset($this->options['filters'][$tag]) ) {
1673
+ foreach ( $filters as $function_name => $priority) {
1674
+ $retval = ( !isset($this->options['filters'][$tag][$function_name]) );
1675
+ if ($retval) break;
1676
+ }
1677
+ } else {
1678
+ $retval = true; break;
1679
+ }
1680
+ }
1681
+ unset ($filters);
1682
+
1683
+ return $retval;
1684
+ }
1685
+
1686
+ //**************************************************************************************
1687
+ // Filters priority change
1688
+ //**************************************************************************************
1689
+ private function _change_filters_priority($tag = ''){
1690
+ global $wp_filter;
1691
+
1692
+ if (empty($tag) && function_exists('current_filter'))
1693
+ $tag = current_filter();
1694
+
1695
+ if (! (isset($this->options['priority'][$tag]) && count($this->options['priority'][$tag]) > 0) )
1696
+ return;
1697
+
1698
+ $active_filters = (isset($wp_filter[$tag])
1699
+ ? $wp_filter[$tag]
1700
+ : array());
1701
+ $custom_priority = (isset($this->options['priority'][$tag])
1702
+ ? $this->options['priority'][$tag]
1703
+ : array());
1704
+ foreach ($active_filters as $priority => $filters) {
1705
+ foreach ($filters as $filter) {
1706
+ $function_name = (is_array($filter['function'])
1707
+ ? get_class($filter['function'][0]) . '::' . $filter['function'][1]
1708
+ : $filter['function']
1709
+ );
1710
+ if ( isset($custom_priority[$function_name]) && $custom_priority[$function_name] != $priority) {
1711
+ remove_filter( $tag, $filter['function'], $priority);
1712
+ if ($custom_priority[$function_name] > 0)
1713
+ add_filter( $tag, $filter['function'], $custom_priority[$function_name]);
1714
+ }
1715
+ }
1716
+ }
1717
+ unset($custom_priority);
1718
+ unset($active_filters);
1719
+ }
1720
+
1721
+ //**************************************************************************************
1722
+ // Debug Information
1723
+ //**************************************************************************************
1724
+ private function _microtime_diff($start, $end=NULL) {
1725
+ if( !$end )
1726
+ $end= microtime();
1727
+ list($start_usec, $start_sec) = explode(" ", $start);
1728
+ list($end_usec, $end_sec) = explode(" ", $end);
1729
+ $diff_sec= intval($end_sec) - intval($start_sec);
1730
+ $diff_usec= floatval($end_usec) - floatval($start_usec);
1731
+ return floatval( $diff_sec ) + $diff_usec;
1732
+ }
1733
+
1734
+ private function _get_debug_info($buffer, $tag = '') {
1735
+ $ret_val = "<!--\n";
1736
+
1737
+ $ret_val .= "***** Processing time ****************************\n"
1738
+ . $this->_microtime_diff($this->mtime_start) . " seconds\n"
1739
+ . "**************************************************\n\n";
1740
+ $this->mtime_start = microtime();
1741
+
1742
+ $ret_val .= "***** Original ***********************************\n"
1743
+ . str_replace(array('<', '>'), array('<', '>'), $buffer) . "\n"
1744
+ . "**************************************************\n\n";
1745
+
1746
+ $ret_val .= "***** Filters ************************************\n";
1747
+ if (empty($tag) && function_exists('current_filter'))
1748
+ $tag = current_filter();
1749
+ $active_filters = (isset($this->filters[$tag])
1750
+ ? $this->filters[$tag]
1751
+ : array());
1752
+ foreach ($active_filters as $function_name => $priority) {
1753
+ if (strpos($function_name, 'HeadCleanerController') === FALSE && strpos($function_name, 'noindex') === FALSE)
1754
+ $ret_val .= " ($priority) : $function_name\n";
1755
+ }
1756
+ $ret_val .= "**************************************************\n\n";
1757
+
1758
+ $ret_val .= "***** ob_list_handlers ***************************\n";
1759
+ if (function_exists('ob_list_handlers')) {
1760
+ $active_handlers = ob_list_handlers();
1761
+ foreach ($active_handlers as $handler) {
1762
+ $ret_val .= " $handler\n";
1763
+ }
1764
+ unset($active_handlers);
1765
+ }
1766
+ $ret_val .= "**************************************************\n\n";
1767
+
1768
+ $ret_val .= "--> \n";
1769
+
1770
+ return $ret_val;
1771
+ }
1772
+ }
1773
+
1774
+ global $head_cleaner;
1775
+
1776
+ $head_cleaner = new HeadCleanerController();
1777
+
1778
+ add_action('admin_menu', array(&$head_cleaner, 'admin_menu'));
1779
+ add_filter('plugin_action_links', array(&$head_cleaner, 'plugin_setting_links'), 10, 2 );
1780
+
1781
+ add_action('get_header', array(&$head_cleaner, 'head_start'));
1782
+ add_action('wp_footer', array(&$head_cleaner, 'filters_save'), 11);
1783
+
1784
+ if (function_exists('register_activation_hook')) {
1785
+ register_activation_hook(__FILE__, array(&$head_cleaner, 'activation'));
1786
+ register_deactivation_hook(__FILE__, array(&$head_cleaner, 'deactivation'));
1787
+ }
1788
+
1789
+ endif;
1790
+ ?>
includes/common-controller.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //**************************************************************************************
3
+ // Require wp-load.php or wp-config.php
4
+ //**************************************************************************************
5
+ if(!function_exists('get_option')) {
6
+ $path = (defined('ABSPATH') ? ABSPATH : dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/');
7
+ require_once(file_exists($path.'wp-load.php') ? $path.'wp-load.php' : $path.'wp-config.php');
8
+ }
9
+
10
+ //**************************************************************************************
11
+ // Common Controller
12
+ //**************************************************************************************
13
+ if (!class_exists('wokController')) :
14
+ class wokController {
15
+ var $file_path;
16
+ var $plugins_dir, $plugin_dir, $plugin_file, $plugin_url;
17
+ var $textdomain_name;
18
+ var $options, $option_name;
19
+ var $admin_option, $admin_action, $admin_hook;
20
+ var $note, $error;
21
+ var $charset;
22
+ var $wp25, $wp26, $wp27;
23
+
24
+ var $jquery_js = 'includes/js/jquery-1.2.6.min.js';
25
+ var $jquery_ver = '1.2.6';
26
+
27
+ var $jquery_noconflict_js = 'includes/js/jquery.noconflict.js';
28
+ var $forChrome_js = 'includes/js/jquery.browser.chrome.min.js';
29
+
30
+ /*
31
+ * initialize
32
+ */
33
+ function init($file) {
34
+ global $wp_version, $wok_script_manager;
35
+
36
+ $this->charset = get_option('blog_charset');
37
+ $this->wp25 = version_compare($wp_version, "2.5", ">=");
38
+ $this->wp26 = version_compare($wp_version, "2.6", ">=");
39
+ $this->wp27 = version_compare($wp_version, "2.7", ">=");
40
+
41
+ $this->setPluginDir($file);
42
+ $this->loadTextdomain();
43
+
44
+ $this->note = '';
45
+ $this->error = 0;
46
+
47
+ $this->admin_option = $this->plugin_file;
48
+ $this->admin_action = trailingslashit(get_bloginfo('wpurl')).'wp-admin/'.($this->wp27 ? 'options-general.php' : 'admin.php').'?page='.$this->admin_option;
49
+ $this->admin_hook = array();
50
+
51
+ $this->options = array();
52
+ $this->option_name = $this->plugin_name." Options";
53
+
54
+ // jQuery 1.3.2 !
55
+ if (file_exists(trailingslashit(ABSPATH . $this->plugins_dir . $this->plugin_dir) . 'includes/js/jquery-1.3.1.min.js')) {
56
+ $this->jquery_js = 'includes/js/jquery-1.3.2.min.js';
57
+ $this->jquery_ver = '1.3.2';
58
+ }
59
+
60
+ if (!isset($wok_script_manager) && class_exists('wokScriptManager'))
61
+ $wok_script_manager = new wokScriptManager();
62
+ }
63
+
64
+ function setPluginDir($file) {
65
+ $this->file_path = $file;
66
+ $this->plugins_dir = trailingslashit(defined('PLUGINDIR') ? PLUGINDIR : 'wp-content/plugins');
67
+ $filename = explode("/", $this->file_path);
68
+ if(count($filename) <= 1) $filename = explode("\\", $this->file_path);
69
+ $this->plugin_dir = $filename[count($filename) - 2];
70
+ $this->plugin_file = $filename[count($filename) - 1];
71
+ $this->plugin_url = trailingslashit(trailingslashit(defined('WP_PLUGIN_URL') ? WP_PLUGIN_URL : trailingslashit(get_bloginfo('wpurl')).$this->plugins_dir).$this->plugin_dir);
72
+ unset($filename);
73
+ }
74
+
75
+ function loadTextdomain( $sub_dir = '' ) {
76
+ $this->textdomain_name = $this->plugin_dir;
77
+ $abs_plugin_dir = ABSPATH.$this->plugins_dir.'/'.$this->plugin_dir;
78
+ if (empty($sub_dir))
79
+ $sub_dir = (file_exists($abs_plugin_dir.'/languages') ? '/languages' : (file_exists($abs_plugin_dir.'/language') ? '/language' : ''));
80
+ $textdomain_dir = trailingslashit(trailingslashit($this->plugin_dir).$sub_dir);
81
+ if ($this->wp26 && defined('WP_PLUGIN_DIR'))
82
+ load_plugin_textdomain($this->textdomain_name, false, $textdomain_dir);
83
+ else
84
+ load_plugin_textdomain($this->textdomain_name, $this->plugins_dir . $textdomain_dir);
85
+ }
86
+
87
+ // Handles Add/strips slashes to the given array
88
+ function stripArray($array) {
89
+ if(!is_array($array))
90
+ return $array;
91
+
92
+ foreach($array as $key => $value) {
93
+ if (!is_array($value))
94
+ $slashed_array[$key] = stripslashes($value);
95
+ else
96
+ $slashed_array[$key] = $this->stripArray($value);
97
+ }
98
+ return $slashed_array;
99
+ }
100
+
101
+ // Get Option
102
+ function getOption($key) {
103
+ if ($key=='version')
104
+ return (isset($this->plugin_ver) ? $this->plugin_ver : false);
105
+ else
106
+ return (isset($this->options[$key]) ? $this->options[$key] : false);
107
+ }
108
+
109
+ // Get Text
110
+ function getText($text) {
111
+ return __($text, $this->textdomain_name);
112
+ }
113
+
114
+
115
+ // Get Options
116
+ function getOptions(){
117
+ return get_option($this->option_name);
118
+ }
119
+
120
+ // Update Options
121
+ function updateOptions() {
122
+ update_option($this->option_name, $this->options);
123
+ }
124
+
125
+ // Delete Options
126
+ function deleteOptions() {
127
+ delete_option($this->option_name);
128
+ }
129
+
130
+ // Add Admin Option Page
131
+ function addOptionPage($page_title, $function, $capability = 9, $menu_title = '', $file = '') {
132
+ if ($menu_title == '') $menu_title = $page_title;
133
+ if ($file == '') $file = $this->plugin_file;
134
+ $this->admin_hook['option'] = add_options_page($page_title, $menu_title, $capability, $file, $function);
135
+ }
136
+
137
+ function addManagementPage($page_title, $function, $capability = 9, $menu_title = '', $file = '') {
138
+ if ($menu_title == '') $menu_title = $page_title;
139
+ if ($file == '') $file = $this->plugin_file;
140
+ $this->admin_hook['management'] = add_management_page($page_title, $menu_title, $capability, $file, $function);
141
+ }
142
+
143
+ function addThemePage($page_title, $function, $capability = 9, $menu_title = '', $file = '') {
144
+ if ($menu_title == '') $menu_title = $page_title;
145
+ if ($file == '') $file = $this->plugin_file;
146
+ $this->admin_hook['theme'] = add_theme_page($page_title, $menu_title, $capability, $file, $function);
147
+ }
148
+
149
+ function addSubmenuPage($parent, $page_title, $function, $capability = 9, $menu_title = '', $file = '') {
150
+ if ($menu_title == '') $menu_title = $page_title;
151
+ if ($file == '') $file = $this->plugin_file;
152
+ $this->admin_hook[$parent] = add_submenu_page($parent, $page_title, $menu_title, $capability, $file, $function);
153
+ }
154
+
155
+ function addMediaPage($page_title, $function, $capability = 9, $menu_title = '', $file = '') {
156
+ $this->addSubmenuPage(($this->wp27 ? 'upload.php' : 'edit.php'), $page_title, $function, $capability, $menu_title, $file);
157
+ }
158
+
159
+ function addEditPage($page_title, $function, $capability = 9, $menu_title = '', $file = '') {
160
+ $this->addSubmenuPage('edit.php', $page_title, $function, $capability, $menu_title, $file);
161
+ }
162
+
163
+ function addPluginSettingLinks($links, $file) {
164
+ $this_plugin = plugin_basename($this->file_path);
165
+ if ($file == $this_plugin) {
166
+ $settings_link = '<a href="options-general.php?page=' . $this->plugin_file . '">' . __('Settings') . '</a>';
167
+ array_unshift($links, $settings_link); // before other links
168
+ }
169
+ return $links;
170
+ }
171
+
172
+ // Make Nonce field
173
+ function makeNonceField($action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
174
+ if ( !function_exists('wp_nonce_field') )
175
+ return;
176
+ else
177
+ return wp_nonce_field($action, $name, $referer, $echo);
178
+ }
179
+
180
+ // This Plugin active?
181
+ function isActive($file = '') {
182
+ $is_active = false;
183
+ if ($file == '') $file = $this->plugin_file;
184
+ foreach (get_option('active_plugins') as $val) {
185
+ if (preg_match('/'.preg_quote($file).'/i', $val)) {
186
+ $is_active = true;
187
+ break;
188
+ }
189
+ }
190
+ return $is_active;
191
+ }
192
+
193
+ // Mobile Access ?
194
+ function isKtai(){
195
+ return (
196
+ (function_exists('is_mobile') && is_mobile()) ||
197
+ (function_exists('is_ktai') && is_ktai())
198
+ );
199
+ }
200
+
201
+ // Output Javascript
202
+ function writeScript($out = '', $place = 'head') {
203
+ global $wok_script_manager;
204
+ if ($out == '' || !isset($wok_script_manager)) return;
205
+ add_filter($place.'_script/manageScripts', create_function('$js', 'return $js . "'.addcslashes($out,'"').'";'));
206
+ }
207
+
208
+ // Regist jQuery
209
+ function addjQuery() {
210
+ if (function_exists('wp_register_script')) {
211
+ global $wok_script_manager;
212
+ if (!isset($wok_script_manager)) return false;
213
+
214
+ $wok_script_manager->registerScript('jquery', $this->plugin_url.$this->jquery_js, false, $this->jquery_ver);
215
+ wp_enqueue_script('jquery');
216
+ if (eregi("chrome", $_SERVER['HTTP_USER_AGENT']))
217
+ wp_enqueue_script('jquery.chrome', $this->plugin_url.$this->forChrome_js, array('jquery'), $this->jquery_ver);
218
+ add_filter('print_scripts_array', array($this, 'jQueryNoConflict'), 11);
219
+ return true;
220
+ } else {
221
+ return false;
222
+ }
223
+ }
224
+
225
+ // jQuery noConflict
226
+ function jQueryNoConflict($args) {
227
+ if (function_exists('wp_register_script')) {
228
+ global $wok_script_manager;
229
+ if (!isset($wok_script_manager)) return false;
230
+
231
+ $jquerypos = array_search('jquery', $args);
232
+ if(false !== $jquerypos && in_array('prototype', $args)) {
233
+ // Need to add a no conflict call after the jquery.
234
+ wp_register_script('jquery.noconflict', $this->plugin_url.$this->jquery_noconflict_js ,array('jquery'));
235
+ array_splice( $args, $jquerypos+1, 0, 'jquery.noconflict' );
236
+ }
237
+ }
238
+ return $args;
239
+ }
240
+
241
+ // WP_CONTENT_DIR
242
+ function wp_content_dir($path = '') {
243
+ return (!defined('WP_CONTENT_DIR')
244
+ ? WP_CONTENT_DIR
245
+ : ABSPATH . 'wp-content'
246
+ ) . $path;
247
+ }
248
+
249
+ // WP_CONTENT_URL
250
+ function wp_content_url($path = '') {
251
+ return (!defined('WP_CONTENT_URL')
252
+ ? WP_CONTENT_URL
253
+ : get_option('siteurl') . '/wp-content'
254
+ ) . $path;
255
+ }
256
+
257
+ // WP_PLUGIN_DIR
258
+ function wp_plugin_dir($path = '') {
259
+ return $this->wp_content_dir( '/plugins' . $path );
260
+ }
261
+
262
+ // WP_PLUGIN_URL
263
+ function wp_plugin_url($path = '') {
264
+ return $this->wp_content_url( '/plugins' . $path );
265
+ }
266
+ }
267
+ endif;
268
+
269
+ //**************************************************************************************
270
+ // JavaScript Manager
271
+ //**************************************************************************************
272
+ if (function_exists('wp_register_script') && !class_exists('wokScriptManager')) :
273
+ class wokScriptManager {
274
+ /*
275
+ * Constructor
276
+ */
277
+ function wokScriptManager() {
278
+ $this->__construct();
279
+ }
280
+ function __construct() {
281
+ global $wp_scripts;
282
+ if (!is_a($wp_scripts, 'WP_Scripts')) $wp_scripts = new WP_Scripts();
283
+ add_action('admin_head', array($this, 'adminHeadPrintScript'), 11);
284
+ add_action('wp_head', array($this, 'headPrintScript'), 11);
285
+ add_action('wp_footer', array($this, 'footerPrintScript'), 11);
286
+ }
287
+
288
+ function registerScript( $handle, $src = '', $deps = false, $ver = false ) {
289
+ global $wp_scripts, $wp_version;
290
+
291
+ if (version_compare($wp_version, "2.6", ">=")) {
292
+ if (isset($wp_scripts->registered[$handle])) {
293
+ if (version_compare($wp_scripts->registered[$handle]->ver, $ver, '<')) {
294
+ if ($src != '') $wp_scripts->registered[$handle]->src = $src;
295
+ if (is_array($deps)) $wp_scripts->registered[$handle]->deps = $deps;
296
+ if ($ver != false) $wp_scripts->registered[$handle]->ver = $ver;
297
+ }
298
+ } else {
299
+ wp_register_script($handle, $src, $deps, $ver);
300
+ }
301
+ } else {
302
+ if (isset($wp_scripts->scripts[$handle])) {
303
+ if (version_compare($wp_scripts->scripts[$handle]->ver, $ver, '<')) {
304
+ if ($src != '') $wp_scripts->scripts[$handle]->src = $src;
305
+ if (is_array($deps)) $wp_scripts->scripts[$handle]->deps = $deps;
306
+ if ($ver != false) $wp_scripts->scripts[$handle]->ver = $ver;
307
+ }
308
+ } else {
309
+ wp_register_script($handle, $src, $deps, $ver);
310
+ }
311
+ }
312
+ }
313
+
314
+ function dequeueScript( $handle ) {
315
+ global $wp_scripts;
316
+ $wp_scripts->dequeue( $handle );
317
+ }
318
+
319
+ function printScript($js) {
320
+ if ($js != '') {
321
+ echo "<script type=\"text/javascript\">//<![CDATA[\n";
322
+ echo $js;
323
+ echo "//]]></script>\n";
324
+ }
325
+ }
326
+
327
+ function adminHeadPrintScript() {
328
+ $this->printScript(apply_filters('admin_head_script/manageScripts', ''));
329
+ }
330
+
331
+ function headPrintScript() {
332
+ $this->printScript(apply_filters('head_script/manageScripts', ''));
333
+ }
334
+
335
+ function footerPrintScript() {
336
+ $this->printScript(apply_filters('footer_script/manageScripts', ''));
337
+ }
338
+ }
339
+ endif;
340
+ ?>
includes/csstidy-1.3/COPYING ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Library General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License
307
+ along with this program; if not, write to the Free Software
308
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
309
+
310
+
311
+ Also add information on how to contact you by electronic and paper mail.
312
+
313
+ If the program is interactive, make it output a short notice like this
314
+ when it starts in an interactive mode:
315
+
316
+ Gnomovision version 69, Copyright (C) year name of author
317
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
+ This is free software, and you are welcome to redistribute it
319
+ under certain conditions; type `show c' for details.
320
+
321
+ The hypothetical commands `show w' and `show c' should show the appropriate
322
+ parts of the General Public License. Of course, the commands you use may
323
+ be called something other than `show w' and `show c'; they could even be
324
+ mouse-clicks or menu items--whatever suits your program.
325
+
326
+ You should also get your employer (if you work as a programmer) or your
327
+ school, if any, to sign a "copyright disclaimer" for the program, if
328
+ necessary. Here is a sample; alter the names:
329
+
330
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
+
333
+ <signature of Ty Coon>, 1 April 1989
334
+ Ty Coon, President of Vice
335
+
336
+ This General Public License does not permit incorporating your program into
337
+ proprietary programs. If your program is a subroutine library, you may
338
+ consider it more useful to permit linking proprietary applications with the
339
+ library. If this is what you want to do, use the GNU Library General
340
+ Public License instead of this License.
includes/csstidy-1.3/README ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CSSTidy
2
+
3
+ Changelog: http://cdburnerxp.se/cssparse/csstidy/changelog.php
4
+
5
+ css_optimiser.php is the web-interface, css_parser.php contains the PHP class (CSSTidy).
6
+
7
+ This class represents a CSS parser which reads CSS code and saves it in an array.
8
+ In opposite to most other CSS parsers, it does not use regular expressions and
9
+ thus has full CSS2 support and a higher reliability. The downside of not using regular expressions
10
+ is a lower speed though.
11
+ Additional to that it applies some optimisations and fixes to the CSS code.
12
+ An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php
13
+
14
+
15
+
16
+ CSSTidy is free software; you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation; either version 2 of the License, or
19
+ (at your option) any later version.
20
+
21
+ CSSTidy is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with CSSTidy; if not, write to the Free Software
28
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
includes/csstidy-1.3/class.csstidy.php ADDED
@@ -0,0 +1,999 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CSSTidy - CSS Parser and Optimiser
4
+ *
5
+ * CSS Parser class
6
+ *
7
+ * This file is part of CSSTidy.
8
+ *
9
+ * CSSTidy is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * CSSTidy is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with CSSTidy; if not, write to the Free Software
21
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
+ *
23
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
24
+ * @package csstidy
25
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
26
+ */
27
+
28
+ /**
29
+ * Various CSS data needed for correct optimisations etc.
30
+ *
31
+ * @version 1.3
32
+ */
33
+ require(dirname(__FILE__).'/data.inc.php');
34
+
35
+ /**
36
+ * Contains a class for printing CSS code
37
+ *
38
+ * @version 1.0
39
+ */
40
+ require(dirname(__FILE__).'/class.csstidy_print.php');
41
+
42
+ /**
43
+ * Contains a class for optimising CSS code
44
+ *
45
+ * @version 1.0
46
+ */
47
+ require(dirname(__FILE__).'/class.csstidy_optimise.php');
48
+
49
+ /**
50
+ * CSS Parser class
51
+ *
52
+ * This class represents a CSS parser which reads CSS code and saves it in an array.
53
+ * In opposite to most other CSS parsers, it does not use regular expressions and
54
+ * thus has full CSS2 support and a higher reliability.
55
+ * Additional to that it applies some optimisations and fixes to the CSS code.
56
+ * An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php
57
+ * @package csstidy
58
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
59
+ * @version 1.3
60
+ */
61
+ class csstidy {
62
+
63
+ /**
64
+ * Saves the parsed CSS
65
+ * @var array
66
+ * @access public
67
+ */
68
+ var $css = array();
69
+
70
+ /**
71
+ * Saves the parsed CSS (raw)
72
+ * @var array
73
+ * @access private
74
+ */
75
+ var $tokens = array();
76
+
77
+ /**
78
+ * Printer class
79
+ * @see csstidy_print
80
+ * @var object
81
+ * @access public
82
+ */
83
+ var $print;
84
+
85
+ /**
86
+ * Optimiser class
87
+ * @see csstidy_optimise
88
+ * @var object
89
+ * @access private
90
+ */
91
+ var $optimise;
92
+
93
+ /**
94
+ * Saves the CSS charset (@charset)
95
+ * @var string
96
+ * @access private
97
+ */
98
+ var $charset = '';
99
+
100
+ /**
101
+ * Saves all @import URLs
102
+ * @var array
103
+ * @access private
104
+ */
105
+ var $import = array();
106
+
107
+ /**
108
+ * Saves the namespace
109
+ * @var string
110
+ * @access private
111
+ */
112
+ var $namespace = '';
113
+
114
+ /**
115
+ * Contains the version of csstidy
116
+ * @var string
117
+ * @access private
118
+ */
119
+ var $version = '1.3';
120
+
121
+ /**
122
+ * Stores the settings
123
+ * @var array
124
+ * @access private
125
+ */
126
+ var $settings = array();
127
+
128
+ /**
129
+ * Saves the parser-status.
130
+ *
131
+ * Possible values:
132
+ * - is = in selector
133
+ * - ip = in property
134
+ * - iv = in value
135
+ * - instr = in string (started at " or ' or ( )
136
+ * - ic = in comment (ignore everything)
137
+ * - at = in @-block
138
+ *
139
+ * @var string
140
+ * @access private
141
+ */
142
+ var $status = 'is';
143
+
144
+
145
+ /**
146
+ * Saves the current at rule (@media)
147
+ * @var string
148
+ * @access private
149
+ */
150
+ var $at = '';
151
+
152
+ /**
153
+ * Saves the current selector
154
+ * @var string
155
+ * @access private
156
+ */
157
+ var $selector = '';
158
+
159
+ /**
160
+ * Saves the current property
161
+ * @var string
162
+ * @access private
163
+ */
164
+ var $property = '';
165
+
166
+ /**
167
+ * Saves the position of , in selectors
168
+ * @var array
169
+ * @access private
170
+ */
171
+ var $sel_separate = array();
172
+
173
+ /**
174
+ * Saves the current value
175
+ * @var string
176
+ * @access private
177
+ */
178
+ var $value = '';
179
+
180
+ /**
181
+ * Saves the current sub-value
182
+ *
183
+ * Example for a subvalue:
184
+ * background:url(foo.png) red no-repeat;
185
+ * "url(foo.png)", "red", and "no-repeat" are subvalues,
186
+ * seperated by whitespace
187
+ * @var string
188
+ * @access private
189
+ */
190
+ var $sub_value = '';
191
+
192
+ /**
193
+ * Array which saves all subvalues for a property.
194
+ * @var array
195
+ * @see sub_value
196
+ * @access private
197
+ */
198
+ var $sub_value_arr = array();
199
+
200
+ /**
201
+ * Saves the char which opened the last string
202
+ * @var string
203
+ * @access private
204
+ */
205
+ var $str_char = '';
206
+ var $cur_string = '';
207
+
208
+ /**
209
+ * Status from which the parser switched to ic or instr
210
+ * @var string
211
+ * @access private
212
+ */
213
+ var $from = '';
214
+
215
+ /**
216
+ * Variable needed to manage string-in-strings, for example url("foo.png")
217
+ * @var string
218
+ * @access private
219
+ */
220
+ var $str_in_str = false;
221
+
222
+ /**
223
+ * =true if in invalid at-rule
224
+ * @var bool
225
+ * @access private
226
+ */
227
+ var $invalid_at = false;
228
+
229
+ /**
230
+ * =true if something has been added to the current selector
231
+ * @var bool
232
+ * @access private
233
+ */
234
+ var $added = false;
235
+
236
+ /**
237
+ * Array which saves the message log
238
+ * @var array
239
+ * @access private
240
+ */
241
+ var $log = array();
242
+
243
+ /**
244
+ * Saves the line number
245
+ * @var integer
246
+ * @access private
247
+ */
248
+ var $line = 1;
249
+
250
+ /**
251
+ * Loads standard template and sets default settings
252
+ * @access private
253
+ * @version 1.3
254
+ */
255
+ function csstidy()
256
+ {
257
+ $this->settings['remove_bslash'] = true;
258
+ $this->settings['compress_colors'] = true;
259
+ $this->settings['compress_font-weight'] = true;
260
+ $this->settings['lowercase_s'] = false;
261
+ $this->settings['optimise_shorthands'] = 1;
262
+ $this->settings['remove_last_;'] = false;
263
+ $this->settings['case_properties'] = 1;
264
+ $this->settings['sort_properties'] = false;
265
+ $this->settings['sort_selectors'] = false;
266
+ $this->settings['merge_selectors'] = 2;
267
+ $this->settings['discard_invalid_properties'] = false;
268
+ $this->settings['css_level'] = 'CSS2.1';
269
+ $this->settings['preserve_css'] = false;
270
+ $this->settings['timestamp'] = false;
271
+
272
+ $this->load_template('default');
273
+ $this->print = new csstidy_print($this);
274
+ $this->optimise = new csstidy_optimise($this);
275
+ }
276
+
277
+ /**
278
+ * Get the value of a setting.
279
+ * @param string $setting
280
+ * @access public
281
+ * @return mixed
282
+ * @version 1.0
283
+ */
284
+ function get_cfg($setting)
285
+ {
286
+ if(isset($this->settings[$setting]))
287
+ {
288
+ return $this->settings[$setting];
289
+ }
290
+ return false;
291
+ }
292
+
293
+ /**
294
+ * Set the value of a setting.
295
+ * @param string $setting
296
+ * @param mixed $value
297
+ * @access public
298
+ * @return bool
299
+ * @version 1.0
300
+ */
301
+ function set_cfg($setting,$value)
302
+ {
303
+ if(isset($this->settings[$setting]) && $value !== '')
304
+ {
305
+ $this->settings[$setting] = $value;
306
+ return true;
307
+ }
308
+ return false;
309
+ }
310
+
311
+ /**
312
+ * Adds a token to $this->tokens
313
+ * @param mixed $type
314
+ * @param string $data
315
+ * @param bool $do add a token even if preserve_css is off
316
+ * @access private
317
+ * @version 1.0
318
+ */
319
+ function _add_token($type, $data, $do = false) {
320
+ if($this->get_cfg('preserve_css') || $do) {
321
+ $this->tokens[] = array($type, ($type == COMMENT) ? $data : trim($data));
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Add a message to the message log
327
+ * @param string $message
328
+ * @param string $type
329
+ * @param integer $line
330
+ * @access private
331
+ * @version 1.0
332
+ */
333
+ function log($message,$type,$line = -1)
334
+ {
335
+ if($line === -1)
336
+ {
337
+ $line = $this->line;
338
+ }
339
+ $line = intval($line);
340
+ $add = array('m' => $message, 't' => $type);
341
+ if(!isset($this->log[$line]) || !in_array($add,$this->log[$line]))
342
+ {
343
+ $this->log[$line][] = $add;
344
+ }
345
+ }
346
+
347
+ /**
348
+ * Parse unicode notations and find a replacement character
349
+ * @param string $string
350
+ * @param integer $i
351
+ * @access private
352
+ * @return string
353
+ * @version 1.2
354
+ */
355
+ function _unicode(&$string, &$i)
356
+ {
357
+ ++$i;
358
+ $add = '';
359
+ $tokens =& $GLOBALS['csstidy']['tokens'];
360
+ $replaced = false;
361
+
362
+ while($i < strlen($string) && (ctype_xdigit($string{$i}) || ctype_space($string{$i})) && strlen($add) < 6)
363
+ {
364
+ $add .= $string{$i};
365
+
366
+ if(ctype_space($string{$i})) {
367
+ break;
368
+ }
369
+ $i++;
370
+ }
371
+
372
+ if(hexdec($add) > 47 && hexdec($add) < 58 || hexdec($add) > 64 && hexdec($add) < 91 || hexdec($add) > 96 && hexdec($add) < 123)
373
+ {
374
+ $this->log('Replaced unicode notation: Changed \\'. $add .' to ' . chr(hexdec($add)),'Information');
375
+ $add = chr(hexdec($add));
376
+ $replaced = true;
377
+ }
378
+ else {
379
+ $add = trim('\\'.$add);
380
+ }
381
+
382
+ if(@ctype_xdigit($string{$i+1}) && ctype_space($string{$i})
383
+ && !$replaced || !ctype_space($string{$i})) {
384
+ $i--;
385
+ }
386
+
387
+ if($add != '\\' || !$this->get_cfg('remove_bslash') || strpos($tokens, $string{$i+1}) !== false) {
388
+ return $add;
389
+ }
390
+
391
+ if($add == '\\') {
392
+ $this->log('Removed unnecessary backslash','Information');
393
+ }
394
+ return '';
395
+ }
396
+
397
+ /**
398
+ * Loads a new template
399
+ * @param string $content either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default"
400
+ * @param bool $from_file uses $content as filename if true
401
+ * @access public
402
+ * @version 1.1
403
+ * @see http://csstidy.sourceforge.net/templates.php
404
+ */
405
+ function load_template($content, $from_file=true)
406
+ {
407
+ $predefined_templates =& $GLOBALS['csstidy']['predefined_templates'];
408
+ if($content == 'high_compression' || $content == 'default' || $content == 'highest_compression' || $content == 'low_compression')
409
+ {
410
+ $this->template = $predefined_templates[$content];
411
+ return;
412
+ }
413
+
414
+ if($from_file)
415
+ {
416
+ $content = strip_tags(file_get_contents($content),'<span>');
417
+ }
418
+ $content = str_replace("\r\n","\n",$content); // Unify newlines (because the output also only uses \n)
419
+ $template = explode('|',$content);
420
+
421
+ for ($i = 0; $i < count($template); $i++ )
422
+ {
423
+ $this->template[$i] = $template[$i];
424
+ }
425
+ }
426
+
427
+ /**
428
+ * Starts parsing from URL
429
+ * @param string $url
430
+ * @access public
431
+ * @version 1.0
432
+ */
433
+ function parse_from_url($url)
434
+ {
435
+ return $this->parse(@file_get_contents($url));
436
+ }
437
+
438
+ /**
439
+ * Checks if there is a token at the current position
440
+ * @param string $string
441
+ * @param integer $i
442
+ * @access public
443
+ * @version 1.11
444
+ */
445
+ function is_token(&$string, $i)
446
+ {
447
+ $tokens =& $GLOBALS['csstidy']['tokens'];
448
+ return (strpos($tokens, $string{$i}) !== false && !csstidy::escaped($string,$i));
449
+ }
450
+
451
+
452
+ /**
453
+ * Parses CSS in $string. The code is saved as array in $this->css
454
+ * @param string $string the CSS code
455
+ * @access public
456
+ * @return bool
457
+ * @version 1.1
458
+ */
459
+ function parse($string) {
460
+ // PHP bug? Settings need to be refreshed in PHP4
461
+ $this->print = new csstidy_print($this);
462
+ $this->optimise = new csstidy_optimise($this);
463
+
464
+ $all_properties =& $GLOBALS['csstidy']['all_properties'];
465
+ $at_rules =& $GLOBALS['csstidy']['at_rules'];
466
+
467
+ $this->css = array();
468
+ $this->print->input_css = $string;
469
+ $string = str_replace("\r\n","\n",$string) . ' ';
470
+ $cur_comment = '';
471
+
472
+ for ($i = 0, $size = strlen($string); $i < $size; $i++ )
473
+ {
474
+ if($string{$i} == "\n" || $string{$i} == "\r")
475
+ {
476
+ ++$this->line;
477
+ }
478
+
479
+ switch($this->status)
480
+ {
481
+ /* Case in at-block */
482
+ case 'at':
483
+ if(csstidy::is_token($string,$i))
484
+ {
485
+ if($string{$i} == '/' && @$string{$i+1} == '*')
486
+ {
487
+ $this->status = 'ic'; ++$i;
488
+ $this->from = 'at';
489
+ }
490
+ elseif($string{$i} == '{')
491
+ {
492
+ $this->status = 'is';
493
+ $this->_add_token(AT_START, $this->at);
494
+ }
495
+ elseif($string{$i} == ',')
496
+ {
497
+ $this->at = trim($this->at).',';
498
+ }
499
+ elseif($string{$i} == '\\')
500
+ {
501
+ $this->at .= $this->_unicode($string,$i);
502
+ }
503
+ }
504
+ else
505
+ {
506
+ $lastpos = strlen($this->at)-1;
507
+ if(!( (ctype_space($this->at{$lastpos}) || csstidy::is_token($this->at,$lastpos) && $this->at{$lastpos} == ',') && ctype_space($string{$i})))
508
+ {
509
+ $this->at .= $string{$i};
510
+ }
511
+ }
512
+ break;
513
+
514
+ /* Case in-selector */
515
+ case 'is':
516
+ if(csstidy::is_token($string,$i))
517
+ {
518
+ if($string{$i} == '/' && @$string{$i+1} == '*' && trim($this->selector) == '')
519
+ {
520
+ $this->status = 'ic'; ++$i;
521
+ $this->from = 'is';
522
+ }
523
+ elseif($string{$i} == '@' && trim($this->selector) == '')
524
+ {
525
+ // Check for at-rule
526
+ $this->invalid_at = true;
527
+ foreach($at_rules as $name => $type)
528
+ {
529
+ if(!strcasecmp(substr($string,$i+1,strlen($name)),$name))
530
+ {
531
+ ($type == 'at') ? $this->at = '@'.$name : $this->selector = '@'.$name;
532
+ $this->status = $type;
533
+ $i += strlen($name);
534
+ $this->invalid_at = false;
535
+ }
536
+ }
537
+
538
+ if($this->invalid_at)
539
+ {
540
+ $this->selector = '@';
541
+ $invalid_at_name = '';
542
+ for($j = $i+1; $j < $size; ++$j)
543
+ {
544
+ if(!ctype_alpha($string{$j}))
545
+ {
546
+ break;
547
+ }
548
+ $invalid_at_name .= $string{$j};
549
+ }
550
+ $this->log('Invalid @-rule: '.$invalid_at_name.' (removed)','Warning');
551
+ }
552
+ }
553
+ elseif(($string{$i} == '"' || $string{$i} == "'"))
554
+ {
555
+ $this->cur_string = $string{$i};
556
+ $this->status = 'instr';
557
+ $this->str_char = $string{$i};
558
+ $this->from = 'is';
559
+ }
560
+ elseif($this->invalid_at && $string{$i} == ';')
561
+ {
562
+ $this->invalid_at = false;
563
+ $this->status = 'is';
564
+ }
565
+ elseif($string{$i} == '{')
566
+ {
567
+ $this->status = 'ip';
568
+ $this->_add_token(SEL_START, $this->selector);
569
+ $this->added = false;
570
+ }
571
+ elseif($string{$i} == '}')
572
+ {
573
+ $this->_add_token(AT_END, $this->at);
574
+ $this->at = '';
575
+ $this->selector = '';
576
+ $this->sel_separate = array();
577
+ }
578
+ elseif($string{$i} == ',')
579
+ {
580
+ $this->selector = trim($this->selector).',';
581
+ $this->sel_separate[] = strlen($this->selector);
582
+ }
583
+ elseif($string{$i} == '\\')
584
+ {
585
+ $this->selector .= $this->_unicode($string,$i);
586
+ }
587
+ // remove unnecessary universal selector, FS#147
588
+ else if(!($string{$i} == '*' && @in_array($string{$i+1}, array('.', '#', '[', ':')))) {
589
+ $this->selector .= $string{$i};
590
+ }
591
+ }
592
+ else
593
+ {
594
+ $lastpos = strlen($this->selector)-1;
595
+ if($lastpos == -1 || !( (ctype_space($this->selector{$lastpos}) || csstidy::is_token($this->selector,$lastpos) && $this->selector{$lastpos} == ',') && ctype_space($string{$i})))
596
+ {
597
+ $this->selector .= $string{$i};
598
+ }
599
+ }
600
+ break;
601
+
602
+ /* Case in-property */
603
+ case 'ip':
604
+ if(csstidy::is_token($string,$i))
605
+ {
606
+ if(($string{$i} == ':' || $string{$i} == '=') && $this->property != '')
607
+ {
608
+ $this->status = 'iv';
609
+ if(!$this->get_cfg('discard_invalid_properties') || csstidy::property_is_valid($this->property)) {
610
+ $this->_add_token(PROPERTY, $this->property);
611
+ }
612
+ }
613
+ elseif($string{$i} == '/' && @$string{$i+1} == '*' && $this->property == '')
614
+ {
615
+ $this->status = 'ic'; ++$i;
616
+ $this->from = 'ip';
617
+ }
618
+ elseif($string{$i} == '}')
619
+ {
620
+ $this->explode_selectors();
621
+ $this->status = 'is';
622
+ $this->invalid_at = false;
623
+ $this->_add_token(SEL_END, $this->selector);
624
+ $this->selector = '';
625
+ $this->property = '';
626
+ }
627
+ elseif($string{$i} == ';')
628
+ {
629
+ $this->property = '';
630
+ }
631
+ elseif($string{$i} == '\\')
632
+ {
633
+ $this->property .= $this->_unicode($string,$i);
634
+ }
635
+ }
636
+ elseif(!ctype_space($string{$i}))
637
+ {
638
+ $this->property .= $string{$i};
639
+ }
640
+ break;
641
+
642
+ /* Case in-value */
643
+ case 'iv':
644
+ $pn = (($string{$i} == "\n" || $string{$i} == "\r") && $this->property_is_next($string,$i+1) || $i == strlen($string)-1);
645
+ if(csstidy::is_token($string,$i) || $pn)
646
+ {
647
+ if($string{$i} == '/' && @$string{$i+1} == '*')
648
+ {
649
+ $this->status = 'ic'; ++$i;
650
+ $this->from = 'iv';
651
+ }
652
+ elseif(($string{$i} == '"' || $string{$i} == "'" || $string{$i} == '('))
653
+ {
654
+ $this->cur_string = $string{$i};
655
+ $this->str_char = ($string{$i} == '(') ? ')' : $string{$i};
656
+ $this->status = 'instr';
657
+ $this->from = 'iv';
658
+ }
659
+ elseif($string{$i} == ',')
660
+ {
661
+ $this->sub_value = trim($this->sub_value).',';
662
+ }
663
+ elseif($string{$i} == '\\')
664
+ {
665
+ $this->sub_value .= $this->_unicode($string,$i);
666
+ }
667
+ elseif($string{$i} == ';' || $pn)
668
+ {
669
+ if($this->selector{0} == '@' && isset($at_rules[substr($this->selector,1)]) && $at_rules[substr($this->selector,1)] == 'iv')
670
+ {
671
+ $this->sub_value_arr[] = trim($this->sub_value);
672
+
673
+ $this->status = 'is';
674
+
675
+ switch($this->selector)
676
+ {
677
+ case '@charset': $this->charset = $this->sub_value_arr[0]; break;
678
+ case '@namespace': $this->namespace = implode(' ',$this->sub_value_arr); break;
679
+ case '@import': $this->import[] = implode(' ',$this->sub_value_arr); break;
680
+ }
681
+
682
+ $this->sub_value_arr = array();
683
+ $this->sub_value = '';
684
+ $this->selector = '';
685
+ $this->sel_separate = array();
686
+ }
687
+ else
688
+ {
689
+ $this->status = 'ip';
690
+ }
691
+ }
692
+ elseif($string{$i} != '}')
693
+ {
694
+ $this->sub_value .= $string{$i};
695
+ }
696
+ if(($string{$i} == '}' || $string{$i} == ';' || $pn) && !empty($this->selector))
697
+ {
698
+ if($this->at == '')
699
+ {
700
+ $this->at = DEFAULT_AT;
701
+ }
702
+
703
+ // case settings
704
+ if($this->get_cfg('lowercase_s'))
705
+ {
706
+ $this->selector = strtolower($this->selector);
707
+ }
708
+ $this->property = strtolower($this->property);
709
+
710
+ $this->optimise->subvalue();
711
+ if($this->sub_value != '') {
712
+ $this->sub_value_arr[] = $this->sub_value;
713
+ $this->sub_value = '';
714
+ }
715
+
716
+ $this->value = implode(' ',$this->sub_value_arr);
717
+
718
+ $this->selector = trim($this->selector);
719
+
720
+ $this->optimise->value();
721
+
722
+ $valid = csstidy::property_is_valid($this->property);
723
+ if((!$this->invalid_at || $this->get_cfg('preserve_css')) && (!$this->get_cfg('discard_invalid_properties') || $valid))
724
+ {
725
+ $this->css_add_property($this->at,$this->selector,$this->property,$this->value);
726
+ $this->_add_token(VALUE, $this->value);
727
+ $this->optimise->shorthands();
728
+ }
729
+ if(!$valid)
730
+ {
731
+ if($this->get_cfg('discard_invalid_properties'))
732
+ {
733
+ $this->log('Removed invalid property: '.$this->property,'Warning');
734
+ }
735
+ else
736
+ {
737
+ $this->log('Invalid property in '.strtoupper($this->get_cfg('css_level')).': '.$this->property,'Warning');
738
+ }
739
+ }
740
+
741
+ $this->property = '';
742
+ $this->sub_value_arr = array();
743
+ $this->value = '';
744
+ }
745
+ if($string{$i} == '}')
746
+ {
747
+ $this->explode_selectors();
748
+ $this->_add_token(SEL_END, $this->selector);
749
+ $this->status = 'is';
750
+ $this->invalid_at = false;
751
+ $this->selector = '';
752
+ }
753
+ }
754
+ elseif(!$pn)
755
+ {
756
+ $this->sub_value .= $string{$i};
757
+
758
+ if(ctype_space($string{$i}))
759
+ {
760
+ $this->optimise->subvalue();
761
+ if($this->sub_value != '') {
762
+ $this->sub_value_arr[] = $this->sub_value;
763
+ $this->sub_value = '';
764
+ }
765
+ }
766
+ }
767
+ break;
768
+
769
+ /* Case in string */
770
+ case 'instr':
771
+ if($this->str_char == ')' && ($string{$i} == '"' || $string{$i} == '\'') && !$this->str_in_str && !csstidy::escaped($string,$i))
772
+ {
773
+ $this->str_in_str = true;
774
+ }
775
+ elseif($this->str_char == ')' && ($string{$i} == '"' || $string{$i} == '\'') && $this->str_in_str && !csstidy::escaped($string,$i))
776
+ {
777
+ $this->str_in_str = false;
778
+ }
779
+ $temp_add = $string{$i}; // ...and no not-escaped backslash at the previous position
780
+ if( ($string{$i} == "\n" || $string{$i} == "\r") && !($string{$i-1} == '\\' && !csstidy::escaped($string,$i-1)) )
781
+ {
782
+ $temp_add = "\\A ";
783
+ $this->log('Fixed incorrect newline in string','Warning');
784
+ }
785
+ if (!($this->str_char == ')' && in_array($string{$i}, $GLOBALS['csstidy']['whitespace']) && !$this->str_in_str)) {
786
+ $this->cur_string .= $temp_add;
787
+ }
788
+ if($string{$i} == $this->str_char && !csstidy::escaped($string,$i) && !$this->str_in_str)
789
+ {
790
+ $this->status = $this->from;
791
+ if (!preg_match('|[' . implode('', $GLOBALS['csstidy']['whitespace']) . ']|uis', $this->cur_string) && $this->property != 'content') {
792
+ if ($this->str_char == '"' || $this->str_char == '\'') {
793
+ $this->cur_string = substr($this->cur_string, 1, -1);
794
+ } else if (strlen($this->cur_string) > 3 && ($this->cur_string[1] == '"' || $this->cur_string[1] == '\'')) /* () */ {
795
+ $this->cur_string = $this->cur_string[0] . substr($this->cur_string, 2, -2) . substr($this->cur_string, -1);
796
+ }
797
+ }
798
+ if($this->from == 'iv')
799
+ {
800
+ $this->sub_value .= $this->cur_string;
801
+ }
802
+ elseif($this->from == 'is')
803
+ {
804
+ $this->selector .= $this->cur_string;
805
+ }
806
+ }
807
+ break;
808
+
809
+ /* Case in-comment */
810
+ case 'ic':
811
+ if($string{$i} == '*' && $string{$i+1} == '/')
812
+ {
813
+ $this->status = $this->from;
814
+ $i++;
815
+ $this->_add_token(COMMENT, $cur_comment);
816
+ $cur_comment = '';
817
+ }
818
+ else
819
+ {
820
+ $cur_comment .= $string{$i};
821
+ }
822
+ break;
823
+ }
824
+ }
825
+
826
+ $this->optimise->postparse();
827
+
828
+ $this->print->_reset();
829
+
830
+ return !(empty($this->css) && empty($this->import) && empty($this->charset) && empty($this->tokens) && empty($this->namespace));
831
+ }
832
+
833
+ /**
834
+ * Explodes selectors
835
+ * @access private
836
+ * @version 1.0
837
+ */
838
+ function explode_selectors()
839
+ {
840
+ // Explode multiple selectors
841
+ if($this->get_cfg('merge_selectors') == 1)
842
+ {
843
+ $new_sels = array();
844
+ $lastpos = 0;
845
+ $this->sel_separate[] = strlen($this->selector);
846
+ foreach($this->sel_separate as $num => $pos)
847
+ {
848
+ if($num == count($this->sel_separate)-1) {
849
+ $pos += 1;
850
+ }
851
+
852
+ $new_sels[] = substr($this->selector,$lastpos,$pos-$lastpos-1);
853
+ $lastpos = $pos;
854
+ }
855
+
856
+ if(count($new_sels) > 1)
857
+ {
858
+ foreach($new_sels as $selector)
859
+ {
860
+ $this->merge_css_blocks($this->at,$selector,$this->css[$this->at][$this->selector]);
861
+ }
862
+ unset($this->css[$this->at][$this->selector]);
863
+ }
864
+ }
865
+ $this->sel_separate = array();
866
+ }
867
+
868
+ /**
869
+ * Checks if a character is escaped (and returns true if it is)
870
+ * @param string $string
871
+ * @param integer $pos
872
+ * @access public
873
+ * @return bool
874
+ * @version 1.02
875
+ */
876
+ function escaped(&$string,$pos)
877
+ {
878
+ return !(@($string{$pos-1} != '\\') || csstidy::escaped($string,$pos-1));
879
+ }
880
+
881
+ /**
882
+ * Adds a property with value to the existing CSS code
883
+ * @param string $media
884
+ * @param string $selector
885
+ * @param string $property
886
+ * @param string $new_val
887
+ * @access private
888
+ * @version 1.2
889
+ */
890
+ function css_add_property($media,$selector,$property,$new_val)
891
+ {
892
+ if($this->get_cfg('preserve_css') || trim($new_val) == '') {
893
+ return;
894
+ }
895
+
896
+ $this->added = true;
897
+ if(isset($this->css[$media][$selector][$property]))
898
+ {
899
+ if((csstidy::is_important($this->css[$media][$selector][$property]) && csstidy::is_important($new_val)) || !csstidy::is_important($this->css[$media][$selector][$property]))
900
+ {
901
+ unset($this->css[$media][$selector][$property]);
902
+ $this->css[$media][$selector][$property] = trim($new_val);
903
+ }
904
+ }
905
+ else
906
+ {
907
+ $this->css[$media][$selector][$property] = trim($new_val);
908
+ }
909
+ }
910
+
911
+ /**
912
+ * Adds CSS to an existing media/selector
913
+ * @param string $media
914
+ * @param string $selector
915
+ * @param array $css_add
916
+ * @access private
917
+ * @version 1.1
918
+ */
919
+ function merge_css_blocks($media,$selector,$css_add)
920
+ {
921
+ foreach($css_add as $property => $value)
922
+ {
923
+ $this->css_add_property($media,$selector,$property,$value,false);
924
+ }
925
+ }
926
+
927
+ /**
928
+ * Checks if $value is !important.
929
+ * @param string $value
930
+ * @return bool
931
+ * @access public
932
+ * @version 1.0
933
+ */
934
+ function is_important(&$value)
935
+ {
936
+ return (!strcasecmp(substr(str_replace($GLOBALS['csstidy']['whitespace'],'',$value),-10,10),'!important'));
937
+ }
938
+
939
+ /**
940
+ * Returns a value without !important
941
+ * @param string $value
942
+ * @return string
943
+ * @access public
944
+ * @version 1.0
945
+ */
946
+ function gvw_important($value)
947
+ {
948
+ if(csstidy::is_important($value))
949
+ {
950
+ $value = trim($value);
951
+ $value = substr($value,0,-9);
952
+ $value = trim($value);
953
+ $value = substr($value,0,-1);
954
+ $value = trim($value);
955
+ return $value;
956
+ }
957
+ return $value;
958
+ }
959
+
960
+ /**
961
+ * Checks if the next word in a string from pos is a CSS property
962
+ * @param string $istring
963
+ * @param integer $pos
964
+ * @return bool
965
+ * @access private
966
+ * @version 1.2
967
+ */
968
+ function property_is_next($istring, $pos)
969
+ {
970
+ $all_properties =& $GLOBALS['csstidy']['all_properties'];
971
+ $istring = substr($istring,$pos,strlen($istring)-$pos);
972
+ $pos = strpos($istring,':');
973
+ if($pos === false)
974
+ {
975
+ return false;
976
+ }
977
+ $istring = strtolower(trim(substr($istring,0,$pos)));
978
+ if(isset($all_properties[$istring]))
979
+ {
980
+ $this->log('Added semicolon to the end of declaration','Warning');
981
+ return true;
982
+ }
983
+ return false;
984
+ }
985
+
986
+ /**
987
+ * Checks if a property is valid
988
+ * @param string $property
989
+ * @return bool;
990
+ * @access public
991
+ * @version 1.0
992
+ */
993
+ function property_is_valid($property) {
994
+ $all_properties =& $GLOBALS['csstidy']['all_properties'];
995
+ return (isset($all_properties[$property]) && strpos($all_properties[$property],strtoupper($this->get_cfg('css_level'))) !== false );
996
+ }
997
+
998
+ }
999
+ ?>
includes/csstidy-1.3/class.csstidy_optimise.php ADDED
@@ -0,0 +1,809 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CSSTidy - CSS Parser and Optimiser
4
+ *
5
+ * CSS Optimising Class
6
+ * This class optimises CSS data generated by csstidy.
7
+ *
8
+ * This file is part of CSSTidy.
9
+ *
10
+ * CSSTidy is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * CSSTidy is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with CSSTidy; if not, write to the Free Software
22
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
+ *
24
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
25
+ * @package csstidy
26
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
27
+ */
28
+
29
+ /**
30
+ * CSS Optimising Class
31
+ *
32
+ * This class optimises CSS data generated by csstidy.
33
+ *
34
+ * @package csstidy
35
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
36
+ * @version 1.0
37
+ */
38
+
39
+ class csstidy_optimise
40
+ {
41
+ /**
42
+ * Constructor
43
+ * @param array $css contains the class csstidy
44
+ * @access private
45
+ * @version 1.0
46
+ */
47
+ function csstidy_optimise(&$css)
48
+ {
49
+ $this->parser =& $css;
50
+ $this->css =& $css->css;
51
+ $this->sub_value =& $css->sub_value;
52
+ $this->at =& $css->at;
53
+ $this->selector =& $css->selector;
54
+ $this->property =& $css->property;
55
+ $this->value =& $css->value;
56
+ }
57
+
58
+ /**
59
+ * Optimises $css after parsing
60
+ * @access public
61
+ * @version 1.0
62
+ */
63
+ function postparse()
64
+ {
65
+ if ($this->parser->get_cfg('preserve_css')) {
66
+ return;
67
+ }
68
+
69
+ if ($this->parser->get_cfg('merge_selectors') == 2)
70
+ {
71
+ foreach ($this->css as $medium => $value)
72
+ {
73
+ $this->merge_selectors($this->css[$medium]);
74
+ }
75
+ }
76
+
77
+ if ($this->parser->get_cfg('optimise_shorthands') > 0)
78
+ {
79
+ foreach ($this->css as $medium => $value)
80
+ {
81
+ foreach ($value as $selector => $value1)
82
+ {
83
+ $this->css[$medium][$selector] = csstidy_optimise::merge_4value_shorthands($this->css[$medium][$selector]);
84
+
85
+ if ($this->parser->get_cfg('optimise_shorthands') < 2) {
86
+ continue;
87
+ }
88
+
89
+ $this->css[$medium][$selector] = csstidy_optimise::merge_bg($this->css[$medium][$selector]);
90
+ if (empty($this->css[$medium][$selector])) {
91
+ unset($this->css[$medium][$selector]);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Optimises values
100
+ * @access public
101
+ * @version 1.0
102
+ */
103
+ function value()
104
+ {
105
+ $shorthands =& $GLOBALS['csstidy']['shorthands'];
106
+
107
+ // optimise shorthand properties
108
+ if(isset($shorthands[$this->property]))
109
+ {
110
+ $temp = csstidy_optimise::shorthand($this->value); // FIXME - move
111
+ if($temp != $this->value)
112
+ {
113
+ $this->parser->log('Optimised shorthand notation ('.$this->property.'): Changed "'.$this->value.'" to "'.$temp.'"','Information');
114
+ }
115
+ $this->value = $temp;
116
+ }
117
+
118
+ // Remove whitespace at ! important
119
+ if($this->value != $this->compress_important($this->value))
120
+ {
121
+ $this->parser->log('Optimised !important','Information');
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Optimises shorthands
127
+ * @access public
128
+ * @version 1.0
129
+ */
130
+ function shorthands()
131
+ {
132
+ $shorthands =& $GLOBALS['csstidy']['shorthands'];
133
+
134
+ if(!$this->parser->get_cfg('optimise_shorthands') || $this->parser->get_cfg('preserve_css')) {
135
+ return;
136
+ }
137
+
138
+ if($this->property == 'background' && $this->parser->get_cfg('optimise_shorthands') > 1)
139
+ {
140
+ unset($this->css[$this->at][$this->selector]['background']);
141
+ $this->parser->merge_css_blocks($this->at,$this->selector,csstidy_optimise::dissolve_short_bg($this->value));
142
+ }
143
+ if(isset($shorthands[$this->property]))
144
+ {
145
+ $this->parser->merge_css_blocks($this->at,$this->selector,csstidy_optimise::dissolve_4value_shorthands($this->property,$this->value));
146
+ if(is_array($shorthands[$this->property]))
147
+ {
148
+ unset($this->css[$this->at][$this->selector][$this->property]);
149
+ }
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Optimises a sub-value
155
+ * @access public
156
+ * @version 1.0
157
+ */
158
+ function subvalue()
159
+ {
160
+ $replace_colors =& $GLOBALS['csstidy']['replace_colors'];
161
+
162
+ $this->sub_value = trim($this->sub_value);
163
+ if($this->sub_value == '') // caution : '0'
164
+ {
165
+ return;
166
+ }
167
+
168
+ $important = '';
169
+ if(csstidy::is_important($this->sub_value))
170
+ {
171
+ $important = '!important';
172
+ }
173
+ $this->sub_value = csstidy::gvw_important($this->sub_value);
174
+
175
+ // Compress font-weight
176
+ if($this->property == 'font-weight' && $this->parser->get_cfg('compress_font-weight'))
177
+ {
178
+ if($this->sub_value == 'bold')
179
+ {
180
+ $this->sub_value = '700';
181
+ $this->parser->log('Optimised font-weight: Changed "bold" to "700"','Information');
182
+ }
183
+ else if($this->sub_value == 'normal')
184
+ {
185
+ $this->sub_value = '400';
186
+ $this->parser->log('Optimised font-weight: Changed "normal" to "400"','Information');
187
+ }
188
+ }
189
+
190
+ $temp = $this->compress_numbers($this->sub_value);
191
+ if($temp != $this->sub_value)
192
+ {
193
+ if(strlen($temp) > strlen($this->sub_value)) {
194
+ $this->parser->log('Fixed invalid number: Changed "'.$this->sub_value.'" to "'.$temp.'"','Warning');
195
+ } else {
196
+ $this->parser->log('Optimised number: Changed "'.$this->sub_value.'" to "'.$temp.'"','Information');
197
+ }
198
+ $this->sub_value = $temp;
199
+ }
200
+ if($this->parser->get_cfg('compress_colors'))
201
+ {
202
+ $temp = $this->cut_color($this->sub_value);
203
+ if($temp !== $this->sub_value)
204
+ {
205
+ if(isset($replace_colors[$this->sub_value])) {
206
+ $this->parser->log('Fixed invalid color name: Changed "'.$this->sub_value.'" to "'.$temp.'"','Warning');
207
+ } else {
208
+ $this->parser->log('Optimised color: Changed "'.$this->sub_value.'" to "'.$temp.'"','Information');
209
+ }
210
+ $this->sub_value = $temp;
211
+ }
212
+ }
213
+ $this->sub_value .= $important;
214
+ }
215
+
216
+ /**
217
+ * Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px
218
+ * @param string $value
219
+ * @access public
220
+ * @return string
221
+ * @version 1.0
222
+ */
223
+ function shorthand($value)
224
+ {
225
+ $important = '';
226
+ if(csstidy::is_important($value))
227
+ {
228
+ $values = csstidy::gvw_important($value);
229
+ $important = '!important';
230
+ }
231
+ else $values = $value;
232
+
233
+ $values = explode(' ',$values);
234
+ switch(count($values))
235
+ {
236
+ case 4:
237
+ if($values[0] == $values[1] && $values[0] == $values[2] && $values[0] == $values[3])
238
+ {
239
+ return $values[0].$important;
240
+ }
241
+ elseif($values[1] == $values[3] && $values[0] == $values[2])
242
+ {
243
+ return $values[0].' '.$values[1].$important;
244
+ }
245
+ elseif($values[1] == $values[3])
246
+ {
247
+ return $values[0].' '.$values[1].' '.$values[2].$important;
248
+ }
249
+ break;
250
+
251
+ case 3:
252
+ if($values[0] == $values[1] && $values[0] == $values[2])
253
+ {
254
+ return $values[0].$important;
255
+ }
256
+ elseif($values[0] == $values[2])
257
+ {
258
+ return $values[0].' '.$values[1].$important;
259
+ }
260
+ break;
261
+
262
+ case 2:
263
+ if($values[0] == $values[1])
264
+ {
265
+ return $values[0].$important;
266
+ }
267
+ break;
268
+ }
269
+
270
+ return $value;
271
+ }
272
+
273
+ /**
274
+ * Removes unnecessary whitespace in ! important
275
+ * @param string $string
276
+ * @return string
277
+ * @access public
278
+ * @version 1.1
279
+ */
280
+ function compress_important(&$string)
281
+ {
282
+ if(csstidy::is_important($string))
283
+ {
284
+ $string = csstidy::gvw_important($string) . '!important';
285
+ }
286
+ return $string;
287
+ }
288
+
289
+ /**
290
+ * Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values.
291
+ * @param string $color
292
+ * @return string
293
+ * @version 1.1
294
+ */
295
+ function cut_color($color)
296
+ {
297
+ $replace_colors =& $GLOBALS['csstidy']['replace_colors'];
298
+
299
+ // rgb(0,0,0) -> #000000 (or #000 in this case later)
300
+ if(strtolower(substr($color,0,4)) == 'rgb(')
301
+ {
302
+ $color_tmp = substr($color,4,strlen($color)-5);
303
+ $color_tmp = explode(',',$color_tmp);
304
+ for ( $i = 0; $i < count($color_tmp); $i++ )
305
+ {
306
+ $color_tmp[$i] = trim ($color_tmp[$i]);
307
+ if(substr($color_tmp[$i],-1) == '%')
308
+ {
309
+ $color_tmp[$i] = round((255*$color_tmp[$i])/100);
310
+ }
311
+ if($color_tmp[$i]>255) $color_tmp[$i] = 255;
312
+ }
313
+ $color = '#';
314
+ for ($i = 0; $i < 3; $i++ )
315
+ {
316
+ if($color_tmp[$i]<16) {
317
+ $color .= '0' . dechex($color_tmp[$i]);
318
+ } else {
319
+ $color .= dechex($color_tmp[$i]);
320
+ }
321
+ }
322
+ }
323
+
324
+ // Fix bad color names
325
+ if(isset($replace_colors[strtolower($color)]))
326
+ {
327
+ $color = $replace_colors[strtolower($color)];
328
+ }
329
+
330
+ // #aabbcc -> #abc
331
+ if(strlen($color) == 7)
332
+ {
333
+ $color_temp = strtolower($color);
334
+ if($color_temp{0} == '#' && $color_temp{1} == $color_temp{2} && $color_temp{3} == $color_temp{4} && $color_temp{5} == $color_temp{6})
335
+ {
336
+ $color = '#'.$color{1}.$color{3}.$color{5};
337
+ }
338
+ }
339
+
340
+ switch(strtolower($color))
341
+ {
342
+ /* color name -> hex code */
343
+ case 'black': return '#000';
344
+ case 'fuchsia': return '#F0F';
345
+ case 'white': return '#FFF';
346
+ case 'yellow': return '#FF0';
347
+
348
+ /* hex code -> color name */
349
+ case '#800000': return 'maroon';
350
+ case '#ffa500': return 'orange';
351
+ case '#808000': return 'olive';
352
+ case '#800080': return 'purple';
353
+ case '#008000': return 'green';
354
+ case '#000080': return 'navy';
355
+ case '#008080': return 'teal';
356
+ case '#c0c0c0': return 'silver';
357
+ case '#808080': return 'gray';
358
+ case '#f00': return 'red';
359
+ }
360
+
361
+ return $color;
362
+ }
363
+
364
+ /**
365
+ * Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
366
+ * @param string $subvalue
367
+ * @return string
368
+ * @version 1.2
369
+ */
370
+ function compress_numbers($subvalue)
371
+ {
372
+ $units =& $GLOBALS['csstidy']['units'];
373
+ $unit_values =& $GLOBALS['csstidy']['unit_values'];
374
+ $color_values =& $GLOBALS['csstidy']['color_values'];
375
+
376
+ // for font:1em/1em sans-serif...;
377
+ if($this->property == 'font')
378
+ {
379
+ $temp = explode('/',$subvalue);
380
+ }
381
+ else
382
+ {
383
+ $temp = array($subvalue);
384
+ }
385
+ for ($l = 0; $l < count($temp); $l++)
386
+ {
387
+ // continue if no numeric value
388
+ if (!(strlen($temp[$l]) > 0 && ( is_numeric($temp[$l]{0}) || $temp[$l]{0} == '+' || $temp[$l]{0} == '-' ) ))
389
+ {
390
+ continue;
391
+ }
392
+
393
+ // Fix bad colors
394
+ if (in_array($this->property, $color_values))
395
+ {
396
+ $temp[$l] = '#'.$temp[$l];
397
+ }
398
+
399
+ if (floatval($temp[$l]) == 0)
400
+ {
401
+ $temp[$l] = '0';
402
+ }
403
+ else
404
+ {
405
+ $unit_found = FALSE;
406
+ for ($m = 0, $size_4 = count($units); $m < $size_4; $m++)
407
+ {
408
+ if (strpos(strtolower($temp[$l]),$units[$m]) !== FALSE)
409
+ {
410
+ $temp[$l] = floatval($temp[$l]).$units[$m];
411
+ $unit_found = TRUE;
412
+ break;
413
+ }
414
+ }
415
+ if (!$unit_found && in_array($this->property,$unit_values,TRUE))
416
+ {
417
+ $temp[$l] = floatval($temp[$l]).'px';
418
+ }
419
+ else if (!$unit_found)
420
+ {
421
+ $temp[$l] = floatval($temp[$l]);
422
+ }
423
+ // Remove leading zero
424
+ if (abs(floatval($temp[$l])) < 1) {
425
+ if (floatval($temp[$l]) < 0) {
426
+ $temp[$l] = '-' . substr($temp[$l], 2);
427
+ } else {
428
+ $temp[$l] = substr($temp[$l], 1);
429
+ }
430
+ }
431
+ }
432
+ }
433
+
434
+ return ((count($temp) > 1) ? $temp[0].'/'.$temp[1] : $temp[0]);
435
+ }
436
+
437
+ /**
438
+ * Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red}
439
+ * Very basic and has at least one bug. Hopefully there is a replacement soon.
440
+ * @param array $array
441
+ * @return array
442
+ * @access public
443
+ * @version 1.2
444
+ */
445
+ function merge_selectors(&$array)
446
+ {
447
+ $css = $array;
448
+ foreach($css as $key => $value)
449
+ {
450
+ if(!isset($css[$key]))
451
+ {
452
+ continue;
453
+ }
454
+ $newsel = '';
455
+
456
+ // Check if properties also exist in another selector
457
+ $keys = array();
458
+ // PHP bug (?) without $css = $array; here
459
+ foreach($css as $selector => $vali)
460
+ {
461
+ if($selector == $key)
462
+ {
463
+ continue;
464
+ }
465
+
466
+ if($css[$key] === $vali)
467
+ {
468
+ $keys[] = $selector;
469
+ }
470
+ }
471
+
472
+ if(!empty($keys))
473
+ {
474
+ $newsel = $key;
475
+ unset($css[$key]);
476
+ foreach($keys as $selector)
477
+ {
478
+ unset($css[$selector]);
479
+ $newsel .= ','.$selector;
480
+ }
481
+ $css[$newsel] = $value;
482
+ }
483
+ }
484
+ $array = $css;
485
+ }
486
+
487
+ /**
488
+ * Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;...
489
+ * @param string $property
490
+ * @param string $value
491
+ * @return array
492
+ * @version 1.0
493
+ * @see merge_4value_shorthands()
494
+ */
495
+ function dissolve_4value_shorthands($property,$value)
496
+ {
497
+ $shorthands =& $GLOBALS['csstidy']['shorthands'];
498
+ if(!is_array($shorthands[$property]))
499
+ {
500
+ $return[$property] = $value;
501
+ return $return;
502
+ }
503
+
504
+ $important = '';
505
+ if(csstidy::is_important($value))
506
+ {
507
+ $value = csstidy::gvw_important($value);
508
+ $important = '!important';
509
+ }
510
+ $values = explode(' ',$value);
511
+
512
+
513
+ $return = array();
514
+ if(count($values) == 4)
515
+ {
516
+ for($i=0;$i<4;$i++)
517
+ {
518
+ $return[$shorthands[$property][$i]] = $values[$i].$important;
519
+ }
520
+ }
521
+ elseif(count($values) == 3)
522
+ {
523
+ $return[$shorthands[$property][0]] = $values[0].$important;
524
+ $return[$shorthands[$property][1]] = $values[1].$important;
525
+ $return[$shorthands[$property][3]] = $values[1].$important;
526
+ $return[$shorthands[$property][2]] = $values[2].$important;
527
+ }
528
+ elseif(count($values) == 2)
529
+ {
530
+ for($i=0;$i<4;$i++)
531
+ {
532
+ $return[$shorthands[$property][$i]] = (($i % 2 != 0)) ? $values[1].$important : $values[0].$important;
533
+ }
534
+ }
535
+ else
536
+ {
537
+ for($i=0;$i<4;$i++)
538
+ {
539
+ $return[$shorthands[$property][$i]] = $values[0].$important;
540
+ }
541
+ }
542
+
543
+ return $return;
544
+ }
545
+
546
+ /**
547
+ * Explodes a string as explode() does, however, not if $sep is escaped or within a string.
548
+ * @param string $sep seperator
549
+ * @param string $string
550
+ * @return array
551
+ * @version 1.0
552
+ */
553
+ function explode_ws($sep,$string)
554
+ {
555
+ $status = 'st';
556
+ $to = '';
557
+
558
+ $output = array();
559
+ $num = 0;
560
+ for($i = 0, $len = strlen($string);$i < $len; $i++)
561
+ {
562
+ switch($status)
563
+ {
564
+ case 'st':
565
+ if($string{$i} == $sep && !csstidy::escaped($string,$i))
566
+ {
567
+ ++$num;
568
+ }
569
+ elseif($string{$i} == '"' || $string{$i} == '\'' || $string{$i} == '(' && !csstidy::escaped($string,$i))
570
+ {
571
+ $status = 'str';
572
+ $to = ($string{$i} == '(') ? ')' : $string{$i};
573
+ (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i};
574
+ }
575
+ else
576
+ {
577
+ (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i};
578
+ }
579
+ break;
580
+
581
+ case 'str':
582
+ if($string{$i} == $to && !csstidy::escaped($string,$i))
583
+ {
584
+ $status = 'st';
585
+ }
586
+ (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i};
587
+ break;
588
+ }
589
+ }
590
+
591
+ if(isset($output[0]))
592
+ {
593
+ return $output;
594
+ }
595
+ else
596
+ {
597
+ return array($output);
598
+ }
599
+ }
600
+
601
+ /**
602
+ * Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
603
+ * @param array $array
604
+ * @return array
605
+ * @version 1.2
606
+ * @see dissolve_4value_shorthands()
607
+ */
608
+ function merge_4value_shorthands($array)
609
+ {
610
+ $return = $array;
611
+ $shorthands =& $GLOBALS['csstidy']['shorthands'];
612
+
613
+ foreach($shorthands as $key => $value)
614
+ {
615
+ if(isset($array[$value[0]]) && isset($array[$value[1]])
616
+ && isset($array[$value[2]]) && isset($array[$value[3]]) && $value !== 0)
617
+ {
618
+ $return[$key] = '';
619
+
620
+ $important = '';
621
+ for($i = 0; $i < 4; $i++)
622
+ {
623
+ $val = $array[$value[$i]];
624
+ if(csstidy::is_important($val))
625
+ {
626
+ $important = '!important';
627
+ $return[$key] .= csstidy::gvw_important($val).' ';
628
+ }
629
+ else
630
+ {
631
+ $return[$key] .= $val.' ';
632
+ }
633
+ unset($return[$value[$i]]);
634
+ }
635
+ $return[$key] = csstidy_optimise::shorthand(trim($return[$key].$important));
636
+ }
637
+ }
638
+ return $return;
639
+ }
640
+
641
+ /**
642
+ * Dissolve background property
643
+ * @param string $str_value
644
+ * @return array
645
+ * @version 1.0
646
+ * @see merge_bg()
647
+ * @todo full CSS 3 compliance
648
+ */
649
+ function dissolve_short_bg($str_value)
650
+ {
651
+ $background_prop_default =& $GLOBALS['csstidy']['background_prop_default'];
652
+ $repeat = array('repeat','repeat-x','repeat-y','no-repeat','space');
653
+ $attachment = array('scroll','fixed','local');
654
+ $clip = array('border','padding');
655
+ $origin = array('border','padding','content');
656
+ $pos = array('top','center','bottom','left','right');
657
+ $important = '';
658
+ $return = array('background-image' => NULL,'background-size' => NULL,'background-repeat' => NULL,'background-position' => NULL,'background-attachment'=>NULL,'background-clip' => NULL,'background-origin' => NULL,'background-color' => NULL);
659
+
660
+ if(csstidy::is_important($str_value))
661
+ {
662
+ $important = ' !important';
663
+ $str_value = csstidy::gvw_important($str_value);
664
+ }
665
+
666
+ $str_value = csstidy_optimise::explode_ws(',',$str_value);
667
+ for($i = 0; $i < count($str_value); $i++)
668
+ {
669
+ $have['clip'] = FALSE; $have['pos'] = FALSE;
670
+ $have['color'] = FALSE; $have['bg'] = FALSE;
671
+
672
+ $str_value[$i] = csstidy_optimise::explode_ws(' ',trim($str_value[$i]));
673
+
674
+ for($j = 0; $j < count($str_value[$i]); $j++)
675
+ {
676
+ if($have['bg'] === FALSE && (substr($str_value[$i][$j],0,4) == 'url(' || $str_value[$i][$j] === 'none'))
677
+ {
678
+ $return['background-image'] .= $str_value[$i][$j].',';
679
+ $have['bg'] = TRUE;
680
+ }
681
+ elseif(in_array($str_value[$i][$j],$repeat,TRUE))
682
+ {
683
+ $return['background-repeat'] .= $str_value[$i][$j].',';
684
+ }
685
+ elseif(in_array($str_value[$i][$j],$attachment,TRUE))
686
+ {
687
+ $return['background-attachment'] .= $str_value[$i][$j].',';
688
+ }
689
+ elseif(in_array($str_value[$i][$j],$clip,TRUE) && !$have['clip'])
690
+ {
691
+ $return['background-clip'] .= $str_value[$i][$j].',';
692
+ $have['clip'] = TRUE;
693
+ }
694
+ elseif(in_array($str_value[$i][$j],$origin,TRUE))
695
+ {
696
+ $return['background-origin'] .= $str_value[$i][$j].',';
697
+ }
698
+ elseif($str_value[$i][$j]{0} == '(')
699
+ {
700
+ $return['background-size'] .= substr($str_value[$i][$j],1,-1).',';
701
+ }
702
+ elseif(in_array($str_value[$i][$j],$pos,TRUE) || is_numeric($str_value[$i][$j]{0}) || $str_value[$i][$j]{0} === NULL)
703
+ {
704
+ $return['background-position'] .= $str_value[$i][$j];
705
+ if(!$have['pos']) $return['background-position'] .= ' '; else $return['background-position'].= ',';
706
+ $have['pos'] = TRUE;
707
+ }
708
+ elseif(!$have['color'])
709
+ {
710
+ $return['background-color'] .= $str_value[$i][$j].',';
711
+ $have['color'] = TRUE;
712
+ }
713
+ }
714
+ }
715
+
716
+ foreach($background_prop_default as $bg_prop => $default_value)
717
+ {
718
+ if($return[$bg_prop] !== NULL)
719
+ {
720
+ $return[$bg_prop] = substr($return[$bg_prop],0,-1).$important;
721
+ }
722
+ else $return[$bg_prop] = $default_value.$important;
723
+ }
724
+ return $return;
725
+ }
726
+
727
+ /**
728
+ * Merges all background properties
729
+ * @param array $input_css
730
+ * @return array
731
+ * @version 1.0
732
+ * @see dissolve_short_bg()
733
+ * @todo full CSS 3 compliance
734
+ */
735
+ function merge_bg($input_css)
736
+ {
737
+ $background_prop_default =& $GLOBALS['csstidy']['background_prop_default'];
738
+ // Max number of background images. CSS3 not yet fully implemented
739
+ $number_of_values = @max(count(csstidy_optimise::explode_ws(',',$input_css['background-image'])),count(csstidy_optimise::explode_ws(',',$input_css['background-color'])),1);
740
+ // Array with background images to check if BG image exists
741
+ $bg_img_array = @csstidy_optimise::explode_ws(',',csstidy::gvw_important($input_css['background-image']));
742
+ $new_bg_value = '';
743
+ $important = '';
744
+
745
+ for($i = 0; $i < $number_of_values; $i++)
746
+ {
747
+ foreach($background_prop_default as $bg_property => $default_value)
748
+ {
749
+ // Skip if property does not exist
750
+ if(!isset($input_css[$bg_property]))
751
+ {
752
+ continue;
753
+ }
754
+
755
+ $cur_value = $input_css[$bg_property];
756
+
757
+ // Skip some properties if there is no background image
758
+ if((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none')
759
+ && ($bg_property === 'background-size' || $bg_property === 'background-position'
760
+ || $bg_property === 'background-attachment' || $bg_property === 'background-repeat'))
761
+ {
762
+ continue;
763
+ }
764
+
765
+ // Remove !important
766
+ if(csstidy::is_important($cur_value))
767
+ {
768
+ $important = ' !important';
769
+ $cur_value = csstidy::gvw_important($cur_value);
770
+ }
771
+
772
+ // Do not add default values
773
+ if($cur_value === $default_value)
774
+ {
775
+ continue;
776
+ }
777
+
778
+ $temp = csstidy_optimise::explode_ws(',',$cur_value);
779
+
780
+ if(isset($temp[$i]))
781
+ {
782
+ if($bg_property == 'background-size')
783
+ {
784
+ $new_bg_value .= '('.$temp[$i].') ';
785
+ }
786
+ else
787
+ {
788
+ $new_bg_value .= $temp[$i].' ';
789
+ }
790
+ }
791
+ }
792
+
793
+ $new_bg_value = trim($new_bg_value);
794
+ if($i != $number_of_values-1) $new_bg_value .= ',';
795
+ }
796
+
797
+ // Delete all background-properties
798
+ foreach($background_prop_default as $bg_property => $default_value)
799
+ {
800
+ unset($input_css[$bg_property]);
801
+ }
802
+
803
+ // Add new background property
804
+ if($new_bg_value !== '') $input_css['background'] = $new_bg_value.$important;
805
+
806
+ return $input_css;
807
+ }
808
+ }
809
+ ?>
includes/csstidy-1.3/class.csstidy_print.php ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CSSTidy - CSS Parser and Optimiser
4
+ *
5
+ * CSS Printing class
6
+ * This class prints CSS data generated by csstidy.
7
+ *
8
+ * This file is part of CSSTidy.
9
+ *
10
+ * CSSTidy is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * CSSTidy is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with CSSTidy; if not, write to the Free Software
22
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
+ *
24
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
25
+ * @package csstidy
26
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
27
+ */
28
+
29
+ /**
30
+ * CSS Printing class
31
+ *
32
+ * This class prints CSS data generated by csstidy.
33
+ *
34
+ * @package csstidy
35
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
36
+ * @version 1.0
37
+ */
38
+
39
+ class csstidy_print
40
+ {
41
+ /**
42
+ * Saves the input CSS string
43
+ * @var string
44
+ * @access private
45
+ */
46
+ var $input_css = '';
47
+
48
+ /**
49
+ * Saves the formatted CSS string
50
+ * @var string
51
+ * @access public
52
+ */
53
+ var $output_css = '';
54
+
55
+ /**
56
+ * Saves the formatted CSS string (plain text)
57
+ * @var string
58
+ * @access public
59
+ */
60
+ var $output_css_plain = '';
61
+
62
+ /**
63
+ * Constructor
64
+ * @param array $css contains the class csstidy
65
+ * @access private
66
+ * @version 1.0
67
+ */
68
+ function csstidy_print(&$css)
69
+ {
70
+ $this->parser =& $css;
71
+ $this->css =& $css->css;
72
+ $this->template =& $css->template;
73
+ $this->tokens =& $css->tokens;
74
+ $this->charset =& $css->charset;
75
+ $this->import =& $css->import;
76
+ $this->namespace =& $css->namespace;
77
+ }
78
+
79
+ /**
80
+ * Resets output_css and output_css_plain (new css code)
81
+ * @access private
82
+ * @version 1.0
83
+ */
84
+ function _reset()
85
+ {
86
+ $this->output_css = '';
87
+ $this->output_css_plain = '';
88
+ }
89
+
90
+ /**
91
+ * Returns the CSS code as plain text
92
+ * @return string
93
+ * @access public
94
+ * @version 1.0
95
+ */
96
+ function plain()
97
+ {
98
+ $this->_print(true);
99
+ return $this->output_css_plain;
100
+ }
101
+
102
+ /**
103
+ * Returns the formatted CSS code
104
+ * @return string
105
+ * @access public
106
+ * @version 1.0
107
+ */
108
+ function formatted()
109
+ {
110
+ $this->_print(false);
111
+ return $this->output_css;
112
+ }
113
+
114
+ /**
115
+ * Returns the formatted CSS Code and saves it into $this->output_css and $this->output_css_plain
116
+ * @param bool $plain plain text or not
117
+ * @access private
118
+ * @version 2.0
119
+ */
120
+ function _print($plain = false)
121
+ {
122
+ if ($this->output_css && $this->output_css_plain) {
123
+ return;
124
+ }
125
+
126
+ $output = '';
127
+ if (!$this->parser->get_cfg('preserve_css')) {
128
+ $this->_convert_raw_css();
129
+ }
130
+
131
+ $template =& $this->template;
132
+
133
+ if ($plain) {
134
+ $template = array_map('strip_tags', $template);
135
+ }
136
+
137
+ if ($this->parser->get_cfg('timestamp')) {
138
+ array_unshift($this->tokens, array(COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . date('r') . ' '));
139
+ }
140
+
141
+ if (!empty($this->charset)) {
142
+ $output .= $template[0].'@charset '.$template[5].$this->charset.$template[6];
143
+ }
144
+
145
+ if (!empty($this->import)) {
146
+ for ($i = 0, $size = count($this->import); $i < $size; $i ++) {
147
+ $output .= $template[0].'@import '.$template[5].$this->import[$i].$template[6];
148
+ }
149
+ }
150
+
151
+ if (!empty($this->namespace)) {
152
+ $output .= $template[0].'@namespace '.$template[5].$this->namespace.$template[6];
153
+ }
154
+
155
+ $output .= $template[13];
156
+ $in_at_out = '';
157
+ $out =& $output;
158
+
159
+ foreach ($this->tokens as $key => $token)
160
+ {
161
+ switch ($token[0])
162
+ {
163
+ case AT_START:
164
+ $out .= $template[0].$this->_htmlsp($token[1], $plain).$template[1];
165
+ $out =& $in_at_out;
166
+ break;
167
+
168
+ case SEL_START:
169
+ if($this->parser->get_cfg('lowercase_s')) $token[1] = strtolower($token[1]);
170
+ $out .= ($token[1]{0} !== '@') ? $template[2].$this->_htmlsp($token[1], $plain) : $template[0].$this->_htmlsp($token[1], $plain);
171
+ $out .= $template[3];
172
+ break;
173
+
174
+ case PROPERTY:
175
+ if($this->parser->get_cfg('case_properties') == 2) $token[1] = strtoupper($token[1]);
176
+ if($this->parser->get_cfg('case_properties') == 1) $token[1] = strtolower($token[1]);
177
+ $out .= $template[4] . $this->_htmlsp($token[1], $plain) . ':' . $template[5];
178
+ break;
179
+
180
+ case VALUE:
181
+ $out .= $this->_htmlsp($token[1], $plain);
182
+ if($this->_seeknocomment($key, 1) == SEL_END && $this->parser->get_cfg('remove_last_;')) {
183
+ $out .= str_replace(';', '', $template[6]);
184
+ } else {
185
+ $out .= $template[6];
186
+ }
187
+ break;
188
+
189
+ case SEL_END:
190
+ $out .= $template[7];
191
+ if($this->_seeknocomment($key, 1) != AT_END) $out .= $template[8];
192
+ break;
193
+
194
+ case AT_END:
195
+ $out =& $output;
196
+ $out .= $template[10] . str_replace("\n", "\n" . $template[10], $in_at_out);
197
+ $in_at_out = '';
198
+ $out .= $template[9];
199
+ break;
200
+
201
+ case COMMENT:
202
+ $out .= $template[11] . '/*' . $this->_htmlsp($token[1], $plain) . '*/' . $template[12];
203
+ break;
204
+ }
205
+ }
206
+
207
+ $output = trim($output);
208
+
209
+ if (!$plain) {
210
+ $this->output_css = $output;
211
+ $this->_print(true);
212
+ } else {
213
+ $this->output_css_plain = $output;
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Gets the next token type which is $move away from $key, excluding comments
219
+ * @param integer $key current position
220
+ * @param integer $move move this far
221
+ * @return mixed a token type
222
+ * @access private
223
+ * @version 1.0
224
+ */
225
+ function _seeknocomment($key, $move) {
226
+ $go = ($move > 0) ? 1 : -1;
227
+ for ($i = $key + 1; abs($key-$i)-1 < abs($move); $i += $go) {
228
+ if (!isset($this->tokens[$i])) {
229
+ return;
230
+ }
231
+ if ($this->tokens[$i][0] == COMMENT) {
232
+ $move += 1;
233
+ continue;
234
+ }
235
+ return $this->tokens[$i][0];
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Converts $this->css array to a raw array ($this->tokens)
241
+ * @access private
242
+ * @version 1.0
243
+ */
244
+ function _convert_raw_css()
245
+ {
246
+ $this->tokens = array();
247
+
248
+ foreach ($this->css as $medium => $val)
249
+ {
250
+ if ($this->parser->get_cfg('sort_selectors')) ksort($val);
251
+ if ($medium != DEFAULT_AT) {
252
+ $this->parser->_add_token(AT_START, $medium, true);
253
+ }
254
+
255
+ foreach ($val as $selector => $vali)
256
+ {
257
+ if ($this->parser->get_cfg('sort_properties')) ksort($vali);
258
+ $this->parser->_add_token(SEL_START, $selector, true);
259
+
260
+ foreach ($vali as $property => $valj)
261
+ {
262
+ $this->parser->_add_token(PROPERTY, $property, true);
263
+ $this->parser->_add_token(VALUE, $valj, true);
264
+ }
265
+
266
+ $this->parser->_add_token(SEL_END, $selector, true);
267
+ }
268
+
269
+ if ($medium != DEFAULT_AT) {
270
+ $this->parser->_add_token(AT_END, $medium, true);
271
+ }
272
+ }
273
+ }
274
+
275
+ /**
276
+ * Same as htmlspecialchars, only that chars are not replaced if $plain !== true. This makes print_code() cleaner.
277
+ * @param string $string
278
+ * @param bool $plain
279
+ * @return string
280
+ * @see csstidy_print::_print()
281
+ * @access private
282
+ * @version 1.0
283
+ */
284
+ function _htmlsp($string, $plain)
285
+ {
286
+ if (!$plain) {
287
+ return htmlspecialchars($string);
288
+ }
289
+ return $string;
290
+ }
291
+
292
+ /**
293
+ * Get compression ratio
294
+ * @access public
295
+ * @return float
296
+ * @version 1.2
297
+ */
298
+ function get_ratio()
299
+ {
300
+ if (!$this->output_css_plain) {
301
+ $this->formatted();
302
+ }
303
+ return round((strlen($this->input_css) - strlen($this->output_css_plain)) / strlen($this->input_css), 3) * 100;
304
+ }
305
+
306
+ /**
307
+ * Get difference between the old and new code in bytes and prints the code if necessary.
308
+ * @access public
309
+ * @return string
310
+ * @version 1.1
311
+ */
312
+ function get_diff()
313
+ {
314
+ if (!$this->output_css_plain) {
315
+ $this->formatted();
316
+ }
317
+
318
+ $diff = strlen($this->output_css_plain) - strlen($this->input_css);
319
+
320
+ if ($diff > 0) {
321
+ return '+' . $diff;
322
+ } elseif ($diff == 0) {
323
+ return '+-' . $diff;
324
+ }
325
+
326
+ return $diff;
327
+ }
328
+
329
+ /**
330
+ * Get the size of either input or output CSS in KB
331
+ * @param string $loc default is "output"
332
+ * @access public
333
+ * @return integer
334
+ * @version 1.0
335
+ */
336
+ function size($loc = 'output')
337
+ {
338
+ if ($loc == 'output' && !$this->output_css) {
339
+ $this->formatted();
340
+ }
341
+
342
+ if ($loc == 'input') {
343
+ return (strlen($this->input_css) / 1000);
344
+ } else {
345
+ return (strlen($this->output_css_plain) / 1000);
346
+ }
347
+ }
348
+ }
349
+ ?>
includes/csstidy-1.3/data.inc.php ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Various CSS Data for CSSTidy
4
+ *
5
+ * This file is part of CSSTidy.
6
+ *
7
+ * CSSTidy is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * CSSTidy is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with CSSTidy; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ *
21
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
22
+ * @package csstidy
23
+ * @author Florian Schmitz (floele at gmail dot com) 2005
24
+ */
25
+
26
+ define('AT_START', 1);
27
+ define('AT_END', 2);
28
+ define('SEL_START', 3);
29
+ define('SEL_END', 4);
30
+ define('PROPERTY', 5);
31
+ define('VALUE', 6);
32
+ define('COMMENT', 7);
33
+ define('DEFAULT_AT', 41);
34
+
35
+ /**
36
+ * All whitespace allowed in CSS
37
+ *
38
+ * @global array $GLOBALS['csstidy']['whitespace']
39
+ * @version 1.0
40
+ */
41
+ $GLOBALS['csstidy']['whitespace'] = array(' ',"\n","\t","\r","\x0B");
42
+
43
+ /**
44
+ * All CSS tokens used by csstidy
45
+ *
46
+ * @global string $GLOBALS['csstidy']['tokens']
47
+ * @version 1.0
48
+ */
49
+ $GLOBALS['csstidy']['tokens'] = '/@}{;:=\'"(,\\!$%&)*+.<>?[]^`|~';
50
+
51
+ /**
52
+ * All CSS units (CSS 3 units included)
53
+ *
54
+ * @see compress_numbers()
55
+ * @global array $GLOBALS['csstidy']['units']
56
+ * @version 1.0
57
+ */
58
+ $GLOBALS['csstidy']['units'] = array('in','cm','mm','pt','pc','px','rem','em','%','ex','gd','vw','vh','vm','deg','grad','rad','ms','s','khz','hz');
59
+
60
+ /**
61
+ * Available at-rules
62
+ *
63
+ * @global array $GLOBALS['csstidy']['at_rules']
64
+ * @version 1.0
65
+ */
66
+ $GLOBALS['csstidy']['at_rules'] = array('page' => 'is','font-face' => 'is','charset' => 'iv', 'import' => 'iv','namespace' => 'iv','media' => 'at');
67
+
68
+ /**
69
+ * Properties that need a value with unit
70
+ *
71
+ * @todo CSS3 properties
72
+ * @see compress_numbers();
73
+ * @global array $GLOBALS['csstidy']['unit_values']
74
+ * @version 1.2
75
+ */
76
+ $GLOBALS['csstidy']['unit_values'] = array ('background', 'background-position', 'border', 'border-top', 'border-right', 'border-bottom', 'border-left', 'border-width',
77
+ 'border-top-width', 'border-right-width', 'border-left-width', 'border-bottom-width', 'bottom', 'border-spacing', 'font-size',
78
+ 'height', 'left', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'max-height', 'max-width',
79
+ 'min-height', 'min-width', 'outline-width', 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
80
+ 'position', 'right', 'top', 'text-indent', 'letter-spacing', 'word-spacing', 'width');
81
+
82
+ /**
83
+ * Properties that allow <color> as value
84
+ *
85
+ * @todo CSS3 properties
86
+ * @see compress_numbers();
87
+ * @global array $GLOBALS['csstidy']['color_values']
88
+ * @version 1.0
89
+ */
90
+ $GLOBALS['csstidy']['color_values'] = array();
91
+ $GLOBALS['csstidy']['color_values'][] = 'background-color';
92
+ $GLOBALS['csstidy']['color_values'][] = 'border-color';
93
+ $GLOBALS['csstidy']['color_values'][] = 'border-top-color';
94
+ $GLOBALS['csstidy']['color_values'][] = 'border-right-color';
95
+ $GLOBALS['csstidy']['color_values'][] = 'border-bottom-color';
96
+ $GLOBALS['csstidy']['color_values'][] = 'border-left-color';
97
+ $GLOBALS['csstidy']['color_values'][] = 'color';
98
+ $GLOBALS['csstidy']['color_values'][] = 'outline-color';
99
+
100
+
101
+ /**
102
+ * Default values for the background properties
103
+ *
104
+ * @todo Possibly property names will change during CSS3 development
105
+ * @global array $GLOBALS['csstidy']['background_prop_default']
106
+ * @see dissolve_short_bg()
107
+ * @see merge_bg()
108
+ * @version 1.0
109
+ */
110
+ $GLOBALS['csstidy']['background_prop_default'] = array();
111
+ $GLOBALS['csstidy']['background_prop_default']['background-image'] = 'none';
112
+ $GLOBALS['csstidy']['background_prop_default']['background-size'] = 'auto';
113
+ $GLOBALS['csstidy']['background_prop_default']['background-repeat'] = 'repeat';
114
+ $GLOBALS['csstidy']['background_prop_default']['background-position'] = '0 0';
115
+ $GLOBALS['csstidy']['background_prop_default']['background-attachment'] = 'scroll';
116
+ $GLOBALS['csstidy']['background_prop_default']['background-clip'] = 'border';
117
+ $GLOBALS['csstidy']['background_prop_default']['background-origin'] = 'padding';
118
+ $GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparent';
119
+
120
+ /**
121
+ * A list of non-W3C color names which get replaced by their hex-codes
122
+ *
123
+ * @global array $GLOBALS['csstidy']['replace_colors']
124
+ * @see cut_color()
125
+ * @version 1.0
126
+ */
127
+ $GLOBALS['csstidy']['replace_colors'] = array();
128
+ $GLOBALS['csstidy']['replace_colors']['aliceblue'] = '#F0F8FF';
129
+ $GLOBALS['csstidy']['replace_colors']['antiquewhite'] = '#FAEBD7';
130
+ $GLOBALS['csstidy']['replace_colors']['aquamarine'] = '#7FFFD4';
131
+ $GLOBALS['csstidy']['replace_colors']['azure'] = '#F0FFFF';
132
+ $GLOBALS['csstidy']['replace_colors']['beige'] = '#F5F5DC';
133
+ $GLOBALS['csstidy']['replace_colors']['bisque'] = '#FFE4C4';
134
+ $GLOBALS['csstidy']['replace_colors']['blanchedalmond'] = '#FFEBCD';
135
+ $GLOBALS['csstidy']['replace_colors']['blueviolet'] = '#8A2BE2';
136
+ $GLOBALS['csstidy']['replace_colors']['brown'] = '#A52A2A';
137
+ $GLOBALS['csstidy']['replace_colors']['burlywood'] = '#DEB887';
138
+ $GLOBALS['csstidy']['replace_colors']['cadetblue'] = '#5F9EA0';
139
+ $GLOBALS['csstidy']['replace_colors']['chartreuse'] = '#7FFF00';
140
+ $GLOBALS['csstidy']['replace_colors']['chocolate'] = '#D2691E';
141
+ $GLOBALS['csstidy']['replace_colors']['coral'] = '#FF7F50';
142
+ $GLOBALS['csstidy']['replace_colors']['cornflowerblue'] = '#6495ED';
143
+ $GLOBALS['csstidy']['replace_colors']['cornsilk'] = '#FFF8DC';
144
+ $GLOBALS['csstidy']['replace_colors']['crimson'] = '#DC143C';
145
+ $GLOBALS['csstidy']['replace_colors']['cyan'] = '#00FFFF';
146
+ $GLOBALS['csstidy']['replace_colors']['darkblue'] = '#00008B';
147
+ $GLOBALS['csstidy']['replace_colors']['darkcyan'] = '#008B8B';
148
+ $GLOBALS['csstidy']['replace_colors']['darkgoldenrod'] = '#B8860B';
149
+ $GLOBALS['csstidy']['replace_colors']['darkgray'] = '#A9A9A9';
150
+ $GLOBALS['csstidy']['replace_colors']['darkgreen'] = '#006400';
151
+ $GLOBALS['csstidy']['replace_colors']['darkkhaki'] = '#BDB76B';
152
+ $GLOBALS['csstidy']['replace_colors']['darkmagenta'] = '#8B008B';
153
+ $GLOBALS['csstidy']['replace_colors']['darkolivegreen'] = '#556B2F';
154
+ $GLOBALS['csstidy']['replace_colors']['darkorange'] = '#FF8C00';
155
+ $GLOBALS['csstidy']['replace_colors']['darkorchid'] = '#9932CC';
156
+ $GLOBALS['csstidy']['replace_colors']['darkred'] = '#8B0000';
157
+ $GLOBALS['csstidy']['replace_colors']['darksalmon'] = '#E9967A';
158
+ $GLOBALS['csstidy']['replace_colors']['darkseagreen'] = '#8FBC8F';
159
+ $GLOBALS['csstidy']['replace_colors']['darkslateblue'] = '#483D8B';
160
+ $GLOBALS['csstidy']['replace_colors']['darkslategray'] = '#2F4F4F';
161
+ $GLOBALS['csstidy']['replace_colors']['darkturquoise'] = '#00CED1';
162
+ $GLOBALS['csstidy']['replace_colors']['darkviolet'] = '#9400D3';
163
+ $GLOBALS['csstidy']['replace_colors']['deeppink'] = '#FF1493';
164
+ $GLOBALS['csstidy']['replace_colors']['deepskyblue'] = '#00BFFF';
165
+ $GLOBALS['csstidy']['replace_colors']['dimgray'] = '#696969';
166
+ $GLOBALS['csstidy']['replace_colors']['dodgerblue'] = '#1E90FF';
167
+ $GLOBALS['csstidy']['replace_colors']['feldspar'] = '#D19275';
168
+ $GLOBALS['csstidy']['replace_colors']['firebrick'] = '#B22222';
169
+ $GLOBALS['csstidy']['replace_colors']['floralwhite'] = '#FFFAF0';
170
+ $GLOBALS['csstidy']['replace_colors']['forestgreen'] = '#228B22';
171
+ $GLOBALS['csstidy']['replace_colors']['gainsboro'] = '#DCDCDC';
172
+ $GLOBALS['csstidy']['replace_colors']['ghostwhite'] = '#F8F8FF';
173
+ $GLOBALS['csstidy']['replace_colors']['gold'] = '#FFD700';
174
+ $GLOBALS['csstidy']['replace_colors']['goldenrod'] = '#DAA520';
175
+ $GLOBALS['csstidy']['replace_colors']['greenyellow'] = '#ADFF2F';
176
+ $GLOBALS['csstidy']['replace_colors']['honeydew'] = '#F0FFF0';
177
+ $GLOBALS['csstidy']['replace_colors']['hotpink'] = '#FF69B4';
178
+ $GLOBALS['csstidy']['replace_colors']['indianred'] = '#CD5C5C';
179
+ $GLOBALS['csstidy']['replace_colors']['indigo'] = '#4B0082';
180
+ $GLOBALS['csstidy']['replace_colors']['ivory'] = '#FFFFF0';
181
+ $GLOBALS['csstidy']['replace_colors']['khaki'] = '#F0E68C';
182
+ $GLOBALS['csstidy']['replace_colors']['lavender'] = '#E6E6FA';
183
+ $GLOBALS['csstidy']['replace_colors']['lavenderblush'] = '#FFF0F5';
184
+ $GLOBALS['csstidy']['replace_colors']['lawngreen'] = '#7CFC00';
185
+ $GLOBALS['csstidy']['replace_colors']['lemonchiffon'] = '#FFFACD';
186
+ $GLOBALS['csstidy']['replace_colors']['lightblue'] = '#ADD8E6';
187
+ $GLOBALS['csstidy']['replace_colors']['lightcoral'] = '#F08080';
188
+ $GLOBALS['csstidy']['replace_colors']['lightcyan'] = '#E0FFFF';
189
+ $GLOBALS['csstidy']['replace_colors']['lightgoldenrodyellow'] = '#FAFAD2';
190
+ $GLOBALS['csstidy']['replace_colors']['lightgrey'] = '#D3D3D3';
191
+ $GLOBALS['csstidy']['replace_colors']['lightgreen'] = '#90EE90';
192
+ $GLOBALS['csstidy']['replace_colors']['lightpink'] = '#FFB6C1';
193
+ $GLOBALS['csstidy']['replace_colors']['lightsalmon'] = '#FFA07A';
194
+ $GLOBALS['csstidy']['replace_colors']['lightseagreen'] = '#20B2AA';
195
+ $GLOBALS['csstidy']['replace_colors']['lightskyblue'] = '#87CEFA';
196
+ $GLOBALS['csstidy']['replace_colors']['lightslateblue'] = '#8470FF';
197
+ $GLOBALS['csstidy']['replace_colors']['lightslategray'] = '#778899';
198
+ $GLOBALS['csstidy']['replace_colors']['lightsteelblue'] = '#B0C4DE';
199
+ $GLOBALS['csstidy']['replace_colors']['lightyellow'] = '#FFFFE0';
200
+ $GLOBALS['csstidy']['replace_colors']['limegreen'] = '#32CD32';
201
+ $GLOBALS['csstidy']['replace_colors']['linen'] = '#FAF0E6';
202
+ $GLOBALS['csstidy']['replace_colors']['magenta'] = '#FF00FF';
203
+ $GLOBALS['csstidy']['replace_colors']['mediumaquamarine'] = '#66CDAA';
204
+ $GLOBALS['csstidy']['replace_colors']['mediumblue'] = '#0000CD';
205
+ $GLOBALS['csstidy']['replace_colors']['mediumorchid'] = '#BA55D3';
206
+ $GLOBALS['csstidy']['replace_colors']['mediumpurple'] = '#9370D8';
207
+ $GLOBALS['csstidy']['replace_colors']['mediumseagreen'] = '#3CB371';
208
+ $GLOBALS['csstidy']['replace_colors']['mediumslateblue'] = '#7B68EE';
209
+ $GLOBALS['csstidy']['replace_colors']['mediumspringgreen'] = '#00FA9A';
210
+ $GLOBALS['csstidy']['replace_colors']['mediumturquoise'] = '#48D1CC';
211
+ $GLOBALS['csstidy']['replace_colors']['mediumvioletred'] = '#C71585';
212
+ $GLOBALS['csstidy']['replace_colors']['midnightblue'] = '#191970';
213
+ $GLOBALS['csstidy']['replace_colors']['mintcream'] = '#F5FFFA';
214
+ $GLOBALS['csstidy']['replace_colors']['mistyrose'] = '#FFE4E1';
215
+ $GLOBALS['csstidy']['replace_colors']['moccasin'] = '#FFE4B5';
216
+ $GLOBALS['csstidy']['replace_colors']['navajowhite'] = '#FFDEAD';
217
+ $GLOBALS['csstidy']['replace_colors']['oldlace'] = '#FDF5E6';
218
+ $GLOBALS['csstidy']['replace_colors']['olivedrab'] = '#6B8E23';
219
+ $GLOBALS['csstidy']['replace_colors']['orangered'] = '#FF4500';
220
+ $GLOBALS['csstidy']['replace_colors']['orchid'] = '#DA70D6';
221
+ $GLOBALS['csstidy']['replace_colors']['palegoldenrod'] = '#EEE8AA';
222
+ $GLOBALS['csstidy']['replace_colors']['palegreen'] = '#98FB98';
223
+ $GLOBALS['csstidy']['replace_colors']['paleturquoise'] = '#AFEEEE';
224
+ $GLOBALS['csstidy']['replace_colors']['palevioletred'] = '#D87093';
225
+ $GLOBALS['csstidy']['replace_colors']['papayawhip'] = '#FFEFD5';
226
+ $GLOBALS['csstidy']['replace_colors']['peachpuff'] = '#FFDAB9';
227
+ $GLOBALS['csstidy']['replace_colors']['peru'] = '#CD853F';
228
+ $GLOBALS['csstidy']['replace_colors']['pink'] = '#FFC0CB';
229
+ $GLOBALS['csstidy']['replace_colors']['plum'] = '#DDA0DD';
230
+ $GLOBALS['csstidy']['replace_colors']['powderblue'] = '#B0E0E6';
231
+ $GLOBALS['csstidy']['replace_colors']['rosybrown'] = '#BC8F8F';
232
+ $GLOBALS['csstidy']['replace_colors']['royalblue'] = '#4169E1';
233
+ $GLOBALS['csstidy']['replace_colors']['saddlebrown'] = '#8B4513';
234
+ $GLOBALS['csstidy']['replace_colors']['salmon'] = '#FA8072';
235
+ $GLOBALS['csstidy']['replace_colors']['sandybrown'] = '#F4A460';
236
+ $GLOBALS['csstidy']['replace_colors']['seagreen'] = '#2E8B57';
237
+ $GLOBALS['csstidy']['replace_colors']['seashell'] = '#FFF5EE';
238
+ $GLOBALS['csstidy']['replace_colors']['sienna'] = '#A0522D';
239
+ $GLOBALS['csstidy']['replace_colors']['skyblue'] = '#87CEEB';
240
+ $GLOBALS['csstidy']['replace_colors']['slateblue'] = '#6A5ACD';
241
+ $GLOBALS['csstidy']['replace_colors']['slategray'] = '#708090';
242
+ $GLOBALS['csstidy']['replace_colors']['snow'] = '#FFFAFA';
243
+ $GLOBALS['csstidy']['replace_colors']['springgreen'] = '#00FF7F';
244
+ $GLOBALS['csstidy']['replace_colors']['steelblue'] = '#4682B4';
245
+ $GLOBALS['csstidy']['replace_colors']['tan'] = '#D2B48C';
246
+ $GLOBALS['csstidy']['replace_colors']['thistle'] = '#D8BFD8';
247
+ $GLOBALS['csstidy']['replace_colors']['tomato'] = '#FF6347';
248
+ $GLOBALS['csstidy']['replace_colors']['turquoise'] = '#40E0D0';
249
+ $GLOBALS['csstidy']['replace_colors']['violet'] = '#EE82EE';
250
+ $GLOBALS['csstidy']['replace_colors']['violetred'] = '#D02090';
251
+ $GLOBALS['csstidy']['replace_colors']['wheat'] = '#F5DEB3';
252
+ $GLOBALS['csstidy']['replace_colors']['whitesmoke'] = '#F5F5F5';
253
+ $GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9ACD32';
254
+
255
+
256
+ /**
257
+ * A list of all shorthand properties that are devided into four properties and/or have four subvalues
258
+ *
259
+ * @global array $GLOBALS['csstidy']['shorthands']
260
+ * @todo Are there new ones in CSS3?
261
+ * @see dissolve_4value_shorthands()
262
+ * @see merge_4value_shorthands()
263
+ * @version 1.0
264
+ */
265
+ $GLOBALS['csstidy']['shorthands'] = array();
266
+ $GLOBALS['csstidy']['shorthands']['border-color'] = array('border-top-color','border-right-color','border-bottom-color','border-left-color');
267
+ $GLOBALS['csstidy']['shorthands']['border-style'] = array('border-top-style','border-right-style','border-bottom-style','border-left-style');
268
+ $GLOBALS['csstidy']['shorthands']['border-width'] = array('border-top-width','border-right-width','border-bottom-width','border-left-width');
269
+ $GLOBALS['csstidy']['shorthands']['margin'] = array('margin-top','margin-right','margin-bottom','margin-left');
270
+ $GLOBALS['csstidy']['shorthands']['padding'] = array('padding-top','padding-right','padding-bottom','padding-left');
271
+ $GLOBALS['csstidy']['shorthands']['-moz-border-radius'] = 0;
272
+
273
+ /**
274
+ * All CSS Properties. Needed for csstidy::property_is_next()
275
+ *
276
+ * @global array $GLOBALS['csstidy']['all_properties']
277
+ * @todo Add CSS3 properties
278
+ * @version 1.0
279
+ * @see csstidy::property_is_next()
280
+ */
281
+ $GLOBALS['csstidy']['all_properties'] = array();
282
+ $GLOBALS['csstidy']['all_properties']['background'] = 'CSS1.0,CSS2.0,CSS2.1';
283
+ $GLOBALS['csstidy']['all_properties']['background-color'] = 'CSS1.0,CSS2.0,CSS2.1';
284
+ $GLOBALS['csstidy']['all_properties']['background-image'] = 'CSS1.0,CSS2.0,CSS2.1';
285
+ $GLOBALS['csstidy']['all_properties']['background-repeat'] = 'CSS1.0,CSS2.0,CSS2.1';
286
+ $GLOBALS['csstidy']['all_properties']['background-attachment'] = 'CSS1.0,CSS2.0,CSS2.1';
287
+ $GLOBALS['csstidy']['all_properties']['background-position'] = 'CSS1.0,CSS2.0,CSS2.1';
288
+ $GLOBALS['csstidy']['all_properties']['border'] = 'CSS1.0,CSS2.0,CSS2.1';
289
+ $GLOBALS['csstidy']['all_properties']['border-top'] = 'CSS1.0,CSS2.0,CSS2.1';
290
+ $GLOBALS['csstidy']['all_properties']['border-right'] = 'CSS1.0,CSS2.0,CSS2.1';
291
+ $GLOBALS['csstidy']['all_properties']['border-bottom'] = 'CSS1.0,CSS2.0,CSS2.1';
292
+ $GLOBALS['csstidy']['all_properties']['border-left'] = 'CSS1.0,CSS2.0,CSS2.1';
293
+ $GLOBALS['csstidy']['all_properties']['border-color'] = 'CSS1.0,CSS2.0,CSS2.1';
294
+ $GLOBALS['csstidy']['all_properties']['border-top-color'] = 'CSS2.0,CSS2.1';
295
+ $GLOBALS['csstidy']['all_properties']['border-bottom-color'] = 'CSS2.0,CSS2.1';
296
+ $GLOBALS['csstidy']['all_properties']['border-left-color'] = 'CSS2.0,CSS2.1';
297
+ $GLOBALS['csstidy']['all_properties']['border-right-color'] = 'CSS2.0,CSS2.1';
298
+ $GLOBALS['csstidy']['all_properties']['border-style'] = 'CSS1.0,CSS2.0,CSS2.1';
299
+ $GLOBALS['csstidy']['all_properties']['border-top-style'] = 'CSS2.0,CSS2.1';
300
+ $GLOBALS['csstidy']['all_properties']['border-right-style'] = 'CSS2.0,CSS2.1';
301
+ $GLOBALS['csstidy']['all_properties']['border-left-style'] = 'CSS2.0,CSS2.1';
302
+ $GLOBALS['csstidy']['all_properties']['border-bottom-style'] = 'CSS2.0,CSS2.1';
303
+ $GLOBALS['csstidy']['all_properties']['border-width'] = 'CSS1.0,CSS2.0,CSS2.1';
304
+ $GLOBALS['csstidy']['all_properties']['border-top-width'] = 'CSS1.0,CSS2.0,CSS2.1';
305
+ $GLOBALS['csstidy']['all_properties']['border-right-width'] = 'CSS1.0,CSS2.0,CSS2.1';
306
+ $GLOBALS['csstidy']['all_properties']['border-left-width'] = 'CSS1.0,CSS2.0,CSS2.1';
307
+ $GLOBALS['csstidy']['all_properties']['border-bottom-width'] = 'CSS1.0,CSS2.0,CSS2.1';
308
+ $GLOBALS['csstidy']['all_properties']['border-collapse'] = 'CSS2.0,CSS2.1';
309
+ $GLOBALS['csstidy']['all_properties']['border-spacing'] = 'CSS2.0,CSS2.1';
310
+ $GLOBALS['csstidy']['all_properties']['bottom'] = 'CSS2.0,CSS2.1';
311
+ $GLOBALS['csstidy']['all_properties']['caption-side'] = 'CSS2.0,CSS2.1';
312
+ $GLOBALS['csstidy']['all_properties']['content'] = 'CSS2.0,CSS2.1';
313
+ $GLOBALS['csstidy']['all_properties']['clear'] = 'CSS1.0,CSS2.0,CSS2.1';
314
+ $GLOBALS['csstidy']['all_properties']['clip'] = 'CSS1.0,CSS2.0,CSS2.1';
315
+ $GLOBALS['csstidy']['all_properties']['color'] = 'CSS1.0,CSS2.0,CSS2.1';
316
+ $GLOBALS['csstidy']['all_properties']['counter-reset'] = 'CSS2.0,CSS2.1';
317
+ $GLOBALS['csstidy']['all_properties']['counter-increment'] = 'CSS2.0,CSS2.1';
318
+ $GLOBALS['csstidy']['all_properties']['cursor'] = 'CSS2.0,CSS2.1';
319
+ $GLOBALS['csstidy']['all_properties']['empty-cells'] = 'CSS2.0,CSS2.1';
320
+ $GLOBALS['csstidy']['all_properties']['display'] = 'CSS1.0,CSS2.0,CSS2.1';
321
+ $GLOBALS['csstidy']['all_properties']['direction'] = 'CSS2.0,CSS2.1';
322
+ $GLOBALS['csstidy']['all_properties']['float'] = 'CSS1.0,CSS2.0,CSS2.1';
323
+ $GLOBALS['csstidy']['all_properties']['font'] = 'CSS1.0,CSS2.0,CSS2.1';
324
+ $GLOBALS['csstidy']['all_properties']['font-family'] = 'CSS1.0,CSS2.0,CSS2.1';
325
+ $GLOBALS['csstidy']['all_properties']['font-style'] = 'CSS1.0,CSS2.0,CSS2.1';
326
+ $GLOBALS['csstidy']['all_properties']['font-variant'] = 'CSS1.0,CSS2.0,CSS2.1';
327
+ $GLOBALS['csstidy']['all_properties']['font-weight'] = 'CSS1.0,CSS2.0,CSS2.1';
328
+ $GLOBALS['csstidy']['all_properties']['font-stretch'] = 'CSS2.0';
329
+ $GLOBALS['csstidy']['all_properties']['font-size-adjust'] = 'CSS2.0';
330
+ $GLOBALS['csstidy']['all_properties']['font-size'] = 'CSS1.0,CSS2.0,CSS2.1';
331
+ $GLOBALS['csstidy']['all_properties']['height'] = 'CSS1.0,CSS2.0,CSS2.1';
332
+ $GLOBALS['csstidy']['all_properties']['left'] = 'CSS1.0,CSS2.0,CSS2.1';
333
+ $GLOBALS['csstidy']['all_properties']['line-height'] = 'CSS1.0,CSS2.0,CSS2.1';
334
+ $GLOBALS['csstidy']['all_properties']['list-style'] = 'CSS1.0,CSS2.0,CSS2.1';
335
+ $GLOBALS['csstidy']['all_properties']['list-style-type'] = 'CSS1.0,CSS2.0,CSS2.1';
336
+ $GLOBALS['csstidy']['all_properties']['list-style-image'] = 'CSS1.0,CSS2.0,CSS2.1';
337
+ $GLOBALS['csstidy']['all_properties']['list-style-position'] = 'CSS1.0,CSS2.0,CSS2.1';
338
+ $GLOBALS['csstidy']['all_properties']['margin'] = 'CSS1.0,CSS2.0,CSS2.1';
339
+ $GLOBALS['csstidy']['all_properties']['margin-top'] = 'CSS1.0,CSS2.0,CSS2.1';
340
+ $GLOBALS['csstidy']['all_properties']['margin-right'] = 'CSS1.0,CSS2.0,CSS2.1';
341
+ $GLOBALS['csstidy']['all_properties']['margin-bottom'] = 'CSS1.0,CSS2.0,CSS2.1';
342
+ $GLOBALS['csstidy']['all_properties']['margin-left'] = 'CSS1.0,CSS2.0,CSS2.1';
343
+ $GLOBALS['csstidy']['all_properties']['marks'] = 'CSS1.0,CSS2.0';
344
+ $GLOBALS['csstidy']['all_properties']['marker-offset'] = 'CSS2.0';
345
+ $GLOBALS['csstidy']['all_properties']['max-height'] = 'CSS2.0,CSS2.1';
346
+ $GLOBALS['csstidy']['all_properties']['max-width'] = 'CSS2.0,CSS2.1';
347
+ $GLOBALS['csstidy']['all_properties']['min-height'] = 'CSS2.0,CSS2.1';
348
+ $GLOBALS['csstidy']['all_properties']['min-width'] = 'CSS2.0,CSS2.1';
349
+ $GLOBALS['csstidy']['all_properties']['overflow'] = 'CSS1.0,CSS2.0,CSS2.1';
350
+ $GLOBALS['csstidy']['all_properties']['orphans'] = 'CSS2.0,CSS2.1';
351
+ $GLOBALS['csstidy']['all_properties']['outline'] = 'CSS2.0,CSS2.1';
352
+ $GLOBALS['csstidy']['all_properties']['outline-width'] = 'CSS2.0,CSS2.1';
353
+ $GLOBALS['csstidy']['all_properties']['outline-style'] = 'CSS2.0,CSS2.1';
354
+ $GLOBALS['csstidy']['all_properties']['outline-color'] = 'CSS2.0,CSS2.1';
355
+ $GLOBALS['csstidy']['all_properties']['padding'] = 'CSS1.0,CSS2.0,CSS2.1';
356
+ $GLOBALS['csstidy']['all_properties']['padding-top'] = 'CSS1.0,CSS2.0,CSS2.1';
357
+ $GLOBALS['csstidy']['all_properties']['padding-right'] = 'CSS1.0,CSS2.0,CSS2.1';
358
+ $GLOBALS['csstidy']['all_properties']['padding-bottom'] = 'CSS1.0,CSS2.0,CSS2.1';
359
+ $GLOBALS['csstidy']['all_properties']['padding-left'] = 'CSS1.0,CSS2.0,CSS2.1';
360
+ $GLOBALS['csstidy']['all_properties']['page-break-before'] = 'CSS1.0,CSS2.0,CSS2.1';
361
+ $GLOBALS['csstidy']['all_properties']['page-break-after'] = 'CSS1.0,CSS2.0,CSS2.1';
362
+ $GLOBALS['csstidy']['all_properties']['page-break-inside'] = 'CSS2.0,CSS2.1';
363
+ $GLOBALS['csstidy']['all_properties']['page'] = 'CSS2.0';
364
+ $GLOBALS['csstidy']['all_properties']['position'] = 'CSS1.0,CSS2.0,CSS2.1';
365
+ $GLOBALS['csstidy']['all_properties']['quotes'] = 'CSS2.0,CSS2.1';
366
+ $GLOBALS['csstidy']['all_properties']['right'] = 'CSS2.0,CSS2.1';
367
+ $GLOBALS['csstidy']['all_properties']['size'] = 'CSS1.0,CSS2.0';
368
+ $GLOBALS['csstidy']['all_properties']['speak-header'] = 'CSS2.0,CSS2.1';
369
+ $GLOBALS['csstidy']['all_properties']['table-layout'] = 'CSS2.0,CSS2.1';
370
+ $GLOBALS['csstidy']['all_properties']['top'] = 'CSS1.0,CSS2.0,CSS2.1';
371
+ $GLOBALS['csstidy']['all_properties']['text-indent'] = 'CSS1.0,CSS2.0,CSS2.1';
372
+ $GLOBALS['csstidy']['all_properties']['text-align'] = 'CSS1.0,CSS2.0,CSS2.1';
373
+ $GLOBALS['csstidy']['all_properties']['text-decoration'] = 'CSS1.0,CSS2.0,CSS2.1';
374
+ $GLOBALS['csstidy']['all_properties']['text-shadow'] = 'CSS2.0';
375
+ $GLOBALS['csstidy']['all_properties']['letter-spacing'] = 'CSS1.0,CSS2.0,CSS2.1';
376
+ $GLOBALS['csstidy']['all_properties']['word-spacing'] = 'CSS1.0,CSS2.0,CSS2.1';
377
+ $GLOBALS['csstidy']['all_properties']['text-transform'] = 'CSS1.0,CSS2.0,CSS2.1';
378
+ $GLOBALS['csstidy']['all_properties']['white-space'] = 'CSS1.0,CSS2.0,CSS2.1';
379
+ $GLOBALS['csstidy']['all_properties']['unicode-bidi'] = 'CSS2.0,CSS2.1';
380
+ $GLOBALS['csstidy']['all_properties']['vertical-align'] = 'CSS1.0,CSS2.0,CSS2.1';
381
+ $GLOBALS['csstidy']['all_properties']['visibility'] = 'CSS1.0,CSS2.0,CSS2.1';
382
+ $GLOBALS['csstidy']['all_properties']['width'] = 'CSS1.0,CSS2.0,CSS2.1';
383
+ $GLOBALS['csstidy']['all_properties']['widows'] = 'CSS2.0,CSS2.1';
384
+ $GLOBALS['csstidy']['all_properties']['z-index'] = 'CSS1.0,CSS2.0,CSS2.1';
385
+ /* Speech */
386
+ $GLOBALS['csstidy']['all_properties']['volume'] = 'CSS2.0,CSS2.1';
387
+ $GLOBALS['csstidy']['all_properties']['speak'] = 'CSS2.0,CSS2.1';
388
+ $GLOBALS['csstidy']['all_properties']['pause'] = 'CSS2.0,CSS2.1';
389
+ $GLOBALS['csstidy']['all_properties']['pause-before'] = 'CSS2.0,CSS2.1';
390
+ $GLOBALS['csstidy']['all_properties']['pause-after'] = 'CSS2.0,CSS2.1';
391
+ $GLOBALS['csstidy']['all_properties']['cue'] = 'CSS2.0,CSS2.1';
392
+ $GLOBALS['csstidy']['all_properties']['cue-before'] = 'CSS2.0,CSS2.1';
393
+ $GLOBALS['csstidy']['all_properties']['cue-after'] = 'CSS2.0,CSS2.1';
394
+ $GLOBALS['csstidy']['all_properties']['play-during'] = 'CSS2.0,CSS2.1';
395
+ $GLOBALS['csstidy']['all_properties']['azimuth'] = 'CSS2.0,CSS2.1';
396
+ $GLOBALS['csstidy']['all_properties']['elevation'] = 'CSS2.0,CSS2.1';
397
+ $GLOBALS['csstidy']['all_properties']['speech-rate'] = 'CSS2.0,CSS2.1';
398
+ $GLOBALS['csstidy']['all_properties']['voice-family'] = 'CSS2.0,CSS2.1';
399
+ $GLOBALS['csstidy']['all_properties']['pitch'] = 'CSS2.0,CSS2.1';
400
+ $GLOBALS['csstidy']['all_properties']['pitch-range'] = 'CSS2.0,CSS2.1';
401
+ $GLOBALS['csstidy']['all_properties']['stress'] = 'CSS2.0,CSS2.1';
402
+ $GLOBALS['csstidy']['all_properties']['richness'] = 'CSS2.0,CSS2.1';
403
+ $GLOBALS['csstidy']['all_properties']['speak-punctuation'] = 'CSS2.0,CSS2.1';
404
+ $GLOBALS['csstidy']['all_properties']['speak-numeral'] = 'CSS2.0,CSS2.1';
405
+
406
+ /**
407
+ * An array containing all predefined templates.
408
+ *
409
+ * @global array $GLOBALS['csstidy']['predefined_templates']
410
+ * @version 1.0
411
+ * @see csstidy::load_template()
412
+ */
413
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="at">'; //string before @rule
414
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>'."\n"; //bracket after @-rule
415
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="selector">'; //string before selector
416
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>'."\n"; //bracket after selector
417
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="property">'; //string before property
418
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="value">'; //string after property+before value
419
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="format">;</span>'."\n"; //string after value
420
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="format">}</span>'; //closing bracket - selector
421
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = "\n\n"; //space between blocks {...}
422
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = "\n".'<span class="format">}</span>'. "\n\n"; //closing bracket @-rule
423
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = ''; //indent in @-rule
424
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="comment">'; // before comment
425
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = '</span>'."\n"; // after comment
426
+ $GLOBALS['csstidy']['predefined_templates']['default'][] = "\n"; // after last line @-rule
427
+
428
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="at">';
429
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span> <span class="format">{</span>'."\n";
430
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="selector">';
431
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="format">{</span>';
432
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="property">';
433
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="value">';
434
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="format">;</span>';
435
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="format">}</span>';
436
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n";
437
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n". '<span class="format">}'."\n".'</span>';
438
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '';
439
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="comment">'; // before comment
440
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span>'; // after comment
441
+ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n";
442
+
443
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="at">';
444
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="format">{</span>';
445
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="selector">';
446
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="format">{</span>';
447
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="property">';
448
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="value">';
449
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="format">;</span>';
450
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="format">}</span>';
451
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
452
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="format">}</span>';
453
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
454
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="comment">'; // before comment
455
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span>'; // after comment
456
+ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
457
+
458
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="at">';
459
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span> <span class="format">{</span>'."\n";
460
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="selector">';
461
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n".'<span class="format">{</span>'."\n";
462
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = ' <span class="property">';
463
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="value">';
464
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="format">;</span>'."\n";
465
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="format">}</span>';
466
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n\n";
467
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n".'<span class="format">}</span>'."\n\n";
468
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = ' ';
469
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="comment">'; // before comment
470
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n"; // after comment
471
+ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n";
472
+
473
+ ?>
includes/csstidy-1.3/lang.inc.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(isset($_GET['lang'])) {
3
+ $l = $_GET['lang'];
4
+ } else {
5
+ $l = getenv('HTTP_ACCEPT_LANGUAGE');
6
+ $l = strtolower(substr($l,0,2));
7
+ }
8
+ $l = ($l == 'de' || $l == 'fr' || $l == 'zh') ? $l : 'en';
9
+
10
+ $lang = array();
11
+ $lang['en'][0] = 'CSS Formatter and Optimiser/Optimizer (based on CSSTidy ';
12
+ $lang['de'][0] = 'CSS Formatierer und Optimierer (basierend auf CSSTidy ';
13
+ $lang['en'][1] = 'CSS Formatter and Optimiser';
14
+ $lang['de'][1] = 'CSS Formatierer und Optimierer';
15
+ $lang['en'][2] = '(based on';
16
+ $lang['de'][2] = '(basierend auf';
17
+ $lang['en'][3] = '(plaintext)';
18
+ $lang['de'][3] = '(Textversion)';
19
+ $lang['en'][4] = 'Important Note:';
20
+ $lang['de'][4] = 'Wichtiger Hinweis:';
21
+ $lang['en'][6] = 'Your code should be well-formed. This is <strong>no validator</strong> which points out errors in your CSS code. To make sure that your code is valid, use the <a href="http://jigsaw.w3.org/css-validator/">W3C Validator</a>.';
22
+ $lang['de'][6] = 'Der CSS Code sollte wohlgeformt sein. Der CSS Code wird <strong>nicht auf Gültigkeit überprüft</strong>. Um sicherzugehen dass dein Code valide ist, benutze den <a href="http://jigsaw.w3.org/css-validator/">W3C Validierungsservice</a>.';
23
+ $lang['en'][7] = 'all comments are removed';
24
+ $lang['de'][7] = 'alle Kommentare werden entfernt';
25
+ $lang['en'][8] = 'CSS Input:';
26
+ $lang['de'][8] = 'CSS Eingabe:';
27
+ $lang['en'][9] = 'CSS-Code:';
28
+ $lang['de'][9] = 'CSS-Code:';
29
+ $lang['en'][10] = 'CSS from URL:';
30
+ $lang['de'][10] = 'CSS von URL:';
31
+ $lang['en'][11] = 'Code Layout:';
32
+ $lang['de'][11] = 'Code Layout:';
33
+ $lang['en'][12] = 'Compression&nbsp;(code&nbsp;layout):';
34
+ $lang['de'][12] = 'Komprimierung&nbsp;(Code&nbsp;Layout):';
35
+ $lang['en'][13] = 'Highest (no readability, smallest size)';
36
+ $lang['de'][13] = 'Höchste (keine Lesbarkeit, niedrigste Größe)';
37
+ $lang['en'][14] = 'High (moderate readability, smaller size)';
38
+ $lang['de'][14] = 'Hoch (mittelmäßige Lesbarkeit, geringe Größe)';
39
+ $lang['en'][15] = 'Standard (balance between readability and size)';
40
+ $lang['de'][15] = 'Standard (Kompromiss zwischen Lesbarkeit und Größe)';
41
+ $lang['en'][16] = 'Low (higher readability)';
42
+ $lang['de'][16] = 'Niedrig (höhere Lesbarkeit)';
43
+ $lang['en'][17] = 'Custom (enter below)';
44
+ $lang['de'][17] = 'Benutzerdefiniert (unten eingeben)';
45
+ $lang['en'][18] = 'Custom <a href="http://csstidy.sourceforge.net/templates.php">template</a>';
46
+ $lang['de'][18] = 'Benutzerdefinierte <a href="http://csstidy.sourceforge.net/templates.php">Vorlage</a>';
47
+ $lang['en'][19] = 'Options';
48
+ $lang['de'][19] = 'Optionen';
49
+ $lang['en'][20] = 'Sort Selectors (caution)';
50
+ $lang['de'][20] = 'Selektoren sortieren (Vorsicht)';
51
+ $lang['en'][21] = 'Sort Properties';
52
+ $lang['de'][21] = 'Eigenschaften sortieren';
53
+ $lang['en'][22] = 'Regroup selectors';
54
+ $lang['de'][22] = 'Selektoren umgruppieren';
55
+ $lang['en'][23] = 'Optimise shorthands';
56
+ $lang['de'][23] = 'Shorthands optimieren';
57
+ $lang['en'][24] = 'Compress colors';
58
+ $lang['de'][24] = 'Farben komprimieren';
59
+ $lang['en'][25] = 'Lowercase selectors';
60
+ $lang['de'][25] = 'Selektoren in Kleinbuchstaben';
61
+ $lang['en'][26] = 'Case for properties:';
62
+ $lang['de'][26] = 'Groß-/Kleinschreibung für Eigenschaften';
63
+ $lang['en'][27] = 'Lowercase';
64
+ $lang['de'][27] = 'Kleinbuchstaben';
65
+ $lang['en'][28] = 'No or invalid CSS input or wrong URL!';
66
+ $lang['de'][28] = 'Keine oder ungültige CSS Eingabe oder falsche URL!';
67
+ $lang['en'][29] = 'Uppercase';
68
+ $lang['de'][29] = 'Großbuchstaben';
69
+ $lang['en'][30] = 'lowercase elementnames needed for XHTML';
70
+ $lang['de'][30] = 'kleingeschriebene Elementnamen benötigt für XHTML';
71
+ $lang['en'][31] = 'Remove unnecessary backslashes';
72
+ $lang['de'][31] = 'Unnötige Backslashes entfernen';
73
+ $lang['en'][32] = 'convert !important-hack';
74
+ $lang['de'][32] = '!important-Hack konvertieren';
75
+ $lang['en'][33] = 'Output as file';
76
+ $lang['de'][33] = 'Als Datei ausgeben';
77
+ $lang['en'][34] = 'Bigger compression because of smaller newlines (copy &amp; paste doesn\'t work)';
78
+ $lang['de'][34] = 'Größere Komprimierung augrund von kleineren Neuezeile-Zeichen';
79
+ $lang['en'][35] = 'Process CSS';
80
+ $lang['de'][35] = 'CSS verarbeiten';
81
+ $lang['en'][36] = 'Compression Ratio';
82
+ $lang['de'][36] = 'Komprimierungsrate';
83
+ $lang['en'][37] = 'Input';
84
+ $lang['de'][37] = 'Eingabe';
85
+ $lang['en'][38] = 'Output';
86
+ $lang['de'][38] = 'Ausgabe';
87
+ $lang['en'][39] = 'Language';
88
+ $lang['de'][39] = 'Sprache';
89
+ $lang['en'][41] = 'Attention: This may change the behaviour of your CSS Code!';
90
+ $lang['de'][41] = 'Achtung: Dies könnte das Verhalten ihres CSS-Codes verändern!';
91
+ $lang['en'][42] = 'Remove last ;';
92
+ $lang['de'][42] = 'Letztes ; entfernen';
93
+ $lang['en'][43] = 'Discard invalid properties';
94
+ $lang['de'][43] = 'Ungültige Eigenschaften entfernen';
95
+ $lang['en'][44] = 'Only safe optimisations';
96
+ $lang['de'][44] = 'Nur sichere Optimierungen';
97
+ $lang['en'][45] = 'Compress font-weight';
98
+ $lang['de'][45] = 'font-weight komprimieren';
99
+ $lang['en'][46] = 'Save comments';
100
+ $lang['de'][46] = 'Kommentare beibehalten';
101
+ $lang['en'][47] = 'Do not change anything';
102
+ $lang['en'][48] = 'Only seperate selectors (split at ,)';
103
+ $lang['en'][49] = 'Merge selectors with the same properties (fast)';
104
+ $lang['en'][50] = 'Merge selectors intelligently (slow)';
105
+ $lang['de'][47] = 'Nichts ändern';
106
+ $lang['de'][48] = 'Selektoren nur trennen (am Komma)';
107
+ $lang['de'][49] = 'Selektoren mit gleichen Eigenschaften zusammenfassen (schnell)';
108
+ $lang['de'][50] = 'Selektoren intelligent zusammenfassen (langsam!)';
109
+ $lang['en'][51] = 'Preserve CSS';
110
+ $lang['de'][51] = 'CSS erhalten';
111
+ $lang['en'][52] = 'Save comments, hacks, etc. Most optimisations can *not* be applied if this is enabled.';
112
+ $lang['de'][52] = 'Kommentare, Hacks, etc. speichern. Viele Optimierungen sind dann aber nicht mehr möglich.';
113
+ $lang['en'][53] = 'None';
114
+ $lang['de'][53] = 'Keine';
115
+ $lang['en'][54] = 'Don\'t optimise';
116
+ $lang['de'][54] = 'Nicht optimieren';
117
+ $lang['en'][55] = 'Safe optimisations';
118
+ $lang['de'][55] = 'Sichere Optimierungen';
119
+ $lang['en'][56] = 'All optimisations';
120
+ $lang['de'][56] = 'Alle Optimierungen';
121
+ $lang['en'][57] = 'Add timestamp';
122
+ $lang['de'][57] = 'Zeitstempel hinzufügen';
123
+
124
+ $lang['fr'][0] = 'CSS Formatteur et Optimiseur (basé sur CSSTidy ';
125
+ $lang['fr'][1] = 'CSS Formatteur et Optimiseur';
126
+ $lang['fr'][2] = '(basé sur ';
127
+ $lang['fr'][3] = '(Version Text)';
128
+ $lang['fr'][4] = 'notes Importantes:';
129
+ $lang['fr'][5] = 'les mêmes sélecteurs et les propriétés sont automatiquement fusionnés';
130
+ $lang['fr'][6] = 'votre code doit être Valide. Ce n\'est <strong>pas un validateur</strong> qui signale des erreurs dans votre code de CSS. Assurez-vous que votre code est correct en utilisant le le validateur : <a href="http://jigsaw.w3.org/css-validator/">W3C Validator</a>';
131
+ $lang['fr'][7] = 'tous les commentaires sont enlevés';
132
+ $lang['fr'][8] = 'Champ CSS:';
133
+ $lang['fr'][9] = 'CSS-Code:';
134
+ $lang['fr'][10] = 'CSS en provenance d\'une URL:<br />';
135
+ $lang['fr'][11] = 'Mise en page du code:';
136
+ $lang['fr'][12] = 'Compression (Mise en page du code):';
137
+ $lang['fr'][13] = 'Le plus compact (aucune lisibilité, plus petite taille)';
138
+ $lang['fr'][14] = 'Trés compact (lisibilité modérée, plus petite taille)';
139
+ $lang['fr'][15] = 'Normale (équilibre entre la lisibilité et la taille)';
140
+ $lang['fr'][16] = 'Peu compact (une lisibilité plus élevée)';
141
+ $lang['fr'][17] = 'Sur mesure (entrer ci-dessous)';
142
+ $lang['fr'][18] = 'Sur mesure <a href="http://csstidy.sourceforge.net/templates.php">Gabarit</a>';
143
+ $lang['fr'][19] = 'Options';
144
+ $lang['fr'][20] = 'Trier les sélecteurs (attention)';
145
+ $lang['fr'][21] = 'Trier les propriétés';
146
+ $lang['fr'][22] = 'Fusionner les sélecteurs';
147
+ $lang['fr'][23] = 'Optimise shorthands';
148
+ $lang['fr'][24] = 'Compresser les couleurs';
149
+ $lang['fr'][25] = 'Sélecteurs en minuscules';
150
+ $lang['fr'][26] = 'Cases (Minuscules &amp; Majuscule) pour les propriétés:';
151
+ $lang['fr'][27] = 'Minuscules';
152
+ $lang['fr'][28] = 'CSS non valide ou URL incorrecte!';
153
+ $lang['fr'][29] = 'Majuscule';
154
+ $lang['fr'][30] = 'les noms des éléments en minuscules (indispensables pour XHTML)';
155
+ $lang['fr'][31] = 'enlever les antislashs inutiles';
156
+ $lang['fr'][32] = 'convertir !important-hack';
157
+ $lang['fr'][33] = 'Sauver en tant que fichier';
158
+ $lang['fr'][34] = 'Une plus grande compression en raison de plus petits caractères';
159
+ $lang['fr'][35] = 'Compresser le CSS';
160
+ $lang['fr'][36] = 'Facteur de Compression';
161
+ $lang['fr'][37] = 'Entrée';
162
+ $lang['fr'][38] = 'Sortie';
163
+ $lang['fr'][39] = 'Language';
164
+ $lang['fr'][41] = 'Attention : ceci peut changer le comportement de votre code de CSS !';
165
+ $lang['fr'][42] = 'Enlever le dernier ;';
166
+ $lang['fr'][43] = 'Supprimer les propriétés non valide';
167
+ $lang['fr'][44] = 'Seulement les optimisations sûres';
168
+ $lang['fr'][45] = 'Compresser font-weight';
169
+ $lang['fr'][46] = 'Sauvegarder les commentaires ';
170
+ $lang['fr'][47] = 'Ne changer rien';
171
+ $lang['fr'][48] = 'Sépare les sélecteurs (sépare au niveau de ,)';
172
+ $lang['fr'][49] = 'Fusionne les sélecteurs avec les mêmes propriétés (rapides)';
173
+ $lang['fr'][50] = 'Fusionne les sélecteurs intelligemment (lent)';
174
+ $lang['fr'][51] = 'Preserve CSS';
175
+ $lang['fr'][52] = 'Save comments, hacks, etc. Most optimisations can *not* be applied if this is enabled.';
176
+ $lang['fr'][53] = 'None';
177
+ $lang['fr'][54] = 'Don\'t optimise';
178
+ $lang['fr'][55] = 'Safe optimisations';
179
+ $lang['fr'][56] = 'All optimisations';
180
+ $lang['fr'][57] = 'Add timestamp';
181
+
182
+ $lang['zh'][0] = 'CSS整形與最佳化工具(使用 CSSTidy ';
183
+ $lang['zh'][1] = 'CSS整形與最佳化工具';
184
+ $lang['zh'][2] = '(使用';
185
+ $lang['zh'][3] = '(純文字)';
186
+ $lang['zh'][4] = '重要事項:';
187
+ $lang['zh'][6] = '你的原始碼必須是良構的(well-formed). 這個工具<strong>沒有內建驗證器(validator)</strong>. 驗證器能夠指出你CSS原始碼裡的錯誤. 請使用 <a href="http://jigsaw.w3.org/css-validator/">W3C 驗證器</a>, 確保你的原始碼合乎規範.';
188
+ $lang['zh'][7] = '所有註解都移除了';
189
+ $lang['zh'][8] = 'CSS 輸入:';
190
+ $lang['zh'][9] = 'CSS 原始碼:';
191
+ $lang['zh'][10] = 'CSS 檔案網址(URL):';
192
+ $lang['zh'][11] = '原始碼規劃:';
193
+ $lang['zh'][12] = '壓縮程度(原始碼規劃):';
194
+ $lang['zh'][13] = '最高 (沒有辦法讀, 檔案最小)';
195
+ $lang['zh'][14] = '高 (適度的可讀性, 檔案小)';
196
+ $lang['zh'][15] = '標準 (兼顧可讀性與檔案大小)';
197
+ $lang['zh'][16] = '低 (注重可讀性)';
198
+ $lang['zh'][17] = '自訂 (在下方設定)';
199
+ $lang['zh'][18] = '自訂<a href="http://csstidy.sourceforge.net/templates.php">樣板</a>';
200
+ $lang['zh'][19] = '選項';
201
+ $lang['zh'][20] = '整理選擇符(請謹慎使用)';
202
+ $lang['zh'][21] = '整理屬性';
203
+ $lang['zh'][22] = '重組選擇符';
204
+ $lang['zh'][23] = '速記法(shorthand)最佳化';
205
+ $lang['zh'][24] = '壓縮色彩語法';
206
+ $lang['zh'][25] = '改用小寫選擇符';
207
+ $lang['zh'][26] = '屬性的字形:';
208
+ $lang['zh'][27] = '小寫';
209
+ $lang['zh'][28] = '沒有輸入CSS, 語法不符合規定, 或是網址錯誤!';
210
+ $lang['zh'][29] = '大寫';
211
+ $lang['zh'][30] = 'XHTML必須使用小寫的元素名稱';
212
+ $lang['zh'][31] = '移除不必要的反斜線';
213
+ $lang['zh'][32] = '轉換 !important-hack';
214
+ $lang['zh'][33] = '輸出成檔案形式';
215
+ $lang['zh'][34] = '由於比較少換行字元, 會有更大的壓縮比率(複製&amp;貼上沒有用)';
216
+ $lang['zh'][35] = '執行';
217
+ $lang['zh'][36] = '壓縮比率';
218
+ $lang['zh'][37] = '輸入';
219
+ $lang['zh'][38] = '輸出';
220
+ $lang['zh'][39] = '語言';
221
+ $lang['zh'][41] = '注意: 這或許會變更你CSS原始碼的行為!';
222
+ $lang['zh'][42] = '除去最後一個分號';
223
+ $lang['zh'][43] = '拋棄不符合規定的屬性';
224
+ $lang['zh'][44] = '只安全地最佳化';
225
+ $lang['zh'][45] = '壓縮 font-weight';
226
+ $lang['zh'][46] = '保留註解';
227
+ $lang['zh'][47] = '什麼都不要改';
228
+ $lang['zh'][48] = '只分開原本用逗號分隔的選擇符';
229
+ $lang['zh'][49] = '合併有相同屬性的選擇符(快速)';
230
+ $lang['zh'][50] = '聰明地合併選擇符(慢速)';
231
+ $lang['zh'][51] = '保護CSS';
232
+ $lang['zh'][52] = '保留註解與 hack 等等. 如果啟用這個選項, 大多數的最佳化程序都不會執行.';
233
+ $lang['zh'][53] = '不改變';
234
+ $lang['zh'][54] = '不做最佳化';
235
+ $lang['zh'][55] = '安全地最佳化';
236
+ $lang['zh'][56] = '全部最佳化';
237
+ $lang['zh'][57] = '加上時間戳記';
238
+ ?>
includes/csstidy-1.3/template.tpl ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <span class="at">|</span> <span class="format">{</span>
2
+ |<span class="selector">|</span> <span class="format">{</span>
3
+ |<span class="property">|</span><span class="value">|</span><span class="format">;</span>
4
+ |<span class="format">}</span>|
5
+
6
+ |
7
+ <span class="format">}</span>
8
+
9
+ ||<span class="comment">|</span>
10
+ |
includes/csstidy-1.3/template1.tpl ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <span class="at">|</span> <span class="format">{</span>
2
+ |<span class="selector">|</span>
3
+ <span class="format">{</span>
4
+ | <span class="property">|</span><span class="value">|</span><span class="format">;</span>
5
+ |<span class="format">}</span>|
6
+
7
+ |
8
+
9
+ <span class="format">}</span>
10
+
11
+ | |<span class="comment">|</span>
12
+ |
includes/csstidy-1.3/template2.tpl ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <span class="at">|</span> <span class="format">{</span>
2
+ |<span class="selector">|</span><span class="format">{</span>|<span class="property">|</span><span class="value">|</span><span class="format">;</span>|<span class="format">}</span>|
3
+ |
4
+ <span class="format">}
5
+ </span>||<span class="comment">|</span>|
includes/csstidy-1.3/template3.tpl ADDED
@@ -0,0 +1 @@
 
1
+ <span class="at">|</span><span class="format">{</span>|<span class="selector">|</span><span class="format">{</span>|<span class="property">|</span><span class="value">|</span><span class="format">;</span>|<span class="format">}</span>||<span class="format">}</span>||<span class="comment">|</span>|
includes/js/.htaccess ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ # BEGIN Head Cleaner
2
+ <IfModule mod_rewrite.c>
3
+ RewriteEngine On
4
+ RewriteCond %{HTTP:Accept-Encoding} gzip
5
+ RewriteCond %{REQUEST_FILENAME} "\.(css|js)$"
6
+ RewriteCond %{REQUEST_FILENAME} !"\.gz$"
7
+ RewriteCond %{REQUEST_FILENAME}.gz -s
8
+ RewriteRule .+ %{REQUEST_URI}.gz [L]
9
+ </IfModule>
10
+ # END Head Cleaner
includes/js/jquery-1.2.6.min.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery 1.2.6 - New Wave Javascript
3
+ *
4
+ * Copyright (c) 2008 John Resig (jquery.com)
5
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
6
+ * and GPL (GPL-LICENSE.txt) licenses.
7
+ *
8
+ * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
9
+ * $Rev: 5685 $
10
+ */
11
+ (function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
12
+ return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
13
+ return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
14
+ selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
15
+ return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
16
+ this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
17
+ return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
18
+ jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
19
+ script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
20
+ for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
21
+ for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
22
+ jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
23
+ ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
24
+ while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
25
+ while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
26
+ for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
27
+ jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
28
+ xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
29
+ jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
30
+ for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
31
+ s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
32
+ e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();
includes/js/jquery-1.2.6.min.js.gz ADDED
Binary file
includes/js/jquery-1.3.2.min.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery JavaScript Library v1.3.2
3
+ * http://jquery.com/
4
+ *
5
+ * Copyright (c) 2009 John Resig
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://docs.jquery.com/License
8
+ *
9
+ * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
10
+ * Revision: 6246
11
+ */
12
+ (function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
13
+ /*
14
+ * Sizzle CSS Selector Engine - v0.9.3
15
+ * Copyright 2009, The Dojo Foundation
16
+ * Released under the MIT, BSD, and GPL Licenses.
17
+ * More information: http://sizzlejs.com/
18
+ */
19
+ (function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML=' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();
includes/js/jquery-1.3.2.min.js.gz ADDED
Binary file
includes/js/jquery.browser.chrome.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(C){var B=navigator.userAgent.toLowerCase();C.browser=C.extend(C.browser,{version:((!/chrome/.test(B)?B.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/):B.match(/.+chrome\/([\d.]+)/))||[])[1],safari:/webkit/.test(B)&&!/chrome/.test(B),chrome:/chrome/.test(B)});if(C.browser.chrome){C.fn.extend({ready:function(E){A();if(C.isReady){E.call(document,C)}else{C.readyList.push(function(){return E.call(this,C)})}return this}});var D=false;function A(){if(D){return }D=true;var E;(function(){if(C.isReady){return }if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return }if(E===undefined){E=C("style, link[rel=stylesheet]").length}if(document.styleSheets.length!=E){setTimeout(arguments.callee,0);return }C.ready()})();C.event.add(window,"load",C.ready)}}})(jQuery);
includes/js/jquery.browser.chrome.min.js.gz ADDED
Binary file
includes/js/jquery.noconflict.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(A){if(typeof A!=="undefined"){A.noConflict()}})(jQuery);
includes/js/mootools-1.2.1-core-nc.js ADDED
@@ -0,0 +1,3946 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Script: Core.js
3
+ MooTools - My Object Oriented JavaScript Tools.
4
+
5
+ License:
6
+ MIT-style license.
7
+
8
+ Copyright:
9
+ Copyright (c) 2006-2008 [Valerio Proietti](http://mad4milk.net/).
10
+
11
+ Code & Documentation:
12
+ [The MooTools production team](http://mootools.net/developers/).
13
+
14
+ Inspiration:
15
+ - Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)
16
+ - Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)
17
+ */
18
+
19
+ var MooTools = {
20
+ 'version': '1.2.1',
21
+ 'build': '0d4845aab3d9a4fdee2f0d4a6dd59210e4b697cf'
22
+ };
23
+
24
+ var Native = function(options){
25
+ options = options || {};
26
+ var name = options.name;
27
+ var legacy = options.legacy;
28
+ var protect = options.protect;
29
+ var methods = options.implement;
30
+ var generics = options.generics;
31
+ var initialize = options.initialize;
32
+ var afterImplement = options.afterImplement || function(){};
33
+ var object = initialize || legacy;
34
+ generics = generics !== false;
35
+
36
+ object.constructor = Native;
37
+ object.$family = {name: 'native'};
38
+ if (legacy && initialize) object.prototype = legacy.prototype;
39
+ object.prototype.constructor = object;
40
+
41
+ if (name){
42
+ var family = name.toLowerCase();
43
+ object.prototype.$family = {name: family};
44
+ Native.typize(object, family);
45
+ }
46
+
47
+ var add = function(obj, name, method, force){
48
+ if (!protect || force || !obj.prototype[name]) obj.prototype[name] = method;
49
+ if (generics) Native.genericize(obj, name, protect);
50
+ afterImplement.call(obj, name, method);
51
+ return obj;
52
+ };
53
+
54
+ object.alias = function(a1, a2, a3){
55
+ if (typeof a1 == 'string'){
56
+ if ((a1 = this.prototype[a1])) return add(this, a2, a1, a3);
57
+ }
58
+ for (var a in a1) this.alias(a, a1[a], a2);
59
+ return this;
60
+ };
61
+
62
+ object.implement = function(a1, a2, a3){
63
+ if (typeof a1 == 'string') return add(this, a1, a2, a3);
64
+ for (var p in a1) add(this, p, a1[p], a2);
65
+ return this;
66
+ };
67
+
68
+ if (methods) object.implement(methods);
69
+
70
+ return object;
71
+ };
72
+
73
+ Native.genericize = function(object, property, check){
74
+ if ((!check || !object[property]) && typeof object.prototype[property] == 'function') object[property] = function(){
75
+ var args = Array.prototype.slice.call(arguments);
76
+ return object.prototype[property].apply(args.shift(), args);
77
+ };
78
+ };
79
+
80
+ Native.implement = function(objects, properties){
81
+ for (var i = 0, l = objects.length; i < l; i++) objects[i].implement(properties);
82
+ };
83
+
84
+ Native.typize = function(object, family){
85
+ if (!object.type) object.type = function(item){
86
+ return ($type(item) === family);
87
+ };
88
+ };
89
+
90
+ (function(){
91
+ var natives = {'Array': Array, 'Date': Date, 'Function': Function, 'Number': Number, 'RegExp': RegExp, 'String': String};
92
+ for (var n in natives) new Native({name: n, initialize: natives[n], protect: true});
93
+
94
+ var types = {'boolean': Boolean, 'native': Native, 'object': Object};
95
+ for (var t in types) Native.typize(types[t], t);
96
+
97
+ var generics = {
98
+ 'Array': ["concat", "indexOf", "join", "lastIndexOf", "pop", "push", "reverse", "shift", "slice", "sort", "splice", "toString", "unshift", "valueOf"],
99
+ 'String': ["charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "match", "replace", "search", "slice", "split", "substr", "substring", "toLowerCase", "toUpperCase", "valueOf"]
100
+ };
101
+ for (var g in generics){
102
+ for (var i = generics[g].length; i--;) Native.genericize(window[g], generics[g][i], true);
103
+ };
104
+ })();
105
+
106
+ var Hash = new Native({
107
+
108
+ name: 'Hash',
109
+
110
+ initialize: function(object){
111
+ if ($type(object) == 'hash') object = $unlink(object.getClean());
112
+ for (var key in object) this[key] = object[key];
113
+ return this;
114
+ }
115
+
116
+ });
117
+
118
+ Hash.implement({
119
+
120
+ forEach: function(fn, bind){
121
+ for (var key in this){
122
+ if (this.hasOwnProperty(key)) fn.call(bind, this[key], key, this);
123
+ }
124
+ },
125
+
126
+ getClean: function(){
127
+ var clean = {};
128
+ for (var key in this){
129
+ if (this.hasOwnProperty(key)) clean[key] = this[key];
130
+ }
131
+ return clean;
132
+ },
133
+
134
+ getLength: function(){
135
+ var length = 0;
136
+ for (var key in this){
137
+ if (this.hasOwnProperty(key)) length++;
138
+ }
139
+ return length;
140
+ }
141
+
142
+ });
143
+
144
+ Hash.alias('forEach', 'each');
145
+
146
+ Array.implement({
147
+
148
+ forEach: function(fn, bind){
149
+ for (var i = 0, l = this.length; i < l; i++) fn.call(bind, this[i], i, this);
150
+ }
151
+
152
+ });
153
+
154
+ Array.alias('forEach', 'each');
155
+
156
+ function $A(iterable){
157
+ if (iterable.item){
158
+ var array = [];
159
+ for (var i = 0, l = iterable.length; i < l; i++) array[i] = iterable[i];
160
+ return array;
161
+ }
162
+ return Array.prototype.slice.call(iterable);
163
+ };
164
+
165
+ function $arguments(i){
166
+ return function(){
167
+ return arguments[i];
168
+ };
169
+ };
170
+
171
+ function $chk(obj){
172
+ return !!(obj || obj === 0);
173
+ };
174
+
175
+ function $clear(timer){
176
+ clearTimeout(timer);
177
+ clearInterval(timer);
178
+ return null;
179
+ };
180
+
181
+ function $defined(obj){
182
+ return (obj != undefined);
183
+ };
184
+
185
+ function $each(iterable, fn, bind){
186
+ var type = $type(iterable);
187
+ ((type == 'arguments' || type == 'collection' || type == 'array') ? Array : Hash).each(iterable, fn, bind);
188
+ };
189
+
190
+ function $empty(){};
191
+
192
+ function $extend(original, extended){
193
+ for (var key in (extended || {})) original[key] = extended[key];
194
+ return original;
195
+ };
196
+
197
+ function $H(object){
198
+ return new Hash(object);
199
+ };
200
+
201
+ function $lambda(value){
202
+ return (typeof value == 'function') ? value : function(){
203
+ return value;
204
+ };
205
+ };
206
+
207
+ function $merge(){
208
+ var mix = {};
209
+ for (var i = 0, l = arguments.length; i < l; i++){
210
+ var object = arguments[i];
211
+ if ($type(object) != 'object') continue;
212
+ for (var key in object){
213
+ var op = object[key], mp = mix[key];
214
+ mix[key] = (mp && $type(op) == 'object' && $type(mp) == 'object') ? $merge(mp, op) : $unlink(op);
215
+ }
216
+ }
217
+ return mix;
218
+ };
219
+
220
+ function $pick(){
221
+ for (var i = 0, l = arguments.length; i < l; i++){
222
+ if (arguments[i] != undefined) return arguments[i];
223
+ }
224
+ return null;
225
+ };
226
+
227
+ function $random(min, max){
228
+ return Math.floor(Math.random() * (max - min + 1) + min);
229
+ };
230
+
231
+ function $splat(obj){
232
+ var type = $type(obj);
233
+ return (type) ? ((type != 'array' && type != 'arguments') ? [obj] : obj) : [];
234
+ };
235
+
236
+ var $time = Date.now || function(){
237
+ return +new Date;
238
+ };
239
+
240
+ function $try(){
241
+ for (var i = 0, l = arguments.length; i < l; i++){
242
+ try {
243
+ return arguments[i]();
244
+ } catch(e){}
245
+ }
246
+ return null;
247
+ };
248
+
249
+ function $type(obj){
250
+ if (obj == undefined) return false;
251
+ if (obj.$family) return (obj.$family.name == 'number' && !isFinite(obj)) ? false : obj.$family.name;
252
+ if (obj.nodeName){
253
+ switch (obj.nodeType){
254
+ case 1: return 'element';
255
+ case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
256
+ }
257
+ } else if (typeof obj.length == 'number'){
258
+ if (obj.callee) return 'arguments';
259
+ else if (obj.item) return 'collection';
260
+ }
261
+ return typeof obj;
262
+ };
263
+
264
+ function $unlink(object){
265
+ var unlinked;
266
+ switch ($type(object)){
267
+ case 'object':
268
+ unlinked = {};
269
+ for (var p in object) unlinked[p] = $unlink(object[p]);
270
+ break;
271
+ case 'hash':
272
+ unlinked = new Hash(object);
273
+ break;
274
+ case 'array':
275
+ unlinked = [];
276
+ for (var i = 0, l = object.length; i < l; i++) unlinked[i] = $unlink(object[i]);
277
+ break;
278
+ default: return object;
279
+ }
280
+ return unlinked;
281
+ };
282
+
283
+
284
+ /*
285
+ Script: Browser.js
286
+ The Browser Core. Contains Browser initialization, Window and Document, and the Browser Hash.
287
+
288
+ License:
289
+ MIT-style license.
290
+ */
291
+
292
+ var Browser = $merge({
293
+
294
+ Engine: {name: 'unknown', version: 0},
295
+
296
+ Platform: {name: (window.orientation != undefined) ? 'ipod' : (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase()},
297
+
298
+ Features: {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)},
299
+
300
+ Plugins: {},
301
+
302
+ Engines: {
303
+
304
+ presto: function(){
305
+ return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925));
306
+ },
307
+
308
+ trident: function(){
309
+ return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? 5 : 4);
310
+ },
311
+
312
+ webkit: function(){
313
+ return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419);
314
+ },
315
+
316
+ gecko: function(){
317
+ return (document.getBoxObjectFor == undefined) ? false : ((document.getElementsByClassName) ? 19 : 18);
318
+ }
319
+
320
+ }
321
+
322
+ }, Browser || {});
323
+
324
+ Browser.Platform[Browser.Platform.name] = true;
325
+
326
+ Browser.detect = function(){
327
+
328
+ for (var engine in this.Engines){
329
+ var version = this.Engines[engine]();
330
+ if (version){
331
+ this.Engine = {name: engine, version: version};
332
+ this.Engine[engine] = this.Engine[engine + version] = true;
333
+ break;
334
+ }
335
+ }
336
+
337
+ return {name: engine, version: version};
338
+
339
+ };
340
+
341
+ Browser.detect();
342
+
343
+ Browser.Request = function(){
344
+ return $try(function(){
345
+ return new XMLHttpRequest();
346
+ }, function(){
347
+ return new ActiveXObject('MSXML2.XMLHTTP');
348
+ });
349
+ };
350
+
351
+ Browser.Features.xhr = !!(Browser.Request());
352
+
353
+ Browser.Plugins.Flash = (function(){
354
+ var version = ($try(function(){
355
+ return navigator.plugins['Shockwave Flash'].description;
356
+ }, function(){
357
+ return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
358
+ }) || '0 r0').match(/\d+/g);
359
+ return {version: parseInt(version[0] || 0 + '.' + version[1] || 0), build: parseInt(version[2] || 0)};
360
+ })();
361
+
362
+ function $exec(text){
363
+ if (!text) return text;
364
+ if (window.execScript){
365
+ window.execScript(text);
366
+ } else {
367
+ var script = document.createElement('script');
368
+ script.setAttribute('type', 'text/javascript');
369
+ script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text;
370
+ document.head.appendChild(script);
371
+ document.head.removeChild(script);
372
+ }
373
+ return text;
374
+ };
375
+
376
+ Native.UID = 1;
377
+
378
+ var $uid = (Browser.Engine.trident) ? function(item){
379
+ return (item.uid || (item.uid = [Native.UID++]))[0];
380
+ } : function(item){
381
+ return item.uid || (item.uid = Native.UID++);
382
+ };
383
+
384
+ var Window = new Native({
385
+
386
+ name: 'Window',
387
+
388
+ legacy: (Browser.Engine.trident) ? null: window.Window,
389
+
390
+ initialize: function(win){
391
+ $uid(win);
392
+ if (!win.Element){
393
+ win.Element = $empty;
394
+ if (Browser.Engine.webkit) win.document.createElement("iframe"); //fixes safari 2
395
+ win.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {};
396
+ }
397
+ win.document.window = win;
398
+ return $extend(win, Window.Prototype);
399
+ },
400
+
401
+ afterImplement: function(property, value){
402
+ window[property] = Window.Prototype[property] = value;
403
+ }
404
+
405
+ });
406
+
407
+ Window.Prototype = {$family: {name: 'window'}};
408
+
409
+ new Window(window);
410
+
411
+ var Document = new Native({
412
+
413
+ name: 'Document',
414
+
415
+ legacy: (Browser.Engine.trident) ? null: window.Document,
416
+
417
+ initialize: function(doc){
418
+ $uid(doc);
419
+ doc.head = doc.getElementsByTagName('head')[0];
420
+ doc.html = doc.getElementsByTagName('html')[0];
421
+ if (Browser.Engine.trident && Browser.Engine.version <= 4) $try(function(){
422
+ doc.execCommand("BackgroundImageCache", false, true);
423
+ });
424
+ if (Browser.Engine.trident) doc.window.attachEvent('onunload', function() {
425
+ doc.window.detachEvent('onunload', arguments.callee);
426
+ doc.head = doc.html = doc.window = null;
427
+ });
428
+ return $extend(doc, Document.Prototype);
429
+ },
430
+
431
+ afterImplement: function(property, value){
432
+ document[property] = Document.Prototype[property] = value;
433
+ }
434
+
435
+ });
436
+
437
+ Document.Prototype = {$family: {name: 'document'}};
438
+
439
+ new Document(document);
440
+
441
+
442
+ /*
443
+ Script: Array.js
444
+ Contains Array Prototypes like each, contains, and erase.
445
+
446
+ License:
447
+ MIT-style license.
448
+ */
449
+
450
+ Array.implement({
451
+
452
+ every: function(fn, bind){
453
+ for (var i = 0, l = this.length; i < l; i++){
454
+ if (!fn.call(bind, this[i], i, this)) return false;
455
+ }
456
+ return true;
457
+ },
458
+
459
+ filter: function(fn, bind){
460
+ var results = [];
461
+ for (var i = 0, l = this.length; i < l; i++){
462
+ if (fn.call(bind, this[i], i, this)) results.push(this[i]);
463
+ }
464
+ return results;
465
+ },
466
+
467
+ clean: function() {
468
+ return this.filter($defined);
469
+ },
470
+
471
+ indexOf: function(item, from){
472
+ var len = this.length;
473
+ for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){
474
+ if (this[i] === item) return i;
475
+ }
476
+ return -1;
477
+ },
478
+
479
+ map: function(fn, bind){
480
+ var results = [];
481
+ for (var i = 0, l = this.length; i < l; i++) results[i] = fn.call(bind, this[i], i, this);
482
+ return results;
483
+ },
484
+
485
+ some: function(fn, bind){
486
+ for (var i = 0, l = this.length; i < l; i++){
487
+ if (fn.call(bind, this[i], i, this)) return true;
488
+ }
489
+ return false;
490
+ },
491
+
492
+ associate: function(keys){
493
+ var obj = {}, length = Math.min(this.length, keys.length);
494
+ for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
495
+ return obj;
496
+ },
497
+
498
+ link: function(object){
499
+ var result = {};
500
+ for (var i = 0, l = this.length; i < l; i++){
501
+ for (var key in object){
502
+ if (object[key](this[i])){
503
+ result[key] = this[i];
504
+ delete object[key];
505
+ break;
506
+ }
507
+ }
508
+ }
509
+ return result;
510
+ },
511
+
512
+ contains: function(item, from){
513
+ return this.indexOf(item, from) != -1;
514
+ },
515
+
516
+ extend: function(array){
517
+ for (var i = 0, j = array.length; i < j; i++) this.push(array[i]);
518
+ return this;
519
+ },
520
+
521
+ getLast: function(){
522
+ return (this.length) ? this[this.length - 1] : null;
523
+ },
524
+
525
+ getRandom: function(){
526
+ return (this.length) ? this[$random(0, this.length - 1)] : null;
527
+ },
528
+
529
+ include: function(item){
530
+ if (!this.contains(item)) this.push(item);
531
+ return this;
532
+ },
533
+
534
+ combine: function(array){
535
+ for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
536
+ return this;
537
+ },
538
+
539
+ erase: function(item){
540
+ for (var i = this.length; i--; i){
541
+ if (this[i] === item) this.splice(i, 1);
542
+ }
543
+ return this;
544
+ },
545
+
546
+ empty: function(){
547
+ this.length = 0;
548
+ return this;
549
+ },
550
+
551
+ flatten: function(){
552
+ var array = [];
553
+ for (var i = 0, l = this.length; i < l; i++){
554
+ var type = $type(this[i]);
555
+ if (!type) continue;
556
+ array = array.concat((type == 'array' || type == 'collection' || type == 'arguments') ? Array.flatten(this[i]) : this[i]);
557
+ }
558
+ return array;
559
+ },
560
+
561
+ hexToRgb: function(array){
562
+ if (this.length != 3) return null;
563
+ var rgb = this.map(function(value){
564
+ if (value.length == 1) value += value;
565
+ return value.toInt(16);
566
+ });
567
+ return (array) ? rgb : 'rgb(' + rgb + ')';
568
+ },
569
+
570
+ rgbToHex: function(array){
571
+ if (this.length < 3) return null;
572
+ if (this.length == 4 && this[3] == 0 && !array) return 'transparent';
573
+ var hex = [];
574
+ for (var i = 0; i < 3; i++){
575
+ var bit = (this[i] - 0).toString(16);
576
+ hex.push((bit.length == 1) ? '0' + bit : bit);
577
+ }
578
+ return (array) ? hex : '#' + hex.join('');
579
+ }
580
+
581
+ });
582
+
583
+
584
+ /*
585
+ Script: Function.js
586
+ Contains Function Prototypes like create, bind, pass, and delay.
587
+
588
+ License:
589
+ MIT-style license.
590
+ */
591
+
592
+ Function.implement({
593
+
594
+ extend: function(properties){
595
+ for (var property in properties) this[property] = properties[property];
596
+ return this;
597
+ },
598
+
599
+ create: function(options){
600
+ var self = this;
601
+ options = options || {};
602
+ return function(event){
603
+ var args = options.arguments;
604
+ args = (args != undefined) ? $splat(args) : Array.slice(arguments, (options.event) ? 1 : 0);
605
+ if (options.event) args = [event || window.event].extend(args);
606
+ var returns = function(){
607
+ return self.apply(options.bind || null, args);
608
+ };
609
+ if (options.delay) return setTimeout(returns, options.delay);
610
+ if (options.periodical) return setInterval(returns, options.periodical);
611
+ if (options.attempt) return $try(returns);
612
+ return returns();
613
+ };
614
+ },
615
+
616
+ run: function(args, bind){
617
+ return this.apply(bind, $splat(args));
618
+ },
619
+
620
+ pass: function(args, bind){
621
+ return this.create({bind: bind, arguments: args});
622
+ },
623
+
624
+ bind: function(bind, args){
625
+ return this.create({bind: bind, arguments: args});
626
+ },
627
+
628
+ bindWithEvent: function(bind, args){
629
+ return this.create({bind: bind, arguments: args, event: true});
630
+ },
631
+
632
+ attempt: function(args, bind){
633
+ return this.create({bind: bind, arguments: args, attempt: true})();
634
+ },
635
+
636
+ delay: function(delay, bind, args){
637
+ return this.create({bind: bind, arguments: args, delay: delay})();
638
+ },
639
+
640
+ periodical: function(periodical, bind, args){
641
+ return this.create({bind: bind, arguments: args, periodical: periodical})();
642
+ }
643
+
644
+ });
645
+
646
+
647
+ /*
648
+ Script: Number.js
649
+ Contains Number Prototypes like limit, round, times, and ceil.
650
+
651
+ License:
652
+ MIT-style license.
653
+ */
654
+
655
+ Number.implement({
656
+
657
+ limit: function(min, max){
658
+ return Math.min(max, Math.max(min, this));
659
+ },
660
+
661
+ round: function(precision){
662
+ precision = Math.pow(10, precision || 0);
663
+ return Math.round(this * precision) / precision;
664
+ },
665
+
666
+ times: function(fn, bind){
667
+ for (var i = 0; i < this; i++) fn.call(bind, i, this);
668
+ },
669
+
670
+ toFloat: function(){
671
+ return parseFloat(this);
672
+ },
673
+
674
+ toInt: function(base){
675
+ return parseInt(this, base || 10);
676
+ }
677
+
678
+ });
679
+
680
+ Number.alias('times', 'each');
681
+
682
+ (function(math){
683
+ var methods = {};
684
+ math.each(function(name){
685
+ if (!Number[name]) methods[name] = function(){
686
+ return Math[name].apply(null, [this].concat($A(arguments)));
687
+ };
688
+ });
689
+ Number.implement(methods);
690
+ })(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
691
+
692
+
693
+ /*
694
+ Script: String.js
695
+ Contains String Prototypes like camelCase, capitalize, test, and toInt.
696
+
697
+ License:
698
+ MIT-style license.
699
+ */
700
+
701
+ String.implement({
702
+
703
+ test: function(regex, params){
704
+ return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this);
705
+ },
706
+
707
+ contains: function(string, separator){
708
+ return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;
709
+ },
710
+
711
+ trim: function(){
712
+ return this.replace(/^\s+|\s+$/g, '');
713
+ },
714
+
715
+ clean: function(){
716
+ return this.replace(/\s+/g, ' ').trim();
717
+ },
718
+
719
+ camelCase: function(){
720
+ return this.replace(/-\D/g, function(match){
721
+ return match.charAt(1).toUpperCase();
722
+ });
723
+ },
724
+
725
+ hyphenate: function(){
726
+ return this.replace(/[A-Z]/g, function(match){
727
+ return ('-' + match.charAt(0).toLowerCase());
728
+ });
729
+ },
730
+
731
+ capitalize: function(){
732
+ return this.replace(/\b[a-z]/g, function(match){
733
+ return match.toUpperCase();
734
+ });
735
+ },
736
+
737
+ escapeRegExp: function(){
738
+ return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
739
+ },
740
+
741
+ toInt: function(base){
742
+ return parseInt(this, base || 10);
743
+ },
744
+
745
+ toFloat: function(){
746
+ return parseFloat(this);
747
+ },
748
+
749
+ hexToRgb: function(array){
750
+ var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
751
+ return (hex) ? hex.slice(1).hexToRgb(array) : null;
752
+ },
753
+
754
+ rgbToHex: function(array){
755
+ var rgb = this.match(/\d{1,3}/g);
756
+ return (rgb) ? rgb.rgbToHex(array) : null;
757
+ },
758
+
759
+ stripScripts: function(option){
760
+ var scripts = '';
761
+ var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
762
+ scripts += arguments[1] + '\n';
763
+ return '';
764
+ });
765
+ if (option === true) $exec(scripts);
766
+ else if ($type(option) == 'function') option(scripts, text);
767
+ return text;
768
+ },
769
+
770
+ substitute: function(object, regexp){
771
+ return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
772
+ if (match.charAt(0) == '\\') return match.slice(1);
773
+ return (object[name] != undefined) ? object[name] : '';
774
+ });
775
+ }
776
+
777
+ });
778
+
779
+
780
+ /*
781
+ Script: Hash.js
782
+ Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects.
783
+
784
+ License:
785
+ MIT-style license.
786
+ */
787
+
788
+ Hash.implement({
789
+
790
+ has: Object.prototype.hasOwnProperty,
791
+
792
+ keyOf: function(value){
793
+ for (var key in this){
794
+ if (this.hasOwnProperty(key) && this[key] === value) return key;
795
+ }
796
+ return null;
797
+ },
798
+
799
+ hasValue: function(value){
800
+ return (Hash.keyOf(this, value) !== null);
801
+ },
802
+
803
+ extend: function(properties){
804
+ Hash.each(properties, function(value, key){
805
+ Hash.set(this, key, value);
806
+ }, this);
807
+ return this;
808
+ },
809
+
810
+ combine: function(properties){
811
+ Hash.each(properties, function(value, key){
812
+ Hash.include(this, key, value);
813
+ }, this);
814
+ return this;
815
+ },
816
+
817
+ erase: function(key){
818
+ if (this.hasOwnProperty(key)) delete this[key];
819
+ return this;
820
+ },
821
+
822
+ get: function(key){
823
+ return (this.hasOwnProperty(key)) ? this[key] : null;
824
+ },
825
+
826
+ set: function(key, value){
827
+ if (!this[key] || this.hasOwnProperty(key)) this[key] = value;
828
+ return this;
829
+ },
830
+
831
+ empty: function(){
832
+ Hash.each(this, function(value, key){
833
+ delete this[key];
834
+ }, this);
835
+ return this;
836
+ },
837
+
838
+ include: function(key, value){
839
+ var k = this[key];
840
+ if (k == undefined) this[key] = value;
841
+ return this;
842
+ },
843
+
844
+ map: function(fn, bind){
845
+ var results = new Hash;
846
+ Hash.each(this, function(value, key){
847
+ results.set(key, fn.call(bind, value, key, this));
848
+ }, this);
849
+ return results;
850
+ },
851
+
852
+ filter: function(fn, bind){
853
+ var results = new Hash;
854
+ Hash.each(this, function(value, key){
855
+ if (fn.call(bind, value, key, this)) results.set(key, value);
856
+ }, this);
857
+ return results;
858
+ },
859
+
860
+ every: function(fn, bind){
861
+ for (var key in this){
862
+ if (this.hasOwnProperty(key) && !fn.call(bind, this[key], key)) return false;
863
+ }
864
+ return true;
865
+ },
866
+
867
+ some: function(fn, bind){
868
+ for (var key in this){
869
+ if (this.hasOwnProperty(key) && fn.call(bind, this[key], key)) return true;
870
+ }
871
+ return false;
872
+ },
873
+
874
+ getKeys: function(){
875
+ var keys = [];
876
+ Hash.each(this, function(value, key){
877
+ keys.push(key);
878
+ });
879
+ return keys;
880
+ },
881
+
882
+ getValues: function(){
883
+ var values = [];
884
+ Hash.each(this, function(value){
885
+ values.push(value);
886
+ });
887
+ return values;
888
+ },
889
+
890
+ toQueryString: function(base){
891
+ var queryString = [];
892
+ Hash.each(this, function(value, key){
893
+ if (base) key = base + '[' + key + ']';
894
+ var result;
895
+ switch ($type(value)){
896
+ case 'object': result = Hash.toQueryString(value, key); break;
897
+ case 'array':
898
+ var qs = {};
899
+ value.each(function(val, i){
900
+ qs[i] = val;
901
+ });
902
+ result = Hash.toQueryString(qs, key);
903
+ break;
904
+ default: result = key + '=' + encodeURIComponent(value);
905
+ }
906
+ if (value != undefined) queryString.push(result);
907
+ });
908
+
909
+ return queryString.join('&');
910
+ }
911
+
912
+ });
913
+
914
+ Hash.alias({keyOf: 'indexOf', hasValue: 'contains'});
915
+
916
+
917
+ /*
918
+ Script: Event.js
919
+ Contains the Event Native, to make the event object completely crossbrowser.
920
+
921
+ License:
922
+ MIT-style license.
923
+ */
924
+
925
+ var Event = new Native({
926
+
927
+ name: 'Event',
928
+
929
+ initialize: function(event, win){
930
+ win = win || window;
931
+ var doc = win.document;
932
+ event = event || win.event;
933
+ if (event.$extended) return event;
934
+ this.$extended = true;
935
+ var type = event.type;
936
+ var target = event.target || event.srcElement;
937
+ while (target && target.nodeType == 3) target = target.parentNode;
938
+
939
+ if (type.test(/key/)){
940
+ var code = event.which || event.keyCode;
941
+ var key = Event.Keys.keyOf(code);
942
+ if (type == 'keydown'){
943
+ var fKey = code - 111;
944
+ if (fKey > 0 && fKey < 13) key = 'f' + fKey;
945
+ }
946
+ key = key || String.fromCharCode(code).toLowerCase();
947
+ } else if (type.match(/(click|mouse|menu)/i)){
948
+ doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
949
+ var page = {
950
+ x: event.pageX || event.clientX + doc.scrollLeft,
951
+ y: event.pageY || event.clientY + doc.scrollTop
952
+ };
953
+ var client = {
954
+ x: (event.pageX) ? event.pageX - win.pageXOffset : event.clientX,
955
+ y: (event.pageY) ? event.pageY - win.pageYOffset : event.clientY
956
+ };
957
+ if (type.match(/DOMMouseScroll|mousewheel/)){
958
+ var wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
959
+ }
960
+ var rightClick = (event.which == 3) || (event.button == 2);
961
+ var related = null;
962
+ if (type.match(/over|out/)){
963
+ switch (type){
964
+ case 'mouseover': related = event.relatedTarget || event.fromElement; break;
965
+ case 'mouseout': related = event.relatedTarget || event.toElement;
966
+ }
967
+ if (!(function(){
968
+ while (related && related.nodeType == 3) related = related.parentNode;
969
+ return true;
970
+ }).create({attempt: Browser.Engine.gecko})()) related = false;
971
+ }
972
+ }
973
+
974
+ return $extend(this, {
975
+ event: event,
976
+ type: type,
977
+
978
+ page: page,
979
+ client: client,
980
+ rightClick: rightClick,
981
+
982
+ wheel: wheel,
983
+
984
+ relatedTarget: related,
985
+ target: target,
986
+
987
+ code: code,
988
+ key: key,
989
+
990
+ shift: event.shiftKey,
991
+ control: event.ctrlKey,
992
+ alt: event.altKey,
993
+ meta: event.metaKey
994
+ });
995
+ }
996
+
997
+ });
998
+
999
+ Event.Keys = new Hash({
1000
+ 'enter': 13,
1001
+ 'up': 38,
1002
+ 'down': 40,
1003
+ 'left': 37,
1004
+ 'right': 39,
1005
+ 'esc': 27,
1006
+ 'space': 32,
1007
+ 'backspace': 8,
1008
+ 'tab': 9,
1009
+ 'delete': 46
1010
+ });
1011
+
1012
+ Event.implement({
1013
+
1014
+ stop: function(){
1015
+ return this.stopPropagation().preventDefault();
1016
+ },
1017
+
1018
+ stopPropagation: function(){
1019
+ if (this.event.stopPropagation) this.event.stopPropagation();
1020
+ else this.event.cancelBubble = true;
1021
+ return this;
1022
+ },
1023
+
1024
+ preventDefault: function(){
1025
+ if (this.event.preventDefault) this.event.preventDefault();
1026
+ else this.event.returnValue = false;
1027
+ return this;
1028
+ }
1029
+
1030
+ });
1031
+
1032
+
1033
+ /*
1034
+ Script: Class.js
1035
+ Contains the Class Function for easily creating, extending, and implementing reusable Classes.
1036
+
1037
+ License:
1038
+ MIT-style license.
1039
+ */
1040
+
1041
+ var Class = new Native({
1042
+
1043
+ name: 'Class',
1044
+
1045
+ initialize: function(properties){
1046
+ properties = properties || {};
1047
+ var klass = function(){
1048
+ for (var key in this){
1049
+ if ($type(this[key]) != 'function') this[key] = $unlink(this[key]);
1050
+ }
1051
+ this.constructor = klass;
1052
+ if (Class.prototyping) return this;
1053
+ var instance = (this.initialize) ? this.initialize.apply(this, arguments) : this;
1054
+ if (this.options && this.options.initialize) this.options.initialize.call(this);
1055
+ return instance;
1056
+ };
1057
+
1058
+ for (var mutator in Class.Mutators){
1059
+ if (!properties[mutator]) continue;
1060
+ properties = Class.Mutators[mutator](properties, properties[mutator]);
1061
+ delete properties[mutator];
1062
+ }
1063
+
1064
+ $extend(klass, this);
1065
+ klass.constructor = Class;
1066
+ klass.prototype = properties;
1067
+ return klass;
1068
+ }
1069
+
1070
+ });
1071
+
1072
+ Class.Mutators = {
1073
+
1074
+ Extends: function(self, klass){
1075
+ Class.prototyping = klass.prototype;
1076
+ var subclass = new klass;
1077
+ delete subclass.parent;
1078
+ subclass = Class.inherit(subclass, self);
1079
+ delete Class.prototyping;
1080
+ return subclass;
1081
+ },
1082
+
1083
+ Implements: function(self, klasses){
1084
+ $splat(klasses).each(function(klass){
1085
+ Class.prototying = klass;
1086
+ $extend(self, ($type(klass) == 'class') ? new klass : klass);
1087
+ delete Class.prototyping;
1088
+ });
1089
+ return self;
1090
+ }
1091
+
1092
+ };
1093
+
1094
+ Class.extend({
1095
+
1096
+ inherit: function(object, properties){
1097
+ var caller = arguments.callee.caller;
1098
+ for (var key in properties){
1099
+ var override = properties[key];
1100
+ var previous = object[key];
1101
+ var type = $type(override);
1102
+ if (previous && type == 'function'){
1103
+ if (override != previous){
1104
+ if (caller){
1105
+ override.__parent = previous;
1106
+ object[key] = override;
1107
+ } else {
1108
+ Class.override(object, key, override);
1109
+ }
1110
+ }
1111
+ } else if(type == 'object'){
1112
+ object[key] = $merge(previous, override);
1113
+ } else {
1114
+ object[key] = override;
1115
+ }
1116
+ }
1117
+
1118
+ if (caller) object.parent = function(){
1119
+ return arguments.callee.caller.__parent.apply(this, arguments);
1120
+ };
1121
+
1122
+ return object;
1123
+ },
1124
+
1125
+ override: function(object, name, method){
1126
+ var parent = Class.prototyping;
1127
+ if (parent && object[name] != parent[name]) parent = null;
1128
+ var override = function(){
1129
+ var previous = this.parent;
1130
+ this.parent = parent ? parent[name] : object[name];
1131
+ var value = method.apply(this, arguments);
1132
+ this.parent = previous;
1133
+ return value;
1134
+ };
1135
+ object[name] = override;
1136
+ }
1137
+
1138
+ });
1139
+
1140
+ Class.implement({
1141
+
1142
+ implement: function(){
1143
+ var proto = this.prototype;
1144
+ $each(arguments, function(properties){
1145
+ Class.inherit(proto, properties);
1146
+ });
1147
+ return this;
1148
+ }
1149
+
1150
+ });
1151
+
1152
+
1153
+ /*
1154
+ Script: Class.Extras.js
1155
+ Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.
1156
+
1157
+ License:
1158
+ MIT-style license.
1159
+ */
1160
+
1161
+ var Chain = new Class({
1162
+
1163
+ $chain: [],
1164
+
1165
+ chain: function(){
1166
+ this.$chain.extend(Array.flatten(arguments));
1167
+ return this;
1168
+ },
1169
+
1170
+ callChain: function(){
1171
+ return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;
1172
+ },
1173
+
1174
+ clearChain: function(){
1175
+ this.$chain.empty();
1176
+ return this;
1177
+ }
1178
+
1179
+ });
1180
+
1181
+ var Events = new Class({
1182
+
1183
+ $events: {},
1184
+
1185
+ addEvent: function(type, fn, internal){
1186
+ type = Events.removeOn(type);
1187
+ if (fn != $empty){
1188
+ this.$events[type] = this.$events[type] || [];
1189
+ this.$events[type].include(fn);
1190
+ if (internal) fn.internal = true;
1191
+ }
1192
+ return this;
1193
+ },
1194
+
1195
+ addEvents: function(events){
1196
+ for (var type in events) this.addEvent(type, events[type]);
1197
+ return this;
1198
+ },
1199
+
1200
+ fireEvent: function(type, args, delay){
1201
+ type = Events.removeOn(type);
1202
+ if (!this.$events || !this.$events[type]) return this;
1203
+ this.$events[type].each(function(fn){
1204
+ fn.create({'bind': this, 'delay': delay, 'arguments': args})();
1205
+ }, this);
1206
+ return this;
1207
+ },
1208
+
1209
+ removeEvent: function(type, fn){
1210
+ type = Events.removeOn(type);
1211
+ if (!this.$events[type]) return this;
1212
+ if (!fn.internal) this.$events[type].erase(fn);
1213
+ return this;
1214
+ },
1215
+
1216
+ removeEvents: function(events){
1217
+ if ($type(events) == 'object'){
1218
+ for (var type in events) this.removeEvent(type, events[type]);
1219
+ return this;
1220
+ }
1221
+ if (events) events = Events.removeOn(events);
1222
+ for (var type in this.$events){
1223
+ if (events && events != type) continue;
1224
+ var fns = this.$events[type];
1225
+ for (var i = fns.length; i--; i) this.removeEvent(type, fns[i]);
1226
+ }
1227
+ return this;
1228
+ }
1229
+
1230
+ });
1231
+
1232
+ Events.removeOn = function(string){
1233
+ return string.replace(/^on([A-Z])/, function(full, first) {
1234
+ return first.toLowerCase();
1235
+ });
1236
+ };
1237
+
1238
+ var Options = new Class({
1239
+
1240
+ setOptions: function(){
1241
+ this.options = $merge.run([this.options].extend(arguments));
1242
+ if (!this.addEvent) return this;
1243
+ for (var option in this.options){
1244
+ if ($type(this.options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
1245
+ this.addEvent(option, this.options[option]);
1246
+ delete this.options[option];
1247
+ }
1248
+ return this;
1249
+ }
1250
+
1251
+ });
1252
+
1253
+
1254
+ /*
1255
+ Script: Element.js
1256
+ One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser,
1257
+ time-saver methods to let you easily work with HTML Elements.
1258
+
1259
+ License:
1260
+ MIT-style license.
1261
+ */
1262
+
1263
+ var Element = new Native({
1264
+
1265
+ name: 'Element',
1266
+
1267
+ legacy: window.Element,
1268
+
1269
+ initialize: function(tag, props){
1270
+ var konstructor = Element.Constructors.get(tag);
1271
+ if (konstructor) return konstructor(props);
1272
+ if (typeof tag == 'string') return document.newElement(tag, props);
1273
+ return $(tag).set(props);
1274
+ },
1275
+
1276
+ afterImplement: function(key, value){
1277
+ Element.Prototype[key] = value;
1278
+ if (Array[key]) return;
1279
+ Elements.implement(key, function(){
1280
+ var items = [], elements = true;
1281
+ for (var i = 0, j = this.length; i < j; i++){
1282
+ var returns = this[i][key].apply(this[i], arguments);
1283
+ items.push(returns);
1284
+ if (elements) elements = ($type(returns) == 'element');
1285
+ }
1286
+ return (elements) ? new Elements(items) : items;
1287
+ });
1288
+ }
1289
+
1290
+ });
1291
+
1292
+ Element.Prototype = {$family: {name: 'element'}};
1293
+
1294
+ Element.Constructors = new Hash;
1295
+
1296
+ var IFrame = new Native({
1297
+
1298
+ name: 'IFrame',
1299
+
1300
+ generics: false,
1301
+
1302
+ initialize: function(){
1303
+ var params = Array.link(arguments, {properties: Object.type, iframe: $defined});
1304
+ var props = params.properties || {};
1305
+ var iframe = $(params.iframe) || false;
1306
+ var onload = props.onload || $empty;
1307
+ delete props.onload;
1308
+ props.id = props.name = $pick(props.id, props.name, iframe.id, iframe.name, 'IFrame_' + $time());
1309
+ iframe = new Element(iframe || 'iframe', props);
1310
+ var onFrameLoad = function(){
1311
+ var host = $try(function(){
1312
+ return iframe.contentWindow.location.host;
1313
+ });
1314
+ if (host && host == window.location.host){
1315
+ var win = new Window(iframe.contentWindow);
1316
+ new Document(iframe.contentWindow.document);
1317
+ $extend(win.Element.prototype, Element.Prototype);
1318
+ }
1319
+ onload.call(iframe.contentWindow, iframe.contentWindow.document);
1320
+ };
1321
+ (window.frames[props.id]) ? onFrameLoad() : iframe.addListener('load', onFrameLoad);
1322
+ return iframe;
1323
+ }
1324
+
1325
+ });
1326
+
1327
+ var Elements = new Native({
1328
+
1329
+ initialize: function(elements, options){
1330
+ options = $extend({ddup: true, cash: true}, options);
1331
+ elements = elements || [];
1332
+ if (options.ddup || options.cash){
1333
+ var uniques = {}, returned = [];
1334
+ for (var i = 0, l = elements.length; i < l; i++){
1335
+ var el = $.element(elements[i], !options.cash);
1336
+ if (options.ddup){
1337
+ if (uniques[el.uid]) continue;
1338
+ uniques[el.uid] = true;
1339
+ }
1340
+ returned.push(el);
1341
+ }
1342
+ elements = returned;
1343
+ }
1344
+ return (options.cash) ? $extend(elements, this) : elements;
1345
+ }
1346
+
1347
+ });
1348
+
1349
+ Elements.implement({
1350
+
1351
+ filter: function(filter, bind){
1352
+ if (!filter) return this;
1353
+ return new Elements(Array.filter(this, (typeof filter == 'string') ? function(item){
1354
+ return item.match(filter);
1355
+ } : filter, bind));
1356
+ }
1357
+
1358
+ });
1359
+
1360
+ Document.implement({
1361
+
1362
+ newElement: function(tag, props){
1363
+ if (Browser.Engine.trident && props){
1364
+ ['name', 'type', 'checked'].each(function(attribute){
1365
+ if (!props[attribute]) return;
1366
+ tag += ' ' + attribute + '="' + props[attribute] + '"';
1367
+ if (attribute != 'checked') delete props[attribute];
1368
+ });
1369
+ tag = '<' + tag + '>';
1370
+ }
1371
+ return $.element(this.createElement(tag)).set(props);
1372
+ },
1373
+
1374
+ newTextNode: function(text){
1375
+ return this.createTextNode(text);
1376
+ },
1377
+
1378
+ getDocument: function(){
1379
+ return this;
1380
+ },
1381
+
1382
+ getWindow: function(){
1383
+ return this.window;
1384
+ }
1385
+
1386
+ });
1387
+
1388
+ Window.implement({
1389
+
1390
+ $: function(el, nocash){
1391
+ if (el && el.$family && el.uid) return el;
1392
+ var type = $type(el);
1393
+ return ($[type]) ? $[type](el, nocash, this.document) : null;
1394
+ },
1395
+
1396
+ $$: function(selector){
1397
+ if (arguments.length == 1 && typeof selector == 'string') return this.document.getElements(selector);
1398
+ var elements = [];
1399
+ var args = Array.flatten(arguments);
1400
+ for (var i = 0, l = args.length; i < l; i++){
1401
+ var item = args[i];
1402
+ switch ($type(item)){
1403
+ case 'element': elements.push(item); break;
1404
+ case 'string': elements.extend(this.document.getElements(item, true));
1405
+ }
1406
+ }
1407
+ return new Elements(elements);
1408
+ },
1409
+
1410
+ getDocument: function(){
1411
+ return this.document;
1412
+ },
1413
+
1414
+ getWindow: function(){
1415
+ return this;
1416
+ }
1417
+
1418
+ });
1419
+
1420
+ $.string = function(id, nocash, doc){
1421
+ id = doc.getElementById(id);
1422
+ return (id) ? $.element(id, nocash) : null;
1423
+ };
1424
+
1425
+ $.element = function(el, nocash){
1426
+ $uid(el);
1427
+ if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){
1428
+ var proto = Element.Prototype;
1429
+ for (var p in proto) el[p] = proto[p];
1430
+ };
1431
+ return el;
1432
+ };
1433
+
1434
+ $.object = function(obj, nocash, doc){
1435
+ if (obj.toElement) return $.element(obj.toElement(doc), nocash);
1436
+ return null;
1437
+ };
1438
+
1439
+ $.textnode = $.whitespace = $.window = $.document = $arguments(0);
1440
+
1441
+ Native.implement([Element, Document], {
1442
+
1443
+ getElement: function(selector, nocash){
1444
+ return $(this.getElements(selector, true)[0] || null, nocash);
1445
+ },
1446
+
1447
+ getElements: function(tags, nocash){
1448
+ tags = tags.split(',');
1449
+ var elements = [];
1450
+ var ddup = (tags.length > 1);
1451
+ tags.each(function(tag){
1452
+ var partial = this.getElementsByTagName(tag.trim());
1453
+ (ddup) ? elements.extend(partial) : elements = partial;
1454
+ }, this);
1455
+ return new Elements(elements, {ddup: ddup, cash: !nocash});
1456
+ }
1457
+
1458
+ });
1459
+
1460
+ (function(){
1461
+
1462
+ var collected = {}, storage = {};
1463
+ var props = {input: 'checked', option: 'selected', textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerHTML' : 'value'};
1464
+
1465
+ var get = function(uid){
1466
+ return (storage[uid] || (storage[uid] = {}));
1467
+ };
1468
+
1469
+ var clean = function(item, retain){
1470
+ if (!item) return;
1471
+ var uid = item.uid;
1472
+ if (Browser.Engine.trident){
1473
+ if (item.clearAttributes){
1474
+ var clone = retain && item.cloneNode(false);
1475
+ item.clearAttributes();
1476
+ if (clone) item.mergeAttributes(clone);
1477
+ } else if (item.removeEvents){
1478
+ item.removeEvents();
1479
+ }
1480
+ if ((/object/i).test(item.tagName)){
1481
+ for (var p in item){
1482
+ if (typeof item[p] == 'function') item[p] = $empty;
1483
+ }
1484
+ Element.dispose(item);
1485
+ }
1486
+ }
1487
+ if (!uid) return;
1488
+ collected[uid] = storage[uid] = null;
1489
+ };
1490
+
1491
+ var purge = function(){
1492
+ Hash.each(collected, clean);
1493
+ if (Browser.Engine.trident) $A(document.getElementsByTagName('object')).each(clean);
1494
+ if (window.CollectGarbage) CollectGarbage();
1495
+ collected = storage = null;
1496
+ };
1497
+
1498
+ var walk = function(element, walk, start, match, all, nocash){
1499
+ var el = element[start || walk];
1500
+ var elements = [];
1501
+ while (el){
1502
+ if (el.nodeType == 1 && (!match || Element.match(el, match))){
1503
+ if (!all) return $(el, nocash);
1504
+ elements.push(el);
1505
+ }
1506
+ el = el[walk];
1507
+ }
1508
+ return (all) ? new Elements(elements, {ddup: false, cash: !nocash}) : null;
1509
+ };
1510
+
1511
+ var attributes = {
1512
+ 'html': 'innerHTML',
1513
+ 'class': 'className',
1514
+ 'for': 'htmlFor',
1515
+ 'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent'
1516
+ };
1517
+ var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'];
1518
+ var camels = ['value', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'];
1519
+
1520
+ Hash.extend(attributes, bools.associate(bools));
1521
+ Hash.extend(attributes, camels.associate(camels.map(String.toLowerCase)));
1522
+
1523
+ var inserters = {
1524
+
1525
+ before: function(context, element){
1526
+ if (element.parentNode) element.parentNode.insertBefore(context, element);
1527
+ },
1528
+
1529
+ after: function(context, element){
1530
+ if (!element.parentNode) return;
1531
+ var next = element.nextSibling;
1532
+ (next) ? element.parentNode.insertBefore(context, next) : element.parentNode.appendChild(context);
1533
+ },
1534
+
1535
+ bottom: function(context, element){
1536
+ element.appendChild(context);
1537
+ },
1538
+
1539
+ top: function(context, element){
1540
+ var first = element.firstChild;
1541
+ (first) ? element.insertBefore(context, first) : element.appendChild(context);
1542
+ }
1543
+
1544
+ };
1545
+
1546
+ inserters.inside = inserters.bottom;
1547
+
1548
+ Hash.each(inserters, function(inserter, where){
1549
+
1550
+ where = where.capitalize();
1551
+
1552
+ Element.implement('inject' + where, function(el){
1553
+ inserter(this, $(el, true));
1554
+ return this;
1555
+ });
1556
+
1557
+ Element.implement('grab' + where, function(el){
1558
+ inserter($(el, true), this);
1559
+ return this;
1560
+ });
1561
+
1562
+ });
1563
+
1564
+ Element.implement({
1565
+
1566
+ set: function(prop, value){
1567
+ switch ($type(prop)){
1568
+ case 'object':
1569
+ for (var p in prop) this.set(p, prop[p]);
1570
+ break;
1571
+ case 'string':
1572
+ var property = Element.Properties.get(prop);
1573
+ (property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value);
1574
+ }
1575
+ return this;
1576
+ },
1577
+
1578
+ get: function(prop){
1579
+ var property = Element.Properties.get(prop);
1580
+ return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop);
1581
+ },
1582
+
1583
+ erase: function(prop){
1584
+ var property = Element.Properties.get(prop);
1585
+ (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
1586
+ return this;
1587
+ },
1588
+
1589
+ setProperty: function(attribute, value){
1590
+ var key = attributes[attribute];
1591
+ if (value == undefined) return this.removeProperty(attribute);
1592
+ if (key && bools[attribute]) value = !!value;
1593
+ (key) ? this[key] = value : this.setAttribute(attribute, '' + value);
1594
+ return this;
1595
+ },
1596
+
1597
+ setProperties: function(attributes){
1598
+ for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);
1599
+ return this;
1600
+ },
1601
+
1602
+ getProperty: function(attribute){
1603
+ var key = attributes[attribute];
1604
+ var value = (key) ? this[key] : this.getAttribute(attribute, 2);
1605
+ return (bools[attribute]) ? !!value : (key) ? value : value || null;
1606
+ },
1607
+
1608
+ getProperties: function(){
1609
+ var args = $A(arguments);
1610
+ return args.map(this.getProperty, this).associate(args);
1611
+ },
1612
+
1613
+ removeProperty: function(attribute){
1614
+ var key = attributes[attribute];
1615
+ (key) ? this[key] = (key && bools[attribute]) ? false : '' : this.removeAttribute(attribute);
1616
+ return this;
1617
+ },
1618
+
1619
+ removeProperties: function(){
1620
+ Array.each(arguments, this.removeProperty, this);
1621
+ return this;
1622
+ },
1623
+
1624
+ hasClass: function(className){
1625
+ return this.className.contains(className, ' ');
1626
+ },
1627
+
1628
+ addClass: function(className){
1629
+ if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
1630
+ return this;
1631
+ },
1632
+
1633
+ removeClass: function(className){
1634
+ this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
1635
+ return this;
1636
+ },
1637
+
1638
+ toggleClass: function(className){
1639
+ return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
1640
+ },
1641
+
1642
+ adopt: function(){
1643
+ Array.flatten(arguments).each(function(element){
1644
+ element = $(element, true);
1645
+ if (element) this.appendChild(element);
1646
+ }, this);
1647
+ return this;
1648
+ },
1649
+
1650
+ appendText: function(text, where){
1651
+ return this.grab(this.getDocument().newTextNode(text), where);
1652
+ },
1653
+
1654
+ grab: function(el, where){
1655
+ inserters[where || 'bottom']($(el, true), this);
1656
+ return this;
1657
+ },
1658
+
1659
+ inject: function(el, where){
1660
+ inserters[where || 'bottom'](this, $(el, true));
1661
+ return this;
1662
+ },
1663
+
1664
+ replaces: function(el){
1665
+ el = $(el, true);
1666
+ el.parentNode.replaceChild(this, el);
1667
+ return this;
1668
+ },
1669
+
1670
+ wraps: function(el, where){
1671
+ el = $(el, true);
1672
+ return this.replaces(el).grab(el, where);
1673
+ },
1674
+
1675
+ getPrevious: function(match, nocash){
1676
+ return walk(this, 'previousSibling', null, match, false, nocash);
1677
+ },
1678
+
1679
+ getAllPrevious: function(match, nocash){
1680
+ return walk(this, 'previousSibling', null, match, true, nocash);
1681
+ },
1682
+
1683
+ getNext: function(match, nocash){
1684
+ return walk(this, 'nextSibling', null, match, false, nocash);
1685
+ },
1686
+
1687
+ getAllNext: function(match, nocash){
1688
+ return walk(this, 'nextSibling', null, match, true, nocash);
1689
+ },
1690
+
1691
+ getFirst: function(match, nocash){
1692
+ return walk(this, 'nextSibling', 'firstChild', match, false, nocash);
1693
+ },
1694
+
1695
+ getLast: function(match, nocash){
1696
+ return walk(this, 'previousSibling', 'lastChild', match, false, nocash);
1697
+ },
1698
+
1699
+ getParent: function(match, nocash){
1700
+ return walk(this, 'parentNode', null, match, false, nocash);
1701
+ },
1702
+
1703
+ getParents: function(match, nocash){
1704
+ return walk(this, 'parentNode', null, match, true, nocash);
1705
+ },
1706
+
1707
+ getChildren: function(match, nocash){
1708
+ return walk(this, 'nextSibling', 'firstChild', match, true, nocash);
1709
+ },
1710
+
1711
+ getWindow: function(){
1712
+ return this.ownerDocument.window;
1713
+ },
1714
+
1715
+ getDocument: function(){
1716
+ return this.ownerDocument;
1717
+ },
1718
+
1719
+ getElementById: function(id, nocash){
1720
+ var el = this.ownerDocument.getElementById(id);
1721
+ if (!el) return null;
1722
+ for (var parent = el.parentNode; parent != this; parent = parent.parentNode){
1723
+ if (!parent) return null;
1724
+ }
1725
+ return $.element(el, nocash);
1726
+ },
1727
+
1728
+ getSelected: function(){
1729
+ return new Elements($A(this.options).filter(function(option){
1730
+ return option.selected;
1731
+ }));
1732
+ },
1733
+
1734
+ getComputedStyle: function(property){
1735
+ if (this.currentStyle) return this.currentStyle[property.camelCase()];
1736
+ var computed = this.getDocument().defaultView.getComputedStyle(this, null);
1737
+ return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;
1738
+ },
1739
+
1740
+ toQueryString: function(){
1741
+ var queryString = [];
1742
+ this.getElements('input, select, textarea', true).each(function(el){
1743
+ if (!el.name || el.disabled) return;
1744
+ var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){
1745
+ return opt.value;
1746
+ }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;
1747
+ $splat(value).each(function(val){
1748
+ if (typeof val != 'undefined') queryString.push(el.name + '=' + encodeURIComponent(val));
1749
+ });
1750
+ });
1751
+ return queryString.join('&');
1752
+ },
1753
+
1754
+ clone: function(contents, keepid){
1755
+ contents = contents !== false;
1756
+ var clone = this.cloneNode(contents);
1757
+ var clean = function(node, element){
1758
+ if (!keepid) node.removeAttribute('id');
1759
+ if (Browser.Engine.trident){
1760
+ node.clearAttributes();
1761
+ node.mergeAttributes(element);
1762
+ node.removeAttribute('uid');
1763
+ if (node.options){
1764
+ var no = node.options, eo = element.options;
1765
+ for (var j = no.length; j--;) no[j].selected = eo[j].selected;
1766
+ }
1767
+ }
1768
+ var prop = props[element.tagName.toLowerCase()];
1769
+ if (prop && element[prop]) node[prop] = element[prop];
1770
+ };
1771
+
1772
+ if (contents){
1773
+ var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*');
1774
+ for (var i = ce.length; i--;) clean(ce[i], te[i]);
1775
+ }
1776
+
1777
+ clean(clone, this);
1778
+ return $(clone);
1779
+ },
1780
+
1781
+ destroy: function(){
1782
+ Element.empty(this);
1783
+ Element.dispose(this);
1784
+ clean(this, true);
1785
+ return null;
1786
+ },
1787
+
1788
+ empty: function(){
1789
+ $A(this.childNodes).each(function(node){
1790
+ Element.destroy(node);
1791
+ });
1792
+ return this;
1793
+ },
1794
+
1795
+ dispose: function(){
1796
+ return (this.parentNode) ? this.parentNode.removeChild(this) : this;
1797
+ },
1798
+
1799
+ hasChild: function(el){
1800
+ el = $(el, true);
1801
+ if (!el) return false;
1802
+ if (Browser.Engine.webkit && Browser.Engine.version < 420) return $A(this.getElementsByTagName(el.tagName)).contains(el);
1803
+ return (this.contains) ? (this != el && this.contains(el)) : !!(this.compareDocumentPosition(el) & 16);
1804
+ },
1805
+
1806
+ match: function(tag){
1807
+ return (!tag || (tag == this) || (Element.get(this, 'tag') == tag));
1808
+ }
1809
+
1810
+ });
1811
+
1812
+ Native.implement([Element, Window, Document], {
1813
+
1814
+ addListener: function(type, fn){
1815
+ if (type == 'unload'){
1816
+ var old = fn, self = this;
1817
+ fn = function(){
1818
+ self.removeListener('unload', fn);
1819
+ old();
1820
+ };
1821
+ } else {
1822
+ collected[this.uid] = this;
1823
+ }
1824
+ if (this.addEventListener) this.addEventListener(type, fn, false);
1825
+ else this.attachEvent('on' + type, fn);
1826
+ return this;
1827
+ },
1828
+
1829
+ removeListener: function(type, fn){
1830
+ if (this.removeEventListener) this.removeEventListener(type, fn, false);
1831
+ else this.detachEvent('on' + type, fn);
1832
+ return this;
1833
+ },
1834
+
1835
+ retrieve: function(property, dflt){
1836
+ var storage = get(this.uid), prop = storage[property];
1837
+ if (dflt != undefined && prop == undefined) prop = storage[property] = dflt;
1838
+ return $pick(prop);
1839
+ },
1840
+
1841
+ store: function(property, value){
1842
+ var storage = get(this.uid);
1843
+ storage[property] = value;
1844
+ return this;
1845
+ },
1846
+
1847
+ eliminate: function(property){
1848
+ var storage = get(this.uid);
1849
+ delete storage[property];
1850
+ return this;
1851
+ }
1852
+
1853
+ });
1854
+
1855
+ window.addListener('unload', purge);
1856
+
1857
+ })();
1858
+
1859
+ Element.Properties = new Hash;
1860
+
1861
+ Element.Properties.style = {
1862
+
1863
+ set: function(style){
1864
+ this.style.cssText = style;
1865
+ },
1866
+
1867
+ get: function(){
1868
+ return this.style.cssText;
1869
+ },
1870
+
1871
+ erase: function(){
1872
+ this.style.cssText = '';
1873
+ }
1874
+
1875
+ };
1876
+
1877
+ Element.Properties.tag = {
1878
+
1879
+ get: function(){
1880
+ return this.tagName.toLowerCase();
1881
+ }
1882
+
1883
+ };
1884
+
1885
+ Element.Properties.html = (function(){
1886
+ var wrapper = document.createElement('div');
1887
+
1888
+ var translations = {
1889
+ table: [1, '<table>', '</table>'],
1890
+ select: [1, '<select>', '</select>'],
1891
+ tbody: [2, '<table><tbody>', '</tbody></table>'],
1892
+ tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']
1893
+ };
1894
+ translations.thead = translations.tfoot = translations.tbody;
1895
+
1896
+ var html = {
1897
+ set: function(){
1898
+ var html = Array.flatten(arguments).join('');
1899
+ var wrap = Browser.Engine.trident && translations[this.get('tag')];
1900
+ if (wrap){
1901
+ var first = wrapper;
1902
+ first.innerHTML = wrap[1] + html + wrap[2];
1903
+ for (var i = wrap[0]; i--;) first = first.firstChild;
1904
+ this.empty().adopt(first.childNodes);
1905
+ } else {
1906
+ this.innerHTML = html;
1907
+ }
1908
+ }
1909
+ };
1910
+
1911
+ html.erase = html.set;
1912
+
1913
+ return html;
1914
+ })();
1915
+
1916
+ if (Browser.Engine.webkit && Browser.Engine.version < 420) Element.Properties.text = {
1917
+ get: function(){
1918
+ if (this.innerText) return this.innerText;
1919
+ var temp = this.ownerDocument.newElement('div', {html: this.innerHTML}).inject(this.ownerDocument.body);
1920
+ var text = temp.innerText;
1921
+ temp.destroy();
1922
+ return text;
1923
+ }
1924
+ };
1925
+
1926
+
1927
+ /*
1928
+ Script: Element.Event.js
1929
+ Contains Element methods for dealing with events, and custom Events.
1930
+
1931
+ License:
1932
+ MIT-style license.
1933
+ */
1934
+
1935
+ Element.Properties.events = {set: function(events){
1936
+ this.addEvents(events);
1937
+ }};
1938
+
1939
+ Native.implement([Element, Window, Document], {
1940
+
1941
+ addEvent: function(type, fn){
1942
+ var events = this.retrieve('events', {});
1943
+ events[type] = events[type] || {'keys': [], 'values': []};
1944
+ if (events[type].keys.contains(fn)) return this;
1945
+ events[type].keys.push(fn);
1946
+ var realType = type, custom = Element.Events.get(type), condition = fn, self = this;
1947
+ if (custom){
1948
+ if (custom.onAdd) custom.onAdd.call(this, fn);
1949
+ if (custom.condition){
1950
+ condition = function(event){
1951
+ if (custom.condition.call(this, event)) return fn.call(this, event);
1952
+ return true;
1953
+ };
1954
+ }
1955
+ realType = custom.base || realType;
1956
+ }
1957
+ var defn = function(){
1958
+ return fn.call(self);
1959
+ };
1960
+ var nativeEvent = Element.NativeEvents[realType];
1961
+ if (nativeEvent){
1962
+ if (nativeEvent == 2){
1963
+ defn = function(event){
1964
+ event = new Event(event, self.getWindow());
1965
+ if (condition.call(self, event) === false) event.stop();
1966
+ };
1967
+ }
1968
+ this.addListener(realType, defn);
1969
+ }
1970
+ events[type].values.push(defn);
1971
+ return this;
1972
+ },
1973
+
1974
+ removeEvent: function(type, fn){
1975
+ var events = this.retrieve('events');
1976
+ if (!events || !events[type]) return this;
1977
+ var pos = events[type].keys.indexOf(fn);
1978
+ if (pos == -1) return this;
1979
+ events[type].keys.splice(pos, 1);
1980
+ var value = events[type].values.splice(pos, 1)[0];
1981
+ var custom = Element.Events.get(type);
1982
+ if (custom){
1983
+ if (custom.onRemove) custom.onRemove.call(this, fn);
1984
+ type = custom.base || type;
1985
+ }
1986
+ return (Element.NativeEvents[type]) ? this.removeListener(type, value) : this;
1987
+ },
1988
+
1989
+ addEvents: function(events){
1990
+ for (var event in events) this.addEvent(event, events[event]);
1991
+ return this;
1992
+ },
1993
+
1994
+ removeEvents: function(events){
1995
+ if ($type(events) == 'object'){
1996
+ for (var type in events) this.removeEvent(type, events[type]);
1997
+ return this;
1998
+ }
1999
+ var attached = this.retrieve('events');
2000
+ if (!attached) return this;
2001
+ if (!events){
2002
+ for (var type in attached) this.removeEvents(type);
2003
+ this.eliminate('events');
2004
+ } else if (attached[events]){
2005
+ while (attached[events].keys[0]) this.removeEvent(events, attached[events].keys[0]);
2006
+ attached[events] = null;
2007
+ }
2008
+ return this;
2009
+ },
2010
+
2011
+ fireEvent: function(type, args, delay){
2012
+ var events = this.retrieve('events');
2013
+ if (!events || !events[type]) return this;
2014
+ events[type].keys.each(function(fn){
2015
+ fn.create({'bind': this, 'delay': delay, 'arguments': args})();
2016
+ }, this);
2017
+ return this;
2018
+ },
2019
+
2020
+ cloneEvents: function(from, type){
2021
+ from = $(from);
2022
+ var fevents = from.retrieve('events');
2023
+ if (!fevents) return this;
2024
+ if (!type){
2025
+ for (var evType in fevents) this.cloneEvents(from, evType);
2026
+ } else if (fevents[type]){
2027
+ fevents[type].keys.each(function(fn){
2028
+ this.addEvent(type, fn);
2029
+ }, this);
2030
+ }
2031
+ return this;
2032
+ }
2033
+
2034
+ });
2035
+
2036
+ Element.NativeEvents = {
2037
+ click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons
2038
+ mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
2039
+ mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement
2040
+ keydown: 2, keypress: 2, keyup: 2, //keyboard
2041
+ focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements
2042
+ load: 1, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window
2043
+ error: 1, abort: 1, scroll: 1 //misc
2044
+ };
2045
+
2046
+ (function(){
2047
+
2048
+ var $check = function(event){
2049
+ var related = event.relatedTarget;
2050
+ if (related == undefined) return true;
2051
+ if (related === false) return false;
2052
+ return ($type(this) != 'document' && related != this && related.prefix != 'xul' && !this.hasChild(related));
2053
+ };
2054
+
2055
+ Element.Events = new Hash({
2056
+
2057
+ mouseenter: {
2058
+ base: 'mouseover',
2059
+ condition: $check
2060
+ },
2061
+
2062
+ mouseleave: {
2063
+ base: 'mouseout',
2064
+ condition: $check
2065
+ },
2066
+
2067
+ mousewheel: {
2068
+ base: (Browser.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel'
2069
+ }
2070
+
2071
+ });
2072
+
2073
+ })();
2074
+
2075
+
2076
+ /*
2077
+ Script: Element.Style.js
2078
+ Contains methods for interacting with the styles of Elements in a fashionable way.
2079
+
2080
+ License:
2081
+ MIT-style license.
2082
+ */
2083
+
2084
+ Element.Properties.styles = {set: function(styles){
2085
+ this.setStyles(styles);
2086
+ }};
2087
+
2088
+ Element.Properties.opacity = {
2089
+
2090
+ set: function(opacity, novisibility){
2091
+ if (!novisibility){
2092
+ if (opacity == 0){
2093
+ if (this.style.visibility != 'hidden') this.style.visibility = 'hidden';
2094
+ } else {
2095
+ if (this.style.visibility != 'visible') this.style.visibility = 'visible';
2096
+ }
2097
+ }
2098
+ if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1;
2099
+ if (Browser.Engine.trident) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';
2100
+ this.style.opacity = opacity;
2101
+ this.store('opacity', opacity);
2102
+ },
2103
+
2104
+ get: function(){
2105
+ return this.retrieve('opacity', 1);
2106
+ }
2107
+
2108
+ };
2109
+
2110
+ Element.implement({
2111
+
2112
+ setOpacity: function(value){
2113
+ return this.set('opacity', value, true);
2114
+ },
2115
+
2116
+ getOpacity: function(){
2117
+ return this.get('opacity');
2118
+ },
2119
+
2120
+ setStyle: function(property, value){
2121
+ switch (property){
2122
+ case 'opacity': return this.set('opacity', parseFloat(value));
2123
+ case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
2124
+ }
2125
+ property = property.camelCase();
2126
+ if ($type(value) != 'string'){
2127
+ var map = (Element.Styles.get(property) || '@').split(' ');
2128
+ value = $splat(value).map(function(val, i){
2129
+ if (!map[i]) return '';
2130
+ return ($type(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;
2131
+ }).join(' ');
2132
+ } else if (value == String(Number(value))){
2133
+ value = Math.round(value);
2134
+ }
2135
+ this.style[property] = value;
2136
+ return this;
2137
+ },
2138
+
2139
+ getStyle: function(property){
2140
+ switch (property){
2141
+ case 'opacity': return this.get('opacity');
2142
+ case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
2143
+ }
2144
+ property = property.camelCase();
2145
+ var result = this.style[property];
2146
+ if (!$chk(result)){
2147
+ result = [];
2148
+ for (var style in Element.ShortStyles){
2149
+ if (property != style) continue;
2150
+ for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));
2151
+ return result.join(' ');
2152
+ }
2153
+ result = this.getComputedStyle(property);
2154
+ }
2155
+ if (result){
2156
+ result = String(result);
2157
+ var color = result.match(/rgba?\([\d\s,]+\)/);
2158
+ if (color) result = result.replace(color[0], color[0].rgbToHex());
2159
+ }
2160
+ if (Browser.Engine.presto || (Browser.Engine.trident && !$chk(parseInt(result)))){
2161
+ if (property.test(/^(height|width)$/)){
2162
+ var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
2163
+ values.each(function(value){
2164
+ size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
2165
+ }, this);
2166
+ return this['offset' + property.capitalize()] - size + 'px';
2167
+ }
2168
+ if ((Browser.Engine.presto) && String(result).test('px')) return result;
2169
+ if (property.test(/(border(.+)Width|margin|padding)/)) return '0px';
2170
+ }
2171
+ return result;
2172
+ },
2173
+
2174
+ setStyles: function(styles){
2175
+ for (var style in styles) this.setStyle(style, styles[style]);
2176
+ return this;
2177
+ },
2178
+
2179
+ getStyles: function(){
2180
+ var result = {};
2181
+ Array.each(arguments, function(key){
2182
+ result[key] = this.getStyle(key);
2183
+ }, this);
2184
+ return result;
2185
+ }
2186
+
2187
+ });
2188
+
2189
+ Element.Styles = new Hash({
2190
+ left: '@px', top: '@px', bottom: '@px', right: '@px',
2191
+ width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
2192
+ backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',
2193
+ fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',
2194
+ margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',
2195
+ borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',
2196
+ zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
2197
+ });
2198
+
2199
+ Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};
2200
+
2201
+ ['Top', 'Right', 'Bottom', 'Left'].each(function(direction){
2202
+ var Short = Element.ShortStyles;
2203
+ var All = Element.Styles;
2204
+ ['margin', 'padding'].each(function(style){
2205
+ var sd = style + direction;
2206
+ Short[style][sd] = All[sd] = '@px';
2207
+ });
2208
+ var bd = 'border' + direction;
2209
+ Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';
2210
+ var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';
2211
+ Short[bd] = {};
2212
+ Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';
2213
+ Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
2214
+ Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
2215
+ });
2216
+
2217
+
2218
+ /*
2219
+ Script: Element.Dimensions.js
2220
+ Contains methods to work with size, scroll, or positioning of Elements and the window object.
2221
+
2222
+ License:
2223
+ MIT-style license.
2224
+
2225
+ Credits:
2226
+ - Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html).
2227
+ - Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html).
2228
+ */
2229
+
2230
+ (function(){
2231
+
2232
+ Element.implement({
2233
+
2234
+ scrollTo: function(x, y){
2235
+ if (isBody(this)){
2236
+ this.getWindow().scrollTo(x, y);
2237
+ } else {
2238
+ this.scrollLeft = x;
2239
+ this.scrollTop = y;
2240
+ }
2241
+ return this;
2242
+ },
2243
+
2244
+ getSize: function(){
2245
+ if (isBody(this)) return this.getWindow().getSize();
2246
+ return {x: this.offsetWidth, y: this.offsetHeight};
2247
+ },
2248
+
2249
+ getScrollSize: function(){
2250
+ if (isBody(this)) return this.getWindow().getScrollSize();
2251
+ return {x: this.scrollWidth, y: this.scrollHeight};
2252
+ },
2253
+
2254
+ getScroll: function(){
2255
+ if (isBody(this)) return this.getWindow().getScroll();
2256
+ return {x: this.scrollLeft, y: this.scrollTop};
2257
+ },
2258
+
2259
+ getScrolls: function(){
2260
+ var element = this, position = {x: 0, y: 0};
2261
+ while (element && !isBody(element)){
2262
+ position.x += element.scrollLeft;
2263
+ position.y += element.scrollTop;
2264
+ element = element.parentNode;
2265
+ }
2266
+ return position;
2267
+ },
2268
+
2269
+ getOffsetParent: function(){
2270
+ var element = this;
2271
+ if (isBody(element)) return null;
2272
+ if (!Browser.Engine.trident) return element.offsetParent;
2273
+ while ((element = element.parentNode) && !isBody(element)){
2274
+ if (styleString(element, 'position') != 'static') return element;
2275
+ }
2276
+ return null;
2277
+ },
2278
+
2279
+ getOffsets: function(){
2280
+ if (Browser.Engine.trident){
2281
+ var bound = this.getBoundingClientRect(), html = this.getDocument().documentElement;
2282
+ return {
2283
+ x: bound.left + html.scrollLeft - html.clientLeft,
2284
+ y: bound.top + html.scrollTop - html.clientTop
2285
+ };
2286
+ }
2287
+
2288
+ var element = this, position = {x: 0, y: 0};
2289
+ if (isBody(this)) return position;
2290
+
2291
+ while (element && !isBody(element)){
2292
+ position.x += element.offsetLeft;
2293
+ position.y += element.offsetTop;
2294
+
2295
+ if (Browser.Engine.gecko){
2296
+ if (!borderBox(element)){
2297
+ position.x += leftBorder(element);
2298
+ position.y += topBorder(element);
2299
+ }
2300
+ var parent = element.parentNode;
2301
+ if (parent && styleString(parent, 'overflow') != 'visible'){
2302
+ position.x += leftBorder(parent);
2303
+ position.y += topBorder(parent);
2304
+ }
2305
+ } else if (element != this && Browser.Engine.webkit){
2306
+ position.x += leftBorder(element);
2307
+ position.y += topBorder(element);
2308
+ }
2309
+
2310
+ element = element.offsetParent;
2311
+ }
2312
+ if (Browser.Engine.gecko && !borderBox(this)){
2313
+ position.x -= leftBorder(this);
2314
+ position.y -= topBorder(this);
2315
+ }
2316
+ return position;
2317
+ },
2318
+
2319
+ getPosition: function(relative){
2320
+ if (isBody(this)) return {x: 0, y: 0};
2321
+ var offset = this.getOffsets(), scroll = this.getScrolls();
2322
+ var position = {x: offset.x - scroll.x, y: offset.y - scroll.y};
2323
+ var relativePosition = (relative && (relative = $(relative))) ? relative.getPosition() : {x: 0, y: 0};
2324
+ return {x: position.x - relativePosition.x, y: position.y - relativePosition.y};
2325
+ },
2326
+
2327
+ getCoordinates: function(element){
2328
+ if (isBody(this)) return this.getWindow().getCoordinates();
2329
+ var position = this.getPosition(element), size = this.getSize();
2330
+ var obj = {left: position.x, top: position.y, width: size.x, height: size.y};
2331
+ obj.right = obj.left + obj.width;
2332
+ obj.bottom = obj.top + obj.height;
2333
+ return obj;
2334
+ },
2335
+
2336
+ computePosition: function(obj){
2337
+ return {left: obj.x - styleNumber(this, 'margin-left'), top: obj.y - styleNumber(this, 'margin-top')};
2338
+ },
2339
+
2340
+ position: function(obj){
2341
+ return this.setStyles(this.computePosition(obj));
2342
+ }
2343
+
2344
+ });
2345
+
2346
+ Native.implement([Document, Window], {
2347
+
2348
+ getSize: function(){
2349
+ var win = this.getWindow();
2350
+ if (Browser.Engine.presto || Browser.Engine.webkit) return {x: win.innerWidth, y: win.innerHeight};
2351
+ var doc = getCompatElement(this);
2352
+ return {x: doc.clientWidth, y: doc.clientHeight};
2353
+ },
2354
+
2355
+ getScroll: function(){
2356
+ var win = this.getWindow();
2357
+ var doc = getCompatElement(this);
2358
+ return {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop};
2359
+ },
2360
+
2361
+ getScrollSize: function(){
2362
+ var doc = getCompatElement(this);
2363
+ var min = this.getSize();
2364
+ return {x: Math.max(doc.scrollWidth, min.x), y: Math.max(doc.scrollHeight, min.y)};
2365
+ },
2366
+
2367
+ getPosition: function(){
2368
+ return {x: 0, y: 0};
2369
+ },
2370
+
2371
+ getCoordinates: function(){
2372
+ var size = this.getSize();
2373
+ return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x};
2374
+ }
2375
+
2376
+ });
2377
+
2378
+ // private methods
2379
+
2380
+ var styleString = Element.getComputedStyle;
2381
+
2382
+ function styleNumber(element, style){
2383
+ return styleString(element, style).toInt() || 0;
2384
+ };
2385
+
2386
+ function borderBox(element){
2387
+ return styleString(element, '-moz-box-sizing') == 'border-box';
2388
+ };
2389
+
2390
+ function topBorder(element){
2391
+ return styleNumber(element, 'border-top-width');
2392
+ };
2393
+
2394
+ function leftBorder(element){
2395
+ return styleNumber(element, 'border-left-width');
2396
+ };
2397
+
2398
+ function isBody(element){
2399
+ return (/^(?:body|html)$/i).test(element.tagName);
2400
+ };
2401
+
2402
+ function getCompatElement(element){
2403
+ var doc = element.getDocument();
2404
+ return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
2405
+ };
2406
+
2407
+ })();
2408
+
2409
+ //aliases
2410
+
2411
+ Native.implement([Window, Document, Element], {
2412
+
2413
+ getHeight: function(){
2414
+ return this.getSize().y;
2415
+ },
2416
+
2417
+ getWidth: function(){
2418
+ return this.getSize().x;
2419
+ },
2420
+
2421
+ getScrollTop: function(){
2422
+ return this.getScroll().y;
2423
+ },
2424
+
2425
+ getScrollLeft: function(){
2426
+ return this.getScroll().x;
2427
+ },
2428
+
2429
+ getScrollHeight: function(){
2430
+ return this.getScrollSize().y;
2431
+ },
2432
+
2433
+ getScrollWidth: function(){
2434
+ return this.getScrollSize().x;
2435
+ },
2436
+
2437
+ getTop: function(){
2438
+ return this.getPosition().y;
2439
+ },
2440
+
2441
+ getLeft: function(){
2442
+ return this.getPosition().x;
2443
+ }
2444
+
2445
+ });
2446
+
2447
+
2448
+ /*
2449
+ Script: Selectors.js
2450
+ Adds advanced CSS Querying capabilities for targeting elements. Also includes pseudoselectors support.
2451
+
2452
+ License:
2453
+ MIT-style license.
2454
+ */
2455
+
2456
+ Native.implement([Document, Element], {
2457
+
2458
+ getElements: function(expression, nocash){
2459
+ expression = expression.split(',');
2460
+ var items, local = {};
2461
+ for (var i = 0, l = expression.length; i < l; i++){
2462
+ var selector = expression[i], elements = Selectors.Utils.search(this, selector, local);
2463
+ if (i != 0 && elements.item) elements = $A(elements);
2464
+ items = (i == 0) ? elements : (items.item) ? $A(items).concat(elements) : items.concat(elements);
2465
+ }
2466
+ return new Elements(items, {ddup: (expression.length > 1), cash: !nocash});
2467
+ }
2468
+
2469
+ });
2470
+
2471
+ Element.implement({
2472
+
2473
+ match: function(selector){
2474
+ if (!selector || (selector == this)) return true;
2475
+ var tagid = Selectors.Utils.parseTagAndID(selector);
2476
+ var tag = tagid[0], id = tagid[1];
2477
+ if (!Selectors.Filters.byID(this, id) || !Selectors.Filters.byTag(this, tag)) return false;
2478
+ var parsed = Selectors.Utils.parseSelector(selector);
2479
+ return (parsed) ? Selectors.Utils.filter(this, parsed, {}) : true;
2480
+ }
2481
+
2482
+ });
2483
+
2484
+ var Selectors = {Cache: {nth: {}, parsed: {}}};
2485
+
2486
+ Selectors.RegExps = {
2487
+ id: (/#([\w-]+)/),
2488
+ tag: (/^(\w+|\*)/),
2489
+ quick: (/^(\w+|\*)$/),
2490
+ splitter: (/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),
2491
+ combined: (/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)
2492
+ };
2493
+
2494
+ Selectors.Utils = {
2495
+
2496
+ chk: function(item, uniques){
2497
+ if (!uniques) return true;
2498
+ var uid = $uid(item);
2499
+ if (!uniques[uid]) return uniques[uid] = true;
2500
+ return false;
2501
+ },
2502
+
2503
+ parseNthArgument: function(argument){
2504
+ if (Selectors.Cache.nth[argument]) return Selectors.Cache.nth[argument];
2505
+ var parsed = argument.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);
2506
+ if (!parsed) return false;
2507
+ var inta = parseInt(parsed[1]);
2508
+ var a = (inta || inta === 0) ? inta : 1;
2509
+ var special = parsed[2] || false;
2510
+ var b = parseInt(parsed[3]) || 0;
2511
+ if (a != 0){
2512
+ b--;
2513
+ while (b < 1) b += a;
2514
+ while (b >= a) b -= a;
2515
+ } else {
2516
+ a = b;
2517
+ special = 'index';
2518
+ }
2519
+ switch (special){
2520
+ case 'n': parsed = {a: a, b: b, special: 'n'}; break;
2521
+ case 'odd': parsed = {a: 2, b: 0, special: 'n'}; break;
2522
+ case 'even': parsed = {a: 2, b: 1, special: 'n'}; break;
2523
+ case 'first': parsed = {a: 0, special: 'index'}; break;
2524
+ case 'last': parsed = {special: 'last-child'}; break;
2525
+ case 'only': parsed = {special: 'only-child'}; break;
2526
+ default: parsed = {a: (a - 1), special: 'index'};
2527
+ }
2528
+
2529
+ return Selectors.Cache.nth[argument] = parsed;
2530
+ },
2531
+
2532
+ parseSelector: function(selector){
2533
+ if (Selectors.Cache.parsed[selector]) return Selectors.Cache.parsed[selector];
2534
+ var m, parsed = {classes: [], pseudos: [], attributes: []};
2535
+ while ((m = Selectors.RegExps.combined.exec(selector))){
2536
+ var cn = m[1], an = m[2], ao = m[3], av = m[5], pn = m[6], pa = m[7];
2537
+ if (cn){
2538
+ parsed.classes.push(cn);
2539
+ } else if (pn){
2540
+ var parser = Selectors.Pseudo.get(pn);
2541
+ if (parser) parsed.pseudos.push({parser: parser, argument: pa});
2542
+ else parsed.attributes.push({name: pn, operator: '=', value: pa});
2543
+ } else if (an){
2544
+ parsed.attributes.push({name: an, operator: ao, value: av});
2545
+ }
2546
+ }
2547
+ if (!parsed.classes.length) delete parsed.classes;
2548
+ if (!parsed.attributes.length) delete parsed.attributes;
2549
+ if (!parsed.pseudos.length) delete parsed.pseudos;
2550
+ if (!parsed.classes && !parsed.attributes && !parsed.pseudos) parsed = null;
2551
+ return Selectors.Cache.parsed[selector] = parsed;
2552
+ },
2553
+
2554
+ parseTagAndID: function(selector){
2555
+ var tag = selector.match(Selectors.RegExps.tag);
2556
+ var id = selector.match(Selectors.RegExps.id);
2557
+ return [(tag) ? tag[1] : '*', (id) ? id[1] : false];
2558
+ },
2559
+
2560
+ filter: function(item, parsed, local){
2561
+ var i;
2562
+ if (parsed.classes){
2563
+ for (i = parsed.classes.length; i--; i){
2564
+ var cn = parsed.classes[i];
2565
+ if (!Selectors.Filters.byClass(item, cn)) return false;
2566
+ }
2567
+ }
2568
+ if (parsed.attributes){
2569
+ for (i = parsed.attributes.length; i--; i){
2570
+ var att = parsed.attributes[i];
2571
+ if (!Selectors.Filters.byAttribute(item, att.name, att.operator, att.value)) return false;
2572
+ }
2573
+ }
2574
+ if (parsed.pseudos){
2575
+ for (i = parsed.pseudos.length; i--; i){
2576
+ var psd = parsed.pseudos[i];
2577
+ if (!Selectors.Filters.byPseudo(item, psd.parser, psd.argument, local)) return false;
2578
+ }
2579
+ }
2580
+ return true;
2581
+ },
2582
+
2583
+ getByTagAndID: function(ctx, tag, id){
2584
+ if (id){
2585
+ var item = (ctx.getElementById) ? ctx.getElementById(id, true) : Element.getElementById(ctx, id, true);
2586
+ return (item && Selectors.Filters.byTag(item, tag)) ? [item] : [];
2587
+ } else {
2588
+ return ctx.getElementsByTagName(tag);
2589
+ }
2590
+ },
2591
+
2592
+ search: function(self, expression, local){
2593
+ var splitters = [];
2594
+
2595
+ var selectors = expression.trim().replace(Selectors.RegExps.splitter, function(m0, m1, m2){
2596
+ splitters.push(m1);
2597
+ return ':)' + m2;
2598
+ }).split(':)');
2599
+
2600
+ var items, filtered, item;
2601
+
2602
+ for (var i = 0, l = selectors.length; i < l; i++){
2603
+
2604
+ var selector = selectors[i];
2605
+
2606
+ if (i == 0 && Selectors.RegExps.quick.test(selector)){
2607
+ items = self.getElementsByTagName(selector);
2608
+ continue;
2609
+ }
2610
+
2611
+ var splitter = splitters[i - 1];
2612
+
2613
+ var tagid = Selectors.Utils.parseTagAndID(selector);
2614
+ var tag = tagid[0], id = tagid[1];
2615
+
2616
+ if (i == 0){
2617
+ items = Selectors.Utils.getByTagAndID(self, tag, id);
2618
+ } else {
2619
+ var uniques = {}, found = [];
2620
+ for (var j = 0, k = items.length; j < k; j++) found = Selectors.Getters[splitter](found, items[j], tag, id, uniques);
2621
+ items = found;
2622
+ }
2623
+
2624
+ var parsed = Selectors.Utils.parseSelector(selector);
2625
+
2626
+ if (parsed){
2627
+ filtered = [];
2628
+ for (var m = 0, n = items.length; m < n; m++){
2629
+ item = items[m];
2630
+ if (Selectors.Utils.filter(item, parsed, local)) filtered.push(item);
2631
+ }
2632
+ items = filtered;
2633
+ }
2634
+
2635
+ }
2636
+
2637
+ return items;
2638
+
2639
+ }
2640
+
2641
+ };
2642
+
2643
+ Selectors.Getters = {
2644
+
2645
+ ' ': function(found, self, tag, id, uniques){
2646
+ var items = Selectors.Utils.getByTagAndID(self, tag, id);
2647
+ for (var i = 0, l = items.length; i < l; i++){
2648
+ var item = items[i];
2649
+ if (Selectors.Utils.chk(item, uniques)) found.push(item);
2650
+ }
2651
+ return found;
2652
+ },
2653
+
2654
+ '>': function(found, self, tag, id, uniques){
2655
+ var children = Selectors.Utils.getByTagAndID(self, tag, id);
2656
+ for (var i = 0, l = children.length; i < l; i++){
2657
+ var child = children[i];
2658
+ if (child.parentNode == self && Selectors.Utils.chk(child, uniques)) found.push(child);
2659
+ }
2660
+ return found;
2661
+ },
2662
+
2663
+ '+': function(found, self, tag, id, uniques){
2664
+ while ((self = self.nextSibling)){
2665
+ if (self.nodeType == 1){
2666
+ if (Selectors.Utils.chk(self, uniques) && Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self);
2667
+ break;
2668
+ }
2669
+ }
2670
+ return found;
2671
+ },
2672
+
2673
+ '~': function(found, self, tag, id, uniques){
2674
+ while ((self = self.nextSibling)){
2675
+ if (self.nodeType == 1){
2676
+ if (!Selectors.Utils.chk(self, uniques)) break;
2677
+ if (Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self);
2678
+ }
2679
+ }
2680
+ return found;
2681
+ }
2682
+
2683
+ };
2684
+
2685
+ Selectors.Filters = {
2686
+
2687
+ byTag: function(self, tag){
2688
+ return (tag == '*' || (self.tagName && self.tagName.toLowerCase() == tag));
2689
+ },
2690
+
2691
+ byID: function(self, id){
2692
+ return (!id || (self.id && self.id == id));
2693
+ },
2694
+
2695
+ byClass: function(self, klass){
2696
+ return (self.className && self.className.contains(klass, ' '));
2697
+ },
2698
+
2699
+ byPseudo: function(self, parser, argument, local){
2700
+ return parser.call(self, argument, local);
2701
+ },
2702
+
2703
+ byAttribute: function(self, name, operator, value){
2704
+ var result = Element.prototype.getProperty.call(self, name);
2705
+ if (!result) return (operator == '!=');
2706
+ if (!operator || value == undefined) return true;
2707
+ switch (operator){
2708
+ case '=': return (result == value);
2709
+ case '*=': return (result.contains(value));
2710
+ case '^=': return (result.substr(0, value.length) == value);
2711
+ case '$=': return (result.substr(result.length - value.length) == value);
2712
+ case '!=': return (result != value);
2713
+ case '~=': return result.contains(value, ' ');
2714
+ case '|=': return result.contains(value, '-');
2715
+ }
2716
+ return false;
2717
+ }
2718
+
2719
+ };
2720
+
2721
+ Selectors.Pseudo = new Hash({
2722
+
2723
+ // w3c pseudo selectors
2724
+
2725
+ checked: function(){
2726
+ return this.checked;
2727
+ },
2728
+
2729
+ empty: function(){
2730
+ return !(this.innerText || this.textContent || '').length;
2731
+ },
2732
+
2733
+ not: function(selector){
2734
+ return !Element.match(this, selector);
2735
+ },
2736
+
2737
+ contains: function(text){
2738
+ return (this.innerText || this.textContent || '').contains(text);
2739
+ },
2740
+
2741
+ 'first-child': function(){
2742
+ return Selectors.Pseudo.index.call(this, 0);
2743
+ },
2744
+
2745
+ 'last-child': function(){
2746
+ var element = this;
2747
+ while ((element = element.nextSibling)){
2748
+ if (element.nodeType == 1) return false;
2749
+ }
2750
+ return true;
2751
+ },
2752
+
2753
+ 'only-child': function(){
2754
+ var prev = this;
2755
+ while ((prev = prev.previousSibling)){
2756
+ if (prev.nodeType == 1) return false;
2757
+ }
2758
+ var next = this;
2759
+ while ((next = next.nextSibling)){
2760
+ if (next.nodeType == 1) return false;
2761
+ }
2762
+ return true;
2763
+ },
2764
+
2765
+ 'nth-child': function(argument, local){
2766
+ argument = (argument == undefined) ? 'n' : argument;
2767
+ var parsed = Selectors.Utils.parseNthArgument(argument);
2768
+ if (parsed.special != 'n') return Selectors.Pseudo[parsed.special].call(this, parsed.a, local);
2769
+ var count = 0;
2770
+ local.positions = local.positions || {};
2771
+ var uid = $uid(this);
2772
+ if (!local.positions[uid]){
2773
+ var self = this;
2774
+ while ((self = self.previousSibling)){
2775
+ if (self.nodeType != 1) continue;
2776
+ count ++;
2777
+ var position = local.positions[$uid(self)];
2778
+ if (position != undefined){
2779
+ count = position + count;
2780
+ break;
2781
+ }
2782
+ }
2783
+ local.positions[uid] = count;
2784
+ }
2785
+ return (local.positions[uid] % parsed.a == parsed.b);
2786
+ },
2787
+
2788
+ // custom pseudo selectors
2789
+
2790
+ index: function(index){
2791
+ var element = this, count = 0;
2792
+ while ((element = element.previousSibling)){
2793
+ if (element.nodeType == 1 && ++count > index) return false;
2794
+ }
2795
+ return (count == index);
2796
+ },
2797
+
2798
+ even: function(argument, local){
2799
+ return Selectors.Pseudo['nth-child'].call(this, '2n+1', local);
2800
+ },
2801
+
2802
+ odd: function(argument, local){
2803
+ return Selectors.Pseudo['nth-child'].call(this, '2n', local);
2804
+ }
2805
+
2806
+ });
2807
+
2808
+
2809
+ /*
2810
+ Script: Domready.js
2811
+ Contains the domready custom event.
2812
+
2813
+ License:
2814
+ MIT-style license.
2815
+ */
2816
+
2817
+ Element.Events.domready = {
2818
+
2819
+ onAdd: function(fn){
2820
+ if (Browser.loaded) fn.call(this);
2821
+ }
2822
+
2823
+ };
2824
+
2825
+ (function(){
2826
+
2827
+ var domready = function(){
2828
+ if (Browser.loaded) return;
2829
+ Browser.loaded = true;
2830
+ window.fireEvent('domready');
2831
+ document.fireEvent('domready');
2832
+ };
2833
+
2834
+ if (Browser.Engine.trident){
2835
+ var temp = document.createElement('div');
2836
+ (function(){
2837
+ ($try(function(){
2838
+ temp.doScroll('left');
2839
+ return $(temp).inject(document.body).set('html', 'temp').dispose();
2840
+ })) ? domready() : arguments.callee.delay(50);
2841
+ })();
2842
+ } else if (Browser.Engine.webkit && Browser.Engine.version < 525){
2843
+ (function(){
2844
+ (['loaded', 'complete'].contains(document.readyState)) ? domready() : arguments.callee.delay(50);
2845
+ })();
2846
+ } else {
2847
+ window.addEvent('load', domready);
2848
+ document.addEvent('DOMContentLoaded', domready);
2849
+ }
2850
+
2851
+ })();
2852
+
2853
+
2854
+ /*
2855
+ Script: JSON.js
2856
+ JSON encoder and decoder.
2857
+
2858
+ License:
2859
+ MIT-style license.
2860
+
2861
+ See Also:
2862
+ <http://www.json.org/>
2863
+ */
2864
+
2865
+ var JSON = new Hash({
2866
+
2867
+ $specialChars: {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'},
2868
+
2869
+ $replaceChars: function(chr){
2870
+ return JSON.$specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16);
2871
+ },
2872
+
2873
+ encode: function(obj){
2874
+ switch ($type(obj)){
2875
+ case 'string':
2876
+ return '"' + obj.replace(/[\x00-\x1f\\"]/g, JSON.$replaceChars) + '"';
2877
+ case 'array':
2878
+ return '[' + String(obj.map(JSON.encode).filter($defined)) + ']';
2879
+ case 'object': case 'hash':
2880
+ var string = [];
2881
+ Hash.each(obj, function(value, key){
2882
+ var json = JSON.encode(value);
2883
+ if (json) string.push(JSON.encode(key) + ':' + json);
2884
+ });
2885
+ return '{' + string + '}';
2886
+ case 'number': case 'boolean': return String(obj);
2887
+ case false: return 'null';
2888
+ }
2889
+ return null;
2890
+ },
2891
+
2892
+ decode: function(string, secure){
2893
+ if ($type(string) != 'string' || !string.length) return null;
2894
+ if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null;
2895
+ return eval('(' + string + ')');
2896
+ }
2897
+
2898
+ });
2899
+
2900
+ Native.implement([Hash, Array, String, Number], {
2901
+
2902
+ toJSON: function(){
2903
+ return JSON.encode(this);
2904
+ }
2905
+
2906
+ });
2907
+
2908
+
2909
+ /*
2910
+ Script: Cookie.js
2911
+ Class for creating, loading, and saving browser Cookies.
2912
+
2913
+ License:
2914
+ MIT-style license.
2915
+
2916
+ Credits:
2917
+ Based on the functions by Peter-Paul Koch (http://quirksmode.org).
2918
+ */
2919
+
2920
+ var Cookie = new Class({
2921
+
2922
+ Implements: Options,
2923
+
2924
+ options: {
2925
+ path: false,
2926
+ domain: false,
2927
+ duration: false,
2928
+ secure: false,
2929
+ document: document
2930
+ },
2931
+
2932
+ initialize: function(key, options){
2933
+ this.key = key;
2934
+ this.setOptions(options);
2935
+ },
2936
+
2937
+ write: function(value){
2938
+ value = encodeURIComponent(value);
2939
+ if (this.options.domain) value += '; domain=' + this.options.domain;
2940
+ if (this.options.path) value += '; path=' + this.options.path;
2941
+ if (this.options.duration){
2942
+ var date = new Date();
2943
+ date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000);
2944
+ value += '; expires=' + date.toGMTString();
2945
+ }
2946
+ if (this.options.secure) value += '; secure';
2947
+ this.options.document.cookie = this.key + '=' + value;
2948
+ return this;
2949
+ },
2950
+
2951
+ read: function(){
2952
+ var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)');
2953
+ return (value) ? decodeURIComponent(value[1]) : null;
2954
+ },
2955
+
2956
+ dispose: function(){
2957
+ new Cookie(this.key, $merge(this.options, {duration: -1})).write('');
2958
+ return this;
2959
+ }
2960
+
2961
+ });
2962
+
2963
+ Cookie.write = function(key, value, options){
2964
+ return new Cookie(key, options).write(value);
2965
+ };
2966
+
2967
+ Cookie.read = function(key){
2968
+ return new Cookie(key).read();
2969
+ };
2970
+
2971
+ Cookie.dispose = function(key, options){
2972
+ return new Cookie(key, options).dispose();
2973
+ };
2974
+
2975
+
2976
+ /*
2977
+ Script: Swiff.js
2978
+ Wrapper for embedding SWF movies. Supports (and fixes) External Interface Communication.
2979
+
2980
+ License:
2981
+ MIT-style license.
2982
+
2983
+ Credits:
2984
+ Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.
2985
+ */
2986
+
2987
+ var Swiff = new Class({
2988
+
2989
+ Implements: [Options],
2990
+
2991
+ options: {
2992
+ id: null,
2993
+ height: 1,
2994
+ width: 1,
2995
+ container: null,
2996
+ properties: {},
2997
+ params: {
2998
+ quality: 'high',
2999
+ allowScriptAccess: 'always',
3000
+ wMode: 'transparent',
3001
+ swLiveConnect: true
3002
+ },
3003
+ callBacks: {},
3004
+ vars: {}
3005
+ },
3006
+
3007
+ toElement: function(){
3008
+ return this.object;
3009
+ },
3010
+
3011
+ initialize: function(path, options){
3012
+ this.instance = 'Swiff_' + $time();
3013
+
3014
+ this.setOptions(options);
3015
+ options = this.options;
3016
+ var id = this.id = options.id || this.instance;
3017
+ var container = $(options.container);
3018
+
3019
+ Swiff.CallBacks[this.instance] = {};
3020
+
3021
+ var params = options.params, vars = options.vars, callBacks = options.callBacks;
3022
+ var properties = $extend({height: options.height, width: options.width}, options.properties);
3023
+
3024
+ var self = this;
3025
+
3026
+ for (var callBack in callBacks){
3027
+ Swiff.CallBacks[this.instance][callBack] = (function(option){
3028
+ return function(){
3029
+ return option.apply(self.object, arguments);
3030
+ };
3031
+ })(callBacks[callBack]);
3032
+ vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;
3033
+ }
3034
+
3035
+ params.flashVars = Hash.toQueryString(vars);
3036
+ if (Browser.Engine.trident){
3037
+ properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
3038
+ params.movie = path;
3039
+ } else {
3040
+ properties.type = 'application/x-shockwave-flash';
3041
+ properties.data = path;
3042
+ }
3043
+ var build = '<object id="' + id + '"';
3044
+ for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';
3045
+ build += '>';
3046
+ for (var param in params){
3047
+ if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';
3048
+ }
3049
+ build += '</object>';
3050
+ this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;
3051
+ },
3052
+
3053
+ replaces: function(element){
3054
+ element = $(element, true);
3055
+ element.parentNode.replaceChild(this.toElement(), element);
3056
+ return this;
3057
+ },
3058
+
3059
+ inject: function(element){
3060
+ $(element, true).appendChild(this.toElement());
3061
+ return this;
3062
+ },
3063
+
3064
+ remote: function(){
3065
+ return Swiff.remote.apply(Swiff, [this.toElement()].extend(arguments));
3066
+ }
3067
+
3068
+ });
3069
+
3070
+ Swiff.CallBacks = {};
3071
+
3072
+ Swiff.remote = function(obj, fn){
3073
+ var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');
3074
+ return eval(rs);
3075
+ };
3076
+
3077
+
3078
+ /*
3079
+ Script: Fx.js
3080
+ Contains the basic animation logic to be extended by all other Fx Classes.
3081
+
3082
+ License:
3083
+ MIT-style license.
3084
+ */
3085
+
3086
+ var Fx = new Class({
3087
+
3088
+ Implements: [Chain, Events, Options],
3089
+
3090
+ options: {
3091
+ /*
3092
+ onStart: $empty,
3093
+ onCancel: $empty,
3094
+ onComplete: $empty,
3095
+ */
3096
+ fps: 50,
3097
+ unit: false,
3098
+ duration: 500,
3099
+ link: 'ignore'
3100
+ },
3101
+
3102
+ initialize: function(options){
3103
+ this.subject = this.subject || this;
3104
+ this.setOptions(options);
3105
+ this.options.duration = Fx.Durations[this.options.duration] || this.options.duration.toInt();
3106
+ var wait = this.options.wait;
3107
+ if (wait === false) this.options.link = 'cancel';
3108
+ },
3109
+
3110
+ getTransition: function(){
3111
+ return function(p){
3112
+ return -(Math.cos(Math.PI * p) - 1) / 2;
3113
+ };
3114
+ },
3115
+
3116
+ step: function(){
3117
+ var time = $time();
3118
+ if (time < this.time + this.options.duration){
3119
+ var delta = this.transition((time - this.time) / this.options.duration);
3120
+ this.set(this.compute(this.from, this.to, delta));
3121
+ } else {
3122
+ this.set(this.compute(this.from, this.to, 1));
3123
+ this.complete();
3124
+ }
3125
+ },
3126
+
3127
+ set: function(now){
3128
+ return now;
3129
+ },
3130
+
3131
+ compute: function(from, to, delta){
3132
+ return Fx.compute(from, to, delta);
3133
+ },
3134
+
3135
+ check: function(caller){
3136
+ if (!this.timer) return true;
3137
+ switch (this.options.link){
3138
+ case 'cancel': this.cancel(); return true;
3139
+ case 'chain': this.chain(caller.bind(this, Array.slice(arguments, 1))); return false;
3140
+ }
3141
+ return false;
3142
+ },
3143
+
3144
+ start: function(from, to){
3145
+ if (!this.check(arguments.callee, from, to)) return this;
3146
+ this.from = from;
3147
+ this.to = to;
3148
+ this.time = 0;
3149
+ this.transition = this.getTransition();
3150
+ this.startTimer();
3151
+ this.onStart();
3152
+ return this;
3153
+ },
3154
+
3155
+ complete: function(){
3156
+ if (this.stopTimer()) this.onComplete();
3157
+ return this;
3158
+ },
3159
+
3160
+ cancel: function(){
3161
+ if (this.stopTimer()) this.onCancel();
3162
+ return this;
3163
+ },
3164
+
3165
+ onStart: function(){
3166
+ this.fireEvent('start', this.subject);
3167
+ },
3168
+
3169
+ onComplete: function(){
3170
+ this.fireEvent('complete', this.subject);
3171
+ if (!this.callChain()) this.fireEvent('chainComplete', this.subject);
3172
+ },
3173
+
3174
+ onCancel: function(){
3175
+ this.fireEvent('cancel', this.subject).clearChain();
3176
+ },
3177
+
3178
+ pause: function(){
3179
+ this.stopTimer();
3180
+ return this;
3181
+ },
3182
+
3183
+ resume: function(){
3184
+ this.startTimer();
3185
+ return this;
3186
+ },
3187
+
3188
+ stopTimer: function(){
3189
+ if (!this.timer) return false;
3190
+ this.time = $time() - this.time;
3191
+ this.timer = $clear(this.timer);
3192
+ return true;
3193
+ },
3194
+
3195
+ startTimer: function(){
3196
+ if (this.timer) return false;
3197
+ this.time = $time() - this.time;
3198
+ this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);
3199
+ return true;
3200
+ }
3201
+
3202
+ });
3203
+
3204
+ Fx.compute = function(from, to, delta){
3205
+ return (to - from) * delta + from;
3206
+ };
3207
+
3208
+ Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000};
3209
+
3210
+
3211
+ /*
3212
+ Script: Fx.CSS.js
3213
+ Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements.
3214
+
3215
+ License:
3216
+ MIT-style license.
3217
+ */
3218
+
3219
+ Fx.CSS = new Class({
3220
+
3221
+ Extends: Fx,
3222
+
3223
+ //prepares the base from/to object
3224
+
3225
+ prepare: function(element, property, values){
3226
+ values = $splat(values);
3227
+ var values1 = values[1];
3228
+ if (!$chk(values1)){
3229
+ values[1] = values[0];
3230
+ values[0] = element.getStyle(property);
3231
+ }
3232
+ var parsed = values.map(this.parse);
3233
+ return {from: parsed[0], to: parsed[1]};
3234
+ },
3235
+
3236
+ //parses a value into an array
3237
+
3238
+ parse: function(value){
3239
+ value = $lambda(value)();
3240
+ value = (typeof value == 'string') ? value.split(' ') : $splat(value);
3241
+ return value.map(function(val){
3242
+ val = String(val);
3243
+ var found = false;
3244
+ Fx.CSS.Parsers.each(function(parser, key){
3245
+ if (found) return;
3246
+ var parsed = parser.parse(val);
3247
+ if ($chk(parsed)) found = {value: parsed, parser: parser};
3248
+ });
3249
+ found = found || {value: val, parser: Fx.CSS.Parsers.String};
3250
+ return found;
3251
+ });
3252
+ },
3253
+
3254
+ //computes by a from and to prepared objects, using their parsers.
3255
+
3256
+ compute: function(from, to, delta){
3257
+ var computed = [];
3258
+ (Math.min(from.length, to.length)).times(function(i){
3259
+ computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});
3260
+ });
3261
+ computed.$family = {name: 'fx:css:value'};
3262
+ return computed;
3263
+ },
3264
+
3265
+ //serves the value as settable
3266
+
3267
+ serve: function(value, unit){
3268
+ if ($type(value) != 'fx:css:value') value = this.parse(value);
3269
+ var returned = [];
3270
+ value.each(function(bit){
3271
+ returned = returned.concat(bit.parser.serve(bit.value, unit));
3272
+ });
3273
+ return returned;
3274
+ },
3275
+
3276
+ //renders the change to an element
3277
+
3278
+ render: function(element, property, value, unit){
3279
+ element.setStyle(property, this.serve(value, unit));
3280
+ },
3281
+
3282
+ //searches inside the page css to find the values for a selector
3283
+
3284
+ search: function(selector){
3285
+ if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];
3286
+ var to = {};
3287
+ Array.each(document.styleSheets, function(sheet, j){
3288
+ var href = sheet.href;
3289
+ if (href && href.contains('://') && !href.contains(document.domain)) return;
3290
+ var rules = sheet.rules || sheet.cssRules;
3291
+ Array.each(rules, function(rule, i){
3292
+ if (!rule.style) return;
3293
+ var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){
3294
+ return m.toLowerCase();
3295
+ }) : null;
3296
+ if (!selectorText || !selectorText.test('^' + selector + '$')) return;
3297
+ Element.Styles.each(function(value, style){
3298
+ if (!rule.style[style] || Element.ShortStyles[style]) return;
3299
+ value = String(rule.style[style]);
3300
+ to[style] = (value.test(/^rgb/)) ? value.rgbToHex() : value;
3301
+ });
3302
+ });
3303
+ });
3304
+ return Fx.CSS.Cache[selector] = to;
3305
+ }
3306
+
3307
+ });
3308
+
3309
+ Fx.CSS.Cache = {};
3310
+
3311
+ Fx.CSS.Parsers = new Hash({
3312
+
3313
+ Color: {
3314
+ parse: function(value){
3315
+ if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true);
3316
+ return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false;
3317
+ },
3318
+ compute: function(from, to, delta){
3319
+ return from.map(function(value, i){
3320
+ return Math.round(Fx.compute(from[i], to[i], delta));
3321
+ });
3322
+ },
3323
+ serve: function(value){
3324
+ return value.map(Number);
3325
+ }
3326
+ },
3327
+
3328
+ Number: {
3329
+ parse: parseFloat,
3330
+ compute: Fx.compute,
3331
+ serve: function(value, unit){
3332
+ return (unit) ? value + unit : value;
3333
+ }
3334
+ },
3335
+
3336
+ String: {
3337
+ parse: $lambda(false),
3338
+ compute: $arguments(1),
3339
+ serve: $arguments(0)
3340
+ }
3341
+
3342
+ });
3343
+
3344
+
3345
+ /*
3346
+ Script: Fx.Tween.js
3347
+ Formerly Fx.Style, effect to transition any CSS property for an element.
3348
+
3349
+ License:
3350
+ MIT-style license.
3351
+ */
3352
+
3353
+ Fx.Tween = new Class({
3354
+
3355
+ Extends: Fx.CSS,
3356
+
3357
+ initialize: function(element, options){
3358
+ this.element = this.subject = $(element);
3359
+ this.parent(options);
3360
+ },
3361
+
3362
+ set: function(property, now){
3363
+ if (arguments.length == 1){
3364
+ now = property;
3365
+ property = this.property || this.options.property;
3366
+ }
3367
+ this.render(this.element, property, now, this.options.unit);
3368
+ return this;
3369
+ },
3370
+
3371
+ start: function(property, from, to){
3372
+ if (!this.check(arguments.callee, property, from, to)) return this;
3373
+ var args = Array.flatten(arguments);
3374
+ this.property = this.options.property || args.shift();
3375
+ var parsed = this.prepare(this.element, this.property, args);
3376
+ return this.parent(parsed.from, parsed.to);
3377
+ }
3378
+
3379
+ });
3380
+
3381
+ Element.Properties.tween = {
3382
+
3383
+ set: function(options){
3384
+ var tween = this.retrieve('tween');
3385
+ if (tween) tween.cancel();
3386
+ return this.eliminate('tween').store('tween:options', $extend({link: 'cancel'}, options));
3387
+ },
3388
+
3389
+ get: function(options){
3390
+ if (options || !this.retrieve('tween')){
3391
+ if (options || !this.retrieve('tween:options')) this.set('tween', options);
3392
+ this.store('tween', new Fx.Tween(this, this.retrieve('tween:options')));
3393
+ }
3394
+ return this.retrieve('tween');
3395
+ }
3396
+
3397
+ };
3398
+
3399
+ Element.implement({
3400
+
3401
+ tween: function(property, from, to){
3402
+ this.get('tween').start(arguments);
3403
+ return this;
3404
+ },
3405
+
3406
+ fade: function(how){
3407
+ var fade = this.get('tween'), o = 'opacity', toggle;
3408
+ how = $pick(how, 'toggle');
3409
+ switch (how){
3410
+ case 'in': fade.start(o, 1); break;
3411
+ case 'out': fade.start(o, 0); break;
3412
+ case 'show': fade.set(o, 1); break;
3413
+ case 'hide': fade.set(o, 0); break;
3414
+ case 'toggle':
3415
+ var flag = this.retrieve('fade:flag', this.get('opacity') == 1);
3416
+ fade.start(o, (flag) ? 0 : 1);
3417
+ this.store('fade:flag', !flag);
3418
+ toggle = true;
3419
+ break;
3420
+ default: fade.start(o, arguments);
3421
+ }
3422
+ if (!toggle) this.eliminate('fade:flag');
3423
+ return this;
3424
+ },
3425
+
3426
+ highlight: function(start, end){
3427
+ if (!end){
3428
+ end = this.retrieve('highlight:original', this.getStyle('background-color'));
3429
+ end = (end == 'transparent') ? '#fff' : end;
3430
+ }
3431
+ var tween = this.get('tween');
3432
+ tween.start('background-color', start || '#ffff88', end).chain(function(){
3433
+ this.setStyle('background-color', this.retrieve('highlight:original'));
3434
+ tween.callChain();
3435
+ }.bind(this));
3436
+ return this;
3437
+ }
3438
+
3439
+ });
3440
+
3441
+
3442
+ /*
3443
+ Script: Fx.Morph.js
3444
+ Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.
3445
+
3446
+ License:
3447
+ MIT-style license.
3448
+ */
3449
+
3450
+ Fx.Morph = new Class({
3451
+
3452
+ Extends: Fx.CSS,
3453
+
3454
+ initialize: function(element, options){
3455
+ this.element = this.subject = $(element);
3456
+ this.parent(options);
3457
+ },
3458
+
3459
+ set: function(now){
3460
+ if (typeof now == 'string') now = this.search(now);
3461
+ for (var p in now) this.render(this.element, p, now[p], this.options.unit);
3462
+ return this;
3463
+ },
3464
+
3465
+ compute: function(from, to, delta){
3466
+ var now = {};
3467
+ for (var p in from) now[p] = this.parent(from[p], to[p], delta);
3468
+ return now;
3469
+ },
3470
+
3471
+ start: function(properties){
3472
+ if (!this.check(arguments.callee, properties)) return this;
3473
+ if (typeof properties == 'string') properties = this.search(properties);
3474
+ var from = {}, to = {};
3475
+ for (var p in properties){
3476
+ var parsed = this.prepare(this.element, p, properties[p]);
3477
+ from[p] = parsed.from;
3478
+ to[p] = parsed.to;
3479
+ }
3480
+ return this.parent(from, to);
3481
+ }
3482
+
3483
+ });
3484
+
3485
+ Element.Properties.morph = {
3486
+
3487
+ set: function(options){
3488
+ var morph = this.retrieve('morph');
3489
+ if (morph) morph.cancel();
3490
+ return this.eliminate('morph').store('morph:options', $extend({link: 'cancel'}, options));
3491
+ },
3492
+
3493
+ get: function(options){
3494
+ if (options || !this.retrieve('morph')){
3495
+ if (options || !this.retrieve('morph:options')) this.set('morph', options);
3496
+ this.store('morph', new Fx.Morph(this, this.retrieve('morph:options')));
3497
+ }
3498
+ return this.retrieve('morph');
3499
+ }
3500
+
3501
+ };
3502
+
3503
+ Element.implement({
3504
+
3505
+ morph: function(props){
3506
+ this.get('morph').start(props);
3507
+ return this;
3508
+ }
3509
+
3510
+ });
3511
+
3512
+
3513
+ /*
3514
+ Script: Fx.Transitions.js
3515
+ Contains a set of advanced transitions to be used with any of the Fx Classes.
3516
+
3517
+ License:
3518
+ MIT-style license.
3519
+
3520
+ Credits:
3521
+ Easing Equations by Robert Penner, <http://www.robertpenner.com/easing/>, modified and optimized to be used with MooTools.
3522
+ */
3523
+
3524
+ Fx.implement({
3525
+
3526
+ getTransition: function(){
3527
+ var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
3528
+ if (typeof trans == 'string'){
3529
+ var data = trans.split(':');
3530
+ trans = Fx.Transitions;
3531
+ trans = trans[data[0]] || trans[data[0].capitalize()];
3532
+ if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
3533
+ }
3534
+ return trans;
3535
+ }
3536
+
3537
+ });
3538
+
3539
+ Fx.Transition = function(transition, params){
3540
+ params = $splat(params);
3541
+ return $extend(transition, {
3542
+ easeIn: function(pos){
3543
+ return transition(pos, params);
3544
+ },
3545
+ easeOut: function(pos){
3546
+ return 1 - transition(1 - pos, params);
3547
+ },
3548
+ easeInOut: function(pos){
3549
+ return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2;
3550
+ }
3551
+ });
3552
+ };
3553
+
3554
+ Fx.Transitions = new Hash({
3555
+
3556
+ linear: $arguments(0)
3557
+
3558
+ });
3559
+
3560
+ Fx.Transitions.extend = function(transitions){
3561
+ for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
3562
+ };
3563
+
3564
+ Fx.Transitions.extend({
3565
+
3566
+ Pow: function(p, x){
3567
+ return Math.pow(p, x[0] || 6);
3568
+ },
3569
+
3570
+ Expo: function(p){
3571
+ return Math.pow(2, 8 * (p - 1));
3572
+ },
3573
+
3574
+ Circ: function(p){
3575
+ return 1 - Math.sin(Math.acos(p));
3576
+ },
3577
+
3578
+ Sine: function(p){
3579
+ return 1 - Math.sin((1 - p) * Math.PI / 2);
3580
+ },
3581
+
3582
+ Back: function(p, x){
3583
+ x = x[0] || 1.618;
3584
+ return Math.pow(p, 2) * ((x + 1) * p - x);
3585
+ },
3586
+
3587
+ Bounce: function(p){
3588
+ var value;
3589
+ for (var a = 0, b = 1; 1; a += b, b /= 2){
3590
+ if (p >= (7 - 4 * a) / 11){
3591
+ value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
3592
+ break;
3593
+ }
3594
+ }
3595
+ return value;
3596
+ },
3597
+
3598
+ Elastic: function(p, x){
3599
+ return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);
3600
+ }
3601
+
3602
+ });
3603
+
3604
+ ['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){
3605
+ Fx.Transitions[transition] = new Fx.Transition(function(p){
3606
+ return Math.pow(p, [i + 2]);
3607
+ });
3608
+ });
3609
+
3610
+
3611
+ /*
3612
+ Script: Request.js
3613
+ Powerful all purpose Request Class. Uses XMLHTTPRequest.
3614
+
3615
+ License:
3616
+ MIT-style license.
3617
+ */
3618
+
3619
+ var Request = new Class({
3620
+
3621
+ Implements: [Chain, Events, Options],
3622
+
3623
+ options: {/*
3624
+ onRequest: $empty,
3625
+ onComplete: $empty,
3626
+ onCancel: $empty,
3627
+ onSuccess: $empty,
3628
+ onFailure: $empty,
3629
+ onException: $empty,*/
3630
+ url: '',
3631
+ data: '',
3632
+ headers: {
3633
+ 'X-Requested-With': 'XMLHttpRequest',
3634
+ 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
3635
+ },
3636
+ async: true,
3637
+ format: false,
3638
+ method: 'post',
3639
+ link: 'ignore',
3640
+ isSuccess: null,
3641
+ emulation: true,
3642
+ urlEncoded: true,
3643
+ encoding: 'utf-8',
3644
+ evalScripts: false,
3645
+ evalResponse: false
3646
+ },
3647
+
3648
+ initialize: function(options){
3649
+ this.xhr = new Browser.Request();
3650
+ this.setOptions(options);
3651
+ this.options.isSuccess = this.options.isSuccess || this.isSuccess;
3652
+ this.headers = new Hash(this.options.headers);
3653
+ },
3654
+
3655
+ onStateChange: function(){
3656
+ if (this.xhr.readyState != 4 || !this.running) return;
3657
+ this.running = false;
3658
+ this.status = 0;
3659
+ $try(function(){
3660
+ this.status = this.xhr.status;
3661
+ }.bind(this));
3662
+ if (this.options.isSuccess.call(this, this.status)){
3663
+ this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
3664
+ this.success(this.response.text, this.response.xml);
3665
+ } else {
3666
+ this.response = {text: null, xml: null};
3667
+ this.failure();
3668
+ }
3669
+ this.xhr.onreadystatechange = $empty;
3670
+ },
3671
+
3672
+ isSuccess: function(){
3673
+ return ((this.status >= 200) && (this.status < 300));
3674
+ },
3675
+
3676
+ processScripts: function(text){
3677
+ if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return $exec(text);
3678
+ return text.stripScripts(this.options.evalScripts);
3679
+ },
3680
+
3681
+ success: function(text, xml){
3682
+ this.onSuccess(this.processScripts(text), xml);
3683
+ },
3684
+
3685
+ onSuccess: function(){
3686
+ this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain();
3687
+ },
3688
+
3689
+ failure: function(){
3690
+ this.onFailure();
3691
+ },
3692
+
3693
+ onFailure: function(){
3694
+ this.fireEvent('complete').fireEvent('failure', this.xhr);
3695
+ },
3696
+
3697
+ setHeader: function(name, value){
3698
+ this.headers.set(name, value);
3699
+ return this;
3700
+ },
3701
+
3702
+ getHeader: function(name){
3703
+ return $try(function(){
3704
+ return this.xhr.getResponseHeader(name);
3705
+ }.bind(this));
3706
+ },
3707
+
3708
+ check: function(caller){
3709
+ if (!this.running) return true;
3710
+ switch (this.options.link){
3711
+ case 'cancel': this.cancel(); return true;
3712
+ case 'chain': this.chain(caller.bind(this, Array.slice(arguments, 1))); return false;
3713
+ }
3714
+ return false;
3715
+ },
3716
+
3717
+ send: function(options){
3718
+ if (!this.check(arguments.callee, options)) return this;
3719
+ this.running = true;
3720
+
3721
+ var type = $type(options);
3722
+ if (type == 'string' || type == 'element') options = {data: options};
3723
+
3724
+ var old = this.options;
3725
+ options = $extend({data: old.data, url: old.url, method: old.method}, options);
3726
+ var data = options.data, url = options.url, method = options.method;
3727
+
3728
+ switch ($type(data)){
3729
+ case 'element': data = $(data).toQueryString(); break;
3730
+ case 'object': case 'hash': data = Hash.toQueryString(data);
3731
+ }
3732
+
3733
+ if (this.options.format){
3734
+ var format = 'format=' + this.options.format;
3735
+ data = (data) ? format + '&' + data : format;
3736
+ }
3737
+
3738
+ if (this.options.emulation && ['put', 'delete'].contains(method)){
3739
+ var _method = '_method=' + method;
3740
+ data = (data) ? _method + '&' + data : _method;
3741
+ method = 'post';
3742
+ }
3743
+
3744
+ if (this.options.urlEncoded && method == 'post'){
3745
+ var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
3746
+ this.headers.set('Content-type', 'application/x-www-form-urlencoded' + encoding);
3747
+ }
3748
+
3749
+ if (data && method == 'get'){
3750
+ url = url + (url.contains('?') ? '&' : '?') + data;
3751
+ data = null;
3752
+ }
3753
+
3754
+ this.xhr.open(method.toUpperCase(), url, this.options.async);
3755
+
3756
+ this.xhr.onreadystatechange = this.onStateChange.bind(this);
3757
+
3758
+ this.headers.each(function(value, key){
3759
+ try {
3760
+ this.xhr.setRequestHeader(key, value);
3761
+ } catch (e){
3762
+ this.fireEvent('exception', [key, value]);
3763
+ }
3764
+ }, this);
3765
+
3766
+ this.fireEvent('request');
3767
+ this.xhr.send(data);
3768
+ if (!this.options.async) this.onStateChange();
3769
+ return this;
3770
+ },
3771
+
3772
+ cancel: function(){
3773
+ if (!this.running) return this;
3774
+ this.running = false;
3775
+ this.xhr.abort();
3776
+ this.xhr.onreadystatechange = $empty;
3777
+ this.xhr = new Browser.Request();
3778
+ this.fireEvent('cancel');
3779
+ return this;
3780
+ }
3781
+
3782
+ });
3783
+
3784
+ (function(){
3785
+
3786
+ var methods = {};
3787
+ ['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){
3788
+ methods[method] = function(){
3789
+ var params = Array.link(arguments, {url: String.type, data: $defined});
3790
+ return this.send($extend(params, {method: method.toLowerCase()}));
3791
+ };
3792
+ });
3793
+
3794
+ Request.implement(methods);
3795
+
3796
+ })();
3797
+
3798
+ Element.Properties.send = {
3799
+
3800
+ set: function(options){
3801
+ var send = this.retrieve('send');
3802
+ if (send) send.cancel();
3803
+ return this.eliminate('send').store('send:options', $extend({
3804
+ data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')
3805
+ }, options));
3806
+ },
3807
+
3808
+ get: function(options){
3809
+ if (options || !this.retrieve('send')){
3810
+ if (options || !this.retrieve('send:options')) this.set('send', options);
3811
+ this.store('send', new Request(this.retrieve('send:options')));
3812
+ }
3813
+ return this.retrieve('send');
3814
+ }
3815
+
3816
+ };
3817
+
3818
+ Element.implement({
3819
+
3820
+ send: function(url){
3821
+ var sender = this.get('send');
3822
+ sender.send({data: this, url: url || sender.options.url});
3823
+ return this;
3824
+ }
3825
+
3826
+ });
3827
+
3828
+
3829
+ /*
3830
+ Script: Request.HTML.js
3831
+ Extends the basic Request Class with additional methods for interacting with HTML responses.
3832
+
3833
+ License:
3834
+ MIT-style license.
3835
+ */
3836
+
3837
+ Request.HTML = new Class({
3838
+
3839
+ Extends: Request,
3840
+
3841
+ options: {
3842
+ update: false,
3843
+ evalScripts: true,
3844
+ filter: false
3845
+ },
3846
+
3847
+ processHTML: function(text){
3848
+ var match = text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
3849
+ text = (match) ? match[1] : text;
3850
+
3851
+ var container = new Element('div');
3852
+
3853
+ return $try(function(){
3854
+ var root = '<root>' + text + '</root>', doc;
3855
+ if (Browser.Engine.trident){
3856
+ doc = new ActiveXObject('Microsoft.XMLDOM');
3857
+ doc.async = false;
3858
+ doc.loadXML(root);
3859
+ } else {
3860
+ doc = new DOMParser().parseFromString(root, 'text/xml');
3861
+ }
3862
+ root = doc.getElementsByTagName('root')[0];
3863
+ for (var i = 0, k = root.childNodes.length; i < k; i++){
3864
+ var child = Element.clone(root.childNodes[i], true, true);
3865
+ if (child) container.grab(child);
3866
+ }
3867
+ return container;
3868
+ }) || container.set('html', text);
3869
+ },
3870
+
3871
+ success: function(text){
3872
+ var options = this.options, response = this.response;
3873
+
3874
+ response.html = text.stripScripts(function(script){
3875
+ response.javascript = script;
3876
+ });
3877
+
3878
+ var temp = this.processHTML(response.html);
3879
+
3880
+ response.tree = temp.childNodes;
3881
+ response.elements = temp.getElements('*');
3882
+
3883
+ if (options.filter) response.tree = response.elements.filter(options.filter);
3884
+ if (options.update) $(options.update).empty().set('html', response.html);
3885
+ if (options.evalScripts) $exec(response.javascript);
3886
+
3887
+ this.onSuccess(response.tree, response.elements, response.html, response.javascript);
3888
+ }
3889
+
3890
+ });
3891
+
3892
+ Element.Properties.load = {
3893
+
3894
+ set: function(options){
3895
+ var load = this.retrieve('load');
3896
+ if (load) load.cancel();
3897
+ return this.eliminate('load').store('load:options', $extend({data: this, link: 'cancel', update: this, method: 'get'}, options));
3898
+ },
3899
+
3900
+ get: function(options){
3901
+ if (options || ! this.retrieve('load')){
3902
+ if (options || !this.retrieve('load:options')) this.set('load', options);
3903
+ this.store('load', new Request.HTML(this.retrieve('load:options')));
3904
+ }
3905
+ return this.retrieve('load');
3906
+ }
3907
+
3908
+ };
3909
+
3910
+ Element.implement({
3911
+
3912
+ load: function(){
3913
+ this.get('load').send(Array.link(arguments, {data: Object.type, url: String.type}));
3914
+ return this;
3915
+ }
3916
+
3917
+ });
3918
+
3919
+
3920
+ /*
3921
+ Script: Request.JSON.js
3922
+ Extends the basic Request Class with additional methods for sending and receiving JSON data.
3923
+
3924
+ License:
3925
+ MIT-style license.
3926
+ */
3927
+
3928
+ Request.JSON = new Class({
3929
+
3930
+ Extends: Request,
3931
+
3932
+ options: {
3933
+ secure: true
3934
+ },
3935
+
3936
+ initialize: function(options){
3937
+ this.parent(options);
3938
+ this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'});
3939
+ },
3940
+
3941
+ success: function(text){
3942
+ this.response.json = JSON.decode(text, this.options.secure);
3943
+ this.onSuccess(this.response.json, text);
3944
+ }
3945
+
3946
+ });
includes/js/mootools-1.2.1-core-nc.js.gz ADDED
Binary file
includes/js/mootools-1.2.1-core-yc.js ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //MooTools, <http://mootools.net>, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, <http://mad4milk.net>, MIT Style License.
2
+
3
+ var MooTools={version:"1.2.1",build:"0d4845aab3d9a4fdee2f0d4a6dd59210e4b697cf"};var Native=function(K){K=K||{};var A=K.name;var I=K.legacy;var B=K.protect;
4
+ var C=K.implement;var H=K.generics;var F=K.initialize;var G=K.afterImplement||function(){};var D=F||I;H=H!==false;D.constructor=Native;D.$family={name:"native"};
5
+ if(I&&F){D.prototype=I.prototype;}D.prototype.constructor=D;if(A){var E=A.toLowerCase();D.prototype.$family={name:E};Native.typize(D,E);}var J=function(N,L,O,M){if(!B||M||!N.prototype[L]){N.prototype[L]=O;
6
+ }if(H){Native.genericize(N,L,B);}G.call(N,L,O);return N;};D.alias=function(N,L,O){if(typeof N=="string"){if((N=this.prototype[N])){return J(this,L,N,O);
7
+ }}for(var M in N){this.alias(M,N[M],L);}return this;};D.implement=function(M,L,O){if(typeof M=="string"){return J(this,M,L,O);}for(var N in M){J(this,N,M[N],L);
8
+ }return this;};if(C){D.implement(C);}return D;};Native.genericize=function(B,C,A){if((!A||!B[C])&&typeof B.prototype[C]=="function"){B[C]=function(){var D=Array.prototype.slice.call(arguments);
9
+ return B.prototype[C].apply(D.shift(),D);};}};Native.implement=function(D,C){for(var B=0,A=D.length;B<A;B++){D[B].implement(C);}};Native.typize=function(A,B){if(!A.type){A.type=function(C){return($type(C)===B);
10
+ };}};(function(){var A={Array:Array,Date:Date,Function:Function,Number:Number,RegExp:RegExp,String:String};for(var G in A){new Native({name:G,initialize:A[G],protect:true});
11
+ }var D={"boolean":Boolean,"native":Native,object:Object};for(var C in D){Native.typize(D[C],C);}var F={Array:["concat","indexOf","join","lastIndexOf","pop","push","reverse","shift","slice","sort","splice","toString","unshift","valueOf"],String:["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase","valueOf"]};
12
+ for(var E in F){for(var B=F[E].length;B--;){Native.genericize(window[E],F[E][B],true);}}})();var Hash=new Native({name:"Hash",initialize:function(A){if($type(A)=="hash"){A=$unlink(A.getClean());
13
+ }for(var B in A){this[B]=A[B];}return this;}});Hash.implement({forEach:function(B,C){for(var A in this){if(this.hasOwnProperty(A)){B.call(C,this[A],A,this);
14
+ }}},getClean:function(){var B={};for(var A in this){if(this.hasOwnProperty(A)){B[A]=this[A];}}return B;},getLength:function(){var B=0;for(var A in this){if(this.hasOwnProperty(A)){B++;
15
+ }}return B;}});Hash.alias("forEach","each");Array.implement({forEach:function(C,D){for(var B=0,A=this.length;B<A;B++){C.call(D,this[B],B,this);}}});Array.alias("forEach","each");
16
+ function $A(C){if(C.item){var D=[];for(var B=0,A=C.length;B<A;B++){D[B]=C[B];}return D;}return Array.prototype.slice.call(C);}function $arguments(A){return function(){return arguments[A];
17
+ };}function $chk(A){return !!(A||A===0);}function $clear(A){clearTimeout(A);clearInterval(A);return null;}function $defined(A){return(A!=undefined);}function $each(C,B,D){var A=$type(C);
18
+ ((A=="arguments"||A=="collection"||A=="array")?Array:Hash).each(C,B,D);}function $empty(){}function $extend(C,A){for(var B in (A||{})){C[B]=A[B];}return C;
19
+ }function $H(A){return new Hash(A);}function $lambda(A){return(typeof A=="function")?A:function(){return A;};}function $merge(){var E={};for(var D=0,A=arguments.length;
20
+ D<A;D++){var B=arguments[D];if($type(B)!="object"){continue;}for(var C in B){var G=B[C],F=E[C];E[C]=(F&&$type(G)=="object"&&$type(F)=="object")?$merge(F,G):$unlink(G);
21
+ }}return E;}function $pick(){for(var B=0,A=arguments.length;B<A;B++){if(arguments[B]!=undefined){return arguments[B];}}return null;}function $random(B,A){return Math.floor(Math.random()*(A-B+1)+B);
22
+ }function $splat(B){var A=$type(B);return(A)?((A!="array"&&A!="arguments")?[B]:B):[];}var $time=Date.now||function(){return +new Date;};function $try(){for(var B=0,A=arguments.length;
23
+ B<A;B++){try{return arguments[B]();}catch(C){}}return null;}function $type(A){if(A==undefined){return false;}if(A.$family){return(A.$family.name=="number"&&!isFinite(A))?false:A.$family.name;
24
+ }if(A.nodeName){switch(A.nodeType){case 1:return"element";case 3:return(/\S/).test(A.nodeValue)?"textnode":"whitespace";}}else{if(typeof A.length=="number"){if(A.callee){return"arguments";
25
+ }else{if(A.item){return"collection";}}}}return typeof A;}function $unlink(C){var B;switch($type(C)){case"object":B={};for(var E in C){B[E]=$unlink(C[E]);
26
+ }break;case"hash":B=new Hash(C);break;case"array":B=[];for(var D=0,A=C.length;D<A;D++){B[D]=$unlink(C[D]);}break;default:return C;}return B;}var Browser=$merge({Engine:{name:"unknown",version:0},Platform:{name:(window.orientation!=undefined)?"ipod":(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase()},Features:{xpath:!!(document.evaluate),air:!!(window.runtime),query:!!(document.querySelector)},Plugins:{},Engines:{presto:function(){return(!window.opera)?false:((arguments.callee.caller)?960:((document.getElementsByClassName)?950:925));
27
+ },trident:function(){return(!window.ActiveXObject)?false:((window.XMLHttpRequest)?5:4);},webkit:function(){return(navigator.taintEnabled)?false:((Browser.Features.xpath)?((Browser.Features.query)?525:420):419);
28
+ },gecko:function(){return(document.getBoxObjectFor==undefined)?false:((document.getElementsByClassName)?19:18);}}},Browser||{});Browser.Platform[Browser.Platform.name]=true;
29
+ Browser.detect=function(){for(var B in this.Engines){var A=this.Engines[B]();if(A){this.Engine={name:B,version:A};this.Engine[B]=this.Engine[B+A]=true;
30
+ break;}}return{name:B,version:A};};Browser.detect();Browser.Request=function(){return $try(function(){return new XMLHttpRequest();},function(){return new ActiveXObject("MSXML2.XMLHTTP");
31
+ });};Browser.Features.xhr=!!(Browser.Request());Browser.Plugins.Flash=(function(){var A=($try(function(){return navigator.plugins["Shockwave Flash"].description;
32
+ },function(){return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version");})||"0 r0").match(/\d+/g);return{version:parseInt(A[0]||0+"."+A[1]||0),build:parseInt(A[2]||0)};
33
+ })();function $exec(B){if(!B){return B;}if(window.execScript){window.execScript(B);}else{var A=document.createElement("script");A.setAttribute("type","text/javascript");
34
+ A[(Browser.Engine.webkit&&Browser.Engine.version<420)?"innerText":"text"]=B;document.head.appendChild(A);document.head.removeChild(A);}return B;}Native.UID=1;
35
+ var $uid=(Browser.Engine.trident)?function(A){return(A.uid||(A.uid=[Native.UID++]))[0];}:function(A){return A.uid||(A.uid=Native.UID++);};var Window=new Native({name:"Window",legacy:(Browser.Engine.trident)?null:window.Window,initialize:function(A){$uid(A);
36
+ if(!A.Element){A.Element=$empty;if(Browser.Engine.webkit){A.document.createElement("iframe");}A.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{};
37
+ }A.document.window=A;return $extend(A,Window.Prototype);},afterImplement:function(B,A){window[B]=Window.Prototype[B]=A;}});Window.Prototype={$family:{name:"window"}};
38
+ new Window(window);var Document=new Native({name:"Document",legacy:(Browser.Engine.trident)?null:window.Document,initialize:function(A){$uid(A);A.head=A.getElementsByTagName("head")[0];
39
+ A.html=A.getElementsByTagName("html")[0];if(Browser.Engine.trident&&Browser.Engine.version<=4){$try(function(){A.execCommand("BackgroundImageCache",false,true);
40
+ });}if(Browser.Engine.trident){A.window.attachEvent("onunload",function(){A.window.detachEvent("onunload",arguments.callee);A.head=A.html=A.window=null;
41
+ });}return $extend(A,Document.Prototype);},afterImplement:function(B,A){document[B]=Document.Prototype[B]=A;}});Document.Prototype={$family:{name:"document"}};
42
+ new Document(document);Array.implement({every:function(C,D){for(var B=0,A=this.length;B<A;B++){if(!C.call(D,this[B],B,this)){return false;}}return true;
43
+ },filter:function(D,E){var C=[];for(var B=0,A=this.length;B<A;B++){if(D.call(E,this[B],B,this)){C.push(this[B]);}}return C;},clean:function(){return this.filter($defined);
44
+ },indexOf:function(C,D){var A=this.length;for(var B=(D<0)?Math.max(0,A+D):D||0;B<A;B++){if(this[B]===C){return B;}}return -1;},map:function(D,E){var C=[];
45
+ for(var B=0,A=this.length;B<A;B++){C[B]=D.call(E,this[B],B,this);}return C;},some:function(C,D){for(var B=0,A=this.length;B<A;B++){if(C.call(D,this[B],B,this)){return true;
46
+ }}return false;},associate:function(C){var D={},B=Math.min(this.length,C.length);for(var A=0;A<B;A++){D[C[A]]=this[A];}return D;},link:function(C){var A={};
47
+ for(var E=0,B=this.length;E<B;E++){for(var D in C){if(C[D](this[E])){A[D]=this[E];delete C[D];break;}}}return A;},contains:function(A,B){return this.indexOf(A,B)!=-1;
48
+ },extend:function(C){for(var B=0,A=C.length;B<A;B++){this.push(C[B]);}return this;},getLast:function(){return(this.length)?this[this.length-1]:null;},getRandom:function(){return(this.length)?this[$random(0,this.length-1)]:null;
49
+ },include:function(A){if(!this.contains(A)){this.push(A);}return this;},combine:function(C){for(var B=0,A=C.length;B<A;B++){this.include(C[B]);}return this;
50
+ },erase:function(B){for(var A=this.length;A--;A){if(this[A]===B){this.splice(A,1);}}return this;},empty:function(){this.length=0;return this;},flatten:function(){var D=[];
51
+ for(var B=0,A=this.length;B<A;B++){var C=$type(this[B]);if(!C){continue;}D=D.concat((C=="array"||C=="collection"||C=="arguments")?Array.flatten(this[B]):this[B]);
52
+ }return D;},hexToRgb:function(B){if(this.length!=3){return null;}var A=this.map(function(C){if(C.length==1){C+=C;}return C.toInt(16);});return(B)?A:"rgb("+A+")";
53
+ },rgbToHex:function(D){if(this.length<3){return null;}if(this.length==4&&this[3]==0&&!D){return"transparent";}var B=[];for(var A=0;A<3;A++){var C=(this[A]-0).toString(16);
54
+ B.push((C.length==1)?"0"+C:C);}return(D)?B:"#"+B.join("");}});Function.implement({extend:function(A){for(var B in A){this[B]=A[B];}return this;},create:function(B){var A=this;
55
+ B=B||{};return function(D){var C=B.arguments;C=(C!=undefined)?$splat(C):Array.slice(arguments,(B.event)?1:0);if(B.event){C=[D||window.event].extend(C);
56
+ }var E=function(){return A.apply(B.bind||null,C);};if(B.delay){return setTimeout(E,B.delay);}if(B.periodical){return setInterval(E,B.periodical);}if(B.attempt){return $try(E);
57
+ }return E();};},run:function(A,B){return this.apply(B,$splat(A));},pass:function(A,B){return this.create({bind:B,arguments:A});},bind:function(B,A){return this.create({bind:B,arguments:A});
58
+ },bindWithEvent:function(B,A){return this.create({bind:B,arguments:A,event:true});},attempt:function(A,B){return this.create({bind:B,arguments:A,attempt:true})();
59
+ },delay:function(B,C,A){return this.create({bind:C,arguments:A,delay:B})();},periodical:function(C,B,A){return this.create({bind:B,arguments:A,periodical:C})();
60
+ }});Number.implement({limit:function(B,A){return Math.min(A,Math.max(B,this));},round:function(A){A=Math.pow(10,A||0);return Math.round(this*A)/A;},times:function(B,C){for(var A=0;
61
+ A<this;A++){B.call(C,A,this);}},toFloat:function(){return parseFloat(this);},toInt:function(A){return parseInt(this,A||10);}});Number.alias("times","each");
62
+ (function(B){var A={};B.each(function(C){if(!Number[C]){A[C]=function(){return Math[C].apply(null,[this].concat($A(arguments)));};}});Number.implement(A);
63
+ })(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);String.implement({test:function(A,B){return((typeof A=="string")?new RegExp(A,B):A).test(this);
64
+ },contains:function(A,B){return(B)?(B+this+B).indexOf(B+A+B)>-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim();
65
+ },camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase());
66
+ });},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1");
67
+ },toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
68
+ return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A="";
69
+ var C=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){A+=arguments[1]+"\n";return"";});if(B===true){$exec(A);}else{if($type(B)=="function"){B(A,C);
70
+ }}return C;},substitute:function(A,B){return this.replace(B||(/\\?\{([^{}]+)\}/g),function(D,C){if(D.charAt(0)=="\\"){return D.slice(1);}return(A[C]!=undefined)?A[C]:"";
71
+ });}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(B){for(var A in this){if(this.hasOwnProperty(A)&&this[A]===B){return A;}}return null;
72
+ },hasValue:function(A){return(Hash.keyOf(this,A)!==null);},extend:function(A){Hash.each(A,function(C,B){Hash.set(this,B,C);},this);return this;},combine:function(A){Hash.each(A,function(C,B){Hash.include(this,B,C);
73
+ },this);return this;},erase:function(A){if(this.hasOwnProperty(A)){delete this[A];}return this;},get:function(A){return(this.hasOwnProperty(A))?this[A]:null;
74
+ },set:function(A,B){if(!this[A]||this.hasOwnProperty(A)){this[A]=B;}return this;},empty:function(){Hash.each(this,function(B,A){delete this[A];},this);
75
+ return this;},include:function(B,C){var A=this[B];if(A==undefined){this[B]=C;}return this;},map:function(B,C){var A=new Hash;Hash.each(this,function(E,D){A.set(D,B.call(C,E,D,this));
76
+ },this);return A;},filter:function(B,C){var A=new Hash;Hash.each(this,function(E,D){if(B.call(C,E,D,this)){A.set(D,E);}},this);return A;},every:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&!B.call(C,this[A],A)){return false;
77
+ }}return true;},some:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&B.call(C,this[A],A)){return true;}}return false;},getKeys:function(){var A=[];
78
+ Hash.each(this,function(C,B){A.push(B);});return A;},getValues:function(){var A=[];Hash.each(this,function(B){A.push(B);});return A;},toQueryString:function(A){var B=[];
79
+ Hash.each(this,function(F,E){if(A){E=A+"["+E+"]";}var D;switch($type(F)){case"object":D=Hash.toQueryString(F,E);break;case"array":var C={};F.each(function(H,G){C[G]=H;
80
+ });D=Hash.toQueryString(C,E);break;default:D=E+"="+encodeURIComponent(F);}if(F!=undefined){B.push(D);}});return B.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"});
81
+ var Event=new Native({name:"Event",initialize:function(A,F){F=F||window;var K=F.document;A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type;
82
+ var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.test(/key/)){var B=A.which||A.keyCode;var M=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111;
83
+ if(D>0&&D<13){M="f"+D;}}M=M||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){K=(!K.compatMode||K.compatMode=="CSS1Compat")?K.html:K.body;
84
+ var I={x:A.pageX||A.clientX+K.scrollLeft,y:A.pageY||A.clientY+K.scrollTop};var C={x:(A.pageX)?A.pageX-F.pageXOffset:A.clientX,y:(A.pageY)?A.pageY-F.pageYOffset:A.clientY};
85
+ if(J.match(/DOMMouseScroll|mousewheel/)){var H=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}var E=(A.which==3)||(A.button==2);var L=null;if(J.match(/over|out/)){switch(J){case"mouseover":L=A.relatedTarget||A.fromElement;
86
+ break;case"mouseout":L=A.relatedTarget||A.toElement;}if(!(function(){while(L&&L.nodeType==3){L=L.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){L=false;
87
+ }}}}return $extend(this,{event:A,type:J,page:I,client:C,rightClick:E,wheel:H,relatedTarget:L,target:G,code:B,key:M,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey});
88
+ }});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault();
89
+ },stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault();
90
+ }else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(){for(var E in this){if($type(this[E])!="function"){this[E]=$unlink(this[E]);
91
+ }}this.constructor=A;if(Class.prototyping){return this;}var D=(this.initialize)?this.initialize.apply(this,arguments):this;if(this.options&&this.options.initialize){this.options.initialize.call(this);
92
+ }return D;};for(var C in Class.Mutators){if(!B[C]){continue;}B=Class.Mutators[C](B,B[C]);delete B[C];}$extend(A,this);A.constructor=Class;A.prototype=B;
93
+ return A;}});Class.Mutators={Extends:function(C,A){Class.prototyping=A.prototype;var B=new A;delete B.parent;B=Class.inherit(B,C);delete Class.prototyping;
94
+ return B;},Implements:function(A,B){$splat(B).each(function(C){Class.prototying=C;$extend(A,($type(C)=="class")?new C:C);delete Class.prototyping;});return A;
95
+ }};Class.extend({inherit:function(B,E){var A=arguments.callee.caller;for(var D in E){var C=E[D];var G=B[D];var F=$type(C);if(G&&F=="function"){if(C!=G){if(A){C.__parent=G;
96
+ B[D]=C;}else{Class.override(B,D,C);}}}else{if(F=="object"){B[D]=$merge(G,C);}else{B[D]=C;}}}if(A){B.parent=function(){return arguments.callee.caller.__parent.apply(this,arguments);
97
+ };}return B;},override:function(B,A,E){var D=Class.prototyping;if(D&&B[A]!=D[A]){D=null;}var C=function(){var F=this.parent;this.parent=D?D[A]:B[A];var G=E.apply(this,arguments);
98
+ this.parent=F;return G;};B[A]=C;}});Class.implement({implement:function(){var A=this.prototype;$each(arguments,function(B){Class.inherit(A,B);});return this;
99
+ }});var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false;
100
+ },clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){this.$events[C]=this.$events[C]||[];
101
+ this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){C=Events.removeOn(C);
102
+ if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,"arguments":B})();},this);return this;},removeEvent:function(B,A){B=Events.removeOn(B);
103
+ if(!this.$events[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){if($type(C)=="object"){for(var D in C){this.removeEvent(D,C[D]);
104
+ }return this;}if(C){C=Events.removeOn(C);}for(var D in this.$events){if(C&&C!=D){continue;}var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]);
105
+ }}return this;}});Events.removeOn=function(A){return A.replace(/^on([A-Z])/,function(B,C){return C.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));
106
+ if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue;}this.addEvent(A,this.options[A]);
107
+ delete this.options[A];}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(A,B){var C=Element.Constructors.get(A);
108
+ if(C){return C(B);}if(typeof A=="string"){return document.newElement(A,B);}return $(A).set(B);},afterImplement:function(A,B){Element.Prototype[A]=B;if(Array[A]){return ;
109
+ }Elements.implement(A,function(){var C=[],G=true;for(var E=0,D=this.length;E<D;E++){var F=this[E][A].apply(this[E],arguments);C.push(F);if(G){G=($type(F)=="element");
110
+ }}return(G)?new Elements(C):C;});}});Element.Prototype={$family:{name:"element"}};Element.Constructors=new Hash;var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){var E=Array.link(arguments,{properties:Object.type,iframe:$defined});
111
+ var C=E.properties||{};var B=$(E.iframe)||false;var D=C.onload||$empty;delete C.onload;C.id=C.name=$pick(C.id,C.name,B.id,B.name,"IFrame_"+$time());B=new Element(B||"iframe",C);
112
+ var A=function(){var F=$try(function(){return B.contentWindow.location.host;});if(F&&F==window.location.host){var G=new Window(B.contentWindow);new Document(B.contentWindow.document);
113
+ $extend(G.Element.prototype,Element.Prototype);}D.call(B.contentWindow,B.contentWindow.document);};(window.frames[C.id])?A():B.addListener("load",A);return B;
114
+ }});var Elements=new Native({initialize:function(F,B){B=$extend({ddup:true,cash:true},B);F=F||[];if(B.ddup||B.cash){var G={},E=[];for(var C=0,A=F.length;
115
+ C<A;C++){var D=$.element(F[C],!B.cash);if(B.ddup){if(G[D.uid]){continue;}G[D.uid]=true;}E.push(D);}F=E;}return(B.cash)?$extend(F,this):F;}});Elements.implement({filter:function(A,B){if(!A){return this;
116
+ }return new Elements(Array.filter(this,(typeof A=="string")?function(C){return C.match(A);}:A,B));}});Document.implement({newElement:function(A,B){if(Browser.Engine.trident&&B){["name","type","checked"].each(function(C){if(!B[C]){return ;
117
+ }A+=" "+C+'="'+B[C]+'"';if(C!="checked"){delete B[C];}});A="<"+A+">";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A);
118
+ },getDocument:function(){return this;},getWindow:function(){return this.window;}});Window.implement({$:function(B,C){if(B&&B.$family&&B.uid){return B;}var A=$type(B);
119
+ return($[A])?$[A](B,C,this.document):null;},$$:function(A){if(arguments.length==1&&typeof A=="string"){return this.document.getElements(A);}var F=[];var C=Array.flatten(arguments);
120
+ for(var D=0,B=C.length;D<B;D++){var E=C[D];switch($type(E)){case"element":F.push(E);break;case"string":F.extend(this.document.getElements(E,true));}}return new Elements(F);
121
+ },getDocument:function(){return this.document;},getWindow:function(){return this;}});$.string=function(C,B,A){C=A.getElementById(C);return(C)?$.element(C,B):null;
122
+ };$.element=function(A,D){$uid(A);if(!D&&!A.$family&&!(/^object|embed$/i).test(A.tagName)){var B=Element.Prototype;for(var C in B){A[C]=B[C];}}return A;
123
+ };$.object=function(B,C,A){if(B.toElement){return $.element(B.toElement(A),C);}return null;};$.textnode=$.whitespace=$.window=$.document=$arguments(0);
124
+ Native.implement([Element,Document],{getElement:function(A,B){return $(this.getElements(A,true)[0]||null,B);},getElements:function(A,D){A=A.split(",");
125
+ var C=[];var B=(A.length>1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D});
126
+ }});(function(){var H={},F={};var I={input:"checked",option:"selected",textarea:(Browser.Engine.webkit&&Browser.Engine.version<420)?"innerHTML":"value"};
127
+ var C=function(L){return(F[L]||(F[L]={}));};var G=function(N,L){if(!N){return ;}var M=N.uid;if(Browser.Engine.trident){if(N.clearAttributes){var P=L&&N.cloneNode(false);
128
+ N.clearAttributes();if(P){N.mergeAttributes(P);}}else{if(N.removeEvents){N.removeEvents();}}if((/object/i).test(N.tagName)){for(var O in N){if(typeof N[O]=="function"){N[O]=$empty;
129
+ }}Element.dispose(N);}}if(!M){return ;}H[M]=F[M]=null;};var D=function(){Hash.each(H,G);if(Browser.Engine.trident){$A(document.getElementsByTagName("object")).each(G);
130
+ }if(window.CollectGarbage){CollectGarbage();}H=F=null;};var J=function(N,L,S,M,P,R){var O=N[S||L];var Q=[];while(O){if(O.nodeType==1&&(!M||Element.match(O,M))){if(!P){return $(O,R);
131
+ }Q.push(O);}O=O[L];}return(P)?new Elements(Q,{ddup:false,cash:!R}):null;};var E={html:"innerHTML","class":"className","for":"htmlFor",text:(Browser.Engine.trident||(Browser.Engine.webkit&&Browser.Engine.version<420))?"innerText":"textContent"};
132
+ var B=["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"];var K=["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"];
133
+ Hash.extend(E,B.associate(B));Hash.extend(E,K.associate(K.map(String.toLowerCase)));var A={before:function(M,L){if(L.parentNode){L.parentNode.insertBefore(M,L);
134
+ }},after:function(M,L){if(!L.parentNode){return ;}var N=L.nextSibling;(N)?L.parentNode.insertBefore(M,N):L.parentNode.appendChild(M);},bottom:function(M,L){L.appendChild(M);
135
+ },top:function(M,L){var N=L.firstChild;(N)?L.insertBefore(M,N):L.appendChild(M);}};A.inside=A.bottom;Hash.each(A,function(L,M){M=M.capitalize();Element.implement("inject"+M,function(N){L(this,$(N,true));
136
+ return this;});Element.implement("grab"+M,function(N){L($(N,true),this);return this;});});Element.implement({set:function(O,M){switch($type(O)){case"object":for(var N in O){this.set(N,O[N]);
137
+ }break;case"string":var L=Element.Properties.get(O);(L&&L.set)?L.set.apply(this,Array.slice(arguments,1)):this.setProperty(O,M);}return this;},get:function(M){var L=Element.Properties.get(M);
138
+ return(L&&L.get)?L.get.apply(this,Array.slice(arguments,1)):this.getProperty(M);},erase:function(M){var L=Element.Properties.get(M);(L&&L.erase)?L.erase.apply(this):this.removeProperty(M);
139
+ return this;},setProperty:function(M,N){var L=E[M];if(N==undefined){return this.removeProperty(M);}if(L&&B[M]){N=!!N;}(L)?this[L]=N:this.setAttribute(M,""+N);
140
+ return this;},setProperties:function(L){for(var M in L){this.setProperty(M,L[M]);}return this;},getProperty:function(M){var L=E[M];var N=(L)?this[L]:this.getAttribute(M,2);
141
+ return(B[M])?!!N:(L)?N:N||null;},getProperties:function(){var L=$A(arguments);return L.map(this.getProperty,this).associate(L);},removeProperty:function(M){var L=E[M];
142
+ (L)?this[L]=(L&&B[M])?false:"":this.removeAttribute(M);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this;
143
+ },hasClass:function(L){return this.className.contains(L," ");},addClass:function(L){if(!this.hasClass(L)){this.className=(this.className+" "+L).clean();
144
+ }return this;},removeClass:function(L){this.className=this.className.replace(new RegExp("(^|\\s)"+L+"(?:\\s|$)"),"$1");return this;},toggleClass:function(L){return this.hasClass(L)?this.removeClass(L):this.addClass(L);
145
+ },adopt:function(){Array.flatten(arguments).each(function(L){L=$(L,true);if(L){this.appendChild(L);}},this);return this;},appendText:function(M,L){return this.grab(this.getDocument().newTextNode(M),L);
146
+ },grab:function(M,L){A[L||"bottom"]($(M,true),this);return this;},inject:function(M,L){A[L||"bottom"](this,$(M,true));return this;},replaces:function(L){L=$(L,true);
147
+ L.parentNode.replaceChild(this,L);return this;},wraps:function(M,L){M=$(M,true);return this.replaces(M).grab(M,L);},getPrevious:function(L,M){return J(this,"previousSibling",null,L,false,M);
148
+ },getAllPrevious:function(L,M){return J(this,"previousSibling",null,L,true,M);},getNext:function(L,M){return J(this,"nextSibling",null,L,false,M);},getAllNext:function(L,M){return J(this,"nextSibling",null,L,true,M);
149
+ },getFirst:function(L,M){return J(this,"nextSibling","firstChild",L,false,M);},getLast:function(L,M){return J(this,"previousSibling","lastChild",L,false,M);
150
+ },getParent:function(L,M){return J(this,"parentNode",null,L,false,M);},getParents:function(L,M){return J(this,"parentNode",null,L,true,M);},getChildren:function(L,M){return J(this,"nextSibling","firstChild",L,true,M);
151
+ },getWindow:function(){return this.ownerDocument.window;},getDocument:function(){return this.ownerDocument;},getElementById:function(O,N){var M=this.ownerDocument.getElementById(O);
152
+ if(!M){return null;}for(var L=M.parentNode;L!=this;L=L.parentNode){if(!L){return null;}}return $.element(M,N);},getSelected:function(){return new Elements($A(this.options).filter(function(L){return L.selected;
153
+ }));},getComputedStyle:function(M){if(this.currentStyle){return this.currentStyle[M.camelCase()];}var L=this.getDocument().defaultView.getComputedStyle(this,null);
154
+ return(L)?L.getPropertyValue([M.hyphenate()]):null;},toQueryString:function(){var L=[];this.getElements("input, select, textarea",true).each(function(M){if(!M.name||M.disabled){return ;
155
+ }var N=(M.tagName.toLowerCase()=="select")?Element.getSelected(M).map(function(O){return O.value;}):((M.type=="radio"||M.type=="checkbox")&&!M.checked)?null:M.value;
156
+ $splat(N).each(function(O){if(typeof O!="undefined"){L.push(M.name+"="+encodeURIComponent(O));}});});return L.join("&");},clone:function(O,L){O=O!==false;
157
+ var R=this.cloneNode(O);var N=function(V,U){if(!L){V.removeAttribute("id");}if(Browser.Engine.trident){V.clearAttributes();V.mergeAttributes(U);V.removeAttribute("uid");
158
+ if(V.options){var W=V.options,S=U.options;for(var T=W.length;T--;){W[T].selected=S[T].selected;}}}var X=I[U.tagName.toLowerCase()];if(X&&U[X]){V[X]=U[X];
159
+ }};if(O){var P=R.getElementsByTagName("*"),Q=this.getElementsByTagName("*");for(var M=P.length;M--;){N(P[M],Q[M]);}}N(R,this);return $(R);},destroy:function(){Element.empty(this);
160
+ Element.dispose(this);G(this,true);return null;},empty:function(){$A(this.childNodes).each(function(L){Element.destroy(L);});return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;
161
+ },hasChild:function(L){L=$(L,true);if(!L){return false;}if(Browser.Engine.webkit&&Browser.Engine.version<420){return $A(this.getElementsByTagName(L.tagName)).contains(L);
162
+ }return(this.contains)?(this!=L&&this.contains(L)):!!(this.compareDocumentPosition(L)&16);},match:function(L){return(!L||(L==this)||(Element.get(this,"tag")==L));
163
+ }});Native.implement([Element,Window,Document],{addListener:function(O,N){if(O=="unload"){var L=N,M=this;N=function(){M.removeListener("unload",N);L();
164
+ };}else{H[this.uid]=this;}if(this.addEventListener){this.addEventListener(O,N,false);}else{this.attachEvent("on"+O,N);}return this;},removeListener:function(M,L){if(this.removeEventListener){this.removeEventListener(M,L,false);
165
+ }else{this.detachEvent("on"+M,L);}return this;},retrieve:function(M,L){var O=C(this.uid),N=O[M];if(L!=undefined&&N==undefined){N=O[M]=L;}return $pick(N);
166
+ },store:function(M,L){var N=C(this.uid);N[M]=L;return this;},eliminate:function(L){var M=C(this.uid);delete M[L];return this;}});window.addListener("unload",D);
167
+ })();Element.Properties=new Hash;Element.Properties.style={set:function(A){this.style.cssText=A;},get:function(){return this.style.cssText;},erase:function(){this.style.cssText="";
168
+ }};Element.Properties.tag={get:function(){return this.tagName.toLowerCase();}};Element.Properties.html=(function(){var C=document.createElement("div");
169
+ var A={table:[1,"<table>","</table>"],select:[1,"<select>","</select>"],tbody:[2,"<table><tbody>","</tbody></table>"],tr:[3,"<table><tbody><tr>","</tr></tbody></table>"]};
170
+ A.thead=A.tfoot=A.tbody;var B={set:function(){var E=Array.flatten(arguments).join("");var F=Browser.Engine.trident&&A[this.get("tag")];if(F){var G=C;G.innerHTML=F[1]+E+F[2];
171
+ for(var D=F[0];D--;){G=G.firstChild;}this.empty().adopt(G.childNodes);}else{this.innerHTML=E;}}};B.erase=B.set;return B;})();if(Browser.Engine.webkit&&Browser.Engine.version<420){Element.Properties.text={get:function(){if(this.innerText){return this.innerText;
172
+ }var A=this.ownerDocument.newElement("div",{html:this.innerHTML}).inject(this.ownerDocument.body);var B=A.innerText;A.destroy();return B;}};}Element.Properties.events={set:function(A){this.addEvents(A);
173
+ }};Native.implement([Element,Window,Document],{addEvent:function(E,G){var H=this.retrieve("events",{});H[E]=H[E]||{keys:[],values:[]};if(H[E].keys.contains(G)){return this;
174
+ }H[E].keys.push(G);var F=E,A=Element.Events.get(E),C=G,I=this;if(A){if(A.onAdd){A.onAdd.call(this,G);}if(A.condition){C=function(J){if(A.condition.call(this,J)){return G.call(this,J);
175
+ }return true;};}F=A.base||F;}var D=function(){return G.call(I);};var B=Element.NativeEvents[F];if(B){if(B==2){D=function(J){J=new Event(J,I.getWindow());
176
+ if(C.call(I,J)===false){J.stop();}};}this.addListener(F,D);}H[E].values.push(D);return this;},removeEvent:function(C,B){var A=this.retrieve("events");if(!A||!A[C]){return this;
177
+ }var F=A[C].keys.indexOf(B);if(F==-1){return this;}A[C].keys.splice(F,1);var E=A[C].values.splice(F,1)[0];var D=Element.Events.get(C);if(D){if(D.onRemove){D.onRemove.call(this,B);
178
+ }C=D.base||C;}return(Element.NativeEvents[C])?this.removeListener(C,E):this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;
179
+ },removeEvents:function(A){if($type(A)=="object"){for(var C in A){this.removeEvent(C,A[C]);}return this;}var B=this.retrieve("events");if(!B){return this;
180
+ }if(!A){for(var C in B){this.removeEvents(C);}this.eliminate("events");}else{if(B[A]){while(B[A].keys[0]){this.removeEvent(A,B[A].keys[0]);}B[A]=null;}}return this;
181
+ },fireEvent:function(D,B,A){var C=this.retrieve("events");if(!C||!C[D]){return this;}C[D].keys.each(function(E){E.create({bind:this,delay:A,"arguments":B})();
182
+ },this);return this;},cloneEvents:function(D,A){D=$(D);var C=D.retrieve("events");if(!C){return this;}if(!A){for(var B in C){this.cloneEvents(D,B);}}else{if(C[A]){C[A].keys.each(function(E){this.addEvent(A,E);
183
+ },this);}}return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1};
184
+ (function(){var A=function(B){var C=B.relatedTarget;if(C==undefined){return true;}if(C===false){return false;}return($type(this)!="document"&&C!=this&&C.prefix!="xul"&&!this.hasChild(C));
185
+ };Element.Events=new Hash({mouseenter:{base:"mouseover",condition:A},mouseleave:{base:"mouseout",condition:A},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}});
186
+ })();Element.Properties.styles={set:function(A){this.setStyles(A);}};Element.Properties.opacity={set:function(A,B){if(!B){if(A==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden";
187
+ }}else{if(this.style.visibility!="visible"){this.style.visibility="visible";}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(Browser.Engine.trident){this.style.filter=(A==1)?"":"alpha(opacity="+A*100+")";
188
+ }this.style.opacity=A;this.store("opacity",A);},get:function(){return this.retrieve("opacity",1);}};Element.implement({setOpacity:function(A){return this.set("opacity",A,true);
189
+ },getOpacity:function(){return this.get("opacity");},setStyle:function(B,A){switch(B){case"opacity":return this.set("opacity",parseFloat(A));case"float":B=(Browser.Engine.trident)?"styleFloat":"cssFloat";
190
+ }B=B.camelCase();if($type(A)!="string"){var C=(Element.Styles.get(B)||"@").split(" ");A=$splat(A).map(function(E,D){if(!C[D]){return"";}return($type(E)=="number")?C[D].replace("@",Math.round(E)):E;
191
+ }).join(" ");}else{if(A==String(Number(A))){A=Math.round(A);}}this.style[B]=A;return this;},getStyle:function(G){switch(G){case"opacity":return this.get("opacity");
192
+ case"float":G=(Browser.Engine.trident)?"styleFloat":"cssFloat";}G=G.camelCase();var A=this.style[G];if(!$chk(A)){A=[];for(var F in Element.ShortStyles){if(G!=F){continue;
193
+ }for(var E in Element.ShortStyles[F]){A.push(this.getStyle(E));}return A.join(" ");}A=this.getComputedStyle(G);}if(A){A=String(A);var C=A.match(/rgba?\([\d\s,]+\)/);
194
+ if(C){A=A.replace(C[0],C[0].rgbToHex());}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(A)))){if(G.test(/^(height|width)$/)){var B=(G=="width")?["left","right"]:["top","bottom"],D=0;
195
+ B.each(function(H){D+=this.getStyle("border-"+H+"-width").toInt()+this.getStyle("padding-"+H).toInt();},this);return this["offset"+G.capitalize()]-D+"px";
196
+ }if((Browser.Engine.presto)&&String(A).test("px")){return A;}if(G.test(/(border(.+)Width|margin|padding)/)){return"0px";}}return A;},setStyles:function(B){for(var A in B){this.setStyle(A,B[A]);
197
+ }return this;},getStyles:function(){var A={};Array.each(arguments,function(B){A[B]=this.getStyle(B);},this);return A;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"});
198
+ Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(G){var F=Element.ShortStyles;
199
+ var B=Element.Styles;["margin","padding"].each(function(H){var I=H+G;F[H][I]=B[I]="@px";});var E="border"+G;F.border[E]=B[E]="@px @ rgb(@, @, @)";var D=E+"Width",A=E+"Style",C=E+"Color";
200
+ F[E]={};F.borderWidth[D]=F[E][D]=B[D]="@px";F.borderStyle[A]=F[E][A]=B[A]="@";F.borderColor[C]=F[E][C]=B[C]="rgb(@, @, @)";});(function(){Element.implement({scrollTo:function(H,I){if(B(this)){this.getWindow().scrollTo(H,I);
201
+ }else{this.scrollLeft=H;this.scrollTop=I;}return this;},getSize:function(){if(B(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight};
202
+ },getScrollSize:function(){if(B(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(B(this)){return this.getWindow().getScroll();
203
+ }return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var I=this,H={x:0,y:0};while(I&&!B(I)){H.x+=I.scrollLeft;H.y+=I.scrollTop;I=I.parentNode;
204
+ }return H;},getOffsetParent:function(){var H=this;if(B(H)){return null;}if(!Browser.Engine.trident){return H.offsetParent;}while((H=H.parentNode)&&!B(H)){if(D(H,"position")!="static"){return H;
205
+ }}return null;},getOffsets:function(){if(Browser.Engine.trident){var L=this.getBoundingClientRect(),J=this.getDocument().documentElement;return{x:L.left+J.scrollLeft-J.clientLeft,y:L.top+J.scrollTop-J.clientTop};
206
+ }var I=this,H={x:0,y:0};if(B(this)){return H;}while(I&&!B(I)){H.x+=I.offsetLeft;H.y+=I.offsetTop;if(Browser.Engine.gecko){if(!F(I)){H.x+=C(I);H.y+=G(I);
207
+ }var K=I.parentNode;if(K&&D(K,"overflow")!="visible"){H.x+=C(K);H.y+=G(K);}}else{if(I!=this&&Browser.Engine.webkit){H.x+=C(I);H.y+=G(I);}}I=I.offsetParent;
208
+ }if(Browser.Engine.gecko&&!F(this)){H.x-=C(this);H.y-=G(this);}return H;},getPosition:function(K){if(B(this)){return{x:0,y:0};}var L=this.getOffsets(),I=this.getScrolls();
209
+ var H={x:L.x-I.x,y:L.y-I.y};var J=(K&&(K=$(K)))?K.getPosition():{x:0,y:0};return{x:H.x-J.x,y:H.y-J.y};},getCoordinates:function(J){if(B(this)){return this.getWindow().getCoordinates();
210
+ }var H=this.getPosition(J),I=this.getSize();var K={left:H.x,top:H.y,width:I.x,height:I.y};K.right=K.left+K.width;K.bottom=K.top+K.height;return K;},computePosition:function(H){return{left:H.x-E(this,"margin-left"),top:H.y-E(this,"margin-top")};
211
+ },position:function(H){return this.setStyles(this.computePosition(H));}});Native.implement([Document,Window],{getSize:function(){var I=this.getWindow();
212
+ if(Browser.Engine.presto||Browser.Engine.webkit){return{x:I.innerWidth,y:I.innerHeight};}var H=A(this);return{x:H.clientWidth,y:H.clientHeight};},getScroll:function(){var I=this.getWindow();
213
+ var H=A(this);return{x:I.pageXOffset||H.scrollLeft,y:I.pageYOffset||H.scrollTop};},getScrollSize:function(){var I=A(this);var H=this.getSize();return{x:Math.max(I.scrollWidth,H.x),y:Math.max(I.scrollHeight,H.y)};
214
+ },getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var H=this.getSize();return{top:0,left:0,bottom:H.y,right:H.x,height:H.y,width:H.x};
215
+ }});var D=Element.getComputedStyle;function E(H,I){return D(H,I).toInt()||0;}function F(H){return D(H,"-moz-box-sizing")=="border-box";}function G(H){return E(H,"border-top-width");
216
+ }function C(H){return E(H,"border-left-width");}function B(H){return(/^(?:body|html)$/i).test(H.tagName);}function A(H){var I=H.getDocument();return(!I.compatMode||I.compatMode=="CSS1Compat")?I.html:I.body;
217
+ }})();Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y;
218
+ },getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x;
219
+ },getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Document,Element],{getElements:function(H,G){H=H.split(",");
220
+ var C,E={};for(var D=0,B=H.length;D<B;D++){var A=H[D],F=Selectors.Utils.search(this,A,E);if(D!=0&&F.item){F=$A(F);}C=(D==0)?F:(C.item)?$A(C).concat(F):C.concat(F);
221
+ }return new Elements(C,{ddup:(H.length>1),cash:!G});}});Element.implement({match:function(B){if(!B||(B==this)){return true;}var D=Selectors.Utils.parseTagAndID(B);
222
+ var A=D[0],E=D[1];if(!Selectors.Filters.byID(this,E)||!Selectors.Filters.byTag(this,A)){return false;}var C=Selectors.Utils.parseSelector(B);return(C)?Selectors.Utils.filter(this,C,{}):true;
223
+ }});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)};
224
+ Selectors.Utils={chk:function(B,C){if(!C){return true;}var A=$uid(B);if(!C[A]){return C[A]=true;}return false;},parseNthArgument:function(F){if(Selectors.Cache.nth[F]){return Selectors.Cache.nth[F];
225
+ }var C=F.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!C){return false;}var E=parseInt(C[1]);var B=(E||E===0)?E:1;var D=C[2]||false;var A=parseInt(C[3])||0;
226
+ if(B!=0){A--;while(A<1){A+=B;}while(A>=B){A-=B;}}else{B=A;D="index";}switch(D){case"n":C={a:B,b:A,special:"n"};break;case"odd":C={a:2,b:0,special:"n"};
227
+ break;case"even":C={a:2,b:1,special:"n"};break;case"first":C={a:0,special:"index"};break;case"last":C={special:"last-child"};break;case"only":C={special:"only-child"};
228
+ break;default:C={a:(B-1),special:"index"};}return Selectors.Cache.nth[F]=C;},parseSelector:function(E){if(Selectors.Cache.parsed[E]){return Selectors.Cache.parsed[E];
229
+ }var D,H={classes:[],pseudos:[],attributes:[]};while((D=Selectors.RegExps.combined.exec(E))){var I=D[1],G=D[2],F=D[3],B=D[5],C=D[6],J=D[7];if(I){H.classes.push(I);
230
+ }else{if(C){var A=Selectors.Pseudo.get(C);if(A){H.pseudos.push({parser:A,argument:J});}else{H.attributes.push({name:C,operator:"=",value:J});}}else{if(G){H.attributes.push({name:G,operator:F,value:B});
231
+ }}}}if(!H.classes.length){delete H.classes;}if(!H.attributes.length){delete H.attributes;}if(!H.pseudos.length){delete H.pseudos;}if(!H.classes&&!H.attributes&&!H.pseudos){H=null;
232
+ }return Selectors.Cache.parsed[E]=H;},parseTagAndID:function(B){var A=B.match(Selectors.RegExps.tag);var C=B.match(Selectors.RegExps.id);return[(A)?A[1]:"*",(C)?C[1]:false];
233
+ },filter:function(F,C,E){var D;if(C.classes){for(D=C.classes.length;D--;D){var G=C.classes[D];if(!Selectors.Filters.byClass(F,G)){return false;}}}if(C.attributes){for(D=C.attributes.length;
234
+ D--;D){var B=C.attributes[D];if(!Selectors.Filters.byAttribute(F,B.name,B.operator,B.value)){return false;}}}if(C.pseudos){for(D=C.pseudos.length;D--;D){var A=C.pseudos[D];
235
+ if(!Selectors.Filters.byPseudo(F,A.parser,A.argument,E)){return false;}}}return true;},getByTagAndID:function(B,A,D){if(D){var C=(B.getElementById)?B.getElementById(D,true):Element.getElementById(B,D,true);
236
+ return(C&&Selectors.Filters.byTag(C,A))?[C]:[];}else{return B.getElementsByTagName(A);}},search:function(I,H,N){var B=[];var C=H.trim().replace(Selectors.RegExps.splitter,function(Y,X,W){B.push(X);
237
+ return":)"+W;}).split(":)");var J,E,U;for(var T=0,P=C.length;T<P;T++){var S=C[T];if(T==0&&Selectors.RegExps.quick.test(S)){J=I.getElementsByTagName(S);
238
+ continue;}var A=B[T-1];var K=Selectors.Utils.parseTagAndID(S);var V=K[0],L=K[1];if(T==0){J=Selectors.Utils.getByTagAndID(I,V,L);}else{var D={},G=[];for(var R=0,Q=J.length;
239
+ R<Q;R++){G=Selectors.Getters[A](G,J[R],V,L,D);}J=G;}var F=Selectors.Utils.parseSelector(S);if(F){E=[];for(var O=0,M=J.length;O<M;O++){U=J[O];if(Selectors.Utils.filter(U,F,N)){E.push(U);
240
+ }}J=E;}}return J;}};Selectors.Getters={" ":function(H,G,I,A,E){var D=Selectors.Utils.getByTagAndID(G,I,A);for(var C=0,B=D.length;C<B;C++){var F=D[C];if(Selectors.Utils.chk(F,E)){H.push(F);
241
+ }}return H;},">":function(H,G,I,A,F){var C=Selectors.Utils.getByTagAndID(G,I,A);for(var E=0,D=C.length;E<D;E++){var B=C[E];if(B.parentNode==G&&Selectors.Utils.chk(B,F)){H.push(B);
242
+ }}return H;},"+":function(C,B,A,E,D){while((B=B.nextSibling)){if(B.nodeType==1){if(Selectors.Utils.chk(B,D)&&Selectors.Filters.byTag(B,A)&&Selectors.Filters.byID(B,E)){C.push(B);
243
+ }break;}}return C;},"~":function(C,B,A,E,D){while((B=B.nextSibling)){if(B.nodeType==1){if(!Selectors.Utils.chk(B,D)){break;}if(Selectors.Filters.byTag(B,A)&&Selectors.Filters.byID(B,E)){C.push(B);
244
+ }}}return C;}};Selectors.Filters={byTag:function(B,A){return(A=="*"||(B.tagName&&B.tagName.toLowerCase()==A));},byID:function(A,B){return(!B||(A.id&&A.id==B));
245
+ },byClass:function(B,A){return(B.className&&B.className.contains(A," "));},byPseudo:function(A,D,C,B){return D.call(A,C,B);},byAttribute:function(C,D,B,E){var A=Element.prototype.getProperty.call(C,D);
246
+ if(!A){return(B=="!=");}if(!B||E==undefined){return true;}switch(B){case"=":return(A==E);case"*=":return(A.contains(E));case"^=":return(A.substr(0,E.length)==E);
247
+ case"$=":return(A.substr(A.length-E.length)==E);case"!=":return(A!=E);case"~=":return A.contains(E," ");case"|=":return A.contains(E,"-");}return false;
248
+ }};Selectors.Pseudo=new Hash({checked:function(){return this.checked;},empty:function(){return !(this.innerText||this.textContent||"").length;},not:function(A){return !Element.match(this,A);
249
+ },contains:function(A){return(this.innerText||this.textContent||"").contains(A);},"first-child":function(){return Selectors.Pseudo.index.call(this,0);},"last-child":function(){var A=this;
250
+ while((A=A.nextSibling)){if(A.nodeType==1){return false;}}return true;},"only-child":function(){var B=this;while((B=B.previousSibling)){if(B.nodeType==1){return false;
251
+ }}var A=this;while((A=A.nextSibling)){if(A.nodeType==1){return false;}}return true;},"nth-child":function(G,E){G=(G==undefined)?"n":G;var C=Selectors.Utils.parseNthArgument(G);
252
+ if(C.special!="n"){return Selectors.Pseudo[C.special].call(this,C.a,E);}var F=0;E.positions=E.positions||{};var D=$uid(this);if(!E.positions[D]){var B=this;
253
+ while((B=B.previousSibling)){if(B.nodeType!=1){continue;}F++;var A=E.positions[$uid(B)];if(A!=undefined){F=A+F;break;}}E.positions[D]=F;}return(E.positions[D]%C.a==C.b);
254
+ },index:function(A){var B=this,C=0;while((B=B.previousSibling)){if(B.nodeType==1&&++C>A){return false;}}return(C==A);},even:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n+1",A);
255
+ },odd:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n",A);}});Element.Events.domready={onAdd:function(A){if(Browser.loaded){A.call(this);
256
+ }}};(function(){var B=function(){if(Browser.loaded){return ;}Browser.loaded=true;window.fireEvent("domready");document.fireEvent("domready");};if(Browser.Engine.trident){var A=document.createElement("div");
257
+ (function(){($try(function(){A.doScroll("left");return $(A).inject(document.body).set("html","temp").dispose();}))?B():arguments.callee.delay(50);})();
258
+ }else{if(Browser.Engine.webkit&&Browser.Engine.version<525){(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50);
259
+ })();}else{window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}}})();var JSON=new Hash({$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},$replaceChars:function(A){return JSON.$specialChars[A]||"\\u00"+Math.floor(A.charCodeAt()/16).toString(16)+(A.charCodeAt()%16).toString(16);
260
+ },encode:function(B){switch($type(B)){case"string":return'"'+B.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(B.map(JSON.encode).filter($defined))+"]";
261
+ case"object":case"hash":var A=[];Hash.each(B,function(E,D){var C=JSON.encode(E);if(C){A.push(JSON.encode(D)+":"+C);}});return"{"+A+"}";case"number":case"boolean":return String(B);
262
+ case false:return"null";}return null;},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null;
263
+ }return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(B,A){this.key=B;
264
+ this.setOptions(A);},write:function(B){B=encodeURIComponent(B);if(this.options.domain){B+="; domain="+this.options.domain;}if(this.options.path){B+="; path="+this.options.path;
265
+ }if(this.options.duration){var A=new Date();A.setTime(A.getTime()+this.options.duration*24*60*60*1000);B+="; expires="+A.toGMTString();}if(this.options.secure){B+="; secure";
266
+ }this.options.document.cookie=this.key+"="+B;return this;},read:function(){var A=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)");
267
+ return(A)?decodeURIComponent(A[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(B,C,A){return new Cookie(B,A).write(C);
268
+ };Cookie.read=function(A){return new Cookie(A).read();};Cookie.dispose=function(B,A){return new Cookie(B,A).dispose();};var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:"high",allowScriptAccess:"always",wMode:"transparent",swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object;
269
+ },initialize:function(L,M){this.instance="Swiff_"+$time();this.setOptions(M);M=this.options;var B=this.id=M.id||this.instance;var A=$(M.container);Swiff.CallBacks[this.instance]={};
270
+ var E=M.params,G=M.vars,F=M.callBacks;var H=$extend({height:M.height,width:M.width},M.properties);var K=this;for(var D in F){Swiff.CallBacks[this.instance][D]=(function(N){return function(){return N.apply(K.object,arguments);
271
+ };})(F[D]);G[D]="Swiff.CallBacks."+this.instance+"."+D;}E.flashVars=Hash.toQueryString(G);if(Browser.Engine.trident){H.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
272
+ E.movie=L;}else{H.type="application/x-shockwave-flash";H.data=L;}var J='<object id="'+B+'"';for(var I in H){J+=" "+I+'="'+H[I]+'"';}J+=">";for(var C in E){if(E[C]){J+='<param name="'+C+'" value="'+E[C]+'" />';
273
+ }}J+="</object>";this.object=((A)?A.empty():new Element("div")).set("html",J).firstChild;},replaces:function(A){A=$(A,true);A.parentNode.replaceChild(this.toElement(),A);
274
+ return this;},inject:function(A){$(A,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments));
275
+ }});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction('<invoke name="'+fn+'" returntype="javascript">'+__flash__argumentsToXML(arguments,2)+"</invoke>");
276
+ return eval(rs);};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore"},initialize:function(A){this.subject=this.subject||this;
277
+ this.setOptions(A);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var B=this.options.wait;if(B===false){this.options.link="cancel";
278
+ }},getTransition:function(){return function(A){return -(Math.cos(Math.PI*A)-1)/2;};},step:function(){var A=$time();if(A<this.time+this.options.duration){var B=this.transition((A-this.time)/this.options.duration);
279
+ this.set(this.compute(this.from,this.to,B));}else{this.set(this.compute(this.from,this.to,1));this.complete();}},set:function(A){return A;},compute:function(C,B,A){return Fx.compute(C,B,A);
280
+ },check:function(A){if(!this.timer){return true;}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));
281
+ return false;}return false;},start:function(B,A){if(!this.check(arguments.callee,B,A)){return this;}this.from=B;this.to=A;this.time=0;this.transition=this.getTransition();
282
+ this.startTimer();this.onStart();return this;},complete:function(){if(this.stopTimer()){this.onComplete();}return this;},cancel:function(){if(this.stopTimer()){this.onCancel();
283
+ }return this;},onStart:function(){this.fireEvent("start",this.subject);},onComplete:function(){this.fireEvent("complete",this.subject);if(!this.callChain()){this.fireEvent("chainComplete",this.subject);
284
+ }},onCancel:function(){this.fireEvent("cancel",this.subject).clearChain();},pause:function(){this.stopTimer();return this;},resume:function(){this.startTimer();
285
+ return this;},stopTimer:function(){if(!this.timer){return false;}this.time=$time()-this.time;this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer){return false;
286
+ }this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true;}});Fx.compute=function(C,B,A){return(B-C)*A+C;
287
+ };Fx.Durations={"short":250,normal:500,"long":1000};Fx.CSS=new Class({Extends:Fx,prepare:function(D,E,B){B=$splat(B);var C=B[1];if(!$chk(C)){B[1]=B[0];
288
+ B[0]=D.getStyle(E);}var A=B.map(this.parse);return{from:A[0],to:A[1]};},parse:function(A){A=$lambda(A)();A=(typeof A=="string")?A.split(" "):$splat(A);
289
+ return A.map(function(C){C=String(C);var B=false;Fx.CSS.Parsers.each(function(F,E){if(B){return ;}var D=F.parse(C);if($chk(D)){B={value:D,parser:F};}});
290
+ B=B||{value:C,parser:Fx.CSS.Parsers.String};return B;});},compute:function(D,C,B){var A=[];(Math.min(D.length,C.length)).times(function(E){A.push({value:D[E].parser.compute(D[E].value,C[E].value,B),parser:D[E].parser});
291
+ });A.$family={name:"fx:css:value"};return A;},serve:function(C,B){if($type(C)!="fx:css:value"){C=this.parse(C);}var A=[];C.each(function(D){A=A.concat(D.parser.serve(D.value,B));
292
+ });return A;},render:function(A,D,C,B){A.setStyle(D,this.serve(C,B));},search:function(A){if(Fx.CSS.Cache[A]){return Fx.CSS.Cache[A];}var B={};Array.each(document.styleSheets,function(E,D){var C=E.href;
293
+ if(C&&C.contains("://")&&!C.contains(document.domain)){return ;}var F=E.rules||E.cssRules;Array.each(F,function(I,G){if(!I.style){return ;}var H=(I.selectorText)?I.selectorText.replace(/^\w+/,function(J){return J.toLowerCase();
294
+ }):null;if(!H||!H.test("^"+A+"$")){return ;}Element.Styles.each(function(K,J){if(!I.style[J]||Element.ShortStyles[J]){return ;}K=String(I.style[J]);B[J]=(K.test(/^rgb/))?K.rgbToHex():K;
295
+ });});});return Fx.CSS.Cache[A]=B;}});Fx.CSS.Cache={};Fx.CSS.Parsers=new Hash({Color:{parse:function(A){if(A.match(/^#[0-9a-f]{3,6}$/i)){return A.hexToRgb(true);
296
+ }return((A=A.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[A[1],A[2],A[3]]:false;},compute:function(C,B,A){return C.map(function(E,D){return Math.round(Fx.compute(C[D],B[D],A));
297
+ });},serve:function(A){return A.map(Number);}},Number:{parse:parseFloat,compute:Fx.compute,serve:function(B,A){return(A)?B+A:B;}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}});
298
+ Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(B,A){this.element=this.subject=$(B);this.parent(A);},set:function(B,A){if(arguments.length==1){A=B;
299
+ B=this.property||this.options.property;}this.render(this.element,B,A,this.options.unit);return this;},start:function(C,E,D){if(!this.check(arguments.callee,C,E,D)){return this;
300
+ }var B=Array.flatten(arguments);this.property=this.options.property||B.shift();var A=this.prepare(this.element,this.property,B);return this.parent(A.from,A.to);
301
+ }});Element.Properties.tween={set:function(A){var B=this.retrieve("tween");if(B){B.cancel();}return this.eliminate("tween").store("tween:options",$extend({link:"cancel"},A));
302
+ },get:function(A){if(A||!this.retrieve("tween")){if(A||!this.retrieve("tween:options")){this.set("tween",A);}this.store("tween",new Fx.Tween(this,this.retrieve("tween:options")));
303
+ }return this.retrieve("tween");}};Element.implement({tween:function(A,C,B){this.get("tween").start(arguments);return this;},fade:function(C){var E=this.get("tween"),D="opacity",A;
304
+ C=$pick(C,"toggle");switch(C){case"in":E.start(D,1);break;case"out":E.start(D,0);break;case"show":E.set(D,1);break;case"hide":E.set(D,0);break;case"toggle":var B=this.retrieve("fade:flag",this.get("opacity")==1);
305
+ E.start(D,(B)?0:1);this.store("fade:flag",!B);A=true;break;default:E.start(D,arguments);}if(!A){this.eliminate("fade:flag");}return this;},highlight:function(C,A){if(!A){A=this.retrieve("highlight:original",this.getStyle("background-color"));
306
+ A=(A=="transparent")?"#fff":A;}var B=this.get("tween");B.start("background-color",C||"#ffff88",A).chain(function(){this.setStyle("background-color",this.retrieve("highlight:original"));
307
+ B.callChain();}.bind(this));return this;}});Fx.Morph=new Class({Extends:Fx.CSS,initialize:function(B,A){this.element=this.subject=$(B);this.parent(A);},set:function(A){if(typeof A=="string"){A=this.search(A);
308
+ }for(var B in A){this.render(this.element,B,A[B],this.options.unit);}return this;},compute:function(E,D,C){var A={};for(var B in E){A[B]=this.parent(E[B],D[B],C);
309
+ }return A;},start:function(B){if(!this.check(arguments.callee,B)){return this;}if(typeof B=="string"){B=this.search(B);}var E={},D={};for(var C in B){var A=this.prepare(this.element,C,B[C]);
310
+ E[C]=A.from;D[C]=A.to;}return this.parent(E,D);}});Element.Properties.morph={set:function(A){var B=this.retrieve("morph");if(B){B.cancel();}return this.eliminate("morph").store("morph:options",$extend({link:"cancel"},A));
311
+ },get:function(A){if(A||!this.retrieve("morph")){if(A||!this.retrieve("morph:options")){this.set("morph",A);}this.store("morph",new Fx.Morph(this,this.retrieve("morph:options")));
312
+ }return this.retrieve("morph");}};Element.implement({morph:function(A){this.get("morph").start(A);return this;}});Fx.implement({getTransition:function(){var A=this.options.transition||Fx.Transitions.Sine.easeInOut;
313
+ if(typeof A=="string"){var B=A.split(":");A=Fx.Transitions;A=A[B[0]]||A[B[0].capitalize()];if(B[1]){A=A["ease"+B[1].capitalize()+(B[2]?B[2].capitalize():"")];
314
+ }}return A;}});Fx.Transition=function(B,A){A=$splat(A);return $extend(B,{easeIn:function(C){return B(C,A);},easeOut:function(C){return 1-B(1-C,A);},easeInOut:function(C){return(C<=0.5)?B(2*C,A)/2:(2-B(2*(1-C),A))/2;
315
+ }});};Fx.Transitions=new Hash({linear:$arguments(0)});Fx.Transitions.extend=function(A){for(var B in A){Fx.Transitions[B]=new Fx.Transition(A[B]);}};Fx.Transitions.extend({Pow:function(B,A){return Math.pow(B,A[0]||6);
316
+ },Expo:function(A){return Math.pow(2,8*(A-1));},Circ:function(A){return 1-Math.sin(Math.acos(A));},Sine:function(A){return 1-Math.sin((1-A)*Math.PI/2);
317
+ },Back:function(B,A){A=A[0]||1.618;return Math.pow(B,2)*((A+1)*B-A);},Bounce:function(D){var C;for(var B=0,A=1;1;B+=A,A/=2){if(D>=(7-4*B)/11){C=A*A-Math.pow((11-6*B-11*D)/4,2);
318
+ break;}}return C;},Elastic:function(B,A){return Math.pow(2,10*--B)*Math.cos(20*B*Math.PI*(A[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(B,A){Fx.Transitions[B]=new Fx.Transition(function(C){return Math.pow(C,[A+2]);
319
+ });});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(A){this.xhr=new Browser.Request();
320
+ this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ;
321
+ }this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};
322
+ this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300));
323
+ },processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts);
324
+ },success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain();
325
+ },failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B);
326
+ return this;},getHeader:function(A){return $try(function(){return this.xhr.getResponseHeader(A);}.bind(this));},check:function(A){if(!this.running){return true;
327
+ }switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));return false;}return false;
328
+ },send:function(I){if(!this.check(arguments.callee,I)){return this;}this.running=true;var G=$type(I);if(G=="string"||G=="element"){I={data:I};}var D=this.options;
329
+ I=$extend({data:D.data,url:D.url,method:D.method},I);var E=I.data,B=I.url,A=I.method;switch($type(E)){case"element":E=$(E).toQueryString();break;case"object":case"hash":E=Hash.toQueryString(E);
330
+ }if(this.options.format){var H="format="+this.options.format;E=(E)?H+"&"+E:H;}if(this.options.emulation&&["put","delete"].contains(A)){var F="_method="+A;
331
+ E=(E)?F+"&"+E:F;A="post";}if(this.options.urlEncoded&&A=="post"){var C=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+C);
332
+ }if(E&&A=="get"){B=B+(B.contains("?")?"&":"?")+E;E=null;}this.xhr.open(A.toUpperCase(),B,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this);
333
+ this.headers.each(function(K,J){try{this.xhr.setRequestHeader(J,K);}catch(L){this.fireEvent("exception",[J,K]);}},this);this.fireEvent("request");this.xhr.send(E);
334
+ if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this;}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;
335
+ this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var A={};["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(B){A[B]=function(){var C=Array.link(arguments,{url:String.type,data:$defined});
336
+ return this.send($extend(C,{method:B.toLowerCase()}));};});Request.implement(A);})();Element.Properties.send={set:function(A){var B=this.retrieve("send");
337
+ if(B){B.cancel();}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},A));
338
+ },get:function(A){if(A||!this.retrieve("send")){if(A||!this.retrieve("send:options")){this.set("send",A);}this.store("send",new Request(this.retrieve("send:options")));
339
+ }return this.retrieve("send");}};Element.implement({send:function(A){var B=this.get("send");B.send({data:this,url:A||B.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,evalScripts:true,filter:false},processHTML:function(C){var B=C.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
340
+ C=(B)?B[1]:C;var A=new Element("div");return $try(function(){var D="<root>"+C+"</root>",G;if(Browser.Engine.trident){G=new ActiveXObject("Microsoft.XMLDOM");
341
+ G.async=false;G.loadXML(D);}else{G=new DOMParser().parseFromString(D,"text/xml");}D=G.getElementsByTagName("root")[0];for(var F=0,E=D.childNodes.length;
342
+ F<E;F++){var H=Element.clone(D.childNodes[F],true,true);if(H){A.grab(H);}}return A;})||A.set("html",C);},success:function(D){var C=this.options,B=this.response;
343
+ B.html=D.stripScripts(function(E){B.javascript=E;});var A=this.processHTML(B.html);B.tree=A.childNodes;B.elements=A.getElements("*");if(C.filter){B.tree=B.elements.filter(C.filter);
344
+ }if(C.update){$(C.update).empty().set("html",B.html);}if(C.evalScripts){$exec(B.javascript);}this.onSuccess(B.tree,B.elements,B.html,B.javascript);}});
345
+ Element.Properties.load={set:function(A){var B=this.retrieve("load");if(B){B.cancel();}return this.eliminate("load").store("load:options",$extend({data:this,link:"cancel",update:this,method:"get"},A));
346
+ },get:function(A){if(A||!this.retrieve("load")){if(A||!this.retrieve("load:options")){this.set("load",A);}this.store("load",new Request.HTML(this.retrieve("load:options")));
347
+ }return this.retrieve("load");}};Element.implement({load:function(){this.get("load").send(Array.link(arguments,{data:Object.type,url:String.type}));return this;
348
+ }});Request.JSON=new Class({Extends:Request,options:{secure:true},initialize:function(A){this.parent(A);this.headers.extend({Accept:"application/json","X-Request":"JSON"});
349
+ },success:function(A){this.response.json=JSON.decode(A,this.options.secure);this.onSuccess(this.response.json,A);}});
includes/js/mootools-1.2.1-core-yc.js.gz ADDED
Binary file
includes/js/prototype-1.6.0.3.js ADDED
@@ -0,0 +1,4320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Prototype JavaScript framework, version 1.6.0.3
2
+ * (c) 2005-2008 Sam Stephenson
3
+ *
4
+ * Prototype is freely distributable under the terms of an MIT-style license.
5
+ * For details, see the Prototype web site: http://www.prototypejs.org/
6
+ *
7
+ *--------------------------------------------------------------------------*/
8
+
9
+ var Prototype = {
10
+ Version: '1.6.0.3',
11
+
12
+ Browser: {
13
+ IE: !!(window.attachEvent &&
14
+ navigator.userAgent.indexOf('Opera') === -1),
15
+ Opera: navigator.userAgent.indexOf('Opera') > -1,
16
+ WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
17
+ Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
18
+ navigator.userAgent.indexOf('KHTML') === -1,
19
+ MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
20
+ },
21
+
22
+ BrowserFeatures: {
23
+ XPath: !!document.evaluate,
24
+ SelectorsAPI: !!document.querySelector,
25
+ ElementExtensions: !!window.HTMLElement,
26
+ SpecificElementExtensions:
27
+ document.createElement('div')['__proto__'] &&
28
+ document.createElement('div')['__proto__'] !==
29
+ document.createElement('form')['__proto__']
30
+ },
31
+
32
+ ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
33
+ JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
34
+
35
+ emptyFunction: function() { },
36
+ K: function(x) { return x }
37
+ };
38
+
39
+ if (Prototype.Browser.MobileSafari)
40
+ Prototype.BrowserFeatures.SpecificElementExtensions = false;
41
+
42
+
43
+ /* Based on Alex Arnell's inheritance implementation. */
44
+ var Class = {
45
+ create: function() {
46
+ var parent = null, properties = $A(arguments);
47
+ if (Object.isFunction(properties[0]))
48
+ parent = properties.shift();
49
+
50
+ function klass() {
51
+ this.initialize.apply(this, arguments);
52
+ }
53
+
54
+ Object.extend(klass, Class.Methods);
55
+ klass.superclass = parent;
56
+ klass.subclasses = [];
57
+
58
+ if (parent) {
59
+ var subclass = function() { };
60
+ subclass.prototype = parent.prototype;
61
+ klass.prototype = new subclass;
62
+ parent.subclasses.push(klass);
63
+ }
64
+
65
+ for (var i = 0; i < properties.length; i++)
66
+ klass.addMethods(properties[i]);
67
+
68
+ if (!klass.prototype.initialize)
69
+ klass.prototype.initialize = Prototype.emptyFunction;
70
+
71
+ klass.prototype.constructor = klass;
72
+
73
+ return klass;
74
+ }
75
+ };
76
+
77
+ Class.Methods = {
78
+ addMethods: function(source) {
79
+ var ancestor = this.superclass && this.superclass.prototype;
80
+ var properties = Object.keys(source);
81
+
82
+ if (!Object.keys({ toString: true }).length)
83
+ properties.push("toString", "valueOf");
84
+
85
+ for (var i = 0, length = properties.length; i < length; i++) {
86
+ var property = properties[i], value = source[property];
87
+ if (ancestor && Object.isFunction(value) &&
88
+ value.argumentNames().first() == "$super") {
89
+ var method = value;
90
+ value = (function(m) {
91
+ return function() { return ancestor[m].apply(this, arguments) };
92
+ })(property).wrap(method);
93
+
94
+ value.valueOf = method.valueOf.bind(method);
95
+ value.toString = method.toString.bind(method);
96
+ }
97
+ this.prototype[property] = value;
98
+ }
99
+
100
+ return this;
101
+ }
102
+ };
103
+
104
+ var Abstract = { };
105
+
106
+ Object.extend = function(destination, source) {
107
+ for (var property in source)
108
+ destination[property] = source[property];
109
+ return destination;
110
+ };
111
+
112
+ Object.extend(Object, {
113
+ inspect: function(object) {
114
+ try {
115
+ if (Object.isUndefined(object)) return 'undefined';
116
+ if (object === null) return 'null';
117
+ return object.inspect ? object.inspect() : String(object);
118
+ } catch (e) {
119
+ if (e instanceof RangeError) return '...';
120
+ throw e;
121
+ }
122
+ },
123
+
124
+ toJSON: function(object) {
125
+ var type = typeof object;
126
+ switch (type) {
127
+ case 'undefined':
128
+ case 'function':
129
+ case 'unknown': return;
130
+ case 'boolean': return object.toString();
131
+ }
132
+
133
+ if (object === null) return 'null';
134
+ if (object.toJSON) return object.toJSON();
135
+ if (Object.isElement(object)) return;
136
+
137
+ var results = [];
138
+ for (var property in object) {
139
+ var value = Object.toJSON(object[property]);
140
+ if (!Object.isUndefined(value))
141
+ results.push(property.toJSON() + ': ' + value);
142
+ }
143
+
144
+ return '{' + results.join(', ') + '}';
145
+ },
146
+
147
+ toQueryString: function(object) {
148
+ return $H(object).toQueryString();
149
+ },
150
+
151
+ toHTML: function(object) {
152
+ return object && object.toHTML ? object.toHTML() : String.interpret(object);
153
+ },
154
+
155
+ keys: function(object) {
156
+ var keys = [];
157
+ for (var property in object)
158
+ keys.push(property);
159
+ return keys;
160
+ },
161
+
162
+ values: function(object) {
163
+ var values = [];
164
+ for (var property in object)
165
+ values.push(object[property]);
166
+ return values;
167
+ },
168
+
169
+ clone: function(object) {
170
+ return Object.extend({ }, object);
171
+ },
172
+
173
+ isElement: function(object) {
174
+ return !!(object && object.nodeType == 1);
175
+ },
176
+
177
+ isArray: function(object) {
178
+ return object != null && typeof object == "object" &&
179
+ 'splice' in object && 'join' in object;
180
+ },
181
+
182
+ isHash: function(object) {
183
+ return object instanceof Hash;
184
+ },
185
+
186
+ isFunction: function(object) {
187
+ return typeof object == "function";
188
+ },
189
+
190
+ isString: function(object) {
191
+ return typeof object == "string";
192
+ },
193
+
194
+ isNumber: function(object) {
195
+ return typeof object == "number";
196
+ },
197
+
198
+ isUndefined: function(object) {
199
+ return typeof object == "undefined";
200
+ }
201
+ });
202
+
203
+ Object.extend(Function.prototype, {
204
+ argumentNames: function() {
205
+ var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
206
+ .replace(/\s+/g, '').split(',');
207
+ return names.length == 1 && !names[0] ? [] : names;
208
+ },
209
+
210
+ bind: function() {
211
+ if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
212
+ var __method = this, args = $A(arguments), object = args.shift();
213
+ return function() {
214
+ return __method.apply(object, args.concat($A(arguments)));
215
+ }
216
+ },
217
+
218
+ bindAsEventListener: function() {
219
+ var __method = this, args = $A(arguments), object = args.shift();
220
+ return function(event) {
221
+ return __method.apply(object, [event || window.event].concat(args));
222
+ }
223
+ },
224
+
225
+ curry: function() {
226
+ if (!arguments.length) return this;
227
+ var __method = this, args = $A(arguments);
228
+ return function() {
229
+ return __method.apply(this, args.concat($A(arguments)));
230
+ }
231
+ },
232
+
233
+ delay: function() {
234
+ var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
235
+ return window.setTimeout(function() {
236
+ return __method.apply(__method, args);
237
+ }, timeout);
238
+ },
239
+
240
+ defer: function() {
241
+ var args = [0.01].concat($A(arguments));
242
+ return this.delay.apply(this, args);
243
+ },
244
+
245
+ wrap: function(wrapper) {
246
+ var __method = this;
247
+ return function() {
248
+ return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
249
+ }
250
+ },
251
+
252
+ methodize: function() {
253
+ if (this._methodized) return this._methodized;
254
+ var __method = this;
255
+ return this._methodized = function() {
256
+ return __method.apply(null, [this].concat($A(arguments)));
257
+ };
258
+ }
259
+ });
260
+
261
+ Date.prototype.toJSON = function() {
262
+ return '"' + this.getUTCFullYear() + '-' +
263
+ (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
264
+ this.getUTCDate().toPaddedString(2) + 'T' +
265
+ this.getUTCHours().toPaddedString(2) + ':' +
266
+ this.getUTCMinutes().toPaddedString(2) + ':' +
267
+ this.getUTCSeconds().toPaddedString(2) + 'Z"';
268
+ };
269
+
270
+ var Try = {
271
+ these: function() {
272
+ var returnValue;
273
+
274
+ for (var i = 0, length = arguments.length; i < length; i++) {
275
+ var lambda = arguments[i];
276
+ try {
277
+ returnValue = lambda();
278
+ break;
279
+ } catch (e) { }
280
+ }
281
+
282
+ return returnValue;
283
+ }
284
+ };
285
+
286
+ RegExp.prototype.match = RegExp.prototype.test;
287
+
288
+ RegExp.escape = function(str) {
289
+ return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
290
+ };
291
+
292
+ /*--------------------------------------------------------------------------*/
293
+
294
+ var PeriodicalExecuter = Class.create({
295
+ initialize: function(callback, frequency) {
296
+ this.callback = callback;
297
+ this.frequency = frequency;
298
+ this.currentlyExecuting = false;
299
+
300
+ this.registerCallback();
301
+ },
302
+
303
+ registerCallback: function() {
304
+ this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
305
+ },
306
+
307
+ execute: function() {
308
+ this.callback(this);
309
+ },
310
+
311
+ stop: function() {
312
+ if (!this.timer) return;
313
+ clearInterval(this.timer);
314
+ this.timer = null;
315
+ },
316
+
317
+ onTimerEvent: function() {
318
+ if (!this.currentlyExecuting) {
319
+ try {
320
+ this.currentlyExecuting = true;
321
+ this.execute();
322
+ } finally {
323
+ this.currentlyExecuting = false;
324
+ }
325
+ }
326
+ }
327
+ });
328
+ Object.extend(String, {
329
+ interpret: function(value) {
330
+ return value == null ? '' : String(value);
331
+ },
332
+ specialChar: {
333
+ '\b': '\\b',
334
+ '\t': '\\t',
335
+ '\n': '\\n',
336
+ '\f': '\\f',
337
+ '\r': '\\r',
338
+ '\\': '\\\\'
339
+ }
340
+ });
341
+
342
+ Object.extend(String.prototype, {
343
+ gsub: function(pattern, replacement) {
344
+ var result = '', source = this, match;
345
+ replacement = arguments.callee.prepareReplacement(replacement);
346
+
347
+ while (source.length > 0) {
348
+ if (match = source.match(pattern)) {
349
+ result += source.slice(0, match.index);
350
+ result += String.interpret(replacement(match));
351
+ source = source.slice(match.index + match[0].length);
352
+ } else {
353
+ result += source, source = '';
354
+ }
355
+ }
356
+ return result;
357
+ },
358
+
359
+ sub: function(pattern, replacement, count) {
360
+ replacement = this.gsub.prepareReplacement(replacement);
361
+ count = Object.isUndefined(count) ? 1 : count;
362
+
363
+ return this.gsub(pattern, function(match) {
364
+ if (--count < 0) return match[0];
365
+ return replacement(match);
366
+ });
367
+ },
368
+
369
+ scan: function(pattern, iterator) {
370
+ this.gsub(pattern, iterator);
371
+ return String(this);
372
+ },
373
+
374
+ truncate: function(length, truncation) {
375
+ length = length || 30;
376
+ truncation = Object.isUndefined(truncation) ? '...' : truncation;
377
+ return this.length > length ?
378
+ this.slice(0, length - truncation.length) + truncation : String(this);
379
+ },
380
+
381
+ strip: function() {
382
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
383
+ },
384
+
385
+ stripTags: function() {
386
+ return this.replace(/<\/?[^>]+>/gi, '');
387
+ },
388
+
389
+ stripScripts: function() {
390
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
391
+ },
392
+
393
+ extractScripts: function() {
394
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
395
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
396
+ return (this.match(matchAll) || []).map(function(scriptTag) {
397
+ return (scriptTag.match(matchOne) || ['', ''])[1];
398
+ });
399
+ },
400
+
401
+ evalScripts: function() {
402
+ return this.extractScripts().map(function(script) { return eval(script) });
403
+ },
404
+
405
+ escapeHTML: function() {
406
+ var self = arguments.callee;
407
+ self.text.data = this;
408
+ return self.div.innerHTML;
409
+ },
410
+
411
+ unescapeHTML: function() {
412
+ var div = new Element('div');
413
+ div.innerHTML = this.stripTags();
414
+ return div.childNodes[0] ? (div.childNodes.length > 1 ?
415
+ $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
416
+ div.childNodes[0].nodeValue) : '';
417
+ },
418
+
419
+ toQueryParams: function(separator) {
420
+ var match = this.strip().match(/([^?#]*)(#.*)?$/);
421
+ if (!match) return { };
422
+
423
+ return match[1].split(separator || '&').inject({ }, function(hash, pair) {
424
+ if ((pair = pair.split('='))[0]) {
425
+ var key = decodeURIComponent(pair.shift());
426
+ var value = pair.length > 1 ? pair.join('=') : pair[0];
427
+ if (value != undefined) value = decodeURIComponent(value);
428
+
429
+ if (key in hash) {
430
+ if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
431
+ hash[key].push(value);
432
+ }
433
+ else hash[key] = value;
434
+ }
435
+ return hash;
436
+ });
437
+ },
438
+
439
+ toArray: function() {
440
+ return this.split('');
441
+ },
442
+
443
+ succ: function() {
444
+ return this.slice(0, this.length - 1) +
445
+ String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
446
+ },
447
+
448
+ times: function(count) {
449
+ return count < 1 ? '' : new Array(count + 1).join(this);
450
+ },
451
+
452
+ camelize: function() {
453
+ var parts = this.split('-'), len = parts.length;
454
+ if (len == 1) return parts[0];
455
+
456
+ var camelized = this.charAt(0) == '-'
457
+ ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
458
+ : parts[0];
459
+
460
+ for (var i = 1; i < len; i++)
461
+ camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
462
+
463
+ return camelized;
464
+ },
465
+
466
+ capitalize: function() {
467
+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
468
+ },
469
+
470
+ underscore: function() {
471
+ return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
472
+ },
473
+
474
+ dasherize: function() {
475
+ return this.gsub(/_/,'-');
476
+ },
477
+
478
+ inspect: function(useDoubleQuotes) {
479
+ var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
480
+ var character = String.specialChar[match[0]];
481
+ return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
482
+ });
483
+ if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
484
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
485
+ },
486
+
487
+ toJSON: function() {
488
+ return this.inspect(true);
489
+ },
490
+
491
+ unfilterJSON: function(filter) {
492
+ return this.sub(filter || Prototype.JSONFilter, '#{1}');
493
+ },
494
+
495
+ isJSON: function() {
496
+ var str = this;
497
+ if (str.blank()) return false;
498
+ str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
499
+ return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
500
+ },
501
+
502
+ evalJSON: function(sanitize) {
503
+ var json = this.unfilterJSON();
504
+ try {
505
+ if (!sanitize || json.isJSON()) return eval('(' + json + ')');
506
+ } catch (e) { }
507
+ throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
508
+ },
509
+
510
+ include: function(pattern) {
511
+ return this.indexOf(pattern) > -1;
512
+ },
513
+
514
+ startsWith: function(pattern) {
515
+ return this.indexOf(pattern) === 0;
516
+ },
517
+
518
+ endsWith: function(pattern) {
519
+ var d = this.length - pattern.length;
520
+ return d >= 0 && this.lastIndexOf(pattern) === d;
521
+ },
522
+
523
+ empty: function() {
524
+ return this == '';
525
+ },
526
+
527
+ blank: function() {
528
+ return /^\s*$/.test(this);
529
+ },
530
+
531
+ interpolate: function(object, pattern) {
532
+ return new Template(this, pattern).evaluate(object);
533
+ }
534
+ });
535
+
536
+ if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
537
+ escapeHTML: function() {
538
+ return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
539
+ },
540
+ unescapeHTML: function() {
541
+ return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
542
+ }
543
+ });
544
+
545
+ String.prototype.gsub.prepareReplacement = function(replacement) {
546
+ if (Object.isFunction(replacement)) return replacement;
547
+ var template = new Template(replacement);
548
+ return function(match) { return template.evaluate(match) };
549
+ };
550
+
551
+ String.prototype.parseQuery = String.prototype.toQueryParams;
552
+
553
+ Object.extend(String.prototype.escapeHTML, {
554
+ div: document.createElement('div'),
555
+ text: document.createTextNode('')
556
+ });
557
+
558
+ String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
559
+
560
+ var Template = Class.create({
561
+ initialize: function(template, pattern) {
562
+ this.template = template.toString();
563
+ this.pattern = pattern || Template.Pattern;
564
+ },
565
+
566
+ evaluate: function(object) {
567
+ if (Object.isFunction(object.toTemplateReplacements))
568
+ object = object.toTemplateReplacements();
569
+
570
+ return this.template.gsub(this.pattern, function(match) {
571
+ if (object == null) return '';
572
+
573
+ var before = match[1] || '';
574
+ if (before == '\\') return match[2];
575
+
576
+ var ctx = object, expr = match[3];
577
+ var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
578
+ match = pattern.exec(expr);
579
+ if (match == null) return before;
580
+
581
+ while (match != null) {
582
+ var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
583
+ ctx = ctx[comp];
584
+ if (null == ctx || '' == match[3]) break;
585
+ expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
586
+ match = pattern.exec(expr);
587
+ }
588
+
589
+ return before + String.interpret(ctx);
590
+ });
591
+ }
592
+ });
593
+ Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
594
+
595
+ var $break = { };
596
+
597
+ var Enumerable = {
598
+ each: function(iterator, context) {
599
+ var index = 0;
600
+ try {
601
+ this._each(function(value) {
602
+ iterator.call(context, value, index++);
603
+ });
604
+ } catch (e) {
605
+ if (e != $break) throw e;
606
+ }
607
+ return this;
608
+ },
609
+
610
+ eachSlice: function(number, iterator, context) {
611
+ var index = -number, slices = [], array = this.toArray();
612
+ if (number < 1) return array;
613
+ while ((index += number) < array.length)
614
+ slices.push(array.slice(index, index+number));
615
+ return slices.collect(iterator, context);
616
+ },
617
+
618
+ all: function(iterator, context) {
619
+ iterator = iterator || Prototype.K;
620
+ var result = true;
621
+ this.each(function(value, index) {
622
+ result = result && !!iterator.call(context, value, index);
623
+ if (!result) throw $break;
624
+ });
625
+ return result;
626
+ },
627
+
628
+ any: function(iterator, context) {
629
+ iterator = iterator || Prototype.K;
630
+ var result = false;
631
+ this.each(function(value, index) {
632
+ if (result = !!iterator.call(context, value, index))
633
+ throw $break;
634
+ });
635
+ return result;
636
+ },
637
+
638
+ collect: function(iterator, context) {
639
+ iterator = iterator || Prototype.K;
640
+ var results = [];
641
+ this.each(function(value, index) {
642
+ results.push(iterator.call(context, value, index));
643
+ });
644
+ return results;
645
+ },
646
+
647
+ detect: function(iterator, context) {
648
+ var result;
649
+ this.each(function(value, index) {
650
+ if (iterator.call(context, value, index)) {
651
+ result = value;
652
+ throw $break;
653
+ }
654
+ });
655
+ return result;
656
+ },
657
+
658
+ findAll: function(iterator, context) {
659
+ var results = [];
660
+ this.each(function(value, index) {
661
+ if (iterator.call(context, value, index))
662
+ results.push(value);
663
+ });
664
+ return results;
665
+ },
666
+
667
+ grep: function(filter, iterator, context) {
668
+ iterator = iterator || Prototype.K;
669
+ var results = [];
670
+
671
+ if (Object.isString(filter))
672
+ filter = new RegExp(filter);
673
+
674
+ this.each(function(value, index) {
675
+ if (filter.match(value))
676
+ results.push(iterator.call(context, value, index));
677
+ });
678
+ return results;
679
+ },
680
+
681
+ include: function(object) {
682
+ if (Object.isFunction(this.indexOf))
683
+ if (this.indexOf(object) != -1) return true;
684
+
685
+ var found = false;
686
+ this.each(function(value) {
687
+ if (value == object) {
688
+ found = true;
689
+ throw $break;
690
+ }
691
+ });
692
+ return found;
693
+ },
694
+
695
+ inGroupsOf: function(number, fillWith) {
696
+ fillWith = Object.isUndefined(fillWith) ? null : fillWith;
697
+ return this.eachSlice(number, function(slice) {
698
+ while(slice.length < number) slice.push(fillWith);
699
+ return slice;
700
+ });
701
+ },
702
+
703
+ inject: function(memo, iterator, context) {
704
+ this.each(function(value, index) {
705
+ memo = iterator.call(context, memo, value, index);
706
+ });
707
+ return memo;
708
+ },
709
+
710
+ invoke: function(method) {
711
+ var args = $A(arguments).slice(1);
712
+ return this.map(function(value) {
713
+ return value[method].apply(value, args);
714
+ });
715
+ },
716
+
717
+ max: function(iterator, context) {
718
+ iterator = iterator || Prototype.K;
719
+ var result;
720
+ this.each(function(value, index) {
721
+ value = iterator.call(context, value, index);
722
+ if (result == null || value >= result)
723
+ result = value;
724
+ });
725
+ return result;
726
+ },
727
+
728
+ min: function(iterator, context) {
729
+ iterator = iterator || Prototype.K;
730
+ var result;
731
+ this.each(function(value, index) {
732
+ value = iterator.call(context, value, index);
733
+ if (result == null || value < result)
734
+ result = value;
735
+ });
736
+ return result;
737
+ },
738
+
739
+ partition: function(iterator, context) {
740
+ iterator = iterator || Prototype.K;
741
+ var trues = [], falses = [];
742
+ this.each(function(value, index) {
743
+ (iterator.call(context, value, index) ?
744
+ trues : falses).push(value);
745
+ });
746
+ return [trues, falses];
747
+ },
748
+
749
+ pluck: function(property) {
750
+ var results = [];
751
+ this.each(function(value) {
752
+ results.push(value[property]);
753
+ });
754
+ return results;
755
+ },
756
+
757
+ reject: function(iterator, context) {
758
+ var results = [];
759
+ this.each(function(value, index) {
760
+ if (!iterator.call(context, value, index))
761
+ results.push(value);
762
+ });
763
+ return results;
764
+ },
765
+
766
+ sortBy: function(iterator, context) {
767
+ return this.map(function(value, index) {
768
+ return {
769
+ value: value,
770
+ criteria: iterator.call(context, value, index)
771
+ };
772
+ }).sort(function(left, right) {
773
+ var a = left.criteria, b = right.criteria;
774
+ return a < b ? -1 : a > b ? 1 : 0;
775
+ }).pluck('value');
776
+ },
777
+
778
+ toArray: function() {
779
+ return this.map();
780
+ },
781
+
782
+ zip: function() {
783
+ var iterator = Prototype.K, args = $A(arguments);
784
+ if (Object.isFunction(args.last()))
785
+ iterator = args.pop();
786
+
787
+ var collections = [this].concat(args).map($A);
788
+ return this.map(function(value, index) {
789
+ return iterator(collections.pluck(index));
790
+ });
791
+ },
792
+
793
+ size: function() {
794
+ return this.toArray().length;
795
+ },
796
+
797
+ inspect: function() {
798
+ return '#<Enumerable:' + this.toArray().inspect() + '>';
799
+ }
800
+ };
801
+
802
+ Object.extend(Enumerable, {
803
+ map: Enumerable.collect,
804
+ find: Enumerable.detect,
805
+ select: Enumerable.findAll,
806
+ filter: Enumerable.findAll,
807
+ member: Enumerable.include,
808
+ entries: Enumerable.toArray,
809
+ every: Enumerable.all,
810
+ some: Enumerable.any
811
+ });
812
+ function $A(iterable) {
813
+ if (!iterable) return [];
814
+ if (iterable.toArray) return iterable.toArray();
815
+ var length = iterable.length || 0, results = new Array(length);
816
+ while (length--) results[length] = iterable[length];
817
+ return results;
818
+ }
819
+
820
+ if (Prototype.Browser.WebKit) {
821
+ $A = function(iterable) {
822
+ if (!iterable) return [];
823
+ // In Safari, only use the `toArray` method if it's not a NodeList.
824
+ // A NodeList is a function, has an function `item` property, and a numeric
825
+ // `length` property. Adapted from Google Doctype.
826
+ if (!(typeof iterable === 'function' && typeof iterable.length ===
827
+ 'number' && typeof iterable.item === 'function') && iterable.toArray)
828
+ return iterable.toArray();
829
+ var length = iterable.length || 0, results = new Array(length);
830
+ while (length--) results[length] = iterable[length];
831
+ return results;
832
+ };
833
+ }
834
+
835
+ Array.from = $A;
836
+
837
+ Object.extend(Array.prototype, Enumerable);
838
+
839
+ if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse;
840
+
841
+ Object.extend(Array.prototype, {
842
+ _each: function(iterator) {
843
+ for (var i = 0, length = this.length; i < length; i++)
844
+ iterator(this[i]);
845
+ },
846
+
847
+ clear: function() {
848
+ this.length = 0;
849
+ return this;
850
+ },
851
+
852
+ first: function() {
853
+ return this[0];
854
+ },
855
+
856
+ last: function() {
857
+ return this[this.length - 1];
858
+ },
859
+
860
+ compact: function() {
861
+ return this.select(function(value) {
862
+ return value != null;
863
+ });
864
+ },
865
+
866
+ flatten: function() {
867
+ return this.inject([], function(array, value) {
868
+ return array.concat(Object.isArray(value) ?
869
+ value.flatten() : [value]);
870
+ });
871
+ },
872
+
873
+ without: function() {
874
+ var values = $A(arguments);
875
+ return this.select(function(value) {
876
+ return !values.include(value);
877
+ });
878
+ },
879
+
880
+ reverse: function(inline) {
881
+ return (inline !== false ? this : this.toArray())._reverse();
882
+ },
883
+
884
+ reduce: function() {
885
+ return this.length > 1 ? this : this[0];
886
+ },
887
+
888
+ uniq: function(sorted) {
889
+ return this.inject([], function(array, value, index) {
890
+ if (0 == index || (sorted ? array.last() != value : !array.include(value)))
891
+ array.push(value);
892
+ return array;
893
+ });
894
+ },
895
+
896
+ intersect: function(array) {
897
+ return this.uniq().findAll(function(item) {
898
+ return array.detect(function(value) { return item === value });
899
+ });
900
+ },
901
+
902
+ clone: function() {
903
+ return [].concat(this);
904
+ },
905
+
906
+ size: function() {
907
+ return this.length;
908
+ },
909
+
910
+ inspect: function() {
911
+ return '[' + this.map(Object.inspect).join(', ') + ']';
912
+ },
913
+
914
+ toJSON: function() {
915
+ var results = [];
916
+ this.each(function(object) {
917
+ var value = Object.toJSON(object);
918
+ if (!Object.isUndefined(value)) results.push(value);
919
+ });
920
+ return '[' + results.join(', ') + ']';
921
+ }
922
+ });
923
+
924
+ // use native browser JS 1.6 implementation if available
925
+ if (Object.isFunction(Array.prototype.forEach))
926
+ Array.prototype._each = Array.prototype.forEach;
927
+
928
+ if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
929
+ i || (i = 0);
930
+ var length = this.length;
931
+ if (i < 0) i = length + i;
932
+ for (; i < length; i++)
933
+ if (this[i] === item) return i;
934
+ return -1;
935
+ };
936
+
937
+ if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) {
938
+ i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
939
+ var n = this.slice(0, i).reverse().indexOf(item);
940
+ return (n < 0) ? n : i - n - 1;
941
+ };
942
+
943
+ Array.prototype.toArray = Array.prototype.clone;
944
+
945
+ function $w(string) {
946
+ if (!Object.isString(string)) return [];
947
+ string = string.strip();
948
+ return string ? string.split(/\s+/) : [];
949
+ }
950
+
951
+ if (Prototype.Browser.Opera){
952
+ Array.prototype.concat = function() {
953
+ var array = [];
954
+ for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
955
+ for (var i = 0, length = arguments.length; i < length; i++) {
956
+ if (Object.isArray(arguments[i])) {
957
+ for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
958
+ array.push(arguments[i][j]);
959
+ } else {
960
+ array.push(arguments[i]);
961
+ }
962
+ }
963
+ return array;
964
+ };
965
+ }
966
+ Object.extend(Number.prototype, {
967
+ toColorPart: function() {
968
+ return this.toPaddedString(2, 16);
969
+ },
970
+
971
+ succ: function() {
972
+ return this + 1;
973
+ },
974
+
975
+ times: function(iterator, context) {
976
+ $R(0, this, true).each(iterator, context);
977
+ return this;
978
+ },
979
+
980
+ toPaddedString: function(length, radix) {
981
+ var string = this.toString(radix || 10);
982
+ return '0'.times(length - string.length) + string;
983
+ },
984
+
985
+ toJSON: function() {
986
+ return isFinite(this) ? this.toString() : 'null';
987
+ }
988
+ });
989
+
990
+ $w('abs round ceil floor').each(function(method){
991
+ Number.prototype[method] = Math[method].methodize();
992
+ });
993
+ function $H(object) {
994
+ return new Hash(object);
995
+ };
996
+
997
+ var Hash = Class.create(Enumerable, (function() {
998
+
999
+ function toQueryPair(key, value) {
1000
+ if (Object.isUndefined(value)) return key;
1001
+ return key + '=' + encodeURIComponent(String.interpret(value));
1002
+ }
1003
+
1004
+ return {
1005
+ initialize: function(object) {
1006
+ this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
1007
+ },
1008
+
1009
+ _each: function(iterator) {
1010
+ for (var key in this._object) {
1011
+ var value = this._object[key], pair = [key, value];
1012
+ pair.key = key;
1013
+ pair.value = value;
1014
+ iterator(pair);
1015
+ }
1016
+ },
1017
+
1018
+ set: function(key, value) {
1019
+ return this._object[key] = value;
1020
+ },
1021
+
1022
+ get: function(key) {
1023
+ // simulating poorly supported hasOwnProperty
1024
+ if (this._object[key] !== Object.prototype[key])
1025
+ return this._object[key];
1026
+ },
1027
+
1028
+ unset: function(key) {
1029
+ var value = this._object[key];
1030
+ delete this._object[key];
1031
+ return value;
1032
+ },
1033
+
1034
+ toObject: function() {
1035
+ return Object.clone(this._object);
1036
+ },
1037
+
1038
+ keys: function() {
1039
+ return this.pluck('key');
1040
+ },
1041
+
1042
+ values: function() {
1043
+ return this.pluck('value');
1044
+ },
1045
+
1046
+ index: function(value) {
1047
+ var match = this.detect(function(pair) {
1048
+ return pair.value === value;
1049
+ });
1050
+ return match && match.key;
1051
+ },
1052
+
1053
+ merge: function(object) {
1054
+ return this.clone().update(object);
1055
+ },
1056
+
1057
+ update: function(object) {
1058
+ return new Hash(object).inject(this, function(result, pair) {
1059
+ result.set(pair.key, pair.value);
1060
+ return result;
1061
+ });
1062
+ },
1063
+
1064
+ toQueryString: function() {
1065
+ return this.inject([], function(results, pair) {
1066
+ var key = encodeURIComponent(pair.key), values = pair.value;
1067
+
1068
+ if (values && typeof values == 'object') {
1069
+ if (Object.isArray(values))
1070
+ return results.concat(values.map(toQueryPair.curry(key)));
1071
+ } else results.push(toQueryPair(key, values));
1072
+ return results;
1073
+ }).join('&');
1074
+ },
1075
+
1076
+ inspect: function() {
1077
+ return '#<Hash:{' + this.map(function(pair) {
1078
+ return pair.map(Object.inspect).join(': ');
1079
+ }).join(', ') + '}>';
1080
+ },
1081
+
1082
+ toJSON: function() {
1083
+ return Object.toJSON(this.toObject());
1084
+ },
1085
+
1086
+ clone: function() {
1087
+ return new Hash(this);
1088
+ }
1089
+ }
1090
+ })());
1091
+
1092
+ Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
1093
+ Hash.from = $H;
1094
+ var ObjectRange = Class.create(Enumerable, {
1095
+ initialize: function(start, end, exclusive) {
1096
+ this.start = start;
1097
+ this.end = end;
1098
+ this.exclusive = exclusive;
1099
+ },
1100
+
1101
+ _each: function(iterator) {
1102
+ var value = this.start;
1103
+ while (this.include(value)) {
1104
+ iterator(value);
1105
+ value = value.succ();
1106
+ }
1107
+ },
1108
+
1109
+ include: function(value) {
1110
+ if (value < this.start)
1111
+ return false;
1112
+ if (this.exclusive)
1113
+ return value < this.end;
1114
+ return value <= this.end;
1115
+ }
1116
+ });
1117
+
1118
+ var $R = function(start, end, exclusive) {
1119
+ return new ObjectRange(start, end, exclusive);
1120
+ };
1121
+
1122
+ var Ajax = {
1123
+ getTransport: function() {
1124
+ return Try.these(
1125
+ function() {return new XMLHttpRequest()},
1126
+ function() {return new ActiveXObject('Msxml2.XMLHTTP')},
1127
+ function() {return new ActiveXObject('Microsoft.XMLHTTP')}
1128
+ ) || false;
1129
+ },
1130
+
1131
+ activeRequestCount: 0
1132
+ };
1133
+
1134
+ Ajax.Responders = {
1135
+ responders: [],
1136
+
1137
+ _each: function(iterator) {
1138
+ this.responders._each(iterator);
1139
+ },
1140
+
1141
+ register: function(responder) {
1142
+ if (!this.include(responder))
1143
+ this.responders.push(responder);
1144
+ },
1145
+
1146
+ unregister: function(responder) {
1147
+ this.responders = this.responders.without(responder);
1148
+ },
1149
+
1150
+ dispatch: function(callback, request, transport, json) {
1151
+ this.each(function(responder) {
1152
+ if (Object.isFunction(responder[callback])) {
1153
+ try {
1154
+ responder[callback].apply(responder, [request, transport, json]);
1155
+ } catch (e) { }
1156
+ }
1157
+ });
1158
+ }
1159
+ };
1160
+
1161
+ Object.extend(Ajax.Responders, Enumerable);
1162
+
1163
+ Ajax.Responders.register({
1164
+ onCreate: function() { Ajax.activeRequestCount++ },
1165
+ onComplete: function() { Ajax.activeRequestCount-- }
1166
+ });
1167
+
1168
+ Ajax.Base = Class.create({
1169
+ initialize: function(options) {
1170
+ this.options = {
1171
+ method: 'post',
1172
+ asynchronous: true,
1173
+ contentType: 'application/x-www-form-urlencoded',
1174
+ encoding: 'UTF-8',
1175
+ parameters: '',
1176
+ evalJSON: true,
1177
+ evalJS: true
1178
+ };
1179
+ Object.extend(this.options, options || { });
1180
+
1181
+ this.options.method = this.options.method.toLowerCase();
1182
+
1183
+ if (Object.isString(this.options.parameters))
1184
+ this.options.parameters = this.options.parameters.toQueryParams();
1185
+ else if (Object.isHash(this.options.parameters))
1186
+ this.options.parameters = this.options.parameters.toObject();
1187
+ }
1188
+ });
1189
+
1190
+ Ajax.Request = Class.create(Ajax.Base, {
1191
+ _complete: false,
1192
+
1193
+ initialize: function($super, url, options) {
1194
+ $super(options);
1195
+ this.transport = Ajax.getTransport();
1196
+ this.request(url);
1197
+ },
1198
+
1199
+ request: function(url) {
1200
+ this.url = url;
1201
+ this.method = this.options.method;
1202
+ var params = Object.clone(this.options.parameters);
1203
+
1204
+ if (!['get', 'post'].include(this.method)) {
1205
+ // simulate other verbs over post
1206
+ params['_method'] = this.method;
1207
+ this.method = 'post';
1208
+ }
1209
+
1210
+ this.parameters = params;
1211
+
1212
+ if (params = Object.toQueryString(params)) {
1213
+ // when GET, append parameters to URL
1214
+ if (this.method == 'get')
1215
+ this.url += (this.url.include('?') ? '&' : '?') + params;
1216
+ else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
1217
+ params += '&_=';
1218
+ }
1219
+
1220
+ try {
1221
+ var response = new Ajax.Response(this);
1222
+ if (this.options.onCreate) this.options.onCreate(response);
1223
+ Ajax.Responders.dispatch('onCreate', this, response);
1224
+
1225
+ this.transport.open(this.method.toUpperCase(), this.url,
1226
+ this.options.asynchronous);
1227
+
1228
+ if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
1229
+
1230
+ this.transport.onreadystatechange = this.onStateChange.bind(this);
1231
+ this.setRequestHeaders();
1232
+
1233
+ this.body = this.method == 'post' ? (this.options.postBody || params) : null;
1234
+ this.transport.send(this.body);
1235
+
1236
+ /* Force Firefox to handle ready state 4 for synchronous requests */
1237
+ if (!this.options.asynchronous && this.transport.overrideMimeType)
1238
+ this.onStateChange();
1239
+
1240
+ }
1241
+ catch (e) {
1242
+ this.dispatchException(e);
1243
+ }
1244
+ },
1245
+
1246
+ onStateChange: function() {
1247
+ var readyState = this.transport.readyState;
1248
+ if (readyState > 1 && !((readyState == 4) && this._complete))
1249
+ this.respondToReadyState(this.transport.readyState);
1250
+ },
1251
+
1252
+ setRequestHeaders: function() {
1253
+ var headers = {
1254
+ 'X-Requested-With': 'XMLHttpRequest',
1255
+ 'X-Prototype-Version': Prototype.Version,
1256
+ 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
1257
+ };
1258
+
1259
+ if (this.method == 'post') {
1260
+ headers['Content-type'] = this.options.contentType +
1261
+ (this.options.encoding ? '; charset=' + this.options.encoding : '');
1262
+
1263
+ /* Force "Connection: close" for older Mozilla browsers to work
1264
+ * around a bug where XMLHttpRequest sends an incorrect
1265
+ * Content-length header. See Mozilla Bugzilla #246651.
1266
+ */
1267
+ if (this.transport.overrideMimeType &&
1268
+ (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
1269
+ headers['Connection'] = 'close';
1270
+ }
1271
+
1272
+ // user-defined headers
1273
+ if (typeof this.options.requestHeaders == 'object') {
1274
+ var extras = this.options.requestHeaders;
1275
+
1276
+ if (Object.isFunction(extras.push))
1277
+ for (var i = 0, length = extras.length; i < length; i += 2)
1278
+ headers[extras[i]] = extras[i+1];
1279
+ else
1280
+ $H(extras).each(function(pair) { headers[pair.key] = pair.value });
1281
+ }
1282
+
1283
+ for (var name in headers)
1284
+ this.transport.setRequestHeader(name, headers[name]);
1285
+ },
1286
+
1287
+ success: function() {
1288
+ var status = this.getStatus();
1289
+ return !status || (status >= 200 && status < 300);
1290
+ },
1291
+
1292
+ getStatus: function() {
1293
+ try {
1294
+ return this.transport.status || 0;
1295
+ } catch (e) { return 0 }
1296
+ },
1297
+
1298
+ respondToReadyState: function(readyState) {
1299
+ var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
1300
+
1301
+ if (state == 'Complete') {
1302
+ try {
1303
+ this._complete = true;
1304
+ (this.options['on' + response.status]
1305
+ || this.options['on' + (this.success() ? 'Success' : 'Failure')]
1306
+ || Prototype.emptyFunction)(response, response.headerJSON);
1307
+ } catch (e) {
1308
+ this.dispatchException(e);
1309
+ }
1310
+
1311
+ var contentType = response.getHeader('Content-type');
1312
+ if (this.options.evalJS == 'force'
1313
+ || (this.options.evalJS && this.isSameOrigin() && contentType
1314
+ && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
1315
+ this.evalResponse();
1316
+ }
1317
+
1318
+ try {
1319
+ (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
1320
+ Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
1321
+ } catch (e) {
1322
+ this.dispatchException(e);
1323
+ }
1324
+
1325
+ if (state == 'Complete') {
1326
+ // avoid memory leak in MSIE: clean up
1327
+ this.transport.onreadystatechange = Prototype.emptyFunction;
1328
+ }
1329
+ },
1330
+
1331
+ isSameOrigin: function() {
1332
+ var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
1333
+ return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
1334
+ protocol: location.protocol,
1335
+ domain: document.domain,
1336
+ port: location.port ? ':' + location.port : ''
1337
+ }));
1338
+ },
1339
+
1340
+ getHeader: function(name) {
1341
+ try {
1342
+ return this.transport.getResponseHeader(name) || null;
1343
+ } catch (e) { return null }
1344
+ },
1345
+
1346
+ evalResponse: function() {
1347
+ try {
1348
+ return eval((this.transport.responseText || '').unfilterJSON());
1349
+ } catch (e) {
1350
+ this.dispatchException(e);
1351
+ }
1352
+ },
1353
+
1354
+ dispatchException: function(exception) {
1355
+ (this.options.onException || Prototype.emptyFunction)(this, exception);
1356
+ Ajax.Responders.dispatch('onException', this, exception);
1357
+ }
1358
+ });
1359
+
1360
+ Ajax.Request.Events =
1361
+ ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
1362
+
1363
+ Ajax.Response = Class.create({
1364
+ initialize: function(request){
1365
+ this.request = request;
1366
+ var transport = this.transport = request.transport,
1367
+ readyState = this.readyState = transport.readyState;
1368
+
1369
+ if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
1370
+ this.status = this.getStatus();
1371
+ this.statusText = this.getStatusText();
1372
+ this.responseText = String.interpret(transport.responseText);
1373
+ this.headerJSON = this._getHeaderJSON();
1374
+ }
1375
+
1376
+ if(readyState == 4) {
1377
+ var xml = transport.responseXML;
1378
+ this.responseXML = Object.isUndefined(xml) ? null : xml;
1379
+ this.responseJSON = this._getResponseJSON();
1380
+ }
1381
+ },
1382
+
1383
+ status: 0,
1384
+ statusText: '',
1385
+
1386
+ getStatus: Ajax.Request.prototype.getStatus,
1387
+
1388
+ getStatusText: function() {
1389
+ try {
1390
+ return this.transport.statusText || '';
1391
+ } catch (e) { return '' }
1392
+ },
1393
+
1394
+ getHeader: Ajax.Request.prototype.getHeader,
1395
+
1396
+ getAllHeaders: function() {
1397
+ try {
1398
+ return this.getAllResponseHeaders();
1399
+ } catch (e) { return null }
1400
+ },
1401
+
1402
+ getResponseHeader: function(name) {
1403
+ return this.transport.getResponseHeader(name);
1404
+ },
1405
+
1406
+ getAllResponseHeaders: function() {
1407
+ return this.transport.getAllResponseHeaders();
1408
+ },
1409
+
1410
+ _getHeaderJSON: function() {
1411
+ var json = this.getHeader('X-JSON');
1412
+ if (!json) return null;
1413
+ json = decodeURIComponent(escape(json));
1414
+ try {
1415
+ return json.evalJSON(this.request.options.sanitizeJSON ||
1416
+ !this.request.isSameOrigin());
1417
+ } catch (e) {
1418
+ this.request.dispatchException(e);
1419
+ }
1420
+ },
1421
+
1422
+ _getResponseJSON: function() {
1423
+ var options = this.request.options;
1424
+ if (!options.evalJSON || (options.evalJSON != 'force' &&
1425
+ !(this.getHeader('Content-type') || '').include('application/json')) ||
1426
+ this.responseText.blank())
1427
+ return null;
1428
+ try {
1429
+ return this.responseText.evalJSON(options.sanitizeJSON ||
1430
+ !this.request.isSameOrigin());
1431
+ } catch (e) {
1432
+ this.request.dispatchException(e);
1433
+ }
1434
+ }
1435
+ });
1436
+
1437
+ Ajax.Updater = Class.create(Ajax.Request, {
1438
+ initialize: function($super, container, url, options) {
1439
+ this.container = {
1440
+ success: (container.success || container),
1441
+ failure: (container.failure || (container.success ? null : container))
1442
+ };
1443
+
1444
+ options = Object.clone(options);
1445
+ var onComplete = options.onComplete;
1446
+ options.onComplete = (function(response, json) {
1447
+ this.updateContent(response.responseText);
1448
+ if (Object.isFunction(onComplete)) onComplete(response, json);
1449
+ }).bind(this);
1450
+
1451
+ $super(url, options);
1452
+ },
1453
+
1454
+ updateContent: function(responseText) {
1455
+ var receiver = this.container[this.success() ? 'success' : 'failure'],
1456
+ options = this.options;
1457
+
1458
+ if (!options.evalScripts) responseText = responseText.stripScripts();
1459
+
1460
+ if (receiver = $(receiver)) {
1461
+ if (options.insertion) {
1462
+ if (Object.isString(options.insertion)) {
1463
+ var insertion = { }; insertion[options.insertion] = responseText;
1464
+ receiver.insert(insertion);
1465
+ }
1466
+ else options.insertion(receiver, responseText);
1467
+ }
1468
+ else receiver.update(responseText);
1469
+ }
1470
+ }
1471
+ });
1472
+
1473
+ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
1474
+ initialize: function($super, container, url, options) {
1475
+ $super(options);
1476
+ this.onComplete = this.options.onComplete;
1477
+
1478
+ this.frequency = (this.options.frequency || 2);
1479
+ this.decay = (this.options.decay || 1);
1480
+
1481
+ this.updater = { };
1482
+ this.container = container;
1483
+ this.url = url;
1484
+
1485
+ this.start();
1486
+ },
1487
+
1488
+ start: function() {
1489
+ this.options.onComplete = this.updateComplete.bind(this);
1490
+ this.onTimerEvent();
1491
+ },
1492
+
1493
+ stop: function() {
1494
+ this.updater.options.onComplete = undefined;
1495
+ clearTimeout(this.timer);
1496
+ (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
1497
+ },
1498
+
1499
+ updateComplete: function(response) {
1500
+ if (this.options.decay) {
1501
+ this.decay = (response.responseText == this.lastText ?
1502
+ this.decay * this.options.decay : 1);
1503
+
1504
+ this.lastText = response.responseText;
1505
+ }
1506
+ this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
1507
+ },
1508
+
1509
+ onTimerEvent: function() {
1510
+ this.updater = new Ajax.Updater(this.container, this.url, this.options);
1511
+ }
1512
+ });
1513
+ function $(element) {
1514
+ if (arguments.length > 1) {
1515
+ for (var i = 0, elements = [], length = arguments.length; i < length; i++)
1516
+ elements.push($(arguments[i]));
1517
+ return elements;
1518
+ }
1519
+ if (Object.isString(element))
1520
+ element = document.getElementById(element);
1521
+ return Element.extend(element);
1522
+ }
1523
+
1524
+ if (Prototype.BrowserFeatures.XPath) {
1525
+ document._getElementsByXPath = function(expression, parentElement) {
1526
+ var results = [];
1527
+ var query = document.evaluate(expression, $(parentElement) || document,
1528
+ null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
1529
+ for (var i = 0, length = query.snapshotLength; i < length; i++)
1530
+ results.push(Element.extend(query.snapshotItem(i)));
1531
+ return results;
1532
+ };
1533
+ }
1534
+
1535
+ /*--------------------------------------------------------------------------*/
1536
+
1537
+ if (!window.Node) var Node = { };
1538
+
1539
+ if (!Node.ELEMENT_NODE) {
1540
+ // DOM level 2 ECMAScript Language Binding
1541
+ Object.extend(Node, {
1542
+ ELEMENT_NODE: 1,
1543
+ ATTRIBUTE_NODE: 2,
1544
+ TEXT_NODE: 3,
1545
+ CDATA_SECTION_NODE: 4,
1546
+ ENTITY_REFERENCE_NODE: 5,
1547
+ ENTITY_NODE: 6,
1548
+ PROCESSING_INSTRUCTION_NODE: 7,
1549
+ COMMENT_NODE: 8,
1550
+ DOCUMENT_NODE: 9,
1551
+ DOCUMENT_TYPE_NODE: 10,
1552
+ DOCUMENT_FRAGMENT_NODE: 11,
1553
+ NOTATION_NODE: 12
1554
+ });
1555
+ }
1556
+
1557
+ (function() {
1558
+ var element = this.Element;
1559
+ this.Element = function(tagName, attributes) {
1560
+ attributes = attributes || { };
1561
+ tagName = tagName.toLowerCase();
1562
+ var cache = Element.cache;
1563
+ if (Prototype.Browser.IE && attributes.name) {
1564
+ tagName = '<' + tagName + ' name="' + attributes.name + '">';
1565
+ delete attributes.name;
1566
+ return Element.writeAttribute(document.createElement(tagName), attributes);
1567
+ }
1568
+ if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
1569
+ return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
1570
+ };
1571
+ Object.extend(this.Element, element || { });
1572
+ if (element) this.Element.prototype = element.prototype;
1573
+ }).call(window);
1574
+
1575
+ Element.cache = { };
1576
+
1577
+ Element.Methods = {
1578
+ visible: function(element) {
1579
+ return $(element).style.display != 'none';
1580
+ },
1581
+
1582
+ toggle: function(element) {
1583
+ element = $(element);
1584
+ Element[Element.visible(element) ? 'hide' : 'show'](element);
1585
+ return element;
1586
+ },
1587
+
1588
+ hide: function(element) {
1589
+ element = $(element);
1590
+ element.style.display = 'none';
1591
+ return element;
1592
+ },
1593
+
1594
+ show: function(element) {
1595
+ element = $(element);
1596
+ element.style.display = '';
1597
+ return element;
1598
+ },
1599
+
1600
+ remove: function(element) {
1601
+ element = $(element);
1602
+ element.parentNode.removeChild(element);
1603
+ return element;
1604
+ },
1605
+
1606
+ update: function(element, content) {
1607
+ element = $(element);
1608
+ if (content && content.toElement) content = content.toElement();
1609
+ if (Object.isElement(content)) return element.update().insert(content);
1610
+ content = Object.toHTML(content);
1611
+ element.innerHTML = content.stripScripts();
1612
+ content.evalScripts.bind(content).defer();
1613
+ return element;
1614
+ },
1615
+
1616
+ replace: function(element, content) {
1617
+ element = $(element);
1618
+ if (content && content.toElement) content = content.toElement();
1619
+ else if (!Object.isElement(content)) {
1620
+ content = Object.toHTML(content);
1621
+ var range = element.ownerDocument.createRange();
1622
+ range.selectNode(element);
1623
+ content.evalScripts.bind(content).defer();
1624
+ content = range.createContextualFragment(content.stripScripts());
1625
+ }
1626
+ element.parentNode.replaceChild(content, element);
1627
+ return element;
1628
+ },
1629
+
1630
+ insert: function(element, insertions) {
1631
+ element = $(element);
1632
+
1633
+ if (Object.isString(insertions) || Object.isNumber(insertions) ||
1634
+ Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
1635
+ insertions = {bottom:insertions};
1636
+
1637
+ var content, insert, tagName, childNodes;
1638
+
1639
+ for (var position in insertions) {
1640
+ content = insertions[position];
1641
+ position = position.toLowerCase();
1642
+ insert = Element._insertionTranslations[position];
1643
+
1644
+ if (content && content.toElement) content = content.toElement();
1645
+ if (Object.isElement(content)) {
1646
+ insert(element, content);
1647
+ continue;
1648
+ }
1649
+
1650
+ content = Object.toHTML(content);
1651
+
1652
+ tagName = ((position == 'before' || position == 'after')
1653
+ ? element.parentNode : element).tagName.toUpperCase();
1654
+
1655
+ childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
1656
+
1657
+ if (position == 'top' || position == 'after') childNodes.reverse();
1658
+ childNodes.each(insert.curry(element));
1659
+
1660
+ content.evalScripts.bind(content).defer();
1661
+ }
1662
+
1663
+ return element;
1664
+ },
1665
+
1666
+ wrap: function(element, wrapper, attributes) {
1667
+ element = $(element);
1668
+ if (Object.isElement(wrapper))
1669
+ $(wrapper).writeAttribute(attributes || { });
1670
+ else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
1671
+ else wrapper = new Element('div', wrapper);
1672
+ if (element.parentNode)
1673
+ element.parentNode.replaceChild(wrapper, element);
1674
+ wrapper.appendChild(element);
1675
+ return wrapper;
1676
+ },
1677
+
1678
+ inspect: function(element) {
1679
+ element = $(element);
1680
+ var result = '<' + element.tagName.toLowerCase();
1681
+ $H({'id': 'id', 'className': 'class'}).each(function(pair) {
1682
+ var property = pair.first(), attribute = pair.last();
1683
+ var value = (element[property] || '').toString();
1684
+ if (value) result += ' ' + attribute + '=' + value.inspect(true);
1685
+ });
1686
+ return result + '>';
1687
+ },
1688
+
1689
+ recursivelyCollect: function(element, property) {
1690
+ element = $(element);
1691
+ var elements = [];
1692
+ while (element = element[property])
1693
+ if (element.nodeType == 1)
1694
+ elements.push(Element.extend(element));
1695
+ return elements;
1696
+ },
1697
+
1698
+ ancestors: function(element) {
1699
+ return $(element).recursivelyCollect('parentNode');
1700
+ },
1701
+
1702
+ descendants: function(element) {
1703
+ return $(element).select("*");
1704
+ },
1705
+
1706
+ firstDescendant: function(element) {
1707
+ element = $(element).firstChild;
1708
+ while (element && element.nodeType != 1) element = element.nextSibling;
1709
+ return $(element);
1710
+ },
1711
+
1712
+ immediateDescendants: function(element) {
1713
+ if (!(element = $(element).firstChild)) return [];
1714
+ while (element && element.nodeType != 1) element = element.nextSibling;
1715
+ if (element) return [element].concat($(element).nextSiblings());
1716
+ return [];
1717
+ },
1718
+
1719
+ previousSiblings: function(element) {
1720
+ return $(element).recursivelyCollect('previousSibling');
1721
+ },
1722
+
1723
+ nextSiblings: function(element) {
1724
+ return $(element).recursivelyCollect('nextSibling');
1725
+ },
1726
+
1727
+ siblings: function(element) {
1728
+ element = $(element);
1729
+ return element.previousSiblings().reverse().concat(element.nextSiblings());
1730
+ },
1731
+
1732
+ match: function(element, selector) {
1733
+ if (Object.isString(selector))
1734
+ selector = new Selector(selector);
1735
+ return selector.match($(element));
1736
+ },
1737
+
1738
+ up: function(element, expression, index) {
1739
+ element = $(element);
1740
+ if (arguments.length == 1) return $(element.parentNode);
1741
+ var ancestors = element.ancestors();
1742
+ return Object.isNumber(expression) ? ancestors[expression] :
1743
+ Selector.findElement(ancestors, expression, index);
1744
+ },
1745
+
1746
+ down: function(element, expression, index) {
1747
+ element = $(element);
1748
+ if (arguments.length == 1) return element.firstDescendant();
1749
+ return Object.isNumber(expression) ? element.descendants()[expression] :
1750
+ Element.select(element, expression)[index || 0];
1751
+ },
1752
+
1753
+ previous: function(element, expression, index) {
1754
+ element = $(element);
1755
+ if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
1756
+ var previousSiblings = element.previousSiblings();
1757
+ return Object.isNumber(expression) ? previousSiblings[expression] :
1758
+ Selector.findElement(previousSiblings, expression, index);
1759
+ },
1760
+
1761
+ next: function(element, expression, index) {
1762
+ element = $(element);
1763
+ if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
1764
+ var nextSiblings = element.nextSiblings();
1765
+ return Object.isNumber(expression) ? nextSiblings[expression] :
1766
+ Selector.findElement(nextSiblings, expression, index);
1767
+ },
1768
+
1769
+ select: function() {
1770
+ var args = $A(arguments), element = $(args.shift());
1771
+ return Selector.findChildElements(element, args);
1772
+ },
1773
+
1774
+ adjacent: function() {
1775
+ var args = $A(arguments), element = $(args.shift());
1776
+ return Selector.findChildElements(element.parentNode, args).without(element);
1777
+ },
1778
+
1779
+ identify: function(element) {
1780
+ element = $(element);
1781
+ var id = element.readAttribute('id'), self = arguments.callee;
1782
+ if (id) return id;
1783
+ do { id = 'anonymous_element_' + self.counter++ } while ($(id));
1784
+ element.writeAttribute('id', id);
1785
+ return id;
1786
+ },
1787
+
1788
+ readAttribute: function(element, name) {
1789
+ element = $(element);
1790
+ if (Prototype.Browser.IE) {
1791
+ var t = Element._attributeTranslations.read;
1792
+ if (t.values[name]) return t.values[name](element, name);
1793
+ if (t.names[name]) name = t.names[name];
1794
+ if (name.include(':')) {
1795
+ return (!element.attributes || !element.attributes[name]) ? null :
1796
+ element.attributes[name].value;
1797
+ }
1798
+ }
1799
+ return element.getAttribute(name);
1800
+ },
1801
+
1802
+ writeAttribute: function(element, name, value) {
1803
+ element = $(element);
1804
+ var attributes = { }, t = Element._attributeTranslations.write;
1805
+
1806
+ if (typeof name == 'object') attributes = name;
1807
+ else attributes[name] = Object.isUndefined(value) ? true : value;
1808
+
1809
+ for (var attr in attributes) {
1810
+ name = t.names[attr] || attr;
1811
+ value = attributes[attr];
1812
+ if (t.values[attr]) name = t.values[attr](element, value);
1813
+ if (value === false || value === null)
1814
+ element.removeAttribute(name);
1815
+ else if (value === true)
1816
+ element.setAttribute(name, name);
1817
+ else element.setAttribute(name, value);
1818
+ }
1819
+ return element;
1820
+ },
1821
+
1822
+ getHeight: function(element) {
1823
+ return $(element).getDimensions().height;
1824
+ },
1825
+
1826
+ getWidth: function(element) {
1827
+ return $(element).getDimensions().width;
1828
+ },
1829
+
1830
+ classNames: function(element) {
1831
+ return new Element.ClassNames(element);
1832
+ },
1833
+
1834
+ hasClassName: function(element, className) {
1835
+ if (!(element = $(element))) return;
1836
+ var elementClassName = element.className;
1837
+ return (elementClassName.length > 0 && (elementClassName == className ||
1838
+ new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
1839
+ },
1840
+
1841
+ addClassName: function(element, className) {
1842
+ if (!(element = $(element))) return;
1843
+ if (!element.hasClassName(className))
1844
+ element.className += (element.className ? ' ' : '') + className;
1845
+ return element;
1846
+ },
1847
+
1848
+ removeClassName: function(element, className) {
1849
+ if (!(element = $(element))) return;
1850
+ element.className = element.className.replace(
1851
+ new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
1852
+ return element;
1853
+ },
1854
+
1855
+ toggleClassName: function(element, className) {
1856
+ if (!(element = $(element))) return;
1857
+ return element[element.hasClassName(className) ?
1858
+ 'removeClassName' : 'addClassName'](className);
1859
+ },
1860
+
1861
+ // removes whitespace-only text node children
1862
+ cleanWhitespace: function(element) {
1863
+ element = $(element);
1864
+ var node = element.firstChild;
1865
+ while (node) {
1866
+ var nextNode = node.nextSibling;
1867
+ if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
1868
+ element.removeChild(node);
1869
+ node = nextNode;
1870
+ }
1871
+ return element;
1872
+ },
1873
+
1874
+ empty: function(element) {
1875
+ return $(element).innerHTML.blank();
1876
+ },
1877
+
1878
+ descendantOf: function(element, ancestor) {
1879
+ element = $(element), ancestor = $(ancestor);
1880
+
1881
+ if (element.compareDocumentPosition)
1882
+ return (element.compareDocumentPosition(ancestor) & 8) === 8;
1883
+
1884
+ if (ancestor.contains)
1885
+ return ancestor.contains(element) && ancestor !== element;
1886
+
1887
+ while (element = element.parentNode)
1888
+ if (element == ancestor) return true;
1889
+
1890
+ return false;
1891
+ },
1892
+
1893
+ scrollTo: function(element) {
1894
+ element = $(element);
1895
+ var pos = element.cumulativeOffset();
1896
+ window.scrollTo(pos[0], pos[1]);
1897
+ return element;
1898
+ },
1899
+
1900
+ getStyle: function(element, style) {
1901
+ element = $(element);
1902
+ style = style == 'float' ? 'cssFloat' : style.camelize();
1903
+ var value = element.style[style];
1904
+ if (!value || value == 'auto') {
1905
+ var css = document.defaultView.getComputedStyle(element, null);
1906
+ value = css ? css[style] : null;
1907
+ }
1908
+ if (style == 'opacity') return value ? parseFloat(value) : 1.0;
1909
+ return value == 'auto' ? null : value;
1910
+ },
1911
+
1912
+ getOpacity: function(element) {
1913
+ return $(element).getStyle('opacity');
1914
+ },
1915
+
1916
+ setStyle: function(element, styles) {
1917
+ element = $(element);
1918
+ var elementStyle = element.style, match;
1919
+ if (Object.isString(styles)) {
1920
+ element.style.cssText += ';' + styles;
1921
+ return styles.include('opacity') ?
1922
+ element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
1923
+ }
1924
+ for (var property in styles)
1925
+ if (property == 'opacity') element.setOpacity(styles[property]);
1926
+ else
1927
+ elementStyle[(property == 'float' || property == 'cssFloat') ?
1928
+ (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
1929
+ property] = styles[property];
1930
+
1931
+ return element;
1932
+ },
1933
+
1934
+ setOpacity: function(element, value) {
1935
+ element = $(element);
1936
+ element.style.opacity = (value == 1 || value === '') ? '' :
1937
+ (value < 0.00001) ? 0 : value;
1938
+ return element;
1939
+ },
1940
+
1941
+ getDimensions: function(element) {
1942
+ element = $(element);
1943
+ var display = element.getStyle('display');
1944
+ if (display != 'none' && display != null) // Safari bug
1945
+ return {width: element.offsetWidth, height: element.offsetHeight};
1946
+
1947
+ // All *Width and *Height properties give 0 on elements with display none,
1948
+ // so enable the element temporarily
1949
+ var els = element.style;
1950
+ var originalVisibility = els.visibility;
1951
+ var originalPosition = els.position;
1952
+ var originalDisplay = els.display;
1953
+ els.visibility = 'hidden';
1954
+ els.position = 'absolute';
1955
+ els.display = 'block';
1956
+ var originalWidth = element.clientWidth;
1957
+ var originalHeight = element.clientHeight;
1958
+ els.display = originalDisplay;
1959
+ els.position = originalPosition;
1960
+ els.visibility = originalVisibility;
1961
+ return {width: originalWidth, height: originalHeight};
1962
+ },
1963
+
1964
+ makePositioned: function(element) {
1965
+ element = $(element);
1966
+ var pos = Element.getStyle(element, 'position');
1967
+ if (pos == 'static' || !pos) {
1968
+ element._madePositioned = true;
1969
+ element.style.position = 'relative';
1970
+ // Opera returns the offset relative to the positioning context, when an
1971
+ // element is position relative but top and left have not been defined
1972
+ if (Prototype.Browser.Opera) {
1973
+ element.style.top = 0;
1974
+ element.style.left = 0;
1975
+ }
1976
+ }
1977
+ return element;
1978
+ },
1979
+
1980
+ undoPositioned: function(element) {
1981
+ element = $(element);
1982
+ if (element._madePositioned) {
1983
+ element._madePositioned = undefined;
1984
+ element.style.position =
1985
+ element.style.top =
1986
+ element.style.left =
1987
+ element.style.bottom =
1988
+ element.style.right = '';
1989
+ }
1990
+ return element;
1991
+ },
1992
+
1993
+ makeClipping: function(element) {
1994
+ element = $(element);
1995
+ if (element._overflow) return element;
1996
+ element._overflow = Element.getStyle(element, 'overflow') || 'auto';
1997
+ if (element._overflow !== 'hidden')
1998
+ element.style.overflow = 'hidden';
1999
+ return element;
2000
+ },
2001
+
2002
+ undoClipping: function(element) {
2003
+ element = $(element);
2004
+ if (!element._overflow) return element;
2005
+ element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
2006
+ element._overflow = null;
2007
+ return element;
2008
+ },
2009
+
2010
+ cumulativeOffset: function(element) {
2011
+ var valueT = 0, valueL = 0;
2012
+ do {
2013
+ valueT += element.offsetTop || 0;
2014
+ valueL += element.offsetLeft || 0;
2015
+ element = element.offsetParent;
2016
+ } while (element);
2017
+ return Element._returnOffset(valueL, valueT);
2018
+ },
2019
+
2020
+ positionedOffset: function(element) {
2021
+ var valueT = 0, valueL = 0;
2022
+ do {
2023
+ valueT += element.offsetTop || 0;
2024
+ valueL += element.offsetLeft || 0;
2025
+ element = element.offsetParent;
2026
+ if (element) {
2027
+ if (element.tagName.toUpperCase() == 'BODY') break;
2028
+ var p = Element.getStyle(element, 'position');
2029
+ if (p !== 'static') break;
2030
+ }
2031
+ } while (element);
2032
+ return Element._returnOffset(valueL, valueT);
2033
+ },
2034
+
2035
+ absolutize: function(element) {
2036
+ element = $(element);
2037
+ if (element.getStyle('position') == 'absolute') return element;
2038
+ // Position.prepare(); // To be done manually by Scripty when it needs it.
2039
+
2040
+ var offsets = element.positionedOffset();
2041
+ var top = offsets[1];
2042
+ var left = offsets[0];
2043
+ var width = element.clientWidth;
2044
+ var height = element.clientHeight;
2045
+
2046
+ element._originalLeft = left - parseFloat(element.style.left || 0);
2047
+ element._originalTop = top - parseFloat(element.style.top || 0);
2048
+ element._originalWidth = element.style.width;
2049
+ element._originalHeight = element.style.height;
2050
+
2051
+ element.style.position = 'absolute';
2052
+ element.style.top = top + 'px';
2053
+ element.style.left = left + 'px';
2054
+ element.style.width = width + 'px';
2055
+ element.style.height = height + 'px';
2056
+ return element;
2057
+ },
2058
+
2059
+ relativize: function(element) {
2060
+ element = $(element);
2061
+ if (element.getStyle('position') == 'relative') return element;
2062
+ // Position.prepare(); // To be done manually by Scripty when it needs it.
2063
+
2064
+ element.style.position = 'relative';
2065
+ var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
2066
+ var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
2067
+
2068
+ element.style.top = top + 'px';
2069
+ element.style.left = left + 'px';
2070
+ element.style.height = element._originalHeight;
2071
+ element.style.width = element._originalWidth;
2072
+ return element;
2073
+ },
2074
+
2075
+ cumulativeScrollOffset: function(element) {
2076
+ var valueT = 0, valueL = 0;
2077
+ do {
2078
+ valueT += element.scrollTop || 0;
2079
+ valueL += element.scrollLeft || 0;
2080
+ element = element.parentNode;
2081
+ } while (element);
2082
+ return Element._returnOffset(valueL, valueT);
2083
+ },
2084
+
2085
+ getOffsetParent: function(element) {
2086
+ if (element.offsetParent) return $(element.offsetParent);
2087
+ if (element == document.body) return $(element);
2088
+
2089
+ while ((element = element.parentNode) && element != document.body)
2090
+ if (Element.getStyle(element, 'position') != 'static')
2091
+ return $(element);
2092
+
2093
+ return $(document.body);
2094
+ },
2095
+
2096
+ viewportOffset: function(forElement) {
2097
+ var valueT = 0, valueL = 0;
2098
+
2099
+ var element = forElement;
2100
+ do {
2101
+ valueT += element.offsetTop || 0;
2102
+ valueL += element.offsetLeft || 0;
2103
+
2104
+ // Safari fix
2105
+ if (element.offsetParent == document.body &&
2106
+ Element.getStyle(element, 'position') == 'absolute') break;
2107
+
2108
+ } while (element = element.offsetParent);
2109
+
2110
+ element = forElement;
2111
+ do {
2112
+ if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
2113
+ valueT -= element.scrollTop || 0;
2114
+ valueL -= element.scrollLeft || 0;
2115
+ }
2116
+ } while (element = element.parentNode);
2117
+
2118
+ return Element._returnOffset(valueL, valueT);
2119
+ },
2120
+
2121
+ clonePosition: function(element, source) {
2122
+ var options = Object.extend({
2123
+ setLeft: true,
2124
+ setTop: true,
2125
+ setWidth: true,
2126
+ setHeight: true,
2127
+ offsetTop: 0,
2128
+ offsetLeft: 0
2129
+ }, arguments[2] || { });
2130
+
2131
+ // find page position of source
2132
+ source = $(source);
2133
+ var p = source.viewportOffset();
2134
+
2135
+ // find coordinate system to use
2136
+ element = $(element);
2137
+ var delta = [0, 0];
2138
+ var parent = null;
2139
+ // delta [0,0] will do fine with position: fixed elements,
2140
+ // position:absolute needs offsetParent deltas
2141
+ if (Element.getStyle(element, 'position') == 'absolute') {
2142
+ parent = element.getOffsetParent();
2143
+ delta = parent.viewportOffset();
2144
+ }
2145
+
2146
+ // correct by body offsets (fixes Safari)
2147
+ if (parent == document.body) {
2148
+ delta[0] -= document.body.offsetLeft;
2149
+ delta[1] -= document.body.offsetTop;
2150
+ }
2151
+
2152
+ // set position
2153
+ if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
2154
+ if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
2155
+ if (options.setWidth) element.style.width = source.offsetWidth + 'px';
2156
+ if (options.setHeight) element.style.height = source.offsetHeight + 'px';
2157
+ return element;
2158
+ }
2159
+ };
2160
+
2161
+ Element.Methods.identify.counter = 1;
2162
+
2163
+ Object.extend(Element.Methods, {
2164
+ getElementsBySelector: Element.Methods.select,
2165
+ childElements: Element.Methods.immediateDescendants
2166
+ });
2167
+
2168
+ Element._attributeTranslations = {
2169
+ write: {
2170
+ names: {
2171
+ className: 'class',
2172
+ htmlFor: 'for'
2173
+ },
2174
+ values: { }
2175
+ }
2176
+ };
2177
+
2178
+ if (Prototype.Browser.Opera) {
2179
+ Element.Methods.getStyle = Element.Methods.getStyle.wrap(
2180
+ function(proceed, element, style) {
2181
+ switch (style) {
2182
+ case 'left': case 'top': case 'right': case 'bottom':
2183
+ if (proceed(element, 'position') === 'static') return null;
2184
+ case 'height': case 'width':
2185
+ // returns '0px' for hidden elements; we want it to return null
2186
+ if (!Element.visible(element)) return null;
2187
+
2188
+ // returns the border-box dimensions rather than the content-box
2189
+ // dimensions, so we subtract padding and borders from the value
2190
+ var dim = parseInt(proceed(element, style), 10);
2191
+
2192
+ if (dim !== element['offset' + style.capitalize()])
2193
+ return dim + 'px';
2194
+
2195
+ var properties;
2196
+ if (style === 'height') {
2197
+ properties = ['border-top-width', 'padding-top',
2198
+ 'padding-bottom', 'border-bottom-width'];
2199
+ }
2200
+ else {
2201
+ properties = ['border-left-width', 'padding-left',
2202
+ 'padding-right', 'border-right-width'];
2203
+ }
2204
+ return properties.inject(dim, function(memo, property) {
2205
+ var val = proceed(element, property);
2206
+ return val === null ? memo : memo - parseInt(val, 10);
2207
+ }) + 'px';
2208
+ default: return proceed(element, style);
2209
+ }
2210
+ }
2211
+ );
2212
+
2213
+ Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
2214
+ function(proceed, element, attribute) {
2215
+ if (attribute === 'title') return element.title;
2216
+ return proceed(element, attribute);
2217
+ }
2218
+ );
2219
+ }
2220
+
2221
+ else if (Prototype.Browser.IE) {
2222
+ // IE doesn't report offsets correctly for static elements, so we change them
2223
+ // to "relative" to get the values, then change them back.
2224
+ Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
2225
+ function(proceed, element) {
2226
+ element = $(element);
2227
+ // IE throws an error if element is not in document
2228
+ try { element.offsetParent }
2229
+ catch(e) { return $(document.body) }
2230
+ var position = element.getStyle('position');
2231
+ if (position !== 'static') return proceed(element);
2232
+ element.setStyle({ position: 'relative' });
2233
+ var value = proceed(element);
2234
+ element.setStyle({ position: position });
2235
+ return value;
2236
+ }
2237
+ );
2238
+
2239
+ $w('positionedOffset viewportOffset').each(function(method) {
2240
+ Element.Methods[method] = Element.Methods[method].wrap(
2241
+ function(proceed, element) {
2242
+ element = $(element);
2243
+ try { element.offsetParent }
2244
+ catch(e) { return Element._returnOffset(0,0) }
2245
+ var position = element.getStyle('position');
2246
+ if (position !== 'static') return proceed(element);
2247
+ // Trigger hasLayout on the offset parent so that IE6 reports
2248
+ // accurate offsetTop and offsetLeft values for position: fixed.
2249
+ var offsetParent = element.getOffsetParent();
2250
+ if (offsetParent && offsetParent.getStyle('position') === 'fixed')
2251
+ offsetParent.setStyle({ zoom: 1 });
2252
+ element.setStyle({ position: 'relative' });
2253
+ var value = proceed(element);
2254
+ element.setStyle({ position: position });
2255
+ return value;
2256
+ }
2257
+ );
2258
+ });
2259
+
2260
+ Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
2261
+ function(proceed, element) {
2262
+ try { element.offsetParent }
2263
+ catch(e) { return Element._returnOffset(0,0) }
2264
+ return proceed(element);
2265
+ }
2266
+ );
2267
+
2268
+ Element.Methods.getStyle = function(element, style) {
2269
+ element = $(element);
2270
+ style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
2271
+ var value = element.style[style];
2272
+ if (!value && element.currentStyle) value = element.currentStyle[style];
2273
+
2274
+ if (style == 'opacity') {
2275
+ if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
2276
+ if (value[1]) return parseFloat(value[1]) / 100;
2277
+ return 1.0;
2278
+ }
2279
+
2280
+ if (value == 'auto') {
2281
+ if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
2282
+ return element['offset' + style.capitalize()] + 'px';
2283
+ return null;
2284
+ }
2285
+ return value;
2286
+ };
2287
+
2288
+ Element.Methods.setOpacity = function(element, value) {
2289
+ function stripAlpha(filter){
2290
+ return filter.replace(/alpha\([^\)]*\)/gi,'');
2291
+ }
2292
+ element = $(element);
2293
+ var currentStyle = element.currentStyle;
2294
+ if ((currentStyle && !currentStyle.hasLayout) ||
2295
+ (!currentStyle && element.style.zoom == 'normal'))
2296
+ element.style.zoom = 1;
2297
+
2298
+ var filter = element.getStyle('filter'), style = element.style;
2299
+ if (value == 1 || value === '') {
2300
+ (filter = stripAlpha(filter)) ?
2301
+ style.filter = filter : style.removeAttribute('filter');
2302
+ return element;
2303
+ } else if (value < 0.00001) value = 0;
2304
+ style.filter = stripAlpha(filter) +
2305
+ 'alpha(opacity=' + (value * 100) + ')';
2306
+ return element;
2307
+ };
2308
+
2309
+ Element._attributeTranslations = {
2310
+ read: {
2311
+ names: {
2312
+ 'class': 'className',
2313
+ 'for': 'htmlFor'
2314
+ },
2315
+ values: {
2316
+ _getAttr: function(element, attribute) {
2317
+ return element.getAttribute(attribute, 2);
2318
+ },
2319
+ _getAttrNode: function(element, attribute) {
2320
+ var node = element.getAttributeNode(attribute);
2321
+ return node ? node.value : "";
2322
+ },
2323
+ _getEv: function(element, attribute) {
2324
+ attribute = element.getAttribute(attribute);
2325
+ return attribute ? attribute.toString().slice(23, -2) : null;
2326
+ },
2327
+ _flag: function(element, attribute) {
2328
+ return $(element).hasAttribute(attribute) ? attribute : null;
2329
+ },
2330
+ style: function(element) {
2331
+ return element.style.cssText.toLowerCase();
2332
+ },
2333
+ title: function(element) {
2334
+ return element.title;
2335
+ }
2336
+ }
2337
+ }
2338
+ };
2339
+
2340
+ Element._attributeTranslations.write = {
2341
+ names: Object.extend({
2342
+ cellpadding: 'cellPadding',
2343
+ cellspacing: 'cellSpacing'
2344
+ }, Element._attributeTranslations.read.names),
2345
+ values: {
2346
+ checked: function(element, value) {
2347
+ element.checked = !!value;
2348
+ },
2349
+
2350
+ style: function(element, value) {
2351
+ element.style.cssText = value ? value : '';
2352
+ }
2353
+ }
2354
+ };
2355
+
2356
+ Element._attributeTranslations.has = {};
2357
+
2358
+ $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
2359
+ 'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
2360
+ Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
2361
+ Element._attributeTranslations.has[attr.toLowerCase()] = attr;
2362
+ });
2363
+
2364
+ (function(v) {
2365
+ Object.extend(v, {
2366
+ href: v._getAttr,
2367
+ src: v._getAttr,
2368
+ type: v._getAttr,
2369
+ action: v._getAttrNode,
2370
+ disabled: v._flag,
2371
+ checked: v._flag,
2372
+ readonly: v._flag,
2373
+ multiple: v._flag,
2374
+ onload: v._getEv,
2375
+ onunload: v._getEv,
2376
+ onclick: v._getEv,
2377
+ ondblclick: v._getEv,
2378
+ onmousedown: v._getEv,
2379
+ onmouseup: v._getEv,
2380
+ onmouseover: v._getEv,
2381
+ onmousemove: v._getEv,
2382
+ onmouseout: v._getEv,
2383
+ onfocus: v._getEv,
2384
+ onblur: v._getEv,
2385
+ onkeypress: v._getEv,
2386
+ onkeydown: v._getEv,
2387
+ onkeyup: v._getEv,
2388
+ onsubmit: v._getEv,
2389
+ onreset: v._getEv,
2390
+ onselect: v._getEv,
2391
+ onchange: v._getEv
2392
+ });
2393
+ })(Element._attributeTranslations.read.values);
2394
+ }
2395
+
2396
+ else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
2397
+ Element.Methods.setOpacity = function(element, value) {
2398
+ element = $(element);
2399
+ element.style.opacity = (value == 1) ? 0.999999 :
2400
+ (value === '') ? '' : (value < 0.00001) ? 0 : value;
2401
+ return element;
2402
+ };
2403
+ }
2404
+
2405
+ else if (Prototype.Browser.WebKit) {
2406
+ Element.Methods.setOpacity = function(element, value) {
2407
+ element = $(element);
2408
+ element.style.opacity = (value == 1 || value === '') ? '' :
2409
+ (value < 0.00001) ? 0 : value;
2410
+
2411
+ if (value == 1)
2412
+ if(element.tagName.toUpperCase() == 'IMG' && element.width) {
2413
+ element.width++; element.width--;
2414
+ } else try {
2415
+ var n = document.createTextNode(' ');
2416
+ element.appendChild(n);
2417
+ element.removeChild(n);
2418
+ } catch (e) { }
2419
+
2420
+ return element;
2421
+ };
2422
+
2423
+ // Safari returns margins on body which is incorrect if the child is absolutely
2424
+ // positioned. For performance reasons, redefine Element#cumulativeOffset for
2425
+ // KHTML/WebKit only.
2426
+ Element.Methods.cumulativeOffset = function(element) {
2427
+ var valueT = 0, valueL = 0;
2428
+ do {
2429
+ valueT += element.offsetTop || 0;
2430
+ valueL += element.offsetLeft || 0;
2431
+ if (element.offsetParent == document.body)
2432
+ if (Element.getStyle(element, 'position') == 'absolute') break;
2433
+
2434
+ element = element.offsetParent;
2435
+ } while (element);
2436
+
2437
+ return Element._returnOffset(valueL, valueT);
2438
+ };
2439
+ }
2440
+
2441
+ if (Prototype.Browser.IE || Prototype.Browser.Opera) {
2442
+ // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements
2443
+ Element.Methods.update = function(element, content) {
2444
+ element = $(element);
2445
+
2446
+ if (content && content.toElement) content = content.toElement();
2447
+ if (Object.isElement(content)) return element.update().insert(content);
2448
+
2449
+ content = Object.toHTML(content);
2450
+ var tagName = element.tagName.toUpperCase();
2451
+
2452
+ if (tagName in Element._insertionTranslations.tags) {
2453
+ $A(element.childNodes).each(function(node) { element.removeChild(node) });
2454
+ Element._getContentFromAnonymousElement(tagName, content.stripScripts())
2455
+ .each(function(node) { element.appendChild(node) });
2456
+ }
2457
+ else element.innerHTML = content.stripScripts();
2458
+
2459
+ content.evalScripts.bind(content).defer();
2460
+ return element;
2461
+ };
2462
+ }
2463
+
2464
+ if ('outerHTML' in document.createElement('div')) {
2465
+ Element.Methods.replace = function(element, content) {
2466
+ element = $(element);
2467
+
2468
+ if (content && content.toElement) content = content.toElement();
2469
+ if (Object.isElement(content)) {
2470
+ element.parentNode.replaceChild(content, element);
2471
+ return element;
2472
+ }
2473
+
2474
+ content = Object.toHTML(content);
2475
+ var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
2476
+
2477
+ if (Element._insertionTranslations.tags[tagName]) {
2478
+ var nextSibling = element.next();
2479
+ var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
2480
+ parent.removeChild(element);
2481
+ if (nextSibling)
2482
+ fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
2483
+ else
2484
+ fragments.each(function(node) { parent.appendChild(node) });
2485
+ }
2486
+ else element.outerHTML = content.stripScripts();
2487
+
2488
+ content.evalScripts.bind(content).defer();
2489
+ return element;
2490
+ };
2491
+ }
2492
+
2493
+ Element._returnOffset = function(l, t) {
2494
+ var result = [l, t];
2495
+ result.left = l;
2496
+ result.top = t;
2497
+ return result;
2498
+ };
2499
+
2500
+ Element._getContentFromAnonymousElement = function(tagName, html) {
2501
+ var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
2502
+ if (t) {
2503
+ div.innerHTML = t[0] + html + t[1];
2504
+ t[2].times(function() { div = div.firstChild });
2505
+ } else div.innerHTML = html;
2506
+ return $A(div.childNodes);
2507
+ };
2508
+
2509
+ Element._insertionTranslations = {
2510
+ before: function(element, node) {
2511
+ element.parentNode.insertBefore(node, element);
2512
+ },
2513
+ top: function(element, node) {
2514
+ element.insertBefore(node, element.firstChild);
2515
+ },
2516
+ bottom: function(element, node) {
2517
+ element.appendChild(node);
2518
+ },
2519
+ after: function(element, node) {
2520
+ element.parentNode.insertBefore(node, element.nextSibling);
2521
+ },
2522
+ tags: {
2523
+ TABLE: ['<table>', '</table>', 1],
2524
+ TBODY: ['<table><tbody>', '</tbody></table>', 2],
2525
+ TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3],
2526
+ TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
2527
+ SELECT: ['<select>', '</select>', 1]
2528
+ }
2529
+ };
2530
+
2531
+ (function() {
2532
+ Object.extend(this.tags, {
2533
+ THEAD: this.tags.TBODY,
2534
+ TFOOT: this.tags.TBODY,
2535
+ TH: this.tags.TD
2536
+ });
2537
+ }).call(Element._insertionTranslations);
2538
+
2539
+ Element.Methods.Simulated = {
2540
+ hasAttribute: function(element, attribute) {
2541
+ attribute = Element._attributeTranslations.has[attribute] || attribute;
2542
+ var node = $(element).getAttributeNode(attribute);
2543
+ return !!(node && node.specified);
2544
+ }
2545
+ };
2546
+
2547
+ Element.Methods.ByTag = { };
2548
+
2549
+ Object.extend(Element, Element.Methods);
2550
+
2551
+ if (!Prototype.BrowserFeatures.ElementExtensions &&
2552
+ document.createElement('div')['__proto__']) {
2553
+ window.HTMLElement = { };
2554
+ window.HTMLElement.prototype = document.createElement('div')['__proto__'];
2555
+ Prototype.BrowserFeatures.ElementExtensions = true;
2556
+ }
2557
+
2558
+ Element.extend = (function() {
2559
+ if (Prototype.BrowserFeatures.SpecificElementExtensions)
2560
+ return Prototype.K;
2561
+
2562
+ var Methods = { }, ByTag = Element.Methods.ByTag;
2563
+
2564
+ var extend = Object.extend(function(element) {
2565
+ if (!element || element._extendedByPrototype ||
2566
+ element.nodeType != 1 || element == window) return element;
2567
+
2568
+ var methods = Object.clone(Methods),
2569
+ tagName = element.tagName.toUpperCase(), property, value;
2570
+
2571
+ // extend methods for specific tags
2572
+ if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
2573
+
2574
+ for (property in methods) {
2575
+ value = methods[property];
2576
+ if (Object.isFunction(value) && !(property in element))
2577
+ element[property] = value.methodize();
2578
+ }
2579
+
2580
+ element._extendedByPrototype = Prototype.emptyFunction;
2581
+ return element;
2582
+
2583
+ }, {
2584
+ refresh: function() {
2585
+ // extend methods for all tags (Safari doesn't need this)
2586
+ if (!Prototype.BrowserFeatures.ElementExtensions) {
2587
+ Object.extend(Methods, Element.Methods);
2588
+ Object.extend(Methods, Element.Methods.Simulated);
2589
+ }
2590
+ }
2591
+ });
2592
+
2593
+ extend.refresh();
2594
+ return extend;
2595
+ })();
2596
+
2597
+ Element.hasAttribute = function(element, attribute) {
2598
+ if (element.hasAttribute) return element.hasAttribute(attribute);
2599
+ return Element.Methods.Simulated.hasAttribute(element, attribute);
2600
+ };
2601
+
2602
+ Element.addMethods = function(methods) {
2603
+ var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
2604
+
2605
+ if (!methods) {
2606
+ Object.extend(Form, Form.Methods);
2607
+ Object.extend(Form.Element, Form.Element.Methods);
2608
+ Object.extend(Element.Methods.ByTag, {
2609
+ "FORM": Object.clone(Form.Methods),
2610
+ "INPUT": Object.clone(Form.Element.Methods),
2611
+ "SELECT": Object.clone(Form.Element.Methods),
2612
+ "TEXTAREA": Object.clone(Form.Element.Methods)
2613
+ });
2614
+ }
2615
+
2616
+ if (arguments.length == 2) {
2617
+ var tagName = methods;
2618
+ methods = arguments[1];
2619
+ }
2620
+
2621
+ if (!tagName) Object.extend(Element.Methods, methods || { });
2622
+ else {
2623
+ if (Object.isArray(tagName)) tagName.each(extend);
2624
+ else extend(tagName);
2625
+ }
2626
+
2627
+ function extend(tagName) {
2628
+ tagName = tagName.toUpperCase();
2629
+ if (!Element.Methods.ByTag[tagName])
2630
+ Element.Methods.ByTag[tagName] = { };
2631
+ Object.extend(Element.Methods.ByTag[tagName], methods);
2632
+ }
2633
+
2634
+ function copy(methods, destination, onlyIfAbsent) {
2635
+ onlyIfAbsent = onlyIfAbsent || false;
2636
+ for (var property in methods) {
2637
+ var value = methods[property];
2638
+ if (!Object.isFunction(value)) continue;
2639
+ if (!onlyIfAbsent || !(property in destination))
2640
+ destination[property] = value.methodize();
2641
+ }
2642
+ }
2643
+
2644
+ function findDOMClass(tagName) {
2645
+ var klass;
2646
+ var trans = {
2647
+ "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
2648
+ "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
2649
+ "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
2650
+ "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
2651
+ "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
2652
+ "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
2653
+ "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
2654
+ "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
2655
+ "FrameSet", "IFRAME": "IFrame"
2656
+ };
2657
+ if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
2658
+ if (window[klass]) return window[klass];
2659
+ klass = 'HTML' + tagName + 'Element';
2660
+ if (window[klass]) return window[klass];
2661
+ klass = 'HTML' + tagName.capitalize() + 'Element';
2662
+ if (window[klass]) return window[klass];
2663
+
2664
+ window[klass] = { };
2665
+ window[klass].prototype = document.createElement(tagName)['__proto__'];
2666
+ return window[klass];
2667
+ }
2668
+
2669
+ if (F.ElementExtensions) {
2670
+ copy(Element.Methods, HTMLElement.prototype);
2671
+ copy(Element.Methods.Simulated, HTMLElement.prototype, true);
2672
+ }
2673
+
2674
+ if (F.SpecificElementExtensions) {
2675
+ for (var tag in Element.Methods.ByTag) {
2676
+ var klass = findDOMClass(tag);
2677
+ if (Object.isUndefined(klass)) continue;
2678
+ copy(T[tag], klass.prototype);
2679
+ }
2680
+ }
2681
+
2682
+ Object.extend(Element, Element.Methods);
2683
+ delete Element.ByTag;
2684
+
2685
+ if (Element.extend.refresh) Element.extend.refresh();
2686
+ Element.cache = { };
2687
+ };
2688
+
2689
+ document.viewport = {
2690
+ getDimensions: function() {
2691
+ var dimensions = { }, B = Prototype.Browser;
2692
+ $w('width height').each(function(d) {
2693
+ var D = d.capitalize();
2694
+ if (B.WebKit && !document.evaluate) {
2695
+ // Safari <3.0 needs self.innerWidth/Height
2696
+ dimensions[d] = self['inner' + D];
2697
+ } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) {
2698
+ // Opera <9.5 needs document.body.clientWidth/Height
2699
+ dimensions[d] = document.body['client' + D]
2700
+ } else {
2701
+ dimensions[d] = document.documentElement['client' + D];
2702
+ }
2703
+ });
2704
+ return dimensions;
2705
+ },
2706
+
2707
+ getWidth: function() {
2708
+ return this.getDimensions().width;
2709
+ },
2710
+
2711
+ getHeight: function() {
2712
+ return this.getDimensions().height;
2713
+ },
2714
+
2715
+ getScrollOffsets: function() {
2716
+ return Element._returnOffset(
2717
+ window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
2718
+ window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
2719
+ }
2720
+ };
2721
+ /* Portions of the Selector class are derived from Jack Slocum's DomQuery,
2722
+ * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
2723
+ * license. Please see http://www.yui-ext.com/ for more information. */
2724
+
2725
+ var Selector = Class.create({
2726
+ initialize: function(expression) {
2727
+ this.expression = expression.strip();
2728
+
2729
+ if (this.shouldUseSelectorsAPI()) {
2730
+ this.mode = 'selectorsAPI';
2731
+ } else if (this.shouldUseXPath()) {
2732
+ this.mode = 'xpath';
2733
+ this.compileXPathMatcher();
2734
+ } else {
2735
+ this.mode = "normal";
2736
+ this.compileMatcher();
2737
+ }
2738
+
2739
+ },
2740
+
2741
+ shouldUseXPath: function() {
2742
+ if (!Prototype.BrowserFeatures.XPath) return false;
2743
+
2744
+ var e = this.expression;
2745
+
2746
+ // Safari 3 chokes on :*-of-type and :empty
2747
+ if (Prototype.Browser.WebKit &&
2748
+ (e.include("-of-type") || e.include(":empty")))
2749
+ return false;
2750
+
2751
+ // XPath can't do namespaced attributes, nor can it read
2752
+ // the "checked" property from DOM nodes
2753
+ if ((/(\[[\w-]*?:|:checked)/).test(e))
2754
+ return false;
2755
+
2756
+ return true;
2757
+ },
2758
+
2759
+ shouldUseSelectorsAPI: function() {
2760
+ if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
2761
+
2762
+ if (!Selector._div) Selector._div = new Element('div');
2763
+
2764
+ // Make sure the browser treats the selector as valid. Test on an
2765
+ // isolated element to minimize cost of this check.
2766
+ try {
2767
+ Selector._div.querySelector(this.expression);
2768
+ } catch(e) {
2769
+ return false;
2770
+ }
2771
+
2772
+ return true;
2773
+ },
2774
+
2775
+ compileMatcher: function() {
2776
+ var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
2777
+ c = Selector.criteria, le, p, m;
2778
+
2779
+ if (Selector._cache[e]) {
2780
+ this.matcher = Selector._cache[e];
2781
+ return;
2782
+ }
2783
+
2784
+ this.matcher = ["this.matcher = function(root) {",
2785
+ "var r = root, h = Selector.handlers, c = false, n;"];
2786
+
2787
+ while (e && le != e && (/\S/).test(e)) {
2788
+ le = e;
2789
+ for (var i in ps) {
2790
+ p = ps[i];
2791
+ if (m = e.match(p)) {
2792
+ this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
2793
+ new Template(c[i]).evaluate(m));
2794
+ e = e.replace(m[0], '');
2795
+ break;
2796
+ }
2797
+ }
2798
+ }
2799
+
2800
+ this.matcher.push("return h.unique(n);\n}");
2801
+ eval(this.matcher.join('\n'));
2802
+ Selector._cache[this.expression] = this.matcher;
2803
+ },
2804
+
2805
+ compileXPathMatcher: function() {
2806
+ var e = this.expression, ps = Selector.patterns,
2807
+ x = Selector.xpath, le, m;
2808
+
2809
+ if (Selector._cache[e]) {
2810
+ this.xpath = Selector._cache[e]; return;
2811
+ }
2812
+
2813
+ this.matcher = ['.//*'];
2814
+ while (e && le != e && (/\S/).test(e)) {
2815
+ le = e;
2816
+ for (var i in ps) {
2817
+ if (m = e.match(ps[i])) {
2818
+ this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
2819
+ new Template(x[i]).evaluate(m));
2820
+ e = e.replace(m[0], '');
2821
+ break;
2822
+ }
2823
+ }
2824
+ }
2825
+
2826
+ this.xpath = this.matcher.join('');
2827
+ Selector._cache[this.expression] = this.xpath;
2828
+ },
2829
+
2830
+ findElements: function(root) {
2831
+ root = root || document;
2832
+ var e = this.expression, results;
2833
+
2834
+ switch (this.mode) {
2835
+ case 'selectorsAPI':
2836
+ // querySelectorAll queries document-wide, then filters to descendants
2837
+ // of the context element. That's not what we want.
2838
+ // Add an explicit context to the selector if necessary.
2839
+ if (root !== document) {
2840
+ var oldId = root.id, id = $(root).identify();
2841
+ e = "#" + id + " " + e;
2842
+ }
2843
+
2844
+ results = $A(root.querySelectorAll(e)).map(Element.extend);
2845
+ root.id = oldId;
2846
+
2847
+ return results;
2848
+ case 'xpath':
2849
+ return document._getElementsByXPath(this.xpath, root);
2850
+ default:
2851
+ return this.matcher(root);
2852
+ }
2853
+ },
2854
+
2855
+ match: function(element) {
2856
+ this.tokens = [];
2857
+
2858
+ var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
2859
+ var le, p, m;
2860
+
2861
+ while (e && le !== e && (/\S/).test(e)) {
2862
+ le = e;
2863
+ for (var i in ps) {
2864
+ p = ps[i];
2865
+ if (m = e.match(p)) {
2866
+ // use the Selector.assertions methods unless the selector
2867
+ // is too complex.
2868
+ if (as[i]) {
2869
+ this.tokens.push([i, Object.clone(m)]);
2870
+ e = e.replace(m[0], '');
2871
+ } else {
2872
+ // reluctantly do a document-wide search
2873
+ // and look for a match in the array
2874
+ return this.findElements(document).include(element);
2875
+ }
2876
+ }
2877
+ }
2878
+ }
2879
+
2880
+ var match = true, name, matches;
2881
+ for (var i = 0, token; token = this.tokens[i]; i++) {
2882
+ name = token[0], matches = token[1];
2883
+ if (!Selector.assertions[name](element, matches)) {
2884
+ match = false; break;
2885
+ }
2886
+ }
2887
+
2888
+ return match;
2889
+ },
2890
+
2891
+ toString: function() {
2892
+ return this.expression;
2893
+ },
2894
+
2895
+ inspect: function() {
2896
+ return "#<Selector:" + this.expression.inspect() + ">";
2897
+ }
2898
+ });
2899
+
2900
+ Object.extend(Selector, {
2901
+ _cache: { },
2902
+
2903
+ xpath: {
2904
+ descendant: "//*",
2905
+ child: "/*",
2906
+ adjacent: "/following-sibling::*[1]",
2907
+ laterSibling: '/following-sibling::*',
2908
+ tagName: function(m) {
2909
+ if (m[1] == '*') return '';
2910
+ return "[local-name()='" + m[1].toLowerCase() +
2911
+ "' or local-name()='" + m[1].toUpperCase() + "']";
2912
+ },
2913
+ className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
2914
+ id: "[@id='#{1}']",
2915
+ attrPresence: function(m) {
2916
+ m[1] = m[1].toLowerCase();
2917
+ return new Template("[@#{1}]").evaluate(m);
2918
+ },
2919
+ attr: function(m) {
2920
+ m[1] = m[1].toLowerCase();
2921
+ m[3] = m[5] || m[6];
2922
+ return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
2923
+ },
2924
+ pseudo: function(m) {
2925
+ var h = Selector.xpath.pseudos[m[1]];
2926
+ if (!h) return '';
2927
+ if (Object.isFunction(h)) return h(m);
2928
+ return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
2929
+ },
2930
+ operators: {
2931
+ '=': "[@#{1}='#{3}']",
2932
+ '!=': "[@#{1}!='#{3}']",
2933
+ '^=': "[starts-with(@#{1}, '#{3}')]",
2934
+ '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
2935
+ '*=': "[contains(@#{1}, '#{3}')]",
2936
+ '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
2937
+ '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
2938
+ },
2939
+ pseudos: {
2940
+ 'first-child': '[not(preceding-sibling::*)]',
2941
+ 'last-child': '[not(following-sibling::*)]',
2942
+ 'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
2943
+ 'empty': "[count(*) = 0 and (count(text()) = 0)]",
2944
+ 'checked': "[@checked]",
2945
+ 'disabled': "[(@disabled) and (@type!='hidden')]",
2946
+ 'enabled': "[not(@disabled) and (@type!='hidden')]",
2947
+ 'not': function(m) {
2948
+ var e = m[6], p = Selector.patterns,
2949
+ x = Selector.xpath, le, v;
2950
+
2951
+ var exclusion = [];
2952
+ while (e && le != e && (/\S/).test(e)) {
2953
+ le = e;
2954
+ for (var i in p) {
2955
+ if (m = e.match(p[i])) {
2956
+ v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
2957
+ exclusion.push("(" + v.substring(1, v.length - 1) + ")");
2958
+ e = e.replace(m[0], '');
2959
+ break;
2960
+ }
2961
+ }
2962
+ }
2963
+ return "[not(" + exclusion.join(" and ") + ")]";
2964
+ },
2965
+ 'nth-child': function(m) {
2966
+ return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
2967
+ },
2968
+ 'nth-last-child': function(m) {
2969
+ return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
2970
+ },
2971
+ 'nth-of-type': function(m) {
2972
+ return Selector.xpath.pseudos.nth("position() ", m);
2973
+ },
2974
+ 'nth-last-of-type': function(m) {
2975
+ return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
2976
+ },
2977
+ 'first-of-type': function(m) {
2978
+ m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
2979
+ },
2980
+ 'last-of-type': function(m) {
2981
+ m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
2982
+ },
2983
+ 'only-of-type': function(m) {
2984
+ var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
2985
+ },
2986
+ nth: function(fragment, m) {
2987
+ var mm, formula = m[6], predicate;
2988
+ if (formula == 'even') formula = '2n+0';
2989
+ if (formula == 'odd') formula = '2n+1';
2990
+ if (mm = formula.match(/^(\d+)$/)) // digit only
2991
+ return '[' + fragment + "= " + mm[1] + ']';
2992
+ if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
2993
+ if (mm[1] == "-") mm[1] = -1;
2994
+ var a = mm[1] ? Number(mm[1]) : 1;
2995
+ var b = mm[2] ? Number(mm[2]) : 0;
2996
+ predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
2997
+ "((#{fragment} - #{b}) div #{a} >= 0)]";
2998
+ return new Template(predicate).evaluate({
2999
+ fragment: fragment, a: a, b: b });
3000
+ }
3001
+ }
3002
+ }
3003
+ },
3004
+
3005
+ criteria: {
3006
+ tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
3007
+ className: 'n = h.className(n, r, "#{1}", c); c = false;',
3008
+ id: 'n = h.id(n, r, "#{1}", c); c = false;',
3009
+ attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
3010
+ attr: function(m) {
3011
+ m[3] = (m[5] || m[6]);
3012
+ return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);
3013
+ },
3014
+ pseudo: function(m) {
3015
+ if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
3016
+ return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
3017
+ },
3018
+ descendant: 'c = "descendant";',
3019
+ child: 'c = "child";',
3020
+ adjacent: 'c = "adjacent";',
3021
+ laterSibling: 'c = "laterSibling";'
3022
+ },
3023
+
3024
+ patterns: {
3025
+ // combinators must be listed first
3026
+ // (and descendant needs to be last combinator)
3027
+ laterSibling: /^\s*~\s*/,
3028
+ child: /^\s*>\s*/,
3029
+ adjacent: /^\s*\+\s*/,
3030
+ descendant: /^\s/,
3031
+
3032
+ // selectors follow
3033
+ tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
3034
+ id: /^#([\w\-\*]+)(\b|$)/,
3035
+ className: /^\.([\w\-\*]+)(\b|$)/,
3036
+ pseudo:
3037
+ /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
3038
+ attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/,
3039
+ attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
3040
+ },
3041
+
3042
+ // for Selector.match and Element#match
3043
+ assertions: {
3044
+ tagName: function(element, matches) {
3045
+ return matches[1].toUpperCase() == element.tagName.toUpperCase();
3046
+ },
3047
+
3048
+ className: function(element, matches) {
3049
+ return Element.hasClassName(element, matches[1]);
3050
+ },
3051
+
3052
+ id: function(element, matches) {
3053
+ return element.id === matches[1];
3054
+ },
3055
+
3056
+ attrPresence: function(element, matches) {
3057
+ return Element.hasAttribute(element, matches[1]);
3058
+ },
3059
+
3060
+ attr: function(element, matches) {
3061
+ var nodeValue = Element.readAttribute(element, matches[1]);
3062
+ return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]);
3063
+ }
3064
+ },
3065
+
3066
+ handlers: {
3067
+ // UTILITY FUNCTIONS
3068
+ // joins two collections
3069
+ concat: function(a, b) {
3070
+ for (var i = 0, node; node = b[i]; i++)
3071
+ a.push(node);
3072
+ return a;
3073
+ },
3074
+
3075
+ // marks an array of nodes for counting
3076
+ mark: function(nodes) {
3077
+ var _true = Prototype.emptyFunction;
3078
+ for (var i = 0, node; node = nodes[i]; i++)
3079
+ node._countedByPrototype = _true;
3080
+ return nodes;
3081
+ },
3082
+
3083
+ unmark: function(nodes) {
3084
+ for (var i = 0, node; node = nodes[i]; i++)
3085
+ node._countedByPrototype = undefined;
3086
+ return nodes;
3087
+ },
3088
+
3089
+ // mark each child node with its position (for nth calls)
3090
+ // "ofType" flag indicates whether we're indexing for nth-of-type
3091
+ // rather than nth-child
3092
+ index: function(parentNode, reverse, ofType) {
3093
+ parentNode._countedByPrototype = Prototype.emptyFunction;
3094
+ if (reverse) {
3095
+ for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
3096
+ var node = nodes[i];
3097
+ if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
3098
+ }
3099
+ } else {
3100
+ for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
3101
+ if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
3102
+ }
3103
+ },
3104
+
3105
+ // filters out duplicates and extends all nodes
3106
+ unique: function(nodes) {
3107
+ if (nodes.length == 0) return nodes;
3108
+ var results = [], n;
3109
+ for (var i = 0, l = nodes.length; i < l; i++)
3110
+ if (!(n = nodes[i])._countedByPrototype) {
3111
+ n._countedByPrototype = Prototype.emptyFunction;
3112
+ results.push(Element.extend(n));
3113
+ }
3114
+ return Selector.handlers.unmark(results);
3115
+ },
3116
+
3117
+ // COMBINATOR FUNCTIONS
3118
+ descendant: function(nodes) {
3119
+ var h = Selector.handlers;
3120
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3121
+ h.concat(results, node.getElementsByTagName('*'));
3122
+ return results;
3123
+ },
3124
+
3125
+ child: function(nodes) {
3126
+ var h = Selector.handlers;
3127
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
3128
+ for (var j = 0, child; child = node.childNodes[j]; j++)
3129
+ if (child.nodeType == 1 && child.tagName != '!') results.push(child);
3130
+ }
3131
+ return results;
3132
+ },
3133
+
3134
+ adjacent: function(nodes) {
3135
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
3136
+ var next = this.nextElementSibling(node);
3137
+ if (next) results.push(next);
3138
+ }
3139
+ return results;
3140
+ },
3141
+
3142
+ laterSibling: function(nodes) {
3143
+ var h = Selector.handlers;
3144
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3145
+ h.concat(results, Element.nextSiblings(node));
3146
+ return results;
3147
+ },
3148
+
3149
+ nextElementSibling: function(node) {
3150
+ while (node = node.nextSibling)
3151
+ if (node.nodeType == 1) return node;
3152
+ return null;
3153
+ },
3154
+
3155
+ previousElementSibling: function(node) {
3156
+ while (node = node.previousSibling)
3157
+ if (node.nodeType == 1) return node;
3158
+ return null;
3159
+ },
3160
+
3161
+ // TOKEN FUNCTIONS
3162
+ tagName: function(nodes, root, tagName, combinator) {
3163
+ var uTagName = tagName.toUpperCase();
3164
+ var results = [], h = Selector.handlers;
3165
+ if (nodes) {
3166
+ if (combinator) {
3167
+ // fastlane for ordinary descendant combinators
3168
+ if (combinator == "descendant") {
3169
+ for (var i = 0, node; node = nodes[i]; i++)
3170
+ h.concat(results, node.getElementsByTagName(tagName));
3171
+ return results;
3172
+ } else nodes = this[combinator](nodes);
3173
+ if (tagName == "*") return nodes;
3174
+ }
3175
+ for (var i = 0, node; node = nodes[i]; i++)
3176
+ if (node.tagName.toUpperCase() === uTagName) results.push(node);
3177
+ return results;
3178
+ } else return root.getElementsByTagName(tagName);
3179
+ },
3180
+
3181
+ id: function(nodes, root, id, combinator) {
3182
+ var targetNode = $(id), h = Selector.handlers;
3183
+ if (!targetNode) return [];
3184
+ if (!nodes && root == document) return [targetNode];
3185
+ if (nodes) {
3186
+ if (combinator) {
3187
+ if (combinator == 'child') {
3188
+ for (var i = 0, node; node = nodes[i]; i++)
3189
+ if (targetNode.parentNode == node) return [targetNode];
3190
+ } else if (combinator == 'descendant') {
3191
+ for (var i = 0, node; node = nodes[i]; i++)
3192
+ if (Element.descendantOf(targetNode, node)) return [targetNode];
3193
+ } else if (combinator == 'adjacent') {
3194
+ for (var i = 0, node; node = nodes[i]; i++)
3195
+ if (Selector.handlers.previousElementSibling(targetNode) == node)
3196
+ return [targetNode];
3197
+ } else nodes = h[combinator](nodes);
3198
+ }
3199
+ for (var i = 0, node; node = nodes[i]; i++)
3200
+ if (node == targetNode) return [targetNode];
3201
+ return [];
3202
+ }
3203
+ return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
3204
+ },
3205
+
3206
+ className: function(nodes, root, className, combinator) {
3207
+ if (nodes && combinator) nodes = this[combinator](nodes);
3208
+ return Selector.handlers.byClassName(nodes, root, className);
3209
+ },
3210
+
3211
+ byClassName: function(nodes, root, className) {
3212
+ if (!nodes) nodes = Selector.handlers.descendant([root]);
3213
+ var needle = ' ' + className + ' ';
3214
+ for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
3215
+ nodeClassName = node.className;
3216
+ if (nodeClassName.length == 0) continue;
3217
+ if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
3218
+ results.push(node);
3219
+ }
3220
+ return results;
3221
+ },
3222
+
3223
+ attrPresence: function(nodes, root, attr, combinator) {
3224
+ if (!nodes) nodes = root.getElementsByTagName("*");
3225
+ if (nodes && combinator) nodes = this[combinator](nodes);
3226
+ var results = [];
3227
+ for (var i = 0, node; node = nodes[i]; i++)
3228
+ if (Element.hasAttribute(node, attr)) results.push(node);
3229
+ return results;
3230
+ },
3231
+
3232
+ attr: function(nodes, root, attr, value, operator, combinator) {
3233
+ if (!nodes) nodes = root.getElementsByTagName("*");
3234
+ if (nodes && combinator) nodes = this[combinator](nodes);
3235
+ var handler = Selector.operators[operator], results = [];
3236
+ for (var i = 0, node; node = nodes[i]; i++) {
3237
+ var nodeValue = Element.readAttribute(node, attr);
3238
+ if (nodeValue === null) continue;
3239
+ if (handler(nodeValue, value)) results.push(node);
3240
+ }
3241
+ return results;
3242
+ },
3243
+
3244
+ pseudo: function(nodes, name, value, root, combinator) {
3245
+ if (nodes && combinator) nodes = this[combinator](nodes);
3246
+ if (!nodes) nodes = root.getElementsByTagName("*");
3247
+ return Selector.pseudos[name](nodes, value, root);
3248
+ }
3249
+ },
3250
+
3251
+ pseudos: {
3252
+ 'first-child': function(nodes, value, root) {
3253
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
3254
+ if (Selector.handlers.previousElementSibling(node)) continue;
3255
+ results.push(node);
3256
+ }
3257
+ return results;
3258
+ },
3259
+ 'last-child': function(nodes, value, root) {
3260
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
3261
+ if (Selector.handlers.nextElementSibling(node)) continue;
3262
+ results.push(node);
3263
+ }
3264
+ return results;
3265
+ },
3266
+ 'only-child': function(nodes, value, root) {
3267
+ var h = Selector.handlers;
3268
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3269
+ if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
3270
+ results.push(node);
3271
+ return results;
3272
+ },
3273
+ 'nth-child': function(nodes, formula, root) {
3274
+ return Selector.pseudos.nth(nodes, formula, root);
3275
+ },
3276
+ 'nth-last-child': function(nodes, formula, root) {
3277
+ return Selector.pseudos.nth(nodes, formula, root, true);
3278
+ },
3279
+ 'nth-of-type': function(nodes, formula, root) {
3280
+ return Selector.pseudos.nth(nodes, formula, root, false, true);
3281
+ },
3282
+ 'nth-last-of-type': function(nodes, formula, root) {
3283
+ return Selector.pseudos.nth(nodes, formula, root, true, true);
3284
+ },
3285
+ 'first-of-type': function(nodes, formula, root) {
3286
+ return Selector.pseudos.nth(nodes, "1", root, false, true);
3287
+ },
3288
+ 'last-of-type': function(nodes, formula, root) {
3289
+ return Selector.pseudos.nth(nodes, "1", root, true, true);
3290
+ },
3291
+ 'only-of-type': function(nodes, formula, root) {
3292
+ var p = Selector.pseudos;
3293
+ return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
3294
+ },
3295
+
3296
+ // handles the an+b logic
3297
+ getIndices: function(a, b, total) {
3298
+ if (a == 0) return b > 0 ? [b] : [];
3299
+ return $R(1, total).inject([], function(memo, i) {
3300
+ if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
3301
+ return memo;
3302
+ });
3303
+ },
3304
+
3305
+ // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
3306
+ nth: function(nodes, formula, root, reverse, ofType) {
3307
+ if (nodes.length == 0) return [];
3308
+ if (formula == 'even') formula = '2n+0';
3309
+ if (formula == 'odd') formula = '2n+1';
3310
+ var h = Selector.handlers, results = [], indexed = [], m;
3311
+ h.mark(nodes);
3312
+ for (var i = 0, node; node = nodes[i]; i++) {
3313
+ if (!node.parentNode._countedByPrototype) {
3314
+ h.index(node.parentNode, reverse, ofType);
3315
+ indexed.push(node.parentNode);
3316
+ }
3317
+ }
3318
+ if (formula.match(/^\d+$/)) { // just a number
3319
+ formula = Number(formula);
3320
+ for (var i = 0, node; node = nodes[i]; i++)
3321
+ if (node.nodeIndex == formula) results.push(node);
3322
+ } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
3323
+ if (m[1] == "-") m[1] = -1;
3324
+ var a = m[1] ? Number(m[1]) : 1;
3325
+ var b = m[2] ? Number(m[2]) : 0;
3326
+ var indices = Selector.pseudos.getIndices(a, b, nodes.length);
3327
+ for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
3328
+ for (var j = 0; j < l; j++)
3329
+ if (node.nodeIndex == indices[j]) results.push(node);
3330
+ }
3331
+ }
3332
+ h.unmark(nodes);
3333
+ h.unmark(indexed);
3334
+ return results;
3335
+ },
3336
+
3337
+ 'empty': function(nodes, value, root) {
3338
+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
3339
+ // IE treats comments as element nodes
3340
+ if (node.tagName == '!' || node.firstChild) continue;
3341
+ results.push(node);
3342
+ }
3343
+ return results;
3344
+ },
3345
+
3346
+ 'not': function(nodes, selector, root) {
3347
+ var h = Selector.handlers, selectorType, m;
3348
+ var exclusions = new Selector(selector).findElements(root);
3349
+ h.mark(exclusions);
3350
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3351
+ if (!node._countedByPrototype) results.push(node);
3352
+ h.unmark(exclusions);
3353
+ return results;
3354
+ },
3355
+
3356
+ 'enabled': function(nodes, value, root) {
3357
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3358
+ if (!node.disabled && (!node.type || node.type !== 'hidden'))
3359
+ results.push(node);
3360
+ return results;
3361
+ },
3362
+
3363
+ 'disabled': function(nodes, value, root) {
3364
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3365
+ if (node.disabled) results.push(node);
3366
+ return results;
3367
+ },
3368
+
3369
+ 'checked': function(nodes, value, root) {
3370
+ for (var i = 0, results = [], node; node = nodes[i]; i++)
3371
+ if (node.checked) results.push(node);
3372
+ return results;
3373
+ }
3374
+ },
3375
+
3376
+ operators: {
3377
+ '=': function(nv, v) { return nv == v; },
3378
+ '!=': function(nv, v) { return nv != v; },
3379
+ '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
3380
+ '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
3381
+ '*=': function(nv, v) { return nv == v || nv && nv.include(v); },
3382
+ '$=': function(nv, v) { return nv.endsWith(v); },
3383
+ '*=': function(nv, v) { return nv.include(v); },
3384
+ '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
3385
+ '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
3386
+ '-').include('-' + (v || "").toUpperCase() + '-'); }
3387
+ },
3388
+
3389
+ split: function(expression) {
3390
+ var expressions = [];
3391
+ expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
3392
+ expressions.push(m[1].strip());
3393
+ });
3394
+ return expressions;
3395
+ },
3396
+
3397
+ matchElements: function(elements, expression) {
3398
+ var matches = $$(expression), h = Selector.handlers;
3399
+ h.mark(matches);
3400
+ for (var i = 0, results = [], element; element = elements[i]; i++)
3401
+ if (element._countedByPrototype) results.push(element);
3402
+ h.unmark(matches);
3403
+ return results;
3404
+ },
3405
+
3406
+ findElement: function(elements, expression, index) {
3407
+ if (Object.isNumber(expression)) {
3408
+ index = expression; expression = false;
3409
+ }
3410
+ return Selector.matchElements(elements, expression || '*')[index || 0];
3411
+ },
3412
+
3413
+ findChildElements: function(element, expressions) {
3414
+ expressions = Selector.split(expressions.join(','));
3415
+ var results = [], h = Selector.handlers;
3416
+ for (var i = 0, l = expressions.length, selector; i < l; i++) {
3417
+ selector = new Selector(expressions[i].strip());
3418
+ h.concat(results, selector.findElements(element));
3419
+ }
3420
+ return (l > 1) ? h.unique(results) : results;
3421
+ }
3422
+ });
3423
+
3424
+ if (Prototype.Browser.IE) {
3425
+ Object.extend(Selector.handlers, {
3426
+ // IE returns comment nodes on getElementsByTagName("*").
3427
+ // Filter them out.
3428
+ concat: function(a, b) {
3429
+ for (var i = 0, node; node = b[i]; i++)
3430
+ if (node.tagName !== "!") a.push(node);
3431
+ return a;
3432
+ },
3433
+
3434
+ // IE improperly serializes _countedByPrototype in (inner|outer)HTML.
3435
+ unmark: function(nodes) {
3436
+ for (var i = 0, node; node = nodes[i]; i++)
3437
+ node.removeAttribute('_countedByPrototype');
3438
+ return nodes;
3439
+ }
3440
+ });
3441
+ }
3442
+
3443
+ function $$() {
3444
+ return Selector.findChildElements(document, $A(arguments));
3445
+ }
3446
+ var Form = {
3447
+ reset: function(form) {
3448
+ $(form).reset();
3449
+ return form;
3450
+ },
3451
+
3452
+ serializeElements: function(elements, options) {
3453
+ if (typeof options != 'object') options = { hash: !!options };
3454
+ else if (Object.isUndefined(options.hash)) options.hash = true;
3455
+ var key, value, submitted = false, submit = options.submit;
3456
+
3457
+ var data = elements.inject({ }, function(result, element) {
3458
+ if (!element.disabled && element.name) {
3459
+ key = element.name; value = $(element).getValue();
3460
+ if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
3461
+ submit !== false && (!submit || key == submit) && (submitted = true)))) {
3462
+ if (key in result) {
3463
+ // a key is already present; construct an array of values
3464
+ if (!Object.isArray(result[key])) result[key] = [result[key]];
3465
+ result[key].push(value);
3466
+ }
3467
+ else result[key] = value;
3468
+ }
3469
+ }
3470
+ return result;
3471
+ });
3472
+
3473
+ return options.hash ? data : Object.toQueryString(data);
3474
+ }
3475
+ };
3476
+
3477
+ Form.Methods = {
3478
+ serialize: function(form, options) {
3479
+ return Form.serializeElements(Form.getElements(form), options);
3480
+ },
3481
+
3482
+ getElements: function(form) {
3483
+ return $A($(form).getElementsByTagName('*')).inject([],
3484
+ function(elements, child) {
3485
+ if (Form.Element.Serializers[child.tagName.toLowerCase()])
3486
+ elements.push(Element.extend(child));
3487
+ return elements;
3488
+ }
3489
+ );
3490
+ },
3491
+
3492
+ getInputs: function(form, typeName, name) {
3493
+ form = $(form);
3494
+ var inputs = form.getElementsByTagName('input');
3495
+
3496
+ if (!typeName && !name) return $A(inputs).map(Element.extend);
3497
+
3498
+ for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
3499
+ var input = inputs[i];
3500
+ if ((typeName && input.type != typeName) || (name && input.name != name))
3501
+ continue;
3502
+ matchingInputs.push(Element.extend(input));
3503
+ }
3504
+
3505
+ return matchingInputs;
3506
+ },
3507
+
3508
+ disable: function(form) {
3509
+ form = $(form);
3510
+ Form.getElements(form).invoke('disable');
3511
+ return form;
3512
+ },
3513
+
3514
+ enable: function(form) {
3515
+ form = $(form);
3516
+ Form.getElements(form).invoke('enable');
3517
+ return form;
3518
+ },
3519
+
3520
+ findFirstElement: function(form) {
3521
+ var elements = $(form).getElements().findAll(function(element) {
3522
+ return 'hidden' != element.type && !element.disabled;
3523
+ });
3524
+ var firstByIndex = elements.findAll(function(element) {
3525
+ return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
3526
+ }).sortBy(function(element) { return element.tabIndex }).first();
3527
+
3528
+ return firstByIndex ? firstByIndex : elements.find(function(element) {
3529
+ return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
3530
+ });
3531
+ },
3532
+
3533
+ focusFirstElement: function(form) {
3534
+ form = $(form);
3535
+ form.findFirstElement().activate();
3536
+ return form;
3537
+ },
3538
+
3539
+ request: function(form, options) {
3540
+ form = $(form), options = Object.clone(options || { });
3541
+
3542
+ var params = options.parameters, action = form.readAttribute('action') || '';
3543
+ if (action.blank()) action = window.location.href;
3544
+ options.parameters = form.serialize(true);
3545
+
3546
+ if (params) {
3547
+ if (Object.isString(params)) params = params.toQueryParams();
3548
+ Object.extend(options.parameters, params);
3549
+ }
3550
+
3551
+ if (form.hasAttribute('method') && !options.method)
3552
+ options.method = form.method;
3553
+
3554
+ return new Ajax.Request(action, options);
3555
+ }
3556
+ };
3557
+
3558
+ /*--------------------------------------------------------------------------*/
3559
+
3560
+ Form.Element = {
3561
+ focus: function(element) {
3562
+ $(element).focus();
3563
+ return element;
3564
+ },
3565
+
3566
+ select: function(element) {
3567
+ $(element).select();
3568
+ return element;
3569
+ }
3570
+ };
3571
+
3572
+ Form.Element.Methods = {
3573
+ serialize: function(element) {
3574
+ element = $(element);
3575
+ if (!element.disabled && element.name) {
3576
+ var value = element.getValue();
3577
+ if (value != undefined) {
3578
+ var pair = { };
3579
+ pair[element.name] = value;
3580
+ return Object.toQueryString(pair);
3581
+ }
3582
+ }
3583
+ return '';
3584
+ },
3585
+
3586
+ getValue: function(element) {
3587
+ element = $(element);
3588
+ var method = element.tagName.toLowerCase();
3589
+ return Form.Element.Serializers[method](element);
3590
+ },
3591
+
3592
+ setValue: function(element, value) {
3593
+ element = $(element);
3594
+ var method = element.tagName.toLowerCase();
3595
+ Form.Element.Serializers[method](element, value);
3596
+ return element;
3597
+ },
3598
+
3599
+ clear: function(element) {
3600
+ $(element).value = '';
3601
+ return element;
3602
+ },
3603
+
3604
+ present: function(element) {
3605
+ return $(element).value != '';
3606
+ },
3607
+
3608
+ activate: function(element) {
3609
+ element = $(element);
3610
+ try {
3611
+ element.focus();
3612
+ if (element.select && (element.tagName.toLowerCase() != 'input' ||
3613
+ !['button', 'reset', 'submit'].include(element.type)))
3614
+ element.select();
3615
+ } catch (e) { }
3616
+ return element;
3617
+ },
3618
+
3619
+ disable: function(element) {
3620
+ element = $(element);
3621
+ element.disabled = true;
3622
+ return element;
3623
+ },
3624
+
3625
+ enable: function(element) {
3626
+ element = $(element);
3627
+ element.disabled = false;
3628
+ return element;
3629
+ }
3630
+ };
3631
+
3632
+ /*--------------------------------------------------------------------------*/
3633
+
3634
+ var Field = Form.Element;
3635
+ var $F = Form.Element.Methods.getValue;
3636
+
3637
+ /*--------------------------------------------------------------------------*/
3638
+
3639
+ Form.Element.Serializers = {
3640
+ input: function(element, value) {
3641
+ switch (element.type.toLowerCase()) {
3642
+ case 'checkbox':
3643
+ case 'radio':
3644
+ return Form.Element.Serializers.inputSelector(element, value);
3645
+ default:
3646
+ return Form.Element.Serializers.textarea(element, value);
3647
+ }
3648
+ },
3649
+
3650
+ inputSelector: function(element, value) {
3651
+ if (Object.isUndefined(value)) return element.checked ? element.value : null;
3652
+ else element.checked = !!value;
3653
+ },
3654
+
3655
+ textarea: function(element, value) {
3656
+ if (Object.isUndefined(value)) return element.value;
3657
+ else element.value = value;
3658
+ },
3659
+
3660
+ select: function(element, value) {
3661
+ if (Object.isUndefined(value))
3662
+ return this[element.type == 'select-one' ?
3663
+ 'selectOne' : 'selectMany'](element);
3664
+ else {
3665
+ var opt, currentValue, single = !Object.isArray(value);
3666
+ for (var i = 0, length = element.length; i < length; i++) {
3667
+ opt = element.options[i];
3668
+ currentValue = this.optionValue(opt);
3669
+ if (single) {
3670
+ if (currentValue == value) {
3671
+ opt.selected = true;
3672
+ return;
3673
+ }
3674
+ }
3675
+ else opt.selected = value.include(currentValue);
3676
+ }
3677
+ }
3678
+ },
3679
+
3680
+ selectOne: function(element) {
3681
+ var index = element.selectedIndex;
3682
+ return index >= 0 ? this.optionValue(element.options[index]) : null;
3683
+ },
3684
+
3685
+ selectMany: function(element) {
3686
+ var values, length = element.length;
3687
+ if (!length) return null;
3688
+
3689
+ for (var i = 0, values = []; i < length; i++) {
3690
+ var opt = element.options[i];
3691
+ if (opt.selected) values.push(this.optionValue(opt));
3692
+ }
3693
+ return values;
3694
+ },
3695
+
3696
+ optionValue: function(opt) {
3697
+ // extend element because hasAttribute may not be native
3698
+ return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
3699
+ }
3700
+ };
3701
+
3702
+ /*--------------------------------------------------------------------------*/
3703
+
3704
+ Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
3705
+ initialize: function($super, element, frequency, callback) {
3706
+ $super(callback, frequency);
3707
+ this.element = $(element);
3708
+ this.lastValue = this.getValue();
3709
+ },
3710
+
3711
+ execute: function() {
3712
+ var value = this.getValue();
3713
+ if (Object.isString(this.lastValue) && Object.isString(value) ?
3714
+ this.lastValue != value : String(this.lastValue) != String(value)) {
3715
+ this.callback(this.element, value);
3716
+ this.lastValue = value;
3717
+ }
3718
+ }
3719
+ });
3720
+
3721
+ Form.Element.Observer = Class.create(Abstract.TimedObserver, {
3722
+ getValue: function() {
3723
+ return Form.Element.getValue(this.element);
3724
+ }
3725
+ });
3726
+
3727
+ Form.Observer = Class.create(Abstract.TimedObserver, {
3728
+ getValue: function() {
3729
+ return Form.serialize(this.element);
3730
+ }
3731
+ });
3732
+
3733
+ /*--------------------------------------------------------------------------*/
3734
+
3735
+ Abstract.EventObserver = Class.create({
3736
+ initialize: function(element, callback) {
3737
+ this.element = $(element);
3738
+ this.callback = callback;
3739
+
3740
+ this.lastValue = this.getValue();
3741
+ if (this.element.tagName.toLowerCase() == 'form')
3742
+ this.registerFormCallbacks();
3743
+ else
3744
+ this.registerCallback(this.element);
3745
+ },
3746
+
3747
+ onElementEvent: function() {
3748
+ var value = this.getValue();
3749
+ if (this.lastValue != value) {
3750
+ this.callback(this.element, value);
3751
+ this.lastValue = value;
3752
+ }
3753
+ },
3754
+
3755
+ registerFormCallbacks: function() {
3756
+ Form.getElements(this.element).each(this.registerCallback, this);
3757
+ },
3758
+
3759
+ registerCallback: function(element) {
3760
+ if (element.type) {
3761
+ switch (element.type.toLowerCase()) {
3762
+ case 'checkbox':
3763
+ case 'radio':
3764
+ Event.observe(element, 'click', this.onElementEvent.bind(this));
3765
+ break;
3766
+ default:
3767
+ Event.observe(element, 'change', this.onElementEvent.bind(this));
3768
+ break;
3769
+ }
3770
+ }
3771
+ }
3772
+ });
3773
+
3774
+ Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
3775
+ getValue: function() {
3776
+ return Form.Element.getValue(this.element);
3777
+ }
3778
+ });
3779
+
3780
+ Form.EventObserver = Class.create(Abstract.EventObserver, {
3781
+ getValue: function() {
3782
+ return Form.serialize(this.element);
3783
+ }
3784
+ });
3785
+ if (!window.Event) var Event = { };
3786
+
3787
+ Object.extend(Event, {
3788
+ KEY_BACKSPACE: 8,
3789
+ KEY_TAB: 9,
3790
+ KEY_RETURN: 13,
3791
+ KEY_ESC: 27,
3792
+ KEY_LEFT: 37,
3793
+ KEY_UP: 38,
3794
+ KEY_RIGHT: 39,
3795
+ KEY_DOWN: 40,
3796
+ KEY_DELETE: 46,
3797
+ KEY_HOME: 36,
3798
+ KEY_END: 35,
3799
+ KEY_PAGEUP: 33,
3800
+ KEY_PAGEDOWN: 34,
3801
+ KEY_INSERT: 45,
3802
+
3803
+ cache: { },
3804
+
3805
+ relatedTarget: function(event) {
3806
+ var element;
3807
+ switch(event.type) {
3808
+ case 'mouseover': element = event.fromElement; break;
3809
+ case 'mouseout': element = event.toElement; break;
3810
+ default: return null;
3811
+ }
3812
+ return Element.extend(element);
3813
+ }
3814
+ });
3815
+
3816
+ Event.Methods = (function() {
3817
+ var isButton;
3818
+
3819
+ if (Prototype.Browser.IE) {
3820
+ var buttonMap = { 0: 1, 1: 4, 2: 2 };
3821
+ isButton = function(event, code) {
3822
+ return event.button == buttonMap[code];
3823
+ };
3824
+
3825
+ } else if (Prototype.Browser.WebKit) {
3826
+ isButton = function(event, code) {
3827
+ switch (code) {
3828
+ case 0: return event.which == 1 && !event.metaKey;
3829
+ case 1: return event.which == 1 && event.metaKey;
3830
+ default: return false;
3831
+ }
3832
+ };
3833
+
3834
+ } else {
3835
+ isButton = function(event, code) {
3836
+ return event.which ? (event.which === code + 1) : (event.button === code);
3837
+ };
3838
+ }
3839
+
3840
+ return {
3841
+ isLeftClick: function(event) { return isButton(event, 0) },
3842
+ isMiddleClick: function(event) { return isButton(event, 1) },
3843
+ isRightClick: function(event) { return isButton(event, 2) },
3844
+
3845
+ element: function(event) {
3846
+ event = Event.extend(event);
3847
+
3848
+ var node = event.target,
3849
+ type = event.type,
3850
+ currentTarget = event.currentTarget;
3851
+
3852
+ if (currentTarget && currentTarget.tagName) {
3853
+ // Firefox screws up the "click" event when moving between radio buttons
3854
+ // via arrow keys. It also screws up the "load" and "error" events on images,
3855
+ // reporting the document as the target instead of the original image.
3856
+ if (type === 'load' || type === 'error' ||
3857
+ (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
3858
+ && currentTarget.type === 'radio'))
3859
+ node = currentTarget;
3860
+ }
3861
+ if (node.nodeType == Node.TEXT_NODE) node = node.parentNode;
3862
+ return Element.extend(node);
3863
+ },
3864
+
3865
+ findElement: function(event, expression) {
3866
+ var element = Event.element(event);
3867
+ if (!expression) return element;
3868
+ var elements = [element].concat(element.ancestors());
3869
+ return Selector.findElement(elements, expression, 0);
3870
+ },
3871
+
3872
+ pointer: function(event) {
3873
+ var docElement = document.documentElement,
3874
+ body = document.body || { scrollLeft: 0, scrollTop: 0 };
3875
+ return {
3876
+ x: event.pageX || (event.clientX +
3877
+ (docElement.scrollLeft || body.scrollLeft) -
3878
+ (docElement.clientLeft || 0)),
3879
+ y: event.pageY || (event.clientY +
3880
+ (docElement.scrollTop || body.scrollTop) -
3881
+ (docElement.clientTop || 0))
3882
+ };
3883
+ },
3884
+
3885
+ pointerX: function(event) { return Event.pointer(event).x },
3886
+ pointerY: function(event) { return Event.pointer(event).y },
3887
+
3888
+ stop: function(event) {
3889
+ Event.extend(event);
3890
+ event.preventDefault();
3891
+ event.stopPropagation();
3892
+ event.stopped = true;
3893
+ }
3894
+ };
3895
+ })();
3896
+
3897
+ Event.extend = (function() {
3898
+ var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
3899
+ m[name] = Event.Methods[name].methodize();
3900
+ return m;
3901
+ });
3902
+
3903
+ if (Prototype.Browser.IE) {
3904
+ Object.extend(methods, {
3905
+ stopPropagation: function() { this.cancelBubble = true },
3906
+ preventDefault: function() { this.returnValue = false },
3907
+ inspect: function() { return "[object Event]" }
3908
+ });
3909
+
3910
+ return function(event) {
3911
+ if (!event) return false;
3912
+ if (event._extendedByPrototype) return event;
3913
+
3914
+ event._extendedByPrototype = Prototype.emptyFunction;
3915
+ var pointer = Event.pointer(event);
3916
+ Object.extend(event, {
3917
+ target: event.srcElement,
3918
+ relatedTarget: Event.relatedTarget(event),
3919
+ pageX: pointer.x,
3920
+ pageY: pointer.y
3921
+ });
3922
+ return Object.extend(event, methods);
3923
+ };
3924
+
3925
+ } else {
3926
+ Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__'];
3927
+ Object.extend(Event.prototype, methods);
3928
+ return Prototype.K;
3929
+ }
3930
+ })();
3931
+
3932
+ Object.extend(Event, (function() {
3933
+ var cache = Event.cache;
3934
+
3935
+ function getEventID(element) {
3936
+ if (element._prototypeEventID) return element._prototypeEventID[0];
3937
+ arguments.callee.id = arguments.callee.id || 1;
3938
+ return element._prototypeEventID = [++arguments.callee.id];
3939
+ }
3940
+
3941
+ function getDOMEventName(eventName) {
3942
+ if (eventName && eventName.include(':')) return "dataavailable";
3943
+ return eventName;
3944
+ }
3945
+
3946
+ function getCacheForID(id) {
3947
+ return cache[id] = cache[id] || { };
3948
+ }
3949
+
3950
+ function getWrappersForEventName(id, eventName) {
3951
+ var c = getCacheForID(id);
3952
+ return c[eventName] = c[eventName] || [];
3953
+ }
3954
+
3955
+ function createWrapper(element, eventName, handler) {
3956
+ var id = getEventID(element);
3957
+ var c = getWrappersForEventName(id, eventName);
3958
+ if (c.pluck("handler").include(handler)) return false;
3959
+
3960
+ var wrapper = function(event) {
3961
+ if (!Event || !Event.extend ||
3962
+ (event.eventName && event.eventName != eventName))
3963
+ return false;
3964
+
3965
+ Event.extend(event);
3966
+ handler.call(element, event);
3967
+ };
3968
+
3969
+ wrapper.handler = handler;
3970
+ c.push(wrapper);
3971
+ return wrapper;
3972
+ }
3973
+
3974
+ function findWrapper(id, eventName, handler) {
3975
+ var c = getWrappersForEventName(id, eventName);
3976
+ return c.find(function(wrapper) { return wrapper.handler == handler });
3977
+ }
3978
+
3979
+ function destroyWrapper(id, eventName, handler) {
3980
+ var c = getCacheForID(id);
3981
+ if (!c[eventName]) return false;
3982
+ c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
3983
+ }
3984
+
3985
+ function destroyCache() {
3986
+ for (var id in cache)
3987
+ for (var eventName in cache[id])
3988
+ cache[id][eventName] = null;
3989
+ }
3990
+
3991
+
3992
+ // Internet Explorer needs to remove event handlers on page unload
3993
+ // in order to avoid memory leaks.
3994
+ if (window.attachEvent) {
3995
+ window.attachEvent("onunload", destroyCache);
3996
+ }
3997
+
3998
+ // Safari has a dummy event handler on page unload so that it won't
3999
+ // use its bfcache. Safari <= 3.1 has an issue with restoring the "document"
4000
+ // object when page is returned to via the back button using its bfcache.
4001
+ if (Prototype.Browser.WebKit) {
4002
+ window.addEventListener('unload', Prototype.emptyFunction, false);
4003
+ }
4004
+
4005
+ return {
4006
+ observe: function(element, eventName, handler) {
4007
+ element = $(element);
4008
+ var name = getDOMEventName(eventName);
4009
+
4010
+ var wrapper = createWrapper(element, eventName, handler);
4011
+ if (!wrapper) return element;
4012
+
4013
+ if (element.addEventListener) {
4014
+ element.addEventListener(name, wrapper, false);
4015
+ } else {
4016
+ element.attachEvent("on" + name, wrapper);
4017
+ }
4018
+
4019
+ return element;
4020
+ },
4021
+
4022
+ stopObserving: function(element, eventName, handler) {
4023
+ element = $(element);
4024
+ var id = getEventID(element), name = getDOMEventName(eventName);
4025
+
4026
+ if (!handler && eventName) {
4027
+ getWrappersForEventName(id, eventName).each(function(wrapper) {
4028
+ element.stopObserving(eventName, wrapper.handler);
4029
+ });
4030
+ return element;
4031
+
4032
+ } else if (!eventName) {
4033
+ Object.keys(getCacheForID(id)).each(function(eventName) {
4034
+ element.stopObserving(eventName);
4035
+ });
4036
+ return element;
4037
+ }
4038
+
4039
+ var wrapper = findWrapper(id, eventName, handler);
4040
+ if (!wrapper) return element;
4041
+
4042
+ if (element.removeEventListener) {
4043
+ element.removeEventListener(name, wrapper, false);
4044
+ } else {
4045
+ element.detachEvent("on" + name, wrapper);
4046
+ }
4047
+
4048
+ destroyWrapper(id, eventName, handler);
4049
+
4050
+ return element;
4051
+ },
4052
+
4053
+ fire: function(element, eventName, memo) {
4054
+ element = $(element);
4055
+ if (element == document && document.createEvent && !element.dispatchEvent)
4056
+ element = document.documentElement;
4057
+
4058
+ var event;
4059
+ if (document.createEvent) {
4060
+ event = document.createEvent("HTMLEvents");
4061
+ event.initEvent("dataavailable", true, true);
4062
+ } else {
4063
+ event = document.createEventObject();
4064
+ event.eventType = "ondataavailable";
4065
+ }
4066
+
4067
+ event.eventName = eventName;
4068
+ event.memo = memo || { };
4069
+
4070
+ if (document.createEvent) {
4071
+ element.dispatchEvent(event);
4072
+ } else {
4073
+ element.fireEvent(event.eventType, event);
4074
+ }
4075
+
4076
+ return Event.extend(event);
4077
+ }
4078
+ };
4079
+ })());
4080
+
4081
+ Object.extend(Event, Event.Methods);
4082
+
4083
+ Element.addMethods({
4084
+ fire: Event.fire,
4085
+ observe: Event.observe,
4086
+ stopObserving: Event.stopObserving
4087
+ });
4088
+
4089
+ Object.extend(document, {
4090
+ fire: Element.Methods.fire.methodize(),
4091
+ observe: Element.Methods.observe.methodize(),
4092
+ stopObserving: Element.Methods.stopObserving.methodize(),
4093
+ loaded: false
4094
+ });
4095
+
4096
+ (function() {
4097
+ /* Support for the DOMContentLoaded event is based on work by Dan Webb,
4098
+ Matthias Miller, Dean Edwards and John Resig. */
4099
+
4100
+ var timer;
4101
+
4102
+ function fireContentLoadedEvent() {
4103
+ if (document.loaded) return;
4104
+ if (timer) window.clearInterval(timer);
4105
+ document.fire("dom:loaded");
4106
+ document.loaded = true;
4107
+ }
4108
+
4109
+ if (document.addEventListener) {
4110
+ if (Prototype.Browser.WebKit) {
4111
+ timer = window.setInterval(function() {
4112
+ if (/loaded|complete/.test(document.readyState))
4113
+ fireContentLoadedEvent();
4114
+ }, 0);
4115
+
4116
+ Event.observe(window, "load", fireContentLoadedEvent);
4117
+
4118
+ } else {
4119
+ document.addEventListener("DOMContentLoaded",
4120
+ fireContentLoadedEvent, false);
4121
+ }
4122
+
4123
+ } else {
4124
+ document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
4125
+ $("__onDOMContentLoaded").onreadystatechange = function() {
4126
+ if (this.readyState == "complete") {
4127
+ this.onreadystatechange = null;
4128
+ fireContentLoadedEvent();
4129
+ }
4130
+ };
4131
+ }
4132
+ })();
4133
+ /*------------------------------- DEPRECATED -------------------------------*/
4134
+
4135
+ Hash.toQueryString = Object.toQueryString;
4136
+
4137
+ var Toggle = { display: Element.toggle };
4138
+
4139
+ Element.Methods.childOf = Element.Methods.descendantOf;
4140
+
4141
+ var Insertion = {
4142
+ Before: function(element, content) {
4143
+ return Element.insert(element, {before:content});
4144
+ },
4145
+
4146
+ Top: function(element, content) {
4147
+ return Element.insert(element, {top:content});
4148
+ },
4149
+
4150
+ Bottom: function(element, content) {
4151
+ return Element.insert(element, {bottom:content});
4152
+ },
4153
+
4154
+ After: function(element, content) {
4155
+ return Element.insert(element, {after:content});
4156
+ }
4157
+ };
4158
+
4159
+ var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
4160
+
4161
+ // This should be moved to script.aculo.us; notice the deprecated methods
4162
+ // further below, that map to the newer Element methods.
4163
+ var Position = {
4164
+ // set to true if needed, warning: firefox performance problems
4165
+ // NOT neeeded for page scrolling, only if draggable contained in
4166
+ // scrollable elements
4167
+ includeScrollOffsets: false,
4168
+
4169
+ // must be called before calling withinIncludingScrolloffset, every time the
4170
+ // page is scrolled
4171
+ prepare: function() {
4172
+ this.deltaX = window.pageXOffset
4173
+ || document.documentElement.scrollLeft
4174
+ || document.body.scrollLeft
4175
+ || 0;
4176
+ this.deltaY = window.pageYOffset
4177
+ || document.documentElement.scrollTop
4178
+ || document.body.scrollTop
4179
+ || 0;
4180
+ },
4181
+
4182
+ // caches x/y coordinate pair to use with overlap
4183
+ within: function(element, x, y) {
4184
+ if (this.includeScrollOffsets)
4185
+ return this.withinIncludingScrolloffsets(element, x, y);
4186
+ this.xcomp = x;
4187
+ this.ycomp = y;
4188
+ this.offset = Element.cumulativeOffset(element);
4189
+
4190
+ return (y >= this.offset[1] &&
4191
+ y < this.offset[1] + element.offsetHeight &&
4192
+ x >= this.offset[0] &&
4193
+ x < this.offset[0] + element.offsetWidth);
4194
+ },
4195
+
4196
+ withinIncludingScrolloffsets: function(element, x, y) {
4197
+ var offsetcache = Element.cumulativeScrollOffset(element);
4198
+
4199
+ this.xcomp = x + offsetcache[0] - this.deltaX;
4200
+ this.ycomp = y + offsetcache[1] - this.deltaY;
4201
+ this.offset = Element.cumulativeOffset(element);
4202
+
4203
+ return (this.ycomp >= this.offset[1] &&
4204
+ this.ycomp < this.offset[1] + element.offsetHeight &&
4205
+ this.xcomp >= this.offset[0] &&
4206
+ this.xcomp < this.offset[0] + element.offsetWidth);
4207
+ },
4208
+
4209
+ // within must be called directly before
4210
+ overlap: function(mode, element) {
4211
+ if (!mode) return 0;
4212
+ if (mode == 'vertical')
4213
+ return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
4214
+ element.offsetHeight;
4215
+ if (mode == 'horizontal')
4216
+ return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
4217
+ element.offsetWidth;
4218
+ },
4219
+
4220
+ // Deprecation layer -- use newer Element methods now (1.5.2).
4221
+
4222
+ cumulativeOffset: Element.Methods.cumulativeOffset,
4223
+
4224
+ positionedOffset: Element.Methods.positionedOffset,
4225
+
4226
+ absolutize: function(element) {
4227
+ Position.prepare();
4228
+ return Element.absolutize(element);
4229
+ },
4230
+
4231
+ relativize: function(element) {
4232
+ Position.prepare();
4233
+ return Element.relativize(element);
4234
+ },
4235
+
4236
+ realOffset: Element.Methods.cumulativeScrollOffset,
4237
+
4238
+ offsetParent: Element.Methods.getOffsetParent,
4239
+
4240
+ page: Element.Methods.viewportOffset,
4241
+
4242
+ clone: function(source, target, options) {
4243
+ options = options || { };
4244
+ return Element.clonePosition(target, source, options);
4245
+ }
4246
+ };
4247
+
4248
+ /*--------------------------------------------------------------------------*/
4249
+
4250
+ if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
4251
+ function iter(name) {
4252
+ return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
4253
+ }
4254
+
4255
+ instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
4256
+ function(element, className) {
4257
+ className = className.toString().strip();
4258
+ var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
4259
+ return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
4260
+ } : function(element, className) {
4261
+ className = className.toString().strip();
4262
+ var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
4263
+ if (!classNames && !className) return elements;
4264
+
4265
+ var nodes = $(element).getElementsByTagName('*');
4266
+ className = ' ' + className + ' ';
4267
+
4268
+ for (var i = 0, child, cn; child = nodes[i]; i++) {
4269
+ if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
4270
+ (classNames && classNames.all(function(name) {
4271
+ return !name.toString().blank() && cn.include(' ' + name + ' ');
4272
+ }))))
4273
+ elements.push(Element.extend(child));
4274
+ }
4275
+ return elements;
4276
+ };
4277
+
4278
+ return function(className, parentElement) {
4279
+ return $(parentElement || document.body).getElementsByClassName(className);
4280
+ };
4281
+ }(Element.Methods);
4282
+
4283
+ /*--------------------------------------------------------------------------*/
4284
+
4285
+ Element.ClassNames = Class.create();
4286
+ Element.ClassNames.prototype = {
4287
+ initialize: function(element) {
4288
+ this.element = $(element);
4289
+ },
4290
+
4291
+ _each: function(iterator) {
4292
+ this.element.className.split(/\s+/).select(function(name) {
4293
+ return name.length > 0;
4294
+ })._each(iterator);
4295
+ },
4296
+
4297
+ set: function(className) {
4298
+ this.element.className = className;
4299
+ },
4300
+
4301
+ add: function(classNameToAdd) {
4302
+ if (this.include(classNameToAdd)) return;
4303
+ this.set($A(this).concat(classNameToAdd).join(' '));
4304
+ },
4305
+
4306
+ remove: function(classNameToRemove) {
4307
+ if (!this.include(classNameToRemove)) return;
4308
+ this.set($A(this).without(classNameToRemove).join(' '));
4309
+ },
4310
+
4311
+ toString: function() {
4312
+ return $A(this).join(' ');
4313
+ }
4314
+ };
4315
+
4316
+ Object.extend(Element.ClassNames.prototype, Enumerable);
4317
+
4318
+ /*--------------------------------------------------------------------------*/
4319
+
4320
+ Element.addMethods();
includes/js/prototype-1.6.0.3.js.gz ADDED
Binary file
includes/js/prototype-1.6.0.3.min.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ /* Prototype JavaScript framework, version 1.6.0.3
2
+ * (c) 2005-2008 Sam Stephenson
3
+ *
4
+ * Prototype is freely distributable under the terms of an MIT-style license.
5
+ * For details, see the Prototype web site: http://www.prototypejs.org/
6
+ *
7
+ *--------------------------------------------------------------------------*/
8
+
9
+ var Prototype={Version:"1.6.0.3",Browser:{IE:!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1),Opera:navigator.userAgent.indexOf("Opera")>-1,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div")["__proto__"]&&document.createElement("div")["__proto__"]!==document.createElement("form")["__proto__"]},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(a){return a}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false}var Class={create:function(){var e=null,d=$A(arguments);if(Object.isFunction(d[0])){e=d.shift()}function a(){this.initialize.apply(this,arguments)}Object.extend(a,Class.Methods);a.superclass=e;a.subclasses=[];if(e){var b=function(){};b.prototype=e.prototype;a.prototype=new b;e.subclasses.push(a)}for(var c=0;c<d.length;c++){a.addMethods(d[c])}if(!a.prototype.initialize){a.prototype.initialize=Prototype.emptyFunction}a.prototype.constructor=a;return a}};Class.Methods={addMethods:function(g){var c=this.superclass&&this.superclass.prototype;var b=Object.keys(g);if(!Object.keys({toString:true}).length){b.push("toString","valueOf")}for(var a=0,d=b.length;a<d;a++){var f=b[a],e=g[f];if(c&&Object.isFunction(e)&&e.argumentNames().first()=="$super"){var h=e;e=(function(i){return function(){return c[i].apply(this,arguments)}})(f).wrap(h);e.valueOf=h.valueOf.bind(h);e.toString=h.toString.bind(h)}this.prototype[f]=e}return this}};var Abstract={};Object.extend=function(a,c){for(var b in c){a[b]=c[b]}return a};Object.extend(Object,{inspect:function(a){try{if(Object.isUndefined(a)){return"undefined"}if(a===null){return"null"}return a.inspect?a.inspect():String(a)}catch(b){if(b instanceof RangeError){return"..."}throw b}},toJSON:function(a){var c=typeof a;switch(c){case"undefined":case"function":case"unknown":return;case"boolean":return a.toString()}if(a===null){return"null"}if(a.toJSON){return a.toJSON()}if(Object.isElement(a)){return}var b=[];for(var e in a){var d=Object.toJSON(a[e]);if(!Object.isUndefined(d)){b.push(e.toJSON()+": "+d)}}return"{"+b.join(", ")+"}"},toQueryString:function(a){return $H(a).toQueryString()},toHTML:function(a){return a&&a.toHTML?a.toHTML():String.interpret(a)},keys:function(a){var b=[];for(var c in a){b.push(c)}return b},values:function(b){var a=[];for(var c in b){a.push(b[c])}return a},clone:function(a){return Object.extend({},a)},isElement:function(a){return !!(a&&a.nodeType==1)},isArray:function(a){return a!=null&&typeof a=="object"&&"splice" in a&&"join" in a},isHash:function(a){return a instanceof Hash},isFunction:function(a){return typeof a=="function"},isString:function(a){return typeof a=="string"},isNumber:function(a){return typeof a=="number"},isUndefined:function(a){return typeof a=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var a=this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1].replace(/\s+/g,"").split(",");return a.length==1&&!a[0]?[]:a},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var a=this,c=$A(arguments),b=c.shift();return function(){return a.apply(b,c.concat($A(arguments)))}},bindAsEventListener:function(){var a=this,c=$A(arguments),b=c.shift();return function(d){return a.apply(b,[d||window.event].concat(c))}},curry:function(){if(!arguments.length){return this}var a=this,b=$A(arguments);return function(){return a.apply(this,b.concat($A(arguments)))}},delay:function(){var a=this,b=$A(arguments),c=b.shift()*1000;return window.setTimeout(function(){return a.apply(a,b)},c)},defer:function(){var a=[0.01].concat($A(arguments));return this.delay.apply(this,a)},wrap:function(b){var a=this;return function(){return b.apply(this,[a.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized){return this._methodized}var a=this;return this._methodized=function(){return a.apply(null,[this].concat($A(arguments)))}}});Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+'Z"'};var Try={these:function(){var c;for(var b=0,d=arguments.length;b<d;b++){var a=arguments[b];try{c=a();break}catch(f){}}return c}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(b,a){this.callback=b;this.frequency=a;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer){return}clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute()}finally{this.currentlyExecuting=false}}}});Object.extend(String,{interpret:function(a){return a==null?"":String(a)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(e,c){var a="",d=this,b;c=arguments.callee.prepareReplacement(c);while(d.length>0){if(b=d.match(e)){a+=d.slice(0,b.index);a+=String.interpret(c(b));d=d.slice(b.index+b[0].length)}else{a+=d,d=""}}return a},sub:function(c,a,b){a=this.gsub.prepareReplacement(a);b=Object.isUndefined(b)?1:b;return this.gsub(c,function(d){if(--b<0){return d[0]}return a(d)})},scan:function(b,a){this.gsub(b,a);return String(this)},truncate:function(b,a){b=b||30;a=Object.isUndefined(a)?"...":a;return this.length>b?this.slice(0,b-a.length)+a:String(this)},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")},extractScripts:function(){var b=new RegExp(Prototype.ScriptFragment,"img");var a=new RegExp(Prototype.ScriptFragment,"im");return(this.match(b)||[]).map(function(c){return(c.match(a)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.innerHTML},unescapeHTML:function(){var a=new Element("div");a.innerHTML=this.stripTags();return a.childNodes[0]?(a.childNodes.length>1?$A(a.childNodes).inject("",function(b,c){return b+c.nodeValue}):a.childNodes[0].nodeValue):""},toQueryParams:function(b){var a=this.strip().match(/([^?#]*)(#.*)?$/);if(!a){return{}}return a[1].split(b||"&").inject({},function(e,f){if((f=f.split("="))[0]){var c=decodeURIComponent(f.shift());var d=f.length>1?f.join("="):f[0];if(d!=undefined){d=decodeURIComponent(d)}if(c in e){if(!Object.isArray(e[c])){e[c]=[e[c]]}e[c].push(d)}else{e[c]=d}}return e})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){return a<1?"":new Array(a+1).join(this)},camelize:function(){var d=this.split("-"),a=d.length;if(a==1){return d[0]}var c=this.charAt(0)=="-"?d[0].charAt(0).toUpperCase()+d[0].substring(1):d[0];for(var b=1;b<a;b++){c+=d[b].charAt(0).toUpperCase()+d[b].substring(1)}return c},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase()},dasherize:function(){return this.gsub(/_/,"-")},inspect:function(b){var a=this.gsub(/[\x00-\x1f\\]/,function(c){var d=String.specialChar[c[0]];return d?d:"\\u00"+c[0].charCodeAt().toPaddedString(2,16)});if(b){return'"'+a.replace(/"/g,'\\"')+'"'}return"'"+a.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,"#{1}")},isJSON:function(){var a=this;if(a.blank()){return false}a=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(a)},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())},include:function(a){return this.indexOf(a)>-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var b=this.length-a.length;return b>=0&&this.lastIndexOf(a)===b},empty:function(){return this==""},blank:function(){return/^\s*$/.test(this)},interpolate:function(a,b){return new Template(this,b).evaluate(a)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(){return this.stripTags().replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}})}String.prototype.gsub.prepareReplacement=function(b){if(Object.isFunction(b)){return b}var a=new Template(b);return function(c){return a.evaluate(c)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(a){if(Object.isFunction(a.toTemplateReplacements)){a=a.toTemplateReplacements()}return this.template.gsub(this.pattern,function(d){if(a==null){return""}var f=d[1]||"";if(f=="\\"){return d[2]}var b=a,g=d[3];var e=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;d=e.exec(g);if(d==null){return f}while(d!=null){var c=d[1].startsWith("[")?d[2].gsub("\\\\]","]"):d[1];b=b[c];if(null==b||""==d[3]){break}g=g.substring("["==d[3]?d[1].length:d[0].length);d=e.exec(g)}return f+String.interpret(b)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(c,b){var a=0;try{this._each(function(e){c.call(b,e,a++)})}catch(d){if(d!=$break){throw d}}return this},eachSlice:function(d,c,b){var a=-d,e=[],f=this.toArray();if(d<1){return f}while((a+=d)<f.length){e.push(f.slice(a,a+d))}return e.collect(c,b)},all:function(c,b){c=c||Prototype.K;var a=true;this.each(function(e,d){a=a&&!!c.call(b,e,d);if(!a){throw $break}});return a},any:function(c,b){c=c||Prototype.K;var a=false;this.each(function(e,d){if(a=!!c.call(b,e,d)){throw $break}});return a},collect:function(c,b){c=c||Prototype.K;var a=[];this.each(function(e,d){a.push(c.call(b,e,d))});return a},detect:function(c,b){var a;this.each(function(e,d){if(c.call(b,e,d)){a=e;throw $break}});return a},findAll:function(c,b){var a=[];this.each(function(e,d){if(c.call(b,e,d)){a.push(e)}});return a},grep:function(d,c,b){c=c||Prototype.K;var a=[];if(Object.isString(d)){d=new RegExp(d)}this.each(function(f,e){if(d.match(f)){a.push(c.call(b,f,e))}});return a},include:function(a){if(Object.isFunction(this.indexOf)){if(this.indexOf(a)!=-1){return true}}var b=false;this.each(function(c){if(c==a){b=true;throw $break}});return b},inGroupsOf:function(b,a){a=Object.isUndefined(a)?null:a;return this.eachSlice(b,function(c){while(c.length<b){c.push(a)}return c})},inject:function(a,c,b){this.each(function(e,d){a=c.call(b,a,e,d)});return a},invoke:function(b){var a=$A(arguments).slice(1);return this.map(function(c){return c[b].apply(c,a)})},max:function(c,b){c=c||Prototype.K;var a;this.each(function(e,d){e=c.call(b,e,d);if(a==null||e>=a){a=e}});return a},min:function(c,b){c=c||Prototype.K;var a;this.each(function(e,d){e=c.call(b,e,d);if(a==null||e<a){a=e}});return a},partition:function(d,b){d=d||Prototype.K;var c=[],a=[];this.each(function(f,e){(d.call(b,f,e)?c:a).push(f)});return[c,a]},pluck:function(b){var a=[];this.each(function(c){a.push(c[b])});return a},reject:function(c,b){var a=[];this.each(function(e,d){if(!c.call(b,e,d)){a.push(e)}});return a},sortBy:function(b,a){return this.map(function(d,c){return{value:d,criteria:b.call(a,d,c)}}).sort(function(f,e){var d=f.criteria,c=e.criteria;return d<c?-1:d>c?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var b=Prototype.K,a=$A(arguments);if(Object.isFunction(a.last())){b=a.pop()}var c=[this].concat(a).map($A);return this.map(function(e,d){return b(c.pluck(d))})},size:function(){return this.toArray().length},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">"}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(c){if(!c){return[]}if(c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}if(Prototype.Browser.WebKit){$A=function(c){if(!c){return[]}if(!(typeof c==="function"&&typeof c.length==="number"&&typeof c.item==="function")&&c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(b){for(var a=0,c=this.length;a<c;a++){b(this[a])}},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(a){return a!=null})},flatten:function(){return this.inject([],function(b,a){return b.concat(Object.isArray(a)?a.flatten():[a])})},without:function(){var a=$A(arguments);return this.select(function(b){return !a.include(b)})},reverse:function(a){return(a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(a){return this.inject([],function(d,c,b){if(0==b||(a?d.last()!=c:!d.include(c))){d.push(c)}return d})},intersect:function(a){return this.uniq().findAll(function(b){return a.detect(function(c){return b===c})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return"["+this.map(Object.inspect).join(", ")+"]"},toJSON:function(){var a=[];this.each(function(b){var c=Object.toJSON(b);if(!Object.isUndefined(c)){a.push(c)}});return"["+a.join(", ")+"]"}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c,a){a||(a=0);var b=this.length;if(a<0){a=b+a}for(;a<b;a++){if(this[a]===c){return a}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(b,a){a=isNaN(a)?this.length:(a<0?this.length+a:a)+1;var c=this.slice(0,a).reverse().indexOf(b);return(c<0)?c:a-c-1}}Array.prototype.toArray=Array.prototype.clone;function $w(a){if(!Object.isString(a)){return[]}a=a.strip();return a?a.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var e=[];for(var b=0,c=this.length;b<c;b++){e.push(this[b])}for(var b=0,c=arguments.length;b<c;b++){if(Object.isArray(arguments[b])){for(var a=0,d=arguments[b].length;a<d;a++){e.push(arguments[b][a])}}else{e.push(arguments[b])}}return e}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(b,a){$R(0,this,true).each(b,a);return this},toPaddedString:function(c,b){var a=this.toString(b||10);return"0".times(c-a.length)+a},toJSON:function(){return isFinite(this)?this.toString():"null"}});$w("abs round ceil floor").each(function(a){Number.prototype[a]=Math[a].methodize()});function $H(a){return new Hash(a)}var Hash=Class.create(Enumerable,(function(){function a(b,c){if(Object.isUndefined(c)){return b}return b+"="+encodeURIComponent(String.interpret(c))}return{initialize:function(b){this._object=Object.isHash(b)?b.toObject():Object.clone(b)},_each:function(c){for(var b in this._object){var d=this._object[b],e=[b,d];e.key=b;e.value=d;c(e)}},set:function(b,c){return this._object[b]=c},get:function(b){if(this._object[b]!==Object.prototype[b]){return this._object[b]}},unset:function(b){var c=this._object[b];delete this._object[b];return c},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},index:function(c){var b=this.detect(function(d){return d.value===c});return b&&b.key},merge:function(b){return this.clone().update(b)},update:function(b){return new Hash(b).inject(this,function(c,d){c.set(d.key,d.value);return c})},toQueryString:function(){return this.inject([],function(d,e){var c=encodeURIComponent(e.key),b=e.value;if(b&&typeof b=="object"){if(Object.isArray(b)){return d.concat(b.map(a.curry(c)))}}else{d.push(a(c,b))}return d}).join("&")},inspect:function(){return"#<Hash:{"+this.map(function(b){return b.map(Object.inspect).join(": ")}).join(", ")+"}>"},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(c,a,b){this.start=c;this.end=a;this.exclusive=b},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start){return false}if(this.exclusive){return a<this.end}return a<=this.end}});var $R=function(c,a,b){return new ObjectRange(c,a,b)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(a){this.responders._each(a)},register:function(a){if(!this.include(a)){this.responders.push(a)}},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(d,b,c,a){this.each(function(f){if(Object.isFunction(f[d])){try{f[d].apply(f,[b,c,a])}catch(g){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(a){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,a||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams()}else{if(Object.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,b,a){$super(a);this.transport=Ajax.getTransport();this.request(b)},request:function(b){this.url=b;this.method=this.options.method;var d=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){d._method=this.method;this.method="post"}this.parameters=d;if(d=Object.toQueryString(d)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+d}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){d+="&_="}}}try{var a=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(a)}Ajax.Responders.dispatch("onCreate",this,a);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1)}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||d):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(c){this.dispatchException(c)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var e={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){e["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){e.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var c=this.options.requestHeaders;if(Object.isFunction(c.push)){for(var b=0,d=c.length;b<d;b+=2){e[c[b]]=c[b+1]}}else{$H(c).each(function(f){e[f.key]=f.value})}}for(var a in e){this.transport.setRequestHeader(a,e[a])}},success:function(){var a=this.getStatus();return !a||(a>=200&&a<300)},getStatus:function(){try{return this.transport.status||0}catch(a){return 0}},respondToReadyState:function(a){var c=Ajax.Request.Events[a],b=new Ajax.Response(this);if(c=="Complete"){try{this._complete=true;(this.options["on"+b.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(b,b.headerJSON)}catch(d){this.dispatchException(d)}var f=b.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&f&&f.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+c]||Prototype.emptyFunction)(b,b.headerJSON);Ajax.Responders.dispatch("on"+c,this,b,b.headerJSON)}catch(d){this.dispatchException(d)}if(c=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var a=this.url.match(/^\s*https?:\/\/[^\/]*/);return !a||(a[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(a){try{return this.transport.getResponseHeader(a)||null}catch(b){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch("onException",this,a)}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(c){this.request=c;var d=this.transport=c.transport,a=this.readyState=d.readyState;if((a>2&&!Prototype.Browser.IE)||a==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(d.responseText);this.headerJSON=this._getHeaderJSON()}if(a==4){var b=d.responseXML;this.responseXML=Object.isUndefined(b)?null:b;this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(a){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(a){return null}},getResponseHeader:function(a){return this.transport.getResponseHeader(a)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var a=this.getHeader("X-JSON");if(!a){return null}a=decodeURIComponent(escape(a));try{return a.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}},_getResponseJSON:function(){var a=this.request.options;if(!a.evalJSON||(a.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,a,c,b){this.container={success:(a.success||a),failure:(a.failure||(a.success?null:a))};b=Object.clone(b);var d=b.onComplete;b.onComplete=(function(e,f){this.updateContent(e.responseText);if(Object.isFunction(d)){d(e,f)}}).bind(this);$super(c,b)},updateContent:function(d){var c=this.container[this.success()?"success":"failure"],a=this.options;if(!a.evalScripts){d=d.stripScripts()}if(c=$(c)){if(a.insertion){if(Object.isString(a.insertion)){var b={};b[a.insertion]=d;c.insert(b)}else{a.insertion(c,d)}}else{c.update(d)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,a,c,b){$super(b);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=a;this.url=c;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(b){if(arguments.length>1){for(var a=0,d=[],c=arguments.length;a<c;a++){d.push($(arguments[a]))}return d}if(Object.isString(b)){b=document.getElementById(b)}return Element.extend(b)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(f,a){var c=[];var e=document.evaluate(f,$(a)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var b=0,d=e.snapshotLength;b<d;b++){c.push(Element.extend(e.snapshotItem(b)))}return c}}if(!window.Node){var Node={}}if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(){var a=this.Element;this.Element=function(d,c){c=c||{};d=d.toLowerCase();var b=Element.cache;if(Prototype.Browser.IE&&c.name){d="<"+d+' name="'+c.name+'">';delete c.name;return Element.writeAttribute(document.createElement(d),c)}if(!b[d]){b[d]=Element.extend(document.createElement(d))}return Element.writeAttribute(b[d].cloneNode(false),c)};Object.extend(this.Element,a||{});if(a){this.Element.prototype=a.prototype}}).call(window);Element.cache={};Element.Methods={visible:function(a){return $(a).style.display!="none"},toggle:function(a){a=$(a);Element[Element.visible(a)?"hide":"show"](a);return a},hide:function(a){a=$(a);a.style.display="none";return a},show:function(a){a=$(a);a.style.display="";return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){a=$(a);if(b&&b.toElement){b=b.toElement()}if(Object.isElement(b)){return a.update().insert(b)}b=Object.toHTML(b);a.innerHTML=b.stripScripts();b.evalScripts.bind(b).defer();return a},replace:function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}else{if(!Object.isElement(c)){c=Object.toHTML(c);var a=b.ownerDocument.createRange();a.selectNode(b);c.evalScripts.bind(c).defer();c=a.createContextualFragment(c.stripScripts())}}b.parentNode.replaceChild(c,b);return b},insert:function(c,e){c=$(c);if(Object.isString(e)||Object.isNumber(e)||Object.isElement(e)||(e&&(e.toElement||e.toHTML))){e={bottom:e}}var d,f,b,g;for(var a in e){d=e[a];a=a.toLowerCase();f=Element._insertionTranslations[a];if(d&&d.toElement){d=d.toElement()}if(Object.isElement(d)){f(c,d);continue}d=Object.toHTML(d);b=((a=="before"||a=="after")?c.parentNode:c).tagName.toUpperCase();g=Element._getContentFromAnonymousElement(b,d.stripScripts());if(a=="top"||a=="after"){g.reverse()}g.each(f.curry(c));d.evalScripts.bind(d).defer()}return c},wrap:function(b,c,a){b=$(b);if(Object.isElement(c)){$(c).writeAttribute(a||{})}else{if(Object.isString(c)){c=new Element(c,a)}else{c=new Element("div",c)}}if(b.parentNode){b.parentNode.replaceChild(c,b)}c.appendChild(b);return c},inspect:function(b){b=$(b);var a="<"+b.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(f){var e=f.first(),c=f.last();var d=(b[e]||"").toString();if(d){a+=" "+c+"="+d.inspect(true)}});return a+">"},recursivelyCollect:function(a,c){a=$(a);var b=[];while(a=a[c]){if(a.nodeType==1){b.push(Element.extend(a))}}return b},ancestors:function(a){return $(a).recursivelyCollect("parentNode")},descendants:function(a){return $(a).select("*")},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1){a=a.nextSibling}return $(a)},immediateDescendants:function(a){if(!(a=$(a).firstChild)){return[]}while(a&&a.nodeType!=1){a=a.nextSibling}if(a){return[a].concat($(a).nextSiblings())}return[]},previousSiblings:function(a){return $(a).recursivelyCollect("previousSibling")},nextSiblings:function(a){return $(a).recursivelyCollect("nextSibling")},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(b,a){if(Object.isString(a)){a=new Selector(a)}return a.match($(b))},up:function(b,d,a){b=$(b);if(arguments.length==1){return $(b.parentNode)}var c=b.ancestors();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},down:function(b,c,a){b=$(b);if(arguments.length==1){return b.firstDescendant()}return Object.isNumber(c)?b.descendants()[c]:Element.select(b,c)[a||0]},previous:function(b,d,a){b=$(b);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(b))}var c=b.previousSiblings();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},next:function(c,d,b){c=$(c);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(c))}var a=c.nextSiblings();return Object.isNumber(d)?a[d]:Selector.findElement(a,d,b)},select:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b,a)},adjacent:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b.parentNode,a).without(b)},identify:function(b){b=$(b);var c=b.readAttribute("id"),a=arguments.callee;if(c){return c}do{c="anonymous_element_"+a.counter++}while($(c));b.writeAttribute("id",c);return c},readAttribute:function(c,a){c=$(c);if(Prototype.Browser.IE){var b=Element._attributeTranslations.read;if(b.values[a]){return b.values[a](c,a)}if(b.names[a]){a=b.names[a]}if(a.include(":")){return(!c.attributes||!c.attributes[a])?null:c.attributes[a].value}}return c.getAttribute(a)},writeAttribute:function(e,c,f){e=$(e);var b={},d=Element._attributeTranslations.write;if(typeof c=="object"){b=c}else{b[c]=Object.isUndefined(f)?true:f}for(var a in b){c=d.names[a]||a;f=b[a];if(d.values[a]){c=d.values[a](e,f)}if(f===false||f===null){e.removeAttribute(c)}else{if(f===true){e.setAttribute(c,c)}else{e.setAttribute(c,f)}}}return e},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a))){return}var c=a.className;return(c.length>0&&(c==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))},addClassName:function(a,b){if(!(a=$(a))){return}if(!a.hasClassName(b)){a.className+=(a.className?" ":"")+b}return a},removeClassName:function(a,b){if(!(a=$(a))){return}a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," ").strip();return a},toggleClassName:function(a,b){if(!(a=$(a))){return}return a[a.hasClassName(b)?"removeClassName":"addClassName"](b)},cleanWhitespace:function(b){b=$(b);var c=b.firstChild;while(c){var a=c.nextSibling;if(c.nodeType==3&&!/\S/.test(c.nodeValue)){b.removeChild(c)}c=a}return b},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(b,a){b=$(b),a=$(a);if(b.compareDocumentPosition){return(b.compareDocumentPosition(a)&8)===8}if(a.contains){return a.contains(b)&&a!==b}while(b=b.parentNode){if(b==a){return true}}return false},scrollTo:function(a){a=$(a);var b=a.cumulativeOffset();window.scrollTo(b[0],b[1]);return a},getStyle:function(b,c){b=$(b);c=c=="float"?"cssFloat":c.camelize();var d=b.style[c];if(!d||d=="auto"){var a=document.defaultView.getComputedStyle(b,null);d=a?a[c]:null}if(c=="opacity"){return d?parseFloat(d):1}return d=="auto"?null:d},getOpacity:function(a){return $(a).getStyle("opacity")},setStyle:function(b,c){b=$(b);var e=b.style,a;if(Object.isString(c)){b.style.cssText+=";"+c;return c.include("opacity")?b.setOpacity(c.match(/opacity:\s*(\d?\.?\d*)/)[1]):b}for(var d in c){if(d=="opacity"){b.setOpacity(c[d])}else{e[(d=="float"||d=="cssFloat")?(Object.isUndefined(e.styleFloat)?"cssFloat":"styleFloat"):d]=c[d]}}return b},setOpacity:function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;return a},getDimensions:function(c){c=$(c);var g=c.getStyle("display");if(g!="none"&&g!=null){return{width:c.offsetWidth,height:c.offsetHeight}}var b=c.style;var f=b.visibility;var d=b.position;var a=b.display;b.visibility="hidden";b.position="absolute";b.display="block";var h=c.clientWidth;var e=c.clientHeight;b.display=a;b.position=d;b.visibility=f;return{width:h,height:e}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,"position");if(b=="static"||!b){a._madePositioned=true;a.style.position="relative";if(Prototype.Browser.Opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=""}return a},makeClipping:function(a){a=$(a);if(a._overflow){return a}a._overflow=Element.getStyle(a,"overflow")||"auto";if(a._overflow!=="hidden"){a.style.overflow="hidden"}return a},undoClipping:function(a){a=$(a);if(!a._overflow){return a}a.style.overflow=a._overflow=="auto"?"":a._overflow;a._overflow=null;return a},cumulativeOffset:function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;b=b.offsetParent}while(b);return Element._returnOffset(c,a)},positionedOffset:function(b){var a=0,d=0;do{a+=b.offsetTop||0;d+=b.offsetLeft||0;b=b.offsetParent;if(b){if(b.tagName.toUpperCase()=="BODY"){break}var c=Element.getStyle(b,"position");if(c!=="static"){break}}}while(b);return Element._returnOffset(d,a)},absolutize:function(b){b=$(b);if(b.getStyle("position")=="absolute"){return b}var d=b.positionedOffset();var f=d[1];var e=d[0];var c=b.clientWidth;var a=b.clientHeight;b._originalLeft=e-parseFloat(b.style.left||0);b._originalTop=f-parseFloat(b.style.top||0);b._originalWidth=b.style.width;b._originalHeight=b.style.height;b.style.position="absolute";b.style.top=f+"px";b.style.left=e+"px";b.style.width=c+"px";b.style.height=a+"px";return b},relativize:function(a){a=$(a);if(a.getStyle("position")=="relative"){return a}a.style.position="relative";var c=parseFloat(a.style.top||0)-(a._originalTop||0);var b=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=c+"px";a.style.left=b+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth;return a},cumulativeScrollOffset:function(b){var a=0,c=0;do{a+=b.scrollTop||0;c+=b.scrollLeft||0;b=b.parentNode}while(b);return Element._returnOffset(c,a)},getOffsetParent:function(a){if(a.offsetParent){return $(a.offsetParent)}if(a==document.body){return $(a)}while((a=a.parentNode)&&a!=document.body){if(Element.getStyle(a,"position")!="static"){return $(a)}}return $(document.body)},viewportOffset:function(d){var a=0,c=0;var b=d;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body&&Element.getStyle(b,"position")=="absolute"){break}}while(b=b.offsetParent);b=d;do{if(!Prototype.Browser.Opera||(b.tagName&&(b.tagName.toUpperCase()=="BODY"))){a-=b.scrollTop||0;c-=b.scrollLeft||0}}while(b=b.parentNode);return Element._returnOffset(c,a)},clonePosition:function(b,d){var a=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});d=$(d);var e=d.viewportOffset();b=$(b);var f=[0,0];var c=null;if(Element.getStyle(b,"position")=="absolute"){c=b.getOffsetParent();f=c.viewportOffset()}if(c==document.body){f[0]-=document.body.offsetLeft;f[1]-=document.body.offsetTop}if(a.setLeft){b.style.left=(e[0]-f[0]+a.offsetLeft)+"px"}if(a.setTop){b.style.top=(e[1]-f[1]+a.offsetTop)+"px"}if(a.setWidth){b.style.width=d.offsetWidth+"px"}if(a.setHeight){b.style.height=d.offsetHeight+"px"}return b}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(d,b,c){switch(c){case"left":case"top":case"right":case"bottom":if(d(b,"position")==="static"){return null}case"height":case"width":if(!Element.visible(b)){return null}var e=parseInt(d(b,c),10);if(e!==b["offset"+c.capitalize()]){return e+"px"}var a;if(c==="height"){a=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{a=["border-left-width","padding-left","padding-right","border-right-width"]}return a.inject(e,function(f,g){var h=d(b,g);return h===null?f:f-parseInt(h,10)})+"px";default:return d(b,c)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(c,a,b){if(b==="title"){return a.title}return c(a,b)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(c,b){b=$(b);try{b.offsetParent}catch(f){return $(document.body)}var a=b.getStyle("position");if(a!=="static"){return c(b)}b.setStyle({position:"relative"});var d=c(b);b.setStyle({position:a});return d});$w("positionedOffset viewportOffset").each(function(a){Element.Methods[a]=Element.Methods[a].wrap(function(f,c){c=$(c);try{c.offsetParent}catch(h){return Element._returnOffset(0,0)}var b=c.getStyle("position");if(b!=="static"){return f(c)}var d=c.getOffsetParent();if(d&&d.getStyle("position")==="fixed"){d.setStyle({zoom:1})}c.setStyle({position:"relative"});var g=f(c);c.setStyle({position:b});return g})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(b,a){try{a.offsetParent}catch(c){return Element._returnOffset(0,0)}return b(a)});Element.Methods.getStyle=function(a,b){a=$(a);b=(b=="float"||b=="cssFloat")?"styleFloat":b.camelize();var c=a.style[b];if(!c&&a.currentStyle){c=a.currentStyle[b]}if(b=="opacity"){if(c=(a.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(c[1]){return parseFloat(c[1])/100}}return 1}if(c=="auto"){if((b=="width"||b=="height")&&(a.getStyle("display")!="none")){return a["offset"+b.capitalize()]+"px"}return null}return c};Element.Methods.setOpacity=function(b,e){function f(g){return g.replace(/alpha\([^\)]*\)/gi,"")}b=$(b);var a=b.currentStyle;if((a&&!a.hasLayout)||(!a&&b.style.zoom=="normal")){b.style.zoom=1}var d=b.getStyle("filter"),c=b.style;if(e==1||e===""){(d=f(d))?c.filter=d:c.removeAttribute("filter");return b}else{if(e<0.00001){e=0}}c.filter=f(d)+"alpha(opacity="+(e*100)+")";return b};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(a,b){return a.getAttribute(b,2)},_getAttrNode:function(a,c){var b=a.getAttributeNode(c);return b?b.value:""},_getEv:function(a,b){b=a.getAttribute(b);return b?b.toString().slice(23,-2):null},_flag:function(a,b){return $(a).hasAttribute(b)?b:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(a){return a.title}}}};Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(a,b){a.checked=!!b},style:function(a,b){a.style.cssText=b?b:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").each(function(a){Element._attributeTranslations.write.names[a.toLowerCase()]=a;Element._attributeTranslations.has[a.toLowerCase()]=a});(function(a){Object.extend(a,{href:a._getAttr,src:a._getAttr,type:a._getAttr,action:a._getAttrNode,disabled:a._flag,checked:a._flag,readonly:a._flag,multiple:a._flag,onload:a._getEv,onunload:a._getEv,onclick:a._getEv,ondblclick:a._getEv,onmousedown:a._getEv,onmouseup:a._getEv,onmouseover:a._getEv,onmousemove:a._getEv,onmouseout:a._getEv,onfocus:a._getEv,onblur:a._getEv,onkeypress:a._getEv,onkeydown:a._getEv,onkeyup:a._getEv,onsubmit:a._getEv,onreset:a._getEv,onselect:a._getEv,onchange:a._getEv})})(Element._attributeTranslations.read.values)}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1)?0.999999:(b==="")?"":(b<0.00001)?0:b;return a}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;if(b==1){if(a.tagName.toUpperCase()=="IMG"&&a.width){a.width++;a.width--}else{try{var d=document.createTextNode(" ");a.appendChild(d);a.removeChild(d)}catch(c){}}}return a};Element.Methods.cumulativeOffset=function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body){if(Element.getStyle(b,"position")=="absolute"){break}}b=b.offsetParent}while(b);return Element._returnOffset(c,a)}}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}if(Object.isElement(c)){return b.update().insert(c)}c=Object.toHTML(c);var a=b.tagName.toUpperCase();if(a in Element._insertionTranslations.tags){$A(b.childNodes).each(function(d){b.removeChild(d)});Element._getContentFromAnonymousElement(a,c.stripScripts()).each(function(d){b.appendChild(d)})}else{b.innerHTML=c.stripScripts()}c.evalScripts.bind(c).defer();return b}}if("outerHTML" in document.createElement("div")){Element.Methods.replace=function(c,e){c=$(c);if(e&&e.toElement){e=e.toElement()}if(Object.isElement(e)){c.parentNode.replaceChild(e,c);return c}e=Object.toHTML(e);var d=c.parentNode,b=d.tagName.toUpperCase();if(Element._insertionTranslations.tags[b]){var f=c.next();var a=Element._getContentFromAnonymousElement(b,e.stripScripts());d.removeChild(c);if(f){a.each(function(g){d.insertBefore(g,f)})}else{a.each(function(g){d.appendChild(g)})}}else{c.outerHTML=e.stripScripts()}e.evalScripts.bind(e).defer();return c}}Element._returnOffset=function(b,c){var a=[b,c];a.left=b;a.top=c;return a};Element._getContentFromAnonymousElement=function(c,b){var d=new Element("div"),a=Element._insertionTranslations.tags[c];if(a){d.innerHTML=a[0]+b+a[1];a[2].times(function(){d=d.firstChild})}else{d.innerHTML=b}return $A(d.childNodes)};Element._insertionTranslations={before:function(a,b){a.parentNode.insertBefore(b,a)},top:function(a,b){a.insertBefore(b,a.firstChild)},bottom:function(a,b){a.appendChild(b)},after:function(a,b){a.parentNode.insertBefore(b,a.nextSibling)},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}};(function(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(a,c){c=Element._attributeTranslations.has[c]||c;var b=$(a).getAttributeNode(c);return !!(b&&b.specified)}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div")["__proto__"]){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div")["__proto__"];Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K}var a={},b=Element.Methods.ByTag;var c=Object.extend(function(f){if(!f||f._extendedByPrototype||f.nodeType!=1||f==window){return f}var d=Object.clone(a),e=f.tagName.toUpperCase(),h,g;if(b[e]){Object.extend(d,b[e])}for(h in d){g=d[h];if(Object.isFunction(g)&&!(h in f)){f[h]=g.methodize()}}f._extendedByPrototype=Prototype.emptyFunction;return f},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(a,Element.Methods);Object.extend(a,Element.Methods.Simulated)}}});c.refresh();return c})();Element.hasAttribute=function(a,b){if(a.hasAttribute){return a.hasAttribute(b)}return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(c){var h=Prototype.BrowserFeatures,d=Element.Methods.ByTag;if(!c){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var b=c;c=arguments[1]}if(!b){Object.extend(Element.Methods,c||{})}else{if(Object.isArray(b)){b.each(g)}else{g(b)}}function g(j){j=j.toUpperCase();if(!Element.Methods.ByTag[j]){Element.Methods.ByTag[j]={}}Object.extend(Element.Methods.ByTag[j],c)}function a(l,k,j){j=j||false;for(var n in l){var m=l[n];if(!Object.isFunction(m)){continue}if(!j||!(n in k)){k[n]=m.methodize()}}}function e(l){var j;var k={OPTGROUP:"OptGroup",TEXTAREA:"TextArea",P:"Paragraph",FIELDSET:"FieldSet",UL:"UList",OL:"OList",DL:"DList",DIR:"Directory",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",Q:"Quote",INS:"Mod",DEL:"Mod",A:"Anchor",IMG:"Image",CAPTION:"TableCaption",COL:"TableCol",COLGROUP:"TableCol",THEAD:"TableSection",TFOOT:"TableSection",TBODY:"TableSection",TR:"TableRow",TH:"TableCell",TD:"TableCell",FRAMESET:"FrameSet",IFRAME:"IFrame"};if(k[l]){j="HTML"+k[l]+"Element"}if(window[j]){return window[j]}j="HTML"+l+"Element";if(window[j]){return window[j]}j="HTML"+l.capitalize()+"Element";if(window[j]){return window[j]}window[j]={};window[j].prototype=document.createElement(l)["__proto__"];return window[j]}if(h.ElementExtensions){a(Element.Methods,HTMLElement.prototype);a(Element.Methods.Simulated,HTMLElement.prototype,true)}if(h.SpecificElementExtensions){for(var i in Element.Methods.ByTag){var f=e(i);if(Object.isUndefined(f)){continue}a(d[i],f.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){var a={},b=Prototype.Browser;$w("width height").each(function(e){var c=e.capitalize();if(b.WebKit&&!document.evaluate){a[e]=self["inner"+c]}else{if(b.Opera&&parseFloat(window.opera.version())<9.5){a[e]=document.body["client"+c]}else{a[e]=document.documentElement["client"+c]}}});return a},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(a){this.expression=a.strip();if(this.shouldUseSelectorsAPI()){this.mode="selectorsAPI"}else{if(this.shouldUseXPath()){this.mode="xpath";this.compileXPathMatcher()}else{this.mode="normal";this.compileMatcher()}}},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath){return false}var a=this.expression;if(Prototype.Browser.WebKit&&(a.include("-of-type")||a.include(":empty"))){return false}if((/(\[[\w-]*?:|:checked)/).test(a)){return false}return true},shouldUseSelectorsAPI:function(){if(!Prototype.BrowserFeatures.SelectorsAPI){return false}if(!Selector._div){Selector._div=new Element("div")}try{Selector._div.querySelector(this.expression)}catch(a){return false}return true},compileMatcher:function(){var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var f=this.expression,g=Selector.patterns,b=Selector.xpath,d,a;if(Selector._cache[f]){this.xpath=Selector._cache[f];return}this.matcher=[".//*"];while(f&&d!=f&&(/\S/).test(f)){d=f;for(var c in g){if(a=f.match(g[c])){this.matcher.push(Object.isFunction(b[c])?b[c](a):new Template(b[c]).evaluate(a));f=f.replace(a[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;var c=this.expression,b;switch(this.mode){case"selectorsAPI":if(a!==document){var d=a.id,f=$(a).identify();c="#"+f+" "+c}b=$A(a.querySelectorAll(c)).map(Element.extend);a.id=d;return b;case"xpath":return document._getElementsByXPath(this.xpath,a);default:return this.matcher(a)}},match:function(j){this.tokens=[];var o=this.expression,a=Selector.patterns,f=Selector.assertions;var b,d,g;while(o&&b!==o&&(/\S/).test(o)){b=o;for(var k in a){d=a[k];if(g=o.match(d)){if(f[k]){this.tokens.push([k,Object.clone(g)]);o=o.replace(g[0],"")}else{return this.findElements(document).include(j)}}}}var n=true,c,l;for(var k=0,h;h=this.tokens[k];k++){c=h[0],l=h[1];if(!Selector.assertions[c](j,l)){n=false;break}}return n},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(a){if(a[1]=="*"){return""}return"[local-name()='"+a[1].toLowerCase()+"' or local-name()='"+a[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(a){a[1]=a[1].toLowerCase();return new Template("[@#{1}]").evaluate(a)},attr:function(a){a[1]=a[1].toLowerCase();a[3]=a[5]||a[6];return new Template(Selector.xpath.operators[a[2]]).evaluate(a)},pseudo:function(a){var b=Selector.xpath.pseudos[a[1]];if(!b){return""}if(Object.isFunction(b)){return b(a)}return new Template(Selector.xpath.pseudos[a[1]]).evaluate(a)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0)]",checked:"[@checked]",disabled:"[(@disabled) and (@type!='hidden')]",enabled:"[not(@disabled) and (@type!='hidden')]",not:function(b){var j=b[6],h=Selector.patterns,a=Selector.xpath,f,c;var g=[];while(j&&f!=j&&(/\S/).test(j)){f=j;for(var d in h){if(b=j.match(h[d])){c=Object.isFunction(a[d])?a[d](b):new Template(a[d]).evaluate(b);g.push("("+c.substring(1,c.length-1)+")");j=j.replace(b[0],"");break}}}return"[not("+g.join(" and ")+")]"},"nth-child":function(a){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",a)},"nth-last-child":function(a){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",a)},"nth-of-type":function(a){return Selector.xpath.pseudos.nth("position() ",a)},"nth-last-of-type":function(a){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",a)},"first-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-of-type"](a)},"last-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](a)},"only-of-type":function(a){var b=Selector.xpath.pseudos;return b["first-of-type"](a)+b["last-of-type"](a)},nth:function(g,e){var h,i=e[6],d;if(i=="even"){i="2n+0"}if(i=="odd"){i="2n+1"}if(h=i.match(/^(\d+)$/)){return"["+g+"= "+h[1]+"]"}if(h=i.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(h[1]=="-"){h[1]=-1}var f=h[1]?Number(h[1]):1;var c=h[2]?Number(h[2]):0;d="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(d).evaluate({fragment:g,a:f,b:c})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c); c = false;',className:'n = h.className(n, r, "#{1}", c); c = false;',id:'n = h.id(n, r, "#{1}", c); c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(a){a[3]=(a[5]||a[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(a)},pseudo:function(a){if(a[6]){a[6]=a[6].replace(/"/g,'\\"')}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(a)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,attrPresence:/^\[((?:[\w]+:)?[\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(a,b){return b[1].toUpperCase()==a.tagName.toUpperCase()},className:function(a,b){return Element.hasClassName(a,b[1])},id:function(a,b){return a.id===b[1]},attrPresence:function(a,b){return Element.hasAttribute(a,b[1])},attr:function(b,c){var a=Element.readAttribute(b,c[1]);return a&&Selector.operators[c[2]](a,c[5]||c[6])}},handlers:{concat:function(d,c){for(var e=0,f;f=c[e];e++){d.push(f)}return d},mark:function(a){var d=Prototype.emptyFunction;for(var b=0,c;c=a[b];b++){c._countedByPrototype=d}return a},unmark:function(a){for(var b=0,c;c=a[b];b++){c._countedByPrototype=undefined}return a},index:function(a,d,g){a._countedByPrototype=Prototype.emptyFunction;if(d){for(var b=a.childNodes,e=b.length-1,c=1;e>=0;e--){var f=b[e];if(f.nodeType==1&&(!g||f._countedByPrototype)){f.nodeIndex=c++}}}else{for(var e=0,c=1,b=a.childNodes;f=b[e];e++){if(f.nodeType==1&&(!g||f._countedByPrototype)){f.nodeIndex=c++}}}},unique:function(b){if(b.length==0){return b}var d=[],e;for(var c=0,a=b.length;c<a;c++){if(!(e=b[c])._countedByPrototype){e._countedByPrototype=Prototype.emptyFunction;d.push(Element.extend(e))}}return Selector.handlers.unmark(d)},descendant:function(a){var d=Selector.handlers;for(var c=0,b=[],e;e=a[c];c++){d.concat(b,e.getElementsByTagName("*"))}return b},child:function(a){var e=Selector.handlers;for(var d=0,c=[],f;f=a[d];d++){for(var b=0,g;g=f.childNodes[b];b++){if(g.nodeType==1&&g.tagName!="!"){c.push(g)}}}return c},adjacent:function(a){for(var c=0,b=[],e;e=a[c];c++){var d=this.nextElementSibling(e);if(d){b.push(d)}}return b},laterSibling:function(a){var d=Selector.handlers;for(var c=0,b=[],e;e=a[c];c++){d.concat(b,Element.nextSiblings(e))}return b},nextElementSibling:function(a){while(a=a.nextSibling){if(a.nodeType==1){return a}}return null},previousElementSibling:function(a){while(a=a.previousSibling){if(a.nodeType==1){return a}}return null},tagName:function(a,j,c,b){var k=c.toUpperCase();var e=[],g=Selector.handlers;if(a){if(b){if(b=="descendant"){for(var f=0,d;d=a[f];f++){g.concat(e,d.getElementsByTagName(c))}return e}else{a=this[b](a)}if(c=="*"){return a}}for(var f=0,d;d=a[f];f++){if(d.tagName.toUpperCase()===k){e.push(d)}}return e}else{return j.getElementsByTagName(c)}},id:function(b,a,j,f){var g=$(j),d=Selector.handlers;if(!g){return[]}if(!b&&a==document){return[g]}if(b){if(f){if(f=="child"){for(var c=0,e;e=b[c];c++){if(g.parentNode==e){return[g]}}}else{if(f=="descendant"){for(var c=0,e;e=b[c];c++){if(Element.descendantOf(g,e)){return[g]}}}else{if(f=="adjacent"){for(var c=0,e;e=b[c];c++){if(Selector.handlers.previousElementSibling(g)==e){return[g]}}}else{b=d[f](b)}}}}for(var c=0,e;e=b[c];c++){if(e==g){return[g]}}return[]}return(g&&Element.descendantOf(g,a))?[g]:[]},className:function(b,a,c,d){if(b&&d){b=this[d](b)}return Selector.handlers.byClassName(b,a,c)},byClassName:function(c,b,f){if(!c){c=Selector.handlers.descendant([b])}var h=" "+f+" ";for(var e=0,d=[],g,a;g=c[e];e++){a=g.className;if(a.length==0){continue}if(a==f||(" "+a+" ").include(h)){d.push(g)}}return d},attrPresence:function(c,b,a,g){if(!c){c=b.getElementsByTagName("*")}if(c&&g){c=this[g](c)}var e=[];for(var d=0,f;f=c[d];d++){if(Element.hasAttribute(f,a)){e.push(f)}}return e},attr:function(a,j,h,k,c,b){if(!a){a=j.getElementsByTagName("*")}if(a&&b){a=this[b](a)}var l=Selector.operators[c],f=[];for(var e=0,d;d=a[e];e++){var g=Element.readAttribute(d,h);if(g===null){continue}if(l(g,k)){f.push(d)}}return f},pseudo:function(b,c,e,a,d){if(b&&d){b=this[d](b)}if(!b){b=a.getElementsByTagName("*")}return Selector.pseudos[c](b,e,a)}},pseudos:{"first-child":function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(Selector.handlers.previousElementSibling(e)){continue}c.push(e)}return c},"last-child":function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(Selector.handlers.nextElementSibling(e)){continue}c.push(e)}return c},"only-child":function(b,g,a){var e=Selector.handlers;for(var d=0,c=[],f;f=b[d];d++){if(!e.previousElementSibling(f)&&!e.nextElementSibling(f)){c.push(f)}}return c},"nth-child":function(b,c,a){return Selector.pseudos.nth(b,c,a)},"nth-last-child":function(b,c,a){return Selector.pseudos.nth(b,c,a,true)},"nth-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,false,true)},"nth-last-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,true,true)},"first-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,false,true)},"last-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,true,true)},"only-of-type":function(b,d,a){var c=Selector.pseudos;return c["last-of-type"](c["first-of-type"](b,d,a),d,a)},getIndices:function(d,c,e){if(d==0){return c>0?[c]:[]}return $R(1,e).inject([],function(a,b){if(0==(b-c)%d&&(b-c)/d>=0){a.push(b)}return a})},nth:function(c,s,u,r,e){if(c.length==0){return[]}if(s=="even"){s="2n+0"}if(s=="odd"){s="2n+1"}var q=Selector.handlers,p=[],d=[],g;q.mark(c);for(var o=0,f;f=c[o];o++){if(!f.parentNode._countedByPrototype){q.index(f.parentNode,r,e);d.push(f.parentNode)}}if(s.match(/^\d+$/)){s=Number(s);for(var o=0,f;f=c[o];o++){if(f.nodeIndex==s){p.push(f)}}}else{if(g=s.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(g[1]=="-"){g[1]=-1}var v=g[1]?Number(g[1]):1;var t=g[2]?Number(g[2]):0;var w=Selector.pseudos.getIndices(v,t,c.length);for(var o=0,f,k=w.length;f=c[o];o++){for(var n=0;n<k;n++){if(f.nodeIndex==w[n]){p.push(f)}}}}}q.unmark(c);q.unmark(d);return p},empty:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.tagName=="!"||e.firstChild){continue}c.push(e)}return c},not:function(a,d,k){var g=Selector.handlers,l,c;var j=new Selector(d).findElements(k);g.mark(j);for(var f=0,e=[],b;b=a[f];f++){if(!b._countedByPrototype){e.push(b)}}g.unmark(j);return e},enabled:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(!e.disabled&&(!e.type||e.type!=="hidden")){c.push(e)}}return c},disabled:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.disabled){c.push(e)}}return c},checked:function(b,f,a){for(var d=0,c=[],e;e=b[d];d++){if(e.checked){c.push(e)}}return c}},operators:{"=":function(b,a){return b==a},"!=":function(b,a){return b!=a},"^=":function(b,a){return b==a||b&&b.startsWith(a)},"$=":function(b,a){return b==a||b&&b.endsWith(a)},"*=":function(b,a){return b==a||b&&b.include(a)},"$=":function(b,a){return b.endsWith(a)},"*=":function(b,a){return b.include(a)},"~=":function(b,a){return(" "+b+" ").include(" "+a+" ")},"|=":function(b,a){return("-"+(b||"").toUpperCase()+"-").include("-"+(a||"").toUpperCase()+"-")}},split:function(b){var a=[];b.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(c){a.push(c[1].strip())});return a},matchElements:function(f,g){var e=$$(g),d=Selector.handlers;d.mark(e);for(var c=0,b=[],a;a=f[c];c++){if(a._countedByPrototype){b.push(a)}}d.unmark(e);return b},findElement:function(b,c,a){if(Object.isNumber(c)){a=c;c=false}return Selector.matchElements(b,c||"*")[a||0]},findChildElements:function(e,g){g=Selector.split(g.join(","));var d=[],f=Selector.handlers;for(var c=0,b=g.length,a;c<b;c++){a=new Selector(g[c].strip());f.concat(d,a.findElements(e))}return(b>1)?f.unique(d):d}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(d,c){for(var e=0,f;f=c[e];e++){if(f.tagName!=="!"){d.push(f)}}return d},unmark:function(a){for(var b=0,c;c=a[b];b++){c.removeAttribute("_countedByPrototype")}return a}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(g,b){if(typeof b!="object"){b={hash:!!b}}else{if(Object.isUndefined(b.hash)){b.hash=true}}var c,f,a=false,e=b.submit;var d=g.inject({},function(h,i){if(!i.disabled&&i.name){c=i.name;f=$(i).getValue();if(f!=null&&i.type!="file"&&(i.type!="submit"||(!a&&e!==false&&(!e||c==e)&&(a=true)))){if(c in h){if(!Object.isArray(h[c])){h[c]=[h[c]]}h[c].push(f)}else{h[c]=f}}}return h});return b.hash?d:Object.toQueryString(d)}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(a){return $A($(a).getElementsByTagName("*")).inject([],function(b,c){if(Form.Element.Serializers[c.tagName.toLowerCase()]){b.push(Element.extend(c))}return b})},getInputs:function(g,c,d){g=$(g);var a=g.getElementsByTagName("input");if(!c&&!d){return $A(a).map(Element.extend)}for(var e=0,h=[],f=a.length;e<f;e++){var b=a[e];if((c&&b.type!=c)||(d&&b.name!=d)){continue}h.push(Element.extend(b))}return h},disable:function(a){a=$(a);Form.getElements(a).invoke("disable");return a},enable:function(a){a=$(a);Form.getElements(a).invoke("enable");return a},findFirstElement:function(b){var c=$(b).getElements().findAll(function(d){return"hidden"!=d.type&&!d.disabled});var a=c.findAll(function(d){return d.hasAttribute("tabIndex")&&d.tabIndex>=0}).sortBy(function(d){return d.tabIndex}).first();return a?a:c.find(function(d){return["input","select","textarea"].include(d.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(b,a){b=$(b),a=Object.clone(a||{});var d=a.parameters,c=b.readAttribute("action")||"";if(c.blank()){c=window.location.href}a.parameters=b.serialize(true);if(d){if(Object.isString(d)){d=d.toQueryParams()}Object.extend(a.parameters,d)}if(b.hasAttribute("method")&&!a.method){a.method=b.method}return new Ajax.Request(c,a)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Object.toQueryString(c)}}return""},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},setValue:function(a,b){a=$(a);var c=a.tagName.toLowerCase();Form.Element.Serializers[c](a,b);return a},clear:function(a){$(a).value="";return a},present:function(a){return $(a).value!=""},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(a.type))){a.select()}}catch(b){}return a},disable:function(a){a=$(a);a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(a,b){switch(a.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(a,b);default:return Form.Element.Serializers.textarea(a,b)}},inputSelector:function(a,b){if(Object.isUndefined(b)){return a.checked?a.value:null}else{a.checked=!!b}},textarea:function(a,b){if(Object.isUndefined(b)){return a.value}else{a.value=b}},select:function(c,f){if(Object.isUndefined(f)){return this[c.type=="select-one"?"selectOne":"selectMany"](c)}else{var b,d,g=!Object.isArray(f);for(var a=0,e=c.length;a<e;a++){b=c.options[a];d=this.optionValue(b);if(g){if(d==f){b.selected=true;return}}else{b.selected=f.include(d)}}}},selectOne:function(b){var a=b.selectedIndex;return a>=0?this.optionValue(b.options[a]):null},selectMany:function(d){var a,e=d.length;if(!e){return null}for(var c=0,a=[];c<e;c++){var b=d.options[c];if(b.selected){a.push(this.optionValue(b))}}return a},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,a,b,c){$super(c,b);this.element=$(a);this.lastValue=this.getValue()},execute:function(){var a=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(a)?this.lastValue!=a:String(this.lastValue)!=String(a)){this.callback(this.element,a);this.lastValue=a}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=Class.create({initialize:function(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(a){if(a.type){switch(a.type.toLowerCase()){case"checkbox":case"radio":Event.observe(a,"click",this.onElementEvent.bind(this));break;default:Event.observe(a,"change",this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});if(!window.Event){var Event={}}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(b){var a;switch(b.type){case"mouseover":a=b.fromElement;break;case"mouseout":a=b.toElement;break;default:return null}return Element.extend(a)}});Event.Methods=(function(){var a;if(Prototype.Browser.IE){var b={0:1,1:4,2:2};a=function(d,c){return d.button==b[c]}}else{if(Prototype.Browser.WebKit){a=function(d,c){switch(c){case 0:return d.which==1&&!d.metaKey;case 1:return d.which==1&&d.metaKey;default:return false}}}else{a=function(d,c){return d.which?(d.which===c+1):(d.button===c)}}}return{isLeftClick:function(c){return a(c,0)},isMiddleClick:function(c){return a(c,1)},isRightClick:function(c){return a(c,2)},element:function(e){e=Event.extend(e);var d=e.target,c=e.type,f=e.currentTarget;if(f&&f.tagName){if(c==="load"||c==="error"||(c==="click"&&f.tagName.toLowerCase()==="input"&&f.type==="radio")){d=f}}if(d.nodeType==Node.TEXT_NODE){d=d.parentNode}return Element.extend(d)},findElement:function(d,f){var c=Event.element(d);if(!f){return c}var e=[c].concat(c.ancestors());return Selector.findElement(e,f,0)},pointer:function(e){var d=document.documentElement,c=document.body||{scrollLeft:0,scrollTop:0};return{x:e.pageX||(e.clientX+(d.scrollLeft||c.scrollLeft)-(d.clientLeft||0)),y:e.pageY||(e.clientY+(d.scrollTop||c.scrollTop)-(d.clientTop||0))}},pointerX:function(c){return Event.pointer(c).x},pointerY:function(c){return Event.pointer(c).y},stop:function(c){Event.extend(c);c.preventDefault();c.stopPropagation();c.stopped=true}}})();Event.extend=(function(){var a=Object.keys(Event.Methods).inject({},function(b,c){b[c]=Event.Methods[c].methodize();return b});if(Prototype.Browser.IE){Object.extend(a,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(b){if(!b){return false}if(b._extendedByPrototype){return b}b._extendedByPrototype=Prototype.emptyFunction;var c=Event.pointer(b);Object.extend(b,{target:b.srcElement,relatedTarget:Event.relatedTarget(b),pageX:c.x,pageY:c.y});return Object.extend(b,a)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents")["__proto__"];Object.extend(Event.prototype,a);return Prototype.K}})();Object.extend(Event,(function(){var b=Event.cache;function c(j){if(j._prototypeEventID){return j._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return j._prototypeEventID=[++arguments.callee.id]}function g(j){if(j&&j.include(":")){return"dataavailable"}return j}function a(j){return b[j]=b[j]||{}}function f(l,j){var k=a(l);return k[j]=k[j]||[]}function h(k,j,l){var o=c(k);var n=f(o,j);if(n.pluck("handler").include(l)){return false}var m=function(p){if(!Event||!Event.extend||(p.eventName&&p.eventName!=j)){return false}Event.extend(p);l.call(k,p)};m.handler=l;n.push(m);return m}function i(m,j,k){var l=f(m,j);return l.find(function(n){return n.handler==k})}function d(m,j,k){var l=a(m);if(!l[j]){return false}l[j]=l[j].without(i(m,j,k))}function e(){for(var k in b){for(var j in b[k]){b[k][j]=null}}}if(window.attachEvent){window.attachEvent("onunload",e)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}return{observe:function(l,j,m){l=$(l);var k=g(j);var n=h(l,j,m);if(!n){return l}if(l.addEventListener){l.addEventListener(k,n,false)}else{l.attachEvent("on"+k,n)}return l},stopObserving:function(l,j,m){l=$(l);var o=c(l),k=g(j);if(!m&&j){f(o,j).each(function(p){l.stopObserving(j,p.handler)});return l}else{if(!j){Object.keys(a(o)).each(function(p){l.stopObserving(p)});return l}}var n=i(o,j,m);if(!n){return l}if(l.removeEventListener){l.removeEventListener(k,n,false)}else{l.detachEvent("on"+k,n)}d(o,j,m);return l},fire:function(l,k,j){l=$(l);if(l==document&&document.createEvent&&!l.dispatchEvent){l=document.documentElement}var m;if(document.createEvent){m=document.createEvent("HTMLEvents");m.initEvent("dataavailable",true,true)}else{m=document.createEventObject();m.eventType="ondataavailable"}m.eventName=k;m.memo=j||{};if(document.createEvent){l.dispatchEvent(m)}else{l.fireEvent(m.eventType,m)}return Event.extend(m)}}})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize(),loaded:false});(function(){var b;function a(){if(document.loaded){return}if(b){window.clearInterval(b)}document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){b=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){a()}},0);Event.observe(window,"load",a)}else{document.addEventListener("DOMContentLoaded",a,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;a()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(a,b){return Element.insert(a,{before:b})},Top:function(a,b){return Element.insert(a,{top:b})},Bottom:function(a,b){return Element.insert(a,{bottom:b})},After:function(a,b){return Element.insert(a,{after:b})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(b,a,c){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(b,a,c)}this.xcomp=a;this.ycomp=c;this.offset=Element.cumulativeOffset(b);return(c>=this.offset[1]&&c<this.offset[1]+b.offsetHeight&&a>=this.offset[0]&&a<this.offset[0]+b.offsetWidth)},withinIncludingScrolloffsets:function(b,a,d){var c=Element.cumulativeScrollOffset(b);this.xcomp=a+c[0]-this.deltaX;this.ycomp=d+c[1]-this.deltaY;this.offset=Element.cumulativeOffset(b);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+b.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+b.offsetWidth)},overlap:function(b,a){if(!b){return 0}if(b=="vertical"){return((this.offset[1]+a.offsetHeight)-this.ycomp)/a.offsetHeight}if(b=="horizontal"){return((this.offset[0]+a.offsetWidth)-this.xcomp)/a.offsetWidth}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(a){Position.prepare();return Element.absolutize(a)},relativize:function(a){Position.prepare();return Element.relativize(a)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(b,c,a){a=a||{};return Element.clonePosition(c,b,a)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(b){function a(c){return c.blank()?null:"[contains(concat(' ', @class, ' '), ' "+c+" ')]"}b.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(c,e){e=e.toString().strip();var d=/\s/.test(e)?$w(e).map(a).join(""):a(e);return d?document._getElementsByXPath(".//*"+d,c):[]}:function(e,f){f=f.toString().strip();var g=[],h=(/\s/.test(f)?$w(f):null);if(!h&&!f){return g}var c=$(e).getElementsByTagName("*");f=" "+f+" ";for(var d=0,k,j;k=c[d];d++){if(k.className&&(j=" "+k.className+" ")&&(j.include(f)||(h&&h.all(function(i){return !i.toString().blank()&&j.include(" "+i+" ")})))){g.push(Element.extend(k))}}return g};return function(d,c){return $(c||document.body).getElementsByClassName(d)}}(Element.Methods)}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(a){this.element=$(a)},_each:function(a){this.element.className.split(/\s+/).select(function(b){return b.length>0})._each(a)},set:function(a){this.element.className=a},add:function(a){if(this.include(a)){return}this.set($A(this).concat(a).join(" "))},remove:function(a){if(!this.include(a)){return}this.set($A(this).without(a).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();
includes/js/prototype-1.6.0.3.min.js.gz ADDED
Binary file
includes/jsmin-1.1.1.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
4
+ *
5
+ * This is pretty much a direct port of jsmin.c to PHP with just a few
6
+ * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
7
+ * outputs to stdout, this library accepts a string as input and returns another
8
+ * string as output.
9
+ *
10
+ * PHP 5 or higher is required.
11
+ *
12
+ * Permission is hereby granted to use this version of the library under the
13
+ * same terms as jsmin.c, which has the following license:
14
+ *
15
+ * --
16
+ * Copyright (c) 2002 Douglas Crockford (www.crockford.com)
17
+ *
18
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
19
+ * this software and associated documentation files (the "Software"), to deal in
20
+ * the Software without restriction, including without limitation the rights to
21
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
22
+ * of the Software, and to permit persons to whom the Software is furnished to do
23
+ * so, subject to the following conditions:
24
+ *
25
+ * The above copyright notice and this permission notice shall be included in all
26
+ * copies or substantial portions of the Software.
27
+ *
28
+ * The Software shall be used for Good, not Evil.
29
+ *
30
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
+ * SOFTWARE.
37
+ * --
38
+ *
39
+ * @package JSMin
40
+ * @author Ryan Grove <ryan@wonko.com>
41
+ * @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
42
+ * @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
43
+ * @license http://opensource.org/licenses/mit-license.php MIT License
44
+ * @version 1.1.1 (2008-03-02)
45
+ * @link http://code.google.com/p/jsmin-php/
46
+ */
47
+
48
+ class JSMin {
49
+ const ORD_LF = 10;
50
+ const ORD_SPACE = 32;
51
+
52
+ protected $a = '';
53
+ protected $b = '';
54
+ protected $input = '';
55
+ protected $inputIndex = 0;
56
+ protected $inputLength = 0;
57
+ protected $lookAhead = null;
58
+ protected $output = '';
59
+
60
+ // -- Public Static Methods --------------------------------------------------
61
+
62
+ public static function minify($js) {
63
+ $jsmin = new JSMin($js);
64
+ return $jsmin->min();
65
+ }
66
+
67
+ // -- Public Instance Methods ------------------------------------------------
68
+
69
+ public function __construct($input) {
70
+ $this->input = str_replace("\r\n", "\n", $input);
71
+ $this->inputLength = strlen($this->input);
72
+ }
73
+
74
+ // -- Protected Instance Methods ---------------------------------------------
75
+
76
+ protected function action($d) {
77
+ switch($d) {
78
+ case 1:
79
+ $this->output .= $this->a;
80
+
81
+ case 2:
82
+ $this->a = $this->b;
83
+
84
+ if ($this->a === "'" || $this->a === '"') {
85
+ for (;;) {
86
+ $this->output .= $this->a;
87
+ $this->a = $this->get();
88
+
89
+ if ($this->a === $this->b) {
90
+ break;
91
+ }
92
+
93
+ if (ord($this->a) <= self::ORD_LF) {
94
+ throw new JSMinException('Unterminated string literal.');
95
+ }
96
+
97
+ if ($this->a === '\\') {
98
+ $this->output .= $this->a;
99
+ $this->a = $this->get();
100
+ }
101
+ }
102
+ }
103
+
104
+ case 3:
105
+ $this->b = $this->next();
106
+
107
+ if ($this->b === '/' && (
108
+ $this->a === '(' || $this->a === ',' || $this->a === '=' ||
109
+ $this->a === ':' || $this->a === '[' || $this->a === '!' ||
110
+ $this->a === '&' || $this->a === '|' || $this->a === '?')) {
111
+
112
+ $this->output .= $this->a . $this->b;
113
+
114
+ for (;;) {
115
+ $this->a = $this->get();
116
+
117
+ if ($this->a === '/') {
118
+ break;
119
+ } elseif ($this->a === '\\') {
120
+ $this->output .= $this->a;
121
+ $this->a = $this->get();
122
+ } elseif (ord($this->a) <= self::ORD_LF) {
123
+ throw new JSMinException('Unterminated regular expression '.
124
+ 'literal.');
125
+ }
126
+
127
+ $this->output .= $this->a;
128
+ }
129
+
130
+ $this->b = $this->next();
131
+ }
132
+ }
133
+ }
134
+
135
+ protected function get() {
136
+ $c = $this->lookAhead;
137
+ $this->lookAhead = null;
138
+
139
+ if ($c === null) {
140
+ if ($this->inputIndex < $this->inputLength) {
141
+ $c = $this->input[$this->inputIndex];
142
+ $this->inputIndex += 1;
143
+ } else {
144
+ $c = null;
145
+ }
146
+ }
147
+
148
+ if ($c === "\r") {
149
+ return "\n";
150
+ }
151
+
152
+ if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
153
+ return $c;
154
+ }
155
+
156
+ return ' ';
157
+ }
158
+
159
+ protected function isAlphaNum($c) {
160
+ return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
161
+ }
162
+
163
+ protected function min() {
164
+ $this->a = "\n";
165
+ $this->action(3);
166
+
167
+ while ($this->a !== null) {
168
+ switch ($this->a) {
169
+ case ' ':
170
+ if ($this->isAlphaNum($this->b)) {
171
+ $this->action(1);
172
+ } else {
173
+ $this->action(2);
174
+ }
175
+ break;
176
+
177
+ case "\n":
178
+ switch ($this->b) {
179
+ case '{':
180
+ case '[':
181
+ case '(':
182
+ case '+':
183
+ case '-':
184
+ $this->action(1);
185
+ break;
186
+
187
+ case ' ':
188
+ $this->action(3);
189
+ break;
190
+
191
+ default:
192
+ if ($this->isAlphaNum($this->b)) {
193
+ $this->action(1);
194
+ }
195
+ else {
196
+ $this->action(2);
197
+ }
198
+ }
199
+ break;
200
+
201
+ default:
202
+ switch ($this->b) {
203
+ case ' ':
204
+ if ($this->isAlphaNum($this->a)) {
205
+ $this->action(1);
206
+ break;
207
+ }
208
+
209
+ $this->action(3);
210
+ break;
211
+
212
+ case "\n":
213
+ switch ($this->a) {
214
+ case '}':
215
+ case ']':
216
+ case ')':
217
+ case '+':
218
+ case '-':
219
+ case '"':
220
+ case "'":
221
+ $this->action(1);
222
+ break;
223
+
224
+ default:
225
+ if ($this->isAlphaNum($this->a)) {
226
+ $this->action(1);
227
+ }
228
+ else {
229
+ $this->action(3);
230
+ }
231
+ }
232
+ break;
233
+
234
+ default:
235
+ $this->action(1);
236
+ break;
237
+ }
238
+ }
239
+ }
240
+
241
+ return $this->output;
242
+ }
243
+
244
+ protected function next() {
245
+ $c = $this->get();
246
+
247
+ if ($c === '/') {
248
+ switch($this->peek()) {
249
+ case '/':
250
+ for (;;) {
251
+ $c = $this->get();
252
+
253
+ if (ord($c) <= self::ORD_LF) {
254
+ return $c;
255
+ }
256
+ }
257
+
258
+ case '*':
259
+ $this->get();
260
+
261
+ for (;;) {
262
+ switch($this->get()) {
263
+ case '*':
264
+ if ($this->peek() === '/') {
265
+ $this->get();
266
+ return ' ';
267
+ }
268
+ break;
269
+
270
+ case null:
271
+ throw new JSMinException('Unterminated comment.');
272
+ }
273
+ }
274
+
275
+ default:
276
+ return $c;
277
+ }
278
+ }
279
+
280
+ return $c;
281
+ }
282
+
283
+ protected function peek() {
284
+ $this->lookAhead = $this->get();
285
+ return $this->lookAhead;
286
+ }
287
+ }
288
+
289
+ // -- Exceptions ---------------------------------------------------------------
290
+ class JSMinException extends Exception {}
291
+ ?>
includes/simple_html_dom.php ADDED
@@ -0,0 +1,975 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*******************************************************************************
3
+ Version: 1.11 ($Rev: 175 $)
4
+ Website: http://sourceforge.net/projects/simplehtmldom/
5
+ Author: S.C. Chen <me578022@gmail.com>
6
+ Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
7
+ Contributions by:
8
+ Yousuke Kumakura (Attribute filters)
9
+ Vadim Voituk (Negative indexes supports of "find" method)
10
+ Antcs (Constructor with automatically load contents either text or file/url)
11
+ Licensed under The MIT License
12
+ Redistributions of files must retain the above copyright notice.
13
+ *******************************************************************************/
14
+
15
+ define('HDOM_TYPE_ELEMENT', 1);
16
+ define('HDOM_TYPE_COMMENT', 2);
17
+ define('HDOM_TYPE_TEXT', 3);
18
+ define('HDOM_TYPE_ENDTAG', 4);
19
+ define('HDOM_TYPE_ROOT', 5);
20
+ define('HDOM_TYPE_UNKNOWN', 6);
21
+ define('HDOM_QUOTE_DOUBLE', 0);
22
+ define('HDOM_QUOTE_SINGLE', 1);
23
+ define('HDOM_QUOTE_NO', 3);
24
+ define('HDOM_INFO_BEGIN', 0);
25
+ define('HDOM_INFO_END', 1);
26
+ define('HDOM_INFO_QUOTE', 2);
27
+ define('HDOM_INFO_SPACE', 3);
28
+ define('HDOM_INFO_TEXT', 4);
29
+ define('HDOM_INFO_INNER', 5);
30
+ define('HDOM_INFO_OUTER', 6);
31
+ define('HDOM_INFO_ENDSPACE',7);
32
+
33
+ // helper functions
34
+ // -----------------------------------------------------------------------------
35
+ // get html dom form file
36
+ function file_get_html() {
37
+ $dom = new simple_html_dom;
38
+ $args = func_get_args();
39
+ $dom->load(call_user_func_array('file_get_contents', $args), true);
40
+ return $dom;
41
+ }
42
+
43
+ // get html dom form string
44
+ function str_get_html($str, $lowercase=true) {
45
+ $dom = new simple_html_dom;
46
+ $dom->load($str, $lowercase);
47
+ return $dom;
48
+ }
49
+
50
+ // dump html dom tree
51
+ function dump_html_tree($node, $show_attr=true, $deep=0) {
52
+ $lead = str_repeat(' ', $deep);
53
+ echo $lead.$node->tag;
54
+ if ($show_attr && count($node->attr)>0) {
55
+ echo '(';
56
+ foreach($node->attr as $k=>$v)
57
+ echo "[$k]=>\"".$node->$k.'", ';
58
+ echo ')';
59
+ }
60
+ echo "\n";
61
+
62
+ foreach($node->nodes as $c)
63
+ dump_html_tree($c, $show_attr, $deep+1);
64
+ }
65
+
66
+ // get dom form file (deprecated)
67
+ function file_get_dom() {
68
+ $dom = new simple_html_dom;
69
+ $args = func_get_args();
70
+ $dom->load(call_user_func_array('file_get_contents', $args), true);
71
+ return $dom;
72
+ }
73
+
74
+ // get dom form string (deprecated)
75
+ function str_get_dom($str, $lowercase=true) {
76
+ $dom = new simple_html_dom;
77
+ $dom->load($str, $lowercase);
78
+ return $dom;
79
+ }
80
+
81
+ // simple html dom node
82
+ // -----------------------------------------------------------------------------
83
+ class simple_html_dom_node {
84
+ public $nodetype = HDOM_TYPE_TEXT;
85
+ public $tag = 'text';
86
+ public $attr = array();
87
+ public $children = array();
88
+ public $nodes = array();
89
+ public $parent = null;
90
+ public $_ = array();
91
+ private $dom = null;
92
+
93
+ function __construct($dom) {
94
+ $this->dom = $dom;
95
+ $dom->nodes[] = $this;
96
+ }
97
+
98
+ function __destruct() {
99
+ $this->clear();
100
+ }
101
+
102
+ function __toString() {
103
+ return $this->outertext();
104
+ }
105
+
106
+ // clean up memory due to php5 circular references memory leak...
107
+ function clear() {
108
+ $this->dom = null;
109
+ $this->nodes = null;
110
+ $this->parent = null;
111
+ $this->children = null;
112
+ }
113
+
114
+ // dump node's tree
115
+ function dump($show_attr=true) {
116
+ dump_html_tree($this, $show_attr);
117
+ }
118
+
119
+ // returns the parent of node
120
+ function parent() {
121
+ return $this->parent;
122
+ }
123
+
124
+ // returns children of node
125
+ function children($idx=-1) {
126
+ if ($idx===-1) return $this->children;
127
+ if (isset($this->children[$idx])) return $this->children[$idx];
128
+ return null;
129
+ }
130
+
131
+ // returns the first child of node
132
+ function first_child() {
133
+ if (count($this->children)>0) return $this->children[0];
134
+ return null;
135
+ }
136
+
137
+ // returns the last child of node
138
+ function last_child() {
139
+ if (($count=count($this->children))>0) return $this->children[$count-1];
140
+ return null;
141
+ }
142
+
143
+ // returns the next sibling of node
144
+ function next_sibling() {
145
+ if ($this->parent===null) return null;
146
+ $idx = 0;
147
+ $count = count($this->parent->children);
148
+ while ($idx<$count && $this!==$this->parent->children[$idx])
149
+ ++$idx;
150
+ if (++$idx>=$count) return null;
151
+ return $this->parent->children[$idx];
152
+ }
153
+
154
+ // returns the previous sibling of node
155
+ function prev_sibling() {
156
+ if ($this->parent===null) return null;
157
+ $idx = 0;
158
+ $count = count($this->parent->children);
159
+ while ($idx<$count && $this!==$this->parent->children[$idx])
160
+ ++$idx;
161
+ if (--$idx<0) return null;
162
+ return $this->parent->children[$idx];
163
+ }
164
+
165
+ // get dom node's inner html
166
+ function innertext() {
167
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
168
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
169
+
170
+ $ret = '';
171
+ foreach($this->nodes as $n)
172
+ $ret .= $n->outertext();
173
+ return $ret;
174
+ }
175
+
176
+ // get dom node's outer text (with tag)
177
+ function outertext() {
178
+ if ($this->tag==='root') return $this->innertext();
179
+
180
+ // trigger callback
181
+ if ($this->dom->callback!==null)
182
+ call_user_func_array($this->dom->callback, array($this));
183
+
184
+ if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
185
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
186
+
187
+ // render begin tag
188
+ $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
189
+
190
+ // render inner text
191
+ if (isset($this->_[HDOM_INFO_INNER]))
192
+ $ret .= $this->_[HDOM_INFO_INNER];
193
+ else {
194
+ foreach($this->nodes as $n)
195
+ $ret .= $n->outertext();
196
+ }
197
+
198
+ // render end tag
199
+ if(isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
200
+ $ret .= '</'.$this->tag.'>';
201
+ return $ret;
202
+ }
203
+
204
+ // get dom node's plain text
205
+ function text() {
206
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
207
+ switch ($this->nodetype) {
208
+ case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
209
+ case HDOM_TYPE_COMMENT: return '';
210
+ case HDOM_TYPE_UNKNOWN: return '';
211
+ }
212
+ if (strcasecmp($this->tag, 'script')===0) return '';
213
+ if (strcasecmp($this->tag, 'style')===0) return '';
214
+
215
+ $ret = '';
216
+ foreach($this->nodes as $n)
217
+ $ret .= $n->text();
218
+ return $ret;
219
+ }
220
+
221
+ function xmltext() {
222
+ $ret = $this->innertext();
223
+ $ret = str_ireplace('<![CDATA[', '', $ret);
224
+ $ret = str_replace(']]>', '', $ret);
225
+ return $ret;
226
+ }
227
+
228
+ // build node's text with tag
229
+ function makeup() {
230
+ // text, comment, unknown
231
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
232
+
233
+ $ret = '<'.$this->tag;
234
+ $i = -1;
235
+
236
+ foreach($this->attr as $key=>$val) {
237
+ ++$i;
238
+
239
+ // skip removed attribute
240
+ if ($val===null || $val===false)
241
+ continue;
242
+
243
+ $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
244
+ //no value attr: nowrap, checked selected...
245
+ if ($val===true)
246
+ $ret .= $key;
247
+ else {
248
+ switch($this->_[HDOM_INFO_QUOTE][$i]) {
249
+ case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
250
+ case HDOM_QUOTE_SINGLE: $quote = '\''; break;
251
+ default: $quote = '';
252
+ }
253
+ $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
254
+ }
255
+ }
256
+ $ret = $this->dom->restore_noise($ret);
257
+ return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
258
+ }
259
+
260
+ // find elements by css selector
261
+ function find($selector, $idx=null) {
262
+ $selectors = $this->parse_selector($selector);
263
+ if (($count=count($selectors))===0) return array();
264
+ $found_keys = array();
265
+
266
+ // find each selector
267
+ for ($c=0; $c<$count; ++$c) {
268
+ if (($levle=count($selectors[0]))===0) return array();
269
+ if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
270
+
271
+ $head = array($this->_[HDOM_INFO_BEGIN]=>1);
272
+
273
+ // handle descendant selectors, no recursive!
274
+ for ($l=0; $l<$levle; ++$l) {
275
+ $ret = array();
276
+ foreach($head as $k=>$v) {
277
+ $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
278
+ $n->seek($selectors[$c][$l], $ret);
279
+ }
280
+ $head = $ret;
281
+ }
282
+
283
+ foreach($head as $k=>$v) {
284
+ if (!isset($found_keys[$k]))
285
+ $found_keys[$k] = 1;
286
+ }
287
+ }
288
+
289
+ // sort keys
290
+ ksort($found_keys);
291
+
292
+ $found = array();
293
+ foreach($found_keys as $k=>$v)
294
+ $found[] = $this->dom->nodes[$k];
295
+
296
+ // return nth-element or array
297
+ if (is_null($idx)) return $found;
298
+ else if ($idx<0) $idx = count($found) + $idx;
299
+ return (isset($found[$idx])) ? $found[$idx] : null;
300
+ }
301
+
302
+ // seek for given conditions
303
+ protected function seek($selector, &$ret) {
304
+ list($tag, $key, $val, $exp, $no_key) = $selector;
305
+
306
+ // xpath index
307
+ if ($tag && $key && is_numeric($key)) {
308
+ $count = 0;
309
+ foreach ($this->children as $c) {
310
+ if ($tag==='*' || $tag===$c->tag) {
311
+ if (++$count==$key) {
312
+ $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
313
+ return;
314
+ }
315
+ }
316
+ }
317
+ return;
318
+ }
319
+
320
+ $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
321
+ if ($end==0) {
322
+ $parent = $this->parent;
323
+ while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
324
+ $end -= 1;
325
+ $parent = $parent->parent;
326
+ }
327
+ $end += $parent->_[HDOM_INFO_END];
328
+ }
329
+
330
+ for($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
331
+ $node = $this->dom->nodes[$i];
332
+ $pass = true;
333
+
334
+ if ($tag==='*' && !$key) {
335
+ if (in_array($node, $this->children, true))
336
+ $ret[$i] = 1;
337
+ continue;
338
+ }
339
+
340
+ // compare tag
341
+ if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
342
+ // compare key
343
+ if ($pass && $key) {
344
+ if ($no_key) {
345
+ if (isset($node->attr[$key])) $pass=false;
346
+ }
347
+ else if (!isset($node->attr[$key])) $pass=false;
348
+ }
349
+ // compare value
350
+ if ($pass && $key && $val && $val!=='*') {
351
+ $check = $this->match($exp, $val, $node->attr[$key]);
352
+ // handle multiple class
353
+ if (!$check && strcasecmp($key, 'class')===0) {
354
+ foreach(explode(' ',$node->attr[$key]) as $k) {
355
+ $check = $this->match($exp, $val, $k);
356
+ if ($check) break;
357
+ }
358
+ }
359
+ if (!$check) $pass = false;
360
+ }
361
+ if ($pass) $ret[$i] = 1;
362
+ unset($node);
363
+ }
364
+ }
365
+
366
+ protected function match($exp, $pattern, $value) {
367
+ switch ($exp) {
368
+ case '=':
369
+ return ($value===$pattern);
370
+ case '!=':
371
+ return ($value!==$pattern);
372
+ case '^=':
373
+ return preg_match("/^".preg_quote($pattern,'/')."/", $value);
374
+ case '$=':
375
+ return preg_match("/".preg_quote($pattern,'/')."$/", $value);
376
+ case '*=':
377
+ if ($pattern[0]=='/')
378
+ return preg_match($pattern, $value);
379
+ return preg_match("/".$pattern."/i", $value);
380
+ }
381
+ return false;
382
+ }
383
+
384
+ protected function parse_selector($selector_string) {
385
+ // pattern of CSS selectors, modified from mootools
386
+ $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
387
+ preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
388
+ $selectors = array();
389
+ $result = array();
390
+ //print_r($matches);
391
+
392
+ foreach ($matches as $m) {
393
+ $m[0] = trim($m[0]);
394
+ if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
395
+ // for borwser grnreated xpath
396
+ if ($m[1]==='tbody') continue;
397
+
398
+ list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
399
+ if(!empty($m[2])) {$key='id'; $val=$m[2];}
400
+ if(!empty($m[3])) {$key='class'; $val=$m[3];}
401
+ if(!empty($m[4])) {$key=$m[4];}
402
+ if(!empty($m[5])) {$exp=$m[5];}
403
+ if(!empty($m[6])) {$val=$m[6];}
404
+
405
+ // convert to lowercase
406
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
407
+ //elements that do NOT have the specified attribute
408
+ if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
409
+
410
+ $result[] = array($tag, $key, $val, $exp, $no_key);
411
+ if (trim($m[7])===',') {
412
+ $selectors[] = $result;
413
+ $result = array();
414
+ }
415
+ }
416
+ if (count($result)>0)
417
+ $selectors[] = $result;
418
+ return $selectors;
419
+ }
420
+
421
+ function __get($name) {
422
+ if (isset($this->attr[$name])) return $this->attr[$name];
423
+ switch($name) {
424
+ case 'outertext': return $this->outertext();
425
+ case 'innertext': return $this->innertext();
426
+ case 'plaintext': return $this->text();
427
+ case 'xmltext': return $this->xmltext();
428
+ default: return array_key_exists($name, $this->attr);
429
+ }
430
+ }
431
+
432
+ function __set($name, $value) {
433
+ switch($name) {
434
+ case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
435
+ case 'innertext':
436
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
437
+ return $this->_[HDOM_INFO_INNER] = $value;
438
+ }
439
+ if (!isset($this->attr[$name])) {
440
+ $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
441
+ $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
442
+ }
443
+ $this->attr[$name] = $value;
444
+ }
445
+
446
+ function __isset($name) {
447
+ switch($name) {
448
+ case 'outertext': return true;
449
+ case 'innertext': return true;
450
+ case 'plaintext': return true;
451
+ }
452
+ //no value attr: nowrap, checked selected...
453
+ return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
454
+ }
455
+
456
+ function __unset($name) {
457
+ if (isset($this->attr[$name]))
458
+ unset($this->attr[$name]);
459
+ }
460
+
461
+ // camel naming conventions
462
+ function getAllAttributes() {return $this->attr;}
463
+ function getAttribute($name) {return $this->__get($name);}
464
+ function setAttribute($name, $value) {$this->__set($name, $value);}
465
+ function hasAttribute($name) {return $this->__isset($name);}
466
+ function removeAttribute($name) {$this->__set($name, null);}
467
+ function getElementById($id) {return $this->find("#$id", 0);}
468
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
469
+ function getElementByTagName($name) {return $this->find($name, 0);}
470
+ function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
471
+ function parentNode() {return $this->parent();}
472
+ function childNodes($idx=-1) {return $this->children($idx);}
473
+ function firstChild() {return $this->first_child();}
474
+ function lastChild() {return $this->last_child();}
475
+ function nextSibling() {return $this->next_sibling();}
476
+ function previousSibling() {return $this->prev_sibling();}
477
+ }
478
+
479
+ // simple html dom parser
480
+ // -----------------------------------------------------------------------------
481
+ class simple_html_dom {
482
+ public $root = null;
483
+ public $nodes = array();
484
+ public $callback = null;
485
+ public $lowercase = false;
486
+ protected $pos;
487
+ protected $doc;
488
+ protected $char;
489
+ protected $size;
490
+ protected $cursor;
491
+ protected $parent;
492
+ protected $noise = array();
493
+ protected $token_blank = " \t\r\n";
494
+ protected $token_equal = ' =/>';
495
+ protected $token_slash = " />\r\n\t";
496
+ protected $token_attr = ' >';
497
+ // use isset instead of in_array, performance boost about 30%...
498
+ protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
499
+ protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
500
+ protected $optional_closing_tags = array(
501
+ 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
502
+ 'th'=>array('th'=>1),
503
+ 'td'=>array('td'=>1),
504
+ 'li'=>array('li'=>1),
505
+ 'dt'=>array('dt'=>1, 'dd'=>1),
506
+ 'dd'=>array('dd'=>1, 'dt'=>1),
507
+ 'dl'=>array('dd'=>1, 'dt'=>1),
508
+ 'p'=>array('p'=>1),
509
+ 'nobr'=>array('nobr'=>1),
510
+ );
511
+
512
+ function __construct($str=null) {
513
+ if ($str) {
514
+ if (preg_match("/^http:\/\//i",$str) || is_file($str))
515
+ $this->load_file($str);
516
+ else
517
+ $this->load($str);
518
+ }
519
+ }
520
+
521
+ function __destruct() {
522
+ $this->clear();
523
+ }
524
+
525
+ // load html from string
526
+ function load($str, $lowercase=true) {
527
+ // prepare
528
+ $this->prepare($str, $lowercase);
529
+ // strip out comments
530
+ $this->remove_noise("'<!--(.*?)-->'is");
531
+ // strip out cdata
532
+ $this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
533
+ // strip out <style> tags
534
+ $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
535
+ $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
536
+ // strip out <script> tags
537
+ $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
538
+ $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
539
+ // strip out preformatted tags
540
+ $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
541
+ // strip out server side scripts
542
+ $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
543
+ // strip smarty scripts
544
+ $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
545
+
546
+ // parsing
547
+ while ($this->parse());
548
+ // end
549
+ $this->root->_[HDOM_INFO_END] = $this->cursor;
550
+ }
551
+
552
+ // load html from file
553
+ function load_file() {
554
+ $args = func_get_args();
555
+ $this->load(call_user_func_array('file_get_contents', $args), true);
556
+ }
557
+
558
+ // set callback function
559
+ function set_callback($function_name) {
560
+ $this->callback = $function_name;
561
+ }
562
+
563
+ // remove callback function
564
+ function remove_callback() {
565
+ $this->callback = null;
566
+ }
567
+
568
+ // save dom as string
569
+ function save($filepath='') {
570
+ $ret = $this->root->innertext();
571
+ if ($filepath!=='') file_put_contents($filepath, $ret);
572
+ return $ret;
573
+ }
574
+
575
+ // find dom node by css selector
576
+ function find($selector, $idx=null) {
577
+ return $this->root->find($selector, $idx);
578
+ }
579
+
580
+ // clean up memory due to php5 circular references memory leak...
581
+ function clear() {
582
+ foreach($this->nodes as $n) {$n->clear(); $n = null;}
583
+ if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
584
+ if (isset($this->root)) {$this->root->clear(); unset($this->root);}
585
+ unset($this->doc);
586
+ unset($this->noise);
587
+ }
588
+
589
+ function dump($show_attr=true) {
590
+ $this->root->dump($show_attr);
591
+ }
592
+
593
+ // prepare HTML data and init everything
594
+ protected function prepare($str, $lowercase=true) {
595
+ $this->clear();
596
+ $this->doc = $str;
597
+ $this->pos = 0;
598
+ $this->cursor = 1;
599
+ $this->noise = array();
600
+ $this->nodes = array();
601
+ $this->lowercase = $lowercase;
602
+ $this->root = new simple_html_dom_node($this);
603
+ $this->root->tag = 'root';
604
+ $this->root->_[HDOM_INFO_BEGIN] = -1;
605
+ $this->root->nodetype = HDOM_TYPE_ROOT;
606
+ $this->parent = $this->root;
607
+ // set the length of content
608
+ $this->size = strlen($str);
609
+ if ($this->size>0) $this->char = $this->doc[0];
610
+ }
611
+
612
+ // parse html content
613
+ protected function parse() {
614
+ if (($s = $this->copy_until_char('<'))==='')
615
+ return $this->read_tag();
616
+
617
+ // text
618
+ $node = new simple_html_dom_node($this);
619
+ ++$this->cursor;
620
+ $node->_[HDOM_INFO_TEXT] = $s;
621
+ $this->link_nodes($node, false);
622
+ return true;
623
+ }
624
+
625
+ // read tag info
626
+ protected function read_tag() {
627
+ if ($this->char!=='<') {
628
+ $this->root->_[HDOM_INFO_END] = $this->cursor;
629
+ return false;
630
+ }
631
+ $begin_tag_pos = $this->pos;
632
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
633
+
634
+ // end tag
635
+ if ($this->char==='/') {
636
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
637
+ $this->skip($this->token_blank_t);
638
+ $tag = $this->copy_until_char('>');
639
+
640
+ // skip attributes in end tag
641
+ if (($pos = strpos($tag, ' '))!==false)
642
+ $tag = substr($tag, 0, $pos);
643
+
644
+ $parent_lower = strtolower($this->parent->tag);
645
+ $tag_lower = strtolower($tag);
646
+
647
+ if ($parent_lower!==$tag_lower) {
648
+ if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) {
649
+ $this->parent->_[HDOM_INFO_END] = 0;
650
+ $org_parent = $this->parent;
651
+
652
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
653
+ $this->parent = $this->parent->parent;
654
+
655
+ if (strtolower($this->parent->tag)!==$tag_lower) {
656
+ $this->parent = $org_parent; // restore origonal parent
657
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
658
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
659
+ return $this->as_text_node($tag);
660
+ }
661
+ }
662
+ else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) {
663
+ $this->parent->_[HDOM_INFO_END] = 0;
664
+ $org_parent = $this->parent;
665
+
666
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
667
+ $this->parent = $this->parent->parent;
668
+
669
+ if (strtolower($this->parent->tag)!==$tag_lower) {
670
+ $this->parent = $org_parent; // restore origonal parent
671
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
672
+ return $this->as_text_node($tag);
673
+ }
674
+ }
675
+ else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) {
676
+ $this->parent->_[HDOM_INFO_END] = 0;
677
+ $this->parent = $this->parent->parent;
678
+ }
679
+ else
680
+ return $this->as_text_node($tag);
681
+ }
682
+
683
+ $this->parent->_[HDOM_INFO_END] = $this->cursor;
684
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
685
+
686
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
687
+ return true;
688
+ }
689
+
690
+ $node = new simple_html_dom_node($this);
691
+ $node->_[HDOM_INFO_BEGIN] = $this->cursor;
692
+ ++$this->cursor;
693
+ $tag = $this->copy_until($this->token_slash);
694
+
695
+ // doctype, cdata & comments...
696
+ if (isset($tag[0]) && $tag[0]==='!') {
697
+ $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
698
+
699
+ if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
700
+ $node->nodetype = HDOM_TYPE_COMMENT;
701
+ $node->tag = 'comment';
702
+ } else {
703
+ $node->nodetype = HDOM_TYPE_UNKNOWN;
704
+ $node->tag = 'unknown';
705
+ }
706
+
707
+ if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
708
+ $this->link_nodes($node, true);
709
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
710
+ return true;
711
+ }
712
+
713
+ // text
714
+ if ($pos=strpos($tag, '<')!==false) {
715
+ $tag = '<' . substr($tag, 0, -1);
716
+ $node->_[HDOM_INFO_TEXT] = $tag;
717
+ $this->link_nodes($node, false);
718
+ $this->char = $this->doc[--$this->pos]; // prev
719
+ return true;
720
+ }
721
+
722
+ if (!preg_match("/^[\w-:]+$/", $tag)) {
723
+ $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
724
+ if ($this->char==='<') {
725
+ $this->link_nodes($node, false);
726
+ return true;
727
+ }
728
+
729
+ if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
730
+ $this->link_nodes($node, false);
731
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
732
+ return true;
733
+ }
734
+
735
+ // begin tag
736
+ $node->nodetype = HDOM_TYPE_ELEMENT;
737
+ $tag_lower = strtolower($tag);
738
+ $node->tag = ($this->lowercase) ? $tag_lower : $tag;
739
+
740
+ // handle optional closing tags
741
+ if (isset($this->optional_closing_tags[$tag_lower]) ) {
742
+ while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) {
743
+ $this->parent->_[HDOM_INFO_END] = 0;
744
+ $this->parent = $this->parent->parent;
745
+ }
746
+ $node->parent = $this->parent;
747
+ }
748
+
749
+ $guard = 0; // prevent infinity loop
750
+ $space = array($this->copy_skip($this->token_blank), '', '');
751
+
752
+ // attributes
753
+ do {
754
+ if ($this->char!==null && $space[0]==='') break;
755
+ $name = $this->copy_until($this->token_equal);
756
+ if($guard===$this->pos) {
757
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
758
+ continue;
759
+ }
760
+ $guard = $this->pos;
761
+
762
+ // handle endless '<'
763
+ if($this->pos>=$this->size-1 && $this->char!=='>') {
764
+ $node->nodetype = HDOM_TYPE_TEXT;
765
+ $node->_[HDOM_INFO_END] = 0;
766
+ $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
767
+ $node->tag = 'text';
768
+ $this->link_nodes($node, false);
769
+ return true;
770
+ }
771
+
772
+ // handle mismatch '<'
773
+ if($this->doc[$this->pos-1]=='<') {
774
+ $node->nodetype = HDOM_TYPE_TEXT;
775
+ $node->tag = 'text';
776
+ $node->attr = array();
777
+ $node->_[HDOM_INFO_END] = 0;
778
+ $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
779
+ $this->pos -= 2;
780
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
781
+ $this->link_nodes($node, false);
782
+ return true;
783
+ }
784
+
785
+ if ($name!=='/' && $name!=='') {
786
+ $space[1] = $this->copy_skip($this->token_blank);
787
+ $name = $this->restore_noise($name);
788
+ if ($this->lowercase) $name = strtolower($name);
789
+ if ($this->char==='=') {
790
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
791
+ $this->parse_attr($node, $name, $space);
792
+ }
793
+ else {
794
+ //no value attr: nowrap, checked selected...
795
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
796
+ $node->attr[$name] = true;
797
+ if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
798
+ }
799
+ $node->_[HDOM_INFO_SPACE][] = $space;
800
+ $space = array($this->copy_skip($this->token_blank), '', '');
801
+ }
802
+ else
803
+ break;
804
+ } while($this->char!=='>' && $this->char!=='/');
805
+
806
+ $this->link_nodes($node, true);
807
+ $node->_[HDOM_INFO_ENDSPACE] = $space[0];
808
+
809
+ // check self closing
810
+ if ($this->copy_until_char_escape('>')==='/') {
811
+ $node->_[HDOM_INFO_ENDSPACE] .= '/';
812
+ $node->_[HDOM_INFO_END] = 0;
813
+ }
814
+ else {
815
+ // reset parent
816
+ if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
817
+ }
818
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
819
+ return true;
820
+ }
821
+
822
+ // parse attributes
823
+ protected function parse_attr($node, $name, &$space) {
824
+ $space[2] = $this->copy_skip($this->token_blank);
825
+ switch($this->char) {
826
+ case '"':
827
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
828
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
829
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
830
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
831
+ break;
832
+ case '\'':
833
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
834
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
835
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
836
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
837
+ break;
838
+ default:
839
+ $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
840
+ $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
841
+ }
842
+ }
843
+
844
+ // link node's parent
845
+ protected function link_nodes(&$node, $is_child) {
846
+ $node->parent = $this->parent;
847
+ $this->parent->nodes[] = $node;
848
+ if ($is_child)
849
+ $this->parent->children[] = $node;
850
+ }
851
+
852
+ // as a text node
853
+ protected function as_text_node($tag) {
854
+ $node = new simple_html_dom_node($this);
855
+ ++$this->cursor;
856
+ $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
857
+ $this->link_nodes($node, false);
858
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
859
+ return true;
860
+ }
861
+
862
+ protected function skip($chars) {
863
+ $this->pos += strspn($this->doc, $chars, $this->pos);
864
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
865
+ }
866
+
867
+ protected function copy_skip($chars) {
868
+ $pos = $this->pos;
869
+ $len = strspn($this->doc, $chars, $pos);
870
+ $this->pos += $len;
871
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
872
+ if ($len===0) return '';
873
+ return substr($this->doc, $pos, $len);
874
+ }
875
+
876
+ protected function copy_until($chars) {
877
+ $pos = $this->pos;
878
+ $len = strcspn($this->doc, $chars, $pos);
879
+ $this->pos += $len;
880
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
881
+ return substr($this->doc, $pos, $len);
882
+ }
883
+
884
+ protected function copy_until_char($char) {
885
+ if ($this->char===null) return '';
886
+
887
+ if (($pos = strpos($this->doc, $char, $this->pos))===false) {
888
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
889
+ $this->char = null;
890
+ $this->pos = $this->size;
891
+ return $ret;
892
+ }
893
+
894
+ if ($pos===$this->pos) return '';
895
+ $pos_old = $this->pos;
896
+ $this->char = $this->doc[$pos];
897
+ $this->pos = $pos;
898
+ return substr($this->doc, $pos_old, $pos-$pos_old);
899
+ }
900
+
901
+ protected function copy_until_char_escape($char) {
902
+ if ($this->char===null) return '';
903
+
904
+ $start = $this->pos;
905
+ while(1) {
906
+ if (($pos = strpos($this->doc, $char, $start))===false) {
907
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
908
+ $this->char = null;
909
+ $this->pos = $this->size;
910
+ return $ret;
911
+ }
912
+
913
+ if ($pos===$this->pos) return '';
914
+
915
+ if ($this->doc[$pos-1]==='\\') {
916
+ $start = $pos+1;
917
+ continue;
918
+ }
919
+
920
+ $pos_old = $this->pos;
921
+ $this->char = $this->doc[$pos];
922
+ $this->pos = $pos;
923
+ return substr($this->doc, $pos_old, $pos-$pos_old);
924
+ }
925
+ }
926
+
927
+ // remove noise from html content
928
+ protected function remove_noise($pattern, $remove_tag=false) {
929
+ $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
930
+
931
+ for ($i=$count-1; $i>-1; --$i) {
932
+ $key = '___noise___'.sprintf('% 3d', count($this->noise)+100);
933
+ $idx = ($remove_tag) ? 0 : 1;
934
+ $this->noise[$key] = $matches[$i][$idx][0];
935
+ $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
936
+ }
937
+
938
+ // reset the length of content
939
+ $this->size = strlen($this->doc);
940
+ if ($this->size>0) $this->char = $this->doc[0];
941
+ }
942
+
943
+ // restore noise to html content
944
+ function restore_noise($text) {
945
+ while(($pos=strpos($text, '___noise___'))!==false) {
946
+ $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13];
947
+ if (isset($this->noise[$key]))
948
+ $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+14);
949
+ }
950
+ return $text;
951
+ }
952
+
953
+ function __toString() {
954
+ return $this->root->innertext();
955
+ }
956
+
957
+ function __get($name) {
958
+ switch($name) {
959
+ case 'outertext': return $this->root->innertext();
960
+ case 'innertext': return $this->root->innertext();
961
+ case 'plaintext': return $this->root->text();
962
+ }
963
+ }
964
+
965
+ // camel naming conventions
966
+ function childNodes($idx=-1) {return $this->root->childNodes($idx);}
967
+ function firstChild() {return $this->root->first_child();}
968
+ function lastChild() {return $this->root->last_child();}
969
+ function getElementById($id) {return $this->find("#$id", 0);}
970
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
971
+ function getElementByTagName($name) {return $this->find($name, 0);}
972
+ function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
973
+ function loadFile() {$args = func_get_args();$this->load(call_user_func_array('file_get_contents', $args), true);}
974
+ }
975
+ ?>
languages/head-cleaner-ja.mo ADDED
Binary file
languages/head-cleaner-ja.po ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Head Cleaner\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2009-03-05 09:42+0900\n"
6
+ "PO-Revision-Date: 2009-03-05 09:43+0900\n"
7
+ "Last-Translator: wokamoto <wokamoto1973@gmail.com>\n"
8
+ "Language-Team: JAPANESE <http://wppluginsj.sourceforge.jp/>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-Language: Japanese\n"
13
+ "X-Poedit-Country: JAPAN\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+
19
+ #: ../head-cleaner.php:1314
20
+ msgid "Head Cleaner"
21
+ msgstr "Head Cleaner"
22
+
23
+ #: ../head-cleaner.php:1320
24
+ msgid "Settings"
25
+ msgstr "設定"
26
+
27
+ #: ../head-cleaner.php:1387
28
+ #: ../head-cleaner.php:1397
29
+ #: ../head-cleaner.php:1407
30
+ msgid "Done!"
31
+ msgstr "完了!"
32
+
33
+ #: ../head-cleaner.php:1419
34
+ msgid "Head Cleaner Options"
35
+ msgstr "Head Cleaner 設定"
36
+
37
+ #: ../head-cleaner.php:1427
38
+ msgid "CSS and JavaScript are cached on the server."
39
+ msgstr "CSS と JavaScript を、サーバ上にキャッシュする"
40
+
41
+ #: ../head-cleaner.php:1431
42
+ msgid "Put JavaScripts at the Bottom."
43
+ msgstr "&lt;head&gt; 内の JavaScript を、フッタ領域に移動"
44
+
45
+ #: ../head-cleaner.php:1435
46
+ msgid "CSS and JS are dynamically generated."
47
+ msgstr "CSS, JS を動的生成する。"
48
+
49
+ #: ../head-cleaner.php:1443
50
+ msgid "Two or more CSS is combined."
51
+ msgstr "複数の CSS を結合する"
52
+
53
+ #: ../head-cleaner.php:1447
54
+ msgid "CSS is optimized."
55
+ msgstr "CSS を最適化する"
56
+
57
+ #: ../head-cleaner.php:1450
58
+ msgid "Default media attribute applied to CSS."
59
+ msgstr "CSS に適用するデフォルト media 属性"
60
+
61
+ #: ../head-cleaner.php:1459
62
+ msgid "Two or more JavaScript is combined."
63
+ msgstr "複数の JavaScript を結合する"
64
+
65
+ #: ../head-cleaner.php:1463
66
+ msgid "JavaScript is minified."
67
+ msgstr "JavaScript を小さくする"
68
+
69
+ #: ../head-cleaner.php:1467
70
+ msgid "Bottom JavaScript is combined, too."
71
+ msgstr "フッタ領域の JavaScript も対象にする"
72
+
73
+ #: ../head-cleaner.php:1475
74
+ msgid "Debug mode"
75
+ msgstr "デバッグモード"
76
+
77
+ #: ../head-cleaner.php:1488
78
+ msgid "The CSS optimization settings"
79
+ msgstr "CSS最適化 オプション"
80
+
81
+ #: ../head-cleaner.php:1490
82
+ msgid "Compression (code layout):"
83
+ msgstr "圧縮率(コードレイアウト):"
84
+
85
+ #: ../head-cleaner.php:1492
86
+ msgid "Highest (no readability, smallest size)"
87
+ msgstr "最高 (改行なし)"
88
+
89
+ #: ../head-cleaner.php:1493
90
+ msgid "High (moderate readability, smaller size)"
91
+ msgstr "高 (セレクタ1行表記)"
92
+
93
+ #: ../head-cleaner.php:1494
94
+ msgid "Standard (balance between readability and size)"
95
+ msgstr "標準 (プロパティごと改行)"
96
+
97
+ #: ../head-cleaner.php:1495
98
+ msgid "Low (higher readability)"
99
+ msgstr "低 (プロパティをインデント)"
100
+
101
+ #: ../head-cleaner.php:1498
102
+ msgid "Optimise shorthands"
103
+ msgstr "ショートハンドCSSの最適化"
104
+
105
+ #: ../head-cleaner.php:1500
106
+ msgid "All optimisations"
107
+ msgstr "margin,padding,border,backgroundを最適化"
108
+
109
+ #: ../head-cleaner.php:1501
110
+ msgid "Safe optimisations"
111
+ msgstr "margin,padding,borderのみ"
112
+
113
+ #: ../head-cleaner.php:1502
114
+ msgid "Don't optimise"
115
+ msgstr "最適化しない"
116
+
117
+ #: ../head-cleaner.php:1507
118
+ msgid "Compress colors"
119
+ msgstr "colorの値を簡略化する"
120
+
121
+ #: ../head-cleaner.php:1510
122
+ msgid "Compress font-weight"
123
+ msgstr "font-weightを数値にする"
124
+
125
+ #: ../head-cleaner.php:1513
126
+ msgid "Remove unnecessary backslashes"
127
+ msgstr "不要なバックスラッシュを削除"
128
+
129
+ #: ../head-cleaner.php:1521
130
+ msgid "Active Filters"
131
+ msgstr "アクティブなフィルタ"
132
+
133
+ #: ../head-cleaner.php:1524
134
+ #: ../head-cleaner.php:1561
135
+ msgid "Off the subject"
136
+ msgstr "対象外"
137
+
138
+ #: ../head-cleaner.php:1525
139
+ #: ../head-cleaner.php:1562
140
+ msgid "Remove"
141
+ msgstr "削除"
142
+
143
+ #: ../head-cleaner.php:1526
144
+ msgid "Head filters"
145
+ msgstr "&lt;head&gt; 内のアクティブなフィルタ"
146
+
147
+ #: ../head-cleaner.php:1528
148
+ #: ../head-cleaner.php:1565
149
+ msgid "Priority"
150
+ msgstr "フィルタの優先順位"
151
+
152
+ #: ../head-cleaner.php:1563
153
+ msgid "Bottom filters"
154
+ msgstr "フッタ領域のアクティブなフィルタ"
155
+
156
+ #: ../head-cleaner.php:1599
157
+ msgid "Update Options"
158
+ msgstr "更新"
159
+
160
+ #: ../head-cleaner.php:1604
161
+ msgid "Remove all cache files"
162
+ msgstr "キャッシュファイル削除"
163
+
164
+ #: ../head-cleaner.php:1607
165
+ msgid "All cache files are removed."
166
+ msgstr "キャッシュフォルダ内のファイルをすべて削除する。"
167
+
168
+ #: ../head-cleaner.php:1608
169
+ msgid "Remove All Cache Files"
170
+ msgstr "削除"
171
+
172
+ #: ../head-cleaner.php:1613
173
+ msgid "Uninstall"
174
+ msgstr "アンインストール"
175
+
176
+ #: ../head-cleaner.php:1616
177
+ msgid "All the settings of &quot;Head Cleaner&quot; are deleted."
178
+ msgstr "&quot;Head Cleaner&quot; の設定をすべて消去する。"
179
+
180
+ #: ../head-cleaner.php:1617
181
+ msgid "Delete Options"
182
+ msgstr "削除"
183
+
languages/head-cleaner.pot ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Head Cleaner\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2009-03-04 18:04+0900\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=iso-8859-1\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+
13
+ #: ../head-cleaner.php:1314
14
+ msgid "Head Cleaner"
15
+ msgstr ""
16
+
17
+ #: ../head-cleaner.php:1320
18
+ msgid "Settings"
19
+ msgstr ""
20
+
21
+ #: ../head-cleaner.php:1387
22
+ #: ../head-cleaner.php:1397
23
+ #: ../head-cleaner.php:1407
24
+ msgid "Done!"
25
+ msgstr ""
26
+
27
+ #: ../head-cleaner.php:1419
28
+ msgid "Head Cleaner Options"
29
+ msgstr ""
30
+
31
+ #: ../head-cleaner.php:1427
32
+ msgid "CSS and JavaScript are cached on the server."
33
+ msgstr ""
34
+
35
+ #: ../head-cleaner.php:1431
36
+ msgid "Put JavaScripts at the Bottom."
37
+ msgstr ""
38
+
39
+ #: ../head-cleaner.php:1435
40
+ msgid "CSS and JS are dynamically generated."
41
+ msgstr ""
42
+
43
+ #: ../head-cleaner.php:1443
44
+ msgid "Two or more CSS is combined."
45
+ msgstr ""
46
+
47
+ #: ../head-cleaner.php:1447
48
+ msgid "CSS is optimized."
49
+ msgstr ""
50
+
51
+ #: ../head-cleaner.php:1450
52
+ msgid "Default media attribute applied to CSS."
53
+ msgstr ""
54
+
55
+ #: ../head-cleaner.php:1459
56
+ msgid "Two or more JavaScript is combined."
57
+ msgstr ""
58
+
59
+ #: ../head-cleaner.php:1463
60
+ msgid "JavaScript is minified."
61
+ msgstr ""
62
+
63
+ #: ../head-cleaner.php:1467
64
+ msgid "Bottom JavaScript is combined, too."
65
+ msgstr ""
66
+
67
+ #: ../head-cleaner.php:1475
68
+ msgid "Debug mode"
69
+ msgstr ""
70
+
71
+ #: ../head-cleaner.php:1488
72
+ msgid "The CSS optimization settings"
73
+ msgstr ""
74
+
75
+ #: ../head-cleaner.php:1490
76
+ msgid "Compression (code layout):"
77
+ msgstr ""
78
+
79
+ #: ../head-cleaner.php:1492
80
+ msgid "Highest (no readability, smallest size)"
81
+ msgstr ""
82
+
83
+ #: ../head-cleaner.php:1493
84
+ msgid "High (moderate readability, smaller size)"
85
+ msgstr ""
86
+
87
+ #: ../head-cleaner.php:1494
88
+ msgid "Standard (balance between readability and size)"
89
+ msgstr ""
90
+
91
+ #: ../head-cleaner.php:1495
92
+ msgid "Low (higher readability)"
93
+ msgstr ""
94
+
95
+ #: ../head-cleaner.php:1498
96
+ msgid "Optimise shorthands"
97
+ msgstr ""
98
+
99
+ #: ../head-cleaner.php:1500
100
+ msgid "All optimisations"
101
+ msgstr ""
102
+
103
+ #: ../head-cleaner.php:1501
104
+ msgid "Safe optimisations"
105
+ msgstr ""
106
+
107
+ #: ../head-cleaner.php:1502
108
+ msgid "Don't optimise"
109
+ msgstr ""
110
+
111
+ #: ../head-cleaner.php:1507
112
+ msgid "Compress colors"
113
+ msgstr ""
114
+
115
+ #: ../head-cleaner.php:1510
116
+ msgid "Compress font-weight"
117
+ msgstr ""
118
+
119
+ #: ../head-cleaner.php:1513
120
+ msgid "Remove unnecessary backslashes"
121
+ msgstr ""
122
+
123
+ #: ../head-cleaner.php:1521
124
+ msgid "Active Filters"
125
+ msgstr ""
126
+
127
+ #: ../head-cleaner.php:1524
128
+ #: ../head-cleaner.php:1561
129
+ msgid "Off the subject"
130
+ msgstr ""
131
+
132
+ #: ../head-cleaner.php:1525
133
+ #: ../head-cleaner.php:1562
134
+ msgid "Remove"
135
+ msgstr ""
136
+
137
+ #: ../head-cleaner.php:1526
138
+ msgid "Head filters"
139
+ msgstr ""
140
+
141
+ #: ../head-cleaner.php:1528
142
+ #: ../head-cleaner.php:1565
143
+ msgid "Priority"
144
+ msgstr ""
145
+
146
+ #: ../head-cleaner.php:1563
147
+ msgid "Bottom filters"
148
+ msgstr ""
149
+
150
+ #: ../head-cleaner.php:1599
151
+ msgid "Update Options"
152
+ msgstr ""
153
+
154
+ #: ../head-cleaner.php:1604
155
+ msgid "Remove all cache files"
156
+ msgstr ""
157
+
158
+ #: ../head-cleaner.php:1607
159
+ msgid "All cache files are removed."
160
+ msgstr ""
161
+
162
+ #: ../head-cleaner.php:1608
163
+ msgid "Remove All Cache Files"
164
+ msgstr ""
165
+
166
+ #: ../head-cleaner.php:1613
167
+ msgid "Uninstall"
168
+ msgstr ""
169
+
170
+ #: ../head-cleaner.php:1616
171
+ msgid "All the settings of &quot;Head Cleaner&quot; are deleted."
172
+ msgstr ""
173
+
174
+ #: ../head-cleaner.php:1617
175
+ msgid "Delete Options"
176
+ msgstr ""
177
+
readme.txt ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Head Cleaner ===
2
+ Contributors: wokamoto
3
+ Tags: head, header, footer, javascript, css, optimization, minified
4
+ Requires at least: 2.5
5
+ Tested up to: 2.7.1
6
+ Stable tag: 1.0.0
7
+
8
+ Cleaning tags from your WordPress header and footer.
9
+
10
+ == Description ==
11
+
12
+ Cleaning tags from your WordPress header and footer.
13
+
14
+ = Features =
15
+
16
+ * IE6 at the top of the non-grant xml declaration.
17
+ * Tags and duplicate, unnecessary tags, comments, and remove the blank.
18
+ * `<meta Name="description" />` If you have multiple tags into one.
19
+ * `<meta Name="keyword" />` If you have multiple tags into one.
20
+ * `<link rel="canonical" />` add tags.
21
+ * IE conditional Tag, if your browser is IE, display when that tag.
22
+ * CSS, JavaScript, if your browser supports gzip compression transfer.
23
+ * Have multiple CSS files into the media and a binding for each attribute.
24
+ Of course, the file contains inline CSS.
25
+ * CSS optimize at [CSSTidy](http://csstidy.sourceforge.net/ "CSSTidy").
26
+ * The administrator can specify CSSTidy optimization.
27
+ * Have multiple JavaScript files into a binding and all.
28
+ Of course, the file also includes an inline JavaScript.
29
+ * JavaScript source code minified at [JSMin](http://code.google.com/p/jsmin-php/ "JSMin").
30
+ * JavaScript can also be moved to the footer area.
31
+ * JavaScript footer areas are combined into a single file as well.
32
+ * Prototype.js, jQuery, mootools is being loaded more than one case, one to read only once.
33
+ * Prototype.js, jQuery, mootools and fix the load order to avoid possible conflicts.
34
+
35
+ == Installation ==
36
+
37
+ 1. Upload the entire `head-cleaner` folder to the `/wp-content/plugins/` directory.
38
+ 2. Please make `js` and `css` a directory under the `/wp-content/cache/head-cleaner/` directory.
39
+ 3. Activate the plugin through the 'Plugins' menu in WordPress.
40
+
41
+ The control panel of Head Cleaner is in 'Settings > Head Cleaner'.
42
+
43
+ **PHP libraries are using [Simple HTML DOM Parser](http://simplehtmldom.sourceforge.net/ "Simple HTML DOM Parser") and [JSMin](http://code.google.com/p/jsmin-php/ "JSMin") upper limit, PHP5 is only later.**
44
+
45
+ == Frequently Asked Questions ==
46
+
47
+ Two directories: CSS, JavaScript caches.
48
+ If you want to enable the cache, please create a folder.
49
+
50
+ * `wp-content/cache/head-cleaner/css`
51
+ * `wp-content/cache/head-cleaner/js`
52
+
53
+ If you want to exclude certain statements in shaping the header.php theme needs to be modified.
54
+ Specifically, the portion to be excluded from shaping <?php wp_head ();?> Please describe below.
55
+
56
+ The theme you are using plug-ins do not work together properly.
57
+ If you do not work properly, after stopping all the other plug-in plug-in,
58
+ To activate each one, please check if any conflicts with plugins.
59
+
60
+ **[Comment Quicktags](http://www.enblogopedia.com/wordpress-plugin-comment-quicktags-reloaded/ "Comment Quicktags")**
61
+
62
+ The setting "Active Filters" - "Head filters" Please exclude the following to select a filter.
63
+
64
+ * `comment_quicktags`
65
+
66
+ **[Ultimate Google Analytics](http://www.oratransplant.nl/uga "Ultimate Google Analytics")**
67
+
68
+ The setting "Active Filters" - "Bottom filters" Please exclude the following to select a filter.
69
+
70
+ * `uga_wp_footer_track`
71
+
72
+ == Screenshots ==
73
+
74
+ 1. The admin page
readme_ja.txt ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Head Cleaner ===
2
+ Contributors: wokamoto
3
+ Tags: head optimization, javascript, css, optimization, minified
4
+ Requires at least: 2.5
5
+ Tested up to: 2.7.1
6
+ Stable tag: 1.0.0
7
+
8
+ Head �� footer �����|�����܂��B
9
+
10
+ == Description ==
11
+
12
+ WordPress �T�C�g�� `<head>` �̒��g�ƁA�t�b�^�̈�𐮌`���Ȃ����܂��B
13
+
14
+ = Features =
15
+
16
+ * IE6 �ȊO�̎��͐擪�� xml �錾��t�^�B
17
+ * �d���^�O��A�s�v�ȃ^�O�A�R�����g�A�󔒂��폜�B
18
+ * `<meta name="description" />` �^�O����������ꍇ�A��‚ɂ܂Ƃ߂�
19
+ * `<meta name="keyword" />` �^�O����������ꍇ�A��‚ɂ܂Ƃ߂�
20
+ * �b��� `<link rel="canonical" />` �^�O��lj��B
21
+ * IE �R���f�B�V���i���^�O�𔻒肵�āA�u���E�U�� IE �̎������Ώۃ^�O��\���B
22
+ * CSS, JavaScript �́A�u���E�U���Ή����Ă���� gzip ���k�]���B
23
+ * �������� CSS �� media �������ƂɌ������Ĉ�t�@�C���ɂ܂Ƃ߂�B
24
+ �������A���̃t�@�C���ɂ� �C�����C�� CSS ���܂܂��B
25
+ * [CSSTidy](http://csstidy.sourceforge.net/ "CSSTidy") ���g�p���� CSS ���œK������B
26
+ * CSSTidy �̍œK���I�v�V�������Ǘ���ʂŎw��ł���B
27
+ * �������� JavaScript �����ׂČ������Ĉ�t�@�C���ɂ܂Ƃ߂�B
28
+ �������A���̃t�@�C���ɂ� �C�����C�� JavaScript ���܂܂��B
29
+ * [JSMin](http://code.google.com/p/jsmin-php/ "JSMin") �ŁAJavaScript �̃\�[�X�R�[�h�����k����B
30
+ * JavaScript ���t�b�^�̈�Ɉړ����邱�Ƃ��ł���B
31
+ * �t�b�^�̈�� JavaScript �����l�Ɍ������Ĉ�t�@�C���ɂ܂Ƃ߂�B
32
+ * Prototype.js, jQuery, mootools �������ǂݍ��܂�Ă���ꍇ�A�P�񂾂��ǂݍ��ނ悤�ɂ���B
33
+ * Prototype.js, jQuery, mootools �̓ǂݍ��ݏ����C�����āA�ł��邾���R���t���N�g���������Ȃ��悤�ɂ���B
34
+
35
+ == Installation ==
36
+
37
+ 1. `/wp-content/plugins/` �f�B���N�g���� `head-cleaner` �f�B���N�g�����쐬���A���̒��Ƀv���O�C���t�@�C�����i�[���Ă��������B
38
+ �@��ʓI�ɂ� .zip ����W�J���ꂽ head-cleaner �t�H���_�����̂܂܃A�b�v���[�h����� OK �ł��B
39
+ 2. `/wp-content/` �f�B���N�g���ȉ��� `cache/head-cleaner` �Ƃ����f�B���N�g�����쐬���A����ɂ��̒��� `js`, `css` �Ƃ����Q�‚̃f�B���N�g�����쐬���āA�������݌�����^���Ă��������B
40
+ 3. WordPress �� "�v���O�C��" ���j���[���� "Head Cleaner" ��L���������������B
41
+
42
+ Head Cleaner �̃I�v�V�����ݒ�� "�ݒ� > Head Cleaner" �ōs���܂��B
43
+
44
+
45
+ **�g�p���Ă���PHP���C�u���� [Simple HTML DOM Parser](http://simplehtmldom.sourceforge.net/ "Simple HTML DOM Parser") �� [JSMin](http://code.google.com/p/jsmin-php/ "JSMin") �̐�����APHP5 �ȍ~�̂ݑΉ��ł��B**
46
+
47
+ == Frequently Asked Questions ==
48
+
49
+ �ȉ��̓�‚̃f�B���N�g���� CSS, JavaScript ���L���b�V�����܂��B
50
+ �L���b�V����L���ɂ������ꍇ�́A���ꂼ��̃t�H���_���쐬���Ă��������B
51
+
52
+ * `wp-content/cache/head-cleaner/css/`
53
+ * `wp-content/cache/head-cleaner/js/`
54
+
55
+
56
+ ����̃v���O�C���������o���R�[�h�𐮌`�ΏۊO�ɂ������ꍇ�́A�ݒ��ʂ́u�A�N�e�B�u�ȃt�B���^�v����A�ΏۊO�ɂ������t�B���^����I�����Ă��������B
57
+
58
+
59
+ �e�[�}���̓���̋L�q�𐮌`�ΏۊO�ɂ������ꍇ�� `header.php` ���C������K�v������܂��B
60
+ ��̓I�ɂ́A���`�ΏۊO�ɂ����������� `<?php wp_head(); ?>` ��艺�ɋL�q���Ă��������B
61
+
62
+
63
+ �����Ɏg�p���Ă���v���O�C���E�e�[�}�ɂ���Ă͐���ɓ��삵�܂���B
64
+ ����ɓ��삵�Ȃ��ꍇ�́A���̃v���O�C���ȊO�̂��ׂẴv���O�C�����~������A��ˆ�—L�������āA�ǂ̃v���O�C���Ƌ������邩�m���߂Ă݂Ă��������B
65
+ ��������v���O�C�������������ꍇ�A��҂܂ŘA������������Ɣ��ɏ�����܂��B
66
+ [http://dogmap.jp/2009/02/20/head-cleaner/](http://dogmap.jp/2009/02/20/head-cleaner/ "")
67
+
68
+
69
+ ���݁A�ȉ��̃v���O�C���Ɠ����Ɏg�p����ƁA����ɓ��삵�Ȃ����Ƃ��񍐂���Ă��܂��B
70
+
71
+ **[All in One SEO Pack](http://wordpress.org/extend/plugins/all-in-one-seo-pack/ "All in One SEO Pack")**
72
+ �@�ꕔ�‹��Łu�^�C�g���̏��������v�I�v�V�������L���ɂȂ��Ă���ƁA���̃v���O�C�������퓮�삵�Ȃ��Ƃ����񍐂�����܂����B
73
+ �@�ʏ�͖�肪����܂��񂪁A��肪���������ꍇ�́u�^�C�g���̏��������v���I�t�ɂ��āA�^�C�g���̏��������͕ʃv���O�C�����g�p����悤�ɂ��Ă��������B
74
+
75
+ **[Comment Quicktags](http://www.enblogopedia.com/wordpress-plugin-comment-quicktags-reloaded/ "Comment Quicktags")**
76
+ �@�ݒ��ʂ́u�A�N�e�B�u�ȃt�B���^�v-�u�t�b�^�̈�̃A�N�e�B�u�ȃt�B���^�v����A�ȉ��̃t�B���^��I�����đΏۊO�ɂ��Ă��������B
77
+ �@�ucomment_quicktags�v
78
+
79
+ **[Ultimate Google Analytics](http://www.oratransplant.nl/uga "Ultimate Google Analytics")**
80
+ �@�ݒ��ʂ́u�A�N�e�B�u�ȃt�B���^�v-�u�t�b�^�̈�̃A�N�e�B�u�ȃt�B���^�v����A�ȉ��̃t�B���^��I�����đΏۊO�ɂ��Ă��������B
81
+ �@�uuga_wp_footer_track�v
82
+ �@����� Ultimate Google Analytics �̏����o���R�[�h�� Head Cleaner �̐��`�ΏۊO�ɂȂ�܂��B
83
+
84
+ == Screenshots ==
85
+
86
+ 1. �Ǘ����
screenshot-1.png ADDED
Binary file