-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq.full.js
269 lines (268 loc) · 79.9 KB
/
q.full.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*
* Q.Full 0.1.1
*
* Copyright (c) 2010 Boys Abroad (Wout Fierens)
*
* Licensed under the MIT (http://opensource.org/licenses/mit-license.php) license.
*/
if(typeof Prototype=='undefined')
alert("Q Error: Prototype is not loaded. Please make sure that your page includes prototype.js before it includes q.js");if(Prototype.Version<"1.6")
alert("Q Error: Minimum Prototype 1.6.0 is required; you are using "+Prototype.Version);if(Prototype.Browser.IE)
if(/MSIE (\d+\.\d+);/.test(navigator.userAgent))
Prototype.BrowserFeatures.version=new Number(RegExp.$1);if(Prototype.Browser.IE&&Prototype.BrowserFeatures.version<7)
alert("Your webbrowser, Internet Explorer "+Prototype.BrowserFeatures.version+", is more than 8 years old and doesn't support many of the features necessary for using this page.")
var Q={imagePath:"images/q",style:"default",types:$w("plain info notice warning error dark"),fontFamily:"Lucida Sans Unicode, Lucida Grande, sans-serif;",fontSize:"12px",imageTypes:{plain:0,info:1,notice:2,warning:3,error:4,dark:5},IE:Prototype.Browser.IE,Opera:Prototype.Browser.Opera,WebKit:Prototype.Browser.WebKit,Gecko:Prototype.Browser.Gecko,MobileSafari:Prototype.Browser.MobileSafari,instances:[],counts:{},active:false,cssDeclarations:[],setup:function(){Q.addDynamicStylesheetMethodsTo(document);this.css=document.createStyleSheet();this.setSkin();this.addCssFor('base');document.fire('q:loaded');},set:function(options){if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();if(options.image_path)
options.imagePath=options.image_path;$H(options).each((function(pair){this[pair.key]=pair.value;}).bind(this));this.setSkin(this.style,true);},setSkin:function(style,load){var preload=load?new Image(25,25):{};if(style)
this.style=style;$w("h v").each((function(part){preload.src=this["imagePath_"+part]=this.imagePath+"/"+this.style+"-"+part+".png";}).bind(this));this.types.each((function(type){preload.src=this["filler_path_"+type]=this.imagePath+"/"+this.style+"-"+type+".png";}).bind(this));["#q_wrapper","#q_wrapper input","#q_wrapper textarea"].each((function(klass){this.addCss(klass,"font-family:"+this.fontFamily+";font-size:"+this.fontSize+";");}).bind(this));},create:function(subclass,options){var klass=options.klass||'q-'+subclass.toLowerCase(),inputType='input';if(subclass=='Textarea')
inputType='textarea'
$$(inputType+'.'+klass).each(function(input){new Q[subclass](input,options);});},register:function(subclass){if(this.counts[subclass])
this.counts[subclass]+=1;else
this.counts[subclass]=1;},hide:function(force){if(force||(this.active&&!this.active.persistent))
this.active.hide();},hideAll:function(force){this.instances.each((function(instance){if(instance!=this&&(force||!instance.persistent))
instance.hide(force);}).bind(this));},reposition:function(){this.instances.invoke("positionHolder");},addCss:function(targets,cssText){if(typeof targets=='string'){targets.split(',').collect(function(part){return part.strip();}).each((function(selector){this.css.addRule(selector,cssText);}).bind(this));}else if(typeof targets=='object'){$H(targets).each((function(pair){if(typeof pair.value=='object'){cssText='';$H(pair.value).each(function(p){cssText+=p.key.underscore().dasherize()+':'+p.value+';';});}else{cssText=pair.value;}
this.css.addRule(pair.key,cssText);}).bind(this));}},addCssFor:function(plugin){if(this.cssDeclarations.indexOf(plugin)>-1)return;switch(plugin){case"base":this.addCss("div.q-protective-layer","position:fixed;left:0;top:0;width:100%;height:100%;z-index:99997;background-color:#fff;");this.addCss("div.q-wrapper","position:absolute;left:0;top:0;z-index:99999999;width:100%;height:1px;");this.addCss(".q-clearer","content:'.';display:block;clear:both;visibility:hidden;line-height:0;height:0;zoom:1;list-style-type:none;margin:0;padding:0;");this.addCss("div.q-background","width:100%;height:100%;padding:0;margin:0;border-spacing:0;position:relative;");this.addCss("div.q-background div.q-center","margin:0 12px;position:relative;");this.addCss("div.q-background div.q-center div.q-top-spacer","height:1px;");this.addCss("div.q-background div.q-corner","width:12px;height:12px;position:absolute;margin:0;padding:0;");this.addCss("div.q-background div.q-edge","width:100%;height:12px;position:absolute;left:0;");this.addCss("div.q-background div.q-edge-spacer","height:12px;position:relative;");this.addCss("div.q-background div.q-border","width:12px;height:100%;position:absolute;margin:0;padding:0;");this.addCss(".q-plain","color:#333;");this.addCss(".q-info","color:rgb(44, 50, 51);");this.addCss(".q-notice","color:rgb(40, 51, 0);");this.addCss(".q-warning","color:rgb(51, 31, 2);");this.addCss(".q-error","color:#fff;");this.addCss(".q-dark","color:#fff;");break;case"informer":this.addCss(".q-message","position:relative;margin:0 0 5px 0;overflow:hidden;cursor:pointer;");this.addCss("div.q-message div.q-message-close","position:absolute;width:24px;height:24px;right:0px;top:0px;z-index:100;cursor:pointer;background-position:-24px -168px;background-image:url("+Q.imagePath_h+");visibility:hidden;");this.addCss("div.q-message:hover div.q-message-close","visibility:visible;");this.addCss("div.q-message div.q-message-close.q-left","left:0px;right:auto;");this.addCss(".q-text","font-size:12px;");this.addCss(".q-pending-bar","width:auto;height:16px;border:1px solid #999;-moz-border-radius:2px;-webkit-border-radius:2px;background-image:url("+Q.imagePath+"/pending.gif"+");");this.addCss(".q-progress-bar","width:auto;height:16px;border:1px solid #999;-moz-border-radius:2px;-webkit-border-radius:2px;");this.addCss(".q-progress-bar .q-indicator","width:0;height:100%;background-color:#ccc;");break;case"palette":this.addCss("#q_wrapper ul.q-palette","margin:0; padding:0; max-width:342px");this.addCss("#q_wrapper ul.q-palette li.q-color","padding:0; list-style-type:none; margin:2px; float:left; width:15px; height:15px; cursor:pointer;");this.addCss("#q_wrapper ul.q-palette li.q-color:hover","margin:0px; width:19px; height:19px;");this.addCss("#q_wrapper ul.q-palette li.q-color.active","margin:0px; width:19px; height:19px;");this.addCss("#q_wrapper ul.q-palette li.q-color.round","-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;");break;case"tagger":this.addCss("#q_wrapper ul.q-taglist","margin:0;padding:0;");this.addCss("#q_wrapper ul.q-taglist li.q-tag","margin:3px;padding:0px 8px;list-style-type:none;float:left;background-color:#666;color:#fff;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;cursor:pointer;");this.addCss("#q_wrapper ul.q-taglist li.q-tag:hover","background-color:#ccc;color:#666;text-decoration:line-through;");this.addCss("#q_wrapper ul.q-taglist li.q-tag.q-used","background-color:#ccc;color:#666;text-decoration:line-through;");this.addCss("#q_wrapper ul.q-taglist li.q-tag.q-used:hover","background-color:#666;color:#fff;text-decoration:none;");break;case"tooltip":this.addCss("#q_wrapper div.q-tooltip","position:absolute;");this.addCss("#q_wrapper div.q-tooltip div.q-content","overflow:hidden;");break;case"textarea":var cssClass;this.addCss('div.q-textarea-wrapper','position: relative;');this.addCss('div.q-textarea-wrapper iframe','border: 1px solid #ccc;');this.addCss('div.q-textarea-wrapper textarea','border:1px solid #ccc; resize:none; position:relative !important; top:auto; left:auto; right:auto; bottom:auto;');this.addCss("ul.q-textarea-toolbar","margin:0; padding: 0; background-color:#f2f2f2; position:relative;");this.addCss("ul.q-textarea-toolbar li.button","margin:0; padding:0; list-style-type:none; cursor:pointer; float:left; position:relative; width:30px; height:30px; background-image: url("+Q.imagePath+"/textarea.png);");this.addCss("ul.q-textarea-toolbar li.q-heading-select","position:absolute; margin:0; padding:0; list-style-type:none; top:0px; left:0; z-index:10;");this.addCss("ul.q-textarea-toolbar li.q-heading-select ul","margin:0; padding:0; top:0px; width:210px; height:30px; background-color:#fff; -webkit-box-shadow: rgba(0, 0, 0, 0.5) 0px 2px 7px; box-shadow: rgba(0, 0, 0, 0.5) 0px 2px 7px; -moz-box-shadow: rgba(0, 0, 0, 0.5) 0px 2px 7px;");this.addCss("ul.q-textarea-toolbar li.q-heading-select ul li","margin:0; padding:0; list-style-type:none; float:left; cursor:pointer;");this.addCss("ul.q-textarea-toolbar li.button input.q-editor-color-field","width:28px; height:28px; margin:0; padding:0; opacity:0; -moz-opacity:0; cursor:pointer;");if(Q.IE){this.addCss("ul.q-textarea-toolbar li.button input.q-editor-color-field","filter:alpha(opacity=0);");this.addCss("ul.q-textarea-toolbar li.q-heading-select ul","border: 2px solid #666;");}
this.addCss("ul.q-textarea-toolbar.small li.q-heading-select ul","width:140px; height:20px;");this.addCss("ul.q-textarea-toolbar.small li.button","width:20px; height:20px; background-image: url("+Q.imagePath+"/textarea-small.png);");this.addCss("ul.q-textarea-toolbar.small li.button select.q-editor-select","top: 2px; width:20px; height:20px;");this.addCss("ul.q-textarea-toolbar.small li.button input.q-editor-color-field","width:18px; height:18px;");$w('Heading Bold Italic Underline StrikeThrough CreateLink InsertImage JustifyLeft JustifyCenter JustifyRight JustifyFull Indent Outdent ForeColor BackColor InsertUnorderedList InsertOrderedList RemoveFormat EditCode').each((function(button,i){cssClass=button.underscore().dasherize();this.addCss("ul.q-textarea-toolbar li."+cssClass,"background-position: -"+i*30+"px 0;");this.addCss("ul.q-textarea-toolbar li."+cssClass+":hover"+", ul.q-textarea-toolbar li."+cssClass+".active","background-position: -"+i*30+"px -30px;");this.addCss("ul.q-textarea-toolbar li."+cssClass+".inactive","background-position: -"+i*30+"px -60px !important; cursor:default !important;");this.addCss("ul.q-textarea-toolbar.small li."+cssClass,"background-position: -"+i*20+"px 0;");this.addCss("ul.q-textarea-toolbar.small li."+cssClass+":hover"+", ul.q-textarea-toolbar.small li."+cssClass+".active","background-position: -"+i*20+"px -20px;");this.addCss("ul.q-textarea-toolbar.small li."+cssClass+".inactive","background-position: -"+i*20+"px -40px !important; cursor:default !important;");}).bind(this));this.addCss("ul.q-textarea-toolbar li.option.div","background-position: 0px 0px;");this.addCss("ul.q-textarea-toolbar li.option.div:hover","background-position: 0px -30px;");this.addCss("ul.q-textarea-toolbar.small li.option.div","background-position: 0px 0px;");this.addCss("ul.q-textarea-toolbar.small li.option.div:hover","background-position: 0px -20px;");$R(1,6).each((function(i){this.addCss("ul.q-textarea-toolbar li.option.h"+i,"background-position: -"+(540+i*30)+"px 0px;");this.addCss("ul.q-textarea-toolbar li.heading.h"+i+", ul.q-textarea-toolbar li.option.h"+i+":hover","background-position: -"+(540+i*30)+"px -30px;");this.addCss("ul.q-textarea-toolbar li.heading.h"+i+".inactive","background-position: -"+(540+i*30)+"px -60px;");this.addCss("ul.q-textarea-toolbar.small li.option.h"+i,"background-position: -"+(360+i*20)+"px 0px;");this.addCss("ul.q-textarea-toolbar.small li.heading.h"+i+", ul.q-textarea-toolbar.small li.option.h"+i+":hover","background-position: -"+(360+i*20)+"px -20px;");this.addCss("ul.q-textarea-toolbar.small li.heading.h"+i+".inactive","background-position: -"+(360+i*20)+"px -40px;");}).bind(this));break;case"window":this.addCss("div.q-window","z-index:99996;font-size:12px;");this.addCss("div.q-window div.q-content","overflow:hidden;");this.addCss("div.q-window div.q-window-close","position:absolute;width:24px;height:24px;right:0px;top:0px;z-index:100;cursor:pointer;background-position:-24px -168px;background-image:url("+Q.imagePath_h+");");this.addCss("div.q-window div.q-window-close.q-left","left:0px;right:auto;");this.addCss("div.q-window div.q-window-resize","position:absolute;width:24px;height:24px;right:6px;bottom:5px;z-index:101;cursor:move;background-position:-72px -168px;background-image:url("+Q.imagePath_h+");");this.addCss("div.q-plain div.q-window-resize","background-position:-96px -168px;");this.addCss("div.q-window div.q-window-title","position:absolute;width:100%;height:24px;left:0px;top:6px;");this.addCss("div.q-window div.q-window-title p.q-window-label","height:100%;margin:0 25px;font-weight:bold;text-align:center;");this.addCss("div.q-window div.q-buttons-wrapper","position:relative;height:25px;")
this.addCss("div.q-window div.q-buttons-wrapper input.q-button","width:100px;height:22px;cursor:pointer;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #fff;font-size:12px;font-weight:bold;background-color:#ccc;background-image:url("+Q.imagePath_h+");background-position:0 -200px;");this.addCss("div.q-window input.q-button:hover","background-color:#999;");this.addCss("div.q-window div.q-buttons-wrapper input.q-next-button","background-color:#8CC63F;text-shadow:#BFFF5C 0px 1px 0px;color:#111;float:right;margin-right:10px;");this.addCss("div.q-window input.q-next-button:hover","background-color:#67991D;");this.addCss("div.q-window div.q-buttons-wrapper input.q-cancel-button","text-shadow:#fff 0px 1px 0px;color:#333;float:left;margin-left:10px;display:block;");this.addCss("div.q-window textarea.q-textarea","width:94%;height:150px;resize:vertical;margin:0 3% 20px 3%;");break;}
this.cssDeclarations.push(plugin);},callback:function(method,self,value,state){switch(typeof self.options[method]){case'function':if(typeof state!='undefined')
self.options[method](value,state,self);else if(typeof value!='undefined')
self.options[method](value,self);else
self.options[method](self);break;case'string':(function(){eval(self.options[method]);}).bind(self)();break;}}};Q.Base=Class.create({initialize:function(input){this.options={};this.createWrapper();this.is_over=false;Q.instances.push(this);if(input)
this.input=$(input);},createWrapper:function(){if($("q_wrapper")){this.div=$("q_wrapper");}else{this.div=new Element("div",{id:"q_wrapper","class":"q-wrapper"});$(document.body).insert({bottom:this.div});}},createHolder:function(type){var holder=this.holder=new Element("div");if(this.options.div)
this.div=$(this.options.div);if(!type)
this.options.style||"plain";holder.addClassName("q-holder").setStyle(this.options.holderStyle).hide();holder.background=this.buildBackground(type);holder.insert(holder.background);this.div.insert(holder);if(!this.options.div)
this.positionHolder();this.holder.observe("mouseover",(function(){this.is_over=true;}).bind(this));this.holder.observe("mouseout",(function(){if(this.is_over)
this.input.focus();this.is_over=false;}).bind(this));this.input.observe("focus",(function(){this.show();}).bind(this));this.input.observe("blur",(function(){if(!this.is_over)this.hide();}).bind(this));return holder;},buildBackground:function(type){var table=new Element("table",{"class":"q-background"}),c=Q.imageTypes[type||"plain"],s=24,div,center;div=new Element("div").addClassName("q-background q-"+type);div.insert(new Element("div").addClassName("q-corner").setStyle({left:0,top:0,backgroundImage:"url("+Q.imagePath_h+")",backgroundPosition:-(c*s)+"px -144px"}));div.insert(new Element("div").addClassName("q-edge-spacer"));div.insert(new Element("div").addClassName("q-corner").setStyle({right:0,top:0,backgroundImage:"url("+Q.imagePath_h+")",backgroundPosition:-(c*s+12)+"px -144px"}));div.center=new Element("div").addClassName("q-content");div.insert(center=new Element("div").addClassName("q-center").setStyle({backgroundImage:"url("+Q["filler_path_"+type]+")"}).insert(new Element("div").addClassName("q-border").setStyle({left:"-12px",top:"0px",backgroundImage:"url("+Q.imagePath_v+")",backgroundPosition:-(c*s)+"px 0"})).insert(new Element("div").addClassName("q-border").setStyle({right:"-12px",top:"0px",backgroundImage:"url("+Q.imagePath_v+")",backgroundPosition:-(c*s+12)+"px 0"})).insert(new Element("div").addClassName("q-edge").setStyle({top:"-12px",backgroundImage:"url("+Q.imagePath_h+")",backgroundPosition:"0 "+-(c*s)+"px"})).insert(new Element("div").addClassName("q-edge").setStyle({bottom:"-12px",backgroundImage:"url("+Q.imagePath_h+")",backgroundPosition:"0 "+-(c*s+11)+"px"})).insert(new Element("div").addClassName("q-top-spacer")));if(Prototype.Browser.IE)
center.insert(new Element("div").addClassName("q-top-spacer"))
center.insert(div.center)
div.insert(new Element("div").addClassName("q-corner").setStyle({left:0,bottom:0,backgroundImage:"url("+Q.imagePath_h+")",backgroundPosition:-(c*s)+"px -155px"}));div.insert(new Element("div").addClassName("q-edge-spacer"));div.insert(new Element("div").addClassName("q-corner").setStyle({right:0,bottom:0,backgroundImage:"url("+Q.imagePath_h+")",backgroundPosition:-(c*s+12)+"px -155px"}));div.insert=function(content,options){this.center.insert(content,options);return this;}
div.update=function(content){this.center.update(content);return this;}
return div;},positionHolder:function(){if(this.holder&&typeof this.input!="undefined"){var pos=this.input.cumulativeOffset(),dim=this.input.getDimensions(),doc=document.viewport.getDimensions(),left=pos[0],top=pos[1]+dim.height,x=this.options.left,y=this.options.top;if(this.options.axis=="vertical"){left=pos[0]+dim.width;top=pos[1];}
if(x==0||parseInt(x))
left+=parseInt(x);if(left+this.holder.getWidth()>doc.width)
left=doc.width-this.holder.getWidth()-5;if(y==0||parseInt(y))
top+=parseInt(y);this.holder.setStyle({left:left+"px",top:top+"px"});}},show:function(force){if(Q.active!=this||force){this.positionHolder();if(typeof this.setValue=="function"&&this.input)
this.setValue(this.input.value);Q.callback('onShow',this);Q.active=this;this.holder.appear({duration:0.1});}},hide:function(force){if(Q.active||force){Q.active=false;if(force){this.is_over=false;this.holder.hide();}else{this.holder.fade({duration:0.05});}
if(this.input)
this.input.blur();Q.callback('onHide',this);}},close:function(){this.hide(true);Q.callback('onClose',this);}});Q.Cookies=Class.create({initialize:function(options){this.options={expires:3600,path:'',domain:'',secure:false,prefix:'Q_'};$H(this.options).merge(options||{}).toObject();if(this.options.expires!=''){var date=new Date();date=new Date(date.getTime()+(this.options.expires*1000));this.options.expires='; expires='+date.toGMTString();}
if(this.options.path!='')
this.options.path='; path='+escape(this.options.path);if(this.options.domain!='')
this.options.domain='; domain='+escape(this.options.domain);if(this.options.secure==true)
this.options.secure='; secure';else
this.options.secure='';},create:function(name,value){var cookie_string,cookie=this.options;name=this.options.prefix+name;switch(typeof value){case'undefined':case'function':case'unknown':return false;case'boolean':case'string':case'number':value=String(value.toString());}
cookie_string=name+"="+escape(Object.toJSON(value));try{document.cookie=cookie_string+cookie.expires+cookie.path+cookie.domain+cookie.secure;}catch(e){return false;}
return true;},remove:function(name){var cookie=this.options,date,expires;name=this.options.prefix+name;try{date=new Date();date.setTime(date.getTime()-(3600*1000));expires='; expires='+date.toGMTString();document.cookie=name+"="+expires+cookie.path+cookie.domain+cookie.secure;}catch(e){return false;}
return true;},get:function(name){name=this.options.prefix+name;var cookies=document.cookie.match(name+'=(.*?)(;|$)');if(cookies){return(unescape(cookies[1])).evalJSON();}else{return null;}},clear:function(){this.names().each((function(key){this.remove(key);}).bind(this));},all:function(){var cookies={};this.names().each((function(key,i){cookies[key]=this.get(key);}).bind(this));return cookies;},names:function(){var keys=[],key_format=/[^=; ]+(?=\=)/g,raw_string=document.cookie,reg_exp=new RegExp("^"+this.options.prefix);while((match=key_format.exec(raw_string))!=undefined){if(reg_exp.test(match[0].strip()))
keys.push(match[0].strip().gsub("^"+this.options.prefix,""));}
return keys;}});Q.I18n={locale:"en",locales:{},add:function(locales){if(typeof locales=="string"&&locales.isJSON())
locales=locales.evalJSON();this.locales=$H(this.locales).merge(locales).toObject();},t:function(key,interpolations){var loc=this.locales,list;key.split(".").each((function(k){if(loc[k])
loc=loc[k];}).bind(this));if(typeof loc=='object'){if(interpolations&&interpolations.fallback){return interpolations.fallback;}else{list=key.split(".");list.unshift(this.locale);return"translation missing: "+list.join(", ");}}else if(typeof loc=="string"&&typeof interpolations=="object"){$H(interpolations).each(function(pair){loc=loc.gsub(new RegExp("\{\{([ ]+)?"+pair.key+"([ ]+)?\}\}"),pair.value)});return loc;}else{return loc;}}}
Object.extend(window,{observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize()});(document.onresize?document:window).observe("resize",function(){if(!document.viewport.is_resized){document.viewport.is_resized=true;document.fire("resize:start");var resizeEnd=(function(){document.viewport.is_resized=false;document.fire("resize:end");Event.stopObserving(document,"mousemove",resizeEnd);}).bind(this);document.observe("mousemove",resizeEnd);}});Object.extend(String.prototype,{toMD5:function(){var string=this;function RotateLeft(lValue,iShiftBits){return(lValue<<iShiftBits)|(lValue>>>(32-iShiftBits));}
function AddUnsigned(lX,lY){var lX4,lY4,lX8,lY8,lResult;lX8=(lX&0x80000000);lY8=(lY&0x80000000);lX4=(lX&0x40000000);lY4=(lY&0x40000000);lResult=(lX&0x3FFFFFFF)+(lY&0x3FFFFFFF);if(lX4&lY4){return(lResult^0x80000000^lX8^lY8);}
if(lX4|lY4){if(lResult&0x40000000){return(lResult^0xC0000000^lX8^lY8);}else{return(lResult^0x40000000^lX8^lY8);}}else{return(lResult^lX8^lY8);}}
function F(x,y,z){return(x&y)|((~x)&z);}
function G(x,y,z){return(x&z)|(y&(~z));}
function H(x,y,z){return(x^y^z);}
function I(x,y,z){return(y^(x|(~z)));}
function FF(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(F(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function GG(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(G(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function HH(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(H(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function II(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(I(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function ConvertToWordArray(string){var lWordCount;var lMessageLength=string.length;var lNumberOfWords_temp1=lMessageLength+8;var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1%64))/64;var lNumberOfWords=(lNumberOfWords_temp2+1)*16;var lWordArray=Array(lNumberOfWords-1);var lBytePosition=0;var lByteCount=0;while(lByteCount<lMessageLength){lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=(lWordArray[lWordCount]|(string.charCodeAt(lByteCount)<<lBytePosition));lByteCount++;}
lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=lWordArray[lWordCount]|(0x80<<lBytePosition);lWordArray[lNumberOfWords-2]=lMessageLength<<3;lWordArray[lNumberOfWords-1]=lMessageLength>>>29;return lWordArray;};function WordToHex(lValue){var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;for(lCount=0;lCount<=3;lCount++){lByte=(lValue>>>(lCount*8))&255;WordToHexValue_temp="0"+lByte.toString(16);WordToHexValue=WordToHexValue+WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);}
return WordToHexValue;};function Utf8Encode(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;};var x=Array();var k,AA,BB,CC,DD,a,b,c,d;var S11=7,S12=12,S13=17,S14=22;var S21=5,S22=9,S23=14,S24=20;var S31=4,S32=11,S33=16,S34=23;var S41=6,S42=10,S43=15,S44=21;string=Utf8Encode(string);x=ConvertToWordArray(string);a=0x67452301;b=0xEFCDAB89;c=0x98BADCFE;d=0x10325476;for(k=0;k<x.length;k+=16){AA=a;BB=b;CC=c;DD=d;a=FF(a,b,c,d,x[k+0],S11,0xD76AA478);d=FF(d,a,b,c,x[k+1],S12,0xE8C7B756);c=FF(c,d,a,b,x[k+2],S13,0x242070DB);b=FF(b,c,d,a,x[k+3],S14,0xC1BDCEEE);a=FF(a,b,c,d,x[k+4],S11,0xF57C0FAF);d=FF(d,a,b,c,x[k+5],S12,0x4787C62A);c=FF(c,d,a,b,x[k+6],S13,0xA8304613);b=FF(b,c,d,a,x[k+7],S14,0xFD469501);a=FF(a,b,c,d,x[k+8],S11,0x698098D8);d=FF(d,a,b,c,x[k+9],S12,0x8B44F7AF);c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);a=FF(a,b,c,d,x[k+12],S11,0x6B901122);d=FF(d,a,b,c,x[k+13],S12,0xFD987193);c=FF(c,d,a,b,x[k+14],S13,0xA679438E);b=FF(b,c,d,a,x[k+15],S14,0x49B40821);a=GG(a,b,c,d,x[k+1],S21,0xF61E2562);d=GG(d,a,b,c,x[k+6],S22,0xC040B340);c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);b=GG(b,c,d,a,x[k+0],S24,0xE9B6C7AA);a=GG(a,b,c,d,x[k+5],S21,0xD62F105D);d=GG(d,a,b,c,x[k+10],S22,0x2441453);c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);b=GG(b,c,d,a,x[k+4],S24,0xE7D3FBC8);a=GG(a,b,c,d,x[k+9],S21,0x21E1CDE6);d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);c=GG(c,d,a,b,x[k+3],S23,0xF4D50D87);b=GG(b,c,d,a,x[k+8],S24,0x455A14ED);a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);d=GG(d,a,b,c,x[k+2],S22,0xFCEFA3F8);c=GG(c,d,a,b,x[k+7],S23,0x676F02D9);b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);a=HH(a,b,c,d,x[k+5],S31,0xFFFA3942);d=HH(d,a,b,c,x[k+8],S32,0x8771F681);c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);a=HH(a,b,c,d,x[k+1],S31,0xA4BEEA44);d=HH(d,a,b,c,x[k+4],S32,0x4BDECFA9);c=HH(c,d,a,b,x[k+7],S33,0xF6BB4B60);b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);d=HH(d,a,b,c,x[k+0],S32,0xEAA127FA);c=HH(c,d,a,b,x[k+3],S33,0xD4EF3085);b=HH(b,c,d,a,x[k+6],S34,0x4881D05);a=HH(a,b,c,d,x[k+9],S31,0xD9D4D039);d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);b=HH(b,c,d,a,x[k+2],S34,0xC4AC5665);a=II(a,b,c,d,x[k+0],S41,0xF4292244);d=II(d,a,b,c,x[k+7],S42,0x432AFF97);c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);b=II(b,c,d,a,x[k+5],S44,0xFC93A039);a=II(a,b,c,d,x[k+12],S41,0x655B59C3);d=II(d,a,b,c,x[k+3],S42,0x8F0CCC92);c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);b=II(b,c,d,a,x[k+1],S44,0x85845DD1);a=II(a,b,c,d,x[k+8],S41,0x6FA87E4F);d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);c=II(c,d,a,b,x[k+6],S43,0xA3014314);b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);a=II(a,b,c,d,x[k+4],S41,0xF7537E82);d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);c=II(c,d,a,b,x[k+2],S43,0x2AD7D2BB);b=II(b,c,d,a,x[k+9],S44,0xEB86D391);a=AddUnsigned(a,AA);b=AddUnsigned(b,BB);c=AddUnsigned(c,CC);d=AddUnsigned(d,DD);}
var temp=WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);return temp.toLowerCase();},HTMLencode:function(){var str=this.replace(/&/g,"&");str=str.replace(/>/g,">");str=str.replace(/</g,"<");str=str.replace(/"/g,""");str=str.replace(/'/g,"'");return str;},HTMLdecode:function(){var str=this.replace(/&/g,"&");str=str.replace(/>/g,">");str=str.replace(/</g,"<");str=str.replace(/"/g,"\"");str=str.replace(/'/g,"'");return str;},humanize:function(){return this.underscore().capitalize().gsub(/(_id)|\-|\.|_/,' ');}});Object.extend(Number.prototype,{toMD5:function(){return this.toString().toMD5();},withFormat:function(options){var prefix=options.prefix||'',delimiter=options.delimiter||'',separator=options.separator||'',suffix=options.suffix||'',precision=options.precision,parts,number=this;if(typeof precision=='number')
number=number.toFixed(precision);parts=number.toString().split('.');parts[0]=parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+delimiter);return prefix+parts.join(separator)+suffix;}});Q.addDynamicStylesheetMethodsTo=function(doc){if(typeof doc.createStyleSheet=='undefined'){doc.createStyleSheet=(function(){function createStyleSheet(href){if(typeof href!=='undefined'){var element=doc.createElement('link');element.type='text/css';element.rel='stylesheet';element.href=href;}
else{var element=doc.createElement('style');element.type='text/css';}
doc.getElementsByTagName('head')[0].appendChild(element);var sheet=doc.styleSheets[doc.styleSheets.length-1];if(typeof sheet.addRule==='undefined')
sheet.addRule=addRule;if(typeof sheet.removeRule==='undefined')
sheet.removeRule=sheet.deleteRule;return sheet;}
function addRule(selectorText,cssText,index){if(typeof index==='undefined')
index=this.cssRules.length;this.insertRule(selectorText+' {'+cssText+'}',index);}
return createStyleSheet;})();}}
document.observe("dom:loaded",function(){document.observe("resize:start",function(){Q.hide();});document.observe("resize:end",function(){Q.reposition();});Q.setup();});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.informer.js");Q.Informer=Class.create(Q.Base,{initialize:function($super,options){$super();if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();Q.addCssFor('informer');Q.register('informer');this.options=$H(this.options).merge({closeButton:'right',life:{plain:10,info:10,notice:7,warning:12,error:"immortal",dark:10},holderStyle:{position:"fixed",right:"10px",top:"10px",width:"250px",zIndex:100001}}).merge(options).toObject();if(!this.div.down("div.q-holder.messages")){var holder,width;if(width=parseInt(this.options.width))
this.options.holderStyle.width=width+'px';holder=this.holder=new Element("div").addClassName("q-holder messages").setStyle(this.options.holderStyle);this.div.insert(holder);if(Prototype.Browser.MobileSafari){var holder_width=parseInt(this.options.holderStyle.width)||250,holder_top=parseInt(this.options.holderStyle.top)||10,holder_right=parseInt(this.options.holderStyle.right),holder_left=parseInt(this.options.holderStyle.left),screen_width=document.viewport.getWidth(),off=document.viewport.getScrollOffsets(),left;holder.setStyle({position:'absolute',right:'auto'});_QInformerRepositionEvent=function(){off=document.viewport.getScrollOffsets();screen_width=document.viewport.getWidth();if(holder_right==0||holder_right)
left=(screen_width-holder_width-holder_right-off.left)+'px';else if(holder_left==0||holder_left)
left=holder_left+'px';else
left='10px';holder.morph('left:'+left+';top:'+(off.top+10)+'px;',{duration:0.3});}
window.observe('scroll',_QInformerRepositionEvent);}}else{this.holder=this.div.down("div.q-holder.messages");}
$w("plain info notice warning error dark").each((function(type){this[type]=(function(message,life){this.message(type,message,life);}).bind(this);$$("p.q-"+type).each((function(message){var m,life;if(m=message.className.match(/q-life-([\d\.]+)/))
life=parseFloat(m[1]);else if(message.hasClassName("q-immortal"))
life="immortal";this.message(type,message.innerHTML,life);message.remove();}).bind(this));}).bind(this));},messages:function(type,list,life){if(!list)return;if(typeof list=="string"&&list.isJSON())
list=list.evalJSON();list.each((function(message){this.message(type,message,life)}).bind(this));return this;},message:function(type,text,life){var id=type+"_"+text.toMD5(),message,disappear,remove,close;if(!life)
life=this.options.life[type];if($(id)&&$(id).visible()){$(id).pulsate({pulses:3,duration:1});}else{message=new Element("div",{id:id}).addClassName("q-message q-"+type).setStyle({width:"100%",left:"0"}).hide();message.insert(this.buildBackground(type));message.down(".q-center").insert(text);if(this.options.closeButton){close=new Element("div").addClassName("q-message-close");if(this.options.closeButton=='left')
close.addClassName("q-left");message.insert(close);}
message.observe("click",(function(){this.disappear(message);}).bind(this));this.holder.insert(message);if(life!="immortal")
(this.disappear).bind(this).delay(life,message);this.appear(message);}
return message;},pending:function(message,id){var pending,bar,text;if(!id)
id="pending_"+Math.random().toMD5();if($(id)){pending=$(id);if(!$(id).visible())
this.holder.insert(pending.remove());}else{pending=new Element("div",{id:id}).addClassName("q-message q-plain q-pending").setStyle({width:"100%",left:"0"}).hide();bar=new Element("div").addClassName("q-pending-bar");pending.insert(this.buildBackground("plain"));if(message&&!message.blank()){text=new Element("div").update(message).addClassName("q-text");pending.down(".q-center").insert(text);}
pending.down(".q-center").insert(bar);Event.observe(pending,"click",(function(){this.disappear(pending);}).bind(this));pending.ready=(function(){this.disappear(pending);}).bind(this);}
this.holder.insert(pending);this.appear(pending);return pending;},progress:function(message,id){var progress,bar,indicator,text;if(!id)
id="progress_"+Math.random().toMD5();if($(id)){progress=$(id);if(!$(id).visible())
this.holder.insert(progress.remove());}else{progress=new Element("div",{id:id}).addClassName("q-message q-plain q-progress").setStyle({width:"100%",left:"0"}).hide();indicator=new Element("div").addClassName("q-indicator");bar=new Element("div").addClassName("q-progress-bar").insert(indicator);progress.insert(this.buildBackground("plain"));if(message&&!message.blank()){text=new Element("div").addClassName("q-text");progress.down(".q-center").insert(text);}
progress.down(".q-center").insert(bar);this.holder.insert(progress);Event.observe(progress,"click",(function(){this.disappear(progress);}).bind(this));progress.update=(function(percent,new_message){if(new_message)
message=new_message;if(percent==0||(percent=parseInt(percent))){if(percent>=100){progress.down(".q-indicator").setStyle({width:"0%"});this.disappear(progress);progress.status=0;}else{text.update(message.gsub(/%n/,percent));progress.down(".q-indicator").morph("width: "+percent+"%",{duration:0.1});progress.status=percent;}}}).bind(this);progress.ready=(function(){this.disappear(progress);}).bind(this);progress.update(0);}
this.appear(progress);return progress;},appear:function(message){if(message.visible())
message.pulsate({pulses:3,duration:0.8});else{message.appear({duration:0.2});if(Prototype.Browser.MobileSafari)
_QInformerRepositionEvent();}},disappear:function(message){message=$(message);if(message.visible()){message.slideUp({duration:0.2});message.morph("margin:0;padding:0;width:0;left:100%;",{duration:0.2});var resetStyle=(function(){message.setStyle({width:"100%",left:"0"});}).bind(this);resetStyle.delay(0.25);}},shutUp:function(){this.holder.select(".q-message").each((function(message){this.disappear(message);}).bind(this));return this;},purgeHidden:function(id){this.holder.select(".q-message").each((function(message){if(!message.visible())
message.remove();}).bind(this));}});var _QInformerRepositionEvent;if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.palette.js");Q.Palette=Class.create(Q.Base,{initialize:function($super,input,options){$super(input);if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({round:true,maxRowSize:18,maxWidth:342,colorizeInput:true,swatchSize:19,swatchSpace:2,holderStyle:{position:'absolute'}}).merge(options).toObject();Q.addCssFor('palette');Q.register('palette');if(!this.input)
alert('Q.Palette Error: No input was defined to attach the Palette to!');else
this.build();},build:function(){var holder=this.createHolder('plain'),ulClass='q-palette-'+Q.counts.palette,shrunken=this.options.swatchSize-(this.options.swatchSpace*2),round=Math.ceil(this.options.swatchSize/2),maxWidth=this.options.maxRowSize?this.options.maxRowSize*this.options.swatchSize:this.options.maxWidth,value=this.value=this.input.value,valid=this.hexToRgb(value),ul;Q.addCss('#q_wrapper ul.q-palette.'+ulClass,'max-width:'+maxWidth+'px;');Q.addCss('#q_wrapper ul.q-palette.'+ulClass+' li.q-color','margin:'+this.options.swatchSpace+'px; width:'+shrunken+'px; height:'+shrunken+'px;');Q.addCss('#q_wrapper ul.q-palette.'+ulClass+' li.q-color:hover','margin:0px; width:'+this.options.swatchSize+'px; height:'+this.options.swatchSize+'px;');Q.addCss('#q_wrapper ul.q-palette.'+ulClass+' li.q-color.active','margin:0px; width:'+this.options.swatchSize+'px; height:'+this.options.swatchSize+'px;');Q.addCss('#q_wrapper ul.q-palette.'+ulClass+' li.q-color.round','-moz-border-radius:'+round+'px;-webkit-border-radius:'+round+'px;border-radius:'+round+'px;');ul=new Element('ul').addClassName('q-palette').addClassName(ulClass);this.colorList().each((function(color){var li=new Element('li').addClassName('q-color').setStyle({backgroundColor:color}).update(' ');if(this.options.round)
li.addClassName('round');if(value==color)
li.addClassName('active');li.onmouseover=(function(){Q.callback('onPick',this,color);}).bind(this);li.onclick=(function(){if(color!=this.value){Q.callback('onChange',this,color);li.up('ul.q-palette').select('li.active').invoke('removeClassName','active');li.addClassName('active');this.input.value=this.value=color;this.colorizeInput(color);}}).bind(this);ul.insert(li);}).bind(this));ul.insert(new Element('li').addClassName('q-clearer').update(' '));if(valid)
this.colorizeInput(this.rgbToHex(valid));holder.down("div.q-center").insert(ul);},colorList:function(){if(this.options.colors){return this.options.colors;}else{var colors=[];$w('00 33 66 99 cc ff').each(function(part_1){$w('00 33 66 99 cc ff').each(function(part_2){$w('00 33 66 99 cc ff').each(function(part_3){colors.push('#'+part_1+part_2+part_3);});});});return colors;}},colorizeInput:function(color){if(this.options.colorizeInput)
this.input.setStyle({backgroundColor:color,color:this.getTextColor(color)});return this;},getTextColor:function(hex){var rgb=this.hexToRgb(hex),brt=(rgb.r/255*0.30)+(rgb.g/255*0.59)+(rgb.b/255*0.11);if(brt<0.5){var m=Math.floor(brt*20)+3;var im=255*(m-1);}else{var m=Math.floor((1.0-brt)*20)+3;var im=0;}
return this.rgbToHex({r:Math.floor((rgb.r+im)/m),g:Math.floor((rgb.g+im)/m),b:Math.floor((rgb.b+im)/m)});},hexToRgb:function(hex){var m;if(m=/^[^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(hex))
return{r:parseInt(m[1],16),g:parseInt(m[2],16),b:parseInt(m[3],16)};if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(hex)){var b=parseInt(m[3],16);return{r:parseInt(m[1],16),g:parseInt(m[2],16),b:b*16+b};}
if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(hex)){var g=parseInt(m[2],16);return{r:parseInt(m[1],16),g:g,b:g};}
if(m=/^[^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(hex)){var r=parseInt(m[1],16);var g=parseInt(m[2],16);var b=parseInt(m[3],16);return{r:r*16+r,g:g*16+g,b:b*16+b};}
if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(hex)){var g=parseInt(m[1],16);return{r:g,g:g,b:g};}
if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(hex)){var g=parseInt(m[1],16);g=g*16+g;return{r:g,g:g,b:g};}
return false;},rgbToHex:function(rgb){return"#"+rgb.r.toColorPart()+rgb.g.toColorPart()+rgb.b.toColorPart();}});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.picker.js");Q.Picker=Class.create(Q.Base,{initialize:function($super,input,options){$super(input);if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({holderStyle:{position:"absolute"},offset:{left:0,top:0}}).merge(options).toObject();this.picking=false;Q.register('picker');if(!this.input)
alert("Q.Picker Error: No input was defined to attach the Picker to!");else
this.build();},build:function(){var paper=new Element("div"),color=this.options.value||this.input.value,holder;this.size=this.options.size||200;if(this.size<75)
this.size=75;else if(this.size>500)
this.size=500;if(!(holder=$(this.options.div))){holder=this.createHolder("plain").down("div.q-background").center;}
holder.insert(paper.setStyle({width:this.size+"px",height:this.size+"px"}));this.zoom=this.size/200;this.paper=Raphael(paper,this.size,this.size);this.mode=null;this.sb_box={x:35*this.zoom,y:25*this.zoom,width:130*this.zoom,height:112*this.zoom};this.buildColorwheel();this.buildTriangle();switch(this.identify(color)){case"hex":this.setHex(color);break;case"rgb":this.setRgb(color);break;case"hsb":this.setHsb(color);break;default:this.setHsb({h:0,s:100,b:100});break;}
holder.observe("mousedown",(function(event){event.preventDefault?event.preventDefault():event.returnValue=false;this.picking=true;this.onMouseDown(Event.pointerX(event)-this.offset(holder).x,Event.pointerY(event)-this.offset(holder).y,event.target);}).bind(this));document.observe("mousemove",(function(event){if(this.picking){event.preventDefault?event.preventDefault():event.returnValue=false;this.onMouseMove(Event.pointerX(event)-this.offset(holder).x,Event.pointerY(event)-this.offset(holder).y,event.target);}}).bind(this));document.observe("mouseup",(function(event){if(this.picking){event.preventDefault?event.preventDefault():event.returnValue=false;this.picking=false;this.onMouseUp(Event.pointerX(event)-this.offset(holder).x,Event.pointerY(event)-this.offset(holder).y,event.target);}}).bind(this));$w("Open Pick Change Close").each((function(e){this["on"+e]=function(){var hex=this.getHex(this.hsb);Q.callback("on"+e,this,hex);this.input.setValue(hex);}}).bind(this));this.input.observe("focus",(function(){this.onOpen(this.hsb,this);}).bind(this));this.input.observe("blur",(function(){this.onClose(this.hsb,this);}).bind(this));this.input.observe("change",(function(){this.setHex(this.input.value);}).bind(this));},setMode:function(mode){this.mode=mode||null;},buildColorwheel:function(){var wheel;wheel=this.paper.image(Q.imagePath+"/colorwheel.png",0,0,this.size,this.size);wheel.id="wheel";Event.observe(wheel.node,"mousedown",(function(){this.setMode("hue");}).bind(this));this.hue_picker=this.buildPicker(14,"hue");this.hue_picker.translate(this.size/2,8.5*this.zoom);},buildTriangle:function(){var points=[],r=75*this.zoom,part=120,tri,gradient,box,hit;(3).times(function(i){var a=i*part-90,x=r*Math.cos(a*Math.PI/180),y=r*Math.sin(a*Math.PI/180);points.push((i==0?"M":"L")+x+","+y);});points.push("Z");this.triangle=this.paper.set();tri=this.paper.path(points.join(" ")).translate(this.size/2,this.size/2+0.45*this.zoom).scale(0.985,0.985,this.size/2,this.size/2).attr({fill:"#f00","stroke-width":0}).toBack();this.triangle.push(tri);$w("#f00 #000 #fff").each((function(color,i){var c=this.paper.circle(this.size/2,25*this.zoom,7*this.zoom).attr({fill:color,"stroke-width":0}).rotate(120*i,this.size/2,this.size/2).toFront();if(i==0)
this.triangle.push(c);}).bind(this));hit=this.paper.circle(this.size/2,this.size/2,80*this.zoom).attr({fill:"#f00","stroke-width":0,opacity:0});Event.observe(hit.node,"mousedown",(function(){this.setMode("sb");}).bind(this));this.sb_picker=this.buildPicker(12,"sb");this.sb_picker.translate(this.size/2,25*this.zoom)},buildPicker:function(size,mode){var light=this.paper.circle(0,0,size/2*this.zoom).attr({"stroke-width":3*this.zoom,stroke:"#fff","stroke-opacity":0.8}),dark=this.paper.circle(0,0,size/3*this.zoom).attr({"stroke-width":1*this.zoom,stroke:"#333","stroke-opacity":0.8}),set=this.paper.set();Event.observe(light.node,"mousedown",(function(){this.setMode(mode);}).bind(this));Event.observe(dark.node,"mousedown",(function(){this.setMode(mode);}).bind(this));set.push(light,dark);return set;},onMouseDown:function(x,y,target){switch(this.mode){case"hue":this.changeHue(x,y);break;case"sb":this.changeSB(x,y);break;}},onMouseMove:function(x,y,target){switch(this.mode){case"hue":this.changeHue(x,y);break;case"sb":this.changeSB(x,y);break;}},onMouseUp:function(x,y,target){if(this.mode)
this.onChange();this.setMode();},changeHue:function(x,y){x-=this.size/2;y-=this.size/2;var hyp=Math.sqrt(Math.pow(x,2)+Math.pow(y,2)),cos=x/hyp,rad=Math.acos(cos),deg=Math.floor(180/(Math.PI/rad));if(y<0)
deg=-deg;else if((Math.floor(y)==0)&&(x<0))
deg=180;deg+=90;this.setHue(deg);this.applyValue({h:deg,s:this.hsb.s,b:this.hsb.b});this.onPick();},setHue:function(hue){this.hue_picker.rotate(hue,this.size/2,this.size/2);this.triangle.attr({fill:this.hsbToHex({h:hue,s:100,b:100})});},changeSB:function(x,y){var box,pct,sat,bgt,half,left,right;box=this.sb_box;if(x<box.x)x=box.x;if(x>box.x+box.width)x=box.x+box.width;if(y<box.y)y=box.y;if(y>box.y+box.height)y=box.y+box.height;pct=(y-box.y)/box.height;half=box.width/2;left=box.x+half-(half*pct);right=box.x+half+half*pct;if(x<left)x=left;if(x>right)x=right;this.sb_picker.attr({cx:x,cy:y});sat=Math.abs(-100+pct*100);brt=Math.abs(-100+(((x-box.x)+pct*half)-half)/box.width*100);this.applyValue({h:this.hsb.h,s:sat,b:brt});this.onPick();},setSB:function(sat,brt){var n_sat=Math.abs(-100+sat),n_brt=Math.abs(-100+brt),half=this.sb_box.width/2,width=this.sb_box.width/100*n_sat,x_off=this.sb_box.x+half/100*sat,point=(brt-sat)/(100-sat)*width,x=x_off+width-(point||0),y=this.sb_box.y+n_sat/100*this.sb_box.height;this.sb_picker.attr({cx:x,cy:y});},applyValue:function(hsb){this.hsb=hsb;var hex=this.getHex();this.input.setValue(hex).setStyle({backgroundColor:hex,color:this.getTextColor(hsb)});},setValue:function(hsb){if(typeof hsb!="string"){this.setHue(hsb.h);this.setSB(hsb.s,hsb.b);this.applyValue(hsb);}},setHex:function(hex){this.setValue(this.hexToHsb(hex));},setRgb:function(rgb){this.setValue(this.rgbToHsb(rgb));},setHsb:function(hsb){this.setValue(hsb);},getHex:function(){return this.rgbToHex(this.hsbToRgb(this.hsb));},getRgb:function(){return this.hsbToRgb(this.hsb);},getHsb:function(){return this.hsb;},getTextColor:function(hsb){var rgb=this.hsbToRgb(hsb),brt=(rgb.r/255*0.30)+(rgb.g/255*0.59)+(rgb.b/255*0.11);if(brt<0.5){var m=Math.floor(brt*20)+3;var im=255*(m-1);}else{var m=Math.floor((1.0-brt)*20)+3;var im=0;}
return this.rgbToHex({r:Math.floor((rgb.r+im)/m),g:Math.floor((rgb.g+im)/m),b:Math.floor((rgb.b+im)/m)});},offset:function(element){var pos=$(this.options.div||element).cumulativeOffset(),off={x:pos.left,y:pos.top},scroll;if(Prototype.Browser.IE&&typeof this.options.div=="undefined"&&Prototype.BrowserFeatures.version<8){off.x-=12;off.y-=12;}
if(this.options.position=='fixed'){scroll=document.viewport.getScrollOffsets();off.x+=scroll.left;off.y+=scroll.top;}
return off;},hsbToRgb:function(hsb){var v=this.toNumber(hsb.b);if(v<0)v=0;if(v>100)v=100;v=v*255/100;var s=this.toNumber(hsb.s);if(s>100)s=100;var h=this.toNumber(hsb.h);h=h%360;if(h<0)h+=360;var vs=v*s/100;var vsf=(vs*((h*256/60)%256))/256;var r,g,b;switch(Math.floor(h/60)){case 0:r=v;g=v-vs+vsf;b=v-vs;break;case 1:r=v-vsf;g=v;b=v-vs;break;case 2:r=v-vs;g=v;b=v-vs+vsf;break;case 3:r=v-vs;g=v-vsf;b=v;break;case 4:r=v-vs+vsf;g=v-vs;b=v;break;case 5:r=v;g=v-vs;b=v-vsf;break;}
r=Math.floor(r+0.5);g=Math.floor(g+0.5);b=Math.floor(b+0.5);return this.normalize({r:r,g:g,b:b});},hsbToHex:function(hsb){return this.rgbToHex(this.hsbToRgb(hsb));},rgbToHsb:function(rgb){var r=Math.floor(this.toNumber(rgb.r)+0.5);var g=Math.floor(this.toNumber(rgb.g)+0.5);var b=Math.floor(this.toNumber(rgb.b)+0.5);if(r<0)r=0;if(r>255)r=255;if(g<0)g=0;if(g>255)g=255;if(b<0)b=0;if(b>255)b=255;var max,delta,diff,offset;var h=r,s=g,v=b;if(r>g){if(r>b)v=max=r,offset=0,diff=g-b;else v=max=b,offset=240,diff=r-g;delta=max-((g<b)?g:b);}
else{if(g>b)v=max=g,offset=120,diff=b-r;else v=max=b,offset=240,diff=r-g;delta=max-((r<b)?r:b);}
if(max!=0)s=Math.floor((delta*100)/max+0.5);else s=0;if(s!=0){h=(offset+Math.floor(diff*120/(delta*2)+0.5))%360;if(h<0)h+=360;}
else h=0;v=Math.floor(v*100/255+0.5);return this.normalize({h:h,s:s,b:v});},rgbToHex:function(rgb){rgb=this.normalize(rgb);return"#"+rgb.r.toColorPart()+rgb.g.toColorPart()+rgb.b.toColorPart();},hexToRgb:function(hex){var m;if(m=/^[^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(hex))
return{r:parseInt(m[1],16),g:parseInt(m[2],16),b:parseInt(m[3],16)};if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(hex)){var b=parseInt(m[3],16);return{r:parseInt(m[1],16),g:parseInt(m[2],16),b:b*16+b};}
if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(hex)){var g=parseInt(m[2],16);return{r:parseInt(m[1],16),g:g,b:g};}
if(m=/^[^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(hex)){var r=parseInt(m[1],16);var g=parseInt(m[2],16);var b=parseInt(m[3],16);return{r:r*16+r,g:g*16+g,b:b*16+b};}
if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f]{2})(?:[^0-9A-Fa-f]|$)/.exec(hex)){var g=parseInt(m[1],16);return{r:g,g:g,b:g};}
if(m=/^[^0-9A-Fa-f]*([0-9A-Fa-f])(?:[^0-9A-Fa-f]|$)/.exec(hex)){var g=parseInt(m[1],16);g=g*16+g;return{r:g,g:g,b:g};}
return false;},hexToHsb:function(hex){return this.rgbToHsb(this.hexToRgb(hex));},toNumber:function(data){switch(typeof data){case"number":return data;break;case"string":if(m=/^[^0-9.+-]*([+-]?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?))(?:[^0-9]|$)/.exec(data))
return Number(m[1]);else return 0;break;case"boolean":return data?1:0;break;case"object":return data?1:0;break;case"function":return 1;break;default:case"undefined":return 0;break;}},normalize:function(color){switch(this.identify(color)){case"rgb":var rgb=color;rgb.r=this.toNumber(rgb.r);rgb.g=this.toNumber(rgb.g);rgb.b=this.toNumber(rgb.b);if(rgb.r<0)rgb.r=0;if(rgb.r>255)rgb.r=255;if(rgb.g<0)rgb.g=0;if(rgb.g>255)rgb.g=255;if(rgb.b<0)rgb.b=0;if(rgb.b>255)rgb.b=255;return rgb;break;case"hsb":var hsb=color;hsb.h=this.toNumber(hsb.h);hsb.s=this.toNumber(hsb.s);hsb.b=this.toNumber(hsb.b);if(hsb.h<0)hsb.h+=360;if(hsb.h>360)hsb.h-=360;if(hsb.s<0)hsb.s=0;if(hsb.s>100)hsb.s=100;if(hsb.b<0)hsb.b=0;if(hsb.b>100)hsb.b=100;return hsb;break;default:return color;break;}},identify:function(data){switch(typeof data){case"string":if(m=data.match(/^#([A-Fa-f0-9]{2,8})$/))
return"hex";break;case"object":if((data.r===0||data.r)&&(data.g===0||data.g)&&(data.b===0||data.b))
return"rgb";if((data.h===0||data.h)&&(data.s===0||data.s)&&(data.b===0||data.b))
return"hsb";break;}}});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.slider.js");Q.Slider=Class.create(Q.Base,{initialize:function($super,input,options){$super(input);if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({delimiter:'',separator:'',prefix:'',suffix:'',holderStyle:{position:"absolute"},trackStyle:{backgroundImage:"url("+Q.imagePath_h+")",backgroundRepeat:"repeat-x",backgroundPosition:"0 -197px",width:"200px",height:"3px",position:"absolute",left:"15px",top:"22px"},trackStyleVertical:{backgroundImage:"url("+Q.imagePath_v+")",backgroundRepeat:"repeat-y",backgroundPosition:"-197px 0",width:"3px",height:"200px",position:"absolute",left:"21px",top:"15px"},handleStyle:{backgroundImage:"url("+Q.imagePath_h+")",backgroundRepeat:"no-repeat",backgroundPosition:"0px -168px",width:"24px",height:"24px",position:"relative",marginTop:"-11px",marginLeft:"0px",cursor:"pointer"},handleStyleVertical:{marginTop:"0px",marginLeft:"-11px"}}).merge(options).toObject();if(this.options.format){this.options.format=this.options.format.match(/^(.*?)([\d]+)(.([\d]+))?(.*?)$/);}
Q.register('slider');if(!this.input)
alert("Q.Slider Error: No input was defined to attach the Slider to!");else
this.build();},build:function(){var holder=this.createHolder("plain"),track=new Element("div"),handle=new Element("div"),size=parseInt(this.options.size)||200,options;this.options.trackStyle.width=size+"px";this.options.trackStyleVertical.width=size+"px";holder.addClassName("slider").setStyle(this.options.holderStyle).insert(track);track.addClassName("q-track").insert(handle).setStyle(this.options.trackStyle);handle.addClassName("q-handle").setStyle(this.options.handleStyle);if(this.options.axis=="vertical"){holder.setStyle(this.options.holderStyleVertical).down("div.q-center").setStyle({width:"20px",height:(size+8)+"px"});track.setStyle(this.options.trackStyleVertical);handle.setStyle(this.options.handleStyleVertical);}else{holder.down("div.q-center").setStyle({width:(size+8)+"px",height:"20px"});}
this.input.observe("blur",(function(){this.input.value=this.format(this.options.value);}).bind(this));this.input.observe("keyup",(function(event){if(event.keyCode==13)
this.hide();this.options.value=this.input.value;}).bind(this));options=$H(this.options).merge({onChange:this.onChange.bind(this),onSlide:this.onSlide.bind(this)}).toObject();this.control=new Control.Slider(handle,track,options);this.setValue(this.options.value||this.input.value||0);},onChange:function(value){if(value==0||value){this.input.setValue(this.format(value));this.options.value=value;this.positionHolder();Q.callback('onChange',this,value);}},onSlide:function(value){if(value==0||value){this.input.setValue(this.format(value));this.options.value=value;Q.callback('onSlide',this,value);}},setValue:function(value){if(value==0||parseFloat(value)){this.control.setValue(parseFloat(value));this.input.setValue(this.format(value));this.options.value=value;}},format:function(value){if(m=this.options.format){if(!m[4])
value=parseInt(value);else
value=parseFloat(value).toFixed(m[4].length);return(m[1]||"")+value+(m[5]||"");}else{return value;}}});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.tagger.js");Q.Tagger=Class.create(Q.Base,{initialize:function($super,input,options){$super(input);if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({holderStyle:{position:'absolute'}}).merge(options).toObject();Q.addCssFor('tagger');Q.register('tagger');if(!this.input)
alert("Q.Tagger Error: No input was defined to attach the Tagger to!");else if(!this.options.tagList&&!this.options.hiddenTagList)
alert("Q.Tagger Error: No tagList was provided of hiddenTagList defined!");else
this.build();},build:function(){var holder=this.createHolder(this.options.style||'plain'),width=parseInt(this.options.size)||300,input=this.input,self=this,tags,list,item,usedTags;holder.addClassName("q-tagger").setStyle(this.options.holderStyle);list=new Element('ul').addClassName('q-taglist').setStyle({width:width+'px'});tags=this.parseTagList();usedTags=this.strip(this.input.value.split(','));tags.each(function(tag){item=new Element('li').addClassName('q-tag').update(tag);if(usedTags.include(tag))
item.addClassName('q-used');item.observe('click',function(){var used;if(this.hasClassName('q-used')){this.removeClassName('q-used');self.onChange(tag,false);}else{this.addClassName('q-used');self.onChange(tag,true);}
used=list.select('li.q-used').collect(function(used){return used.innerHTML.strip().HTMLdecode();});input.value=used.join(', ');});list.insert(item);});item=new Element('li').addClassName('q-clearer').update(' ');this.input.observe('keyup',function(){usedTags=self.strip(this.value.split(','));list.select('li').each(function(li){if(usedTags.include(li.innerHTML.strip().HTMLdecode()))
li.addClassName('q-used');else
li.removeClassName('q-used');});});list.insert(item);holder.down("div.q-center").insert(list);},onChange:function(value,state){Q.callback('onChange',this,value,state);},parseTagList:function(){var tags;if(this.options.tagList)
if(typeof this.options.tagList=='string')
if(this.options.tagList.isJSON())
tags=this.options.tagList.parseJSON();else
tags=this.options.tagList.split(',');else
tags=this.options.tagList;else
tags=$(this.options.hiddenTagList).value.split(',');return this.strip(tags);},strip:function(list){return list.collect(function(item){return item.strip();});}});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.textarea.js");Q.Textarea=Class.create({availableButtons:$w('Heading Bold Italic Underline StrikeThrough CreateLink InsertImage JustifyLeft JustifyCenter JustifyRight JustifyFull Indent Outdent ForeColor InsertUnorderedList InsertOrderedList RemoveFormat EditCode'),initialize:function(textarea,options){if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({className:'q-textarea',forecolor:'palette',backcolor:'palette'}).merge(options).toObject();Q.addCssFor('textarea');Q.register('textarea');this.build(textarea);},build:function(textarea){var blankBody,styleSheet,diffDim,headingSelect,oldarea=$(textarea),width=this.options.width||oldarea.getWidth(),height=this.options.height||oldarea.getHeight(),buttons=this.options.buttons||this.availableButtons;diffDim=oldarea.setStyle({width:width+'px',height:height+'px'}).getDimensions();diffDim.width-=width;diffDim.height-=height;this.toolbarButtons={};this.active=true;this.oldCaret=false;this.codearea=oldarea.cloneNode(true);this.holder=new Element('div');this.toolbar=new Element('ul');this.editor=new Element('iframe');oldarea.replace(this.holder);this.holder.addClassName('q-textarea-wrapper').setStyle({width:width+'px'}).hide();if(oldarea.className)
this.holder.addClassName(oldarea.className);this.holder.id=oldarea.id;oldarea.id='';this.codearea.id='';this.holder.insert(this.editor);this.codearea.hide().setStyle({width:(width-diffDim.width)+'px',height:(height-diffDim.height)+'px'});this.editor.insert({before:this.toolbar}).setStyle({width:(width-2)+'px',height:(height-2)+'px'});this.toolbar.insert({after:this.codearea}).addClassName('q-textarea-toolbar').setStyle({width:width+'px'});if(this.options.icons)
this.toolbar.addClassName(this.options.icons);buttons.uniq().each((function(action){var li,option,input,pick,change;if(this.availableButtons.indexOf(action)>-1){li=new Element('li',{unselectable:'on',title:Q.I18n.t('textarea.tooltips.'+action.underscore(),{fallback:action.humanize()})}).addClassName('button').addClassName('q-tip').addClassName(action.underscore().dasherize());switch(action){default:li.insert(' ')
break;case'Heading':headingSelect=new Element('ul').addClassName('heading-options').hide();option=new Element('li',{unselectable:'on',title:'Default'}).addClassName('q-tip button option div');headingSelect.insert(option);option.onclick=(function(){this.perform(action,'div');headingSelect.hide();}).bind(this);$R(1,6).each((function(i){option=new Element('li',{unselectable:'on',title:'Heading '+i}).addClassName('q-tip button option h'+i);headingSelect.insert(option);option.onmousedown=(function(){this.perform(action,'h'+i);headingSelect.hide();}).bind(this);}).bind(this));break;case'ForeColor':input=new Element('input').addClassName('q-editor-color-field');pick=(function(value){this.perform(action,value);}).bind(this);if(this.options[action.toLowerCase()]=='picker'){new Q.Picker(input,{size:150,onShow:function(){li.addClassName('active')},onPick:pick,onChange:(function(value,instance){if(this.oldCaret)
this.oldCaret.range.select();pick(value);}).bind(this),onHide:function(){li.removeClassName('active')}});}else if(this.options[action.toLowerCase()]=='palette'){new Q.Palette(input,{swatchSize:13,swatchSpace:1,colors:this.options[action.toLowerCase()+'s'],onShow:function(){li.addClassName('active')},onChange:(function(value,instance){if(this.oldCaret)
this.oldCaret.range.select();pick(value);instance.close();}).bind(this),onHide:function(){li.removeClassName('active')}});}
li.insert(input);if(Q.IE)
li.onmouseover=(function(){this.oldCaret=this.getCaret();}).bind(this);break;}
this.toolbar.insert(li);this.toolbarButtons[action.underscore()]=li;li.onclick=(function(){switch(action){default:this.perform(action);break;case'EditCode':this.toggleToolbarState();break;case'Heading':if(this.active){var observeBlur,offset;observeBlur=function(){headingSelect.hide();document.stopObserving('mouseup',observeBlur);}
document.observe('mouseup',observeBlur);offset=li.positionedOffset();Q.addCss('ul.q-textarea-toolbar li.q-heading-select','left:'+offset.left+'px; top:'+offset.top+'px;');headingSelect.show();}
break;case'ForeColor':break;}}).bind(this);}}).bind(this));this.toolbar.insert(new Element('li').addClassName('q-clearer').update(' '));if(headingSelect)
this.toolbar.insert(new Element('li').addClassName('q-heading-select').update(headingSelect));this.doc=this.editor.contentWindow.document;blankBody='<html><head>';if(!this.options.styleSheet&&Q.IE){blankBody+='<link href="'+this.options.styleSheet+'" rel="stylesheet" type="text/css"></link>';}
blankBody+='<title>Q.Textarea Editor</title></head><body id="q_editor">';blankBody+=this.codearea.value;blankBody+='</body></html>';this.doc.open();this.doc.write(blankBody);this.doc.close();this.editorInitializationCount=0;this.initializeEditor();if(this.options.styleSheet&&!Q.IE){styleSheet=this.doc.createElement('link');styleSheet.setAttribute('rel','stylesheet');styleSheet.setAttribute('type','text/css');styleSheet.setAttribute('href',this.options.styleSheet);this.doc.getElementsByTagName('head')[0].appendChild(styleSheet);}},initializeEditor:function(){try{this.doc.designMode="on";this.addEditorFunctions();this.addCss('p, div','margin:0;padding:0;');if(this.options.css)
this.addCss(this.options.css);this.holder.appear({duration:0.2});Q.callback('onLoad',this);}catch(e){if(this.editorInitializationCount<10){(function(){this.initializeEditor();}).bind(this).delay(0.1);this.editorInitializationCount+=1;}else{}
return false;}},addEditorFunctions:function(){Q.addDynamicStylesheetMethodsTo(this.doc);this.editor.contentWindow.css=this.doc.createStyleSheet();if(typeof this.doc.addEventListener=='function'){this.doc.addEventListener('mouseup',(function(){this.setButtonState();return true;}).bind(this),false);this.doc.addEventListener('keyup',(function(){this.setButtonState();this.sync();return true;}).bind(this),false);}else{this.doc.attachEvent('onmouseup',(function(){this.setButtonState();return true;}).bind(this));this.doc.attachEvent('onkeyup',(function(){this.setButtonState();this.sync();return true;}).bind(this));}
this.codearea.observe('keyup',(function(){this.sync();}).bind(this));},addCss:function(targets,cssText){if(typeof targets=='string'){targets.split(',').collect(function(part){return part.strip();}).each((function(selector){this.editor.contentWindow.css.addRule(selector,cssText);}).bind(this));}else if(typeof targets=='object'){$H(targets).each((function(pair){if(typeof pair.value=='object'){cssText='';$H(pair.value).each(function(p){cssText+=p.key.underscore().dasherize()+':'+p.value+';';});}else{cssText=pair.value;}
this.editor.contentWindow.css.addRule(pair.key,cssText);}).bind(this));}},perform:function(action,value){if(!this.active)return false;var button=this.toolbar.down('li.'+action.underscore().dasherize());switch(action){default:this.doc.execCommand(action,false,null);if(button.hasClassName('active'))
button.removeClassName('active');else
button.addClassName('active');break;case'RemoveFormat':var html,caret=this.getCaret(),node=caret.node;this.doc.execCommand(action,false,null);if(caret.selection!=''){if(node.nodeName=='#text')
node=node.parentNode;if(node.nodeName.match(/h[\d]/i))
this.doc.execCommand('FormatBlock',false,'<div>');node.innerHTML=node.innerHTML.stripScripts().stripTags();$w('style align STYLE ALIGN').each(function(attribute){node.setAttribute(attribute,'');node.removeAttribute(attribute);});}
this.toolbar.select('li').each(function(button){button.removeClassName('active');if(button.hasClassName('heading')){$R(1,6).each(function(i){button.removeClassName('h'+i);});}});break;case'Heading':$R(1,6).each((function(i){this.toolbarButtons.heading.removeClassName('h'+i);}).bind(this));this.toolbarButtons.heading.addClassName(value);this.doc.execCommand('FormatBlock',false,'<'+value+'>');break;case'Indent':case'Outdent':this.doc.execCommand(action,false,null);break;case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':this.doc.execCommand(action,false,null);$w('left center right full').each((function(type){this.toolbarButtons['justify_'+type].removeClassName('active');}).bind(this));button.addClassName('active');break;case'ForeColor':var caret=this.getCaret(),node=caret.node;if(caret.selection!=''){this.editor.focus();if(node.nodeName=='SPAN')
node.setAttribute('style','color:'+value+';')
else
this.insertHTML('<span style="color:'+value+';">'+caret.text+'</span>');}
break;case'CreateLink':var win,text,message,promptUrl,alertInvalidUrl;if(Q.IE)
this.oldCaret=this.getCaret();promptUrl=(function(){message='<input type="checkbox" name="q_new_window_check" class="target-check" /> open link in a new window?';win=new Q.Prompt('Link',message,{text:'http://',onConfirm:(function(link){if(link.blank()||link=='http://'){alertInvalidUrl();}else{var anchor,caret=this.oldCaret||this.getCaret();if(caret.selection!=''){anchor='<a href="'+link+'"';if(win.holder.down('input.target-check').checked)
anchor+=' target="_blank"';anchor+='>';anchor+=caret.text;anchor+='</a>';this.insertHTML(anchor);}
this.sync();}}).bind(this)});}).bind(this);alertInvalidUrl=(function(){new Q.Alert('',Q.I18n.t('textarea.create_link.invalid_link',{fallback:'The link you entered is invalid, please try again.'}),{onConfirm:(function(){promptUrl();}).bind(this)});}).bind(this);if(this.toolbarButtons.create_link.hasClassName('active')){this.doc.execCommand('Unlink',false,null);this.toolbarButtons.create_link.removeClassName('active');}else{if(this.doc.selection)
text=this.doc.selection.createRange().text;else
text=this.editor.contentWindow.getSelection();if(text==''){new Q.Alert('',Q.I18n.t('textarea.create_link.select_text',{fallback:'Please first select a part of the text you want to be linked.'}));break;}
promptUrl();}
break;case'InsertImage':var promptUrl,alertUrl,promptAlt,imageUrl,imageAlt,insertImage;if(Q.IE)
this.oldCaret=this.getCaret();promptUrl=(function(){new Q.Prompt(Q.I18n.t('textarea.insert_image.image',{fallback:'Image'}),Q.I18n.t('textarea.insert_image.enter_url',{fallback:'Enter the url of the image you want to insert:'}),{text:'http://',onConfirm:(function(value){var match;if(match=value.match(/^https?:\/\/[a-z0-9\-]+\.[a-z0-9\-]+(.*?)\/(.*)\.[a-z]{2,4}(\?.*)?$/i)){imageUrl=value;imageAlt=match[2].split('/').last().gsub(/(\-|\.|\+|_)/,' ');promptAlt();}else{alertUrl();}}).bind(this)});}).bind(this);alertUrl=function(){new Q.Alert(Q.I18n.t('textarea.insert_image.image',{fallback:'Oops!'}),Q.I18n.t('textarea.insert_image.invalid_url',{fallback:'The image address you entered is not correct, try again.'}),{onConfirm:promptUrl});}
promptAlt=(function(){new Q.Prompt(Q.I18n.t('textarea.insert_image.description',{fallback:'Description'}),Q.I18n.t('textarea.insert_image.image_alt',{fallback:'Excellent! Now enter a description:'}),{text:imageAlt,onConfirm:(function(value){imageAlt=value.HTMLencode();insertImage();}).bind(this)});}).bind(this);insertImage=(function(){this.insertHTML('<img alt="'+imageAlt+'" src="'+imageUrl+'" />');this.sync();}).bind(this);promptUrl();break;}
this.sync();},insertHTML:function(html){if(Q.IE){var range=this.oldCaret.range;range.pasteHTML(html);range.collapse(false);range.select();}else{this.doc.execCommand('insertHTML',false,html);}},setButtonState:function(){(function(){var selection,range,parentNode,level=0;this.toolbar.select('li').each(function(button){button.removeClassName('active');});if(this.toolbarButtons.heading)
$R(1,6).each((function(i){this.toolbarButtons.heading.removeClassName('h'+i);}).bind(this));if(this.doc.selection){selection=this.doc.selection;range=selection.createRange();try{parentNode=range.parentElement();}catch(e){return false;}}else{try{selection=this.editor.contentWindow.getSelection();}catch(e){return false;}
range=selection.getRangeAt(0);parentNode=range.commonAncestorContainer;}
while(parentNode.nodeType==3){parentNode=parentNode.parentNode;}
while(parentNode.nodeName!='BODY'){switch(parentNode.nodeName.toLowerCase()){case'a':this.toolbarButtons.create_link.addClassName('active');break;case'b':case'strong':this.toolbarButtons.bold.addClassName('active');break;case'i':case'em':this.toolbarButtons.italic.addClassName('active');break;case'u':this.toolbarButtons.underline.addClassName('active');break;case's':case'strike':this.toolbarButtons.strike_through.addClassName('active');break;case'ol':this.toolbarButtons.insert_ordered_list.addClassName('active');this.toolbarButtons.insert_unordered_list.removeClassName('active');break;case'ul':this.toolbarButtons.insert_unordered_list.addClassName('active');this.toolbarButtons.insert_ordered_list.removeClassName('active');break;case'li':break;case'h1':case'h2':case'h3':case'h4':case'h5':case'h6':if(this.toolbarButtons.heading)
this.toolbarButtons.heading.addClassName(parentNode.nodeName.toLowerCase());break;case'div':if(parentNode.getAttribute('style')){var style,match;style=parentNode.getAttribute('style').toString();match=style.match(/text\-align: ?(left|center|right|justify);/i);if(match){switch(match[1]){default:this.toolbarButtons['justify_'+match[1]].addClassName('active');break;case'justify':this.toolbarButtons.justify_full.addClassName('active');break;}}}
break;}
parentNode=parentNode.parentNode;level++;}
return true;}).bind(this).delay(0.1);},toggleToolbarState:function(){if(this.active){this.toolbar.select('li').each(function(button){if(button.hasClassName('q-heading-select')){button.down('ul').hide();}else if(button.hasClassName('edit-code')){button.addClassName('active');}else{button.removeClassName('active').addClassName('inactive');if(button.hasClassName('fore-color'))
button.down('input').hide();}});this.codearea.show();this.editor.hide();this.active=false;}else{this.toolbar.select('li').each(function(button){button.removeClassName('active').removeClassName('inactive');if(button.hasClassName('fore-color'))
button.down('input').show();});this.codearea.hide();this.editor.show();this.active=true;}},sync:function(thorough){var body=this.doc.getElementById('q_editor');if(this.active)
this.codearea.setValue(this.polishCode(body.innerHTML));else
body.innerHTML=this.polishCode(this.codearea.value);Q.callback('onType',this);if(this.active&&thorough)
this.doc.getElementById('q_editor').innerHTML=this.codearea.value;},polishCode:function(code){return code.gsub(/<embed width="0" height="0" type="application\/x-safari-validator">/i,'').gsub(/<div>(<br>| )<\/div>/i,'<br/>').gsub(/<br ?>/i,'<br/>').gsub(/<p(.*)?>/i,function(match){return'<div'+match[1]+'>';}).gsub(/<\/p>/i,'</div>');},getValue:function(){this.sync(true);return this.doc.getElementById('q_editor').innerHTML;},setValue:function(value){this.doc.getElementById('q_editor').innerHTML=value;this.codearea.setValue(value);},getCaret:function(){var caret={node:null};if(this.doc.selection){caret.selection=this.doc.selection;if(caret.selection=='')return caret;caret.range=caret.selection.createRange();caret.node=caret.range.parentElement();caret.text=caret.range.text;}else{caret.selection=this.editor.contentWindow.getSelection();if(caret.selection=='')return caret;caret.range=caret.selection.getRangeAt(0);caret.node=caret.range.commonAncestorContainer;caret.text=caret.selection;}
return caret;}});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.tooltip.js");Q.Tooltip=Class.create(Q.Base,{initialize:function($super,options){var unique_id="q_tooltip_"+Math.random().toMD5(),key;$super();if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({klass:".q-tip",style:"dark",left:20,top:20,width:200,delay:0.5}).merge(options).toObject();Q.addCssFor("tooltip");this.active=false;this.titles={};this.holder_width=this.options.width+26;this.available_width=this.div.getWidth();document.observe("resize:end",(function(){this.available_width=this.div.getWidth();}).bind(this));Q.register('tooltip');this.build();$$(this.options.klass).each((function(element,i){var title=element.title||"";if(element.id.blank()){key=unique_id+"_"+i;element.id=key;}else{key=element.id;}
title.scan(/!(([^ ]+)\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF))!/,function(m){title=title.replace(m[0],'<img src="'+m[1]+'" alt="'+m[2]+'" />');});title=title.gsub(/(\n|\r)/,'<br/>');this.titles[key]=title;element.removeAttribute("title");element.observe("mouseover",(function(event){this.show(element,event);}).bind(this));element.observe("mouseout",(function(){this.hide();}).bind(this));}).bind(this));},build:function(){var holder=this.holder=new Element("div"),background=this.buildBackground(this.options.style);background.insert(new Element("div").addClassName("q-tooltip-center").setStyle({maxWidth:this.options.width+"px"}));holder.addClassName("q-tooltip q-"+this.options.style).insert(background).hide();this.div.insert(holder);},show:function(element,event){var position=event.pointer(),new_pos;new_pos={left:position.x+this.options.left,top:position.y+this.options.top}
if(this.available_width<new_pos.left+this.holder_width)
new_pos.left=this.available_width-this.holder_width;if(!this.holder.visible()&&!this.titles[element.id].blank())
this.holder.setStyle({left:new_pos.left+"px",top:new_pos.top+"px"}).appear({duration:0.2,delay:this.options.delay,queue:{position:"end",limit:2,scope:"q_tooltip"}}).down(".q-tooltip-center").update(this.titles[element.id]);},hide:function(){var queue=Effect.Queues.get("q_tooltip");queue.each(function(effect){effect.cancel();});this.holder.hide();}});if(typeof Q=='undefined')
alert("Q is not loaded. Please make sure that your page includes q.js before it includes q.window.js");Q.Window=Class.create(Q.Base,{initialize:function($super,options){$super();this.persistent=false;if(typeof options=="string"&&options.isJSON())
options=options.evalJSON();this.options=$H(this.options).merge({style:'dark',position:'fixed',draggable:true,closeButton:'right',left:50,top:50,minWidth:300,minHeight:50,maxWidth:3000,maxHeight:3000,hide:false}).merge(options).toObject();if(this.options.position=="static"||this.options.position=="inherit")
this.options.position="relative";Q.addCssFor('window');Q.register('window');this.build();},build:function(){var win,close,resize,title,label,background,source;win=this.holder=new Element("div");if(this.options.id)
win.id=this.options.id;if(this.options.div)
this.div=$(this.options.div);win.addClassName("q-window q-"+this.options.style).setStyle({position:this.options.position,left:parseInt(this.options.left)+"px",top:parseInt(this.options.top)+"px"}).hide();if(this.options.closeButton){close=new Element("div").addClassName("q-window-close");if(this.options.closeButton=='left')
close.addClassName("q-left");close.onclick=(function(){this.hide(true);}).bind(this);win.insert(close);}
background=this.buildBackground(this.options.style);win.insert(background);win.content=new Element("div");background.center.insert(win.content)
win.center=background.center;if(this.options.resizable){resize=new Element("div").addClassName("q-window-resize");win.insert(resize);resize.observe("mousedown",(function(event){event.preventDefault?event.preventDefault():event.returnValue=false;resize.resizing=true;var size={width:win.down(".q-content").getWidth(),height:win.down(".q-content").getHeight()}
Q.callback('onStartResize',this,size);Q.callback('onResize',this,size);}).bind(this));document.observe("mousemove",(function(event){if(resize.resizing){event.preventDefault?event.preventDefault():event.returnValue=false;var width=event.pointerX()-parseInt(win.getStyle("left"))-8,height=event.pointerY()-parseInt(win.getStyle("top"))-8,offset;if(this.options.position=="fixed"){offset=document.viewport.getScrollOffsets();width-=offset.left;height-=offset.top;}
if(this.validWidth(width))
win.down(".q-content").setStyle({width:width+"px"});if(this.validHeight(height))
win.down(".q-content").setStyle({height:height+"px"});Q.callback('onResize',this,{width:win.down(".q-content").getWidth(),height:win.down(".q-content").getHeight()});}}).bind(this));document.observe("mouseup",(function(){if(resize.resizing){resize.resizing=false;Q.callback('onEndResize',this,{width:win.down(".q-content").getWidth(),height:win.down(".q-content").getHeight()});}}).bind(this));}
title=new Element("div").addClassName("q-window-title");win.insert(title);if(this.options.draggable)
new Draggable(win,{handle:title,zindex:100000,onStart:(function(){Q.callback('onStartDrag',this);}).bind(this),onDrag:(function(){Q.callback('onDrag',this);}).bind(this),onEnd:(function(){Q.callback('onEndDrag',this);}).bind(this)});title.style.cursor="move";if(this.options.title){label=new Element("p").addClassName("q-window-label").update(this.options.title);title.insert(label);}
this.holder.observe("mouseup",(function(){this.restack();Q.callback('onFocus',this);}).bind(this));if(trigger=$(this.options.trigger)){trigger.observe("click",(function(){if(!this.visible())
this.onShow();}).bind(this));}else if(!this.options.hide){this.onShow();}
this.div.insert(win);this.initSize(win);if(this.options.source&&(source=$(this.options.source))){this.update(source.innerHTML);source.remove();}else{this.update(this.options.text);}},initSize:function(win){var width=300,height;if(this.options.width)
width=this.options.width;if(this.options.height)
height=this.options.height;if(parseInt(width))
width+="px";else
width="auto";if(parseInt(height))
height+="px";else
height="auto";win.center.setStyle({width:width,height:height,minWidth:this.options.minWidth+"px",minHeight:this.options.minHeight+"px",maxWidth:this.options.maxWidth+"px",maxHeight:this.options.maxHeight+"px"});},update:function(content){this.holder.content.update(new Element("div").setStyle({height:"10px"})).insert(content);return this;},insert:function(content,options){this.holder.content.insert(content,options);return this;},visible:function(){return this.holder.visible();},validWidth:function(value){if(this.options.minWidth&&value<this.options.minWidth)
return false;if(this.options.maxWidth&&value>this.options.maxWidth)
return false;return true;},validHeight:function(value){if(this.options.minHeight&&value<this.options.minHeight)
return false;if(this.options.maxHeight&&value>this.options.maxHeight)
return false;return true;},restack:function(){$("q_wrapper").select("div.q-window").each(function(win){win.style.zIndex=win.hasClassName("q-window-blocking")?99997:99995;});this.holder.style.zIndex=this.holder.hasClassName("q-window-blocking")?99998:99996;},onShow:function(){this.restack();this.show();}});Q.Alert=Class.create(Q.Window,{initialize:function($super,title,message,options){var dim=document.viewport.getDimensions()
options=$H({width:300,minHeight:30,draggable:false,closeButton:false,left:dim.width/2-(options&&options.width?options.width/2:150),top:dim.height/3-75,title:title,confirmLabel:"Ok!"}).merge(options||{}).toObject();$super(options);if(trigger=$(options.trigger)){trigger.observe("click",(function(){this.alert(title,message,options);}).bind(this));}else{this.alert(title,message,options);}},alert:function(title,message,options){var dim=document.viewport.getDimensions(),next,win,msg,wrapper,onConfirm;onConfirm=(function(){document.stopObserving("keydown",this.confirmWithEnter);document.stopObserving("keydown",this.cancelWithEscape);document.stopObserving("keydown",this.onWindowResize);this.hide();if(typeof this.textarea!='undefined')
Q.callback('onConfirm',this,this.textarea.value);else
Q.callback('onConfirm',this);this.remove();}).bind(this);this.confirmWithEnter=(function(event){if(event.keyCode==13){next.focus();onConfirm();}}).bind(this);document.observe("keydown",this.confirmWithEnter);this.onWindowResize=(function(){var dim=document.viewport.getDimensions();this.holder.setStyle({left:(dim.width/2-(options&&options.width?options.width/2:150))+'px',top:(dim.height/3-75)+'px'});}).bind(this);(document.onresize?document:window).observe("resize",this.onWindowResize);this.holder.addClassName("q-window-blocking").setStyle({zIndex:99998});this.protection=new Element("div").addClassName("q-protective-layer");this.div.insert({top:this.protection});this.protection.hide();next=new Element("input",{type:"button",value:options.confirmLabel}).addClassName("q-button q-next-button");next.onclick=(function(){onConfirm();}).bind(this);wrapper=new Element("div").addClassName("q-buttons-wrapper");msg=new Element("div").setStyle({margin:"10px 10px 20px 10px"}).update(message);wrapper.insert(next);this.update(msg).insert(wrapper);this.persistent=true;this.show();this.protection.appear({duration:0.1,to:0.5});},remove:function(){this.protection.fade({duration:0.01});(function(){try{this.protection.remove();delete this;}catch(e){}}).bind(this).delay(0.2);}})
Q.Confirm=Class.create(Q.Alert,{initialize:function($super,title,message,options){options=$H({cancelLabel:"Cancel"}).merge(options||{}).toObject();$super(title,message,options);if(trigger=$(options.trigger)){trigger.observe("click",(function(){this.confirm(options);}).bind(this));}else{this.confirm(options);}},confirm:function(options){var cancel,clearer,onCancel;onCancel=(function(){document.stopObserving("keydown",this.confirmWithEnter);document.stopObserving("keydown",this.cancelWithEscape);document.stopObserving("keydown",this.onWindowResize);this.hide();Q.callback('onCancel',this);this.remove();}).bind(this);this.cancelWithEscape=(function(event){if(event.keyCode==27)
onCancel();}).bind(this);document.observe("keydown",this.cancelWithEscape);cancel=new Element("input",{type:"button",value:options.cancelLabel}).addClassName("q-button q-cancel-button");cancel.onclick=(function(){onCancel();}).bind(this);this.holder.down("div.q-buttons-wrapper").insert({top:cancel});}});Q.Prompt=Class.create(Q.Confirm,{initialize:function($super,title,message,options){$super(title,message,options);if(trigger=$(options.trigger)){trigger.observe("click",(function(){this.prompt(options);}).bind(this));}else{this.prompt(options);}},prompt:function(options){this.textarea=new Element("textarea").addClassName("q-textarea").setValue(options.text)
this.holder.down("div.q-buttons-wrapper").insert({before:this.textarea});}});