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