if (window.attachEvent)
{
window.attachEvent("onkeydown", interceptKey);
}
else	{
window.onkeydown=interceptKey;
}
var isDebug = false;
function interceptKey(evt)
{
var type= evt.type;
var code = evt.keyCode;
var key = String.fromCharCode(code);
var alt = evt.altKey;
var ctrl = evt.ctrlKey;
var shift = evt.shiftKey;
if(shift && alt && key == 'D' && isDebug == false) startDebugger('on');
}
function startDebugger(event)
{
var body_array = document.getElementsByTagName("BODY");
var body = body_array[0];
if(event == 'on')
{
isDebug = true;
var debug = document.createElement('div');
debug.setAttribute('id','debug');
body.appendChild(debug);
var close = document.createElement('div');
close.setAttribute('id','close');
var close_text = document.createTextNode('chiudi');
close.onclick = function(){body.removeChild(debug);isDebug = false;}
close.appendChild(close_text);
debug.appendChild(close);
var h2 = document.createElement('h2');
var h2_text = document.createTextNode('Debug Javascript');
h2.appendChild(h2_text);
debug.appendChild(h2);
var debug_container = document.createElement('div');
debug_container.setAttribute('id','debug_container');
debug.appendChild(debug_container);
for(var i=0;i<document.styleSheets.length;i++)
{
var num_foglio_stile = document.styleSheets[i];
var href = document.styleSheets[i].href;
var foglio_stile = document.createElement('div');
foglio_stile.setAttribute('id', 'foglio_'+i);
foglio_stile.setAttribute('class', 'foglio');
debug_container.appendChild(foglio_stile);
var h3_foglio = document.createElement('h3');
var titolo_foglio = document.createTextNode(href);
h3_foglio.appendChild(titolo_foglio);
foglio_stile.appendChild(h3_foglio);
for(var j=0;j<num_foglio_stile.cssRules.length;j++)
{
var num_rule = num_foglio_stile.cssRules[j];
var rule = document.createElement('div');
rule.setAttribute('class', 'rule');
var strong = document.createElement('strong');
var rule_name = document.createTextNode(num_rule.selectorText+': ');
var rule_text = document.createTextNode(num_rule.style.cssText);
strong.appendChild(rule_name)
rule.appendChild(strong);
rule.appendChild(rule_text);	foglio_stile.appendChild(rule);
}
}
}
}