extensionsmall-sizechart - Version 1.0.0

Version Notes

Stable version of ExtensionsMall size-chart

Download this release

Release Info

Developer Extensions Mall
Extension extensionsmall-sizechart
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (57) hide show
  1. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit.php +45 -0
  2. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit/Form.php +19 -0
  3. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit/Tab/Form.php +153 -0
  4. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit/Tabs.php +28 -0
  5. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/List.php +14 -0
  6. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/List/Grid.php +55 -0
  7. app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/System/Config/Form/Field/Color.php +31 -0
  8. app/code/community/ExtensionsMall/SizeChart/Block/Sizechart.php +85 -0
  9. app/code/community/ExtensionsMall/SizeChart/Block/Sizechart/Anchor.php +15 -0
  10. app/code/community/ExtensionsMall/SizeChart/Helper/Data.php +5 -0
  11. app/code/community/ExtensionsMall/SizeChart/Model/Resource/Setup.php +13 -0
  12. app/code/community/ExtensionsMall/SizeChart/Model/Resource/Sizechart.php +9 -0
  13. app/code/community/ExtensionsMall/SizeChart/Model/Resource/Sizechart/Collection.php +10 -0
  14. app/code/community/ExtensionsMall/SizeChart/Model/Sizechart.php +44 -0
  15. app/code/community/ExtensionsMall/SizeChart/controllers/Adminhtml/ExtensionsmallsizechartController.php +82 -0
  16. app/code/community/ExtensionsMall/SizeChart/data/extensionsmall_sizechart_setup/data-install-1.0.0.php +11 -0
  17. app/code/community/ExtensionsMall/SizeChart/etc/adminhtml.xml +27 -0
  18. app/code/community/ExtensionsMall/SizeChart/etc/config.xml +97 -0
  19. app/code/community/ExtensionsMall/SizeChart/etc/system.xml +59 -0
  20. app/code/community/ExtensionsMall/SizeChart/sql/extensionsmall_sizechart_setup/mysql4-install-1.0.0.php +33 -0
  21. app/design/frontend/base/default/layout/sizechart.xml +36 -0
  22. app/design/frontend/base/default/template/sizechart/anchor.phtml +3 -0
  23. app/design/frontend/base/default/template/sizechart/sizechart.phtml +78 -0
  24. app/etc/modules/ExtensionsMall_SizeChart.xml +9 -0
  25. js/procolor-1.0/api.html +158 -0
  26. js/procolor-1.0/docs.css +44 -0
  27. js/procolor-1.0/examples.html +145 -0
  28. js/procolor-1.0/img/procolor_win_bars.png +0 -0
  29. js/procolor-1.0/img/procolor_win_bg.gif +0 -0
  30. js/procolor-1.0/img/procolor_win_bg.png +0 -0
  31. js/procolor-1.0/img/procolor_win_boxes.png +0 -0
  32. js/procolor-1.0/img/procolor_win_close.png +0 -0
  33. js/procolor-1.0/img/procolor_win_drop.png +0 -0
  34. js/procolor-1.0/img/procolor_win_palette_raw.png +0 -0
  35. js/procolor-1.0/img/procolor_win_sel_circle.gif +0 -0
  36. js/procolor-1.0/img/procolor_win_sel_circle.png +0 -0
  37. js/procolor-1.0/img/procolor_win_sel_rect.gif +0 -0
  38. js/procolor-1.0/img/procolor_win_sel_rect.png +0 -0
  39. js/procolor-1.0/img/procolor_win_wheel_black.png +0 -0
  40. js/procolor-1.0/img/procolor_win_wheel_rgb.jpg +0 -0
  41. js/procolor-1.0/index.html +117 -0
  42. js/procolor-1.0/license.html +64 -0
  43. js/procolor-1.0/options.html +137 -0
  44. js/procolor-1.0/procolor.compressed.js +1 -0
  45. js/procolor-1.0/procolor.js +1745 -0
  46. js/procolor-1.0/prototype.compressed.js +1 -0
  47. js/procolor-1.0/prototype.js +4320 -0
  48. js/sizechart/fancybox_overlay.png +0 -0
  49. js/sizechart/fancybox_sprite.png +0 -0
  50. js/sizechart/jquery-1.11.3.min.js +5 -0
  51. js/sizechart/jquery.fancybox.css +274 -0
  52. js/sizechart/jquery.fancybox.pack.js +46 -0
  53. js/sizechart/sizechart.js +176 -0
  54. package.xml +18 -0
  55. skin/frontend/base/default/sizechart/images/size-chart-button.png +0 -0
  56. skin/frontend/base/default/sizechart/images/sizechart-siluete.jpg +0 -0
  57. skin/frontend/base/default/sizechart/sizechart.css +108 -0
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'sizechart_id';
10
+ $this->_blockGroup = 'extensionsmall_sizechart';
11
+ $this->_controller = 'adminhtml';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('extensionsmall_sizechart')->__('Save sizechart'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('extensionsmall_sizechart')->__('Delete sizechart'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('bannerslider_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'bannerslider_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'bannerslider_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('sizechart_data') && Mage::registry('sizechart_data')->getId() ) {
40
+ return Mage::helper('extensionsmall_sizechart')->__("Edit sizechart '%s'", $this->htmlEscape(Mage::registry('sizechart_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('extensionsmall_sizechart')->__('Add sizechart');
43
+ }
44
+ }
45
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form(array(
7
+ 'id' => 'edit_form',
8
+ 'action' => $this->getUrl('*/*/save', array('sizechart_id' => $this->getRequest()->getParam('sizechart_id'))),
9
+ 'method' => 'post',
10
+ 'enctype' => 'multipart/form-data'
11
+ )
12
+ );
13
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+
19
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit/Tab/Form.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ $fieldset = $form->addFieldset('sizechart_form', array('legend' => Mage::helper('extensionsmall_sizechart')->__('General information')));
9
+ $fieldset->addField('title', 'text', array(
10
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Title'),
11
+ 'class' => 'required-entry',
12
+ 'required' => true,
13
+ 'name' => 'title',
14
+ ));
15
+ $fieldset->addField('sizes', 'text', array(
16
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Sizes'),
17
+ 'class' => 'required-entry',
18
+ 'required' => true,
19
+ 'name' => 'sizes',
20
+ ));
21
+ $fieldset->addField('bust', 'text', array(
22
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Bust'),
23
+ 'required' => FALSE,
24
+ 'name' => 'bust',
25
+ ));
26
+
27
+ $fieldset->addField('waist', 'text', array(
28
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Waist'),
29
+ 'required' => FALSE,
30
+ 'name' => 'waist',
31
+ ));
32
+ $fieldset->addField('hip', 'text', array(
33
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hips'),
34
+ 'required' => FALSE,
35
+ 'name' => 'hip',
36
+ ));
37
+ /*
38
+ $fieldset->addField('chest', 'text', array(
39
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Chest'),
40
+ 'required' => FALSE,
41
+ 'name' => 'chest',
42
+ ));
43
+ $fieldset->addField('dress_size', 'text', array(
44
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Dress Size'),
45
+ 'required' => FALSE,
46
+ 'name' => 'dress_size',
47
+ ));
48
+
49
+ $fieldset->addField('vest_size', 'text', array(
50
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Vest Size'),
51
+ 'required' => FALSE,
52
+ 'name' => 'vest_size',
53
+ ));
54
+ $fieldset->addField('equivalent_to', 'text', array(
55
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Equivalent To'),
56
+ 'required' => FALSE,
57
+ 'name' => 'equivalent_to',
58
+ ));
59
+ $fieldset->addField('chest_measurement_vest', 'text', array(
60
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Chest Measurement (Vest)'),
61
+ 'required' => FALSE,
62
+ 'name' => 'chest_measurement_vest',
63
+ ));
64
+ $fieldset->addField('waist_measurement_vest', 'text', array(
65
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Waist Measurement (Vest)'),
66
+ 'required' => FALSE,
67
+ 'name' => 'waist_measurement_vest',
68
+ ));
69
+ $fieldset->addField('length_shoulder_to_point', 'text', array(
70
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Length (Shoulder to Point)'),
71
+ 'required' => FALSE,
72
+ 'name' => 'length_shoulder_to_point',
73
+ ));
74
+
75
+ $fieldset->addField('length', 'text', array(
76
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Length'),
77
+ 'required' => FALSE,
78
+ 'name' => 'length',
79
+ ));
80
+ $fieldset->addField('h_waist', 'text', array(
81
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hollow to Waist'),
82
+ 'required' => FALSE,
83
+ 'name' => 'h_waist',
84
+ ));
85
+ $fieldset->addField('h_hem', 'text', array(
86
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hollow to Hem'),
87
+ 'required' => FALSE,
88
+ 'name' => 'h_hem',
89
+ ));
90
+
91
+
92
+ $fieldset->addField('tea_length', 'text', array(
93
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Tea Length'),
94
+ 'required' => FALSE,
95
+ 'name' => 'tea_length',
96
+ ));
97
+ $fieldset->addField('knee_length', 'text', array(
98
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Knee Length'),
99
+ 'required' => FALSE,
100
+ 'name' => 'knee_length',
101
+ ));
102
+ $fieldset->addField('ankle_length', 'text', array(
103
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Ankle Length'),
104
+ 'required' => FALSE,
105
+ 'name' => 'ankle_length',
106
+ ));
107
+ $fieldset->addField('floor_length', 'text', array(
108
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Floor Length'),
109
+ 'required' => FALSE,
110
+ 'name' => 'floor_length',
111
+ ));
112
+ $fieldset->addField('lower_back', 'text', array(
113
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Lower Back'),
114
+ 'required' => FALSE,
115
+ 'name' => 'lower_back',
116
+ ));
117
+ $fieldset->addField('h_hem_floor', 'text', array(
118
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hollow to Hem: Floor'),
119
+ 'required' => FALSE,
120
+ 'name' => 'h_hem_floor',
121
+ ));
122
+ $fieldset->addField('h_hem_tea', 'text', array(
123
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hollow to Hem: Tea'),
124
+ 'required' => FALSE,
125
+ 'name' => 'h_hem_tea',
126
+ ));
127
+ $fieldset->addField('h_hem_knee', 'text', array(
128
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hollow to Hem: Knee'),
129
+ 'required' => FALSE,
130
+ 'name' => 'h_hem_knee',
131
+ ));
132
+ $fieldset->addField('h_hem_short', 'text', array(
133
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Hollow to Hem: Short'),
134
+ 'required' => FALSE,
135
+ 'name' => 'h_hem_short',
136
+ ));
137
+ $fieldset->addField('image', 'image', array(
138
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('Image File'),
139
+ 'required' => false,
140
+ 'name' => 'image',
141
+ ));
142
+ */
143
+ if (Mage::getSingleton('adminhtml/session')->getSizeChartData()) {
144
+ $data = Mage::getSingleton('adminhtml/session')->getSizeChartData();
145
+ Mage::getSingleton('adminhtml/session')->setSizeChartData(null);
146
+ } elseif (Mage::registry('sizechart_data')) {
147
+ $data = Mage::registry('sizechart_data')->getData();
148
+ }
149
+ $form->setValues($data);
150
+ return parent::_prepareForm();
151
+ }
152
+
153
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('sizechart_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('extensionsmall_sizechart')->__('Information'));
10
+ }
11
+
12
+ protected function _beforeToHtml() {
13
+ $this->addTab('form_section', array(
14
+ 'label' => Mage::helper('extensionsmall_sizechart')->__('General Information'),
15
+ 'title' => Mage::helper('extensionsmall_sizechart')->__('General Information'),
16
+ 'content' => $this->getLayout()->createBlock('extensionsmall_sizechart/adminhtml_edit_tab_form')->toHtml(),
17
+ ));
18
+
19
+ // $this->addTab('display_section', array(
20
+ // 'label' => Mage::helper('sizechart')->__('Categories'),
21
+ // 'url' => $this->getUrl('*/*/categories', array('_current' => true)),
22
+ // 'class' => 'ajax',
23
+ // ));
24
+
25
+ return parent::_beforeToHtml();
26
+ }
27
+
28
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/List.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_List extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'extensionsmall_sizechart';
8
+ $this->_controller = 'adminhtml_list';
9
+ $this->_headerText = Mage::helper('extensionsmall_sizechart')->__('Sizechart List');
10
+
11
+ parent::__construct();
12
+ # $this->_removeButton('add');
13
+ }
14
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/List/Grid.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_List_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+
8
+ // Set some defaults for our grid
9
+ $this->setDefaultSort('sizechart_id');
10
+ $this->setId('sizechart_list_grid');
11
+ $this->setDefaultDir('asc');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _getCollectionClass() {
16
+ // This is the model we are using for the grid
17
+ return 'extensionsmall_sizechart/sizechart_collection';
18
+ }
19
+
20
+ protected function _prepareCollection() {
21
+ // Get and set our collection for the grid
22
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
23
+ $this->setCollection($collection);
24
+
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns() {
29
+ // Add the columns that should appear in the grid
30
+ $this->addColumn('sizechart_id', array(
31
+ 'header' => $this->__('ID'),
32
+ 'align' => 'right',
33
+ 'width' => '50px',
34
+ 'index' => 'sizechart_id'
35
+ )
36
+ );
37
+ $this->addColumn('title', array(
38
+ 'header' => $this->__('Title'),
39
+ 'index' => 'title'
40
+ )
41
+ );
42
+ $this->addColumn('sizes', array(
43
+ 'header' => $this->__('Sizes'),
44
+ 'index' => 'sizes'
45
+ )
46
+ );
47
+ return parent::_prepareColumns();
48
+ }
49
+
50
+ public function getRowUrl($row) {
51
+ // This is where our row data will link to
52
+ return $this->getUrl('*/*/edit', array('sizechart_id' => $row->getSizechartId()));
53
+ }
54
+
55
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Adminhtml/System/Config/Form/Field/Color.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Adminhtml_System_Config_Form_Field_Color extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
+ $html = '<script type="text/javascript" src="' . Mage::getBaseUrl('js') . 'procolor-1.0/procolor.compressed.js' . '"></script>';
7
+ $input = new Varien_Data_Form_Element_Text();
8
+ $input->setForm($element->getForm())
9
+ ->setElement($element)
10
+ ->setValue($element->getValue())
11
+ ->setHtmlId($element->getHtmlId())
12
+ ->setName($element->getName())
13
+ ->setStyle('width: 60px')
14
+ ->addClass('validate-hex');
15
+ $html .= $input->getHtml();
16
+ $html .= $this->_getProcolorJs($element->getHtmlId());
17
+ $html .= $this->_addHexValidator();
18
+ return $html;
19
+ }
20
+
21
+ protected function _getProcolorJs($htmlId) {
22
+ return '<script type="text/javascript">ProColor.prototype.attachButton(\'' . $htmlId . '\', { imgPath:\'' . Mage::getBaseUrl('js') . 'procolor-1.0/' . 'img/procolor_win_\', showInField: true });</script>';
23
+ }
24
+
25
+ protected function _addHexValidator() {
26
+ return '<script type="text/javascript">Validation.add(\'validate-hex\', \'' . Mage::helper('extensionsmall_sizechart')->__('Please enter a valid hex color code') . '\', function(v) {
27
+ return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(v);
28
+ });</script>';
29
+ }
30
+
31
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Sizechart.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Sizechart extends Mage_Core_Block_Template {
4
+
5
+ protected $config;
6
+ # protected $data = array();
7
+ protected $columns = array();
8
+
9
+ public function getConfig() {
10
+ if (!isset($this->config)) {
11
+ $config['sizechart_table_heading_color'] = Mage::getStoreConfig('sizechart_options/style/sizechart_table_heading_color');
12
+ $this->config = $config;
13
+ }
14
+ return $this->config;
15
+ }
16
+
17
+ public function getTbody() {
18
+ $data = $this->getColumns();
19
+ if(!isset($data[0]['values'])){
20
+ return null;
21
+ }
22
+ $rows = count($data[0]['values']);
23
+ $colums = count($data);
24
+ $html = '';
25
+ for ($i = 0; $i < $rows; $i++) {
26
+ $html .= '<tr>';
27
+ for ($j = 0; $j < $colums; $j++) {
28
+ if (isset($data[$j]['values'][$i])) {
29
+ $html .= '<td>' . $data[$j]['values'][$i] . '</td>';
30
+ }else{
31
+ $html .= '<td></td>';
32
+ }
33
+ }
34
+ $html .= '</tr>';
35
+ }
36
+ return $html;
37
+ }
38
+
39
+ public function getThead() {
40
+ $columns = $this->getColumns();
41
+ $html = '<tr>';
42
+ foreach ($columns as $value) {
43
+ $html .= '<th>' . $value['name'] . '</th>';
44
+ }
45
+ $html .= '</tr>';
46
+ return $html;
47
+ }
48
+
49
+ public function getColumns() {
50
+ if (empty($this->columns)) {
51
+ $chartName = Mage::registry('current_product')->getData('size_chart');
52
+ $model = Mage::getModel('extensionsmall_sizechart/sizechart');
53
+ $chart = $model->getChart($chartName);
54
+ if (empty($chart)) {
55
+ $chart = $model->getChart('Default');
56
+ }
57
+ $columnNames = array(
58
+ 'sizes' => 'Size',
59
+ 'bust' => 'Bust',
60
+ 'waist' => 'Waist',
61
+ 'hip' => 'Hips',
62
+ );
63
+ $i = 0;
64
+ foreach ($columnNames as $key => $value) {
65
+ $string = trim($chart[$key]);
66
+ if (!empty($string)) {
67
+ $this->columns[$i]['name'] = $value;
68
+ $this->columns[$i]['values'] = explode(',', $string);
69
+ $i++;
70
+ }
71
+ }
72
+ }
73
+ return $this->columns;
74
+ }
75
+
76
+ public function getLeftColumnWidth() {
77
+ $columnsNo = count($this->getColumns());
78
+ if ($columnsNo == 4) {
79
+ return '375px';
80
+ } else {
81
+ return ($columnsNo * 80) . 'px';
82
+ }
83
+ }
84
+
85
+ }
app/code/community/ExtensionsMall/SizeChart/Block/Sizechart/Anchor.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Block_Sizechart_Anchor extends Mage_Core_Block_Template {
4
+
5
+ public function showAnchor() {
6
+ $chartName = Mage::registry('current_product')->getData('size_chart');
7
+ $model = Mage::getModel('extensionsmall_sizechart/sizechart');
8
+ if ($model->chartExists($chartName)) {
9
+ return TRUE;
10
+ } else {
11
+ return FALSE;
12
+ }
13
+ }
14
+
15
+ }
app/code/community/ExtensionsMall/SizeChart/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ }
app/code/community/ExtensionsMall/SizeChart/Model/Resource/Setup.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
4
+
5
+ public function getCatalogSetup() {
6
+ return new Mage_Catalog_Model_Resource_Setup('extensionsmall_sizechart_setup');
7
+ }
8
+
9
+ public function getCustomerSetup() {
10
+ return new Mage_Customer_Model_Resource_Setup('extensionsmall_sizechart_setup');
11
+ }
12
+
13
+ }
app/code/community/ExtensionsMall/SizeChart/Model/Resource/Sizechart.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Model_Resource_SizeChart extends Mage_Core_Model_Mysql4_Abstract {
4
+
5
+ public function _construct() {
6
+ $this->_init('extensionsmall_sizechart/sizechart', 'sizechart_id');
7
+ }
8
+
9
+ }
app/code/community/ExtensionsMall/SizeChart/Model/Resource/Sizechart/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Model_Resource_SizeChart_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('extensionsmall_sizechart/sizechart');
8
+ }
9
+
10
+ }
app/code/community/ExtensionsMall/SizeChart/Model/Sizechart.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Model_SizeChart extends Mage_Core_Model_Abstract {
4
+
5
+ const IMAGEDIR = 'sizechart/';
6
+
7
+ public function _construct() {
8
+ parent::_construct();
9
+ $this->_init('extensionsmall_sizechart/sizechart');
10
+ }
11
+
12
+ public function saveImage() {
13
+ if (isset($_FILES['image']['name']) && $_FILES['image']['name'] != '') {
14
+ try {
15
+ $uploader = new Varien_File_Uploader('image');
16
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
17
+ $uploader->setAllowRenameFiles(false);
18
+ $uploader->setFilesDispersion(false);
19
+ // We set media as the upload dir
20
+ $path = Mage::getBaseDir('media') . DS . 'sizechart' . DS;
21
+ $result = $uploader->save($path, $_FILES['image']['name']);
22
+ return self::IMAGEDIR . $result['file'];
23
+ } catch (Exception $e) {
24
+ return $_FILES['image']['name'];
25
+ }
26
+ }
27
+ }
28
+
29
+ public function getChart($chartTitle) {
30
+ $collection = $this->getCollection();
31
+ $collection->addFieldToFilter('title', $chartTitle);
32
+ $data = $collection->getFirstItem()->getData();
33
+ return $data;
34
+ }
35
+ public function chartExists($chartName) {
36
+ $data = $this->getChart($chartName);
37
+ if (empty($data)) {
38
+ return FALSE;
39
+ }else {
40
+ return TRUE;
41
+ }
42
+ }
43
+
44
+ }
app/code/community/ExtensionsMall/SizeChart/controllers/Adminhtml/ExtensionsmallsizechartController.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ExtensionsMall_SizeChart_Adminhtml_ExtensionsmallsizechartController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ public function indexAction() {
6
+ $this->_title($this->__('Catalog'))->_title($this->__('Sizecharts'));
7
+ $this->loadLayout();
8
+ $this->_setActiveMenu('catalog');
9
+ $this->_addContent($this->getLayout()->createBlock('extensionsmall_sizechart/adminhtml_list'));
10
+ $this->renderLayout();
11
+ }
12
+
13
+ public function newAction() {
14
+ $this->_forward('edit');
15
+ }
16
+
17
+ public function editAction() {
18
+ $sizechart_id = $this->getRequest()->getParam('sizechart_id');
19
+ $model = Mage::getModel('extensionsmall_sizechart/sizechart')->load($sizechart_id);
20
+
21
+ if ($model->getSizechartId() || $sizechart_id == 0) {
22
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
23
+ if (!empty($data)) {
24
+ $model->setData($data);
25
+ }
26
+ Mage::register('sizechart_data', $model);
27
+ $this->_title($this->__('Sizechart'))->_title($this->__('Manage sizechart'));
28
+ if ($model->getSizechartId()) {
29
+ $this->_title($model->getTitle());
30
+ } else {
31
+ $this->_title($this->__('New sizechart'));
32
+ }
33
+ $this->loadLayout();
34
+ $this->_setActiveMenu('sizechart/items');
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
36
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+ $this->_addContent($this->getLayout()->createBlock('extensionsmall_sizechart/adminhtml_edit'))
39
+ ->_addLeft($this->getLayout()->createBlock('extensionsmall_sizechart/adminhtml_edit_tabs'));
40
+ $this->renderLayout();
41
+ } else {
42
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('extensionsmall_sizechart')->__('Item does not exist'));
43
+ $this->_redirect('*/*/');
44
+ }
45
+ }
46
+
47
+ public function saveAction() {
48
+ $data = $this->getRequest()->getPost();
49
+ if ($data) {
50
+ $model = Mage::getModel('extensionsmall_sizechart/sizechart');
51
+ if (isset($data['image']['delete']) && $data['image']['delete'] == 1) {
52
+ $data['image'] = '';
53
+ } elseif (isset($data['image']) && is_array($data['image'])) {
54
+ $data['image'] = $data['image']['value'];
55
+ }
56
+ $data['image'] = $model->saveImage();
57
+
58
+ $model->setData($data)->setSizechartId($this->getRequest()->getParam('sizechart_id'));
59
+ /* print_r($model->getData());
60
+ die();*/
61
+ try {
62
+ $model->save();
63
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('extensionsmall_sizechart')->__('Item was successfully saved'));
64
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
65
+ if ($this->getRequest()->getParam('back')) {
66
+ $this->_redirect('*/*/edit', array('sizechart_id' => $model->getSizechartId()));
67
+ return;
68
+ }
69
+ $this->_redirect('*/*/');
70
+ return;
71
+ } catch (Exception $e) {
72
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
73
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
74
+ $this->_redirect('*/*/edit', array('sizechart_id' => $this->getRequest()->getParam('sizechart_id')));
75
+ return;
76
+ }
77
+ }
78
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sizechart')->__('Unable to find item to save'));
79
+ $this->_redirect('*/*/');
80
+ }
81
+
82
+ }
app/code/community/ExtensionsMall/SizeChart/data/extensionsmall_sizechart_setup/data-install-1.0.0.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $data = array(
4
+ 'title' => 'Default',
5
+ 'sizes' => '0,2,4,6,8,10,12,14,16,18,20,22,24,26',
6
+ 'bust' => '32,33,34,35,36,37,38.5,40,42,44,46,48.5,51,53.5',
7
+ 'waist' => '24.5,25.5,26.5,27.5,28.5,29.5,31,32.5,34.5,36.5,39,41.5,44,47',
8
+ 'hip' => '35.5,36.5,37.5,38.5,39.5,40.5,42,43.5,45.5,47.5,49.5,52,54.5,57'
9
+ );
10
+
11
+ Mage::getModel('extensionsmall_sizechart/sizechart')->setData($data)->save();
app/code/community/ExtensionsMall/SizeChart/etc/adminhtml.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <catalog>
5
+ <children>
6
+ <extensionsmall_sizechart translate="title" module="extensionsmall_sizechart">
7
+ <sort_order>30</sort_order>
8
+ <title>Sizechart</title>
9
+ <!-- <action>adminhtml/sizechart/index/</action>-->
10
+ <action>adminhtml/extensionsmallsizechart/index</action>
11
+ </extensionsmall_sizechart>
12
+ </children>
13
+ </catalog>
14
+ </menu>
15
+ <acl>
16
+ <resources>
17
+ <admin>
18
+ <children>
19
+ <extensionsmall_sizechart translate="title" module="extensionsmall_sizechart">
20
+ <title>Sizechart</title>
21
+ <sort_order>1</sort_order>
22
+ </extensionsmall_sizechart>
23
+ </children>
24
+ </admin>
25
+ </resources>
26
+ </acl>
27
+ </config>
app/code/community/ExtensionsMall/SizeChart/etc/config.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ExtensionsMall_SizeChart>
5
+ <version>1.0.0</version>
6
+ </ExtensionsMall_SizeChart>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <extensionsmall_sizechart>
11
+ <class>ExtensionsMall_SizeChart_Model</class>
12
+ <resourceModel>extensionsmall_sizechart_resource</resourceModel>
13
+ </extensionsmall_sizechart>
14
+ <extensionsmall_sizechart_resource>
15
+ <class>ExtensionsMall_SizeChart_Model_Resource</class>
16
+ <entities>
17
+ <sizechart>
18
+ <table>extensionsmall_sizechart</table>
19
+ </sizechart>
20
+ </entities>
21
+ </extensionsmall_sizechart_resource>
22
+ </models>
23
+ <resources>
24
+ <extensionsmall_sizechart_setup>
25
+ <setup>
26
+ <module>ExtensionsMall_SizeChart</module>
27
+ <class>Mage_Catalog_Model_Resource_Setup</class>
28
+ </setup>
29
+ </extensionsmall_sizechart_setup>
30
+ </resources>
31
+ <blocks>
32
+ <extensionsmall_sizechart>
33
+ <class>ExtensionsMall_SizeChart_Block</class>
34
+ </extensionsmall_sizechart>
35
+ </blocks>
36
+ <helpers>
37
+ <extensionsmall_sizechart>
38
+ <class>ExtensionsMall_SizeChart_Helper</class>
39
+ </extensionsmall_sizechart>
40
+ </helpers>
41
+ </global>
42
+ <frontend>
43
+ <layout>
44
+ <updates>
45
+ <sizechart>
46
+ <file>sizechart.xml</file>
47
+ </sizechart>
48
+ </updates>
49
+ </layout>
50
+ </frontend>
51
+ <admin>
52
+ <routers>
53
+ <adminhtml>
54
+ <args>
55
+ <modules>
56
+ <extensionsmallsizechart before="Mage_Adminhtml">ExtensionsMall_SizeChart_Adminhtml</extensionsmallsizechart>
57
+ </modules>
58
+ </args>
59
+ </adminhtml>
60
+ </routers>
61
+ </admin>
62
+ <adminhtml>
63
+ <acl>
64
+ <resources>
65
+ <admin>
66
+ <children>
67
+ <system>
68
+ <children>
69
+ <config>
70
+ <children>
71
+ <sizechart_options>
72
+ <title>Sizechart Module Section</title>
73
+ </sizechart_options>
74
+ </children>
75
+ </config>
76
+ </children>
77
+ </system>
78
+ </children>
79
+ </admin>
80
+ </resources>
81
+ </acl>
82
+ </adminhtml>
83
+ <!-- START DEFAULTS -->
84
+ <default>
85
+ <sizechart_options>
86
+ <style>
87
+ <enabled>1</enabled>
88
+ <sizechart_table_heading_color>#3399CC</sizechart_table_heading_color>
89
+ </style>
90
+ <general>
91
+ <enabled>1</enabled>
92
+ <include_jquery>1</include_jquery>
93
+ </general>
94
+ </sizechart_options>
95
+ </default>
96
+ <!-- END DEFAULTS -->
97
+ </config>
app/code/community/ExtensionsMall/SizeChart/etc/system.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <tabs>
3
+ <extensionsmall translate="label" module="extensionsmall_sizechart">
4
+ <label>ExtensionsMall</label>
5
+ <sort_order>300</sort_order>
6
+ </extensionsmall>
7
+ </tabs>
8
+ <sections>
9
+ <sizechart_options translate="label" module="extensionsmall_sizechart">
10
+ <label>SizeChart Settings</label>
11
+ <tab>extensionsmall</tab>
12
+ <frontend_type>text</frontend_type>
13
+ <sort_order>1000</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <general translate="label">
19
+ <label>General</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <include_jquery>
27
+ <label>Include jQuery</label>
28
+ <frontend_type>select</frontend_type>
29
+ <source_model>adminhtml/system_config_source_yesno</source_model>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </include_jquery>
35
+ </fields>
36
+ </general>
37
+ <style translate="label">
38
+ <label>Style</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>20</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <fields>
45
+ <sizechart_table_heading_color>
46
+ <label>Table Heading Color</label>
47
+ <frontend_type>text</frontend_type>
48
+ <frontend_model>extensionsmall_sizechart/adminhtml_system_config_form_field_color</frontend_model>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </sizechart_table_heading_color>
54
+ </fields>
55
+ </style>
56
+ </groups>
57
+ </sizechart_options>
58
+ </sections>
59
+ </config>
app/code/community/ExtensionsMall/SizeChart/sql/extensionsmall_sizechart_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('extensionsmall_sizechart/sizechart')};
10
+ CREATE TABLE {$this->getTable('extensionsmall_sizechart/sizechart')} (
11
+ `sizechart_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `sizes` varchar(255) NULL default NULL,
14
+ `bust` varchar(255) NULL default NULL,
15
+ `waist` varchar(255) NULL default NULL,
16
+ `hip` varchar(255) NULL default NULL,
17
+ PRIMARY KEY (`sizechart_id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+ ");
20
+
21
+ $this->addAttribute('catalog_product', 'size_chart', array(
22
+ 'group' => 'General',
23
+ 'input' => 'text',
24
+ 'type' => 'text',
25
+ 'label' => 'Size Chart',
26
+ 'backend' => '',
27
+ 'visible' => true,
28
+ 'required' => false,
29
+ 'visible_on_front' => true,
30
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
31
+ ));
32
+
33
+ $installer->endSetup();
app/design/frontend/base/default/layout/sizechart.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <stylesheet>sizechart/sizechart.css</stylesheet>
7
+ </action>
8
+ <action method="addJs" ifconfig="sizechart_options/general/include_jquery">
9
+ <script>sizechart/jquery-1.11.3.min.js</script>
10
+ </action>
11
+ <action method="addJs">
12
+ <script>sizechart/sizechart.js</script>
13
+ </action>
14
+ <action method="addJs">
15
+ <script>sizechart/jquery.fancybox.pack.js</script>
16
+ </action>
17
+ <action method="addItem">
18
+ <type>js_css</type>
19
+ <name>sizechart/jquery.fancybox.css</name>
20
+ </action>
21
+ </reference>
22
+ <reference name="content">
23
+ <block type="extensionsmall_sizechart/sizechart" name="sizechart" template="sizechart/sizechart.phtml" after="-" />
24
+ </reference>
25
+ </catalog_product_view>
26
+ <PRODUCT_TYPE_simple>
27
+ <reference name="product.info">
28
+ <block type="extensionsmall_sizechart/sizechart_anchor" name="sizechart_anchor" template="sizechart/anchor.phtml" before="-" />
29
+ </reference>
30
+ </PRODUCT_TYPE_simple>
31
+ <PRODUCT_TYPE_configurable>
32
+ <reference name="product.info.options.wrapper">
33
+ <block type="extensionsmall_sizechart/sizechart_anchor" name="sizechart_anchor" template="sizechart/anchor.phtml" before="-" />
34
+ </reference>
35
+ </PRODUCT_TYPE_configurable>
36
+ </layout>
app/design/frontend/base/default/template/sizechart/anchor.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php if($this->showAnchor()): ?>
2
+ <a id="sizechartbutton" href="#sizechartbox"><img alt="Size chart" src="<?php echo $this->getSkinUrl('sizechart/images/size-chart-button.png');?>"></a>
3
+ <?php endif;?>
app/design/frontend/base/default/template/sizechart/sizechart.phtml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $config = $this->getConfig();
3
+ $sizeChartWitdh = $this->getLeftColumnWidth();
4
+ ?>
5
+ <div id="sizechartbox" style="display:none;">
6
+ <div id="sizechart">
7
+ <div>
8
+ <h2>Size Chart</h2>
9
+ </div>
10
+ <div class="left-column" style="width: <?php echo $sizeChartWitdh ?>">
11
+ <div class="size">
12
+ <div class="measurements">
13
+ <p>Find your size for this dress:</p>
14
+ <form id="sizechart_form" name="sizechart_form">
15
+ <table>
16
+ <tr>
17
+ <td><label for="bust">Bust:</label><br /><input name="bust" value="" type="text" size="3" id="bust" /></td>
18
+ <td><label for="waist">Waist:</label><br /><input name="waist" value="" type="text" size="3" id="waist" /></td>
19
+ <td><label for="hip">Hip:</label><br /><input name="hip" value="" type="text" size="3" id="hip" /></td>
20
+ </tr>
21
+ </table>
22
+ </form>
23
+ <p><a href="#" id="convertsizeunits">Convert to Centimeters</a></p>
24
+ </div>
25
+ <div class="results">
26
+ <p>Based on your measurements we recommend ordering size <strong id="size-value"></strong></p>
27
+ </div>
28
+ </div>
29
+ <div class="chart">
30
+ <table>
31
+ <thead id="chart_head" style="background-color: <?php echo $config['sizechart_table_heading_color'] ?>">
32
+ <?php echo $this->getThead(); ?>
33
+ </thead>
34
+ <tbody id="chart_values">
35
+ <?php echo $this->getTbody(); ?>
36
+ </tbody>
37
+ </table>
38
+ </div>
39
+ <div class="country">
40
+ <table>
41
+ <thead style="background-color: <?php echo $config['sizechart_table_heading_color'] ?>">
42
+ <tr><th colspan="15">Country</th>
43
+ </thead>
44
+ <tbody>
45
+ <tr><td>US</td><td>0</td><td>2</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>16</td><td>18</td><td>20</td><td>22</td><td>24</td><td>26</td></tr>
46
+ <tr><td>UK</td><td>2</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>16</td><td>18</td><td>20</td><td>22</td><td>24</td><td>26</td><td>28</td></tr>
47
+ <tr><td>AU</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>16</td><td>18</td><td>20</td><td>22</td><td>24</td><td>26</td><td>28</td><td>30</td></tr>
48
+ <tr><td>EU</td><td>30</td><td>32</td><td>34</td><td>36</td><td>38</td><td>40</td><td>42</td><td>44</td><td>46</td><td>48</td><td>50</td><td>52</td><td>54</td><td>56</td></tr>
49
+ </tbody>
50
+
51
+ </table>
52
+ </div>
53
+ <div class="notes">
54
+ <p>*The following size recommendation is based on the current measurements. The final responsibility on choosing a size is the customers.</p>
55
+ </div>
56
+ </div>
57
+ <div class="right-column">
58
+ <img src="<?php echo $this->getSkinUrl('sizechart/images/sizechart-siluete.jpg'); ?>" />
59
+ </div>
60
+ <div class="sizechart-credits">
61
+ Provided by <a href="http://www.extensionmall.com/" title="ExtensionsMall" target="_blank">ExtensionsMall</a>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ <script type="text/javascript">
66
+ document.observe("dom:loaded", function () {
67
+ jQuery("#sizechartbutton").fancybox();
68
+ // jQuery("a#sizechartbox").colorbox({inline:true, href:"#sizechart"});
69
+ var sizeChartObject = new sizeChart('sizechart_form');
70
+ $('convertsizeunits').on('click', function (event) {
71
+ sizeChartObject.changeUnits();
72
+ Event.stop(event);
73
+ });
74
+ new Form.Observer('sizechart_form', 0.5, function () {
75
+ sizeChartObject.findSize();
76
+ });
77
+ });
78
+ </script>
app/etc/modules/ExtensionsMall_SizeChart.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ExtensionsMall_SizeChart>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </ExtensionsMall_SizeChart>
8
+ </modules>
9
+ </config>
js/procolor-1.0/api.html ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>API - ProColor</title>
8
+ <script type='text/javascript' src='prototype.compressed.js'></script>
9
+ <script type='text/javascript' src='procolor.compressed.js'></script>
10
+ <link rel='stylesheet' type='text/css' href='docs.css' />
11
+ </head>
12
+
13
+ <body><div class='wrapper'>
14
+
15
+ <!--============================================================================================-->
16
+
17
+ <div class='header'>
18
+
19
+ <h1 style='margin-bottom:0;'>ProColor</h1>
20
+ <p style='margin-top:0;font-style:italic;color:#999;'>Copyright &copy; 2009 by the Phantom Inker. All rights reserved.</p>
21
+
22
+ <p><a href='index.html'>Overview &amp; Usage</a>
23
+ | <a href='options.html'>Options</a>
24
+ | <b>Public API</b>
25
+ | <a href='examples.html'>Examples</a>
26
+ | <a href='license.html'>License</a></p>
27
+
28
+ </div>
29
+
30
+ <!--============================================================================================-->
31
+ <hr />
32
+
33
+ <h2>ProColor Public API</h2>
34
+
35
+ <p>Many of ProColor's methods and members are for internal use only. However, these members
36
+ and methods are all public:</p>
37
+
38
+ <ul class='options'>
39
+ <li><tt>new ProColor(options)</tt><br />
40
+ Creates, displays, and returns a new ProColor object with the given options.</li>
41
+
42
+ <li><tt>procolor.color</tt><br />
43
+ The current color as selected by the user. This will always be a string in canonical hex RGB
44
+ form, '<tt>#RRGGBB</tt>".</li>
45
+
46
+ <li><tt>procolor.div</tt><br />
47
+ The dynamically-created containing element of the color-picker and all of its child controls.
48
+ This element is publicly-visible, but its child elements should be considered implementation
49
+ details, and they can and will likely change in future versions of ProColor.</li>
50
+
51
+ <li><tt>procolor.options.imgPath</tt><br />
52
+ This variable is used to control the image path used by the automatic-attachment routine,
53
+ which creates ProColor objects attached to <tt>&lt;input&gt;</tt> controls whose classes
54
+ contain '<tt>procolor</tt>'. The default image path is '<tt>img/procolor_win_</tt>'. You
55
+ must set this value in your page's <tt>&lt;head&gt;</tt> if you are going to set it at all.</li>
56
+
57
+ <li><tt>procolor.options.showInField</tt><br />
58
+ This variable controls how the automatically-attached ProColor objects will have their
59
+ <tt>showInField</tt> option set. You
60
+ must set this value in your page's <tt>&lt;head&gt;</tt> if you are going to set it at all.</li>
61
+
62
+ <li><tt>procolor.positionPopup()</tt><br />
63
+ If this is a popup and the associated input element is moved on the page, you should call this
64
+ method to reposition the popup above or below the moved input element.</li>
65
+
66
+ <li><tt>procolor.close()</tt><br />
67
+ Closes and destroys a color-picker. The ProColor object will still exist after calling this
68
+ function, but none of its elements will exist anymore. Note that the <tt>procolor.color</tt>
69
+ member will still be valid after this is called.</li>
70
+
71
+ <li><tt>procolor.update(mode, color, sources)</tt><br />
72
+ Programmatically change the selected color. <tt>mode</tt> must be either <tt>"rgb"</tt> or
73
+ <tt>"hsb"</tt>, and the <tt>color</tt> must be an object of one of the following two forms,
74
+ depending on the mode:<br />
75
+ <br />
76
+ <tt>&nbsp;&nbsp;&nbsp;&nbsp;{ r:red, g:green, b:blue }</tt><br />
77
+ <tt>&nbsp;&nbsp;&nbsp;&nbsp;{ hue:hue, sat:saturation, brt:brightness</tt><br />
78
+ <br />
79
+ The RGB values range from 0 to 255, inclusive, and the HSB values range from 0 to 359 (hue)
80
+ and 0 to 100 (saturation &amp; brightness). Fractional values are allowed, and values
81
+ outside allowed ranges will be clipped.<br />
82
+ <br />
83
+ The <tt>sources</tt> is an array of strings describing parts of the color-picker that
84
+ should <i>not</i> be updated. If <tt>update()</tt> is called externally (i.e., by you),
85
+ this array should always be empty (i.e., it should always be <tt>[]</tt>).<br />
86
+ <br />
87
+ This method updates the visual appearance of the color-picker, and also updates the
88
+ input field (if appropriate) and updates <tt>procolor.color</tt>.</li>
89
+
90
+ <li><tt>procolor.formatOutput(color, format)</tt><br />
91
+ Given a color in a recognizable format (like "#RRGGBB"), convert that color to the
92
+ given output format. This uses the same formatting logic as the <tt>outputFormat</tt>
93
+ option above.</li>
94
+
95
+ <li><tt>procolor.decodeHexColor(color)</tt><br />
96
+ Given a color in a recognizable format (like "#RRGGBB"), convert that to a clean RGB object,
97
+ same as would be passed to <tt>procolor.update()</tt>. This tries several different ways
98
+ to decode the color. If it is unable to decode the color, it returns <tt>false</tt> instead
99
+ of an RGB object.</li>
100
+
101
+ <li><tt>procolor.trueBrightness(rgb)</tt><br />
102
+ Given an RGB object describing a color, this returns the brightness of that object, on the
103
+ range of [0,1]. This is weighted according to human color perception, with weights of
104
+ 0.3, 0.59, and 0.11, for red, green, and blue respectively.</li>
105
+
106
+ <li><tt>procolor.computeTextColor(rgb)</tt><br />
107
+ Given an RGB object describing a background color, this will return a new RGB object
108
+ describing a similarly-hued color that can be used for displaying legible text against
109
+ that background.</li>
110
+
111
+ <li><tt>procolor.RGBtoHSB(rgb)</tt><br />
112
+ Given an RGB color object, this returns an equivalent HSB color object,
113
+ always with valid (but possibly with fractional) integer values.</li>
114
+
115
+ <li><tt>procolor.HSBtoRGB(rgb)</tt><br />
116
+ Given an HSB color object, this returns an equivalent RGB color object,
117
+ always with valid (but possibly with fractional) integer values.</li>
118
+
119
+ <li><tt>procolor.acceptAndClose()</tt><br />
120
+ Simulate the user pressing Enter or double-clicking on the color-picker; this calls
121
+ <tt>options.onAcceptClick</tt>, and then <tt>procolor.Close()</tt> (but only if this
122
+ is in '<tt>popup</tt>' mode.</li>
123
+
124
+ <li><tt>procolor.cancelAndClose()</tt><br />
125
+ Simulate the user pressing Esc or clicking outside the color-picker; this calls
126
+ <tt>options.onCancelClick</tt>, and then <tt>procolor.Close()</tt> (but only if this
127
+ is in '<tt>popup</tt>' mode.</li>
128
+ </ul>
129
+
130
+ <!--============================================================================================-->
131
+ <hr />
132
+
133
+ <h2>MouseCapture Public API</h2>
134
+
135
+ <p>ProColor uses a small library named "MouseCapture" for performing mouse tracking, and you can
136
+ use it in your own programs. Its usage is very simple; create a MouseCapture object, call
137
+ mousecapture.begin(), and then within your callback, call mousecapture.end() when the mouse
138
+ button is released. Its API is documented below:</p>
139
+
140
+ <ul class='options'>
141
+ <li><tt>new MouseCapture()</tt><br />
142
+ Creates and returns a new MouseCapture object with the given options. A MouseCapture
143
+ object can be used to capture mouse input from a mouse-button-press until its release.</li>
144
+
145
+ <li><tt>mousecapture.setCursor(cursor)</tt><br />
146
+ In the current mouse capture, change the mouse cursor to the given type. This takes a
147
+ standard CSS cursor type, such as 'default' or 'pointer' or 'crosshair'.</li>
148
+
149
+ <li><tt>mousecapture.begin(callback)</tt><br />
150
+ Begin the mouse capture. This will capture all mouse and keyboard input events and send
151
+ them to the given callback function. The callback will be called as <tt>callback(event, eventType)</tt>.</li>
152
+
153
+ <li><tt>mousecapture.end()</tt><br />
154
+ This ends a mouse capture and allows events to propagate normally.</li>
155
+ </ul>
156
+
157
+ </div></body>
158
+ </html>
js/procolor-1.0/docs.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ body {
3
+ font: 11pt Verdana,Tahoma,Arial,Helv,Helvetica;
4
+ background-color: #DEF;
5
+ color: #000;
6
+ padding: 0;
7
+ margin: 0;
8
+ }
9
+
10
+ div.wrapper {
11
+ margin: 0 2em;
12
+ padding: 0.5em 1em;
13
+ border-left: 1px solid #CDE;
14
+ border-right: 1px solid #CDE;
15
+ background-color: #FFF;
16
+ }
17
+
18
+ div.header {
19
+ text-align:center;
20
+ }
21
+
22
+ h1 { margin: 0; }
23
+
24
+ input {
25
+ border: 1px solid #999;
26
+ width: 6em;
27
+ }
28
+
29
+ ul.options li {
30
+ margin-top: 1em;
31
+ }
32
+
33
+ ul.collapsed {
34
+ margin-top: 0.5em;
35
+ margin-bottom: 0.5em;
36
+ }
37
+
38
+ ul.collapsed li {
39
+ margin-top: 0;
40
+ }
41
+
42
+ xmp {
43
+ font: 10pt Courier,mono,monospace;
44
+ }
js/procolor-1.0/examples.html ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>Examples - ProColor</title>
8
+ <script type='text/javascript' src='prototype.compressed.js'></script>
9
+ <script type='text/javascript' src='procolor.compressed.js'></script>
10
+ <link rel='stylesheet' type='text/css' href='docs.css' />
11
+ </head>
12
+
13
+ <body><div class='wrapper'>
14
+
15
+ <!--============================================================================================-->
16
+
17
+ <div class='header'>
18
+
19
+ <h1 style='margin-bottom:0;'>ProColor</h1>
20
+ <p style='margin-top:0;font-style:italic;color:#999;'>Copyright &copy; 2009 by the Phantom Inker. All rights reserved.</p>
21
+
22
+ <p><a href='index.html'>Overview &amp; Usage</a>
23
+ | <a href='options.html'>Options</a>
24
+ | <a href='api.html'>Public API</a>
25
+ | <b>Examples</b>
26
+ | <a href='license.html'>License</a></p>
27
+
28
+ </div>
29
+
30
+ <!--============================================================================================-->
31
+ <hr />
32
+
33
+ <h2>Example #1</h2>
34
+
35
+ <p>This first example demonstrates including the ProColor color-picker as a static page element.
36
+ Notice that the color-picker window is tied to the input textbox, and that the events generated
37
+ by the color-picker are captured and displayed below the color-picker. Notice also that we
38
+ use unusual color-formatting here, which ProColor allows.</p>
39
+
40
+ <input id="hex" style="width: 6em;" type="text" />
41
+
42
+ <div id="colorpicker"></div>
43
+
44
+ <div style="margin: 1em 0pt 3em;">
45
+ Most recent action: <span id="log"><b>none</b></span>
46
+ </div>
47
+
48
+ <script type="text/javascript"><!--
49
+ new ProColor({
50
+ mode:'static',
51
+ parent:'colorpicker',
52
+ imgPath:'img/procolor_win_',
53
+ input:'hex',
54
+ showInField: true,
55
+ color:'#FF0000',
56
+ outputFormat:'(#{RR}{GG}{BB})',
57
+ onChanged:function(pc) { $('log').innerHTML = "<b>choose " + pc.color + "</b>"; },
58
+ onAcceptClick:function(pc) { $('log').innerHTML = "<b>done " + pc.color + "</b>"; },
59
+ onCancelClick:function(pc) { $('log').innerHTML = "<b>cancel</b>"; },
60
+ onCloseButton:function(pc) { $('log').innerHTML = "<b>close</b>"; }
61
+ });
62
+ --></script>
63
+
64
+ <h4 style='margin:0;'>Complete source code:</h4>
65
+
66
+ <xmp style='margin-left:2em;margin-top:0;'><input id="hex" style="width: 6em;" type="text" />
67
+
68
+ <div id="colorpicker"></div>
69
+
70
+ <div style="margin: 1em 0pt 3em;">
71
+ Most recent action: <span id="log"><b>none</b></span>
72
+ </div>
73
+
74
+ <script type="text/javascript"><!--
75
+ new ProColor({
76
+ mode:'static',
77
+ parent:'colorpicker',
78
+ imgPath:'img/procolor_win_',
79
+ input:'hex',
80
+ showInField: true,
81
+ color:'#FF0000',
82
+ outputFormat:'(#{RR}{GG}{BB})',
83
+ onChanged:function(pc) { $('log').innerHTML = "<b>choose " + pc.color + "</b>"; },
84
+ onAcceptClick:function(pc) { $('log').innerHTML = "<b>done " + pc.color + "</b>"; },
85
+ onCancelClick:function(pc) { $('log').innerHTML = "<b>cancel</b>"; },
86
+ onCloseButton:function(pc) { $('log').innerHTML = "<b>close</b>"; }
87
+ });
88
+ --></script>
89
+ </xmp>
90
+
91
+ <!--============================================================================================-->
92
+ <hr />
93
+
94
+ <h2>Example #2</h2>
95
+
96
+ <p>In this example, we use the dropdown-button functionality provided by ProColor. Clicking the
97
+ dropdown button generates a color-picker popup window, and clicking outside that window (or clicking
98
+ the color-picker's X button) closes it. Again, the color-picker is fully synchronized to the
99
+ input field at all times, and the button object works in lieu of the color-picker window, when
100
+ necessary, to ensure that the input field has a valid input value (and background/text color) at
101
+ all times.</p>
102
+
103
+ <div style="text-align: center; margin-bottom: 3em;">
104
+ <input id="hex2" value="#FF0000" style="width: 6em;" type="text" />
105
+ </div>
106
+
107
+ <script type="text/javascript"><!--
108
+ ProColor.prototype.attachButton('hex2', { imgPath:'img/procolor_win_', showInField: true });
109
+ --></script>
110
+
111
+ <h4 style='margin:0;'>Complete source code:</h4>
112
+
113
+ <xmp style='margin-left:2em;margin-top:0;'><div style="text-align: center; margin-bottom: 3em;">
114
+ <input id="hex2" value="#FF0000" style="width: 6em;" type="text" />
115
+ </div>
116
+
117
+ <script type="text/javascript"><!--
118
+ ProColor.prototype.attachButton('hex2', { imgPath:'img/procolor_win_', showInField: true });
119
+ --></script>
120
+ </xmp>
121
+
122
+ <!--============================================================================================-->
123
+ <hr />
124
+
125
+ <h2>Example #3</h2>
126
+
127
+ <h4 style='margin:0;'>Complete source code for this next example:</h4>
128
+
129
+ <xmp style='margin-left:2em;margin-top:0;'><div style="text-align: right; margin-bottom: 3em;">
130
+ <input id="hex3" value="#FF0000" style="width: 6em;" type="text" class="procolor" />
131
+ </div>
132
+ </xmp>
133
+
134
+ <p>This very lightweight example shows how you can easily add ProColor to existing pages with
135
+ minimal changes. The input field below simply has "procolor" as part of its classname, and
136
+ ProColor can automatically pick up on that and generate a suitable popup button. Notice also
137
+ how ProColor's color-picker is smart enough to stay on-screen despite being positioned at the
138
+ bottom-right corner of the document.</p>
139
+
140
+ <div style="text-align: right; margin-bottom: 1em;">
141
+ <input id="hex3" value="#FF0000" style="width: 6em;" type="text" class="procolor" />
142
+ </div>
143
+
144
+ </div></body>
145
+ </html>
js/procolor-1.0/img/procolor_win_bars.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_bg.gif ADDED
Binary file
js/procolor-1.0/img/procolor_win_bg.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_boxes.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_close.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_drop.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_palette_raw.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_sel_circle.gif ADDED
Binary file
js/procolor-1.0/img/procolor_win_sel_circle.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_sel_rect.gif ADDED
Binary file
js/procolor-1.0/img/procolor_win_sel_rect.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_wheel_black.png ADDED
Binary file
js/procolor-1.0/img/procolor_win_wheel_rgb.jpg ADDED
Binary file
js/procolor-1.0/index.html ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>ProColor</title>
8
+ <script type='text/javascript' src='prototype.compressed.js'></script>
9
+ <script type='text/javascript' src='procolor.compressed.js'></script>
10
+ <link rel='stylesheet' type='text/css' href='docs.css' />
11
+ </head>
12
+
13
+ <body><div class='wrapper'>
14
+
15
+ <!--============================================================================================-->
16
+
17
+ <div class='header'>
18
+
19
+ <h1 style='margin-bottom:0;'>ProColor</h1>
20
+ <p style='margin-top:0;font-style:italic;color:#999;'>Copyright &copy; 2009 by the Phantom Inker. All rights reserved.</p>
21
+
22
+ <p><b>Overview &amp; Usage</b>
23
+ | <a href='options.html'>Options</a>
24
+ | <a href='api.html'>Public API</a>
25
+ | <a href='examples.html'>Examples</a>
26
+ | <a href='license.html'>License</a></p>
27
+
28
+ </div>
29
+
30
+ <!--============================================================================================-->
31
+ <hr />
32
+
33
+ <div style='width:22em;padding:0.5em 1em;border:1px solid #999;background-color:#EEE;float:right;margin:1em 2em 2em 2em;font-size:10pt;'>
34
+ ProColor has been tested and found to perform correctly in the following browsers:
35
+
36
+ <ul style='margin-bottom:0;margin-top:0.5em;'>
37
+ <li>Microsoft Internet Explorer 6.0</li>
38
+ <li>Microsoft Internet Explorer 7</li>
39
+ <li>Microsoft Internet Explorer 8 RC1</li>
40
+ <li>Mozilla Firefox 3.0.6</li>
41
+ <li>Apple Safari 3.2.1</li>
42
+ <li>Opera 9.63</li>
43
+ <li>Google Chrome 1.0.154</li>
44
+ </ul>
45
+ </div>
46
+
47
+ <h2>Overview</h2>
48
+
49
+ <p>ProColor is a simple, flexible, easy-to-use color-picker for the
50
+ <a href="http://prototypejs.org">Prototype</a> Javascript
51
+ framework. ProColor is designed to be friendly to artists and programmers both. This user's
52
+ manual both documents ProColor and demonstrates it in action.</p>
53
+
54
+ <p>ProColor is compatible with IE6+, Firefox 2+, Safari 3+, Opera 9+, and Chrome. It is not
55
+ compatible with very old browsers, but it does at least fall back to a simple text-edit field
56
+ for old browsers. It runs very well on Safari and Chome, reasonably well on Firefox and Opera,
57
+ and is usable (if slow) on IE.</p>
58
+
59
+ <div style='clear:both;'>
60
+
61
+ <!--============================================================================================-->
62
+ <hr />
63
+
64
+ <h2>Basic Usage</h2>
65
+
66
+ <p>Usage is straightforward. Include "prototype.js" and then "procolor.js" (or better yet,
67
+ include the compressed version, "procolor.compressed.js"), and then make this call to create
68
+ a color-picker:
69
+
70
+ <xmp style='margin-left:2em;'>new ProColor(options);</xmp>
71
+
72
+ <p>For example, for a static color picker:</p>
73
+
74
+ <xmp style='margin-left:2em;'>new ProColor({ mode:'static', parent:container_element });</xmp>
75
+
76
+ <p>Or for a drop-down/popup color picker:</p>
77
+
78
+ <xmp style='margin-left:2em;'>new ProColor({ mode:'popup', input:input_element });</xmp>
79
+
80
+ <p>If you want a drop-down color picker the easy way, it's better to use the button factory
81
+ method to create them:</p>
82
+
83
+ <xmp style='margin-left:2em;'><input type='text' value='#FF0000' id='mycolor' />
84
+ ...
85
+ ProColor.prototype.attachButton('mycolor', options);</xmp>
86
+
87
+ <p>Or if that's still too hard, you can make it even simpler by using the automatic factory
88
+ method that runs during onload. This factory method uses the current setting of
89
+ ProColor.prototype.options for its options, and creates a button attached to any
90
+ <tt>&lt;input&gt;</tt> whose class contains 'procolor':
91
+
92
+ <xmp style='margin-left:2em;'><input type='text' value='#FF0000' class='procolor' /></xmp>
93
+
94
+ <p>Examples of all of these methods of creating a color-picker are included in this user's manual.</p>
95
+
96
+ <p>The only files required to actually use ProColor are <tt>prototype.js</tt> (Prototype),
97
+ <tt>procolor.js</tt> or <tt>procolor.compressed.js</tt>, and the various PNG and GIF and JPEG
98
+ images found in the <tt>img/</tt> directory:</p>
99
+
100
+ <ul>
101
+ <li><tt>procolor_win_bars.png</tt></li>
102
+ <li><tt>procolor_win_bg.gif</tt> (used only by IE6)</li>
103
+ <li><tt>procolor_win_bg.png</tt></li>
104
+ <li><tt>procolor_win_boxes.png</tt></li>
105
+ <li><tt>procolor_win_close.png</tt></li>
106
+ <li><tt>procolor_win_drop.png</tt></li>
107
+ <li><tt>procolor_win_palette_raw.png</tt></li>
108
+ <li><tt>procolor_win_sel_circle.gif</tt> (used only by IE6)</li>
109
+ <li><tt>procolor_win_sel_circle.png</tt></li>
110
+ <li><tt>procolor_win_sel_rect.gif</tt> (used only by IE6)</li>
111
+ <li><tt>procolor_win_sel_rect.png</tt></li>
112
+ <li><tt>procolor_win_wheel_black.png</tt></li>
113
+ <li><tt>procolor_win_wheel_rgb.jpg</tt></li>
114
+ </ul>
115
+
116
+ </div></body>
117
+ </html>
js/procolor-1.0/license.html ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>License - ProColor</title>
8
+ <script type='text/javascript' src='prototype.compressed.js'></script>
9
+ <script type='text/javascript' src='procolor.compressed.js'></script>
10
+ <link rel='stylesheet' type='text/css' href='docs.css' />
11
+ </head>
12
+
13
+ <body><div class='wrapper'>
14
+
15
+ <!--============================================================================================-->
16
+
17
+ <div class='header'>
18
+
19
+ <h1 style='margin-bottom:0;'>ProColor</h1>
20
+ <p style='margin-top:0;font-style:italic;color:#999;'>Copyright &copy; 2009 by the Phantom Inker. All rights reserved.</p>
21
+
22
+ <p><a href='index.html'>Overview &amp; Usage</a>
23
+ | <a href='options.html'>Options</a>
24
+ | <a href='api.html'>Public API</a>
25
+ | <a href='examples.html'>Examples</a>
26
+ | <b>License</b></p>
27
+
28
+ </div>
29
+
30
+ <!--============================================================================================-->
31
+ <hr />
32
+
33
+ <h2>License</h2>
34
+
35
+ <p style='font-style:italic;color:#999;'>ProColor is open-source, licensed under the
36
+ <a href="http://www.opensource.org/licenses/bsd-license.php">new BSD license</a>,
37
+ copied below.</p>
38
+
39
+ <p>Redistribution and use in source and binary forms, with or without
40
+ modification, are permitted provided that the following conditions are met:</p>
41
+
42
+ <ul>
43
+ <li>Redistributions of source code must retain the above copyright
44
+ notice, this list of conditions and the following disclaimer.</li>
45
+
46
+ <li>Redistributions in binary form must reproduce the above copyright
47
+ notice, this list of conditions and the following disclaimer in the
48
+ documentation and/or other materials provided with the distribution.</li>
49
+ </ul>
50
+
51
+ <p>THIS SOFTWARE IS PROVIDED BY THE PHANTOM INKER AND CONTRIBUTORS "AS IS"
52
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
55
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
56
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
57
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
58
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
59
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
61
+ THE POSSIBILITY OF SUCH DAMAGE.</p>
62
+
63
+ </div></body>
64
+ </html>
js/procolor-1.0/options.html ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>Options - ProColor</title>
8
+ <script type='text/javascript' src='prototype.compressed.js'></script>
9
+ <script type='text/javascript' src='procolor.compressed.js'></script>
10
+ <link rel='stylesheet' type='text/css' href='docs.css' />
11
+ </head>
12
+
13
+ <body><div class='wrapper'>
14
+
15
+ <!--============================================================================================-->
16
+
17
+ <div class='header'>
18
+
19
+ <h1 style='margin-bottom:0;'>ProColor</h1>
20
+ <p style='margin-top:0;font-style:italic;color:#999;'>Copyright &copy; 2009 by the Phantom Inker. All rights reserved.</p>
21
+
22
+ <p><a href='index.html'>Overview &amp; Usage</a>
23
+ | <b>Options</b>
24
+ | <a href='api.html'>Public API</a>
25
+ | <a href='examples.html'>Examples</a>
26
+ | <a href='license.html'>License</a></p>
27
+
28
+ </div>
29
+
30
+ <!--============================================================================================-->
31
+ <hr />
32
+
33
+ <h2>Options</h2>
34
+
35
+ <p>ProColor offers many different options for configuring its behavior when a new ProColor object
36
+ is created. All of the important ones are documented below. To see examples of these options
37
+ in use, look at the <a href='examples.html'>examples page</a>.</p>
38
+
39
+ <h3>Options:</h3>
40
+
41
+ <ul class='options'>
42
+ <li><tt>mode</tt>: Either '<tt>static</tt>' or '<tt>popup</tt>'.</li>
43
+
44
+ <li><tt>input</tt>: Input textbox or hidden field to record color in.
45
+ (Format: '<tt>#RRGGBB</tt>' string.)</li>
46
+
47
+ <li><tt>showInField</tt>: Show the current color as the input field's background
48
+ color (default: <tt>false</tt>).</li>
49
+
50
+ <li><tt>parent</tt>: In static mode, the containing element to insert this into.
51
+ In popup mode, this is the element the popup should be attached to (usually
52
+ the same as input).</li>
53
+
54
+ <li><tt>closeButton</tt>: Show close button (default: <tt>false</tt> for '<tt>static</tt>',
55
+ <tt>true</tt> for '<tt>popup</tt>').</li>
56
+
57
+ <li><tt>color</tt>: Initial color to select (default: extract from input field, or
58
+ use '<tt>#FFFFFF</tt>').</li>
59
+
60
+ <li><tt>imgPath</tt>: URL to dir containing ProColor's <tt>.png</tt> files, if they're not in the same place
61
+ as the <tt>.js</tt> file. This is directly prepended to the names of the files, so
62
+ it usually must have a trailing '<tt>/</tt>'.</li>
63
+
64
+ <li><tt>width</tt>: Dimensions of the color picker, in pixels. Default width is '<tt>360</tt>' pixels.</li>
65
+
66
+ <li><tt>height</tt>: Dimensions of the color picker, in pixels. Default height is '<tt>192</tt>' pixels.</li>
67
+
68
+ <li><tt>offsetx</tt>: Offset of color picker's content, from its left edge, in pixels. Default is '<tt>0</tt>' pixels.</li>
69
+
70
+ <li><tt>offsety</tt>: Offset of color picker's content, from its top edge, in pixels. Default is '<tt>0</tt>' pixels.</li>
71
+
72
+ <li><tt>editbg</tt>: Background color of color picker's edit fields. Default is '<tt>#FFFFFF</tt>'.</li>
73
+
74
+ <li><tt>edittext</tt>: Color of text in color picker's edit fields: Default is '<tt>#4C4C4C</tt>'.</li>
75
+
76
+ <li><tt>outputFormat</tt>: How to format the text in the textbox. A format string that accepts:
77
+
78
+ <ul class='collapsed'>
79
+ <li><tt>{RR}</tt> - Two-digit red hex value.</li>
80
+ <li><tt>{GG}</tt> - Two-digit green hex value.</li>
81
+ <li><tt>{BB}</tt> - Two-digit blue hex value.</li>
82
+ <li><tt>{R}</tt> - One-digit red hex value.</li>
83
+ <li><tt>{G}</tt> - One-digit green hex value.</li>
84
+ <li><tt>{B}</tt> - One-digit blue hex value.</li>
85
+ <li><tt>{red}</tt> - Decimal red (0-255).</li>
86
+ <li><tt>{grn}</tt> - Decimal green (0-255).</li>
87
+ <li><tt>{blu}</tt> - Decimal blue (0-255).</li>
88
+ <li><tt>{hue}</tt> - Decimal hue (0-359).</li>
89
+ <li><tt>{sat}</tt> - Decimal saturation (0-100).</li>
90
+ <li><tt>{brt}</tt> - Decimal brightness (0-100).</li>
91
+ <li><tt>.</tt> - All other characters will be copied as-is.</li>
92
+ </ul>
93
+
94
+ In addition, you may use tokens like {rr} to request lowercase hex instead
95
+ of uppercase. The default format string is "<tt>#{RR}{GG}{BB}</tt>".</li>
96
+
97
+ <li><tt>onOpening</tt>: Called when the color picker is about to appear but has not yet appeared:
98
+ <tt>callback(this, 'opening')</tt>. (Note that the color picker's <tt>&lt;div&gt;</tt> has <i>not</i>
99
+ been created when <tt>onOpening</tt> is called --- the color picker object has been created and
100
+ its options initialized, but no elements have yet been created.)
101
+ The return value of your callback is ignored.</li>
102
+
103
+ <li><tt>onOpened</tt>: Called after the color picker has appeared, just before returning control back to
104
+ the browser:
105
+ <tt>callback(this, 'opened')</tt>. The return value of your callback is ignored.</li>
106
+
107
+ <li><tt>onClosing</tt>: Called when the color picker is about to be destroyed but has not yet been destroyed:
108
+ <tt>callback(this, 'closing')</tt>. The return value of your callback is ignored.</li>
109
+
110
+ <li><tt>onClosed</tt>: Called after the color picker has been destroyed, just before the code returns
111
+ control to the browser:
112
+ <tt>callback(this, 'closed').</tt> (Note that the color picker object still exists, but all of
113
+ its elements and event handlers have been destroyed by this point.) The return value of your callback is ignored.</li>
114
+
115
+ <li><tt>onChanging</tt>: Called when the color is changing: <tt>callback(this, 'changing')</tt>. (This is called
116
+ many times while the color is changing during a mouse-drag operation, for example, and is always
117
+ called <i>after</i> the color-picker's <tt>color</tt> member has been updated.) The return value of your callback is ignored.</li>
118
+
119
+ <li><tt>onChanged</tt>: Called when the color has changed: <tt>callback(this, 'changed')</tt>. (This
120
+ is called after the user has made a definitive change to the color, such as when the mouse button
121
+ is released, or when the user types in a new color. This is always called <i>after</i> the
122
+ color-picker's <tt>color</tt> member has been updated.) The return value of your callback is ignored.</li>
123
+
124
+ <li><tt>onCancelClick</tt>: Called when user presses Esc or clicks outside the color-picker popup:
125
+ <tt>callback(this, 'cancelclick')</tt>. The return value of your callback is ignored.</li>
126
+
127
+ <li><tt>onAcceptClick</tt>: Called when user presses Enter or double-clicks:
128
+ <tt>callback(this, 'acceptclick')</tt>. The return value of your callback is ignored.</li>
129
+
130
+ <li><tt>onCloseButton</tt>: Called when user clicks the close button, before closing the color-picker:
131
+ <tt>callback(this, 'closebutton')</tt>. This function must return a value indicating whether
132
+ the color-picker should be closed, <tt>true</tt> to close the color-picker, or <tt>false</tt>
133
+ to leave it open.</li>
134
+ </ul>
135
+
136
+ </div></body>
137
+ </html>
js/procolor-1.0/procolor.compressed.js ADDED
@@ -0,0 +1 @@
 
1
+ if(typeof Prototype=="undefined"){alert("ProColor Error: Prototype is not loaded. Please make sure that your page includes prototype.js before it includes procolor.js.")}if(Prototype.Version<"1.6"){alert("ProColor Error: Minimum Prototype 1.6.0 is required; you are using "+Prototype.Version)}Element.addMethods({build:function(a,d,b,c){var f=$(document.createElement(d));$H(b).each(function(e){f[e.key]=e.value});if(c){f.setStyle(c)}a.appendChild(f);return f},isEventIn:function(b,c){var f=b.getDimensions();var e=b.cumulativeOffset();var a=c.pointerX(),g=c.pointerY();return(a>=e.left&&g>=e.top&&a<e.left+f.width&&g<e.top+f.height)}});var MouseCapture=Class.create({initialize:function(){},onEvent:function(a,b){if(b&&a.type!="mouseover"&&a.type!="mouseout"){b(a,a.type)}a.stop()},setCursor:function(a){if(this.div){this.div.setStyle({cursor:a})}},begin:function(c){this.listener=this.onEvent.bindAsEventListener(this,c);Event.observe(document,"mouseup",this.listener);Event.observe(document,"mousemove",this.listener);Event.observe(document,"mousedown",this.listener);Event.observe(document,"mouseover",this.listener);Event.observe(document,"mouseout",this.listener);Event.observe(document,"keyup",this.listener);Event.observe(document,"keydown",this.listener);this.old_body_ondrag=document.body.ondrag;this.old_body_onselectstart=document.body.onselectstart;document.body.ondrag=function(){return false};document.body.onselectstart=function(){return false};var a=Element.extend(document.body);var b=a.getDimensions();this.div=a.build("div",{},{display:"block",position:"absolute",top:"0px",left:"0px",width:b.width+"px",height:b.height+"px",zIndex:999999999,cursor:"default",backgroundColor:"#FFFFFF",opacity:0.0001})},end:function(){this.div.remove();Event.stopObserving(document,"mouseup",this.listener);Event.stopObserving(document,"mousemove",this.listener);Event.stopObserving(document,"mousedown",this.listener);Event.stopObserving(document,"mouseover",this.listener);Event.stopObserving(document,"mouseout",this.listener);Event.stopObserving(document,"keyup",this.listener);Event.stopObserving(document,"keydown",this.listener);document.body.ondrag=this.old_body_ondrag;document.body.onselectstart=this.old_body_onselectstart;delete this.old_body_ondrag;delete this.old_body_onselectstart}});var ProColor=Class.create({palette:["F00C30900633963C63","FC9FC0C93F93F96F60","993CC3FF0FF6FF9FFC","3306639966939C39C6","0F09C99F9CFCCF69F0","3C36960630933C6396","6999CC9FF0FF6FC3C9","36603303936F69F0CF","00666C00F66F99FCCF","C9F90F60C63F30930C","96CC6FC3F90C639306","C9C969C6CF9F909606","F0FF9CC69F39F69F06","F66F99FCC936C36C39"],options:{imgPath:"img/procolor_win_",showInField:true},initialize:function(c){var a=navigator.appVersion.split("MSIE");var d=parseFloat(a[1]);this.old_ie=(d>=5.5&&d<7&&document.body.filters);this.div=null;this.color=null;this.listeners={};this.dblclk={time:0};if(c.parent){this.parent=$(c.parent)}else{this.parent=Element.extend(document.body)}if(c.input){this.input=$(c.input)}else{this.input=null}this.options={mode:"static",width:360,height:192,offsetx:13,offsety:8,input:null,showInField:false,parent:null,closeButton:(c.mode=="popup"),imgPath:"",color:(!this.input?"#FFFFFF":this.input.tagName=="INPUT"?this.input.value:this.input.innerHTML),editbg:"#FFFFFF",edittext:"#4C4C4C",outputFormat:"#{RR}{GG}{BB}",onOpening:null,onOpened:null,onClosing:null,onClosed:null,onCloseButton:null,onChanging:null,onChanged:null,onCancelClick:null,onAcceptClick:null};for(var b in c){this.options[b]=c[b]}if(this.options.onOpening){this.options.onOpening(this,"opening")}this.createDiv();if(this.options.mode=="popup"){this.positionPopup();Event.observe(document,"mousedown",this.closeClickHandler=this.handleCloseClick.bindAsEventListener(this));Event.observe(document,"keypress",this.keyPressHandler=this.handleKeyPress.bindAsEventListener(this))}if(this.options.onOpened){this.options.onOpened(this,"opened")}},positionPopup:function(){var f=this.div.cumulativeOffset(),h=f[0],g=f[1];var c=this.div.getDimensions(),q=c.height,b=c.width;var k=document.viewport.getHeight(),o=document.viewport.getWidth();var n=document.viewport.getScrollOffsets();var p=$(this.input).cumulativeOffset(),d=p[1],m=p[0];var e=$(this.input).getDimensions().height,i=d+e;if(m+b>o-8){m=o-8-b}if(m<8){m=8}var l=(i+q>n.top+k)&&(i-q>n.top);var a=m.toString()+"px";var j=(l?(d-q):(d+e)).toString()+"px";this.div.style.left=a;this.div.style.top=j;this.div.setStyle({visibility:"",display:"block"})},createDiv:function(){var b={display:"block",width:this.options.width+"px",height:this.options.height+"px",backgroundPosition:"0% 0%",backgroundAttachment:"scroll",backgroundRepeat:"no-repeat",backgroundImage:"url("+this.options.imgPath+(this.old_ie?"bg.gif)":"bg.png)"),color:"#BBBBD7",left:0,top:0};if(this.options.mode=="popup"){b.position="absolute";b.display="none";b.visibility="hidden";b.zIndex=999999}else{b.position="relative"}this.div=$(this.parent).build("div",{className:"procolor_box"},b);this.img_palette=this.loadBgImage(this.div,"palette_raw.png",0,1,66,174);this.img_bar_lower=this.loadBgImage(this.div,"bars.png",77,1,20,174,{zIndex:1,opacity:1});this.img_bar_middle=this.loadBgImage(this.div,"bars.png",77,1,20,174,{zIndex:2,opacity:0});this.img_bar_upper=this.loadBgImage(this.div,"bars.png",77,1,20,174,{zIndex:3,opacity:0});this.img_wheel_rgb=this.loadBgImage(this.div,"wheel_rgb.jpg",105,0,176,176,{zIndex:1,opacity:1});this.img_wheel_black=this.loadBgImage(this.div,"wheel_black.png",105,0,176,176,{zIndex:2,opacity:1});this.img_boxes=this.loadBgImage(this.div,"boxes.png",287,25,50,149,{zIndex:1});this.img_bar_dragger=this.createImageButton(this.div,"sel_rect",73+this.options.offsetx,-1+this.options.offsety,24,8,{zIndex:4});this.img_wheel_dragger=this.createImageButton(this.div,"sel_circle",184+this.options.offsetx,79+this.options.offsety,17,17,{zIndex:5});this.listeners.wheel=this.onWheelEvent.bindAsEventListener(this);this.img_wheel_black.observe("mousedown",this.listeners.wheel);this.img_wheel_dragger.observe("mousedown",this.listeners.wheel);this.img_wheel_dragger.observe("keydown",this.listeners.wheel);this.listeners.bar=this.onBarEvent.bindAsEventListener(this);this.img_bar_upper.observe("mousedown",this.listeners.bar);this.img_bar_dragger.observe("mousedown",this.listeners.bar);this.img_bar_dragger.observe("keydown",this.listeners.bar);this.listeners.palette=this.onPaletteEvent.bindAsEventListener(this);this.img_palette.observe("mousedown",this.listeners.palette);this.wheel={left:106+this.options.offsetx,top:1+this.options.offsety,width:174,height:174};this.bar={left:77+this.options.offsetx,top:2+this.options.offsety,width:20,height:172};this.wheelsel={width:17,height:17};this.barsel={width:24,height:8};this.listeners.rgb=this.onNumberBox.bindAsEventListener(this,"rgb",0,255,0);this.r_edit=this.createEdit(this.div,287,25,37,20,this.listeners.rgb);this.g_edit=this.createEdit(this.div,287,47,37,20,this.listeners.rgb);this.b_edit=this.createEdit(this.div,287,69,37,20,this.listeners.rgb);this.listeners.hue=this.onNumberBox.bindAsEventListener(this,"hsb",0,359,360);this.listeners.satbrt=this.onNumberBox.bindAsEventListener(this,"hsb",0,100,0);this.hue_edit=this.createEdit(this.div,287,110,37,20,this.listeners.hue);this.sat_edit=this.createEdit(this.div,287,132,37,20,this.listeners.satbrt);this.brt_edit=this.createEdit(this.div,287,154,37,20,this.listeners.satbrt);if(this.options.closeButton){this.img_close=this.createImageButton(this.div,"close",this.options.width-40,0,24,16);this.listeners.close=this.onCloseEvent.bindAsEventListener(this);this.img_close.observe("mouseover",this.listeners.close);this.img_close.observe("mouseout",this.listeners.close);this.img_close.observe("mousedown",this.listeners.close);this.img_close.observe("keydown",this.listeners.close);this.img_close.trackingMouse=false}if(this.input&&this.input.tagName=="INPUT"){this.listeners.input=this.onInput.bindAsEventListener(this);this.input.observe("keyup",this.listeners.input);this.input.observe("focus",this.listeners.input);this.input.observe("blur",this.listeners.input)}else{this.listeners.input=null}var a=this.decodeHexColor(this.options.color);if(!a){a={r:0,g:0,b:0}}this.update("rgb",a,[])},loadBgImage:function(k,d,g,f,j,c,e){var a={display:"block",position:"absolute",width:j+"px",height:c+"px",left:g+this.options.offsetx+"px",top:f+this.options.offsety+"px",padding:"0",backgroundImage:"url("+this.options.imgPath+d+")"};if(e){for(var b in e){a[b]=e[b]}}return k.build("div",{},a)},createImageButton:function(l,e,j,g,k,d,f){var a={display:"block",position:"absolute",width:k+"px",height:d+"px",left:j+"px",top:g+"px",border:"0",cursor:"default",padding:"0",fontSize:"1px",backgroundImage:"url("+this.options.imgPath+e+(this.old_ie?".gif)":".png)")};if(f){for(var c in f){a[c]=f[c]}}var b=l.build("a",{href:"#"},a);return b},createEdit:function(c,a,i,b,f,g){a+=5;b-=9;i+=2;f-=6;var e={display:"inline",position:"absolute",width:b+"px",height:f+"px",left:a+this.options.offsetx+"px",top:i+this.options.offsety+"px",verticalAlign:"top",backgroundColor:this.options.editbg,padding:"0",color:this.options.edittext,fontFamily:"Verdana,Tahoma,Arial,sans-serif,sans serif,sans",fontSize:"12px",fontStyle:"Normal",fontVariant:"Normal",fontWeight:"Normal",textAlign:"right",direction:"ltr",border:0,zIndex:10};var d=c.build("input",{type:"text",value:"0",maxLength:3},e);d.observe("keypress",g);d.observe("keyup",g);d.observe("focus",g);d.observe("blur",g);return d},close:function(){if(!this.div){return false}if(this.options.onClosing){this.options.onClosing(this,"closing")}if(this.options.closeButton){Event.stopObserving(this.img_close)}Event.stopObserving(this.r_edit);Event.stopObserving(this.g_edit);Event.stopObserving(this.b_edit);Event.stopObserving(this.hue_edit);Event.stopObserving(this.sat_edit);Event.stopObserving(this.brt_edit);Event.stopObserving(this.img_wheel_black);Event.stopObserving(this.img_bar_upper);Event.stopObserving(this.img_palette);Event.stopObserving(this.img_wheel_dragger);Event.stopObserving(this.img_bar_dragger);if(this.listeners.input){Event.stopObserving(this.input,"keyup",this.listeners.input);Event.stopObserving(this.input,"focus",this.listeners.input);Event.stopObserving(this.input,"blur",this.listeners.input)}Event.stopObserving(document,"mousedown",this.closeClickHandler);Event.stopObserving(document,"keypress",this.keyPressHandler);this.div.remove();this.div=null;this.listeners={};this.dblclk={};if(this.input.type!="hidden"&&!this.input.disabled){this.input.focus()}if(this.options.onClosed){this.options.onClosed(this,"closed")}},updateState:{},updateTimeout:false,queuedUpdate:function(d,a,c){if(!Prototype.Browser.IE){this.update(d,a,c)}else{var b=this;b.updateState={mode:d,color:a,sources:c};if(b.updateTimeout==false){b.updateTimeout=setTimeout(function(){b.updateTimeout=false;b.update(b.updateState.mode,b.updateState.color,b.updateState.sources)},25)}}},finalUpdate:function(){if(this.updateTimeout){clearTimeout(this.updateTimeout);this.updateTimeout=false;this.update(this.updateState.mode,this.updateState.color,this.updateState.sources);this.updateState={}}},update:function(i,f,l){if(typeof(f)!="object"){f={r:0,g:0,b:0,hue:0,sat:0,brt:0}}f.r=this.toNumber(f.r);f.g=this.toNumber(f.g);f.b=this.toNumber(f.b);f.hue=this.toNumber(f.hue);f.sat=this.toNumber(f.sat);f.brt=this.toNumber(f.brt);var k,e;if(i=="rgb"){k=f;e=this.RGBtoHSB(k)}else{if(i=="hsb"){e=f;k=this.HSBtoRGB(e)}}if(k.r<0){k.r=0}if(k.r>255){k.r=255}if(k.g<0){k.g=0}if(k.g>255){k.g=255}if(k.b<0){k.b=0}if(k.b>255){k.b=255}e.hue=e.hue%360;if(e.hue<0){e.hue+=360}if(e.sat<0){e.sat=0}if(e.sat>100){e.sat=100}if(e.brt<0){e.brt=0}if(e.brt>100){e.brt=100}source={};l.each(function(c){source[c]=true});var r=this;if(!source.wheel){var a=e.brt/100;if(a>0.9999){a=0.9999}r.img_wheel_black.setOpacity(1-a);var b=((e.hue+270)%360)*(Math.PI*2/360);var j=Math.cos(b);var u=Math.sin(b);var p=Math.floor(j*e.sat*r.wheel.width/200+0.5)+r.wheel.left+((r.wheel.width-4)/2)+2;var m=Math.floor(u*e.sat*r.wheel.height/200+0.5)+r.wheel.top+((r.wheel.height-4)/2)+2;r.img_wheel_dragger.setStyle({left:p-Math.floor(r.wheelsel.width/2)+"px",top:m-Math.floor(r.wheelsel.height/2)+"px"})}if(!source.bar){var g=Math.floor(e.hue/60);var h=(g+1)%6;r.img_bar_lower.setStyle({backgroundPosition:(-g*20-20)+"px 0px"});r.img_bar_middle.setStyle({backgroundPosition:(-h*20-20)+"px 0px"});r.img_bar_middle.setOpacity((e.hue-g*60)/60);var a=(100-e.sat)/100;if(a<0.0001){a=0.0001}r.img_bar_upper.setOpacity(a);r.img_bar_dragger.setStyle({top:r.bar.top-Math.floor(r.barsel.height/2)+Math.floor((100-e.brt)*r.bar.height/100+0.5)+"px",left:r.bar.left+Math.floor(r.bar.width-r.barsel.width)/2+"px"})}k.r=Math.floor(k.r+0.5);k.g=Math.floor(k.g+0.5);k.b=Math.floor(k.b+0.5);e.hue=Math.floor(e.hue+0.5);e.sat=Math.floor(e.sat+0.5);e.brt=Math.floor(e.brt+0.5);e.hue=e.hue%360;this.color="#"+(k.r.toColorPart()+k.g.toColorPart()+k.b.toColorPart()).toUpperCase();if(!source.rgb){this.r_edit.value=k.r;this.g_edit.value=k.g;this.b_edit.value=k.b}if(!source.hsb){this.hue_edit.value=e.hue;this.sat_edit.value=e.sat;this.brt_edit.value=e.brt}if(this.options.input){var n=$(this.options.input);if(!source.input){var q=this.internalFormatOutput(k,e,this.options.outputFormat);if(n.tagName=="INPUT"){n.value=q}else{n.innerHTML=q}}if(this.options.showInField){var d=this.computeTextColor(k);n.setStyle({backgroundColor:this.color,color:"#"+d.r.toColorPart()+d.g.toColorPart()+d.b.toColorPart()})}}},toNumber:function(a){switch(typeof a){case"number":return a;case"string":if(matches=/^[^0-9.+-]*([+-]?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?))(?:[^0-9]|$)/.exec(a)){return Number(matches[1])}else{return 0}case"boolean":return a?1:0;case"object":return a?1:0;case"function":return 1;default:case"undefined":return 0}},formatOutput:function(a,c){if(!c){c="#{RR}{GG}{BB}"}var b=this.decodeHexColor(a);if(!b){b={r:0,g:0,b:0}}return this.internalFormatOutput(b,this.RGBtoHSB(b),c)},internalFormatOutput:function(c,b,e){var a=e.match(/(\{\w+\}|[^{]+)/g);var d="";a.each(function(f){var g;switch(f){case"{RR}":g=c.r.toColorPart().toUpperCase();break;case"{GG}":g=c.g.toColorPart().toUpperCase();break;case"{BB}":g=c.b.toColorPart().toUpperCase();break;case"{rr}":g=c.r.toColorPart().toLowerCase();break;case"{gg}":g=c.g.toColorPart().toLowerCase();break;case"{bb}":g=c.b.toColorPart().toLowerCase();break;case"{R}":g=this.halfColorPart(c.r).toUpperCase();break;case"{G}":g=this.halfColorPart(c.g).toUpperCase();break;case"{B}":g=this.halfColorPart(c.b).toUpperCase();break;case"{r}":g=this.halfColorPart(c.r).toLowerCase();break;case"{g}":g=this.halfColorPart(c.g).toLowerCase();break;case"{b}":g=this.halfColorPart(c.b).toLowerCase();break;case"{red}":g=c.r.toString();break;case"{grn}":g=c.g.toString();break;case"{blu}":g=c.b.toString();break;case"{hue}":g=b.hue.toString();break;case"{sat}":g=b.sat.toString();break;case"{brt}":g=b.brt.toString();break;default:g=f;break}d+=g});return d},halfColorPart:function(a){return Math.floor((a+8)/17).toString(16)},decodeHexColor:function(c){var f;if(f=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{0,2})(?:[^0-9A-Fa-f]|$)/.exec(c)){return{r:parseInt(f[1],16),g:parseInt(f[2],16),b:parseInt(f[3],16)}}if(f=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(c)){var a=parseInt(f[3],16);return{r:parseInt(f[1],16),g:parseInt(f[2],16),b:a*16+a}}if(f=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(c)){var e=parseInt(f[2],16);return{r:parseInt(f[1],16),g:e,b:e}}if(f=/^[^0-9A-Fa-f]*([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]{0,2})(?:[^0-9A-Fa-f]|$)/.exec(c)){var d=parseInt(f[1],16);var e=parseInt(f[2],16);var a=parseInt(f[3],16);return{r:d*16+d,g:e*16+e,b:a*16+a}}if(f=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(c)){var e=parseInt(f[1],16);return{r:e,g:e,b:e}}if(f=/^[^0-9A-Fa-f]*([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(c)){var e=parseInt(f[1],16);e=e*16+e;return{r:e,g:e,b:e}}return false},trueBrightness:function(a){return(a.r/255*0.3)+(a.g/255*0.59)+(a.b/255*0.11)},computeTextColor:function(c){var d=this.trueBrightness(c);if(d<0.5){var a=Math.floor(d*20)+3;var b=255*(a-1)}else{var a=Math.floor((1-d)*20)+3;var b=0}return{r:Math.floor((c.r+b)/a),g:Math.floor((c.g+b)/a),b:Math.floor((c.b+b)/a)}},RGBtoHSB:function(f){var a=Math.floor(this.toNumber(f.r)+0.5);var e=Math.floor(this.toNumber(f.g)+0.5);var j=Math.floor(this.toNumber(f.b)+0.5);if(a<0){a=0}if(a>255){a=255}if(e<0){e=0}if(e>255){e=255}if(j<0){j=0}if(j>255){j=255}var i,m,k,c;var d=a,n=e,l=j;if(a>e){if(a>j){l=i=a,c=0,k=e-j}else{l=i=j,c=240,k=a-e}m=i-((e<j)?e:j)}else{if(e>j){l=i=e,c=120,k=j-a}else{l=i=j,c=240,k=a-e}m=i-((a<j)?a:j)}if(i!=0){n=Math.floor((m*100)/i+0.5)}else{n=0}if(n!=0){d=(c+Math.floor(k*120/(m*2)+0.5))%360;if(d<0){d+=360}}else{d=0}l=Math.floor(l*100/255+0.5);return{hue:d,sat:n,brt:l}},HSBtoRGB:function(d){var j=this.toNumber(d.brt);if(j<0){j=0}if(j>100){j=100}j=j*255/100;var l=this.toNumber(d.sat);if(l<=0){j=Math.floor(j+0.5);return{r:j,g:j,b:j}}if(l>100){l=100}var e=this.toNumber(d.hue);e=e%360;if(e<0){e+=360}var k=j*l/100;var c=(k*((e*256/60)%256))/256;var a,f,i;switch(Math.floor(e/60)){case 0:a=j;f=j-k+c;i=j-k;break;case 1:a=j-c;f=j;i=j-k;break;case 2:a=j-k;f=j;i=j-k+c;break;case 3:a=j-k;f=j-c;i=j;break;case 4:a=j-k+c;f=j-k;i=j;break;case 5:a=j;f=j-k;i=j-c;break}a=Math.floor(a+0.5);f=Math.floor(f+0.5);i=Math.floor(i+0.5);if(a<0){a=0}if(a>255){a=255}if(f<0){f=0}if(f>255){f=255}if(i<0){i=0}if(i>255){i=255}return{r:a,g:f,b:i}},acceptAndClose:function(){if(this.options.onAcceptClick){this.options.onAcceptClick(this,"acceptclick")}if(this.options.mode=="popup"){this.close()}},cancelAndClose:function(){if(this.options.onCancelClick){this.options.onCancelClick(this,"cancelclick")}if(this.options.mode=="popup"){this.close()}},closeOnDoubleClick:function(d){var a=d.pointerX(),f=d.pointerY();var b=new Date;var c=b.getTime();if(Math.abs(this.dblclk.x-a)<3&&Math.abs(this.dblclk.y-f)<3&&c-this.dblclk.time<=500){this.dblclk.time=0;this.acceptAndClose();return true}else{this.dblclk.x=a;this.dblclk.y=f;this.dblclk.time=c;return false}},brtFromPoint:function(a,e){var c=this.img_bar_upper.getDimensions();var b=this.img_bar_upper.cumulativeOffset();if(e<b.top){return 100}else{if(e>=b.top+c.height){return 0}else{return((b.top+c.height-1-e)*100/c.height)}}},hueSatFromPoint:function(a,i){var h=this.img_wheel_rgb.getDimensions();var g=this.img_wheel_rgb.cumulativeOffset();var b=(i-(g.top+h.height/2))/((h.height-4)/2);var f=(a-(g.left+h.width/2))/((h.width-4)/2);var e=Math.sqrt(b*b+f*f)*100+0.5;var c=Math.atan2(b,f)*180/Math.PI+90;if(e<=0){c=e=0}if(e>100){e=100}if(c<0){c+=360}return{sat:e,hue:c}},colorFromPalette:function(c,j){var i=this.img_palette.getDimensions();var h=this.img_palette.cumulativeOffset();if(c<h.left||c>=h.left+i.width){return false}c=Math.floor((c-h.left)/11);if(j>=h.top&&j<h.top+12){line="000333666999CCCFFF"}else{if(j>h.top+20&&j<h.top+20+this.palette.length*11){line=this.palette[Math.floor((j-(h.top+20))/11)]}else{return false}}var f=parseInt(line.substr(c*3,1),16);var e=parseInt(line.substr(c*3+1,1),16);var a=parseInt(line.substr(c*3+2,1),16);return{r:f*16+f,g:e*16+e,b:a*16+a}},updateByMode:function(a){this.update(a,{r:this.r_edit.value,g:this.g_edit.value,b:this.b_edit.value,hue:this.hue_edit.value,sat:this.sat_edit.value,brt:this.brt_edit.value},[a])},onCloseEvent:function(c){switch(c.type){case"keydown":switch(c.keyCode){case Event.KEY_RETURN:case 32:if(this.options.onCloseButton){if(!this.options.onCloseButton(this,"closebutton")){break}}if(this.options.mode=="popup"){this.close()}break}break;case"mouseover":if(!this.img_close.trackingMouse){this.img_close.setStyle({backgroundPosition:"0px -16px"})}break;case"mouseout":if(!this.img_close.trackingMouse){this.img_close.setStyle({backgroundPosition:"0px 0px"})}break;case"mousedown":this.img_close.trackingMouse=true;this.img_close.setStyle({backgroundPosition:"0px -32px"});c.stop();if(this.img_close.focus){this.img_close.focus()}var b=true;var a=new MouseCapture;a.setCursor("default");a.begin((function(e,d){switch(d){case"mouseup":case"keyup":a.end();this.img_close.trackingMouse=false;if(!b){this.img_close.setStyle({backgroundPosition:"0px 0px"})}else{this.img_close.setStyle({backgroundPosition:"0px -16px"});if(this.options.onCloseButton){if(!this.options.onCloseButton(this,"closebutton")){break}}if(this.options.mode=="popup"){this.close()}}break;case"mousemove":b=(this.img_close.getStyle("backgroundPosition")=="0px -32px");if(this.img_close.isEventIn(e)!=b){b=!b;if(!b){this.img_close.setStyle({backgroundPosition:"0px 0px"})}else{this.img_close.setStyle({backgroundPosition:"0px -32px"})}}break}}).bind(this));break}},onBarEvent:function(h){switch(h.type){case"keydown":var d=this;var g=this.toNumber(d.brt_edit.value),f=g;var c=h.shiftKey||h.ctrlKey||h.altKey;switch(h.keyCode){case Event.KEY_UP:g+=c?10:1;h.stop();break;case Event.KEY_DOWN:g-=c?10:1;h.stop();break;case Event.KEY_PAGEUP:g+=c?25:10;h.stop();break;case Event.KEY_PAGEDOWN:g-=c?25:10;h.stop();break;case Event.KEY_HOME:g=100;h.stop();break;case Event.KEY_END:g=0;h.stop();break}if(g<0){g=0}if(g>100){g=100}if(d.options.onChanging&&(f!=g)){d.options.onChanging(d,"changing")}d.update("hsb",{hue:d.hue_edit.value,sat:d.sat_edit.value,brt:g},[]);if(d.options.onChanged&&(f!=g)){d.options.onChanged(d,"changed")}break;case"mousedown":h.stop();var d=this;d.oldcolor=d.color;if(d.img_bar_dragger.focus){d.img_bar_dragger.focus()}var b=function(j){var i={hue:d.hue_edit.value,sat:d.sat_edit.value,brt:d.brtFromPoint(j.pointerX(),j.pointerY())};d.queuedUpdate("hsb",i,[]);if(d.options.onChanging){d.options.onChanging(d,"changing")}};b(h);if(this.closeOnDoubleClick(h)){break}var a=new MouseCapture;a.setCursor("default");a.begin(function(i,e){switch(e){case"mouseup":case"keyup":a.end();d.finalUpdate();if(d.options.onChanged&&d.oldcolor!=d.color){d.options.onChanged(d,"changed")}break;case"mousemove":b(i);break}});break}},onWheelEvent:function(f){switch(f.type){case"keydown":var i=this;var d=this.toNumber(i.hue_edit.value),g=d;var b=this.toNumber(i.sat_edit.value),j=b;var a=f.shiftKey||f.ctrlKey||f.altKey;switch(f.keyCode){case Event.KEY_UP:b+=a?10:1;f.stop();break;case Event.KEY_DOWN:b-=a?10:1;f.stop();break;case Event.KEY_LEFT:d-=a?10:1;f.stop();break;case Event.KEY_RIGHT:d+=a?10:1;f.stop();break;case Event.KEY_PAGEUP:b+=a?25:10;f.stop();break;case Event.KEY_PAGEDOWN:b-=a?25:10;f.stop();break;case Event.KEY_HOME:b=100;f.stop();break;case Event.KEY_END:b=0;f.stop();break}if(b<0){b=0}if(b>100){b=100}d=d%360;if(d<0){d+=360}if(i.options.onChanging&&(g!=d||j!=b)){i.options.onChanging(i,"changing")}i.update("hsb",{hue:d,sat:b,brt:i.brt_edit.value},[]);if(i.options.onChanged&&(g!=d||j!=b)){i.options.onChanged(i,"changed")}break;case"mousedown":f.stop();var i=this;i.oldcolor=i.color;if(i.img_wheel_dragger.focus){i.img_wheel_dragger.focus()}var c=function(l){var k=i.hueSatFromPoint(l.pointerX(),l.pointerY());k.brt=i.brt_edit.value;i.queuedUpdate("hsb",k,[]);if(i.options.onChanging){i.options.onChanging(i,"changing")}};c(f);if(this.closeOnDoubleClick(f)){break}var h=new MouseCapture;h.setCursor("default");h.begin(function(k,e){switch(e){case"mouseup":case"keyup":h.end();i.finalUpdate();if(i.options.onChanged&&i.oldcolor!=i.color){i.options.onChanged(i,"changed")}break;case"mousemove":c(k);break}});break}},onPaletteEvent:function(d){switch(d.type){case"mousedown":var c=this;c.oldcolor=c.color;if(c.img_palette.focus){c.img_palette.focus()}var b=function(g){var f=c.colorFromPalette(g.pointerX(),g.pointerY());if(f){c.queuedUpdate("rgb",f,[])}if(c.options.onChanging){c.options.onChanging(c,"changing")}return f};if(!b(d)){break}d.stop();if(this.closeOnDoubleClick(d)){break}var a=new MouseCapture;a.setCursor("default");a.begin(function(f,e){switch(e){case"mouseup":case"keyup":a.end();c.finalUpdate();if(c.options.onChanged&&c.oldcolor!=c.color){c.options.onChanged(c,"changed")}break;case"mousemove":b(f);break}});break}},onNumberBox:function(f,g,e,a,d){var c=Event.element(f);switch(f.type){case"keypress":if(!f||f.ctrlKey||f.altKey){f.stop()}else{if((f.charCode>=48&&f.charCode<=57)||(f.keyCode>=48&&f.keyCode<=57)){}else{if(f.keyCode>0&&f.keyCode<48){}else{f.stop()}}}break;case"keyup":if(f.keyCode!=Event.KEY_TAB){this.updateByMode(g);if(this.options.onChanging){this.options.onChanging(this,"changing")}}if(f.keyCode==Event.KEY_RETURN){this.acceptAndClose();f.stop()}if(f.keyCode==Event.KEY_ESC){this.cancelAndClose();f.stop()}break;case"focus":this.oldcolor=this.color;break;case"blur":var b=this.toNumber(c.value);if(b<e||b>a){if(d){b%=d;if(b<0){b+=d}}else{if(b<e){b=e}else{b=a}}c.value=b;this.updateByMode(g)}if(this.options.onChanged&&this.oldcolor!=this.color){this.options.onChanged(this,"changed")}break}},onInput:function(b){switch(b.type){case"keyup":if(b.keyCode!=Event.KEY_TAB){this.update("rgb",this.decodeHexColor(this.input.value),["input"]);if(this.options.onChanging){this.options.onChanging(this,"changing")}}if(b.keyCode==Event.KEY_RETURN){this.acceptAndClose();b.stop()}if(b.keyCode==Event.KEY_ESC){this.cancelAndClose();b.stop()}break;case"focus":this.oldcolor=this.color;break;case"blur":var a=this.decodeHexColor(this.input.value);this.update("rgb",a,[]);if(this.oldcolor!=this.color){this.input.value=this.internalFormatOutput(a,this.RGBtoHSB(a),this.options.outputFormat);if(this.options.onChanged){this.options.onChanged(this,"changed")}}break}},handleCloseClick:function(b){var a=$(Event.element(b));if(a==this.div||a.descendantOf(this.div)){return}if(a==this.input||a.descendantOf(this.input)){return}this.cancelAndClose()},handleKeyPress:function(a){if(a.keyCode==Event.KEY_ESC){this.cancelAndClose()}},attachButton:function(f,d){f=$(f);if(!f){return}var g;if(d.imgPath){g=d.imgPath}else{g=""}var c=$(document.createElement("a"));c.setStyle({display:"inline-block",visibility:"visible",border:"0px",textDecoration:"none",verticalAlign:"bottom",width:"40px",height:"24px",padding:"0px",marginLeft:"2px",backgroundImage:"url("+g+"drop.png)",backgroundPosition:"0px 0px",backgroundRepeat:"no-repeat",cursor:"default"});c.href="#";for(var a in this.buttonMembers){c[a]=this.buttonMembers[a]}var b=d.color;c.buttonHandler=c.eventHandler.bindAsEventListener(c);c.options=Object.clone(d);c.options.input=f;c.options.pc=this;delete c.options.color;if(!c.options.outputFormat){c.options.outputFormat="#{RR}{GG}{BB}"}Event.observe(c,"click",c.buttonHandler);Event.observe(c,"mouseover",c.buttonHandler);Event.observe(c,"mouseout",c.buttonHandler);Event.observe(c,"mousedown",c.buttonHandler);Event.observe(c,"mouseup",c.buttonHandler);Event.observe(c,"keydown",c.buttonHandler);Event.observe(c,"keyup",c.buttonHandler);if(f.nextSibling){f.parentNode.insertBefore(c,f.nextSibling)}else{f.parentNode.appendChild(c)}c.inputHandler=c.onInput.bindAsEventListener(c);c.observeInput();if(b){f.value=b}c.colorSync(true);return c},buttonMembers:{pressed:false,hovered:false,inputHandler:false,options:{},setImg:function(a){this.setStyle({backgroundPosition:"0px "+(a*-24)+"px"})},observeInput:function(){Event.observe(this.options.input,"keyup",this.inputHandler);Event.observe(this.options.input,"focus",this.inputHandler);Event.observe(this.options.input,"blur",this.inputHandler)},stopObservingInput:function(){Event.stopObserving(this.options.input,"keyup",this.inputHandler);Event.stopObserving(this.options.input,"focus",this.inputHandler);Event.stopObserving(this.options.input,"blur",this.inputHandler)},toggle:function(){if(this.pressed){this.setImg(this.hovered?1:0);this.pressed=false;if(this.popup){this.popup.close();this.popup=null}this.observeInput()}else{var a=this;this.setImg(2);this.pressed=true;this.stopObservingInput();this.popup=new ProColor(Object.extend(Object.clone(this.options),{mode:"popup",closeButton:true,onClosed:function(c,b){a.popup=null;a.setImg(this.hovered?1:0);a.pressed=false;a.observeInput();if(a.options.onClosed){a.options.onClosed(c,b)}},parent:null}))}},colorSync:function(d){var c=this.options.pc.decodeHexColor(this.options.input.value);if(c){if(this.options.showInField){var a=this.options.pc.computeTextColor(c);this.options.input.setStyle({backgroundColor:"#"+c.r.toColorPart()+c.g.toColorPart()+c.b.toColorPart(),color:"#"+a.r.toColorPart()+a.g.toColorPart()+a.b.toColorPart()})}var b=this.options.pc.internalFormatOutput(c,this.options.pc.RGBtoHSB(c),this.options.outputFormat);if(b!=this.options.input.value&&this.options.onChanging){this.options.onChanging(this.options.input,"changing")}if(d){if(b!=this.options.input.value){this.options.input.value=b;if(this.options.onChanged){this.options.onChanged(this.options.input,"changed")}}}}},onInput:function(a){switch(a.type){case"keyup":if(a.keyCode!=Event.KEY_TAB&&this.options.showInField){this.colorSync(false)}break;case"focus":case"blur":this.colorSync(true);break}},eventHandler:function(b){switch(b.type){case"click":b.stop();break;case"keydown":switch(b.keyCode){case Event.KEY_RETURN:case 32:this.toggle();b.stop();break}break;case"keyup":break;case"mousedown":this.focus();var a=this;setTimeout(function(){a.toggle()},20);break;case"mouseup":break;case"mouseover":if(this.pressed){this.setImg(2)}else{this.setImg(1)}this.hovered=true;break;case"mouseout":if(this.pressed){this.setImg(2)}else{this.setImg(0)}this.hovered=false;break}}}});Event.observe(window,"load",function(){$$("input.procolor").each(function(a){ProColor.prototype.attachButton(a,ProColor.prototype.options)})});
js/procolor-1.0/procolor.js ADDED
@@ -0,0 +1,1745 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*--------------------------------------------------------------------------------------------------
2
+ **
3
+ ** PROCOLOR v1.0
4
+ **
5
+ ** Copyright (c) 2009 by the Phantom Inker (inker2576@yahoo.com).
6
+ ** All Rights Reserved.
7
+ **
8
+ **--------------------------------------------------------------------------------------------------
9
+ **
10
+ ** OVERVIEW
11
+ ** --------
12
+ **
13
+ ** ProColor is yet another web color picker, this time for Prototype, and hue-wheel-based,
14
+ ** which seems to be a friendlier concept to artists than many of the RGB-box-based pickers.
15
+ **
16
+ **--------------------------------------------------------------------------------------------------
17
+ **
18
+ ** PROCOLOR LICENSE
19
+ ** ----------------
20
+ **
21
+ ** Redistribution and use in source and binary forms, with or without
22
+ ** modification, are permitted provided that the following conditions are met:
23
+ **
24
+ ** * Redistributions of source code must retain the above copyright
25
+ ** notice, this list of conditions and the following disclaimer.
26
+ **
27
+ ** * Redistributions in binary form must reproduce the above copyright
28
+ ** notice, this list of conditions and the following disclaimer in the
29
+ ** documentation and/or other materials provided with the distribution.
30
+ **
31
+ ** THIS SOFTWARE IS PROVIDED BY THE PHANTOM INKER AND CONTRIBUTORS "AS IS"
32
+ ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33
+ ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34
+ ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
35
+ ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36
+ ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37
+ ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38
+ ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39
+ ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40
+ ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
41
+ ** THE POSSIBILITY OF SUCH DAMAGE.
42
+ **
43
+ **--------------------------------------------------------------------------------------------------
44
+ **
45
+ ** USAGE
46
+ ** -----
47
+ **
48
+ ** Usage is straightforward. Include this file (or better yet, the compressed
49
+ ** version), and then make this call to create a color-picker:
50
+ **
51
+ ** new ProColor(options);
52
+ **
53
+ ** For example, for a static color picker:
54
+ **
55
+ ** new ProColor({ mode:'static', parent:container_element });
56
+ **
57
+ ** Or for a drop-down/popup color picker:
58
+ **
59
+ ** new ProColor({ mode:'popup', input:input_element });
60
+ **
61
+ ** If you want a drop-down color picker the easy way, it's better to use the button factory
62
+ ** method to create them:
63
+ **
64
+ ** <input type='text' value='#FF0000' id='mycolor' />
65
+ ** ...
66
+ ** ProColor.prototype.attachButton('mycolor', options);
67
+ **
68
+ ** Or if that's still too hard, you can make it even simpler by using the automatic factory
69
+ ** method that runs during onload. This factory method uses the current setting of
70
+ ** ProColor.prototype.options for its options, and creates a button attached to any <input>
71
+ ** whose class contains 'procolor':
72
+ **
73
+ ** <input type='text' value='#FF0000' class='procolor' />
74
+ **
75
+ **--------------------------------------------------------------------------------------------------
76
+ **
77
+ ** OPTIONS
78
+ ** -------
79
+ **
80
+ ** ProColor offers many different options for configuring its behavior. All of the important
81
+ ** ones are documented below.
82
+ **
83
+ ** Options:
84
+ **
85
+ ** mode: Either 'static' or 'popup'.
86
+ **
87
+ ** input: Input textbox or hidden field to record color in. (Format: '#RRGGBB' string.)
88
+ **
89
+ ** showInField: Show the current color as the input field's background color (default: false).
90
+ **
91
+ ** parent: In static mode, the containing element to insert this into.
92
+ ** In popup mode, this is the element the popup should be attached to (usually
93
+ ** the same as input).
94
+ **
95
+ ** closeButton: Show close button (default: false for 'static', true for 'popup').
96
+ **
97
+ ** color: Initial color to select (default: extract from input field, or use #FFFFFF).
98
+ **
99
+ ** imgPath: URL to dir containing ProColor's .png files, if they're not in the same place
100
+ ** as the .js file. This is directly prepended to the names of the files, so
101
+ ** it usually must have a trailing '/'.
102
+ **
103
+ ** width: Dimensions of the color picker, in pixels. Default width is 360.
104
+ ** height: Dimensions of the color picker, in pixels. Default height is 192.
105
+ **
106
+ ** offsetx: Offset of color picker's content, from its left edge, in pixels. Default is 0.
107
+ ** offsety: Offset of color picker's content, from its top edge, in pixels. Default is 0.
108
+ **
109
+ ** editbg: Background color of color picker's edit fields. Default is '#FFFFFF'.
110
+ ** edittext: Color of text in color picker's edit fields: Default is '#4C4C4C'.
111
+ **
112
+ ** outputFormat: How to format the text in the textbox. A format string that accepts:
113
+ **
114
+ ** {RR} Two-digit red hex value.
115
+ ** {GG} Two-digit green hex value.
116
+ ** {BB} Two-digit blue hex value.
117
+ ** {R} One-digit red hex value.
118
+ ** {G} One-digit green hex value.
119
+ ** {B} One-digit blue hex value.
120
+ ** {red} Decimal red (0-255).
121
+ ** {grn} Decimal green (0-255).
122
+ ** {blu} Decimal blue (0-255).
123
+ ** {hue} Decimal hue (0-359).
124
+ ** {sat} Decimal saturation (0-100).
125
+ ** {brt} Decimal brightness (0-100).
126
+ ** . All other characters will be copied as-is.
127
+ **
128
+ ** In addition, you may use tokens like {rr} to request lowercase hex instead
129
+ ** of uppercase. The default format string is "#{RR}{GG}{BB}".
130
+ **
131
+ ** onOpening: Called when the color picker is about to appear: callback(this, 'opening').
132
+ ** onOpened: Called after the color picker has appeared: callback(this, 'opened').
133
+ ** onClosing: Called when the color picker is about to be destroyed: callback(this, 'closing').
134
+ ** onClosed: Called after the color picker has been destroyed: callback(this, 'closed').
135
+ **
136
+ ** onChanging: Called when the color is changing (many events): callback(this, 'changing').
137
+ ** onChanged: Called when the color has changed (at mouseup): callback(this, 'changed').
138
+ **
139
+ ** onCancelClick: Called when user presses Esc or clicks outside popup: callback(this, 'cancelclick').
140
+ ** onAcceptClick: Called when user presses Enter or double-clicks: callback(this, 'acceptclick').
141
+ **
142
+ ** onCloseButton: Called when user clicks close button, before closing: callback(this, 'closebutton').
143
+ **
144
+ **--------------------------------------------------------------------------------------------------
145
+ **
146
+ ** CHANGELOG
147
+ ** ---------
148
+ **
149
+ ** Version 1.0 (2009-02-26) - Initial release.
150
+ **
151
+ **------------------------------------------------------------------------------------------------*/
152
+
153
+
154
+ /*--------------------------------------------------------------------------------------------------
155
+ ** Make sure that Prototype has already been loaded.
156
+ */
157
+
158
+ if (typeof Prototype == 'undefined')
159
+ alert("ProColor Error: Prototype is not loaded. Please make sure that your page includes prototype.js before it includes procolor.js.");
160
+ if (Prototype.Version < "1.6")
161
+ alert("ProColor Error: Minimum Prototype 1.6.0 is required; you are using " + Prototype.Version);
162
+
163
+
164
+ /*--------------------------------------------------------------------------------------------------
165
+ ** Add two useful methods to Element. Many other libraries add build(), and ours
166
+ ** is, in theory, compatible with all of their versions.
167
+ */
168
+
169
+ Element.addMethods({
170
+ /* Create a child element with the given options (attributes) and style. */
171
+ build: function(element, type, options, style) {
172
+ var e = $(document.createElement(type));
173
+ $H(options).each(function(pair) { e[pair.key] = pair.value; });
174
+ if (style) e.setStyle(style);
175
+ element.appendChild(e);
176
+ return e;
177
+ },
178
+
179
+ /* Return true if this event was a mouse event that occurred inside the given element. */
180
+ isEventIn: function(element, event) {
181
+ var d = element.getDimensions();
182
+ var p = element.cumulativeOffset();
183
+ var x = event.pointerX(), y = event.pointerY();
184
+ return (x >= p.left && y >= p.top && x < p.left+d.width && y < p.top+d.height);
185
+ }
186
+ });
187
+
188
+
189
+ /*--------------------------------------------------------------------------------------------------
190
+ ** This is a simple class for capturing all mouse input after a mouse button
191
+ ** is held down until the mouse button is released.
192
+ */
193
+
194
+ var MouseCapture = Class.create({
195
+
196
+ initialize: function() { },
197
+
198
+ onEvent: function(event, callback) {
199
+ if (callback && event.type != 'mouseover' && event.type != 'mouseout')
200
+ callback(event, event.type);
201
+ event.stop();
202
+ },
203
+
204
+ setCursor: function(c) {
205
+ if (this.div)
206
+ this.div.setStyle({ cursor: c });
207
+ },
208
+
209
+ begin: function(callback) {
210
+ /* Create our event listener. We'll need this object now, and later on to
211
+ be able to stop listening to events too. */
212
+ this.listener = this.onEvent.bindAsEventListener(this, callback);
213
+
214
+ /* Start observing events. */
215
+ Event.observe(document, 'mouseup', this.listener);
216
+ Event.observe(document, 'mousemove', this.listener);
217
+ Event.observe(document, 'mousedown', this.listener);
218
+ Event.observe(document, 'mouseover', this.listener);
219
+ Event.observe(document, 'mouseout', this.listener);
220
+ Event.observe(document, 'keyup', this.listener);
221
+ Event.observe(document, 'keydown', this.listener);
222
+
223
+ /* Don't let the browser perform text-selection while capturing. */
224
+ this.old_body_ondrag = document.body.ondrag;
225
+ this.old_body_onselectstart = document.body.onselectstart;
226
+ document.body.ondrag = function () { return false; };
227
+ document.body.onselectstart = function () { return false; };
228
+
229
+ var body = Element.extend(document.body);
230
+ var dim = body.getDimensions();
231
+
232
+ /* Build a (nearly) invisible <div> that covers the entire document and that
233
+ will capture all events, even those that would go to iframes. */
234
+ this.div = body.build('div', { }, {
235
+ display: 'block',
236
+ position: 'absolute',
237
+ top: '0px', left: '0px',
238
+ width: dim.width + 'px', height: dim.height + 'px',
239
+ zIndex: 999999999,
240
+ cursor: 'default',
241
+ backgroundColor: '#FFFFFF',
242
+ opacity: 0.0001
243
+ });
244
+ },
245
+
246
+ end: function() {
247
+ /* Remove our invisible event-capturing <div>. */
248
+ this.div.remove();
249
+
250
+ /* Stop event observing. */
251
+ Event.stopObserving(document, 'mouseup', this.listener);
252
+ Event.stopObserving(document, 'mousemove', this.listener);
253
+ Event.stopObserving(document, 'mousedown', this.listener);
254
+ Event.stopObserving(document, 'mouseover', this.listener);
255
+ Event.stopObserving(document, 'mouseout', this.listener);
256
+ Event.stopObserving(document, 'keyup', this.listener);
257
+ Event.stopObserving(document, 'keydown', this.listener);
258
+
259
+ /* Reenable selection. */
260
+ document.body.ondrag = this.old_body_ondrag;
261
+ document.body.onselectstart = this.old_body_onselectstart;
262
+ delete this.old_body_ondrag;
263
+ delete this.old_body_onselectstart;
264
+ }
265
+
266
+ });
267
+
268
+
269
+ /*--------------------------------------------------------------------------------------------------
270
+ ** The ProColor class, which can be used to instantiate ProColor color-picker objects.
271
+ */
272
+
273
+ var ProColor = Class.create({
274
+
275
+
276
+ /*------------------------------------------------------------------------------------------
277
+ ** Default object properties.
278
+ */
279
+
280
+ /* The entire color palette, minus the easy grayscale colors, and packed down to
281
+ consume as little code space as possible. This is stored three hex digits per
282
+ color, in the same order as the visible palette. */
283
+ palette: [
284
+ "F00C30900633963C63",
285
+ "FC9FC0C93F93F96F60",
286
+ "993CC3FF0FF6FF9FFC",
287
+ "3306639966939C39C6",
288
+ "0F09C99F9CFCCF69F0",
289
+ "3C36960630933C6396",
290
+ "6999CC9FF0FF6FC3C9",
291
+ "36603303936F69F0CF",
292
+ "00666C00F66F99FCCF",
293
+ "C9F90F60C63F30930C",
294
+ "96CC6FC3F90C639306",
295
+ "C9C969C6CF9F909606",
296
+ "F0FF9CC69F39F69F06",
297
+ "F66F99FCC936C36C39"
298
+ ],
299
+
300
+ /* These are the default options used by the optional automatic setup routine that
301
+ runs at page onload. */
302
+ options: {
303
+ imgPath:'img/procolor_win_',
304
+ showInField: true
305
+ },
306
+
307
+ /*------------------------------------------------------------------------------------------
308
+ ** Creation and destruction.
309
+ */
310
+
311
+ /* Create this color picker, with the given creation options. */
312
+ initialize: function(options) {
313
+
314
+ /* Determine if we're on an old browser that can't handle alpha PNGs. */
315
+ var browser_version = navigator.appVersion.split("MSIE");
316
+ var browser_version_number = parseFloat(browser_version[1]);
317
+ this.old_ie = (browser_version_number >= 5.5 && browser_version_number < 7
318
+ && document.body.filters);
319
+
320
+ /* Set initial values. */
321
+ this.div = null;
322
+ this.color = null;
323
+ this.listeners = { };
324
+ this.dblclk = { time: 0 };
325
+
326
+ if (options.parent) this.parent = $(options.parent);
327
+ else this.parent = Element.extend(document.body);
328
+
329
+ if (options.input) this.input = $(options.input);
330
+ else this.input = null;
331
+
332
+ this.options = {
333
+ mode: 'static',
334
+ width: 360, height: 192,
335
+ offsetx: 13, offsety: 8,
336
+ input: null,
337
+ showInField: false,
338
+ parent: null,
339
+ closeButton: (options.mode == 'popup'),
340
+ imgPath: "",
341
+ color: (!this.input ? '#FFFFFF'
342
+ : this.input.tagName == 'INPUT' ? this.input.value
343
+ : this.input.innerHTML),
344
+ editbg: '#FFFFFF',
345
+ edittext: '#4C4C4C',
346
+ outputFormat: '#{RR}{GG}{BB}',
347
+ onOpening: null,
348
+ onOpened: null,
349
+ onClosing: null,
350
+ onClosed: null,
351
+ onCloseButton: null,
352
+ onChanging: null,
353
+ onChanged: null,
354
+ onCancelClick: null,
355
+ onAcceptClick: null
356
+ };
357
+ for (var i in options)
358
+ this.options[i] = options[i];
359
+
360
+ if (this.options.onOpening)
361
+ this.options.onOpening(this, 'opening');
362
+
363
+ this.createDiv();
364
+
365
+ if (this.options.mode == 'popup') {
366
+ this.positionPopup();
367
+ Event.observe(document, "mousedown",
368
+ this.closeClickHandler = this.handleCloseClick.bindAsEventListener(this));
369
+ Event.observe(document, "keypress",
370
+ this.keyPressHandler = this.handleKeyPress.bindAsEventListener(this));
371
+ }
372
+
373
+ if (this.options.onOpened)
374
+ this.options.onOpened(this, 'opened');
375
+ },
376
+
377
+ /* Reposition the popup properly relative to its parent element. */
378
+ positionPopup: function() {
379
+ var c_pos = this.div.cumulativeOffset(), c_left = c_pos[0], c_top = c_pos[1];
380
+ var c_dim = this.div.getDimensions(), c_height = c_dim.height, c_width = c_dim.width;
381
+ var w_height = document.viewport.getHeight(), w_width = document.viewport.getWidth();
382
+ var w_scroll = document.viewport.getScrollOffsets();
383
+ var e_dim = $(this.input).cumulativeOffset(), e_top = e_dim[1], e_left = e_dim[0];
384
+ var e_height = $(this.input).getDimensions().height, e_bottom = e_top + e_height;
385
+
386
+ if (e_left + c_width > w_width - 8)
387
+ e_left = w_width - 8 - c_width;
388
+ if (e_left < 8) e_left = 8;
389
+
390
+ var above = (e_bottom + c_height > w_scroll.top + w_height) && (e_bottom - c_height > w_scroll.top);
391
+ var left_px = e_left.toString() + "px";
392
+ var top_px = (above ? (e_top - c_height) : (e_top + e_height)).toString() + "px";
393
+
394
+ this.div.style.left = left_px; this.div.style.top = top_px;
395
+
396
+ this.div.setStyle({ visibility:"", display:"block" });
397
+ },
398
+
399
+ /* Create the main color picker <div> element. This sets up the entire color picker
400
+ and sets up suitable event watching. The color-picker will be created VISIBLE.
401
+ This returns nothing; it merely updates members of this object. */
402
+ createDiv: function() {
403
+ var style = {
404
+ display: 'block',
405
+ width: this.options.width + 'px',
406
+ height: this.options.height + 'px',
407
+ backgroundPosition: '0% 0%',
408
+ backgroundAttachment: 'scroll',
409
+ backgroundRepeat: 'no-repeat',
410
+ backgroundImage: 'url(' + this.options.imgPath + (this.old_ie ? 'bg.gif)' : 'bg.png)'),
411
+ color: '#BBBBD7',
412
+ left: 0,
413
+ top: 0
414
+ };
415
+ if (this.options.mode == 'popup') {
416
+ style.position = "absolute";
417
+ style.display = "none";
418
+ style.visibility = "hidden";
419
+ style.zIndex = 999999;
420
+ }
421
+ else style.position = "relative";
422
+ this.div = $(this.parent).build('div', { className: "procolor_box" }, style);
423
+
424
+ this.img_palette = this.loadBgImage(this.div, 'palette_raw.png', 0, 1, 66, 174);
425
+ this.img_bar_lower = this.loadBgImage(this.div, 'bars.png', 77, 1, 20, 174, { zIndex: 1, opacity: 1.0 });
426
+ this.img_bar_middle = this.loadBgImage(this.div, 'bars.png', 77, 1, 20, 174, { zIndex: 2, opacity: 0.0 });
427
+ this.img_bar_upper = this.loadBgImage(this.div, 'bars.png', 77, 1, 20, 174, { zIndex: 3, opacity: 0.0 });
428
+ this.img_wheel_rgb = this.loadBgImage(this.div, 'wheel_rgb.jpg', 105, 0, 176, 176, { zIndex: 1, opacity: 1.0 });
429
+ this.img_wheel_black = this.loadBgImage(this.div, 'wheel_black.png', 105, 0, 176, 176, { zIndex: 2, opacity: 1.0 });
430
+ this.img_boxes = this.loadBgImage(this.div, 'boxes.png', 287, 25, 50, 149, { zIndex: 1 });
431
+
432
+ this.img_bar_dragger = this.createImageButton(this.div, 'sel_rect',
433
+ 73 + this.options.offsetx, -1 + this.options.offsety, 24, 8, { zIndex: 4 });
434
+ this.img_wheel_dragger = this.createImageButton(this.div, 'sel_circle',
435
+ 184 + this.options.offsetx, 79 + this.options.offsety, 17, 17, { zIndex: 5 });
436
+
437
+ this.listeners.wheel = this.onWheelEvent.bindAsEventListener(this);
438
+ this.img_wheel_black.observe('mousedown', this.listeners.wheel);
439
+ this.img_wheel_dragger.observe('mousedown', this.listeners.wheel);
440
+ this.img_wheel_dragger.observe('keydown', this.listeners.wheel);
441
+
442
+ this.listeners.bar = this.onBarEvent.bindAsEventListener(this);
443
+ this.img_bar_upper.observe('mousedown', this.listeners.bar);
444
+ this.img_bar_dragger.observe('mousedown', this.listeners.bar);
445
+ this.img_bar_dragger.observe('keydown', this.listeners.bar);
446
+
447
+ this.listeners.palette = this.onPaletteEvent.bindAsEventListener(this);
448
+ this.img_palette.observe('mousedown', this.listeners.palette);
449
+
450
+ this.wheel = { left: 106 + this.options.offsetx, top: 1 + this.options.offsety,
451
+ width: 174, height: 174 };
452
+ this.bar = { left: 77 + this.options.offsetx, top: 2 + this.options.offsety,
453
+ width: 20, height: 172 };
454
+ this.wheelsel = { width: 17, height: 17 };
455
+ this.barsel = { width: 24, height: 8 };
456
+
457
+ this.listeners.rgb = this.onNumberBox.bindAsEventListener(this, 'rgb', 0, 255, 0);
458
+ this.r_edit = this.createEdit(this.div, 287, 25, 37, 20, this.listeners.rgb);
459
+ this.g_edit = this.createEdit(this.div, 287, 47, 37, 20, this.listeners.rgb);
460
+ this.b_edit = this.createEdit(this.div, 287, 69, 37, 20, this.listeners.rgb);
461
+
462
+ this.listeners.hue = this.onNumberBox.bindAsEventListener(this, 'hsb', 0, 359, 360);
463
+ this.listeners.satbrt = this.onNumberBox.bindAsEventListener(this, 'hsb', 0, 100, 0);
464
+ this.hue_edit = this.createEdit(this.div, 287, 110, 37, 20, this.listeners.hue);
465
+ this.sat_edit = this.createEdit(this.div, 287, 132, 37, 20, this.listeners.satbrt);
466
+ this.brt_edit = this.createEdit(this.div, 287, 154, 37, 20, this.listeners.satbrt);
467
+
468
+ if (this.options.closeButton) {
469
+ this.img_close = this.createImageButton(this.div, 'close', this.options.width - 40, 0, 24, 16);
470
+ this.listeners.close = this.onCloseEvent.bindAsEventListener(this);
471
+ this.img_close.observe('mouseover', this.listeners.close);
472
+ this.img_close.observe('mouseout', this.listeners.close);
473
+ this.img_close.observe('mousedown', this.listeners.close);
474
+ this.img_close.observe('keydown', this.listeners.close);
475
+ this.img_close.trackingMouse = false;
476
+ }
477
+
478
+ if (this.input && this.input.tagName == 'INPUT') {
479
+ this.listeners.input = this.onInput.bindAsEventListener(this);
480
+ this.input.observe('keyup', this.listeners.input);
481
+ this.input.observe('focus', this.listeners.input);
482
+ this.input.observe('blur', this.listeners.input);
483
+ }
484
+ else this.listeners.input = null;
485
+
486
+ var rgb = this.decodeHexColor(this.options.color);
487
+ if (!rgb) rgb = { r:0, g:0, b:0 };
488
+ this.update('rgb', rgb, []);
489
+ },
490
+
491
+ /* Create a <div> at the given relative coordinates with an image as its background,
492
+ applying the given CSS style options. */
493
+ loadBgImage: function(parent, filename, x, y, w, h, options) {
494
+ var style = {
495
+ display: 'block',
496
+ position: 'absolute',
497
+ width: w + 'px',
498
+ height: h + 'px',
499
+ left: x + this.options.offsetx + 'px',
500
+ top: y + this.options.offsety + 'px',
501
+ padding: '0',
502
+ backgroundImage: 'url(' + this.options.imgPath + filename + ')'
503
+ };
504
+ if (options)
505
+ for (var i in options)
506
+ style[i] = options[i];
507
+ return parent.build('div', { }, style);
508
+ },
509
+
510
+ /* Create an <a href='#'> at the given absolute coordinates,
511
+ applying the given CSS style options. This is remarkably similar to
512
+ creating the <div> above, except that this object is able to take the
513
+ keyboard focus. */
514
+ createImageButton: function(parent, filename, x, y, w, h, options) {
515
+ var style = {
516
+ display: 'block',
517
+ position: 'absolute',
518
+ width: w + 'px',
519
+ height: h + 'px',
520
+ left: x + 'px',
521
+ top: y + 'px',
522
+ border: '0',
523
+ cursor: 'default',
524
+ padding: '0',
525
+ fontSize: '1px', /* Make IE6 respect the width and height */
526
+ backgroundImage: 'url(' + this.options.imgPath + filename
527
+ + (this.old_ie ? '.gif)' : '.png)')
528
+ };
529
+ if (options)
530
+ for (var i in options)
531
+ style[i] = options[i];
532
+ var element = parent.build('a', { href:'#' }, style);
533
+ return element;
534
+ },
535
+
536
+ /* Create an edit field at the given relative coordinates with the given event listener. */
537
+ createEdit: function(parent, x, y, w, h, listener) {
538
+ x += 5; w -= 9;
539
+ y += 2; h -= 6;
540
+ var style = {
541
+ display: 'inline',
542
+ position: 'absolute',
543
+ width: w + 'px',
544
+ height: h + 'px',
545
+ left: x + this.options.offsetx + 'px',
546
+ top: y + this.options.offsety + 'px',
547
+ verticalAlign: 'top',
548
+ backgroundColor: this.options.editbg,
549
+ padding: '0',
550
+ color: this.options.edittext,
551
+ fontFamily: 'Verdana,Tahoma,Arial,sans-serif,sans serif,sans',
552
+ fontSize: '12px',
553
+ fontStyle: 'Normal',
554
+ fontVariant: 'Normal',
555
+ fontWeight: 'Normal',
556
+ textAlign: 'right',
557
+ direction: 'ltr',
558
+ border: 0,
559
+ zIndex: 10
560
+ };
561
+
562
+ var element = parent.build('input', { type:'text', value:'0', maxLength:3 }, style);
563
+
564
+ element.observe('keypress', listener);
565
+ element.observe('keyup', listener);
566
+ element.observe('focus', listener);
567
+ element.observe('blur', listener);
568
+
569
+ return element;
570
+ },
571
+
572
+ /* Close the color picker and "destroy" it. After this has been called, the
573
+ color picker will not be visible on the screen anymore, and its <div> element
574
+ will no longer exist. However, the "this.color" value may still be used to
575
+ identify the last color selected, and may continue to be used until this
576
+ object is garbage-collected. After close() has been called, you may call
577
+ this.initialize(...) to safely create a new <div> element (and color picker)
578
+ within this object again. */
579
+ close: function() {
580
+ if (!this.div) return false;
581
+
582
+ if (this.options.onClosing)
583
+ this.options.onClosing(this, 'closing');
584
+
585
+ if (this.options.closeButton)
586
+ Event.stopObserving(this.img_close);
587
+
588
+ Event.stopObserving(this.r_edit);
589
+ Event.stopObserving(this.g_edit);
590
+ Event.stopObserving(this.b_edit);
591
+ Event.stopObserving(this.hue_edit);
592
+ Event.stopObserving(this.sat_edit);
593
+ Event.stopObserving(this.brt_edit);
594
+
595
+ Event.stopObserving(this.img_wheel_black);
596
+ Event.stopObserving(this.img_bar_upper);
597
+ Event.stopObserving(this.img_palette);
598
+
599
+ Event.stopObserving(this.img_wheel_dragger);
600
+ Event.stopObserving(this.img_bar_dragger);
601
+
602
+ if (this.listeners.input) {
603
+ Event.stopObserving(this.input, 'keyup', this.listeners.input);
604
+ Event.stopObserving(this.input, 'focus', this.listeners.input);
605
+ Event.stopObserving(this.input, 'blur', this.listeners.input);
606
+ }
607
+
608
+ Event.stopObserving(document, "mousedown", this.closeClickHandler);
609
+ Event.stopObserving(document, "keypress", this.keyPressHandler);
610
+ this.div.remove();
611
+ this.div = null;
612
+
613
+ this.listeners = { };
614
+ this.dblclk = { };
615
+
616
+ if (this.input.type != "hidden" && !this.input.disabled)
617
+ this.input.focus();
618
+
619
+ if (this.options.onClosed)
620
+ this.options.onClosed(this, 'closed');
621
+ },
622
+
623
+
624
+ /*------------------------------------------------------------------------------------------
625
+ ** Updating the view (edit boxes) when the model (internal data) changes.
626
+ */
627
+
628
+ updateState: { },
629
+ updateTimeout: false,
630
+
631
+ /* This wrapper around update (below) is a hack for IE that delays and queues
632
+ high-speed updates to avoid overloading the browser's page renderer. */
633
+ queuedUpdate: function(mode, color, sources) {
634
+ if (!Prototype.Browser.IE)
635
+ this.update(mode, color, sources);
636
+ else {
637
+ var t = this;
638
+ t.updateState = { mode:mode, color:color, sources:sources };
639
+ if (t.updateTimeout == false) {
640
+ t.updateTimeout = setTimeout(function() {
641
+ t.updateTimeout = false;
642
+ t.update(t.updateState.mode, t.updateState.color, t.updateState.sources);
643
+ }, 25);
644
+ }
645
+ }
646
+ },
647
+
648
+ /* This concludes a series of high-speed updates. */
649
+ finalUpdate: function() {
650
+ if (this.updateTimeout) {
651
+ clearTimeout(this.updateTimeout);
652
+ this.updateTimeout = false;
653
+ this.update(this.updateState.mode, this.updateState.color, this.updateState.sources);
654
+ this.updateState = { };
655
+ }
656
+ },
657
+
658
+ /* When one of the input fields changes, update all of the others to
659
+ reflect the same state (but take care not to update the originating
660
+ field). */
661
+ update: function(mode, color, sources) {
662
+
663
+ /* Carefully ensure that all of r, g, b, hue, sat, and brt are members
664
+ of 'color', and that all of their values are numbers. */
665
+ if (typeof(color) != 'object')
666
+ color = { r:0, g:0, b:0, hue:0, sat:0, brt:0 };
667
+ color.r = this.toNumber(color.r);
668
+ color.g = this.toNumber(color.g);
669
+ color.b = this.toNumber(color.b);
670
+ color.hue = this.toNumber(color.hue);
671
+ color.sat = this.toNumber(color.sat);
672
+ color.brt = this.toNumber(color.brt);
673
+
674
+ /* Determine both the RGB and HSB values from our given color. */
675
+ var rgb, hsb;
676
+ if (mode == 'rgb') {
677
+ rgb = color;
678
+ hsb = this.RGBtoHSB(rgb);
679
+ }
680
+ else if (mode == 'hsb') {
681
+ hsb = color;
682
+ rgb = this.HSBtoRGB(hsb);
683
+ }
684
+
685
+ if (rgb.r < 0) rgb.r = 0;
686
+ if (rgb.r > 255) rgb.r = 255;
687
+ if (rgb.g < 0) rgb.g = 0;
688
+ if (rgb.g > 255) rgb.g = 255;
689
+ if (rgb.b < 0) rgb.b = 0;
690
+ if (rgb.b > 255) rgb.b = 255;
691
+
692
+ hsb.hue = hsb.hue % 360;
693
+ if (hsb.hue < 0) hsb.hue += 360;
694
+ if (hsb.sat < 0) hsb.sat = 0;
695
+ if (hsb.sat > 100) hsb.sat = 100;
696
+ if (hsb.brt < 0) hsb.brt = 0;
697
+ if (hsb.brt > 100) hsb.brt = 100;
698
+
699
+ /* Determine which sources we're *not* going to update visually. */
700
+ source = { };
701
+ sources.each(function(s) { source[s] = true; });
702
+
703
+ /* Positional representations allow fractional RGB or HSB values, so do those first. */
704
+
705
+ var t = this;
706
+ if (!source.wheel) {
707
+ var o = hsb.brt / 100;
708
+ if (o > 0.9999) o = 0.9999; /* Make sure we can still collect events */
709
+
710
+ t.img_wheel_black.setOpacity(1.0 - o);
711
+
712
+ var angle = ((hsb.hue + 270) % 360) * (Math.PI * 2 / 360);
713
+ var c = Math.cos(angle);
714
+ var s = Math.sin(angle);
715
+ var x = Math.floor(c * hsb.sat * t.wheel.width / 200 + 0.5) + t.wheel.left + ((t.wheel.width-4)/2) + 2;
716
+ var y = Math.floor(s * hsb.sat * t.wheel.height / 200 + 0.5) + t.wheel.top + ((t.wheel.height-4)/2) + 2;
717
+ t.img_wheel_dragger.setStyle({ left:x - Math.floor(t.wheelsel.width/2) + "px",
718
+ top:y - Math.floor(t.wheelsel.height/2) + "px" });
719
+ }
720
+ if (!source.bar) {
721
+ var base_hue = Math.floor(hsb.hue / 60);
722
+ var next_hue = (base_hue + 1) % 6;
723
+ t.img_bar_lower.setStyle({ backgroundPosition:(-base_hue * 20 - 20) + "px 0px" });
724
+ t.img_bar_middle.setStyle({ backgroundPosition:(-next_hue * 20 - 20) + "px 0px" });
725
+ t.img_bar_middle.setOpacity((hsb.hue - base_hue * 60) / 60);
726
+
727
+ var o = (100 - hsb.sat) / 100;
728
+ if (o < 0.0001) o = 0.0001; /* Make sure we can still collect events */
729
+ t.img_bar_upper.setOpacity(o);
730
+
731
+ t.img_bar_dragger.setStyle({ top:t.bar.top - Math.floor(t.barsel.height/2)
732
+ + Math.floor((100-hsb.brt) * t.bar.height/100+0.5) + "px",
733
+ left:t.bar.left+Math.floor(t.bar.width-t.barsel.width)/2 + "px" });
734
+ }
735
+
736
+ /* Non-positional representations require integer RGB or HSB values, so clean up
737
+ any fractional bits. */
738
+ rgb.r = Math.floor(rgb.r + 0.5);
739
+ rgb.g = Math.floor(rgb.g + 0.5);
740
+ rgb.b = Math.floor(rgb.b + 0.5);
741
+ hsb.hue = Math.floor(hsb.hue + 0.5);
742
+ hsb.sat = Math.floor(hsb.sat + 0.5);
743
+ hsb.brt = Math.floor(hsb.brt + 0.5);
744
+ hsb.hue = hsb.hue % 360;
745
+
746
+ /* Compute this.color, which is always the color in CSS-friendly six-digit hex form. */
747
+ this.color = '#' + (rgb.r.toColorPart() + rgb.g.toColorPart() + rgb.b.toColorPart()).toUpperCase();
748
+
749
+ if (!source.rgb) {
750
+ this.r_edit.value = rgb.r;
751
+ this.g_edit.value = rgb.g;
752
+ this.b_edit.value = rgb.b;
753
+ }
754
+ if (!source.hsb) {
755
+ this.hue_edit.value = hsb.hue;
756
+ this.sat_edit.value = hsb.sat;
757
+ this.brt_edit.value = hsb.brt;
758
+ }
759
+
760
+ /* If desired, update the input field. */
761
+ if (this.options.input) {
762
+ var input = $(this.options.input);
763
+ if (!source.input) {
764
+ var value = this.internalFormatOutput(rgb, hsb, this.options.outputFormat);
765
+ if (input.tagName == 'INPUT')
766
+ input.value = value;
767
+ else input.innerHTML = value;
768
+ }
769
+ if (this.options.showInField) {
770
+ var tc = this.computeTextColor(rgb);
771
+ input.setStyle({ backgroundColor:this.color,
772
+ color: '#' + tc.r.toColorPart() + tc.g.toColorPart() + tc.b.toColorPart() });
773
+ }
774
+ }
775
+ },
776
+
777
+
778
+ /*------------------------------------------------------------------------------------------
779
+ ** Various data converters, encoders, and decoders.
780
+ */
781
+
782
+ /* Safely convert an unknown chunk of data to a decimal value, even if it's a string with
783
+ all sorts of weird characters in it. */
784
+ toNumber: function(x) {
785
+ switch (typeof x) {
786
+ case 'number':
787
+ return x;
788
+ case 'string':
789
+ if (matches = /^[^0-9.+-]*([+-]?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?))(?:[^0-9]|$)/.exec(x))
790
+ return Number(matches[1]);
791
+ else return 0;
792
+ case 'boolean':
793
+ return x ? 1 : 0;
794
+ case 'object':
795
+ return x ? 1 : 0;
796
+ case 'function':
797
+ return 1;
798
+ default:
799
+ case 'undefined':
800
+ return 0;
801
+ }
802
+ },
803
+
804
+ /* Format a color, specified as an arbitrary hex string, using the given formatting
805
+ string, as defined in the "formatOutput" option for ProColor. */
806
+ formatOutput: function(color_string, format) {
807
+ if (!format) format = "#{RR}{GG}{BB}";
808
+ var rgb = this.decodeHexColor(color_string);
809
+ if (!rgb) rgb = { r:0, g:0, b:0 };
810
+ return this.internalFormatOutput(rgb, this.RGBtoHSB(rgb), format);
811
+ },
812
+
813
+ /* Format a color, specified as an RGB object and an HSB object, using the given formatting
814
+ string, as defined in the "formatOutput" option for ProColor. */
815
+ internalFormatOutput: function(rgb, hsb, format) {
816
+ /* The previous version of this used String.split(), but String.split() is
817
+ badly broken on IE, and we don't want to include extra libraries to fix
818
+ it, so instead we use some cleverness with String.match() here, which
819
+ *does* work on IE. */
820
+ var pieces = format.match(/(\{\w+\}|[^{]+)/g);
821
+ var output = '';
822
+
823
+ pieces.each(function(piece) {
824
+ var result;
825
+ switch (piece) {
826
+ case '{RR}': result = rgb.r.toColorPart().toUpperCase(); break;
827
+ case '{GG}': result = rgb.g.toColorPart().toUpperCase(); break;
828
+ case '{BB}': result = rgb.b.toColorPart().toUpperCase(); break;
829
+ case '{rr}': result = rgb.r.toColorPart().toLowerCase(); break;
830
+ case '{gg}': result = rgb.g.toColorPart().toLowerCase(); break;
831
+ case '{bb}': result = rgb.b.toColorPart().toLowerCase(); break;
832
+ case '{R}': result = this.halfColorPart(rgb.r).toUpperCase(); break;
833
+ case '{G}': result = this.halfColorPart(rgb.g).toUpperCase(); break;
834
+ case '{B}': result = this.halfColorPart(rgb.b).toUpperCase(); break;
835
+ case '{r}': result = this.halfColorPart(rgb.r).toLowerCase(); break;
836
+ case '{g}': result = this.halfColorPart(rgb.g).toLowerCase(); break;
837
+ case '{b}': result = this.halfColorPart(rgb.b).toLowerCase(); break;
838
+ case '{red}': result = rgb.r.toString(); break;
839
+ case '{grn}': result = rgb.g.toString(); break;
840
+ case '{blu}': result = rgb.b.toString(); break;
841
+ case '{hue}': result = hsb.hue.toString(); break;
842
+ case '{sat}': result = hsb.sat.toString(); break;
843
+ case '{brt}': result = hsb.brt.toString(); break;
844
+ default: result = piece; break;
845
+ }
846
+ output += result;
847
+ });
848
+
849
+ return output;
850
+ },
851
+
852
+ /* Take a standard 0-255 RGB value and convert it to its single-digit-hex pseudo-equivalent.
853
+ CSS allows us to specify colors as #369, for example, so this function can be used to pack
854
+ a truecolor 24-bit color value down to a three-digit 12-bit version like that. */
855
+ halfColorPart: function(v) {
856
+ return Math.floor((v + 8) / 17).toString(16);
857
+ },
858
+
859
+ /* Given a hex color represented in a string, convert that to an RGB object. This does
860
+ its best to decode colors no matter how weird they are, skipping over non-hex characters
861
+ and accepting inputs of varying length. Usually, it returns an RGB object, but if it
862
+ absolutely positively cannot convert the input string to RGB, it will return false. */
863
+ decodeHexColor: function(string) {
864
+ var matches;
865
+
866
+ /* Six-to-eight hex values. Treat as RRGGBB, RRGGBBA, or RRGGBBAA. */
867
+ if (matches = /^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{0,2})(?:[^0-9A-Fa-f]|$)/.exec(string))
868
+ return { r:parseInt(matches[1], 16), g:parseInt(matches[2], 16), b:parseInt(matches[3],16) };
869
+
870
+ /* Five hex values. Treat as RRGGB. */
871
+ if (matches = /^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(string)) {
872
+ var b = parseInt(matches[3], 16);
873
+ return { r:parseInt(matches[1], 16), g:parseInt(matches[2], 16), b:b*16+b };
874
+ }
875
+
876
+ /* Four hex values. Treat as RRGG, B=G. */
877
+ if (matches = /^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(string)) {
878
+ var g = parseInt(matches[2], 16);
879
+ return { r:parseInt(matches[1], 16), g:g, b:g };
880
+ }
881
+
882
+ /* Three hex values. Treat as RGB. */
883
+ if (matches = /^[^0-9A-Fa-f]*([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]{0,2})(?:[^0-9A-Fa-f]|$)/.exec(string)) {
884
+ var r = parseInt(matches[1], 16);
885
+ var g = parseInt(matches[2], 16);
886
+ var b = parseInt(matches[3], 16);
887
+ return { r:r*16+r, g:g*16+g, b:b*16+b };
888
+ }
889
+
890
+ /* Two hex values. Treat as 8-bit grayscale. */
891
+ if (matches = /^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(string)) {
892
+ var g = parseInt(matches[1], 16);
893
+ return { r:g, g:g, b:g };
894
+ }
895
+
896
+ /* One hex value. Treat as 4-bit grayscale. */
897
+ if (matches = /^[^0-9A-Fa-f]*([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(string)) {
898
+ var g = parseInt(matches[1], 16);
899
+ g = g * 16 + g;
900
+ return { r:g, g:g, b:g };
901
+ }
902
+
903
+ /* Zero hex values, or more than eight: Just unknown garbage. */
904
+ return false;
905
+ },
906
+
907
+ /* Compute the "true" brightness of a color, taking into account typical human-eye
908
+ brightness perception of the three primary colors. */
909
+ trueBrightness: function(rgb) {
910
+ return (rgb.r / 255 * 0.30) + (rgb.g / 255 * 0.59) + (rgb.b / 255 * 0.11);
911
+ },
912
+
913
+ /* Compute a text color given a background color. This attempts to find a text color
914
+ that is reasonably legible against the given background color, and it usually finds
915
+ a reasonably tolerable one. */
916
+ computeTextColor: function(rgb) {
917
+ var brt = this.trueBrightness(rgb);
918
+ if (brt < 0.5) {
919
+ var m = Math.floor(brt * 20) + 3;
920
+ var im = 255 * (m - 1);
921
+ }
922
+ else {
923
+ var m = Math.floor((1.0 - brt) * 20) + 3;
924
+ var im = 0;
925
+ }
926
+ return { r:Math.floor((rgb.r+im)/m), g:Math.floor((rgb.g+im)/m), b:Math.floor((rgb.b+im)/m) };
927
+ },
928
+
929
+ /* Convert an RGB object to a HSB object. The HSB object may have fractional values in it.
930
+ The input RGB object is safely converted to numbers and rounded to integers before
931
+ conversion to HSB. */
932
+ RGBtoHSB: function(rgb) {
933
+ var r = Math.floor(this.toNumber(rgb.r) + 0.5);
934
+ var g = Math.floor(this.toNumber(rgb.g) + 0.5);
935
+ var b = Math.floor(this.toNumber(rgb.b) + 0.5);
936
+ if (r < 0) r = 0;
937
+ if (r > 255) r = 255;
938
+ if (g < 0) g = 0;
939
+ if (g > 255) g = 255;
940
+ if (b < 0) b = 0;
941
+ if (b > 255) b = 255;
942
+
943
+ var max, delta, diff, offset;
944
+ var h = r, s = g, v = b;
945
+
946
+ if (r > g) {
947
+ if (r > b) v = max = r, offset = 0, diff = g - b;
948
+ else v = max = b, offset = 240, diff = r - g;
949
+ delta = max - ((g < b) ? g : b);
950
+ }
951
+ else {
952
+ if (g > b) v = max = g, offset = 120, diff = b - r;
953
+ else v = max = b, offset = 240, diff = r - g;
954
+ delta = max - ((r < b) ? r : b);
955
+ }
956
+
957
+ if (max != 0) s = Math.floor((delta * 100) / max + 0.5);
958
+ else s = 0;
959
+
960
+ if (s != 0) {
961
+ h = (offset + Math.floor(diff * 120 / (delta * 2) + 0.5)) % 360;
962
+ if (h < 0) h += 360;
963
+ }
964
+ else h = 0;
965
+
966
+ v = Math.floor(v * 100 / 255 + 0.5);
967
+
968
+ return { hue:h, sat:s, brt:v };
969
+ },
970
+
971
+ /* Convert a HSB object to an RGB object. The HSB object may have fractional values in it.
972
+ The input HSB object is safely converted to numbers before conversion to RGB, but is not
973
+ rounded to integers, which yields a more accurate conversion. The RGB values, however,
974
+ will be integers, and limited to 0-255 each. */
975
+ HSBtoRGB: function(hsb) {
976
+ var v = this.toNumber(hsb.brt);
977
+ if (v < 0) v = 0;
978
+ if (v > 100) v = 100;
979
+ v = v * 255 / 100;
980
+
981
+ var s = this.toNumber(hsb.sat);
982
+ if (s <= 0) {
983
+ v = Math.floor(v + 0.5);
984
+ return { r:v, g:v, b:v };
985
+ }
986
+ if (s > 100) s = 100;
987
+
988
+ var h = this.toNumber(hsb.hue);
989
+ h = h % 360;
990
+ if (h < 0) h += 360;
991
+
992
+ var vs = v * s / 100;
993
+ var vsf = (vs * ((h * 256 / 60) % 256)) / 256;
994
+
995
+ var r, g, b;
996
+ switch (Math.floor(h / 60)) {
997
+ case 0: r = v; g = v-vs+vsf; b = v-vs; break;
998
+ case 1: r = v-vsf; g = v; b = v-vs; break;
999
+ case 2: r = v-vs; g = v; b = v-vs+vsf; break;
1000
+ case 3: r = v-vs; g = v-vsf; b = v; break;
1001
+ case 4: r = v-vs+vsf; g = v-vs; b = v; break;
1002
+ case 5: r = v; g = v-vs; b = v-vsf; break;
1003
+ }
1004
+
1005
+ r = Math.floor(r + 0.5);
1006
+ g = Math.floor(g + 0.5);
1007
+ b = Math.floor(b + 0.5);
1008
+ if (r < 0) r = 0;
1009
+ if (r > 255) r = 255;
1010
+ if (g < 0) g = 0;
1011
+ if (g > 255) g = 255;
1012
+ if (b < 0) b = 0;
1013
+ if (b > 255) b = 255;
1014
+
1015
+ return { r:r, g:g, b:b };
1016
+ },
1017
+
1018
+
1019
+ /*------------------------------------------------------------------------------------------
1020
+ ** Supporting functions for the event handlers (controllers).
1021
+ */
1022
+
1023
+ /* When the user has hit Enter or double-clicked, accept the color and close the popup. */
1024
+ acceptAndClose: function() {
1025
+ if (this.options.onAcceptClick)
1026
+ this.options.onAcceptClick(this, 'acceptclick');
1027
+ if (this.options.mode == 'popup')
1028
+ this.close();
1029
+ },
1030
+
1031
+ /* When the user has hit Esc or clicked outside the popup, close the popup. */
1032
+ cancelAndClose: function() {
1033
+ if (this.options.onCancelClick)
1034
+ this.options.onCancelClick(this, 'cancelclick');
1035
+ if (this.options.mode == 'popup')
1036
+ this.close();
1037
+ },
1038
+
1039
+ /* Because of the way we capture mouse events for tracking, we can't use normal
1040
+ 'dblclick' events, because the browser will never fire them. So we use
1041
+ simulated 'dblclick' testing here to achieve a similar result. */
1042
+ closeOnDoubleClick: function(e) {
1043
+ var x = e.pointerX(), y = e.pointerY();
1044
+ var date = new Date;
1045
+ var time = date.getTime();
1046
+
1047
+ if (Math.abs(this.dblclk.x - x) < 3
1048
+ && Math.abs(this.dblclk.y - y) < 3
1049
+ && time - this.dblclk.time <= 500) {
1050
+ this.dblclk.time = 0;
1051
+ this.acceptAndClose();
1052
+ return true;
1053
+ }
1054
+ else {
1055
+ this.dblclk.x = x;
1056
+ this.dblclk.y = y;
1057
+ this.dblclk.time = time;
1058
+ return false;
1059
+ }
1060
+ },
1061
+
1062
+ /* Compute the brightness given a mouse click on the given *absolute* coordinate
1063
+ of the brightness slider. Returns a simple integer, 0 to 100. */
1064
+ brtFromPoint: function(x, y) {
1065
+ var d = this.img_bar_upper.getDimensions();
1066
+ var p = this.img_bar_upper.cumulativeOffset();
1067
+ if (y < p.top) return 100;
1068
+ else if (y >= p.top + d.height) return 0;
1069
+ else return ((p.top + d.height - 1 - y) * 100 / d.height);
1070
+ },
1071
+
1072
+ /* Compute the hue (angle) and saturation (radius) from the given *absolute*
1073
+ coordinate of the wheel. Returns a partial hsb object (with no brightness value). */
1074
+ hueSatFromPoint: function(x, y) {
1075
+ var d = this.img_wheel_rgb.getDimensions();
1076
+ var p = this.img_wheel_rgb.cumulativeOffset();
1077
+ var dy = (y - (p.top + d.height / 2)) / ((d.height - 4) / 2);
1078
+ var dx = (x - (p.left + d.width / 2)) / ((d.width - 4) / 2);
1079
+ var sat = Math.sqrt(dy * dy + dx * dx) * 100 + 0.5;
1080
+ var hue = Math.atan2(dy, dx) * 180 / Math.PI + 90;
1081
+ if (sat <= 0) hue = sat = 0;
1082
+ if (sat > 100) sat = 100;
1083
+ if (hue < 0) hue += 360;
1084
+ return { sat:sat, hue:hue };
1085
+ },
1086
+
1087
+ /* Given pixel coordinates of the mouse, return the palette color that lies
1088
+ under those coordinates. If the mouse lies outside the palette, return false. */
1089
+ colorFromPalette: function(x, y) {
1090
+ var d = this.img_palette.getDimensions();
1091
+ var p = this.img_palette.cumulativeOffset();
1092
+
1093
+ if (x < p.left || x >= p.left + d.width)
1094
+ return false;
1095
+ x = Math.floor((x - p.left) / 11);
1096
+
1097
+ if (y >= p.top && y < p.top + 12)
1098
+ line = "000333666999CCCFFF";
1099
+ else if (y > p.top + 20 && y < p.top + 20 + this.palette.length * 11)
1100
+ line = this.palette[Math.floor((y - (p.top + 20)) / 11)];
1101
+ else return false;
1102
+
1103
+ var r = parseInt(line.substr(x*3 , 1), 16);
1104
+ var g = parseInt(line.substr(x*3+1, 1), 16);
1105
+ var b = parseInt(line.substr(x*3+2, 1), 16);
1106
+
1107
+ return { r: r*16 + r, g: g*16 + g, b: b * 16 + b };
1108
+ },
1109
+
1110
+ /* Perform an update for input from an edit box, correctly updating only the edit
1111
+ boxes that weren't changed by the user. 'mode' is either 'rgb' or 'hsb', and
1112
+ determines which edit boxes the user changed. */
1113
+ updateByMode: function(mode) {
1114
+ this.update(mode, {
1115
+ r:this.r_edit.value, g:this.g_edit.value, b:this.b_edit.value,
1116
+ hue:this.hue_edit.value, sat:this.sat_edit.value, brt:this.brt_edit.value
1117
+ }, [mode]);
1118
+ },
1119
+
1120
+
1121
+ /*------------------------------------------------------------------------------------------
1122
+ ** Event handlers (controllers) for the various input widgets, and their
1123
+ ** supporting functions.
1124
+ */
1125
+
1126
+ /* Handle events on the close button (X button) */
1127
+ onCloseEvent: function(e) {
1128
+ switch (e.type) {
1129
+ case 'keydown':
1130
+ switch (e.keyCode) {
1131
+ case Event.KEY_RETURN:
1132
+ case 32:
1133
+ if (this.options.onCloseButton)
1134
+ if (!this.options.onCloseButton(this, 'closebutton'))
1135
+ break;
1136
+ if (this.options.mode == 'popup')
1137
+ this.close();
1138
+ break;
1139
+ }
1140
+ break;
1141
+ case 'mouseover':
1142
+ if (!this.img_close.trackingMouse)
1143
+ this.img_close.setStyle({ backgroundPosition:"0px -16px" });
1144
+ break;
1145
+ case 'mouseout':
1146
+ if (!this.img_close.trackingMouse)
1147
+ this.img_close.setStyle({ backgroundPosition:"0px 0px" });
1148
+ break;
1149
+ case 'mousedown':
1150
+ this.img_close.trackingMouse = true;
1151
+ this.img_close.setStyle({ backgroundPosition:"0px -32px" });
1152
+ e.stop();
1153
+
1154
+ if (this.img_close.focus)
1155
+ this.img_close.focus();
1156
+
1157
+ var over = true;
1158
+ var capture = new MouseCapture;
1159
+ capture.setCursor('default');
1160
+
1161
+ capture.begin((function(event, type) {
1162
+ switch (type) {
1163
+ case 'mouseup':
1164
+ case 'keyup':
1165
+ capture.end();
1166
+ this.img_close.trackingMouse = false;
1167
+ if (!over)
1168
+ this.img_close.setStyle({ backgroundPosition:"0px 0px" });
1169
+ else {
1170
+ this.img_close.setStyle({ backgroundPosition:"0px -16px" });
1171
+ if (this.options.onCloseButton)
1172
+ if (!this.options.onCloseButton(this, 'closebutton'))
1173
+ break;
1174
+ if (this.options.mode == 'popup')
1175
+ this.close();
1176
+ }
1177
+ break;
1178
+ case 'mousemove':
1179
+ over = (this.img_close.getStyle('backgroundPosition') == '0px -32px');
1180
+ if (this.img_close.isEventIn(event) != over) {
1181
+ over = !over;
1182
+ if (!over)
1183
+ this.img_close.setStyle({ backgroundPosition:"0px 0px" });
1184
+ else this.img_close.setStyle({ backgroundPosition:"0px -32px" });
1185
+ }
1186
+ break;
1187
+ }
1188
+ }).bind(this));
1189
+ break;
1190
+ }
1191
+ },
1192
+
1193
+ /* Handle events on the brightness slider. */
1194
+ onBarEvent: function(e) {
1195
+ switch (e.type) {
1196
+
1197
+ case 'keydown':
1198
+ var t = this;
1199
+ var brt = this.toNumber(t.brt_edit.value), oldbrt = brt;
1200
+ var shiftKey = e.shiftKey || e.ctrlKey || e.altKey;
1201
+ switch (e.keyCode) {
1202
+ case Event.KEY_UP:
1203
+ brt += shiftKey ? 10 : 1;
1204
+ e.stop();
1205
+ break;
1206
+ case Event.KEY_DOWN:
1207
+ brt -= shiftKey ? 10 : 1;
1208
+ e.stop();
1209
+ break;
1210
+ case Event.KEY_PAGEUP:
1211
+ brt += shiftKey ? 25 : 10;
1212
+ e.stop();
1213
+ break;
1214
+ case Event.KEY_PAGEDOWN:
1215
+ brt -= shiftKey ? 25 : 10;
1216
+ e.stop();
1217
+ break;
1218
+ case Event.KEY_HOME:
1219
+ brt = 100;
1220
+ e.stop();
1221
+ break;
1222
+ case Event.KEY_END:
1223
+ brt = 0;
1224
+ e.stop();
1225
+ break;
1226
+ }
1227
+ if (brt < 0) brt = 0;
1228
+ if (brt > 100) brt = 100;
1229
+ if (t.options.onChanging && (oldbrt != brt))
1230
+ t.options.onChanging(t, 'changing');
1231
+ t.update('hsb', { hue:t.hue_edit.value, sat:t.sat_edit.value, brt:brt }, []);
1232
+ if (t.options.onChanged && (oldbrt != brt))
1233
+ t.options.onChanged(t, 'changed');
1234
+ break;
1235
+
1236
+ case 'mousedown':
1237
+ e.stop();
1238
+ var t = this;
1239
+ t.oldcolor = t.color;
1240
+
1241
+ if (t.img_bar_dragger.focus)
1242
+ t.img_bar_dragger.focus();
1243
+
1244
+ var do_update = function(e) {
1245
+ var hsb = {
1246
+ hue: t.hue_edit.value,
1247
+ sat: t.sat_edit.value,
1248
+ brt: t.brtFromPoint(e.pointerX(), e.pointerY())
1249
+ };
1250
+ t.queuedUpdate('hsb', hsb, []);
1251
+ if (t.options.onChanging)
1252
+ t.options.onChanging(t, 'changing');
1253
+ };
1254
+ do_update(e);
1255
+
1256
+ if (this.closeOnDoubleClick(e))
1257
+ break;
1258
+
1259
+ var capture = new MouseCapture;
1260
+ capture.setCursor('default');
1261
+
1262
+ capture.begin(function(event, type) {
1263
+ switch (type) {
1264
+ case 'mouseup':
1265
+ case 'keyup':
1266
+ capture.end();
1267
+ t.finalUpdate();
1268
+ if (t.options.onChanged && t.oldcolor != t.color)
1269
+ t.options.onChanged(t, 'changed');
1270
+ break;
1271
+ case 'mousemove':
1272
+ do_update(event);
1273
+ break;
1274
+ }
1275
+ });
1276
+ break;
1277
+ }
1278
+ },
1279
+
1280
+ /* Handle events on the color wheel. */
1281
+ onWheelEvent: function(e) {
1282
+ switch (e.type) {
1283
+
1284
+ case 'keydown':
1285
+ var t = this;
1286
+ var hue = this.toNumber(t.hue_edit.value), oldhue = hue;
1287
+ var sat = this.toNumber(t.sat_edit.value), oldsat = sat;
1288
+ var shiftKey = e.shiftKey || e.ctrlKey || e.altKey;
1289
+ switch (e.keyCode) {
1290
+ case Event.KEY_UP:
1291
+ sat += shiftKey ? 10 : 1;
1292
+ e.stop();
1293
+ break;
1294
+ case Event.KEY_DOWN:
1295
+ sat -= shiftKey ? 10 : 1;
1296
+ e.stop();
1297
+ break;
1298
+ case Event.KEY_LEFT:
1299
+ hue -= shiftKey ? 10 : 1;
1300
+ e.stop();
1301
+ break;
1302
+ case Event.KEY_RIGHT:
1303
+ hue += shiftKey ? 10 : 1;
1304
+ e.stop();
1305
+ break;
1306
+ case Event.KEY_PAGEUP:
1307
+ sat += shiftKey ? 25 : 10;
1308
+ e.stop();
1309
+ break;
1310
+ case Event.KEY_PAGEDOWN:
1311
+ sat -= shiftKey ? 25 : 10;
1312
+ e.stop();
1313
+ break;
1314
+ case Event.KEY_HOME:
1315
+ sat = 100;
1316
+ e.stop();
1317
+ break;
1318
+ case Event.KEY_END:
1319
+ sat = 0;
1320
+ e.stop();
1321
+ break;
1322
+ }
1323
+ if (sat < 0) sat = 0;
1324
+ if (sat > 100) sat = 100;
1325
+ hue = hue % 360;
1326
+ if (hue < 0) hue += 360;
1327
+ if (t.options.onChanging && (oldhue != hue || oldsat != sat))
1328
+ t.options.onChanging(t, 'changing');
1329
+ t.update('hsb', { hue:hue, sat:sat, brt:t.brt_edit.value }, []);
1330
+ if (t.options.onChanged && (oldhue != hue || oldsat != sat))
1331
+ t.options.onChanged(t, 'changed');
1332
+ break;
1333
+
1334
+ case 'mousedown':
1335
+ e.stop();
1336
+ var t = this;
1337
+ t.oldcolor = t.color;
1338
+
1339
+ if (t.img_wheel_dragger.focus)
1340
+ t.img_wheel_dragger.focus();
1341
+
1342
+ var do_update = function(e) {
1343
+ var hsb = t.hueSatFromPoint(e.pointerX(), e.pointerY());
1344
+ hsb.brt = t.brt_edit.value;
1345
+ t.queuedUpdate('hsb', hsb, []);
1346
+ if (t.options.onChanging)
1347
+ t.options.onChanging(t, 'changing');
1348
+ };
1349
+ do_update(e);
1350
+
1351
+ if (this.closeOnDoubleClick(e))
1352
+ break;
1353
+
1354
+ var capture = new MouseCapture;
1355
+ capture.setCursor('default');
1356
+
1357
+ capture.begin(function(event, type) {
1358
+ switch (type) {
1359
+ case 'mouseup':
1360
+ case 'keyup':
1361
+ capture.end();
1362
+ t.finalUpdate();
1363
+ if (t.options.onChanged && t.oldcolor != t.color)
1364
+ t.options.onChanged(t, 'changed');
1365
+ break;
1366
+ case 'mousemove':
1367
+ do_update(event);
1368
+ break;
1369
+ }
1370
+ });
1371
+ break;
1372
+ }
1373
+ },
1374
+
1375
+ /* Handle events on the color palette. */
1376
+ onPaletteEvent: function(e) {
1377
+ switch (e.type) {
1378
+
1379
+ case 'mousedown':
1380
+ var t = this;
1381
+ t.oldcolor = t.color;
1382
+
1383
+ if (t.img_palette.focus)
1384
+ t.img_palette.focus();
1385
+
1386
+ var do_update = function(e) {
1387
+ var rgb = t.colorFromPalette(e.pointerX(), e.pointerY());
1388
+ if (rgb)
1389
+ t.queuedUpdate('rgb', rgb, []);
1390
+ if (t.options.onChanging)
1391
+ t.options.onChanging(t, 'changing');
1392
+ return rgb;
1393
+ };
1394
+ if (!do_update(e)) break;
1395
+
1396
+ e.stop();
1397
+
1398
+ if (this.closeOnDoubleClick(e))
1399
+ break;
1400
+
1401
+ var capture = new MouseCapture;
1402
+ capture.setCursor('default');
1403
+
1404
+ capture.begin(function(event, type) {
1405
+ switch (type) {
1406
+ case 'mouseup':
1407
+ case 'keyup':
1408
+ capture.end();
1409
+ t.finalUpdate();
1410
+ if (t.options.onChanged && t.oldcolor != t.color)
1411
+ t.options.onChanged(t, 'changed');
1412
+ break;
1413
+ case 'mousemove':
1414
+ do_update(event);
1415
+ break;
1416
+ }
1417
+ });
1418
+ break;
1419
+ }
1420
+ },
1421
+
1422
+ /* Handle events in one of the numeric input boxes on the right. */
1423
+ onNumberBox: function(event, mode, min, max, mod) {
1424
+ var element = Event.element(event);
1425
+
1426
+ switch (event.type) {
1427
+
1428
+ case 'keypress':
1429
+ /* Only allow numbers to be typed into the input field. This is more complex
1430
+ than it sounds, because the browsers do *not* agree on what events appear
1431
+ for keypresses, so we have to handle multiple "standards" here. */
1432
+ if (!event || event.ctrlKey || event.altKey) {
1433
+ /* Broken event, or ctrl/alt being held down. */
1434
+ event.stop();
1435
+ }
1436
+ else if ((event.charCode >= 0x30 && event.charCode <= 0x39)
1437
+ || (event.keyCode >= 0x30 && event.keyCode <= 0x39)) {
1438
+ /* A number, as either a charCode (Firefox) or as a keyCode (IE). */
1439
+ }
1440
+ else if (event.keyCode > 0 && event.keyCode < 48) {
1441
+ /* A control key, like an arrow key or tab. */
1442
+ }
1443
+ else {
1444
+ /* All other unknown keys are rejected. */
1445
+ event.stop();
1446
+ }
1447
+ break;
1448
+
1449
+ case 'keyup':
1450
+ if (event.keyCode != Event.KEY_TAB) {
1451
+ this.updateByMode(mode);
1452
+ if (this.options.onChanging)
1453
+ this.options.onChanging(this, 'changing');
1454
+ }
1455
+ if (event.keyCode == Event.KEY_RETURN) {
1456
+ this.acceptAndClose();
1457
+ event.stop();
1458
+ }
1459
+ if (event.keyCode == Event.KEY_ESC) {
1460
+ this.cancelAndClose();
1461
+ event.stop();
1462
+ }
1463
+ break;
1464
+
1465
+ case 'focus':
1466
+ this.oldcolor = this.color;
1467
+ break;
1468
+
1469
+ case 'blur':
1470
+ var v = this.toNumber(element.value);
1471
+ if (v < min || v > max) {
1472
+ if (mod) {
1473
+ v %= mod;
1474
+ if (v < 0) v += mod;
1475
+ }
1476
+ else if (v < min) v = min;
1477
+ else v = max;
1478
+ element.value = v;
1479
+ this.updateByMode(mode);
1480
+ }
1481
+ if (this.options.onChanged && this.oldcolor != this.color)
1482
+ this.options.onChanged(this, 'changed');
1483
+ break;
1484
+ }
1485
+ },
1486
+
1487
+ /* Handle events in the primary formatted-text input field. */
1488
+ onInput: function(event) {
1489
+ switch (event.type) {
1490
+ case 'keyup':
1491
+ if (event.keyCode != Event.KEY_TAB) {
1492
+ this.update('rgb', this.decodeHexColor(this.input.value), ['input']);
1493
+ if (this.options.onChanging)
1494
+ this.options.onChanging(this, 'changing');
1495
+ }
1496
+ if (event.keyCode == Event.KEY_RETURN) {
1497
+ this.acceptAndClose();
1498
+ event.stop();
1499
+ }
1500
+ if (event.keyCode == Event.KEY_ESC) {
1501
+ this.cancelAndClose();
1502
+ event.stop();
1503
+ }
1504
+ break;
1505
+ case 'focus':
1506
+ this.oldcolor = this.color;
1507
+ break;
1508
+ case 'blur':
1509
+ var rgb = this.decodeHexColor(this.input.value);
1510
+ this.update('rgb', rgb, []);
1511
+ if (this.oldcolor != this.color) {
1512
+ this.input.value = this.internalFormatOutput(rgb, this.RGBtoHSB(rgb),
1513
+ this.options.outputFormat);
1514
+ if (this.options.onChanged)
1515
+ this.options.onChanged(this, 'changed');
1516
+ }
1517
+ break;
1518
+ }
1519
+ },
1520
+
1521
+
1522
+ /*------------------------------------------------------------------------------------------
1523
+ ** Safety closing methods: These let the user click outside the popup or hit Escape
1524
+ ** to close it.
1525
+ */
1526
+
1527
+ /* Handle clicks outside the popup. */
1528
+ handleCloseClick: function(e) {
1529
+ var elem = $(Event.element(e));
1530
+ if (elem == this.div || elem.descendantOf(this.div)) return;
1531
+ if (elem == this.input || elem.descendantOf(this.input)) return;
1532
+ this.cancelAndClose();
1533
+ },
1534
+
1535
+ /* Handle key presses that would close the popup. */
1536
+ handleKeyPress: function(e) {
1537
+ if (e.keyCode == Event.KEY_ESC)
1538
+ this.cancelAndClose();
1539
+ },
1540
+
1541
+ /*------------------------------------------------------------------------------------------
1542
+ ** Special factory method: This creates a popup button immediately after the given
1543
+ ** element, and sets up a watch on that element so that if the element changes, its
1544
+ ** colors will be updated accordingly even if the popup is not open.
1545
+ */
1546
+
1547
+ attachButton: function(e, options) {
1548
+ e = $(e);
1549
+ if (!e) return;
1550
+
1551
+ var imgPath;
1552
+ if (options.imgPath) imgPath = options.imgPath;
1553
+ else imgPath = "";
1554
+
1555
+ var button = $(document.createElement('a'));
1556
+ button.setStyle({ display:'inline-block', visibility:'visible',
1557
+ border:'0px', textDecoration:'none', verticalAlign:'bottom',
1558
+ width:'40px', height:'24px', padding:'0px', marginLeft:'2px',
1559
+ backgroundImage:'url(' + imgPath + 'drop.png)', backgroundPosition:'0px 0px',
1560
+ backgroundRepeat:'no-repeat', cursor:'default' });
1561
+ button.href = '#';
1562
+
1563
+ for (var m in this.buttonMembers)
1564
+ button[m] = this.buttonMembers[m];
1565
+
1566
+ var color = options.color;
1567
+
1568
+ button.buttonHandler = button.eventHandler.bindAsEventListener(button);
1569
+ button.options = Object.clone(options);
1570
+ button.options.input = e;
1571
+ button.options.pc = this;
1572
+ delete button.options.color;
1573
+ if (!button.options.outputFormat)
1574
+ button.options.outputFormat = '#{RR}{GG}{BB}';
1575
+
1576
+ Event.observe(button, "click", button.buttonHandler);
1577
+ Event.observe(button, "mouseover", button.buttonHandler);
1578
+ Event.observe(button, "mouseout", button.buttonHandler);
1579
+ Event.observe(button, "mousedown", button.buttonHandler);
1580
+ Event.observe(button, "mouseup", button.buttonHandler);
1581
+ Event.observe(button, "keydown", button.buttonHandler);
1582
+ Event.observe(button, "keyup", button.buttonHandler);
1583
+
1584
+ if (e.nextSibling)
1585
+ e.parentNode.insertBefore(button, e.nextSibling);
1586
+ else e.parentNode.appendChild(button);
1587
+
1588
+ button.inputHandler = button.onInput.bindAsEventListener(button);
1589
+ button.observeInput();
1590
+
1591
+ if (color) e.value = color;
1592
+ button.colorSync(true);
1593
+
1594
+ return button;
1595
+ },
1596
+
1597
+ buttonMembers: {
1598
+ pressed: false,
1599
+ hovered: false,
1600
+ inputHandler: false,
1601
+ options: { },
1602
+
1603
+ setImg: function(n) {
1604
+ this.setStyle({ backgroundPosition:'0px ' + (n*-24) + 'px' });
1605
+ },
1606
+
1607
+ observeInput: function() {
1608
+ Event.observe(this.options.input, 'keyup', this.inputHandler);
1609
+ Event.observe(this.options.input, 'focus', this.inputHandler);
1610
+ Event.observe(this.options.input, 'blur', this.inputHandler);
1611
+ },
1612
+
1613
+ stopObservingInput: function() {
1614
+ Event.stopObserving(this.options.input, 'keyup', this.inputHandler);
1615
+ Event.stopObserving(this.options.input, 'focus', this.inputHandler);
1616
+ Event.stopObserving(this.options.input, 'blur', this.inputHandler);
1617
+ },
1618
+
1619
+ toggle: function() {
1620
+ if (this.pressed) {
1621
+ this.setImg(this.hovered ? 1 : 0);
1622
+ this.pressed = false;
1623
+ if (this.popup) {
1624
+ this.popup.close();
1625
+ this.popup = null;
1626
+ }
1627
+ this.observeInput();
1628
+ }
1629
+ else {
1630
+ var t = this;
1631
+ this.setImg(2);
1632
+ this.pressed = true;
1633
+ this.stopObservingInput();
1634
+ this.popup = new ProColor(Object.extend(Object.clone(this.options), {
1635
+ mode: 'popup',
1636
+ closeButton: true,
1637
+ onClosed: function(p, a) {
1638
+ t.popup = null;
1639
+ t.setImg(this.hovered ? 1 : 0);
1640
+ t.pressed = false;
1641
+ t.observeInput();
1642
+ if (t.options.onClosed)
1643
+ t.options.onClosed(p, a);
1644
+ },
1645
+ parent: null
1646
+ }));
1647
+ }
1648
+ },
1649
+
1650
+ colorSync: function(update_value) {
1651
+ var rgb = this.options.pc.decodeHexColor(this.options.input.value);
1652
+ if (rgb) {
1653
+ if (this.options.showInField) {
1654
+ var tc = this.options.pc.computeTextColor(rgb);
1655
+ this.options.input.setStyle({
1656
+ backgroundColor: '#' + rgb.r.toColorPart() + rgb.g.toColorPart() + rgb.b.toColorPart(),
1657
+ color: '#' + tc.r.toColorPart() + tc.g.toColorPart() + tc.b.toColorPart()
1658
+ });
1659
+ }
1660
+ var newvalue = this.options.pc.internalFormatOutput(rgb,
1661
+ this.options.pc.RGBtoHSB(rgb), this.options.outputFormat);
1662
+ if (newvalue != this.options.input.value && this.options.onChanging)
1663
+ this.options.onChanging(this.options.input, 'changing');
1664
+ if (update_value) {
1665
+ if (newvalue != this.options.input.value) {
1666
+ this.options.input.value = newvalue;
1667
+ if (this.options.onChanged)
1668
+ this.options.onChanged(this.options.input, 'changed');
1669
+ }
1670
+ }
1671
+ }
1672
+ },
1673
+
1674
+ onInput: function(event) {
1675
+ switch (event.type) {
1676
+ case 'keyup':
1677
+ if (event.keyCode != Event.KEY_TAB && this.options.showInField)
1678
+ this.colorSync(false);
1679
+ break;
1680
+ case 'focus':
1681
+ case 'blur':
1682
+ this.colorSync(true);
1683
+ break;
1684
+ }
1685
+ },
1686
+
1687
+ eventHandler: function(event) {
1688
+ switch (event.type) {
1689
+ case 'click':
1690
+ event.stop();
1691
+ break;
1692
+ case 'keydown':
1693
+ switch (event.keyCode) {
1694
+ case Event.KEY_RETURN:
1695
+ case 32:
1696
+ this.toggle();
1697
+ event.stop();
1698
+ break;
1699
+ }
1700
+ break;
1701
+ case 'keyup':
1702
+ break;
1703
+ case 'mousedown':
1704
+ this.focus();
1705
+ /* We open the color-picker after a very short delay, because if we open
1706
+ it immediately, the browser gets confused about the focus change and
1707
+ closes it immediately as well. So the delay gives just enough time for
1708
+ this event to propagate the rest of the way and leave the browser in a
1709
+ sensible state. */
1710
+ var t = this;
1711
+ setTimeout(function() { t.toggle(); }, 20);
1712
+ break;
1713
+ case 'mouseup':
1714
+ break;
1715
+ case 'mouseover':
1716
+ if (this.pressed)
1717
+ this.setImg(2);
1718
+ else this.setImg(1);
1719
+ this.hovered = true;
1720
+ break;
1721
+ case 'mouseout':
1722
+ if (this.pressed)
1723
+ this.setImg(2);
1724
+ else this.setImg(0);
1725
+ this.hovered = false;
1726
+ break;
1727
+ }
1728
+ }
1729
+ }
1730
+
1731
+ });
1732
+
1733
+
1734
+ /*--------------------------------------------------------------------------------------------------
1735
+ ** After the document has loaded, catch any <input> fields with a 'procolor' classname
1736
+ ** and add dropdown buttons to them. If you need to alter the default options used by this,
1737
+ ** you can do so anywhere in your page by updating ProColor.prototype.options with your
1738
+ ** desired options.
1739
+ */
1740
+
1741
+ Event.observe(window, 'load', function() {
1742
+ $$('input.procolor').each(function(e) {
1743
+ ProColor.prototype.attachButton(e, ProColor.prototype.options);
1744
+ });
1745
+ });
js/procolor-1.0/prototype.compressed.js ADDED
@@ -0,0 +1 @@
 
1
+ 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 b=null,c=$A(arguments);if(Object.isFunction(c[0])){b=c.shift()}function a(){this.initialize.apply(this,arguments)}Object.extend(a,Class.Methods);a.superclass=b;a.subclasses=[];if(b){var e=function(){};e.prototype=b.prototype;a.prototype=new e;b.subclasses.push(a)}for(var d=0;d<c.length;d++){a.addMethods(c[d])}if(!a.prototype.initialize){a.prototype.initialize=Prototype.emptyFunction}a.prototype.constructor=a;return a}};Class.Methods={addMethods:function(b){var e=this.superclass&&this.superclass.prototype;var d=Object.keys(b);if(!Object.keys({toString:true}).length){d.push("toString","valueOf")}for(var f=0,c=d.length;f<c;f++){var a=d[f],g=b[a];if(e&&Object.isFunction(g)&&g.argumentNames().first()=="$super"){var h=g;g=(function(i){return function(){return e[i].apply(this,arguments)}})(a).wrap(h);g.valueOf=h.valueOf.bind(h);g.toString=h.toString.bind(h)}this.prototype[a]=g}return this}};var Abstract={};Object.extend=function(c,b){for(var a in b){c[a]=b[a]}return c};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(c){var d=typeof c;switch(d){case"undefined":case"function":case"unknown":return;case"boolean":return c.toString()}if(c===null){return"null"}if(c.toJSON){return c.toJSON()}if(Object.isElement(c)){return}var b=[];for(var a in c){var e=Object.toJSON(c[a]);if(!Object.isUndefined(e)){b.push(a.toJSON()+": "+e)}}return"{"+b.join(", ")+"}"},toQueryString:function(a){return $H(a).toQueryString()},toHTML:function(a){return a&&a.toHTML?a.toHTML():String.interpret(a)},keys:function(b){var c=[];for(var a in b){c.push(a)}return c},values:function(b){var c=[];for(var a in b){c.push(b[a])}return c},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 c=this,a=$A(arguments),b=a.shift();return function(){return c.apply(b,a.concat($A(arguments)))}},bindAsEventListener:function(){var c=this,a=$A(arguments),b=a.shift();return function(d){return c.apply(b,[d||window.event].concat(a))}},curry:function(){if(!arguments.length){return this}var b=this,a=$A(arguments);return function(){return b.apply(this,a.concat($A(arguments)))}},delay:function(){var c=this,b=$A(arguments),a=b.shift()*1000;return window.setTimeout(function(){return c.apply(c,b)},a)},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 b;for(var c=0,a=arguments.length;c<a;c++){var d=arguments[c];try{b=d();break}catch(f){}}return b}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(a,b){this.callback=a;this.frequency=b;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(b,d){var e="",a=this,c;d=arguments.callee.prepareReplacement(d);while(a.length>0){if(c=a.match(b)){e+=a.slice(0,c.index);e+=String.interpret(d(c));a=a.slice(c.index+c[0].length)}else{e+=a,a=""}}return e},sub:function(a,b,c){b=this.gsub.prepareReplacement(b);c=Object.isUndefined(c)?1:c;return this.gsub(a,function(d){if(--c<0){return d[0]}return b(d)})},scan:function(a,b){this.gsub(a,b);return String(this)},truncate:function(a,b){a=a||30;b=Object.isUndefined(b)?"...":b;return this.length>a?this.slice(0,a-b.length)+b: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 b=this.charAt(0)=="-"?d[0].charAt(0).toUpperCase()+d[0].substring(1):d[0];for(var c=1;c<a;c++){b+=d[c].charAt(0).toUpperCase()+d[c].substring(1)}return b},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(b,a){return new Template(this,a).evaluate(b)}});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(b,a){this.template=b.toString();this.pattern=a||Template.Pattern},evaluate:function(a){if(Object.isFunction(a.toTemplateReplacements)){a=a.toTemplateReplacements()}return this.template.gsub(this.pattern,function(f){if(a==null){return""}var c=f[1]||"";if(c=="\\"){return f[2]}var d=a,g=f[3];var b=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;f=b.exec(g);if(f==null){return c}while(f!=null){var e=f[1].startsWith("[")?f[2].gsub("\\\\]","]"):f[1];d=d[e];if(null==d||""==f[3]){break}g=g.substring("["==f[3]?f[1].length:f[0].length);f=b.exec(g)}return c+String.interpret(d)})}});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(a,d,c){var b=-a,e=[],f=this.toArray();if(a<1){return f}while((b+=a)<f.length){e.push(f.slice(b,b+a))}return e.collect(d,c)},all:function(b,a){b=b||Prototype.K;var c=true;this.each(function(e,d){c=c&&!!b.call(a,e,d);if(!c){throw $break}});return c},any:function(b,a){b=b||Prototype.K;var c=false;this.each(function(e,d){if(c=!!b.call(a,e,d)){throw $break}});return c},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(b,a){var c;this.each(function(e,d){if(b.call(a,e,d)){c=e;throw $break}});return c},findAll:function(c,b){var a=[];this.each(function(e,d){if(c.call(b,e,d)){a.push(e)}});return a},grep:function(a,d,c){d=d||Prototype.K;var b=[];if(Object.isString(a)){a=new RegExp(a)}this.each(function(f,e){if(a.match(f)){b.push(d.call(c,f,e))}});return b},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(a,b){b=Object.isUndefined(b)?null:b;return this.eachSlice(a,function(c){while(c.length<a){c.push(b)}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(b,a){b=b||Prototype.K;var c;this.each(function(e,d){e=b.call(a,e,d);if(c==null||e>=c){c=e}});return c},min:function(b,a){b=b||Prototype.K;var c;this.each(function(e,d){e=b.call(a,e,d);if(c==null||e<c){c=e}});return c},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(a){var b=[];this.each(function(c){b.push(c[a])});return b},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 a=c.length||0,b=new Array(a);while(a--){b[a]=c[a]}return b}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 a=c.length||0,b=new Array(a);while(a--){b[a]=c[a]}return b}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(c){for(var b=0,a=this.length;b<a;b++){c(this[b])}},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,b){b||(b=0);var a=this.length;if(b<0){b=a+b}for(;b<a;b++){if(this[b]===c){return b}}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 c=0,a=this.length;c<a;c++){e.push(this[c])}for(var c=0,a=arguments.length;c<a;c++){if(Object.isArray(arguments[c])){for(var b=0,d=arguments[c].length;b<d;b++){e.push(arguments[c][b])}}else{e.push(arguments[c])}}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(a,c){var b=this.toString(c||10);return"0".times(a-b.length)+b},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(c,e){var b=encodeURIComponent(e.key),d=e.value;if(d&&typeof d=="object"){if(Object.isArray(d)){return c.concat(d.map(a.curry(b)))}}else{c.push(a(b,d))}return c}).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(c,b,d,a){this.each(function(f){if(Object.isFunction(f[c])){try{f[c].apply(f,[b,d,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,a,b){$super(b);this.transport=Ajax.getTransport();this.request(a)},request:function(a){this.url=a;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 b=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(b)}Ajax.Responders.dispatch("onCreate",this,b);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 b=this.options.requestHeaders;if(Object.isFunction(b.push)){for(var d=0,a=b.length;d<a;d+=2){e[b[d]]=b[d+1]}}else{$H(b).each(function(f){e[f.key]=f.value})}}for(var c in e){this.transport.setRequestHeader(c,e[c])}},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(f){this.dispatchException(f)}var d=b.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&d&&d.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(f){this.dispatchException(f)}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,c,a,b){this.container={success:(c.success||c),failure:(c.failure||(c.success?null:c))};b=Object.clone(b);var d=b.onComplete;b.onComplete=(function(f,e){this.updateContent(f.responseText);if(Object.isFunction(d)){d(f,e)}}).bind(this);$super(a,b)},updateContent:function(d){var b=this.container[this.success()?"success":"failure"],c=this.options;if(!c.evalScripts){d=d.stripScripts()}if(b=$(b)){if(c.insertion){if(Object.isString(c.insertion)){var a={};a[c.insertion]=d;b.insert(a)}else{c.insertion(b,d)}}else{b.update(d)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,c,a,b){$super(b);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=c;this.url=a;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 $(c){if(arguments.length>1){for(var d=0,a=[],b=arguments.length;d<b;d++){a.push($(arguments[d]))}return a}if(Object.isString(c)){c=document.getElementById(c)}return Element.extend(c)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(f,d){var c=[];var e=document.evaluate(f,$(d)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var b=0,a=e.snapshotLength;b<a;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(d,f){d=$(d);if(Object.isString(f)||Object.isNumber(f)||Object.isElement(f)||(f&&(f.toElement||f.toHTML))){f={bottom:f}}var e,b,c,g;for(var a in f){e=f[a];a=a.toLowerCase();b=Element._insertionTranslations[a];if(e&&e.toElement){e=e.toElement()}if(Object.isElement(e)){b(d,e);continue}e=Object.toHTML(e);c=((a=="before"||a=="after")?d.parentNode:d).tagName.toUpperCase();g=Element._getContentFromAnonymousElement(c,e.stripScripts());if(a=="top"||a=="after"){g.reverse()}g.each(b.curry(d));e.evalScripts.bind(e).defer()}return d},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(a){a=$(a);var b="<"+a.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(f){var c=f.first(),d=f.last();var e=(a[c]||"").toString();if(e){b+=" "+d+"="+e.inspect(true)}});return b+">"},recursivelyCollect:function(c,b){c=$(c);var a=[];while(c=c[b]){if(c.nodeType==1){a.push(Element.extend(c))}}return a},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(c,d,b){c=$(c);if(arguments.length==1){return $(c.parentNode)}var a=c.ancestors();return Object.isNumber(d)?a[d]:Selector.findElement(a,d,b)},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(b,d,a){b=$(b);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(b))}var c=b.nextSiblings();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},select:function(){var b=$A(arguments),a=$(b.shift());return Selector.findChildElements(a,b)},adjacent:function(){var b=$A(arguments),a=$(b.shift());return Selector.findChildElements(a.parentNode,b).without(a)},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(b,a){b=$(b);if(Prototype.Browser.IE){var c=Element._attributeTranslations.read;if(c.values[a]){return c.values[a](b,a)}if(c.names[a]){a=c.names[a]}if(a.include(":")){return(!b.attributes||!b.attributes[a])?null:b.attributes[a].value}}return b.getAttribute(a)},writeAttribute:function(d,c,f){d=$(d);var b={},e=Element._attributeTranslations.write;if(typeof c=="object"){b=c}else{b[c]=Object.isUndefined(f)?true:f}for(var a in b){c=e.names[a]||a;f=b[a];if(e.values[a]){c=e.values[a](d,f)}if(f===false||f===null){d.removeAttribute(c)}else{if(f===true){d.setAttribute(c,c)}else{d.setAttribute(c,f)}}}return d},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(b,a){if(!(b=$(b))){return}var c=b.className;return(c.length>0&&(c==a||new RegExp("(^|\\s)"+a+"(\\s|$)").test(c)))},addClassName:function(b,a){if(!(b=$(b))){return}if(!b.hasClassName(a)){b.className+=(b.className?" ":"")+a}return b},removeClassName:function(b,a){if(!(b=$(b))){return}b.className=b.className.replace(new RegExp("(^|\\s+)"+a+"(\\s+|$)")," ").strip();return b},toggleClassName:function(b,a){if(!(b=$(b))){return}return b[b.hasClassName(a)?"removeClassName":"addClassName"](a)},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(a,c){a=$(a);c=c=="float"?"cssFloat":c.camelize();var d=a.style[c];if(!d||d=="auto"){var b=document.defaultView.getComputedStyle(a,null);d=b?b[c]:null}if(c=="opacity"){return d?parseFloat(d):1}return d=="auto"?null:d},getOpacity:function(a){return $(a).getStyle("opacity")},setStyle:function(e,c){e=$(e);var b=e.style,d;if(Object.isString(c)){e.style.cssText+=";"+c;return c.include("opacity")?e.setOpacity(c.match(/opacity:\s*(\d?\.?\d*)/)[1]):e}for(var a in c){if(a=="opacity"){e.setOpacity(c[a])}else{b[(a=="float"||a=="cssFloat")?(Object.isUndefined(b.styleFloat)?"cssFloat":"styleFloat"):a]=c[a]}}return e},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 e=c.style;var a=e.visibility;var b=e.position;var d=e.display;e.visibility="hidden";e.position="absolute";e.display="block";var h=c.clientWidth;var f=c.clientHeight;e.display=d;e.position=b;e.visibility=a;return{width:h,height:f}},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(a){var b=0,c=0;do{b+=a.offsetTop||0;c+=a.offsetLeft||0;a=a.offsetParent}while(a);return Element._returnOffset(c,b)},positionedOffset:function(a){var b=0,d=0;do{b+=a.offsetTop||0;d+=a.offsetLeft||0;a=a.offsetParent;if(a){if(a.tagName.toUpperCase()=="BODY"){break}var c=Element.getStyle(a,"position");if(c!=="static"){break}}}while(a);return Element._returnOffset(d,b)},absolutize:function(b){b=$(b);if(b.getStyle("position")=="absolute"){return b}var a=b.positionedOffset();var f=a[1];var e=a[0];var c=b.clientWidth;var d=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=d+"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(a){var b=0,c=0;do{b+=a.scrollTop||0;c+=a.scrollLeft||0;a=a.parentNode}while(a);return Element._returnOffset(c,b)},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(c){var b=0,d=0;var a=c;do{b+=a.offsetTop||0;d+=a.offsetLeft||0;if(a.offsetParent==document.body&&Element.getStyle(a,"position")=="absolute"){break}}while(a=a.offsetParent);a=c;do{if(!Prototype.Browser.Opera||(a.tagName&&(a.tagName.toUpperCase()=="BODY"))){b-=a.scrollTop||0;d-=a.scrollLeft||0}}while(a=a.parentNode);return Element._returnOffset(d,b)},clonePosition:function(c,a){var d=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});a=$(a);var e=a.viewportOffset();c=$(c);var f=[0,0];var b=null;if(Element.getStyle(c,"position")=="absolute"){b=c.getOffsetParent();f=b.viewportOffset()}if(b==document.body){f[0]-=document.body.offsetLeft;f[1]-=document.body.offsetTop}if(d.setLeft){c.style.left=(e[0]-f[0]+d.offsetLeft)+"px"}if(d.setTop){c.style.top=(e[1]-f[1]+d.offsetTop)+"px"}if(d.setWidth){c.style.width=a.offsetWidth+"px"}if(d.setHeight){c.style.height=a.offsetHeight+"px"}return c}};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(a,c,d){switch(d){case"left":case"top":case"right":case"bottom":if(a(c,"position")==="static"){return null}case"height":case"width":if(!Element.visible(c)){return null}var e=parseInt(a(c,d),10);if(e!==c["offset"+d.capitalize()]){return e+"px"}var b;if(d==="height"){b=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{b=["border-left-width","padding-left","padding-right","border-right-width"]}return b.inject(e,function(g,f){var h=a(c,f);return h===null?g:g-parseInt(h,10)})+"px";default:return a(c,d)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(a,b,c){if(c==="title"){return b.title}return a(b,c)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(b,c){c=$(c);try{c.offsetParent}catch(f){return $(document.body)}var a=c.getStyle("position");if(a!=="static"){return b(c)}c.setStyle({position:"relative"});var d=b(c);c.setStyle({position:a});return d});$w("positionedOffset viewportOffset").each(function(a){Element.Methods[a]=Element.Methods[a].wrap(function(c,d){d=$(d);try{d.offsetParent}catch(h){return Element._returnOffset(0,0)}var b=d.getStyle("position");if(b!=="static"){return c(d)}var f=d.getOffsetParent();if(f&&f.getStyle("position")==="fixed"){f.setStyle({zoom:1})}d.setStyle({position:"relative"});var g=c(d);d.setStyle({position:b});return g})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(a,b){try{b.offsetParent}catch(c){return Element._returnOffset(0,0)}return a(b)});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(c,e){function f(g){return g.replace(/alpha\([^\)]*\)/gi,"")}c=$(c);var b=c.currentStyle;if((b&&!b.hasLayout)||(!b&&c.style.zoom=="normal")){c.style.zoom=1}var a=c.getStyle("filter"),d=c.style;if(e==1||e===""){(a=f(a))?d.filter=a:d.removeAttribute("filter");return c}else{if(e<0.00001){e=0}}d.filter=f(a)+"alpha(opacity="+(e*100)+")";return c};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(a){var b=0,c=0;do{b+=a.offsetTop||0;c+=a.offsetLeft||0;if(a.offsetParent==document.body){if(Element.getStyle(a,"position")=="absolute"){break}}a=a.offsetParent}while(a);return Element._returnOffset(c,b)}}}}}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(e,f){e=$(e);if(f&&f.toElement){f=f.toElement()}if(Object.isElement(f)){e.parentNode.replaceChild(f,e);return e}f=Object.toHTML(f);var c=e.parentNode,d=c.tagName.toUpperCase();if(Element._insertionTranslations.tags[d]){var b=e.next();var a=Element._getContentFromAnonymousElement(d,f.stripScripts());c.removeChild(e);if(b){a.each(function(g){c.insertBefore(g,b)})}else{a.each(function(g){c.appendChild(g)})}}else{e.outerHTML=f.stripScripts()}f.evalScripts.bind(f).defer();return e}}Element._returnOffset=function(a,b){var c=[a,b];c.left=a;c.top=b;return c};Element._getContentFromAnonymousElement=function(a,c){var d=new Element("div"),b=Element._insertionTranslations.tags[a];if(b){d.innerHTML=b[0]+c+b[1];b[2].times(function(){d=d.firstChild})}else{d.innerHTML=c}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 b={},a=Element.Methods.ByTag;var c=Object.extend(function(g){if(!g||g._extendedByPrototype||g.nodeType!=1||g==window){return g}var e=Object.clone(b),f=g.tagName.toUpperCase(),d,h;if(a[f]){Object.extend(e,a[f])}for(d in e){h=e[d];if(Object.isFunction(h)&&!(d in g)){g[d]=h.methodize()}}g._extendedByPrototype=Prototype.emptyFunction;return g},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(b,Element.Methods);Object.extend(b,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 f=c;c=arguments[1]}if(!f){Object.extend(Element.Methods,c||{})}else{if(Object.isArray(f)){f.each(a)}else{a(f)}}function a(j){j=j.toUpperCase();if(!Element.Methods.ByTag[j]){Element.Methods.ByTag[j]={}}Object.extend(Element.Methods.ByTag[j],c)}function b(k,n,m){m=m||false;for(var j in k){var l=k[j];if(!Object.isFunction(l)){continue}if(!m||!(j in n)){n[j]=l.methodize()}}}function e(k){var j;var l={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(l[k]){j="HTML"+l[k]+"Element"}if(window[j]){return window[j]}j="HTML"+k+"Element";if(window[j]){return window[j]}j="HTML"+k.capitalize()+"Element";if(window[j]){return window[j]}window[j]={};window[j].prototype=document.createElement(k)["__proto__"];return window[j]}if(h.ElementExtensions){b(Element.Methods,HTMLElement.prototype);b(Element.Methods.Simulated,HTMLElement.prototype,true)}if(h.SpecificElementExtensions){for(var i in Element.Methods.ByTag){var g=e(i);if(Object.isUndefined(g)){continue}b(d[i],g.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,b=Selector.patterns,g=Selector.assertions;var a,d,f;while(o&&a!==o&&(/\S/).test(o)){a=o;for(var k in b){d=b[k];if(f=o.match(d)){if(g[k]){this.tokens.push([k,Object.clone(f)]);o=o.replace(f[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(f,d){var i,h=d[6],g;if(h=="even"){h="2n+0"}if(h=="odd"){h="2n+1"}if(i=h.match(/^(\d+)$/)){return"["+f+"= "+i[1]+"]"}if(i=h.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(i[1]=="-"){i[1]=-1}var e=i[1]?Number(i[1]):1;var c=i[2]?Number(i[2]):0;g="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(g).evaluate({fragment:f,a:e,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(f,c,g){f._countedByPrototype=Prototype.emptyFunction;if(c){for(var a=f.childNodes,d=a.length-1,b=1;d>=0;d--){var e=a[d];if(e.nodeType==1&&(!g||e._countedByPrototype)){e.nodeIndex=b++}}}else{for(var d=0,b=1,a=f.childNodes;e=a[d];d++){if(e.nodeType==1&&(!g||e._countedByPrototype)){e.nodeIndex=b++}}}},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,f,g){var k=f.toUpperCase();var d=[],e=Selector.handlers;if(a){if(g){if(g=="descendant"){for(var c=0,b;b=a[c];c++){e.concat(d,b.getElementsByTagName(f))}return d}else{a=this[g](a)}if(f=="*"){return a}}for(var c=0,b;b=a[c];c++){if(b.tagName.toUpperCase()===k){d.push(b)}}return d}else{return j.getElementsByTagName(f)}},id:function(c,b,j,a){var g=$(j),e=Selector.handlers;if(!g){return[]}if(!c&&b==document){return[g]}if(c){if(a){if(a=="child"){for(var d=0,f;f=c[d];d++){if(g.parentNode==f){return[g]}}}else{if(a=="descendant"){for(var d=0,f;f=c[d];d++){if(Element.descendantOf(g,f)){return[g]}}}else{if(a=="adjacent"){for(var d=0,f;f=c[d];d++){if(Selector.handlers.previousElementSibling(g)==f){return[g]}}}else{c=e[a](c)}}}}for(var d=0,f;f=c[d];d++){if(f==g){return[g]}}return[]}return(g&&Element.descendantOf(g,b))?[g]:[]},className:function(d,b,c,a){if(d&&a){d=this[a](d)}return Selector.handlers.byClassName(d,b,c)},byClassName:function(c,a,b){if(!c){c=Selector.handlers.descendant([a])}var h=" "+b+" ";for(var e=0,d=[],g,f;g=c[e];e++){f=g.className;if(f.length==0){continue}if(f==b||(" "+f+" ").include(h)){d.push(g)}}return d},attrPresence:function(d,c,a,b){if(!d){d=c.getElementsByTagName("*")}if(d&&b){d=this[b](d)}var f=[];for(var e=0,g;g=d[e];e++){if(Element.hasAttribute(g,a)){f.push(g)}}return f},attr:function(a,j,h,k,g,f){if(!a){a=j.getElementsByTagName("*")}if(a&&f){a=this[f](a)}var l=Selector.operators[g],d=[];for(var c=0,b;b=a[c];c++){var e=Element.readAttribute(b,h);if(e===null){continue}if(l(e,k)){d.push(b)}}return d},pseudo:function(c,d,e,b,a){if(c&&a){c=this[a](c)}if(!c){c=b.getElementsByTagName("*")}return Selector.pseudos[d](c,e,b)}},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,d,u,s,r){if(c.length==0){return[]}if(d=="even"){d="2n+0"}if(d=="odd"){d="2n+1"}var q=Selector.handlers,p=[],e=[],g;q.mark(c);for(var o=0,f;f=c[o];o++){if(!f.parentNode._countedByPrototype){q.index(f.parentNode,s,r);e.push(f.parentNode)}}if(d.match(/^\d+$/)){d=Number(d);for(var o=0,f;f=c[o];o++){if(f.nodeIndex==d){p.push(f)}}}else{if(g=d.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(e);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(a,g){var f=$$(g),e=Selector.handlers;e.mark(f);for(var d=0,c=[],b;b=a[d];d++){if(b._countedByPrototype){c.push(b)}}e.unmark(f);return c},findElement:function(a,c,b){if(Object.isNumber(c)){b=c;c=false}return Selector.matchElements(a,c||"*")[b||0]},findChildElements:function(c,g){g=Selector.split(g.join(","));var e=[],f=Selector.handlers;for(var d=0,b=g.length,a;d<b;d++){a=new Selector(g[d].strip());f.concat(e,a.findElements(c))}return(b>1)?f.unique(e):e}});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(c,e){if(typeof e!="object"){e={hash:!!e}}else{if(Object.isUndefined(e.hash)){e.hash=true}}var d,g,b=false,a=e.submit;var f=c.inject({},function(i,h){if(!h.disabled&&h.name){d=h.name;g=$(h).getValue();if(g!=null&&h.type!="file"&&(h.type!="submit"||(!b&&a!==false&&(!a||d==a)&&(b=true)))){if(d in i){if(!Object.isArray(i[d])){i[d]=[i[d]]}i[d].push(g)}else{i[d]=g}}}return i});return e.hash?f:Object.toQueryString(f)}};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,e,c){g=$(g);var f=g.getElementsByTagName("input");if(!e&&!c){return $A(f).map(Element.extend)}for(var d=0,h=[],a=f.length;d<a;d++){var b=f[d];if((e&&b.type!=e)||(c&&b.name!=c)){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(c){var a=$(c).getElements().findAll(function(d){return"hidden"!=d.type&&!d.disabled});var b=a.findAll(function(d){return d.hasAttribute("tabIndex")&&d.tabIndex>=0}).sortBy(function(d){return d.tabIndex}).first();return b?b:a.find(function(d){return["input","select","textarea"].include(d.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(c,b){c=$(c),b=Object.clone(b||{});var d=b.parameters,a=c.readAttribute("action")||"";if(a.blank()){a=window.location.href}b.parameters=c.serialize(true);if(d){if(Object.isString(d)){d=d.toQueryParams()}Object.extend(b.parameters,d)}if(c.hasAttribute("method")&&!b.method){b.method=c.method}return new Ajax.Request(a,b)}};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(b,f){if(Object.isUndefined(f)){return this[b.type=="select-one"?"selectOne":"selectMany"](b)}else{var d,e,g=!Object.isArray(f);for(var c=0,a=b.length;c<a;c++){d=b.options[c];e=this.optionValue(d);if(g){if(e==f){d.selected=true;return}}else{d.selected=f.include(e)}}}},selectOne:function(b){var a=b.selectedIndex;return a>=0?this.optionValue(b.options[a]):null},selectMany:function(b){var e,a=b.length;if(!a){return null}for(var d=0,e=[];d<a;d++){var c=b.options[d];if(c.selected){e.push(this.optionValue(c))}}return e},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,a,c,b){$super(b,c);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 b;if(Prototype.Browser.IE){var a={0:1,1:4,2:2};b=function(d,c){return d.button==a[c]}}else{if(Prototype.Browser.WebKit){b=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{b=function(d,c){return d.which?(d.which===c+1):(d.button===c)}}}return{isLeftClick:function(c){return b(c,0)},isMiddleClick:function(c){return b(c,1)},isRightClick:function(c){return b(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(e,f){var d=Event.element(e);if(!f){return d}var c=[d].concat(d.ancestors());return Selector.findElement(c,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 a=Event.cache;function d(j){if(j._prototypeEventID){return j._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return j._prototypeEventID=[++arguments.callee.id]}function e(j){if(j&&j.include(":")){return"dataavailable"}return j}function g(j){return a[j]=a[j]||{}}function f(l,j){var k=g(l);return k[j]=k[j]||[]}function i(k,j,l){var o=d(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 h(m,j,k){var l=f(m,j);return l.find(function(n){return n.handler==k})}function b(m,j,k){var l=g(m);if(!l[j]){return false}l[j]=l[j].without(h(m,j,k))}function c(){for(var k in a){for(var j in a[k]){a[k][j]=null}}}if(window.attachEvent){window.attachEvent("onunload",c)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}return{observe:function(l,j,m){l=$(l);var k=e(j);var n=i(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=d(l),k=e(j);if(!m&&j){f(o,j).each(function(p){l.stopObserving(j,p.handler)});return l}else{if(!j){Object.keys(g(o)).each(function(p){l.stopObserving(p)});return l}}var n=h(o,j,m);if(!n){return l}if(l.removeEventListener){l.removeEventListener(k,n,false)}else{l.detachEvent("on"+k,n)}b(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(a,c,b){b=b||{};return Element.clonePosition(c,a,b)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(b){function a(c){return c.blank()?null:"[contains(concat(' ', @class, ' '), ' "+c+" ')]"}b.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(d,c){c=c.toString().strip();var e=/\s/.test(c)?$w(c).map(a).join(""):a(c);return e?document._getElementsByXPath(".//*"+e,d):[]}:function(f,e){e=e.toString().strip();var c=[],h=(/\s/.test(e)?$w(e):null);if(!h&&!e){return c}var d=$(f).getElementsByTagName("*");e=" "+e+" ";for(var g=0,k,j;k=d[g];g++){if(k.className&&(j=" "+k.className+" ")&&(j.include(e)||(h&&h.all(function(i){return !i.toString().blank()&&j.include(" "+i+" ")})))){c.push(Element.extend(k))}}return c};return function(c,d){return $(d||document.body).getElementsByClassName(c)}}(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();
js/procolor-1.0/prototype.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();
js/sizechart/fancybox_overlay.png ADDED
Binary file
js/sizechart/fancybox_sprite.png ADDED
Binary file
js/sizechart/jquery-1.11.3.min.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
2
+ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\f]' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function qa(){}qa.prototype=d.filters=d.pseudos,d.setFilters=new qa,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function ra(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;
3
+
4
+ return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==ca()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===ca()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?aa:ba):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=aa,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=aa,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=aa,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=ba;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=ba),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function da(a){var b=ea.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var ea="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fa=/ jQuery\d+="(?:null|\d+)"/g,ga=new RegExp("<(?:"+ea+")[\\s/>]","i"),ha=/^\s+/,ia=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ja=/<([\w:]+)/,ka=/<tbody/i,la=/<|&#?\w+;/,ma=/<(?:script|style|link)/i,na=/checked\s*(?:[^=]|=\s*.checked.)/i,oa=/^$|\/(?:java|ecma)script/i,pa=/^true\/(.*)/,qa=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ra={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sa=da(y),ta=sa.appendChild(y.createElement("div"));ra.optgroup=ra.option,ra.tbody=ra.tfoot=ra.colgroup=ra.caption=ra.thead,ra.th=ra.td;function ua(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ua(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function va(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wa(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xa(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function ya(a){var b=pa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function za(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Aa(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Ba(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xa(b).text=a.text,ya(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!ga.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ta.innerHTML=a.outerHTML,ta.removeChild(f=ta.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ua(f),h=ua(a),g=0;null!=(e=h[g]);++g)d[g]&&Ba(e,d[g]);if(b)if(c)for(h=h||ua(a),d=d||ua(f),g=0;null!=(e=h[g]);g++)Aa(e,d[g]);else Aa(a,f);return d=ua(f,"script"),d.length>0&&za(d,!i&&ua(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=da(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(la.test(f)){h=h||o.appendChild(b.createElement("div")),i=(ja.exec(f)||["",""])[1].toLowerCase(),l=ra[i]||ra._default,h.innerHTML=l[1]+f.replace(ia,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&ha.test(f)&&p.push(b.createTextNode(ha.exec(f)[0])),!k.tbody){f="table"!==i||ka.test(f)?"<table>"!==l[1]||ka.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ua(p,"input"),va),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ua(o.appendChild(f),"script"),g&&za(h),c)){e=0;while(f=h[e++])oa.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ua(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&za(ua(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ua(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fa,""):void 0;if(!("string"!=typeof a||ma.test(a)||!k.htmlSerialize&&ga.test(a)||!k.leadingWhitespace&&ha.test(a)||ra[(ja.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ia,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ua(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ua(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&na.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ua(i,"script"),xa),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ua(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,ya),j=0;f>j;j++)d=g[j],oa.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qa,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Ca,Da={};function Ea(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fa(a){var b=y,c=Da[a];return c||(c=Ea(a,b),"none"!==c&&c||(Ca=(Ca||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Ca[0].contentWindow||Ca[0].contentDocument).document,b.write(),b.close(),c=Ea(a,b),Ca.detach()),Da[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Ga=/^margin/,Ha=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ia,Ja,Ka=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ia=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)},Ja=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ia(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Ha.test(g)&&Ga.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ia=function(a){return a.currentStyle},Ja=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ia(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Ha.test(g)&&!Ka.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function La(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight),b.removeChild(i)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Ma=/alpha\([^)]*\)/i,Na=/opacity\s*=\s*([^)]*)/,Oa=/^(none|table(?!-c[ea]).+)/,Pa=new RegExp("^("+S+")(.*)$","i"),Qa=new RegExp("^([+-])=("+S+")","i"),Ra={position:"absolute",visibility:"hidden",display:"block"},Sa={letterSpacing:"0",fontWeight:"400"},Ta=["Webkit","O","Moz","ms"];function Ua(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Ta.length;while(e--)if(b=Ta[e]+c,b in a)return b;return d}function Va(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fa(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wa(a,b,c){var d=Pa.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xa(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Ya(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ia(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Ja(a,b,f),(0>e||null==e)&&(e=a.style[b]),Ha.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xa(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Ja(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ua(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qa.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ua(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Ja(a,b,d)),"normal"===f&&b in Sa&&(f=Sa[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Oa.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Ra,function(){return Ya(a,b,d)}):Ya(a,b,d):void 0},set:function(a,c,d){var e=d&&Ia(a);return Wa(a,c,d?Xa(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Na.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Ma,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Ma.test(f)?f.replace(Ma,e):f+" "+e)}}),m.cssHooks.marginRight=La(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Ja,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Ga.test(a)||(m.cssHooks[a+b].set=Wa)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ia(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Va(this,!0)},hide:function(){return Va(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Za(a,b,c,d,e){
5
+ return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$a||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);g>f;f++)if(d=db[f].call(j,a,k,j.opts))return d;return m.map(k,hb,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kb,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],eb[c]=eb[c]||[],eb[c].unshift(b)},prefilter:function(a,b){b?db.unshift(a):db.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kb(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gb(b,!0),a,d,e)}}),m.each({slideDown:gb("show"),slideUp:gb("hide"),slideToggle:gb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($a=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$a=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_a||(_a=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_a),_a=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lb=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lb,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mb,nb,ob=m.expr.attrHandle,pb=/^(?:checked|selected)$/i,qb=k.getSetAttribute,rb=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nb:mb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rb&&qb||!pb.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qb?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nb={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rb&&qb||!pb.test(c)?a.setAttribute(!qb&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=ob[b]||m.find.attr;ob[b]=rb&&qb||!pb.test(b)?function(a,b,d){var e,f;return d||(f=ob[b],ob[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,ob[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rb&&qb||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mb&&mb.set(a,b,c)}}),qb||(mb={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},ob.id=ob.name=ob.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mb.set},m.attrHooks.contenteditable={set:function(a,b,c){mb.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sb=/^(?:input|select|textarea|button|object)$/i,tb=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sb.test(a.nodeName)||tb.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var ub=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ub," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ub," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ub," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vb=m.now(),wb=/\?/,xb=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xb,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yb,zb,Ab=/#.*$/,Bb=/([?&])_=[^&]*/,Cb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Db=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Eb=/^(?:GET|HEAD)$/,Fb=/^\/\//,Gb=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hb={},Ib={},Jb="*/".concat("*");try{zb=location.href}catch(Kb){zb=y.createElement("a"),zb.href="",zb=zb.href}yb=Gb.exec(zb.toLowerCase())||[];function Lb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mb(a,b,c,d){var e={},f=a===Ib;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nb(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Ob(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zb,type:"GET",isLocal:Db.test(yb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nb(Nb(a,m.ajaxSettings),b):Nb(m.ajaxSettings,a)},ajaxPrefilter:Lb(Hb),ajaxTransport:Lb(Ib),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cb.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zb)+"").replace(Ab,"").replace(Fb,yb[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gb.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yb[1]&&c[2]===yb[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yb[3]||("http:"===yb[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mb(Hb,k,b,v),2===t)return v;h=m.event&&k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Eb.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wb.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bb.test(e)?e.replace(Bb,"$1_="+vb++):e+(wb.test(e)?"&":"?")+"_="+vb++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jb+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mb(Ib,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Ob(k,v,c)),u=Pb(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qb=/%20/g,Rb=/\[\]$/,Sb=/\r?\n/g,Tb=/^(?:submit|button|image|reset|file)$/i,Ub=/^(?:input|select|textarea|keygen)/i;function Vb(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rb.test(a)?d(a,e):Vb(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vb(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vb(c,a[c],b,e);return d.join("&").replace(Qb,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Ub.test(this.nodeName)&&!Tb.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sb,"\r\n")}}):{name:b.name,value:c.replace(Sb,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zb()||$b()}:Zb;var Wb=0,Xb={},Yb=m.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Xb)Xb[a](void 0,!0)}),k.cors=!!Yb&&"withCredentials"in Yb,Yb=k.ajax=!!Yb,Yb&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wb;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xb[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xb[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zb(){try{return new a.XMLHttpRequest}catch(b){}}function $b(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _b=[],ac=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_b.pop()||m.expando+"_"+vb++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ac.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ac.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ac,"$1"+e):b.jsonp!==!1&&(b.url+=(wb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_b.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bc=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bc)return bc.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cc=a.document.documentElement;function dc(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dc(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cc;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cc})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dc(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=La(k.pixelPosition,function(a,c){return c?(c=Ja(a,b),Ha.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ec=a.jQuery,fc=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fc),b&&a.jQuery===m&&(a.jQuery=ec),m},typeof b===K&&(a.jQuery=a.$=m),m});
js/sizechart/jquery.fancybox.css ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
2
+ .fancybox-wrap,
3
+ .fancybox-skin,
4
+ .fancybox-outer,
5
+ .fancybox-inner,
6
+ .fancybox-image,
7
+ .fancybox-wrap iframe,
8
+ .fancybox-wrap object,
9
+ .fancybox-nav,
10
+ .fancybox-nav span,
11
+ .fancybox-tmp
12
+ {
13
+ padding: 0;
14
+ margin: 0;
15
+ border: 0;
16
+ outline: none;
17
+ vertical-align: top;
18
+ }
19
+
20
+ .fancybox-wrap {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ z-index: 8020;
25
+ }
26
+
27
+ .fancybox-skin {
28
+ position: relative;
29
+ background: #f9f9f9;
30
+ color: #444;
31
+ text-shadow: none;
32
+ -webkit-border-radius: 4px;
33
+ -moz-border-radius: 4px;
34
+ border-radius: 4px;
35
+ }
36
+
37
+ .fancybox-opened {
38
+ z-index: 8030;
39
+ }
40
+
41
+ .fancybox-opened .fancybox-skin {
42
+ -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
43
+ -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
44
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
45
+ }
46
+
47
+ .fancybox-outer, .fancybox-inner {
48
+ position: relative;
49
+ }
50
+
51
+ .fancybox-inner {
52
+ overflow: hidden;
53
+ }
54
+
55
+ .fancybox-type-iframe .fancybox-inner {
56
+ -webkit-overflow-scrolling: touch;
57
+ }
58
+
59
+ .fancybox-error {
60
+ color: #444;
61
+ font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
62
+ margin: 0;
63
+ padding: 15px;
64
+ white-space: nowrap;
65
+ }
66
+
67
+ .fancybox-image, .fancybox-iframe {
68
+ display: block;
69
+ width: 100%;
70
+ height: 100%;
71
+ }
72
+
73
+ .fancybox-image {
74
+ max-width: 100%;
75
+ max-height: 100%;
76
+ }
77
+
78
+ #fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
79
+ background-image: url('fancybox_sprite.png');
80
+ }
81
+
82
+ #fancybox-loading {
83
+ position: fixed;
84
+ top: 50%;
85
+ left: 50%;
86
+ margin-top: -22px;
87
+ margin-left: -22px;
88
+ background-position: 0 -108px;
89
+ opacity: 0.8;
90
+ cursor: pointer;
91
+ z-index: 8060;
92
+ }
93
+
94
+ #fancybox-loading div {
95
+ width: 44px;
96
+ height: 44px;
97
+ background: url('fancybox_loading.gif') center center no-repeat;
98
+ }
99
+
100
+ .fancybox-close {
101
+ position: absolute;
102
+ top: -18px;
103
+ right: -18px;
104
+ width: 36px;
105
+ height: 36px;
106
+ cursor: pointer;
107
+ z-index: 8040;
108
+ }
109
+
110
+ .fancybox-nav {
111
+ position: absolute;
112
+ top: 0;
113
+ width: 40%;
114
+ height: 100%;
115
+ cursor: pointer;
116
+ text-decoration: none;
117
+ background: transparent url('blank.gif'); /* helps IE */
118
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
119
+ z-index: 8040;
120
+ }
121
+
122
+ .fancybox-prev {
123
+ left: 0;
124
+ }
125
+
126
+ .fancybox-next {
127
+ right: 0;
128
+ }
129
+
130
+ .fancybox-nav span {
131
+ position: absolute;
132
+ top: 50%;
133
+ width: 36px;
134
+ height: 34px;
135
+ margin-top: -18px;
136
+ cursor: pointer;
137
+ z-index: 8040;
138
+ visibility: hidden;
139
+ }
140
+
141
+ .fancybox-prev span {
142
+ left: 10px;
143
+ background-position: 0 -36px;
144
+ }
145
+
146
+ .fancybox-next span {
147
+ right: 10px;
148
+ background-position: 0 -72px;
149
+ }
150
+
151
+ .fancybox-nav:hover span {
152
+ visibility: visible;
153
+ }
154
+
155
+ .fancybox-tmp {
156
+ position: absolute;
157
+ top: -99999px;
158
+ left: -99999px;
159
+ visibility: hidden;
160
+ max-width: 99999px;
161
+ max-height: 99999px;
162
+ overflow: visible !important;
163
+ }
164
+
165
+ /* Overlay helper */
166
+
167
+ .fancybox-lock {
168
+ overflow: hidden !important;
169
+ width: auto;
170
+ }
171
+
172
+ .fancybox-lock body {
173
+ overflow: hidden !important;
174
+ }
175
+
176
+ .fancybox-lock-test {
177
+ overflow-y: hidden !important;
178
+ }
179
+
180
+ .fancybox-overlay {
181
+ position: absolute;
182
+ top: 0;
183
+ left: 0;
184
+ overflow: hidden;
185
+ display: none;
186
+ z-index: 8010;
187
+ background: url('fancybox_overlay.png');
188
+ }
189
+
190
+ .fancybox-overlay-fixed {
191
+ position: fixed;
192
+ bottom: 0;
193
+ right: 0;
194
+ }
195
+
196
+ .fancybox-lock .fancybox-overlay {
197
+ overflow: auto;
198
+ overflow-y: scroll;
199
+ }
200
+
201
+ /* Title helper */
202
+
203
+ .fancybox-title {
204
+ visibility: hidden;
205
+ font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
206
+ position: relative;
207
+ text-shadow: none;
208
+ z-index: 8050;
209
+ }
210
+
211
+ .fancybox-opened .fancybox-title {
212
+ visibility: visible;
213
+ }
214
+
215
+ .fancybox-title-float-wrap {
216
+ position: absolute;
217
+ bottom: 0;
218
+ right: 50%;
219
+ margin-bottom: -35px;
220
+ z-index: 8050;
221
+ text-align: center;
222
+ }
223
+
224
+ .fancybox-title-float-wrap .child {
225
+ display: inline-block;
226
+ margin-right: -100%;
227
+ padding: 2px 20px;
228
+ background: transparent; /* Fallback for web browsers that doesn't support RGBa */
229
+ background: rgba(0, 0, 0, 0.8);
230
+ -webkit-border-radius: 15px;
231
+ -moz-border-radius: 15px;
232
+ border-radius: 15px;
233
+ text-shadow: 0 1px 2px #222;
234
+ color: #FFF;
235
+ font-weight: bold;
236
+ line-height: 24px;
237
+ white-space: nowrap;
238
+ }
239
+
240
+ .fancybox-title-outside-wrap {
241
+ position: relative;
242
+ margin-top: 10px;
243
+ color: #fff;
244
+ }
245
+
246
+ .fancybox-title-inside-wrap {
247
+ padding-top: 10px;
248
+ }
249
+
250
+ .fancybox-title-over-wrap {
251
+ position: absolute;
252
+ bottom: 0;
253
+ left: 0;
254
+ color: #fff;
255
+ padding: 10px;
256
+ background: #000;
257
+ background: rgba(0, 0, 0, .8);
258
+ }
259
+
260
+ /*Retina graphics!*/
261
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
262
+ only screen and (min--moz-device-pixel-ratio: 1.5),
263
+ only screen and (min-device-pixel-ratio: 1.5){
264
+
265
+ #fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
266
+ background-image: url('fancybox_sprite@2x.png');
267
+ background-size: 44px 152px; /*The size of the normal image, half the size of the hi-res image*/
268
+ }
269
+
270
+ #fancybox-loading div {
271
+ background-image: url('fancybox_loading@2x.gif');
272
+ background-size: 24px 24px; /*The size of the normal image, half the size of the hi-res image*/
273
+ }
274
+ }
js/sizechart/jquery.fancybox.pack.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
2
+ (function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0<a.indexOf("%")},l=function(a,d){var e=parseInt(a,10)||0;d&&E(a)&&(e*=b.getViewport()[d]/100);return Math.ceil(e)},w=function(a,b){return l(a,b)+"px"};f.extend(b,{version:"2.1.5",defaults:{padding:15,margin:20,
3
+ width:800,height:600,minWidth:100,minHeight:100,maxWidth:9999,maxHeight:9999,pixelRatio:1,autoSize:!0,autoHeight:!1,autoWidth:!1,autoResize:!0,autoCenter:!s,fitToView:!0,aspectRatio:!1,topRatio:0.5,leftRatio:0.5,scrolling:"auto",wrapCSS:"",arrows:!0,closeBtn:!0,closeClick:!1,nextClick:!1,mouseWheel:!0,autoPlay:!1,playSpeed:3E3,preload:3,modal:!1,loop:!0,ajax:{dataType:"html",headers:{"X-fancyBox":!0}},iframe:{scrolling:"auto",preload:!0},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},
4
+ keys:{next:{13:"left",34:"up",39:"left",40:"up"},prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:!0,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+
5
+ (I?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0,
6
+ openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1,
7
+ isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k,
8
+ c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&&
9
+ k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current||
10
+ b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer=
11
+ setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index<b.group.length-1))b.player.isActive=!0,p.bind({"onCancel.player beforeClose.player":c,"onUpdate.player":e,"beforeLoad.player":d}),e(),b.trigger("onPlayStart")}else c()},next:function(a){var d=b.current;d&&(q(a)||(a=d.direction.next),b.jumpto(d.index+1,a,"next"))},prev:function(a){var d=b.current;
12
+ d&&(q(a)||(a=d.direction.prev),b.jumpto(d.index-1,a,"prev"))},jumpto:function(a,d,e){var c=b.current;c&&(a=l(a),b.direction=d||c.direction[a>=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d=
13
+ a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")),
14
+ b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(),
15
+ y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement;
16
+ if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1<a.group.length&&k[c]!==v)return b[d](k[c]),e.preventDefault(),!1;if(-1<f.inArray(c,k))return b[d](),e.preventDefault(),!1})}),f.fn.mousewheel&&a.mouseWheel&&b.wrap.bind("mousewheel.fb",function(d,c,k,g){for(var h=f(d.target||null),j=!1;h.length&&!j&&!h.is(".fancybox-skin")&&!h.is(".fancybox-wrap");)j=h[0]&&!(h[0].style.overflow&&"hidden"===h[0].style.overflow)&&
17
+ (h[0].clientWidth&&h[0].scrollWidth>h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1<b.group.length&&!a.canShrink){if(0<g||0<k)b.prev(0<g?"down":"left");else if(0>g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0,
18
+ {},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,
19
+ mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=
20
+ !0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");
21
+ "image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload=
22
+ this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href);
23
+ f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,
24
+ e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,
25
+ outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("<div>").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}",
26
+ g);break;case "swf":e='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+g+'"></param>',h="",f.each(a.swf,function(a,b){e+='<param name="'+a+'" value="'+b+'"></param>';h+=" "+a+'="'+b+'"'}),e+='<embed src="'+g+'" type="application/x-shockwave-flash" width="100%" height="100%"'+h+"></embed></object>"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll":
27
+ "no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside?
28
+ h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth||
29
+ h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),c<m&&(c=m,j=l(c/D)),j<u&&(j=u,c=l(j*D))):(c=Math.max(m,Math.min(c,n)),h.autoHeight&&
30
+ "iframe"!==h.type&&(g.width(c),j=g.height()),j=Math.max(u,Math.min(j,p)));if(h.fitToView)if(g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height(),h.aspectRatio)for(;(a>z||y>r)&&(c>m&&j>u)&&!(19<d++);)j=Math.max(u,Math.min(p,j-10)),c=l(j*D),c<m&&(c=m,j=l(c/D)),c>n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&j<A&&c+x+q<z)&&(c+=q);g.width(c).height(j);e.width(c+x);a=e.width();
31
+ y=e.height();e=(a>z||y>r)&&c>m&&j>u;c=h.aspectRatio?c<F&&j<B&&c<C&&j<A:(c<F||j<B)&&(c<C||j<A);f.extend(h,{dim:{width:w(a),height:w(y)},origWidth:C,origHeight:A,canShrink:e,canExpand:c,wPadding:x,hPadding:v,wrapSpace:y-k.outerHeight(!0),skinSpace:k.height()-j});!H&&(h.autoHeight&&j>u&&j<p&&!c)&&g.height("auto")},_getPosition:function(a){var d=b.current,e=b.getViewport(),c=d.margin,f=b.wrap.width()+c[1]+c[3],g=b.wrap.height()+c[0]+c[2],c={position:"absolute",top:c[0],left:c[3]};d.autoCenter&&d.fixed&&
32
+ !a&&g<=e.h&&f<=e.w?c.position="fixed":d.locked||(c.top+=e.y,c.left+=e.x);c.top=w(Math.max(c.top,c.top+(e.h-g)*d.topRatio));c.left=w(Math.max(c.left,c.left+(e.w-f)*d.leftRatio));return c},_afterZoomIn:function(){var a=b.current;a&&(b.isOpen=b.isOpened=!0,b.wrap.css("overflow","visible").addClass("fancybox-opened"),b.update(),(a.closeClick||a.nextClick&&1<b.group.length)&&b.inner.css("cursor","pointer").bind("click.fb",function(d){!f(d.target).is("a")&&!f(d.target).parent().is("a")&&(d.preventDefault(),
33
+ b[a.closeClick?"close":"next"]())}),a.closeBtn&&f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb",function(a){a.preventDefault();b.close()}),a.arrows&&1<b.group.length&&((a.loop||0<a.index)&&f(a.tpl.prev).appendTo(b.outer).bind("click.fb",b.prev),(a.loop||a.index<b.group.length-1)&&f(a.tpl.next).appendTo(b.outer).bind("click.fb",b.next)),b.trigger("afterShow"),!a.loop&&a.index===a.group.length-1?b.play(!1):b.opts.autoPlay&&!b.player.isActive&&(b.opts.autoPlay=!1,b.play()))},_afterZoomOut:function(a){a=
34
+ a||b.current;f(".fancybox-wrap").trigger("onReset").remove();f.extend(b,{group:{},opts:{},router:!1,current:null,isActive:!1,isOpened:!1,isOpen:!1,isClosing:!1,wrap:null,skin:null,outer:null,inner:null});b.trigger("afterClose",a)}});b.transitions={getOrigPosition:function(){var a=b.current,d=a.element,e=a.orig,c={},f=50,g=50,h=a.hPadding,j=a.wPadding,m=b.getViewport();!e&&(a.isDom&&d.is(":visible"))&&(e=d.find("img:first"),e.length||(e=d));t(e)?(c=e.offset(),e.is("img")&&(f=e.outerWidth(),g=e.outerHeight())):
35
+ (c.top=m.y+(m.h-g)*a.topRatio,c.left=m.x+(m.w-f)*a.leftRatio);if("fixed"===b.wrap.css("position")||a.locked)c.top-=m.y,c.left-=m.x;return c={top:w(c.top-h*a.topRatio),left:w(c.left-j*a.leftRatio),width:w(f+j),height:w(g+h)}},step:function(a,d){var e,c,f=d.prop;c=b.current;var g=c.wrapSpace,h=c.skinSpace;if("width"===f||"height"===f)e=d.end===d.start?1:(a-d.start)/(d.end-d.start),b.isClosing&&(e=1-e),c="width"===f?c.wPadding:c.hPadding,c=a-c,b.skin[f](l("width"===f?c:c-g*e)),b.inner[f](l("width"===
36
+ f?c:c-g*e-h*e))},zoomIn:function(){var a=b.current,d=a.pos,e=a.openEffect,c="elastic"===e,k=f.extend({opacity:1},d);delete k.position;c?(d=this.getOrigPosition(),a.openOpacity&&(d.opacity=0.1)):"fade"===e&&(d.opacity=0.1);b.wrap.css(d).animate(k,{duration:"none"===e?0:a.openSpeed,easing:a.openEasing,step:c?this.step:null,complete:b._afterZoomIn})},zoomOut:function(){var a=b.current,d=a.closeEffect,e="elastic"===d,c={opacity:0.1};e&&(c=this.getOrigPosition(),a.closeOpacity&&(c.opacity=0.1));b.wrap.animate(c,
37
+ {duration:"none"===d?0:a.closeSpeed,easing:a.closeEasing,step:e?this.step:null,complete:b._afterZoomOut})},changeIn:function(){var a=b.current,d=a.nextEffect,e=a.pos,c={opacity:1},f=b.direction,g;e.opacity=0.1;"elastic"===d&&(g="down"===f||"up"===f?"top":"left","down"===f||"right"===f?(e[g]=w(l(e[g])-200),c[g]="+=200px"):(e[g]=w(l(e[g])+200),c[g]="-=200px"));"none"===d?b._afterZoomIn():b.wrap.css(e).animate(c,{duration:a.nextSpeed,easing:a.nextEasing,complete:b._afterZoomIn})},changeOut:function(){var a=
38
+ b.previous,d=a.prevEffect,e={opacity:0.1},c=b.direction;"elastic"===d&&(e["down"===c||"up"===c?"top":"left"]=("up"===c||"left"===c?"-":"+")+"=200px");a.wrap.animate(e,{duration:"none"===d?0:a.prevSpeed,easing:a.prevEasing,complete:function(){f(this).trigger("onReset").remove()}})}};b.helpers.overlay={defaults:{closeClick:!0,speedOut:200,showEarly:!0,css:{},locked:!s,fixed:!0},overlay:null,fixed:!1,el:f("html"),create:function(a){a=f.extend({},this.defaults,a);this.overlay&&this.close();this.overlay=
39
+ f('<div class="fancybox-overlay"></div>').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive?
40
+ b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth),
41
+ p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"===
42
+ f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=
43
+ b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('<div class="fancybox-title fancybox-title-'+c+'-wrap">'+e+"</div>");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner('<span class="child"></span>'),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,
44
+ e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+
45
+ ":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('<div style="position:fixed;top:20px;"></div>').appendTo("body");var e=20===
46
+ d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("<style type='text/css'>.fancybox-margin{margin-right:"+(d-a)+"px;}</style>").appendTo("head")})})(window,document,jQuery);
js/sizechart/sizechart.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ var sizeChart = Class.create({
3
+ initialize: function (formId) {
4
+ this.form = $(formId);
5
+ if (!this.form) {
6
+ return;
7
+ }
8
+ this.table = $('chart_values');
9
+ this.cookieKey = 'sizechart';
10
+ if (this.getCookie(this.cookieKey)) {
11
+ this.units = this.getCookie(this.cookieKey);
12
+ if (this.units === 'cm') {
13
+ this.convertUnits();
14
+ }
15
+ } else {
16
+ this.units = 'in';
17
+ }
18
+ this.chartValues();
19
+ this.setFormText();
20
+
21
+ },
22
+ findSize: function () {
23
+ this.removeSelection();
24
+ this.bust = this.form['bust'];
25
+ this.waist = this.form['waist'];
26
+ this.hip = this.form['hip'];
27
+ /* ---- Find index and assign class ---------*/
28
+ var bustIndex = this.closestValueIndex(this.bust.getValue(), this.bustValues);
29
+ this.table.rows[bustIndex].cells[1].addClassName('current');
30
+ var waistIndex = this.closestValueIndex(this.waist.getValue(), this.waistValues);
31
+ this.table.rows[waistIndex].cells[2].addClassName('current');
32
+ var hipIndex = this.closestValueIndex(this.hip.getValue(), this.hipValues);
33
+ this.table.rows[hipIndex].cells[3].addClassName('current');
34
+ /* ---- Find max index for size selection ---------*/
35
+ var array = [bustIndex, waistIndex, hipIndex];
36
+ var sizeIndex = Math.max.apply(null, array);
37
+ this.table.rows[sizeIndex].addClassName('recomended-size');
38
+ var size = this.sizeValues[sizeIndex];
39
+ $('size-value').update(size);
40
+
41
+ },
42
+ chartValues: function () {
43
+ this.sizeValues = [];
44
+ this.bustValues = [];
45
+ this.waistValues = [];
46
+ this.hipValues = [];
47
+ rows = this.table.select('tr');
48
+ for (var rowIndex = 0; rowIndex < rows.length; ++rowIndex) {
49
+ cells = rows[rowIndex].select('td');
50
+ for (var index = 0; index < cells.length; ++index) {
51
+ var value = cells[index].innerHTML;
52
+ if (index === 0)
53
+ this.sizeValues[rowIndex] = value;
54
+ if (index === 1)
55
+ this.bustValues[rowIndex] = parseInt(value);
56
+ if (index === 2)
57
+ this.waistValues[rowIndex] = parseInt(value);
58
+ if (index === 3)
59
+ this.hipValues[rowIndex] = parseInt(value);
60
+ }
61
+ }
62
+ },
63
+ closestValue: function (num, array) {
64
+ var current = array[0];
65
+ array.each(function (value) {
66
+ if (Math.abs(num - value) < Math.abs(num - current)) {
67
+ current = value;
68
+ }
69
+ });
70
+ return current;
71
+ },
72
+ closestValueIndex: function (num, array) {
73
+ var currentIndex = 0;
74
+ var current = array[0];
75
+ for (var index = 0; index < array.length; ++index) {
76
+ value = array[index];
77
+ if (Math.abs(num - value) < Math.abs(num - current)) {
78
+ current = value;
79
+ currentIndex = index;
80
+ }
81
+ }
82
+ return currentIndex;
83
+ },
84
+ removeSelection: function () {
85
+ var rows = this.table.select('tr.recomended-size');
86
+ rows.each(function (element) {
87
+ element.removeClassName('recomended-size');
88
+ });
89
+ var cells = this.table.select('td.current');
90
+ cells.each(function (element) {
91
+ element.removeClassName('current');
92
+ });
93
+ },
94
+ convertUnits: function () {
95
+ this.setUnitText();
96
+ rows = this.table.select('tr');
97
+ var th = $('chart_head').select('th');
98
+ for (var rowIndex = 0; rowIndex < rows.length; ++rowIndex) {
99
+ for (var i = 1; i < th.length; ++i) {
100
+ cell = rows[rowIndex].select('td')[i];
101
+ if (this.units === 'in') {
102
+ cell.innerHTML = this.convertToInch(cell.innerHTML);
103
+ } else {
104
+ cell.innerHTML = this.convertToCentimeters(cell.innerHTML);
105
+ }
106
+ }
107
+ }
108
+ },
109
+ changeUnits: function () {
110
+ if (this.units === 'in') {
111
+ this.units = 'cm';
112
+ } else {
113
+ this.units = 'in';
114
+ }
115
+ this.clearForm();
116
+ this.changeCookie();
117
+ this.convertUnits();
118
+ this.chartValues();
119
+ },
120
+ convertToCentimeters: function (val) {
121
+ var cm = val * 2.54;
122
+ return +cm.toFixed(1);
123
+ },
124
+ convertToInch: function (val) {
125
+ var inch = val / 2.54;
126
+ return +inch.toFixed(1);
127
+ },
128
+ clearForm: function () {
129
+ this.form['bust'].clear();
130
+ this.form['waist'].clear();
131
+ this.form['hip'].clear();
132
+ },
133
+ changeCookie: function () {
134
+ this.setCookie(this.cookieKey, this.units, 10);
135
+ },
136
+ getCookie: function (cname) {
137
+ var name = cname + "=";
138
+ var ca = document.cookie.split(';');
139
+ for (var i = 0; i < ca.length; i++) {
140
+ var c = ca[i];
141
+ while (c.charAt(0) === ' ')
142
+ c = c.substring(1);
143
+ if (c.indexOf(name) === 0)
144
+ return c.substring(name.length, c.length);
145
+ }
146
+ return "";
147
+ },
148
+ setCookie: function (cname, cvalue, exdays) {
149
+ var d = new Date();
150
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
151
+ var expires = "expires=" + d.toUTCString();
152
+ document.cookie = cname + "=" + cvalue + "; " + expires;
153
+ },
154
+ setUnitText: function () {
155
+ var th = $('chart_head').select('th');
156
+ if (this.units === 'in') {
157
+ $('convertsizeunits').innerHTML = 'Convert to Centimeters';
158
+
159
+ /* th[1].innerHTML = 'Bust (in)';
160
+ th[2].innerHTML = 'Waist (in)';
161
+ th[3].innerHTML = 'Hip (in)';*/
162
+ } else {
163
+ $('convertsizeunits').innerHTML = 'Convert to Inches';
164
+ /* th[1].innerHTML = 'Bust (cm)';
165
+ th[2].innerHTML = 'Waist (cm)';
166
+ th[3].innerHTML = 'Hip (cm)';*/
167
+ }
168
+ },
169
+ setFormText: function () {
170
+ var label = $('sizechart_form').select('label');
171
+ var th = $('chart_head').select('th');
172
+ label[0].innerHTML = th[1].innerHTML;
173
+ label[1].innerHTML = th[2].innerHTML;
174
+ label[2].innerHTML = th[3].innerHTML;
175
+ }
176
+ });
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ExtensionsMall_SizeChart</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/">GNU General Public License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Size Chart extension is the dressing room for your online store.</summary>
10
+ <description>One of customer's biggest problems when shopping for clothes on the internet is not knowing which size to choose. It a huge letdown to realize that the purchased dress doesn't fit. Size Chart extension is the dressing room for your online store. Allow customers to easily find the right size and avoid unpleasant surprises by allowing them to find their exact dress number just by entering measurements.</description>
11
+ <notes>Stable version of ExtensionsMall size-chart</notes>
12
+ <authors><author><name>Extensions Mall</name><user>smdesign</user><email>info@extensionsmall.com</email></author></authors>
13
+ <date>2016-01-20</date>
14
+ <time>10:18:29</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="ExtensionsMall_SizeChart.xml" hash="055a0c52194682c94461d0f7b1a26d0a"/></dir></target><target name="magecommunity"><dir name="ExtensionsMall"><dir name="SizeChart"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><file name="Form.php" hash="9307a532156b1e8dbf28315d46eec1b9"/><dir name="Tab"><file name="Form.php" hash="dbe22fdb48aeb029e1184b53f747676b"/></dir><file name="Tabs.php" hash="497f6b890194e9a5547fb02447ade2f0"/></dir><file name="Edit.php" hash="68691c59dc3848edacc1fe8c3e79b84d"/><dir name="List"><file name="Grid.php" hash="5557e511de09172e1b4dd6f4306a0b92"/></dir><file name="List.php" hash="ef0f6d0f850344de30c28e2b2dfcc8d0"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Color.php" hash="8edb37c9456443da4a226c31f03eebbe"/></dir></dir></dir></dir></dir><dir name="Sizechart"><file name="Anchor.php" hash="94f4861e75102e07d90a5ecb2168a0d0"/></dir><file name="Sizechart.php" hash="99a377dcc3ae56198c888f45b9b90790"/></dir><dir name="Helper"><file name="Data.php" hash="5833eae85e205ed6fb4d10265097302c"/></dir><dir name="Model"><dir name="Resource"><file name="Setup.php" hash="089ee1c56ac7a1c57b6b28cc7b7dba11"/><dir name="Sizechart"><file name="Collection.php" hash="471689df0f82dfe9247722b882c20b7a"/></dir><file name="Sizechart.php" hash="a79e4bc2024e42630cf99f8cdd1885ab"/></dir><file name="Sizechart.php" hash="f002460f7cf466e32dceabb6d7d4cd73"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExtensionsmallsizechartController.php" hash="63dbb599e464b8be78bc4168a63e2969"/></dir></dir><dir name="data"><dir name="extensionsmall_sizechart_setup"><file name="data-install-1.0.0.php" hash="c55a7d232e17fd539216ea9bed4b2537"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="def6effc7a84e5a321176b624542d409"/><file name="config.xml" hash="1e6a0e7e53e7287729a24c3207870688"/><file name="system.xml" hash="d84b52b40e504e0ca231c21fbb77899a"/></dir><dir name="sql"><dir name="extensionsmall_sizechart_setup"><file name="mysql4-install-1.0.0.php" hash="ca4910b127132434b936d9b309d91792"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sizechart.xml" hash="1b7d61d7d0b3f501888d14ccb9d65b92"/></dir><dir name="template"><dir name="sizechart"><file name="anchor.phtml" hash="6b00aec1b1ba5c9fae0db5d6cbc60450"/><file name="sizechart.phtml" hash="f4e582222236a0e513d940701e0e7164"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="sizechart"><dir name="images"><file name="size-chart-button.png" hash="8291a93828bef5b65926d95d5d5fafc9"/><file name="sizechart-siluete.jpg" hash="381361db3c71a178a1deae3bba392efa"/></dir><file name="sizechart.css" hash="9befa51ad4e6774c803516bdb455c81a"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="procolor-1.0"><file name="api.html" hash="7e2d51a6f9f36e38db47f90225566372"/><file name="docs.css" hash="b4960943726540ca2fac2f74cecad02e"/><file name="examples.html" hash="af1b0a9fc06746433e060eda4b17fe60"/><dir name="img"><file name="procolor_win_bars.png" hash="a8e41fdddd2253309e0b3e5154668c24"/><file name="procolor_win_bg.gif" hash="c0558cecd0e0ffb9ca89efe00f422261"/><file name="procolor_win_bg.png" hash="4e2a34cc64888fe264fcf6249dfe40da"/><file name="procolor_win_boxes.png" hash="e971c1ca87a0cb52d32408270d00a0da"/><file name="procolor_win_close.png" hash="20a8bb9433157962ab25d86d28d088a3"/><file name="procolor_win_drop.png" hash="9ddce741de330573f082ffe83005d691"/><file name="procolor_win_palette_raw.png" hash="ea98dde528e987029af6e24dbef53922"/><file name="procolor_win_sel_circle.gif" hash="3674b62db5a6eaa4dcedb0749dde4106"/><file name="procolor_win_sel_circle.png" hash="d76195d1777e9a14ebc1a242ab712037"/><file name="procolor_win_sel_rect.gif" hash="b74a72aaf1ea21d55b8751079f283537"/><file name="procolor_win_sel_rect.png" hash="5513589e2b6dc1a980a4e65a746005d0"/><file name="procolor_win_wheel_black.png" hash="62353005bb70bbfa8ffd700112d72582"/><file name="procolor_win_wheel_rgb.jpg" hash="afdd3852c3788a58794ddf1de9557fd8"/></dir><file name="index.html" hash="1f266e57af7350d9711153cb809f5b91"/><file name="license.html" hash="8094fb6fe622b93b85cccacdfd5eb06b"/><file name="options.html" hash="ac3215f0f60e969740c0e5bb79f13e24"/><file name="procolor.compressed.js" hash="79e463efad21212e4096d40b9e17d96c"/><file name="procolor.js" hash="93ec3cb6a0356cce4cf8e51006dfaeec"/><file name="prototype.compressed.js" hash="c0d7c7d5d972f4fe19da42aafadc4eb9"/><file name="prototype.js" hash="b5684120e496c310977713be34be4868"/></dir><dir name="sizechart"><file name="fancybox_overlay.png" hash="77aeaa52715b898b73c74d68c630330e"/><file name="fancybox_sprite.png" hash="783d4031fe50c3d83c960911e1fbc705"/><file name="jquery-1.11.3.min.js" hash="895323ed2f7258af4fae2c738c8aea49"/><file name="jquery.fancybox.css" hash="6c55951ce1e3115711f63f99b7501f3a"/><file name="jquery.fancybox.pack.js" hash="cc9e759f24ba773aeef8a131889d3728"/><file name="sizechart.js" hash="55503cc4e518a32c9a3ed02abe275dce"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>7.0.2</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/sizechart/images/size-chart-button.png ADDED
Binary file
skin/frontend/base/default/sizechart/images/sizechart-siluete.jpg ADDED
Binary file
skin/frontend/base/default/sizechart/sizechart.css ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #sizechartbutton{
2
+ position: absolute;
3
+ top: 36px;
4
+ right: 16px;
5
+ z-index: 10;
6
+ }
7
+ /*
8
+ #cboxClose{
9
+ padding: 0 30px 0 10px;
10
+ }
11
+ */
12
+ #sizechart{
13
+ color: #2d3331;
14
+ //max-width: 700px;
15
+ }
16
+ #sizechart .left-column{
17
+ float: left;
18
+ // max-width: 375px;
19
+ }
20
+ #sizechart .right-column{
21
+ float: right;
22
+ width: 150px;
23
+ }
24
+ #sizechart_form label{
25
+ clear: both;
26
+ width: 100%;
27
+ }
28
+ #sizechart table tr:nth-child(even) {
29
+ background-color: #eeeeee;
30
+ }
31
+ #sizechart #chart_values tr.recomended-size {
32
+ background-color: #a1a1a1;
33
+ }
34
+
35
+ #sizechart table td {
36
+ border: 1px solid #eeeeee;
37
+ line-height: 20px;
38
+ }
39
+ #sizechart #chart_values td.current {
40
+ font-size: 16px;
41
+ font-weight: bold;
42
+ }
43
+ #sizechart table th{
44
+ border: 1px solid #ffffff;
45
+ padding: 4px;
46
+ color: #ffffff;
47
+ text-align: center;
48
+ line-height: 15px;
49
+ }
50
+ #sizechart .size{
51
+ clear: both;
52
+ overflow: auto;
53
+ margin-bottom: 10px;
54
+ }
55
+ #sizechart .measurements table{
56
+ width: 100%;
57
+ // float: left;
58
+ // width: 48%;
59
+ }
60
+ #sizechart .measurements table td{
61
+ border: 0;
62
+ padding: 4px 15px;
63
+ text-align: center;
64
+ }
65
+ #sizechart .measurements input{
66
+ width: 56px;
67
+ }
68
+ #sizechart .measurements p{
69
+ margin: 0;
70
+ }
71
+ #sizechart .measurements .col{
72
+ // width: 55px;
73
+ // float: left;
74
+ }
75
+ #sizechart .results{
76
+ // width: 48%;
77
+ // float: right;
78
+ background-color: #ffffaa;
79
+ padding: 5px;
80
+ }
81
+ #sizechart .results p{
82
+ margin: 0;
83
+ padding: 5px;
84
+ }
85
+ #sizechart .chart table{
86
+ width: 100%;
87
+ text-align: center;
88
+ }
89
+ #sizechart .chart td{
90
+ text-align: center;
91
+ }
92
+ #sizechart .country table{
93
+ width: 100%;
94
+ margin-top: 20px;
95
+ }
96
+ #sizechart .country td{
97
+ text-align: center;
98
+ }
99
+ #sizechart .notes{
100
+ font-size: 12px;
101
+ margin-top: 10px;
102
+ font-weight: bold;
103
+ }
104
+ .sizechart-credits {
105
+ clear: both;
106
+ float: left;
107
+ font-size: 8px;
108
+ }