// <![CDATA[
var isopera = false;
var ischrome = false;
var isff = false;
var isie = false;
var isie6 = false;
var isie7 = false;
var isie8 = false;
if(navigator.userAgent.split('Opera').length == 2) isopera = true;
else if(navigator.userAgent.split('Chrome').length == 2) ischrome = true;
else if(navigator.userAgent.split('Firefox').length == 2) isff = true;
else if(navigator.userAgent.split('MSIE').length == 2) {
    isie = true;
    var bv = parseInt(navigator.userAgent.split('MSIE')[1]);
    if(bv <= 6) isie6 = true;
    else if(bv == 7) isie7 = true;
    else if(bv == 8) isie8 = true;
}
var d = document;
function debug(el, func, infunc) {
    if(!$('debug')) {
        var deb = d.createElement('div');
        deb.id = 'debug';
        deb.style.maxHeight = '400px';
        deb.style.width = '500px';
        deb.style.overflow = 'auto';
        deb.style.position = isie6 ? 'absolute' : 'fixed';
        deb.style.left = (d.viewport.getDimensions().width-503)+'px';
        deb.style.top = '0';
        deb.style.backgroundColor = '#444444';
        deb.style.color = '#ffffff';
        deb.style.font = '11px Arial';
        deb.style.borderLeft = '2px solid #ffffff';
        deb.style.zIndex = '10000';
        $(d.body).appendChild(deb);
        $('debug').setOpacity(0.9);
    }
    var type = typeof(el);
    var sel = '';
    switch(type) {
        case 'object':
            for (var i in el)
                if(i != 'channel' && el[i] && (typeof(el[i]) != 'function' || func)) {
                    sel += i;
                    if(infunc || typeof(el[i]) != 'function') sel += ' : '+el[i].toString().replace(/\n/g, '<br>');
                    sel += '<br>';
                }
        break;
        case 'undefined':
            sel = 'undefined';
        break;
        case 'boolean':
        case 'number':
        case 'string':
        case 'function':
        default:
            sel = el.toString().replace(/\n/g, '<br>');
        break;
    }
    if(!sel) sel = '&nbsp;';
    $('debug').innerHTML += ($('debug').innerHTML.length ? '<br>' : '')+sel;
    $('debug').scrollTop = $('debug').scrollHeight - $('debug').clientHeight;
}

// ]]>