]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/tiny_mce/classes/firebug/firebug-lite.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / tiny_mce / classes / firebug / firebug-lite.js
1 var firebug = {
2   version:[1.23,20090309],
3   el:{}, 
4   env:{ 
5     "cache":{},
6     "extConsole":null,
7     "css":"http://getfirebug.com/releases/lite/1.2/firebug-lite.css", 
8     "debug":true,
9     "detectFirebug":true,
10     "dIndex":"console", 
11     "height":295,
12     "hideDOMFunctions":false,
13     "init":false, 
14     "isPopup":false,
15     "liteFilename":"firebug-lite.js",
16     "minimized":false,
17     "openInPopup": false,
18     "override":true,
19     "ml":false,
20     "popupWin":null,
21     "showIconWhenHidden":true,
22     "targetWindow":undefined,
23     "popupTop":1,
24     "popupLeft":1,
25     "popupWidth":undefined,
26     "popupHeight":undefined
27   },
28   initConsole:function(){
29     /* 
30      * initialize the console - user defined values are not available within this method because FBLite is not yet initialized
31      */
32     var command;
33     try{
34       if((!window.console || (window.console && !window.console.firebug)) || (firebug.env.override && !(/Firefox\/3/i.test(navigator.userAgent)))){
35         window.console = { "provider":"Firebug Lite" };
36
37         for(command in firebug.d.console.cmd){
38           window.console[command] = firebug.lib.util.Curry(firebug.d.console.run,window,command);
39         };
40       }
41       /*window.onerror = function(_message,_file,_line){
42         firebug.d.console.run('error',firebug.lib.util.String.format('{0} ({1},{2})',_message,firebug.getFileName(_file),_line));
43       };*/
44       } catch(e){}
45   },
46   overrideConsole:function(){
47     with (firebug){
48       env.override=true;
49       try{
50         env.extConsole=window.console;
51       } catch(e){}
52       initConsole();
53     }
54   },
55   restoreConsole:function(){
56     with(firebug){
57       if(env.extConsole){
58         env.override=false;
59         try{
60           window.console=env.extConsole;
61         } catch(e){}
62         env.extConsole=null;
63       }
64     }
65   },
66   init:function(_css){
67     var iconTitle = "Click here or press F12, (CTRL|CMD)+SHIFT+L or SHIFT+ENTER to show Firebug Lite. CTRL|CMD click this icon to hide it.";
68   
69     with(firebug){
70       if(document.getElementsByTagName('html')[0].attributes.getNamedItem('debug')){
71         env.debug = document.getElementsByTagName('html')[0].attributes.getNamedItem('debug').nodeValue !== "false";
72       }
73             
74       if(env.isPopup) {
75         env.openInPopup = false;
76         env.targetWindow = window.opener;
77         env.popupWidth = window.opener.firebug.env.popupWidth || window.opener.firebug.lib.util.GetViewport().width;
78         env.popupHeight = window.opener.firebug.env.popupHeight || window.opener.firebug.lib.util.GetViewport().height;
79       } else {
80         env.targetWindow = window;
81         env.popupWidth = env.popupWidth || lib.util.GetViewport().width;
82         env.popupHeight = env.popupHeight || lib.util.GetViewport().height;
83       }
84
85       settings.readCookie();
86       
87       if(env.init || (env.detectFirebug && window.console && window.console.firebug)) {
88         return;
89       }
90
91       document.getElementsByTagName("head")[0].appendChild(
92         new lib.element("link").attribute.set("rel","stylesheet").attribute.set("type","text/css").attribute.set("href",env.css).element
93       );
94
95       if(env.override){
96         overrideConsole();
97       }
98       
99       /* 
100        * Firebug Icon
101        */
102       el.firebugIcon = new lib.element("div").attribute.set("id","firebugIconDiv").attribute.set("title",iconTitle).attribute.set("alt",iconTitle).event.addListener("mousedown",win.iconClicked).insert(document.body);
103       
104       /* 
105        * main interface
106        */
107       el.content = {};
108       el.mainiframe = new lib.element("IFRAME").attribute.set("id","FirebugIFrame").environment.addStyle({ "display":"none", "width":lib.util.GetViewport().width+"px" }).insert(document.body);
109       el.main = new lib.element("DIV").attribute.set("id","Firebug").environment.addStyle({ "display":"none", "width":lib.util.GetViewport().width+"px" }).insert(document.body);
110       if(!env.isPopup){
111         el.resizer = new lib.element("DIV").attribute.addClass("Resizer").event.addListener("mousedown",win.resizer.start).insert(el.main);
112       }
113       el.header = new lib.element("DIV").attribute.addClass("Header").insert(el.main);
114       el.left = {};
115       el.left.container = new lib.element("DIV").attribute.addClass("Left").insert(el.main);
116       el.right = {};
117       el.right.container = new lib.element("DIV").attribute.addClass("Right").insert(el.main);
118       el.main.child.add(new lib.element("DIV").attribute.addClass('Clear'));
119
120       /*
121        * buttons
122        */
123       el.button = {};
124       el.button.container = new lib.element("DIV").attribute.addClass("ButtonContainer").insert(el.header);
125       el.button.logo = new lib.element("A").attribute.set("title","Firebug Lite").attribute.set("target","_blank").attribute.set("href","http://getfirebug.com/lite.html").update(" ").attribute.addClass("Button Logo").insert(el.button.container);
126       el.button.inspect = new lib.element("A").attribute.addClass("Button").event.addListener("click",env.targetWindow.firebug.d.inspector.toggle).update("Inspect").insert(el.button.container);
127       el.button.dock = new lib.element("A").attribute.addClass("Button Dock").event.addListener("click", win.dock).insert(el.button.container);
128       el.button.newWindow = new lib.element("A").attribute.addClass("Button NewWindow").event.addListener("click", win.newWindow).insert(el.button.container);
129
130       if(!env.isPopup){
131         el.button.maximize = new lib.element("A").attribute.addClass("Button Maximize").event.addListener("click",win.maximize).insert(el.button.container);
132         el.button.minimize = new lib.element("A").attribute.addClass("Button Minimize").event.addListener("click",win.minimize).insert(el.button.container);
133         el.button.close = new lib.element("A").attribute.addClass("Button Close").event.addListener("click",win.hide).insert(el.button.container);
134       }
135
136       if(lib.env.ie||lib.env.webkit){
137         el.button.container.environment.addStyle({ "paddingTop":"12px" });
138       }
139
140       /*
141        * navigation
142        */
143       el.nav = {};
144       el.nav.container = new lib.element("DIV").attribute.addClass("Nav").insert(el.left.container);
145       el.nav.console = new lib.element("A").attribute.addClass("Tab Selected").event.addListener("click",lib.util.Curry(d.navigate,window,"console")).update("Console").insert(el.nav.container);
146       el.nav.html = new lib.element("A").attribute.addClass("Tab").update("HTML").event.addListener("click",lib.util.Curry(d.navigate,window,"html")).insert(el.nav.container);
147       el.nav.css = new lib.element("A").attribute.addClass("Tab").update("CSS").event.addListener("click",lib.util.Curry(d.navigate,window,"css")).insert(el.nav.container);
148       if(!env.isPopup){
149         el.nav.scripts = new lib.element("A").attribute.addClass("Tab").update("Script").event.addListener("click",lib.util.Curry(d.navigate,window,"scripts")).insert(el.nav.container);
150       }
151       el.nav.dom = new lib.element("A").attribute.addClass("Tab").update("DOM").event.addListener("click",lib.util.Curry(d.navigate,env.targetWindow,"dom")).insert(el.nav.container);
152       el.nav.xhr = new lib.element("A").attribute.addClass("Tab").update("XHR").event.addListener("click",lib.util.Curry(d.navigate,window,"xhr")).insert(el.nav.container);
153       el.nav.optionsdiv = new lib.element("DIV").attribute.addClass("Settings").insert(el.nav.container);
154       el.nav.options = new lib.element("A").attribute.addClass("Tab").update("Options ∨").event.addListener("click", settings.toggle).insert(el.nav.optionsdiv);
155       
156       /*
157        * inspector
158        */
159       el.borderInspector = new lib.element("DIV").attribute.set("id","FirebugBorderInspector").event.addListener("click",listen.inspector).insert(document.body);
160       el.bgInspector = new lib.element("DIV").attribute.set("id","FirebugBGInspector").insert(document.body);
161
162       /*
163        * console
164        */
165       el.left.console = {};
166       el.left.console.container = new lib.element("DIV").attribute.addClass("Console").insert(el.left.container);
167       el.left.console.mlButton = new lib.element("A").attribute.addClass("MLButton").event.addListener("click",d.console.toggleML).insert(el.left.console.container);
168       el.left.console.monitor = new lib.element("DIV").insert(
169           new lib.element("DIV").attribute.addClass("Monitor").insert(el.left.console.container)
170       );
171       el.left.console.container.child.add(
172           new lib.element("DIV").attribute.addClass("InputArrow").update(">>>")
173       );
174       el.left.console.input = new lib.element("INPUT").attribute.set("type","text").attribute.addClass("Input").event.addListener("keydown",listen.consoleTextbox).insert(
175           new lib.element("DIV").attribute.addClass("InputContainer").insert(el.left.console.container)
176       );
177
178       el.right.console = {};
179       el.right.console.container = new lib.element("DIV").attribute.addClass("Console Container").insert(el.right.container);
180       el.right.console.mlButton = new lib.element("A").attribute.addClass("MLButton CloseML").event.addListener("click",d.console.toggleML).insert(el.right.console.container);
181       el.right.console.input = new lib.element("TEXTAREA").attribute.addClass("Input").insert(el.right.console.container);
182       el.right.console.input.event.addListener("keydown",lib.util.Curry(tab,window,el.right.console.input.element));
183       el.right.console.run = new lib.element("A").attribute.addClass("Button").event.addListener("click",listen.runMultiline).update("Run").insert(el.right.console.container);
184       el.right.console.clear = new lib.element("A").attribute.addClass("Button").event.addListener("click",lib.util.Curry(d.clean,window,el.right.console.input)).update("Clear").insert(el.right.console.container);
185
186       el.button.console = {};
187       el.button.console.container = new lib.element("DIV").attribute.addClass("ButtonSet").insert(el.button.container);
188       el.button.console.clear = new lib.element("A").attribute.addClass("Button").event.addListener("click",d.console.clear).update("Clear").insert(el.button.console.container);
189
190       /*
191        * html
192        */
193
194       el.left.html = {};
195       el.left.html.container = new lib.element("DIV").attribute.addClass("HTML").insert(el.left.container);
196
197       el.right.html = {};
198       el.right.html.container = new lib.element("DIV").attribute.addClass("HTML Container").insert(el.right.container);
199
200       el.right.html.nav = {};
201       el.right.html.nav.container = new lib.element("DIV").attribute.addClass("Nav").insert(el.right.html.container);
202       el.right.html.nav.computedStyle = new lib.element("A").attribute.addClass("Tab Selected").event.addListener("click",lib.util.Curry(d.html.navigate,firebug,"computedStyle")).update("Computed Style").insert(el.right.html.nav.container);
203       el.right.html.nav.dom = new lib.element("A").attribute.addClass("Tab").event.addListener("click",lib.util.Curry(d.html.navigate,firebug,"dom")).update("DOM").insert(el.right.html.nav.container);
204
205       el.right.html.content = new lib.element("DIV").attribute.addClass("Content").insert(el.right.html.container);
206
207       el.button.html = {};
208       el.button.html.container = new lib.element("DIV").attribute.addClass("ButtonSet HTML").insert(el.button.container);
209
210       /*
211        * css
212        */
213
214       el.left.css = {};
215       el.left.css.container = new lib.element("DIV").attribute.addClass("CSS").insert(el.left.container);
216
217       el.right.css = {};
218       el.right.css.container = new lib.element("DIV").attribute.addClass("CSS Container").insert(el.right.container);
219
220       el.right.css.nav = {};
221       el.right.css.nav.container = new lib.element("DIV").attribute.addClass("Nav").insert(el.right.css.container);
222       el.right.css.nav.runCSS = new lib.element("A").attribute.addClass("Tab Selected").update("Run CSS").insert(el.right.css.nav.container);
223
224       el.right.css.mlButton = new lib.element("A").attribute.addClass("MLButton CloseML").event.addListener("click",d.console.toggleML).insert(el.right.css.container);
225       el.right.css.input = new lib.element("TEXTAREA").attribute.addClass("Input").insert(el.right.css.container);
226       el.right.css.input.event.addListener("keydown",lib.util.Curry(firebug.tab,window,el.right.css.input.element));
227       el.right.css.run = new lib.element("A").attribute.addClass("Button").event.addListener("click",listen.runCSS).update("Run").insert(el.right.css.container);
228       el.right.css.clear = new lib.element("A").attribute.addClass("Button").event.addListener("click",lib.util.Curry(d.clean,window,el.right.css.input)).update("Clear").insert(el.right.css.container);
229
230       el.button.css = {};
231       el.button.css.container = new lib.element("DIV").attribute.addClass("ButtonSet CSS").insert(el.button.container);
232       el.button.css.selectbox = new lib.element("SELECT").event.addListener("change",listen.cssSelectbox).insert(el.button.css.container);
233
234       /*
235        * scripts
236        */
237
238       el.left.scripts = {};
239       el.left.scripts.container = new lib.element("DIV").attribute.addClass("Scripts").insert(el.left.container);
240
241       el.right.scripts = {};
242       el.right.scripts.container = new lib.element("DIV").attribute.addClass("Scripts Container").insert(el.right.container);
243
244       el.button.scripts = {};
245       el.button.scripts.container = new lib.element("DIV").attribute.addClass("ButtonSet Scripts").insert(el.button.container);
246       el.button.scripts.selectbox = new lib.element("SELECT").event.addListener("change",listen.scriptsSelectbox).insert(el.button.scripts.container);
247       el.button.scripts.lineNumbers = new lib.element("A").attribute.addClass("Button").event.addListener("click",d.scripts.toggleLineNumbers).update("Show Line Numbers").insert(el.button.scripts.container);
248
249       /*
250        * dom
251        */
252
253       el.left.dom = {};
254       el.left.dom.container = new lib.element("DIV").attribute.addClass("DOM").insert(el.left.container);
255
256       el.right.dom = {};
257       el.right.dom.container = new lib.element("DIV").attribute.addClass("DOM Container").insert(el.right.container);
258
259       el.button.dom = {};
260       el.button.dom.container = new lib.element("DIV").attribute.addClass("ButtonSet DOM").insert(el.button.container);
261       el.button.dom.label = new lib.element("LABEL").update("Object Path:").insert(el.button.dom.container);
262       el.button.dom.textbox = new lib.element("INPUT").event.addListener("keydown",listen.domTextbox).update(env.isPopup?"window.opener":"window").insert(el.button.dom.container);
263
264       /*
265        * str
266        */
267       el.left.str = {};
268       el.left.str.container = new lib.element("DIV").attribute.addClass("STR").insert(el.left.container);
269
270       el.right.str = {};
271       el.right.str.container = new lib.element("DIV").attribute.addClass("STR").insert(el.left.container);
272
273       el.button.str = {};
274       el.button.str.container = new lib.element("DIV").attribute.addClass("ButtonSet XHR").insert(el.button.container);
275       el.button.str.watch = new lib.element("A").attribute.addClass("Button").event.addListener("click",lib.util.Curry(d.navigate,window,"xhr")).update("Back").insert(el.button.str.container);
276
277       /*
278        * xhr
279        */
280       el.left.xhr = {};
281       el.left.xhr.container = new lib.element("DIV").attribute.addClass("XHR").insert(el.left.container);
282
283       el.right.xhr = {};
284       el.right.xhr.container = new lib.element("DIV").attribute.addClass("XHR").insert(el.left.container);
285
286
287       el.button.xhr = {};
288       el.button.xhr.container = new lib.element("DIV").attribute.addClass("ButtonSet XHR").insert(el.button.container);
289       el.button.xhr.label = new lib.element("LABEL").update("XHR Path:").insert(el.button.xhr.container);
290       el.button.xhr.textbox = new lib.element("INPUT").event.addListener("keydown",listen.xhrTextbox).insert(el.button.xhr.container);
291       el.button.xhr.watch = new lib.element("A").attribute.addClass("Button").event.addListener("click",listen.addXhrObject).update("Watch").insert(el.button.xhr.container);
292
293       /*
294        * settings
295        */
296       el.settings = {};
297       el.settings.container = new lib.element("DIV").child.add(
298         new lib.element("DIV").attribute.addClass("Header").child.add(
299           new lib.element().attribute.addClass("Title").update('Firebug Lite Settings')
300         )
301       ).attribute.addClass("SettingsDiv").insert(el.main);
302       el.settings.content = new lib.element("DIV").attribute.addClass("Content").insert(el.settings.container);
303       el.settings.progressDiv = new lib.element("DIV").attribute.addClass("ProgressDiv").insert(el.settings.content);
304       el.settings.progress = new lib.element("DIV").attribute.addClass("Progress").insert(el.settings.progressDiv);
305       el.settings.cbxDebug = new lib.element("INPUT").attribute.set("type","checkbox").attribute.addClass("SettingsCBX").insert(el.settings.content);
306       el.settings.content.child.add(document.createTextNode("Start visible"));
307       new lib.element("BR").insert(el.settings.content);
308       el.settings.cbxDetectFirebug = new lib.element("INPUT").attribute.set("type","checkbox").attribute.addClass("SettingsCBX").insert(el.settings.content);
309       el.settings.content.child.add(document.createTextNode("Hide when Firebug active"));
310       new lib.element("BR").insert(el.settings.content);
311       el.settings.cbxHideDOMFunctions = new lib.element("INPUT").attribute.set("type","checkbox").attribute.addClass("SettingsCBX").insert(el.settings.content);
312       el.settings.content.child.add(document.createTextNode("Hide DOM functions"));
313       new lib.element("BR").insert(el.settings.content);
314       el.settings.cbxOverride = new lib.element("INPUT").attribute.set("type","checkbox").attribute.addClass("SettingsCBX").insert(el.settings.content);
315       el.settings.content.child.add(document.createTextNode("Override window.console"));
316       new lib.element("BR").insert(el.settings.content);
317       el.settings.cbxShowIcon = new lib.element("INPUT").attribute.set("type","checkbox").attribute.addClass("SettingsCBX").insert(el.settings.content);
318       el.settings.content.child.add(document.createTextNode("Show icon when hidden"));
319       new lib.element("BR").insert(el.settings.content);
320       el.settings.cbxOpenInPopup = new lib.element("INPUT").attribute.set("type","checkbox").attribute.addClass("SettingsCBX").insert(el.settings.content);
321       el.settings.content.child.add(document.createTextNode("Open in popup"));
322       el.settings.buttonDiv = new lib.element("DIV").insert(el.settings.content);
323       el.settings.buttonLeftDiv = new lib.element("DIV").attribute.addClass("ButtonsLeft").insert(el.settings.buttonDiv);
324       el.settings.resetButton = new lib.element("INPUT").attribute.set("type","button").update("Reset").event.addListener("click",settings.reset).insert(el.settings.buttonLeftDiv);
325       el.settings.buttonRightDiv = new lib.element("DIV").attribute.addClass("ButtonsRight").insert(el.settings.buttonDiv);
326       el.settings.cancelButton = new lib.element("INPUT").attribute.set("type","button").update("Cancel").event.addListener("click",settings.hide).insert(el.settings.buttonRightDiv);
327       el.settings.buttonRightDiv.child.add(document.createTextNode(" "));
328       el.settings.saveButton = new lib.element("INPUT").attribute.set("type","button").update("Save").event.addListener("click",settings.saveClicked).insert(el.settings.buttonRightDiv);
329
330       lib.util.AddEvent(document,"mousemove",listen.mouse)("mousemove",win.resizer.resize)("mouseup",win.resizer.stop)("keydown",listen.keyboard);
331
332       env.init = true;
333
334       for(var i=0, len=d.console.cache.length; i<len; i++){
335         var item = d.console.cache[i];
336         d.console.cmd[item.command].apply(window,item.arg);
337       };
338
339       if(lib.env.ie6){
340         window.onscroll = lib.util.Curry(win.setVerticalPosition,window,null);
341         var buttons = [
342           el.button.inspect,
343           el.button.close,
344           el.button.inspect,
345           el.button.console.clear,
346           el.right.console.run,
347           el.right.console.clear,
348           el.right.css.run,
349           el.right.css.clear
350           ];
351         for(var i=0, len=buttons.length; i<len; i++)
352           buttons[i].attribute.set("href","#");
353         win.refreshSize();
354       }
355      
356       if(env.showIconWhenHidden) {
357         if(!env.popupWin) {
358           el.firebugIcon.environment.addStyle({ "display": env.debug&&'none'||'block' });
359         }
360       }
361
362       lib.util.AddEvent(window, "unload", win.unload);
363
364       if (env.isPopup) {
365         env.height=lib.util.GetViewport().height;
366         lib.util.AddEvent(window, "resize", win.fitToPopup);
367         win.fitToPopup();
368       } else {
369         lib.util.AddEvent(window, "resize", win.refreshSize);
370       }
371
372       win.setHeight(env.height);
373
374       if(env.openInPopup&&!env.isPopup) {
375         win.newWindow();
376       } else {
377         el.main.environment.addStyle({ "display":env.debug&&'block'||'none' });
378         el.mainiframe.environment.addStyle({ "display":env.debug&&'block'||'none' });
379       }
380     }  
381   },
382   inspect:function(){
383     return firebug.d.html.inspect.apply(window,arguments);
384   },
385   watchXHR:function(){
386     with(firebug){
387       d.xhr.addObject.apply(window,arguments);
388       if(env.dIndex!="xhr"){
389         d.navigate("xhr");
390       }
391     }
392   },
393   settings:{
394     isVisible:false,
395     show: function() {
396       with(firebug){
397         var posXY=lib.util.Element.getPosition(firebug.el.nav.options.element);
398         settings.refreshForm();
399
400         el.settings.container.environment.addStyle({
401           "display": "block",
402           "left": (posXY.offsetLeft-125)+"px"
403         });
404         el.settings.progressDiv.environment.addStyle({
405           "display": "none"
406         });
407         firebug.settings.isVisible = true;
408       }
409     },
410     hide: function() {
411       with(firebug){
412         firebug.el.settings.container.environment.addStyle({
413           "display": "none"
414         });
415         firebug.settings.isVisible = false;
416       }
417     },
418     toggle: function(){
419       with(firebug){
420         settings[!settings.isVisible && 'show' || 'hide']();
421       }
422     },
423     saveClicked: function() {
424       firebug.el.settings.progressDiv.environment.addStyle({
425         "display": "block"
426       });
427       setTimeout(firebug.settings.formToSettings,0);
428     },
429     formToSettings: function() {
430       var fe=firebug.env,
431         ofe,
432         elSet=firebug.el.settings,
433         exdate;
434
435       fe.debug=elSet.cbxDebug.element.checked;
436       fe.detectFirebug=elSet.cbxDetectFirebug.element.checked;
437       fe.hideDOMFunctions=elSet.cbxHideDOMFunctions.element.checked;
438       fe.override=elSet.cbxOverride.element.checked;
439       fe.showIconWhenHidden=elSet.cbxShowIcon.element.checked;
440       fe.openInPopup=elSet.cbxOpenInPopup.element.checked;
441
442       if(fe.isPopup) {
443         ofe=window.opener.firebug.env;
444         ofe.debug=fe.debug;
445         ofe.detectFirebug=fe.detectFirebug;
446         ofe.hideDOMFunctions=fe.hideDOMFunctions;
447         ofe.override=fe.override;
448         ofe.showIconWhenHidden=fe.showIconWhenHidden;
449         ofe.openInPopup=fe.openInPopup;
450         ofe.popupTop=fe.popupTop;
451         ofe.popupLeft=fe.popupLeft;
452         ofe.popupWidth=fe.popupWidth;
453         ofe.popupHeight=fe.popupHeight;
454       }
455
456       with(firebug) {
457         settings.writeCookie();
458         settings.hide();
459         win.refreshDOM();
460       }
461     },
462     reset: function() {
463       var exdate=new Date();
464
465       exdate.setTime(exdate.getTime()-1);
466       document.cookie='FBLiteSettings=;expires='+exdate.toGMTString();
467       location.reload(true);
468     },
469     readCookie: function() {
470       var i,cookieArr,valueArr,item,value;
471
472       with(firebug.env){
473         if(targetWindow.document.cookie.length>0) {
474           cookieArr=targetWindow.document.cookie.split('; ');
475           
476           for(i=0;i<cookieArr.length;i++) {
477             if(cookieArr[i].split('=')[0]=='FBLiteSettings') {
478               valueArr=cookieArr[i].split('=')[1].split(',');
479             }
480           }
481
482           if(valueArr) {
483             for(i=0;i<valueArr.length;i++) {
484               item=valueArr[i].split(':')[0];
485               value=valueArr[i].split(':')[1];
486               
487               switch(item) {
488                 case 'debug':
489                   debug=value=="true";
490                   break;
491                 case 'detectFirebug':
492                   detectFirebug=value=="true";
493                   break;
494                 case 'hideDOMFunctions':
495                   hideDOMFunctions=value=="true";
496                   break;
497                 case 'override':
498                   override=value=="true";
499                   break;
500                 case 'showIconWhenHidden':
501                   showIconWhenHidden=value=="true";
502                   break;
503                 case 'openInPopup':
504                   openInPopup=value=="true";
505                   break;
506                 case 'popupTop':
507                   popupTop=parseInt(value,10);
508                   break;
509                 case 'popupLeft':
510                   popupLeft=parseInt(value,10);
511                   break;
512                 case 'popupWidth':
513                   popupWidth=parseInt(value,10);
514                   break;
515                 case 'popupHeight':
516                   popupHeight=parseInt(value,10);
517                   break;
518                 case 'height':
519                   height=parseInt(value,10);
520                   break;
521               }
522             }
523           }
524         }
525       }
526     },
527     writeCookie: function() {
528       var values;
529       
530       with(firebug.env){
531         values='debug:'+debug+',';
532         values+='detectFirebug:'+detectFirebug+',';
533         values+='hideDOMFunctions:'+hideDOMFunctions+',';
534         values+='override:'+override+',';
535         values+='showIconWhenHidden:'+showIconWhenHidden+',';
536         values+='openInPopup:'+openInPopup+',';
537
538         if(isPopup) {
539           if(window.outerWidth===undefined) {
540             values+='popupTop:'+(window.screenTop-56)+',';
541             values+='popupLeft:'+(window.screenLeft-8)+',';
542             values+='popupWidth:'+document.body.clientWidth+',';
543             values+='popupHeight:'+document.body.clientHeight+',';
544           } else {
545             values+='popupTop:'+window.screenY+',';
546             values+='popupLeft:'+window.screenX+',';
547             values+='popupWidth:'+window.outerWidth+',';
548             values+='popupHeight:'+window.outerHeight+',';
549           }
550         } else {
551           values+='popupTop:'+popupTop+',';
552           values+='popupLeft:'+popupLeft+',';
553           values+='popupWidth:'+popupWidth+',';
554           values+='popupHeight:'+popupHeight+',';
555         }
556         
557         values+='height:'+(parseInt(targetWindow.firebug.el.main.element.style.height.replace(/px/,''),10)-38);
558
559         exdate=new Date();
560         exdate.setDate(exdate.getDate()+365);
561         targetWindow.document.cookie='FBLiteSettings='+values+';expires='+exdate.toGMTString();
562       }
563     },
564     refreshForm: function() {
565       var fe=firebug.env,
566           elSet=firebug.el.settings;
567
568       elSet.cbxDebug.element.checked=fe.debug;
569       elSet.cbxDetectFirebug.element.checked=fe.detectFirebug;
570       elSet.cbxHideDOMFunctions.element.checked=fe.hideDOMFunctions;
571       elSet.cbxOverride.element.checked=fe.override;
572       elSet.cbxShowIcon.element.checked=fe.showIconWhenHidden;
573       elSet.cbxOpenInPopup.element.checked=fe.openInPopup;
574     }
575   },
576   win:{
577     hide:function(){
578       with(firebug){
579         el.main.environment.addStyle({
580           "display": "none"
581         });
582         el.mainiframe.environment.addStyle({
583           "display": "none"
584         });
585         if(env.showIconWhenHidden) {
586           el.firebugIcon.environment.addStyle({
587             "display": "block"
588           });
589         }
590       }
591     },
592     show:function(){
593       with(firebug){
594         el.main.environment.addStyle({
595           "display": "block"
596         });
597         el.mainiframe.environment.addStyle({
598           "display": "block"
599         });
600         if(env.showIconWhenHidden) {
601           el.firebugIcon.environment.addStyle({
602             "display": "none"
603           });
604         }
605       }
606     },
607     iconClicked:function(_event) {
608         with(firebug) {
609             if(_event.ctrlKey==true||_event.metaKey==true) {
610                 el.firebugIcon.environment.addStyle({ "display": "none" });
611                 env.showIconWhenHidden=false;
612             } else {
613                 win.show();
614             }
615         }
616     },
617     minimize:function(){
618       with(firebug){
619         env.minimized=true;
620         el.main.environment.addStyle({ "height":"35px" });
621         el.mainiframe.environment.addStyle({ "height":"35px" });
622         el.button.maximize.environment.addStyle({ "display":"block" });
623         el.button.minimize.environment.addStyle({ "display":"none" });
624         win.refreshSize();
625       }
626     },
627     maximize:function(){
628       with(firebug){
629         env.minimized=false;
630         el.button.minimize.environment.addStyle({ "display":"block" });
631         el.button.maximize.environment.addStyle({ "display":"none" });
632         win.setHeight(env.height);
633       }
634     },
635     newWindow: function() {
636       var interval,scripts,script,scriptPath,
637           fe=firebug.env;
638
639       if (!fe.popupWin) {
640         scripts = document.getElementsByTagName('script');
641         
642         fe.popupWin = window.open("", "_firebug", 
643           "status=0,menubar=0,resizable=1,top="+fe.popupTop+",left="+fe.popupLeft+",width=" + fe.popupWidth + 
644           ",height=" + fe.popupHeight + ",scrollbars=0,addressbar=0,outerWidth="+fe.popupWidth+",outerHeight="+fe.popupHeight+
645           "toolbar=0,location=0,directories=0,dialog=0");
646         
647         if(!fe.popupWin) {
648           alert("Firebug Lite could not open a pop-up window, most likely because of a popup blocker.\nPlease enable popups for this domain");
649         } else {
650           firebug.settings.hide();
651         
652           for (i=0,len=scripts.length; i<len; i++) {
653             if (scripts[i].src.indexOf(fe.liteFilename) > -1) {
654               scriptPath = scripts[i].src;
655               break;
656             }
657           }
658
659           if (scriptPath) {
660             script = fe.popupWin.document.createElement('script'), done = false;
661             script.type = 'text/javascript';
662             script.src = scriptPath;
663
664             script[firebug.lib.env.ie?"onreadystatechange":"onload"] = function(){
665               if(!done && (!firebug.lib.env.ie || this.readyState == "complete" || this.readyState=="loaded")){
666                 done = true;
667                 if(fe.popupWin.firebug) {
668                   with(fe.popupWin.firebug) {
669                     env.isPopup = true;
670                     env.css = fe.css;
671                     init();
672                     el.button.dock.environment.addStyle({ "display": "block"});
673                     el.button.newWindow.environment.addStyle({ "display": "none"});
674                   }
675                 }
676               }
677             };
678
679             if (!done && firebug.lib.env.webkit) {
680               fe.popupWin.document.write('<html><head></head><body></body></html>');
681               interval = setInterval(function() {
682                 if (fe.popupWin.firebug) {
683                   clearInterval(interval);
684                   done = true;
685                   with(fe.popupWin.firebug) {
686                     env.isPopup = true;
687                     env.css = fe.css;
688                     init();
689                     el.button.dock.environment.addStyle({ "display": "block"});
690                     el.button.newWindow.environment.addStyle({ "display": "none"});
691                   }
692                 }
693               }, 10);
694             };
695
696             if (!done) {
697               fe.popupWin.document.getElementsByTagName('head')[0].appendChild(script);
698               firebug.el.main.environment.addStyle({"display": "none"});
699               firebug.el.mainiframe.environment.addStyle({"display": "none"});
700             }
701           } else {
702             alert("Unable to detect the following script \"" + fe.liteFilename +
703                   "\" ... if the script has been renamed then please set the value of firebug.env.liteFilename to reflect this change");
704             fe.popupWin.close();
705             fe.popupWin=null;
706           }
707         }
708       }
709     },
710     dock: function() {
711       with(opener.firebug) {
712         env.popupWin = null;
713         el.main.environment.addStyle({
714           "display": "block"
715         });
716         el.mainiframe.environment.addStyle({
717           "display": "block"
718         });
719         settings.readCookie();
720         window.close();
721       };
722     },
723     unload: function() {
724       with(firebug){
725         if(env.isPopup) {
726           win.dock();
727         } else if(env.popupWin) {
728           env.popupWin.close();
729         }
730       }
731     },
732     fitToPopup: function() {
733       with(firebug) {
734         var viewport = lib.util.GetViewport(window);
735         win.setHeight((window.innerHeight||viewport.height) - 38);
736         el.main.environment.addStyle({
737           "width": (viewport.width) + "px"
738         });
739         el.mainiframe.environment.addStyle({
740           "width": (viewport.width) + "px"
741         });
742       }
743     },
744     resizer:{
745       y:[], enabled:false,
746       start:function(_event){
747         with(firebug){
748           if(env.minimized)return;
749           win.resizer.y=[el.main.element.offsetHeight,_event.clientY];
750           if(lib.env.ie6){
751             win.resizer.y[3]=parseInt(el.main.environment.getPosition().top);
752           }
753           win.resizer.enabled=true;
754         }
755       },
756       resize:function(_event){
757         with(firebug){
758           if(!win.resizer.enabled)return;
759           win.resizer.y[2]=(win.resizer.y[0]+(win.resizer.y[1]-_event.clientY));
760           el.main.environment.addStyle({ "height":win.resizer.y[2]+"px" });
761           el.mainiframe.environment.addStyle({ "height":win.resizer.y[2]+"px" });
762           if(lib.env.ie6){
763             el.main.environment.addStyle({ "top":win.resizer.y[3]-(win.resizer.y[1]-_event.clientY)+"px" });
764             el.mainiframe.environment.addStyle({ "top":win.resizer.y[3]-(win.resizer.y[1]-_event.clientY)+"px" });
765           }
766         }
767       },
768       stop:function(_event){
769         with(firebug){
770           if(win.resizer.enabled){
771             win.resizer.enabled=false;
772             win.setHeight(win.resizer.y[2]-35);
773           }
774         }
775       }
776     },
777     setHeight:function(_height){
778       with(firebug){
779         env.height=_height;
780
781         el.left.container.environment.addStyle({ "height":_height+"px" });
782         el.right.container.environment.addStyle({ "height":_height+"px" });
783         el.main.environment.addStyle({ "height":_height+38+"px" });
784         el.mainiframe.environment.addStyle({ "height":_height+38+"px" });
785
786         win.refreshSize();
787
788         // console
789         el.left.console.monitor.element.parentNode.style.height=_height-47+"px";
790         el.left.console.mlButton.environment.addStyle({ "top":_height+19+"px" });
791         el.right.console.mlButton.environment.addStyle({ "top":_height+19+"px" });
792         el.right.console.input.environment.addStyle({ "height":_height-29+"px" });
793
794         // html
795         el.left.html.container.environment.addStyle({"height":_height-23+"px"});
796         el.right.html.content.environment.addStyle({"height":_height-23+"px"});
797
798         // css
799         el.left.css.container.environment.addStyle({"height":_height-33+"px"});
800         el.right.css.input.environment.addStyle({ "height":_height-55+"px" });
801
802         // script
803         el.left.scripts.container.environment.addStyle({"height":_height-23+"px"});
804
805         // dom
806         el.left.dom.container.environment.addStyle({"height":_height-31+"px"});
807
808         // xhr
809         el.left.xhr.container.environment.addStyle({"height":_height-32+"px"});
810
811         // string
812         el.left.str.container.environment.addStyle({"height":_height-32+"px"});
813       }
814     },
815     refreshDOM:function(){
816       with(firebug){
817         d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
818         if(d.html.nIndex=="dom"){
819           firebug.d.html.navigate("dom")
820         }
821       }
822     },
823     refreshSize:function(){
824       with(firebug){
825         if(!env.init)
826           return;
827
828         var dim = lib.util.GetViewport();
829         el.main.environment.addStyle({ "width":dim.width+"px"});
830         el.mainiframe.environment.addStyle({ "width":dim.width+"px"});
831         if(lib.env.ie6)
832           win.setVerticalPosition(dim);
833       }
834     },
835     setVerticalPosition:function(_dim,_event){
836       with(firebug){
837         var dim = _dim||lib.util.GetViewport();
838         el.main.environment.addStyle({ "top":dim.height-el.main.environment.getSize().offsetHeight+Math.max(document.documentElement.scrollTop,document.body.scrollTop)+"px" });
839         el.mainiframe.environment.addStyle({ "top":dim.height-el.main.environment.getSize().offsetHeight+Math.max(document.documentElement.scrollTop,document.body.scrollTop)+"px" });
840       }
841     }
842   },
843   d: {
844     clean:function(_element){
845       with(firebug){
846         _element.update("");
847       }
848     },
849     console:{
850       addLine:function(){
851         with (firebug) {
852           return new lib.element("DIV").attribute.addClass("Row").insert(el.left.console.monitor);
853         }
854       },
855       cache:[],
856       clear:function(){
857         with(firebug){
858           d.clean(el.left.console.monitor);
859           d.console.cache = [];
860         }
861       },
862       formatArgs:function(){
863         with(firebug){
864           var content = [];
865           for(var i=0, len=arguments.length; i<len; i++){
866             content.push( d.highlight(arguments[i],false,false,true) );
867           }
868           return content.join(" ");
869         }
870       },
871       history:[], historyIndex:0,
872       openObject:function(_index){
873         with (firebug) {
874           d.dom.open(d.console.cache[_index], el.left.dom.container, lib.env.ie);
875           d.navigate("dom");
876         }
877       },
878       print: function(_cmd,_text){
879         with (firebug){
880           d.console.addLine().attribute.addClass("Arrow").update(">>> "+_cmd);
881           d.console.addLine().update(d.highlight(_text,false,false,true));
882           d.console.scroll();
883         }
884       },
885       printException: function(_exception){
886         with(firebug){
887           var message = _exception.description||_exception.message||_exception;
888           if(_exception.fileName){
889             message+=' ('+(_exception.name&&(_exception.name+', ')||'')+getFileName(_exception.fileName)+', '+_exception.lineNumber+')';
890           }
891           d.console.addLine().attribute.addClass("Error").update("<strong>Error: </strong>"+message,true);
892         }
893       },
894       eval:function(_cmd){
895         var result;
896         with(firebug){
897           if(_cmd.length==0)
898             return;
899
900           el.left.console.input.environment.getElement().value = "";
901           d.console.historyIndex = d.console.history.push(_cmd);
902
903           try {
904             if(_cmd==='console.firebug') {
905               d.console.addLine().attribute.addClass("Arrow").update(firebug.version);
906             } else {  
907               result = eval.call(window,_cmd);
908               d.console.print(_cmd,result);
909             }
910           } catch(e){
911             d.console.addLine().attribute.addClass("Arrow").update(">>> "+_cmd);
912             d.console.printException(e);
913           }
914           d.console.scroll();
915         }
916       },
917       scroll:function(){
918         with(firebug){
919           el.left.console.monitor.environment.getElement().parentNode.scrollTop = Math.abs(el.left.console.monitor.environment.getSize().offsetHeight-(el.left.console.monitor.element.parentNode.offsetHeight-11));
920         }
921       },
922       run:function(_command){
923         with(firebug){
924           if(!env.init){
925             d.console.cache.push({ "command":_command, "arg":Array.prototype.slice.call(arguments,1) });
926           } else {
927             d.console.cmd[_command].apply(window,Array.prototype.slice.call(arguments,1));
928           }
929         }
930       },
931       toggleML:function(){
932         with(firebug){
933           var open = !env.ml;
934           env.ml = !env.ml;
935           d.navigateRightColumn("console",open);
936           el[open?"left":"right"].console.mlButton.environment.addStyle({ display:"none" });
937           el[!open?"left":"right"].console.mlButton.environment.addStyle({ display:"block" });
938           el.left.console.mlButton.attribute[(open?"add":"remove")+"Class"]("CloseML");
939         }
940       },
941       countMap:{}, timeMap: {},
942       cmd:{
943         log: function(_value){
944           with(firebug){
945             var args = d.console.formatArgs.apply(window,arguments);
946             d.console.addLine().attribute.addClass("Log").update(args);
947             d.console.scroll();
948           }
949         },
950         warn: function(_value){
951           with(firebug){
952             var args = d.console.formatArgs.apply(window,arguments);
953             d.console.addLine().attribute.addClass("Warn").update(args);
954             d.console.scroll();
955           }
956         },
957         info: function(_value){
958           with(firebug){
959             var args = d.console.formatArgs.apply(window,arguments);
960             d.console.addLine().attribute.addClass("Info").update(args);
961             d.console.scroll();
962           }
963         },
964         debug: function(_value){
965           with(firebug){
966             var args = d.console.formatArgs.apply(window,arguments);
967             d.console.addLine().attribute.addClass("Debug").update(args);
968             d.console.scroll();
969           }
970         },
971         error: function(_value){
972           with(firebug){
973             var args = d.console.formatArgs.apply(window,arguments);
974             d.console.addLine().attribute.addClass("Error").update(args);
975             d.console.scroll();
976           }
977         },
978         trace: function(_value){
979           with(firebug){
980             var stackAmt = 3, f = arguments.caller, isArray = lib.util.IsArray(f); //function that called trace
981
982             if((!isArray&&f)||(isArray&&f.length>0)){
983               d.console.addLine().attribute.addClass("Arrow").update(">>> console.trace(stack)");
984               for(var i=0;i<stackAmt;i++){
985                 var func = f.toString(), args = f.arguments;
986                 d.dom.open({"function":func, "arguments":args},d.console.addLine());
987                 f = f.caller;
988               }
989             }
990           }
991         },
992         dir:function(_value){
993           with(firebug){
994             d.console.addLine().attribute.addClass("Arrow").update(">>> console.dir("+_value+")");
995             d.dom.open(_value,d.console.addLine());
996           }
997         },
998         dirxml: function(){
999           with(firebug){
1000             d.console.cmd.log.apply(this, arguments);
1001           }
1002         },
1003         time: function(_name){
1004           with(firebug){
1005             d.console.timeMap[_name] = new Date().getTime();
1006           }
1007         },
1008         timeEnd: function(_name){
1009           with(firebug){
1010             if(_name in d.console.timeMap){
1011               var delta = new Date().getTime() - d.console.timeMap[_name],
1012               args = d.console.formatArgs.apply(window,[_name+":", delta+"ms"]);
1013               d.console.addLine().attribute.addClass("log").update(args);
1014               delete d.console.timeMap[_name];
1015             }
1016           }
1017         },
1018         count: function(_name){
1019           with(firebug){
1020             if(!d.console.countMap[_name])
1021               d.console.countMap[_name] = 0;
1022             d.console.countMap[_name]++;
1023             d.console.cmd.log.apply(window, [_name, d.console.countMap[_name]]);
1024           }
1025         },
1026         group:function(){
1027           with(firebug){
1028             d.console.cmd.log.apply(this, ["console.group is not supported"]);
1029           }
1030         },
1031         groupEnd:function(){
1032           with(firebug){
1033             d.console.cmd.log.apply(this, ["console.groupEnd is not supported"]);
1034           }
1035         },
1036         profile:function(){
1037           with(firebug){
1038             d.console.cmd.log.apply(this, ["console.profile is not supported"]);
1039           }
1040         },
1041         profileEnd:function(){
1042           with(firebug){
1043             d.console.cmd.log.apply(this, ["console.profileEnd is not supported"]);
1044           }
1045         }
1046       }
1047     },
1048     css:{
1049       index:-1,
1050       open:function(_index){
1051         with (firebug) {
1052           var item = env.targetWindow.document.styleSheets[_index],
1053           uri = item.href;
1054           try {
1055             var rules = item[lib.env.ie ? "rules" : "cssRules"], str = "";
1056             for (var i=0; i<rules.length; i++) {
1057               var item = rules[i];
1058               var selector = item.selectorText;
1059               var cssText = lib.env.ie?item.style.cssText:item.cssText.match(/\{(.*)\}/)[1];
1060               str+=d.css.printRule(selector, cssText.split(";"), el.left.css.container);
1061             }
1062           } catch(e) {
1063             str="<em>Access to restricted URI denied</em>";
1064           }
1065           el.left.css.container.update(str);
1066         }
1067       },
1068       printRule:function(_selector,_css,_layer){
1069         with(firebug){
1070           var str = "<div class='Selector'>"+_selector+" {</div>";
1071           for(var i=0,len=_css.length; i<len; i++){
1072             var item = _css[i];
1073             str += "<div class='CSSText'>"+item.replace(/(.+\:)(.+)/,"<span class='CSSProperty'>$1</span><span class='CSSValue'>$2;</span>")+"</div>";
1074           }
1075           str+="<div class='Selector'>}</div>";
1076           return str;
1077         }
1078       },
1079       refresh:function(){
1080         with(firebug){
1081           el.button.css.selectbox.update("");
1082           var collection = env.targetWindow.document.styleSheets;
1083           for(var i=0,len=collection.length; i<len; i++){
1084             var uri = getFileName(collection[i].href);
1085             d.css.index=d.css.index<0?i:d.css.index;
1086             el.button.css.selectbox.child.add(
1087                 new lib.element("OPTION").attribute.set("value",i).update(uri)
1088             )
1089           };
1090           d.css.open(d.css.index);
1091         }
1092       }
1093     },
1094     dom: {
1095       open: function(_object,_layer){
1096         with (firebug) {
1097           _layer.clean();
1098           var container = new lib.element("DIV").attribute.addClass("DOMContent").insert(_layer);
1099           d.dom.print(_object, container);
1100         }
1101       },
1102       print:function(_object,_parent, _inTree){
1103         with (firebug) {
1104           var obj = _object || window, parentElement = _parent;
1105           parentElement.update("");
1106
1107           if(parentElement.opened&&parentElement!=el.left.dom.container){
1108             parentElement.environment.getParent().lib.child.get()[0].lib.child.get()[0].lib.attribute.removeClass("Opened");
1109             parentElement.opened = false;
1110             parentElement.environment.addStyle({ "display":"none" });
1111             return;
1112           }
1113           if(_inTree)
1114             parentElement.environment.getParent().lib.child.get()[0].lib.child.get()[0].lib.attribute.addClass("Opened");
1115           parentElement.opened = true;
1116
1117           for (var key in obj) {
1118             try {
1119               if (env.hideDOMFunctions && typeof(obj[key]) == "function") continue;
1120               var value = obj[key], property = key, container = new lib.element("DIV").attribute.addClass("DOMRow").insert(parentElement),
1121               left = new lib.element("DIV").attribute.addClass("DOMRowLeft").insert(container), right = new lib.element("DIV").attribute.addClass("DOMRowRight").insert(container);
1122
1123               container.child.add(
1124                   new lib.element("DIV").attribute.addClass('Clear')
1125               );
1126
1127               var link = new lib.element("A").attribute.addClass(
1128                   typeof value=="object"&&Boolean(value)?"Property Object":"Property"
1129               ).update(property).insert(left);
1130
1131               right.update(d.highlight(value,false,true));
1132
1133               var subContainer = new lib.element("DIV").attribute.addClass("DOMRowSubContainer").insert(container);
1134
1135               if(typeof value!="object"||Boolean(value)==false)
1136                 continue;
1137
1138               link.event.addListener("click",lib.util.Curry(d.dom.print,window,value, subContainer, true));
1139             }catch(e){
1140             }
1141           }
1142           parentElement.environment.addStyle({ "display":"block" });
1143         }
1144       }
1145     },
1146     highlight:function(_value,_inObject,_inArray,_link){
1147       with(firebug){
1148         var isArray = false, isHash, isElement = false, vtype=typeof _value, result=[];
1149         
1150         if(vtype=="object"){
1151           if(Object.prototype.toString.call(_value) === "[object Date]"){
1152             vtype = "date";
1153           } else if(Object.prototype.toString.call(_value) === "[object String]"){
1154             vtype = "string";
1155           } else if(Object.prototype.toString.call(_value) === "[object Boolean]"){
1156             vtype = "boolean";
1157           } else if(Object.prototype.toString.call(_value) === "[object RegExp]"){
1158             vtype = "regexp";
1159           }
1160         }
1161         
1162         try {
1163           isArray = lib.util.IsArray(_value);
1164           isHash = lib.util.IsHash(_value);
1165           isElement = _value!=undefined&&Boolean(_value.nodeName)&&Boolean(_value.nodeType);
1166
1167           // number, string, boolean, null, function
1168           if(_value==null||vtype=="number"||vtype=="string"||vtype=="boolean"||vtype=="function"||vtype=="regexp"||vtype=="date"){
1169             if(_value==null){
1170               result.push("<span class='Null'>null</span>");
1171             }else if (vtype=="regexp") {
1172               result.push("<span class='Maroon'>" + _value + "</span>");
1173             }else if (vtype=="date") {
1174               result.push("<span class='DarkBlue'>'" + _value + "'</span>");
1175             } else if (vtype=="boolean"||vtype=="number") {
1176               result.push("<span class='DarkBlue'>" + _value + "</span>");
1177             } else if(vtype=="function"){
1178               result.push("<span class='"+(_inObject?"Italic Gray":"Green")+"'>function()</span>");
1179             } else {
1180               result.push("<span class='Red'>\""+( !_inObject&&!_inArray?_value : _value.substring(0,35)+(_value.length>35?" ...":"") ).replace(/\n/g,"\\n").replace(/\s/g,"&nbsp;").replace(/>/g,"&#62;").replace(/</g,"&#60;")+"\"</span>");
1181             }
1182           }
1183           // element
1184           else if(isElement){
1185
1186             if(_value.nodeType==3)
1187               result.push(d.highlight(_value.nodeValue));
1188             else if(_inObject){
1189               result.push("<span class='Gray Italic'>"+_value.nodeName.toLowerCase()+"</span>");
1190             } else {
1191               result.push("<span class='Blue"+ ( !_link?"'":" ObjectLink' onmouseover='this.className=this.className.replace(\"ObjectLink\",\"ObjectLinkHover\")' onmouseout='this.className=this.className.replace(\"ObjectLinkHover\",\"ObjectLink\")' onclick='firebug.d.html.inspect(firebug.d.console.cache[" +( d.console.cache.push( _value ) -1 )+"])'" ) + "'>");
1192
1193               if(_inArray){
1194                 result.push(_value.nodeName.toLowerCase());
1195                 if(_value.getAttribute){
1196                   if(_value.getAttribute&&_value.getAttribute("id"))
1197                     result.push("<span class='DarkBlue'>#"+_value.getAttribute("id")+"</span>");
1198                   var elClass = _value.getAttribute(lib.env.ie&&!lib.env.ie8?"className":"class")||"";
1199                   result.push(!elClass?"":"<span class='Red'>."+elClass.split(" ")[0]+"</span>");
1200                 }
1201                 result.push("</span>");
1202               } else {
1203                 result.push("<span class='DarkBlue'>&#60;<span class='Blue TagName'>"+ _value.nodeName.toLowerCase());
1204
1205                 if(_value.attributes){
1206                   for(var i=0,len=_value.attributes.length; i<len; i++){
1207                     var item = _value.attributes[i];
1208
1209                     if(!lib.env.ie||item.nodeValue)
1210                       result.push(" <span class='DarkBlue'>"+item.nodeName+"=\"<span class='Red'>"+item.nodeValue+"</span>\"</span>");
1211                   }
1212                 }
1213
1214                 result.push("</span>&#62;</span>");
1215               }
1216             }
1217           } 
1218           // array, hash
1219           else if(isArray||isHash){
1220             if(isArray){
1221               if(_inObject){
1222                 result.push("<span class='Gray Italic'>["+_value.length+"]</span>");
1223               } else {
1224                 result.push("<span class='Strong'>[ ");
1225
1226                 for(var i=0,len=_value.length; i<len; i++){
1227                   if((_inObject||_inArray)&&i>3){
1228                     result.push(", <span class='Strong Gray'>"+(len-4)+" More...</span>");
1229                     break;
1230                   }
1231                   result.push( (i > 0 ? ", " : "") + d.highlight(_value[i], false, true, true) );
1232                 }
1233
1234                 result.push(" ]</span>");
1235               }
1236             } else if(_inObject){
1237               result.push("<span class='Gray Italic'>Object</span>");
1238             } else {  
1239               result.push("<span class='Strong Green"+ ( !_link?"'":" ObjectLink' onmouseover='this.className=this.className.replace(\"ObjectLink\",\"ObjectLinkHover\")' onmouseout='this.className=this.className.replace(\"ObjectLinkHover\",\"ObjectLink\")' onclick='firebug.d.console.openObject(" +( d.console.cache.push( _value ) -1 )+")'" ) + ">Object");
1240               var i=0;
1241               for(var key in _value){
1242                 var value = _value[key];
1243                 if((_inObject||_inArray)&&i>3){
1244                   result.push(" <span class='Strong Gray'>More...</span>");
1245                   break;
1246                 }
1247                 result.push(" "+key+"="+d.highlight(value,true));
1248                 i++;
1249               }
1250               result.push("</span>");
1251             } 
1252           } else {
1253             result.push(["<span class'Gray Italic'>"+_value+"</span>"]);
1254           }
1255         } catch(e){
1256           result.push(".."); 
1257         }
1258         return result.join("");
1259       }
1260     },
1261     html:{
1262       nIndex:"computedStyle",
1263       current:null,
1264       highlight:function(_element,_clear,_event){
1265         with(firebug){
1266           if(_element.firebugElement){
1267             return;
1268           }
1269           if(_clear){
1270             env.targetWindow.firebug.el.bgInspector.environment.addStyle({ "display":"none" });
1271             return;
1272           }
1273           d.inspector.inspect(_element,true);
1274         }
1275       },
1276       inspect:function(_element){
1277         var map = [],
1278         parentLayer,
1279         t,
1280         tagName,
1281         parent = _element;
1282         while (parent) {
1283           map.push(parent);
1284           if (parent == firebug.env.targetWindow.document.body) break;
1285           parent = parent.parentNode;
1286         }
1287         map = map.reverse();
1288         with(firebug) {
1289           if (env.dIndex != "html") {
1290             env.targetWindow.firebug.d.navigate("html");
1291           }
1292
1293           env.targetWindow.firebug.d.inspector.toggle(false);
1294
1295           for (t = 0; t < el.left.html.container.child.get().length; t++) {
1296             if (el.left.html.container.child.get()[t].childNodes[0].childNodes[1].childNodes[0].childNodes[0]) {
1297               if (el.left.html.container.child.get()[t].childNodes[0].childNodes[1].childNodes[0].childNodes[0].innerText) {
1298                 tagName = el.left.html.container.child.get()[t].childNodes[0].childNodes[1].childNodes[0].childNodes[0].innerText;
1299               } else {
1300                 tagName = el.left.html.container.child.get()[t].childNodes[0].childNodes[1].childNodes[0].childNodes[0].textContent;
1301               }
1302
1303               if (/<body/i.test(tagName)) {
1304                 parentLayer = el.left.html.container.child.get()[t].childNodes[1].lib;
1305                 break;
1306               }
1307             }
1308           }
1309
1310           if (!parentLayer) {
1311             parentLayer = el.left.html.container.child.get()[3].childNodes[1].lib;
1312           }
1313
1314           for (t = 0, len = map.length; map[t]; t++) {
1315             if (t == len - 1) {
1316               var link = parentLayer.environment.getElement().previousSibling.lib;
1317               link.attribute.addClass("Selected");
1318
1319               if (d.html.current) {
1320                 d.html.current[1].attribute.removeClass("Selected");
1321               }
1322               d.html.current = [_element, link];
1323               return;
1324             }
1325             parentLayer = d.html.openHtmlTree(map[t], parentLayer, map[t + 1]);
1326           }
1327         }
1328       },
1329       navigate:function(_index,_element){
1330         with(firebug){
1331           el.right.html.nav[d.html.nIndex].attribute.removeClass("Selected");
1332           el.right.html.nav[_index].attribute.addClass("Selected");
1333           d.html.nIndex = _index;
1334           d.html.openProperties();
1335         }
1336       },
1337       openHtmlTree:function(_element,_parent,_returnParentElementByElement,_event){
1338         with(firebug){
1339           var element = _element || env.targetWindow.document.documentElement, 
1340               parent = _parent || el.left.html.container, 
1341               returnParentEl = _returnParentElementByElement || null, 
1342               returnParentVal = null,
1343               len = element.childNodes.length,
1344               nodeLink;
1345
1346           if(parent!=el.left.html.container){
1347             nodeLink = parent.environment.getParent().lib.child.get()[0].lib;
1348             if (d.html.current) {
1349               d.html.current[1].attribute.removeClass("Selected");
1350             }
1351             nodeLink.attribute.addClass("Selected");
1352
1353             d.html.current = [_element,nodeLink];
1354             d.html.openProperties();
1355           };
1356
1357           if(element.childNodes&&(len==0||(len==1&&element.childNodes[0].nodeType==3)))return;
1358           parent.clean();
1359
1360           if(parent.opened&&Boolean(_returnParentElementByElement)==false){
1361             parent.opened = false;
1362             parent.element.previousSibling.lib.attribute.removeClass("Open");
1363             parent.element.lib.attribute.removeClass("OpenSubContainer");
1364             return;
1365           };
1366
1367           if (parent != el.left.html.container) {
1368             parent.element.previousSibling.lib.attribute.addClass("Open");
1369             parent.element.lib.attribute.addClass("OpenSubContainer");
1370             parent.opened = true;
1371           };
1372
1373           if(element==document.documentElement){
1374             new lib.element("A").attribute.addClass("Block").update("<span class='DarkBlue'>&#60;<span class='Blue'>html</span>&#62;").insert(parent);
1375           };
1376
1377           for(var i=0; i<=len; i++){
1378             if(i==len){
1379               new lib.element("A").attribute.addClass("Block").update("<span class='DarkBlue'>&#60;/<span class='Blue'>"+element.nodeName.toLowerCase()+"</span>&#62;").insert(container);
1380               break;
1381             } 
1382             var item = element.childNodes[i];
1383
1384             if (item.nodeType != 3){
1385               var container = new lib.element().attribute.addClass("Block").insert(parent), 
1386               link = new lib.element("A").attribute.addClass("Link").insert(container), 
1387               spacer = new lib.element("SPAN").attribute.addClass("Spacer").update("&nbsp;").insert(link),
1388               html = new lib.element("SPAN").attribute.addClass("Content").update(d.highlight(item)).insert(link),
1389               subContainer = new lib.element("DIV").attribute.addClass("SubContainer").insert(container),
1390               view = lib.util.Element.getView(item);
1391
1392               link.event.addListener("click", lib.util.Curry(d.html.openHtmlTree, window, item, subContainer, false));
1393               link.event.addListener("mouseover", lib.util.Curry(d.html.highlight, window, item, false));
1394               link.event.addListener("mouseout", lib.util.Curry(d.html.highlight, window, item, true));
1395
1396               returnParentVal = returnParentEl == item ? subContainer : returnParentVal;
1397
1398               if(d.html.current==null&&item==document.body){
1399                 link.attribute.addClass("Selected");
1400                 d.html.current = [item,link];
1401                 d.html.openHtmlTree(item,subContainer);
1402               }
1403
1404               if(element.nodeName!="HEAD"&&element!=document.documentElement&&(view.visibility=="hidden"||view.display=="none")){
1405                 container.attribute.addClass("Unvisible");
1406               };
1407
1408               if (item.childNodes){
1409                 var childLen = item.childNodes.length;
1410                 if (childLen == 1 && item.childNodes[0].nodeType == 3) {
1411                   html.child.add(document.createTextNode(item.childNodes[0].nodeValue.substring(0, 50)));
1412                   html.child.add(document.createTextNode("</"));
1413                   html.child.add(new lib.element("span").attribute.addClass("Blue").update(item.nodeName.toLowerCase()).environment.getElement());
1414                   html.child.add(document.createTextNode(">"));
1415                   continue;
1416                 }
1417                 else 
1418                   if (childLen > 0) {
1419                     link.attribute.addClass("Parent");
1420                   }
1421               }
1422             }
1423           };
1424           return returnParentVal;
1425         }
1426       },
1427       openProperties:function(){
1428         with(firebug){
1429           var index = d.html.nIndex;
1430           var node = d.html.current[0];
1431           d.clean(el.right.html.content);
1432           var str = "";
1433           switch(index){
1434             case "computedStyle":
1435               var property = ["opacity","filter","azimuth","background","backgroundAttachment","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","border","borderCollapse","borderColor","borderSpacing","borderStyle","borderTop","borderRight","borderBottom","borderLeft","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderWidth","bottom","captionSide","clear","clip","color","content","counterIncrement","counterReset","cue","cueAfter","cueBefore","cursor","direction","display","elevation","emptyCells","cssFloat","font","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","height","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginTop","marginRight","marginBottom","marginLeft","markerOffset","marks","maxHeight","maxWidth","minHeight","minWidth","orphans","outline","outlineColor","outlineStyle","outlineWidth","overflow","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","page","pageBreakAfter","pageBreakBefore","pageBreakInside","pause","pauseAfter","pauseBefore","pitch","pitchRange","playDuring","position","quotes","richness","right","size","speak","speakHeader","speakNumeral","speakPunctuation","speechRate","stress","tableLayout","textAlign","textDecoration","textIndent","textShadow","textTransform","top","unicodeBidi","verticalAlign","visibility","voiceFamily","volume","whiteSpace","widows","width","wordSpacing","zIndex"].sort();
1436               var view = document.defaultView?document.defaultView.getComputedStyle(node,null):node.currentStyle;
1437               for(var i=0,len=property.length; i<len; i++){
1438                 var item = property[i];
1439                 if(!view[item])continue;
1440                 str+="<div class='CSSItem'><div class='CSSProperty'>"+item+"</div><div class='CSSValue'>"+d.highlight(view[item])+"</div></div>";
1441               }
1442               el.right.html.content.update(str);
1443               break;
1444             case "dom":
1445               d.dom.open(node,el.right.html.content,lib.env.ie);
1446               break;
1447           }
1448         }
1449       }
1450     },
1451     inspector:{
1452       enabled:false,
1453       el:null,
1454       inspect:function(_element,_bgInspector){
1455         with(firebug){
1456           var pos = env.targetWindow.firebug.lib.util.Element.getPosition(_element);
1457
1458           env.targetWindow.firebug.el[_bgInspector&&"bgInspector"||"borderInspector"].environment.addStyle({ 
1459             "width":_element.offsetWidth+"px", "height":_element.offsetHeight+"px",
1460             "top":pos.offsetTop-(_bgInspector?0:2)+"px", "left":pos.offsetLeft-(_bgInspector?0:2)+"px",
1461             "display":"block"
1462           });
1463 9
1464           if(!_bgInspector){
1465             d.inspector.el = _element;
1466           }
1467         };
1468       },
1469       toggle:function(_absoluteValue,_event){
1470         with (firebug) {
1471           if(_absoluteValue==d.inspector.enabled)
1472             return;
1473           d.inspector.enabled = _absoluteValue!=undefined&&!_absoluteValue.clientX?_absoluteValue:!d.inspector.enabled;
1474           el.button.inspect.attribute[(d.inspector.enabled ? "add" : "remove") + "Class"]("Enabled");
1475           if(d.inspector.enabled==false){
1476             el.borderInspector.environment.addStyle({ "display":"none" });
1477             d.inspector.el = null;
1478           } else if(lib.env.dIndex!="html") {
1479             if (env.popupWin) {
1480               env.popupWin.firebug.d.navigate("html");
1481             } else {
1482               d.navigate("html");
1483             }
1484           }
1485         }
1486       }
1487     },
1488     scripts:{
1489       index:-1,
1490       lineNumbers:false,
1491       open:function(_index){
1492         with(firebug){
1493           d.scripts.index = _index;
1494           el.left.scripts.container.update("");
1495           var script = document.getElementsByTagName("script")[_index],uri = script.src||document.location.href,source;
1496           try {
1497             if(uri!=document.location.href){
1498               source = env.cache[uri]||lib.xhr.get(uri).responseText;
1499               env.cache[uri] = source;
1500             } else {
1501               source = script.innerHTML;
1502             }
1503             source = source.replace(/<|>/g,function(_ch){
1504               return ({"<":"&#60;",">":"&#62;"})[_ch];
1505             });
1506           
1507             if(!d.scripts.lineNumbers) 
1508               el.left.scripts.container.child.add(
1509                   new lib.element("DIV").attribute.addClass("CodeContainer").update(source)
1510               );
1511             else {
1512               source = source.split("<br />");
1513               for (var i = 0; i < source.length; i++) {
1514                 el.left.scripts.container.child.add(new lib.element("DIV").child.add(new lib.element("DIV").attribute.addClass("LineNumber").update(i + 1), new lib.element("DIV").attribute.addClass("Code").update("&nbsp;" + source[i]), new lib.element("DIV").attribute.addClass('Clear')));
1515               };
1516             };
1517           } catch(e){
1518             el.left.scripts.container.child.add(
1519               new lib.element("DIV").attribute.addClass("CodeContainer").update("<em>Access to restricted URI denied</em>")
1520             );
1521           }
1522         }
1523       },
1524       toggleLineNumbers:function(){
1525         with(firebug){
1526           d.scripts.lineNumbers = !d.scripts.lineNumbers;
1527           el.button.scripts.lineNumbers.attribute[(d.scripts.lineNumbers ? "add" : "remove") + "Class"]("Enabled");
1528           d.scripts.open( d.scripts.index );
1529         }
1530       },
1531       refresh:function(){
1532         with(firebug){
1533           el.button.scripts.selectbox.clean();
1534           var collection = env.targetWindow.document.getElementsByTagName("script");
1535           for(var i=0,len=collection.length; i<len; i++){
1536             var item = collection[i],
1537             fileName = getFileName(item.src||item.baseURI||"..");
1538             d.scripts.index=d.scripts.index<0?i:d.scripts.index;
1539             el.button.scripts.selectbox.child.add(
1540                 new lib.element("OPTION").attribute.set("value",i).update(fileName)
1541             );
1542           }
1543           d.scripts.open( d.scripts.index );
1544         }
1545       }
1546     },
1547     str: {
1548       open:function(_str){
1549         with(firebug){
1550           d.navigate("str");
1551           el.left.str.container.update(_str.replace(/\n/g,"<br />"))
1552         }
1553       }
1554     },
1555     xhr:{
1556       objects:[],
1557       addObject:function(){
1558         with(firebug){
1559           for(var i=0,len=arguments.length; i<len; i++){
1560             try {
1561               var item = arguments[i],
1562                   val = env.targetWindow.eval(item);
1563               d.xhr.objects.push([item, val]);
1564             } catch(e){
1565               continue;
1566             }
1567           }
1568         }
1569       },
1570       open:function(){
1571         with(firebug){
1572           el.left.xhr.container.update("");
1573           el.left.xhr.name = new lib.element("DIV").attribute.addClass("BlockContent").insert(new lib.element("DIV").attribute.addClass("Block").environment.addStyle({ "width":"20%" }).insert(el.left.xhr.container));
1574           el.left.xhr.nameTitle = new lib.element("STRONG").update("Object Name:").insert(el.left.xhr.name);
1575           el.left.xhr.nameContent = new lib.element("DIV").insert(el.left.xhr.name);
1576           el.left.xhr.status = new lib.element("DIV").attribute.addClass("BlockContent").insert(new lib.element("DIV").attribute.addClass("Block").environment.addStyle({ "width":"10%" }).insert(el.left.xhr.container));
1577           el.left.xhr.statusTitle = new lib.element("STRONG").update("Status:").insert(el.left.xhr.status);
1578           el.left.xhr.statusContent = new lib.element("DIV").insert(el.left.xhr.status);
1579           el.left.xhr.readystate = new lib.element("DIV").attribute.addClass("BlockContent").insert(new lib.element("DIV").environment.addStyle({ "width":"15%" }).attribute.addClass("Block").insert(el.left.xhr.container));
1580           el.left.xhr.readystateTitle =el.left.xhr.nameTitle = new lib.element("STRONG").update("Ready State:").insert(el.left.xhr.readystate);
1581           el.left.xhr.readystateContent = new lib.element("DIV").insert(el.left.xhr.readystate);
1582           el.left.xhr.response = new lib.element("DIV").attribute.addClass("BlockContent").insert(new lib.element("DIV").environment.addStyle({ "width":(lib.env.ie?"50":"55")+"%" }).attribute.addClass("Block").insert(el.left.xhr.container));
1583           el.left.xhr.responseTitle = new lib.element("STRONG").update("Response:").insert(el.left.xhr.response);
1584           el.left.xhr.responseContent = new lib.element("DIV").insert(el.left.xhr.response);
1585           setTimeout(d.xhr.refresh,500);
1586         }
1587       },
1588       refresh:function(){
1589         with(firebug){
1590           el.left.xhr.nameContent.update("");
1591           el.left.xhr.statusContent.update("");
1592           el.left.xhr.readystateContent.update("");
1593           el.left.xhr.responseContent.update("");
1594           for(var i=0,len=d.xhr.objects.length; i<len; i++){
1595             var item = d.xhr.objects[i],
1596                 response = item[1].responseText;
1597             if(Boolean(item[1])==false)continue;
1598             el.left.xhr.nameContent.child.add(new lib.element("span").update(item[0]));
1599             try {
1600               el.left.xhr.statusContent.child.add(new lib.element("span").update(item[1].status));
1601             } catch(e){ el.left.xhr.statusContent.child.add(new lib.element("span").update("&nbsp;")); }
1602             el.left.xhr.readystateContent.child.add(new lib.element("span").update(item[1].readyState));
1603
1604             el.left.xhr.responseContent.child.add(new lib.element("span").child.add(
1605                 new lib.element("A").event.addListener("click",lib.util.Curry(d.str.open,window,response)).update("&nbsp;"+response.substring(0,50))
1606             ));
1607           };
1608           if(env.dIndex=="xhr")
1609             setTimeout(d.xhr.refresh,500);
1610         }
1611       }
1612     },
1613     navigateRightColumn:function(_index,_open){
1614       with(firebug){
1615         el.left.container.environment.addStyle({ "width":_open?"70%":"100%" });
1616         el.right.container.environment.addStyle({ "display":_open?"block":"none" });
1617       }
1618     },
1619     navigate:function(_index){
1620       with(firebug){
1621         var open = _index, close = env.dIndex;
1622         env.dIndex = open;
1623
1624         settings.hide();
1625
1626         el.button[close].container.environment.addStyle({ "display":"none" });
1627         el.left[close].container.environment.addStyle({ "display":"none" });
1628         el.right[close].container.environment.addStyle({ "display":"none" });
1629
1630         el.button[open].container.environment.addStyle({ "display":"inline" });
1631         el.left[open].container.environment.addStyle({ "display":"block" });
1632         el.right[open].container.environment.addStyle({ "display":"block" });
1633
1634         if(el.nav[close])
1635           el.nav[close].attribute.removeClass("Selected");
1636         if(el.nav[open])
1637           el.nav[open].attribute.addClass("Selected");
1638
1639         switch(open){
1640           case "console":
1641             d.navigateRightColumn(_index);
1642             break;
1643           case "html":
1644             d.navigateRightColumn(_index,true);
1645             if(!d.html.current){
1646               var t=Number(new Date);
1647               d.html.openHtmlTree();
1648             }
1649             break;
1650           case "css":
1651             d.navigateRightColumn(_index,true);
1652             d.css.refresh();
1653             break;
1654           case "scripts":
1655             d.navigateRightColumn(_index);
1656             d.scripts.refresh();
1657             break;
1658           case "dom":
1659             d.navigateRightColumn(_index);
1660             if(el.left.dom.container.environment.getElement().innerHTML==""){
1661               var t=Number(new Date);
1662               d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
1663             }
1664             break;
1665           case "xhr":
1666             d.navigateRightColumn(_index);
1667             d.xhr.open();
1668             break;
1669         }
1670       }
1671     }
1672   },
1673   getFileName:function(_path){
1674     var match = _path&&_path.match(/[\w\-\.\?\=\&]+$/);
1675     return match&&match[0]||_path;
1676   },
1677   cancelEvent:function(_event){
1678     if(_event.stopPropagation)
1679       _event.stopPropagation();
1680     if(_event.preventDefault)
1681       _event.preventDefault();
1682   },
1683   getSelection:function(_el){
1684     with(firebug){
1685       if(lib.env.ie){
1686         var range = document.selection.createRange(),stored = range.duplicate();
1687         stored.moveToElementText(_el);
1688         stored.setEndPoint('EndToEnd', range);
1689         _el.selectionStart = stored.text.length - range.text.length;
1690         _el.selectionEnd = _el.selectionStart + range.text.length;
1691       }
1692       return {
1693         start:_el.selectionStart,
1694         length:_el.selectionEnd-_el.selectionStart
1695       }
1696     }
1697   },
1698   tab:function(_el,_event){
1699     with(firebug){
1700       if(_event.keyCode==9){
1701         if(_el.setSelectionRange){
1702           var position = firebug.getSelection(_el);
1703           _el.value = _el.value.substring(0,position.start) + String.fromCharCode(9) + _el.value.substring(position.start+position.length,_el.value.length);
1704           _el.setSelectionRange(position.start+1,position.start+1);
1705         } else if(document.selection) {  
1706           var range = document.selection.createRange(), isCollapsed = range.text == '';
1707           range.text = String.fromCharCode(9);
1708           range.moveStart('character', -1);
1709         }
1710         firebug.cancelEvent(_event);
1711         if(lib.env.ie)
1712           setTimeout(_el.focus,100);
1713       };
1714     }
1715   },
1716   listen: {
1717     addXhrObject:function(){
1718       with(firebug){
1719         d.xhr.addObject.apply(env.targetWindow, el.button.xhr.textbox.environment.getElement().value.split(","));
1720       }
1721     },
1722     consoleTextbox:function(_event){
1723       with(firebug){
1724         if(_event.keyCode==13&&(env.multilinemode==false||_event.shiftKey==false)){
1725           d.console.historyIndex = d.console.history.length;
1726           d.console.eval(el.left.console.input.environment.getElement().value);
1727           return false;
1728         }
1729
1730         switch(_event.keyCode){
1731           case 40:
1732             if(d.console.history[d.console.historyIndex+1]){
1733               d.console.historyIndex+=1;
1734               el.left.console.input.update( d.console.history[d.console.historyIndex] );
1735             }
1736             break;
1737           case 38:
1738             if(d.console.history[d.console.historyIndex-1]){
1739               d.console.historyIndex-=1;
1740               el.left.console.input.update( d.console.history[d.console.historyIndex] );
1741             }
1742             break;
1743         }
1744       }
1745     },
1746     cssSelectbox:function(){
1747       with(firebug){
1748         d.css.open(el.button.css.selectbox.environment.getElement().selectedIndex);
1749       }
1750     },
1751     domTextbox:function(_event){
1752       with(firebug){
1753         if(_event.keyCode==13){
1754           d.dom.open(eval(el.button.dom.textbox.environment.getElement().value),el.left.dom.container);
1755         }
1756       }
1757     },
1758     inspector:function(){
1759       with(firebug){
1760         if (env.popupWin) {
1761           env.popupWin.firebug.d.html.inspect(firebug.d.inspector.el);
1762         } else {
1763           firebug.d.html.inspect(firebug.d.inspector.el);
1764         }
1765       }
1766     },
1767     keyboard:function(_event){
1768       with(firebug){
1769         if(_event.keyCode==27 && d.inspector.enabled){
1770           d.inspector.toggle();
1771         } else if(_event.keyCode === 123 && _event.ctrlKey || _event.metaKey) {
1772           if(env.isPopup){
1773             win.dock();
1774           }else {
1775             win.newWindow();
1776           }
1777         } else if(
1778             (_event.keyCode === 123 && !_event.ctrlKey && !_event.metaKey) || 
1779             (_event.keyCode === 76 && (_event.ctrlKey || _event.metaKey) && _event.shiftKey) ||
1780             (_event.keyCode === 13 && _event.shiftKey)) {
1781
1782           if(env.isPopup){
1783             win.dock();
1784           } else if (el.main.environment.getStyle("display") === 'none') {
1785             win.show();
1786           } else {
1787             win.hide();
1788           }
1789         }
1790       }
1791     },
1792     mouse:function(_event){
1793       with(firebug){
1794         var target;
1795         
1796         if(document.elementFromPoint) {
1797           target = document.elementFromPoint(_event.clientX, _event.clientY);
1798         } else {
1799           if(lib.env.ie) {
1800             target = _event.srcElement;
1801           } else {
1802             target = _event.explicitOriginalTarget || _event.target;
1803           }
1804         }
1805         
1806         if( d.inspector.enabled&&
1807           target!=document.body&&
1808           target!=document.firstChild&&
1809           target!=document.childNodes[1]&&
1810           target!=el.borderInspector.environment.getElement()&&
1811           target!=el.main.environment.getElement()&&
1812           target.offsetParent!=el.main.environment.getElement() ) {
1813             d.inspector.inspect(target);
1814         }
1815       }
1816     },
1817     runMultiline:function(){
1818       with(firebug){
1819         d.console.eval.call(window,el.right.console.input.environment.getElement().value);
1820       }
1821     },
1822     runCSS:function(){
1823       with(firebug){
1824         var source = el.right.css.input.environment.getElement().value.replace(/\n|\t/g,"").split("}");
1825         for(var i=0, len=source.length; i<len; i++){
1826           var item = source[i]+"}", rule = !lib.env.ie?item:item.split(/{|}/),
1827               styleSheet = document.styleSheets[0];
1828           console.log(rule);
1829           if(item.match(/.+\{.+\}/)){
1830             if(lib.env.ie)
1831               styleSheet.addRule(rule[0],rule[1]);
1832             else
1833               styleSheet.insertRule( rule, styleSheet.cssRules.length );
1834           }
1835         }
1836       }
1837     },
1838     scriptsSelectbox:function(){
1839       with(firebug){
1840         d.scripts.open(parseInt(el.button.scripts.selectbox.environment.getElement().value));
1841       }
1842     },
1843     xhrTextbox:function(_event){
1844       with(firebug){
1845         if(_event.keyCode==13){
1846           d.xhr.addObject.apply(env.targetWindow, el.button.xhr.textbox.environment.getElement().value.split(","));
1847         }
1848       }
1849     }
1850   }
1851 };
1852
1853 (function(_scope){
1854   _scope.lib = {};
1855   var pi  = _scope.lib; pi.version = [1.1,2008091000];
1856
1857   pi.env = {
1858     ie: /MSIE/i.test(navigator.userAgent),
1859     ie6: /MSIE 6/i.test(navigator.userAgent),
1860     ie7: /MSIE 7/i.test(navigator.userAgent),
1861     ie8: /MSIE 8/i.test(navigator.userAgent),
1862     firefox: /Firefox/i.test(navigator.userAgent),
1863     opera: /Opera/i.test(navigator.userAgent),
1864     webkit: /Webkit/i.test(navigator.userAgent),
1865     camino: /Camino/i.test(navigator.userAgent)
1866   };
1867
1868   pi.get = function(){
1869     return document.getElementById(arguments[0]);
1870   };
1871   pi.get.byTag = function(){
1872     return document.getElementsByTagName(arguments[0]);
1873   };
1874   pi.get.byClass = function(){ return document.getElementsByClassName.apply(document,arguments); };
1875
1876   pi.util = {
1877     Array:{
1878       clone:function(_array,_undeep){
1879         var tmp = [];
1880         Array.prototype.push.apply(tmp,_array);
1881         pi.util.Array.forEach(tmp,function(_item,_index,_source){
1882           if(_item instanceof Array&&!_undeep)
1883             _source[_index] = pi.util.Array.clone(_source[_index]);
1884         });
1885         return tmp;
1886       },
1887       count:function(_array,_value){
1888         var count = 0;
1889         pi.util.Array.forEach(_array,function(){
1890           count+=Number(arguments[0]==_value);
1891         });
1892         return count;
1893       },
1894       forEach:function(_array,_function){
1895         if(_array.forEach)
1896           return _array.forEach(_function);
1897         for(var i=0,len=_array.length; i<len; i++)
1898           _function.apply(_array,[_array[i],i,_array]);   
1899       },
1900       getLatest:function(_array){
1901         return _array[_array.length-1];
1902       },
1903       indexOf:function(_array,_value){
1904         if(!pi.env.ie){
1905           return _array.indexOf(_value);
1906         };
1907
1908         var index = -1;
1909         for(var i=0, len=_array.length; i<len; i++){
1910           if(_array[i]==_value){
1911             index = i;
1912             break;
1913           }
1914         }
1915         return index;
1916       },
1917       remove:function(_array,_index){
1918         var result = _array.slice(0,_index);
1919         _array = Array.prototype.push.apply(result,_array.slice(_index+1));
1920         return result;
1921       }
1922     },
1923     Curry:function(_fn,_scope){
1924       var fn = _fn, scope = _scope||window, args = Array.prototype.slice.call(arguments,2);
1925       return function(){ 
1926         return fn.apply(scope,args.concat( Array.prototype.slice.call(arguments,0) )); 
1927       };
1928     },
1929     Extend:function(_superClass,_prototype,_skipClonning){
1930       var object = new pi.base;
1931       if(_prototype["$Init"]){
1932         object.init = _prototype["$Init"];
1933         delete _prototype["$Init"];
1934       };
1935
1936       object.body = _superClass==pi.base?_prototype:pi.util.Hash.merge(_prototype,_superClass.prototype);
1937       object.init=object.init||function(){
1938         if(_superClass!=pi.base)
1939           _superClass.apply(this,arguments);
1940       };
1941
1942       return object.build(_skipClonning);
1943     },
1944     IsArray:function(_object){
1945       if(_object===null){
1946         return false;
1947       }
1948       if(window.NodeList&&window.NamedNodeMap&&!pi.env.ie8){
1949         if(_object instanceof Array||_object instanceof NodeList||_object instanceof NamedNodeMap||(window.HTMLCollection&&_object instanceof HTMLCollection))
1950           return true;
1951       };
1952       if(!_object||_object==window||typeof _object=="function"||typeof _object=="string"||typeof _object.length!="number"){
1953         return false
1954       };
1955       var len = _object.length;
1956       if(len>0&&_object[0]!=undefined&&_object[len-1]!=undefined){
1957         return true;
1958       } else {
1959         for(var key in _object){
1960           if(key!="item"&&key!="length"&&key!="setNamedItemNS"&&key!="setNamedItem"&&key!="getNamedItem"&&key!="removeNamedItem"&&key!="getNamedItemNS"&&key!="removeNamedItemNS"&&key!="tags"){
1961             return false;
1962           }
1963         }
1964         return true
1965       };
1966     },
1967     IsHash:function(_object){
1968       return _object && typeof _object=="object"&&(_object==window||_object instanceof Object)&&!_object.nodeName&&!pi.util.IsArray(_object)
1969     },
1970     Init:[],
1971     AddEvent: function(_element,_eventName,_fn,_useCapture){
1972       _element[pi.env.ie?"attachEvent":"addEventListener"]((pi.env.ie?"on":"")+_eventName,_fn,_useCapture||false);
1973       return pi.util.Curry(pi.util.AddEvent,this,_element);
1974     },
1975     RemoveEvent: function(_element,_eventName,_fn,_useCapture){
1976       _element[pi.env.ie?"detachEvent":"removeEventListener"]((pi.env.ie?"on":"")+_eventName,_fn,_useCapture||false);
1977       return pi.util.Curry(pi.util.RemoveEvent,this,_element);
1978     },
1979     Element:{
1980       addClass:function(_element,_class){
1981         if( !pi.util.Element.hasClass(_element,_class) )
1982           pi.util.Element.setClass(_element, pi.util.Element.getClass(_element) + " " + _class );
1983       },
1984       getClass:function(_element){
1985         return _element.getAttribute(pi.env.ie&&!pi.env.ie8?"className":"class")||"";
1986       },
1987       hasClass:function(_element,_class){
1988         return pi.util.Array.indexOf(pi.util.Element.getClass(_element).split(" "),_class)>-1;
1989       },
1990       removeClass:function(_element,_class){
1991         if( pi.util.Element.hasClass(_element,_class) ){
1992           var names = pi.util.Element.getClass(_element,_class).split(" ");
1993           pi.util.Element.setClass(
1994               _element, 
1995               pi.util.Array.remove(names,pi.util.Array.indexOf(names,_class)).join(" ")
1996           );
1997         }
1998       },
1999       setClass:function(_element,_value){
2000         if(pi.env.ie8){
2001           _element.setAttribute("className", _value );
2002           _element.setAttribute("class", _value );
2003         } else {
2004           _element.setAttribute(pi.env.ie?"className":"class", _value );
2005         }
2006       },
2007       toggleClass:function(){
2008         if(pi.util.Element.hasClass.apply(this,arguments))
2009           pi.util.Element.removeClass.apply(this,arguments);
2010         else
2011           pi.util.Element.addClass.apply(this,arguments);
2012       },
2013       getOpacity:function(_styleObject){
2014         var styleObject = _styleObject;
2015         if(!pi.env.ie)
2016           return styleObject["opacity"];
2017
2018         var alpha = styleObject["filter"].match(/opacity\=(\d+)/i);
2019         return alpha?alpha[1]/100:1;
2020       },
2021       setOpacity:function(_element,_value){
2022         if(!pi.env.ie)
2023           return pi.util.Element.addStyle(_element,{ "opacity":_value });
2024         _value*=100;
2025         pi.util.Element.addStyle(_element,{ "filter":"alpha(opacity="+_value+")" });
2026         return this._parent_;
2027       },
2028       getPosition:function(_element){
2029         var parent = _element,offsetLeft = document.body.offsetLeft, offsetTop = document.body.offsetTop, view = pi.util.Element.getView(_element);
2030         while(parent&&parent!=document.body&&parent!=document.firstChild){
2031           offsetLeft +=parseInt(parent.offsetLeft);
2032           offsetTop += parseInt(parent.offsetTop);
2033           parent = parent.offsetParent;
2034         };
2035         return {
2036           "bottom":view["bottom"],
2037           "clientLeft":_element.clientLeft,
2038           "clientTop":_element.clientTop,
2039           "left":view["left"],
2040           "marginTop":view["marginTop"],
2041           "marginLeft":view["marginLeft"],
2042           "offsetLeft":offsetLeft,
2043           "offsetTop":offsetTop,
2044           "position":view["position"],
2045           "right":view["right"],
2046           "top":view["top"],
2047           "zIndex":view["zIndex"]
2048         };
2049       },
2050       getSize:function(_element){
2051         var view = pi.util.Element.getView(_element);
2052         return {
2053           "height":view["height"],
2054           "clientHeight":_element.clientHeight,
2055           "clientWidth":_element.clientWidth,
2056           "offsetHeight":_element.offsetHeight,
2057           "offsetWidth":_element.offsetWidth,
2058           "width":view["width"]
2059         }
2060       },
2061       addStyle:function(_element,_style){
2062         for(var key in _style){
2063           key = key=="float"?pi.env.ie?"styleFloat":"cssFloat":key;
2064           if (key == "opacity" && pi.env.ie) {
2065             pi.util.Element.setOpacity(_element,_style[key]);
2066             continue;
2067           }
2068           try {
2069             _element.style[key] = _style[key];
2070           }catch(e){}     
2071         }
2072       },
2073       getStyle:function(_element,_property){
2074         _property = _property=="float"?pi.env.ie?"styleFloat":"cssFloat":_property;
2075         if(_property=="opacity"&&pi.env.ie)
2076           return pi.util.Element.getOpacity(_element.style);
2077         return typeof _property=="string"?_element.style[_property]:_element.style;
2078       },
2079       getValue:function(_element){
2080         switch(_element.nodeName.toLowerCase()){
2081           case "input":
2082           case "textarea":
2083             return _element.value;
2084           case "select":
2085             return _element.options[_element.selectedIndex].value;
2086           default:
2087             return _element.innerHTML;
2088           break;
2089         }
2090       },
2091       getView:function(_element,_property){
2092         var view = document.defaultView?document.defaultView.getComputedStyle(_element,null):_element.currentStyle;
2093         _property = _property=="float"?pi.env.ie?"styleFloat":"cssFloat":_property;
2094         if(_property=="opacity"&&pi.env.ie)
2095           return pi.util.Element.getOpacity(_element,view);
2096         return typeof _property=="string"?view[_property]:view;
2097       }
2098     },
2099     Hash: {
2100       clone:function(_hash,_undeep){
2101         var tmp = {};
2102         for(var key in _hash){
2103           if( !_undeep&&pi.util.IsArray( _hash[key] ) ){
2104             tmp[key] = pi.util.Array.clone( _hash[key] );
2105           } else if( !_undeep&&pi.util.IsHash( _hash[key] ) ){
2106             tmp[ key ] = pi.util.Hash.clone(_hash[key]);
2107           } else {
2108             tmp[key] = _hash[key];
2109           }
2110         }
2111         return tmp;
2112       },
2113       merge:function(_hash,_source,_undeep){
2114         for(var key in _source){
2115           var value = _source[key];
2116           if (!_undeep&&pi.util.IsArray(_source[key])) {
2117             if(pi.util.IsArray( _hash[key] )){
2118               Array.prototype.push.apply( _source[key], _hash[key] )
2119             }
2120             else
2121               value = pi.util.Array.clone(_source[key]);
2122           }
2123           else if (!_undeep&&pi.util.IsHash(_source[key])) {
2124             if (pi.util.IsHash(_hash[key])) {
2125               value = pi.util.Hash.merge(_hash[key], _source[key]);
2126             } else {
2127               value = pi.util.Hash.clone( _source[key] );
2128             }
2129           } else if( _hash[key] )
2130             value = _hash[ key ];
2131           _hash[key] = value;
2132         };
2133         return _hash;
2134       }
2135     },
2136     String:{
2137       format:function(_str){
2138         var values = Array.prototype.slice.call(arguments,1);
2139         return _str.replace(/\{(\d)\}/g,function(){
2140           return values[arguments[1]];
2141         })
2142       }
2143     },
2144     GetViewport:function(){
2145       return {
2146         height:document.documentElement.clientHeight||document.body.clientHeight,
2147         width:document.documentElement.clientWidth||document.body.clientWidth
2148       }
2149     }
2150   };
2151
2152   pi.base = function(){
2153     this.body = {};
2154     this.init = null;
2155
2156     this.build = function(_skipClonning){
2157       var base = this, skipClonning = _skipClonning||false, _private = {},
2158       fn = function(){
2159         var _p = pi.util.Hash.clone(_private);
2160         if(!skipClonning){
2161           for(var key in this){
2162             if(pi.util.IsArray( this[ key ] ) ){
2163               this[key] = pi.util.Array.clone( this[key] );
2164             } else
2165               if( pi.util.IsHash(this[key]) ){
2166                 this[key] = pi.util.Hash.clone( 
2167                     this[ key ],
2168                     function(_key,_object){
2169                       this[ _key ]._parent_ = this;
2170                     }
2171                 );
2172                 //this[key]._parent_ = this;
2173               }
2174           }
2175         };
2176         base.createAccessors( _p, this );
2177         if(base.init)
2178           return base.init.apply(this,arguments);
2179         return this;
2180       };
2181       this.movePrivateMembers(this.body,_private);
2182       if(this.init){
2183         fn["$Init"] = this.init;
2184       };
2185       fn.prototype = this.body;
2186       return fn;
2187     };
2188
2189     this.createAccessors = function(_p, _branch){
2190       var getter = function(_property){ return this[_property]; },
2191       setter = function(_property,_value){ this[_property] = _value; return _branch._parent_||_branch; };
2192
2193       for (var name in _p) {
2194         var isPrivate = name.substring(0, 1) == "_", title = name.substring(1, 2).toUpperCase() + name.substring(2);
2195
2196         if (isPrivate) {
2197           _branch[(_branch["get" + title]?"_":"")+"get" + title] = pi.util.Curry(getter,_p,name);
2198           _branch[(_branch["set" + title]?"_":"")+"set" + title] = pi.util.Curry(setter,_p,name);
2199         }
2200         else 
2201           if (pi.util.IsHash(_p[name])){
2202             _branch[name]._parent_ = _branch;
2203             if(!_branch[name])
2204               _branch[name] = {};
2205             this.createAccessors(_p[name], _branch[name]);
2206           }   
2207       };
2208     };
2209
2210     this.movePrivateMembers = function(_object, _branch){
2211       for (var name in _object) {
2212         var isPrivate = name.substring(0, 1) == "_";
2213
2214         if (isPrivate) {
2215           _branch[name] = _object[name];
2216           delete _object[name];
2217         }
2218         else 
2219           if (pi.util.IsHash(_object[name])){
2220             _branch[name] = {};
2221             this.movePrivateMembers(_object[name], _branch[name]);
2222           }
2223       };
2224     };
2225   };
2226
2227   pi.element = new pi.base;
2228   pi.element.init = function(_val){
2229     this.environment.setElement(
2230         typeof _val=="string"||!_val?
2231             document.createElement(_val||"DIV"):
2232               _val
2233     );
2234     return this;
2235   };
2236
2237   pi.element.body = {
2238     "addStyle":function(){
2239       return this.environment.addStyle.apply(this.environment,arguments);
2240     },
2241     "clean":function(){
2242       var childs = this.child.get();
2243       while(childs.length){
2244         childs[0].parentNode.removeChild(childs[0]);
2245       }
2246     },
2247     "clone":function(_deep){
2248       return this.environment.getElement().cloneNode(_deep);
2249     },
2250     "insert":function(_element){
2251       _element = _element.environment?_element.environment.getElement():_element;
2252       _element.appendChild(this.environment.getElement());
2253       return this;
2254     },
2255     "insertAfter":function(_referenceElement){
2256       _referenceElement = _referenceElement.environment?_referenceElement.environment.getElement():_referenceElement;
2257       _referenceElement.nextSibling?this.insertBefore(_referenceElement.nextSibling):this.insert(_referenceElement.parentNode);
2258       return this;
2259     },
2260     "insertBefore":function(_referenceElement){
2261       _referenceElement = _referenceElement.environment?_referenceElement.environment.getElement():_referenceElement;
2262       _referenceElement.parentNode.insertBefore(this.environment.getElement(),_referenceElement);
2263       return this;
2264     },
2265     "query":function(_expression,_resultType,namespaceResolver,_result){
2266       return pi.xpath(_expression,_resultType||"ORDERED_NODE_SNAPSHOT_TYPE",this.environment.getElement(),_namespaceResolver,_result);
2267     },
2268     "remove":function(){
2269       if (this.environment.getParent()) {
2270         this.environment.getParent().removeChild(this.environment.getElement());
2271       }
2272     },
2273     "update":function(_value){
2274       this.element[this.element.nodeName.toLowerCase()=="textarea"||this.element.nodeName.toLowerCase()=="input"?"value":"innerHTML"]=_value;
2275       return this;
2276     },
2277     "attribute":{
2278       "getAll":function(){
2279         return this._parent_.environment.getElement().attributes;
2280       },
2281       "clear":function(_name){
2282         this.set(_name,"");
2283         return this._parent_;
2284       },
2285       "get":function(_name){
2286         return this._parent_.environment.getElement().getAttribute(_name);
2287       },
2288       "has":function(_name){
2289         return pi.env.ie?(this.get(_name)!=null):this._parent_.environment.getElement().hasAttribute(_name);
2290       },
2291       "remove":function(_name){
2292         this._parent_.environment.getElement().removeAttribute(_name);
2293         return this._parent_;
2294       },
2295       "set":function(_name,_value){
2296         this._parent_.environment.getElement().setAttribute(_name,_value);
2297         return this._parent_;
2298       },
2299       "addClass":function(_classes){
2300         for(var i=0,len=arguments.length; i<len; i++){
2301           pi.util.Element.addClass(this._parent_.environment.getElement(),arguments[i]);
2302         };
2303         return this._parent_;
2304       },
2305       "clearClass":function(){
2306         this.setClass("");
2307         this._parent_;
2308       },
2309       "getClass":function(){
2310         return pi.util.Element.getClass( this._parent_.environment.getElement() );
2311       },
2312       "hasClass":function(_class){
2313         return pi.util.Element.hasClass( this._parent_.environment.getElement(), _class );
2314       },
2315       "setClass":function(_value){
2316         return pi.util.Element.setClass( this._parent_.environment.getElement(), _value );
2317       },
2318       "removeClass":function(_class){
2319         pi.util.Element.removeClass( this._parent_.environment.getElement(), _class );
2320         return this._parent_;
2321       },
2322       "toggleClass":function(_class){
2323         pi.util.Element.toggleClass( this._parent_.environment.getElement(), _class );
2324       }
2325     },
2326     "child":{
2327       "get":function(){
2328         return this._parent_.environment.getElement().childNodes;
2329       },
2330       "add":function(_elements){
2331         for (var i = 0; i < arguments.length; i++) {
2332           var el = arguments[i];
2333           this._parent_.environment.getElement().appendChild(
2334               el.environment ? el.environment.getElement() : el
2335           );
2336         }
2337         return this._parent_;
2338       },
2339       "addAfter":function(_element,_referenceElement){
2340         this.addBefore(
2341             _element.environment?_element.environment.getElement():_element,
2342                 (_referenceElement.environment?_referenceElement.environment.getElement():_referenceElement).nextSibling
2343         );
2344         return this._parent_;
2345       },
2346       "addBefore":function(_element,_referenceElement){
2347         this._parent_.environment.getElement().insertBefore(
2348             _element.environment?_element.environment.getElement():_element,
2349                 _referenceElement.environment?_referenceElement.environment.getElement():_referenceElement
2350         );
2351         return this._parent_;
2352       },
2353       "remove":function(_element){
2354         this._parent_.environment.getElement().removeChild(_element.environment?_element.environment.getElement():_element);
2355       }
2356     },
2357     "environment":{
2358       "_element":null,
2359       "setElement":function(_value){
2360         this._parent_.element = _value;
2361         this._parent_.element.lib = this._parent_;
2362         this._parent_.element.firebugElement = true;
2363         this._setElement(_value);
2364       },
2365       "getParent":function(){
2366         return this.getElement().parentNode;
2367       },
2368       "getPosition":function(){
2369         return pi.util.Element.getPosition(this.getElement());
2370       },
2371       "getSize":function(){
2372         return pi.util.Element.getSize( this.getElement() );
2373       },
2374       "addStyle":function(_styleObject){
2375         pi.util.Element.addStyle(this.getElement(),_styleObject);
2376         return this._parent_;
2377       },
2378       "getStyle":function(_property){
2379         return pi.util.Element.getStyle(this.getElement(),_property);
2380       },
2381       "getName":function(){
2382         return this.getElement().nodeName;
2383       },
2384       "getType":function(){
2385         return this.getElement().nodeType;
2386       },
2387       "getValue":function(){
2388         return pi.util.Element.getValue(this.getElement());
2389       },
2390       "getView":function(_property){
2391         return pi.util.Element.getView(this.getElement(),_property);
2392       }
2393     },
2394     "event":{
2395       "addListener":function(_event,_fn,_useCapture){
2396         pi.util.AddEvent(this._parent_.environment.getElement(),_event,_fn,_useCapture);
2397         return this._parent_;
2398       },
2399       "removeListener":function(_event,_fn,_useCapture){
2400         pi.util.RemoveEvent(this._parent_.environment.getElement(),_event,_fn,_useCapture);
2401         return this._parent_;
2402       }
2403     }
2404   };
2405   pi.element = pi.element.build();
2406
2407   pi.xhr = new pi.base;
2408   pi.xhr.init = function(_url){
2409     if(!window.XMLHttpRequest){
2410       var names = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
2411       for (var i = 0; i < names.length; i++) {
2412         try {
2413           this.environment.setApi(new ActiveXObject(names[i]));
2414           break;
2415         } catch (e) { continue; }
2416       }
2417     }
2418     else {
2419       this.environment.setApi(new XMLHttpRequest());
2420     }
2421     this.environment.getApi().onreadystatechange=pi.util.Curry(this.event.readystatechange,this);
2422     this.environment.setUrl(_url);
2423     this.environment.setCallback([]);
2424
2425     return this;
2426   };
2427   pi.xhr.body = {
2428     "addCallback": function(){
2429       return this.environment.addCallback.apply(this.environment,arguments);
2430     },
2431     "addData": function(){
2432       return this.environment.addData.apply(this.environment,arguments);
2433     },
2434     "abort":function(){
2435       this.environment.getApi().abort();
2436       return this;
2437     },
2438     "send":function(){
2439       var url = this.environment.getUrl(), data = this.environment.getData(),dataUrl = ""; 
2440
2441       if(!this.environment.getCache())
2442         data["forceCache"] = Number(new Date);
2443
2444       for (var key in data)
2445         dataUrl += pi.util.String.format("{0}={1}&",key, data[key]);
2446
2447       if (this.environment.getType()=="GET")
2448         url += (url.search("\\?")==-1?"?":"&")+pi.util.String.format("{0}",dataUrl);
2449
2450       this.api.open(this.environment.getType(),url,this.environment.getAsync());
2451       if(this.environment.getType()=="POST"){
2452         this.api.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
2453       };
2454       this.api.send(this.environment.getType()=="GET"?"":dataUrl);
2455       return this;
2456     }
2457   };
2458   pi.xhr.body.environment = {
2459     "_async":true, "_api":null, "_cache":true, "_callback":null, "_data":{}, "_type":"GET", "_url":"",
2460     "setApi":function(_value){
2461       this._parent_.api = _value;
2462       this._setApi(_value);
2463     },
2464     "addCallback": function(_readyState,_fn){
2465       this.getCallback().push({ "fn":_fn, "readyState":_readyState  });
2466       return this._parent_;
2467     },
2468     "addData": function(_key,_value){
2469       this.getData()[_key] = _value;
2470       return this._parent_;
2471     },
2472     "setType": function(_value){
2473       this._setType(_value);
2474       return this._parent_;
2475     }
2476   };
2477   pi.xhr.body.event = {
2478     "readystatechange":function(){
2479       var readyState = this.environment.getApi().readyState, callback=this.environment.getCallback();
2480       for (var i = 0, len=callback.length; i < len; i++) {
2481         if(pi.util.Array.indexOf(callback[i].readyState,readyState)>-1){
2482           callback[i].fn.apply(this);
2483         }
2484       }
2485     }
2486   };
2487   pi.xhr = pi.xhr.build();
2488
2489   /*
2490    * xml.xhr.get
2491    */
2492
2493   pi.xhr.get = function(_url,_returnPiObject){
2494     var request = new pi.xhr();
2495     request.environment.setAsync(false);
2496     request.environment.setUrl(_url);
2497     request.send();
2498     return _returnPiObject?request:request.environment.getApi();
2499   };
2500
2501   /*
2502    * registering onload event for init functions
2503    */
2504   pi.util.AddEvent(
2505     pi.env.ie?window:document,
2506     pi.env.ie?"load":"DOMContentLoaded",
2507     function(){
2508       for(var i=0,len=pi.util.Init.length; i<len; i++){
2509         pi.util.Init[ i ]();
2510       }
2511     }
2512   );
2513 })(firebug);
2514
2515 with(firebug){
2516   initConsole();
2517   lib.util.Init.push(firebug.init);
2518 }