var jBugConf={width:600,height:600};var gWindow={};var oActiveLoadDiv={};var gDumpCounter=1;jBug=function(object,debugname){var bWindowOpen=(typeof gWindow.closed==="undefined"||gWindow.closed===true)?false:true;var sContent="";var bContentExists=false;var sDebugName=(typeof debugname=='undefined')?"&nbsp;":debugname;var sCurrentUrl=location.href;var sWindowName='jBugWindow_'+sCurrentUrl.replace(/[^a-zA-Z 0-9]+/g,'');var sWindowTitle='jBug for '+sCurrentUrl;sContent+=(/string|number|undefined|boolean/.test(typeof(object))||object===null)?_jBugHtmlSpecialChars(object):recurse(object,typeof object);if(!bWindowOpen){var iLeftPosition=screen.width?(screen.width-jBugConf.width)/2:0;var iTopPosition=screen.height?(screen.height-jBugConf.height)/2:0;var sSettings='height='+jBugConf.height+',width='+jBugConf.width+',top='+iTopPosition+',left='+iLeftPosition+',location=no,toolbar=no,scrollbars=yes,menubar=no,status=no,resizable=yes';gWindow=window.open('about:blank',sWindowName,sSettings);}bContentExists=(gWindow.document.getElementById("loadcounter")===null)?false:true;if(!bContentExists){var sScript='function tRow(s) {t = s.parentNode.lastChild;tTarget(t, tSource(s)) ;}function tTable(s) {var switchToState = tSource(s) ;var table = s.parentNode.parentNode;for (var i = 1; i < table.childNodes.length; i++) {t = table.childNodes[i] ;if (t.style) {tTarget(t, switchToState);}}}function tSource(s) {if (s.style.fontStyle == "italic" || s.style.fontStyle == null) {s.style.fontStyle = "normal";s.title = "click to collapse";return "open";} else {s.style.fontStyle = "italic";s.title = "click to expand";return "closed" ;}}function tTarget (t, switchToState) {if (switchToState == "open") {t.style.display = "";} else {t.style.display = "none";}}';var sDebugHeader='<input type="hidden" value="0" id="loadcounter" /><table id="debugheader" width="100%" cellpadding="3" cellspacing="0" border="1" style="font-family:Arial; font-size:12px; font-weight:bold; border-collapse:collapse; background-color:#a9c95d;"><tr><td style="border:1px solid #888888;">'+sWindowTitle+'</td><td style="border:1px solid #888888; width:50px; cursor:pointer; background-color:#FC422A;" align="center" id="act_clearall">Clear all</td></tr></table>';var sDebugContainer='<div id="debugcontent"></div>';gWindow.document.write('<html><head><title> '+sWindowTitle+' </title><script type="text/javascript">'+sScript+'</script><head><body>'+sDebugHeader+sDebugContainer+'</body></html>');gWindow.document.body.innerHTML=sDebugHeader+sDebugContainer;}gWindow.document.getElementById("act_clearall").onclick=function(){jBugClear();};if(gDumpCounter===1){gWindow.document.getElementById("loadcounter").value=parseInt(gWindow.document.getElementById("loadcounter").value)+1;var oDate=new Date();var sLoadDate=((oDate.getHours()<10)?"0":"")+oDate.getHours()+":"+((oDate.getMinutes()<10)?"0":"")+oDate.getMinutes()+":"+((oDate.getSeconds()<10)?"0":"")+oDate.getSeconds();var oContentLoadDiv=gWindow.document.createElement("div");oContentLoadDiv.id="jbug_load_"+gWindow.document.getElementById("loadcounter").value;oContentLoadDiv.style.backgroundColor="#EEEEEE";oContentLoadDiv.style.border="1px solid #888888";oContentLoadDiv.style.fontFamily="Arial";oContentLoadDiv.style.marginTop="10px";var oLoadTitleDiv=gWindow.document.createElement("div");oLoadTitleDiv.id="jbug_load_title_"+gWindow.document.getElementById("loadcounter").value;oLoadTitleDiv.style.backgroundColor="#CCCCCC";oLoadTitleDiv.innerHTML='<table width="100%" cellspacing="0" cellpadding="3" style="font-size:11px; font-weight:bold;"><tr><td>Loaded at '+sLoadDate+'</td><td style="width:50px; cursor:pointer; background-color:#999999; border-left:1px solid #888888;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-o-user-select:none;user-select:none;" align="center" id="jbug_load_toggle_'+gWindow.document.getElementById("loadcounter").value+'">Hide</td><td style="width:50px; cursor:pointer; background-color:#ff6833; border-left:1px solid #888888;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-o-user-select:none;user-select:none;" align="center" id="jbug_load_remove_'+gWindow.document.getElementById("loadcounter").value+'">Remove</td></tr></table>';oContentLoadDiv.appendChild(oLoadTitleDiv);oActiveLoadDiv=gWindow.document.createElement("div");oActiveLoadDiv.id="jbug_load_content_"+gWindow.document.getElementById("loadcounter").value;oActiveLoadDiv.style.borderTop="1px solid #888888";oActiveLoadDiv.style.fontSize="11px";oActiveLoadDiv.style.padding="10px";oContentLoadDiv.appendChild(oActiveLoadDiv);var oLoadDivParent=gWindow.document.getElementById("debugcontent");oLoadDivParent.insertBefore(oContentLoadDiv,oLoadDivParent.childNodes[0]);}for(var i=1;i<=parseInt(gWindow.document.getElementById("loadcounter").value);i++){if(gWindow.document.getElementById("jbug_load_remove_"+i)!=null){gWindow.document.getElementById("jbug_load_remove_"+i).onclick=function(){jBugRemoveLoad(this.id.replace("jbug_load_remove_",""));};gWindow.document.getElementById("jbug_load_toggle_"+i).onclick=function(){jBugToggleLoad(this.id.replace("jbug_load_toggle_",""));};}}var oDebugTempDiv=gWindow.document.createElement("div");var oDebugTable=gWindow.document.createElement("table");oDebugTable.id="jbug_dump_"+gWindow.document.getElementById("loadcounter").value+"_"+gDumpCounter;oDebugTable.border=0;oDebugTable.cellPadding=3;oDebugTable.cellSpacing=0;oDebugTable.style.backgroundColor="#FFFFFF";oDebugTable.style.borderCollapse="collapse";oDebugTable.style.fontFamily="Arial";oDebugTable.style.fontSize="11px";oDebugTable.style.width="100%";if(gDumpCounter>1){oDebugTable.style.marginBottom="10px";}var oDebugTitleTr=gWindow.document.createElement("tr");var oDebugTdDumpCounter=gWindow.document.createElement("td");oDebugTdDumpCounter.style.border="1px solid #888888";oDebugTdDumpCounter.style.fontWeight="bold";oDebugTdDumpCounter.style.textAlign="right";oDebugTdDumpCounter.style.width="13px";oDebugTdDumpCounter.innerHTML=gDumpCounter;oDebugTitleTr.appendChild(oDebugTdDumpCounter);var oDebugTdDumpName=gWindow.document.createElement("td");oDebugTdDumpName.style.border="1px solid #888888";oDebugTdDumpName.style.fontWeight="bold";oDebugTdDumpName.innerHTML=sDebugName;oDebugTitleTr.appendChild(oDebugTdDumpName);oDebugTable.appendChild(oDebugTitleTr);var oDebugContentTr=gWindow.document.createElement("tr");var oDebugContentTd=gWindow.document.createElement("td");oDebugContentTd.style.border="1px solid #888888";oDebugContentTd.colSpan=2;oDebugContentTd.innerHTML=sContent;oDebugContentTr.appendChild(oDebugContentTd);oDebugTable.appendChild(oDebugContentTr);oActiveLoadDiv.insertBefore(oDebugTable,oActiveLoadDiv.childNodes[0]);for(var i=1;i<parseInt(gWindow.document.getElementById("loadcounter").value);i++){if(gWindow.document.getElementById("jbug_load_content_"+i)!=null){gWindow.document.getElementById("jbug_load_content_"+i).style.display="none";gWindow.document.getElementById("jbug_load_toggle_"+i).innerHTML="Show";}}gDumpCounter++;function recurse(o,type){var i;var j=0;var r='';type=_jBugType(o);switch(type){case'regexp':var t=type;r+='<table'+_jBugStyles(t,'table')+'><tr><th colspan="2"'+_jBugStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_jBugStyles(t,'td-value')+'><table'+_jBugStyles('arguments','table')+'><tr><td'+_jBugStyles('arguments','td-key')+'><i>RegExp: </i></td><td'+_jBugStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case'date':var t=type;r+='<table'+_jBugStyles(t,'table')+'><tr><th colspan="2"'+_jBugStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_jBugStyles(t,'td-value')+'><table'+_jBugStyles('arguments','table')+'><tr><td'+_jBugStyles('arguments','td-key')+'><i>Date: </i></td><td'+_jBugStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case'function':var t=type;var a=o.toString().match(/^.*function.*?\((.*?)\)/im);var args=(a==null||typeof a[1]=='undefined'||a[1]=='')?'none':a[1];r+='<table'+_jBugStyles(t,'table')+'><tr><th colspan="2"'+_jBugStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_jBugStyles(t,'td-value')+'><table'+_jBugStyles('arguments','table')+'><tr><td'+_jBugStyles('arguments','td-key')+'><i>Arguments: </i></td><td'+_jBugStyles(type,'td-value')+'>'+args+'</td></tr><tr><td'+_jBugStyles('arguments','td-key')+'><i>Function: </i></td><td'+_jBugStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case'domelement':var t=type;r+='<table'+_jBugStyles(t,'table')+'><tr><th colspan="2"'+_jBugStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td'+_jBugStyles(t,'td-key')+'><i>Node Name: </i></td><td'+_jBugStyles(type,'td-value')+'>'+o.nodeName.toLowerCase()+'</td></tr>';r+='<tr><td'+_jBugStyles(t,'td-key')+'><i>Node Type: </i></td><td'+_jBugStyles(type,'td-value')+'>'+o.nodeType+'</td></tr>';r+='<tr><td'+_jBugStyles(t,'td-key')+'><i>Node Value: </i></td><td'+_jBugStyles(type,'td-value')+'>'+o.nodeValue+'</td></tr>';r+='<tr><td'+_jBugStyles(t,'td-key')+'><i>innerHTML: </i></td><td'+_jBugStyles(type,'td-value')+'>'+_jBugHtmlSpecialChars(o.innerHTML)+'</td></tr>';j++;break;}if(/object|array/.test(type)){for(i in o){var t=_jBugType(o[i]);if(j<1){r+='<table'+_jBugStyles(type,'table')+'><tr><th colspan="2"'+_jBugStyles(type,'th')+'>'+type+'</th></tr>';j++;}if(typeof o[i]=='object'&&o[i]!==null){r+='<tr><td'+_jBugStyles(type,'td-key')+'>'+i+' ['+t+']'+'</td><td'+_jBugStyles(type,'td-value')+'>'+recurse(o[i],t)+'</td></tr>';}else if(typeof o[i]=='function'){r+='<tr><td'+_jBugStyles(type,'td-key')+'>'+i+' ['+t+']'+'</td><td'+_jBugStyles(type,'td-value')+'>'+recurse(o[i],t)+'</td></tr>';}else{r+='<tr><td'+_jBugStyles(type,'td-key')+'>'+i+' ['+t+']'+'</td><td'+_jBugStyles(type,'td-value')+'>'+o[i]+'</td></tr>';}}}if(j===0){r+='<table'+_jBugStyles(type,'table')+'><tr><th colspan="2"'+_jBugStyles(type,'th')+'>'+type+' [empty]</th></tr>';}r+='</table>';return r;}};var jBugClear=function(){oActiveLoadDiv={};gDumpCounter=1;gWindow.document.getElementById("loadcounter").value=0;gWindow.document.getElementById("debugcontent").innerHTML="";};var jBugRemoveLoad=function(iLoadNr){var oLoadParent=gWindow.document.getElementById("debugcontent");var oLoadDivDelete=gWindow.document.getElementById("jbug_load_"+iLoadNr);oLoadParent.removeChild(oLoadDivDelete);};var jBugToggleLoad=function(iLoadNr){if(gWindow.document.getElementById("jbug_load_content_"+iLoadNr).style.display=="none"){gWindow.document.getElementById("jbug_load_toggle_"+iLoadNr).innerHTML="Hide";gWindow.document.getElementById("jbug_load_content_"+iLoadNr).style.display="block";}else{gWindow.document.getElementById("jbug_load_toggle_"+iLoadNr).innerHTML="Show";gWindow.document.getElementById("jbug_load_content_"+iLoadNr).style.display="none";}};_jBugStyles=function(type,elem){var r='';var table='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;cell-spacing:2px;';var th='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;text-align:left;color: white;padding: 5px;vertical-align :top;cursor:hand;cursor:pointer;';var td='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;vertical-align:top;padding:3px;';var thScript='onClick="tTable(this);" title="click to collapse"';var tdScript='onClick="tRow(this);" title="click to collapse"';switch(type){case'string':case'number':case'boolean':case'undefined':case'object':switch(elem){case'table':r=' style="'+table+'background-color:#0000cc;"';break;case'th':r=' style="'+th+'background-color:#4444cc;"'+thScript;break;case'td-key':r=' style="'+td+'background-color:#ccddff;cursor:hand;cursor:pointer;"'+tdScript;break;case'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case'array':switch(elem){case'table':r=' style="'+table+'background-color:#006600;"';break;case'th':r=' style="'+th+'background-color:#009900;"'+thScript;break;case'td-key':r=' style="'+td+'background-color:#ccffcc;cursor:hand;cursor:pointer;"'+tdScript;break;case'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case'function':switch(elem){case'table':r=' style="'+table+'background-color:#aa4400;"';break;case'th':r=' style="'+th+'background-color:#cc6600;"'+thScript;break;case'td-key':r=' style="'+td+'background-color:#fff;cursor:hand;cursor:pointer;"'+tdScript;break;case'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case'arguments':switch(elem){case'table':r=' style="'+table+'background-color:#dddddd;cell-spacing:3;"';break;case'td-key':r=' style="'+th+'background-color:#eeeeee;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;}break;case'regexp':switch(elem){case'table':r=' style="'+table+'background-color:#CC0000;cell-spacing:3;"';break;case'th':r=' style="'+th+'background-color:#FF0000;"'+thScript;break;case'td-key':r=' style="'+th+'background-color:#FF5757;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case'date':switch(elem){case'table':r=' style="'+table+'background-color:#663399;cell-spacing:3;"';break;case'th':r=' style="'+th+'background-color:#9966CC;"'+thScript;break;case'td-key':r=' style="'+th+'background-color:#B266FF;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case'domelement':switch(elem){case'table':r=' style="'+table+'background-color:#FFCC33;cell-spacing:3;"';break;case'th':r=' style="'+th+'background-color:#FFD966;"'+thScript;break;case'td-key':r=' style="'+th+'background-color:#FFF2CC;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;}return r;};_jBugType=function(obj){var t=typeof(obj);if(t=='function'){var f=obj.toString();if((/^\/.*\/[gi]??[gi]??$/).test(f)){return'regexp';}else if((/^\[object.*\]$/i).test(f)){t='object'}}if(t!='object'){return t;}switch(obj){case null:return'null';case window:return'window';case document:return document;case window.event:return'event';}if(window.event&&(event.type==obj.type)){return'event';}var c=obj.constructor;if(c!=null){switch(c){case Array:t='array';break;case Date:return'date';case RegExp:return'regexp';case Object:t='object';break;case ReferenceError:return'error';}}var nt=obj.nodeType;if(nt!=null){switch(nt){case 1:if(obj.item==null){return'domelement';}break;case 3:return'string';}}if(obj.toString!=null){var ex=obj.toString();var am=ex.match(/^\[object (.*)\]$/i);if(am!=null){var am=am[1];switch(am.toLowerCase()){case'event':return'event';case'nodelist':case'htmlcollection':case'elementarray':return'array';case'htmldocument':return'htmldocument';}}}return t;};_jBugHtmlSpecialChars=function(str){if(typeof(str)=="string"){str=str.replace(/&/g,"&amp;");str=str.replace(/"/g,"&quot;");str=str.replace(/'/g,"&#039;");str=str.replace(/</g,"&lt;");str=str.replace(/>/g,"&gt;");}return str;};
