/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------  */
function ErrorHandler(err, url, line, except) {
    var i, obj, ehi, member, ni = '', errobj = '', msg = '';
    if (except) {
        if (except.message) err = except.message;
        if (except.fileName) url = except.fileName;
        if (except.lineNumber) line = except.lineNumber;
        for (obj in except) {
            errobj = errobj + '&except[' + obj + ']=' + encodeURIComponent(except[obj]);
            msg = msg + '\n' + obj + ': ' + except[obj];
        } /* obj */
    } /* except */
    var q = '?err=' + encodeURIComponent(err) + '&line=' + encodeURIComponent(line) + '&url=' + encodeURIComponent(url);
    if (navigator) {
        if (navigator.plugins
            && navigator.plugins.length) {
                for (i = 0; i < navigator.plugins.length; i++) {
                    q += '&pi[' + i + ']=' + encodeURIComponent(
                        navigator.plugins[i].name + '|' + navigator.plugins[i].filename);
                } /* for i */
        } /* navigator.plugins */
        if ((typeof navigator.appName) != 'undefined')
            q += '&app=' + encodeURIComponent(navigator.appName);
        if ((typeof navigator.userAgent) != 'undefined')
            q += '&ua=' + encodeURIComponent(navigator.userAgent);
        if ((typeof navigator.platform) != 'undefined')
            q += '&sys=' + encodeURIComponent(navigator.platform);
        if ((typeof navigator.language) != 'undefined')
            q += '&lang=' + encodeURIComponent(navigator.language);
        if ((typeof navigator.cookieEnabled) != 'undefined')
            q += '&ca=' + encodeURIComponent(navigator.cookieEnabled);
    } /* navigator */
    q += errobj;
    q += '&vers=1.2';
    if (Image && (ehi = new Image()))
        ehi.src = 'http://' + window.location.hostname+ '/screrr.php'+ q;
    return true;
}
if (!debug) {window.onerror = ErrorHandler;}
/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------  */



/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------  */
function methodExists(obj, method) {
    var too, toom, ret = false;
    if (obj) {
        too = typeof obj;
        if (too == "function" || too == "object") {
            toom  = typeof obj[method];
            if (toom == "function" || toom == "object")  ret = true;
        } /* too */
    } /* obj */
    return ret;
}
function memberExists(obj, method) {
    var too, ret = false;
    if (obj) {
        too = typeof obj;
        if (too == "function" || too == "object") {
            if ((typeof obj[method]) != 'undefined') ret = true;
        } /* too */
    } /* obj */
    return ret;
}
function insertElement(obj, pos, html) {
    var r;
    if ((typeof html) == 'string') {
        if (methodExists(obj,'insertAdjacentHTML')) {
            obj.insertAdjacentHTML(pos,html);
            pos = '';
        } else {
            if (methodExists(document,'createRange')
                && (r = document.createRange())
                && methodExists(r,'setStartBefore')) {
                r.setStartBefore(obj);
                if (methodExists(r,'createContextualFragment'))
                    html = r.createContextualFragment(html);
            } 
        }
    }
    switch (pos.toLowerCase()) {
        case 'beforebegin':
            if (obj.parentNode
                && methodExists(obj.parentNode, 'insertBefore'))
                obj.parentNode.insertBefore(html, obj);
            break;
        case 'afterbegin':
            if (methodExists(obj, 'insertBefore')
                && memberExists(obj,'firstChild'))
                obj.insertBefore(html, obj.firstChild);
            break;
        case 'beforeend':
            if (methodExists(obj, 'appendChild'))
                obj.appendChild(html);
            break;
        case 'afterend':
            if (memberExists(obj,'nextSibling')
                && obj.nextSibling
                && memberExists(obj,'parentNode')
                && methodExists(obj.parentNode,'insertBefore'))
                    obj.parentNode.insertBefore(html,obj.nextSibling);
            else {
                if (memberExists(obj,'parentNode')
                    && methodExists(obj.parentNode,'appendChild'))
                    obj.parentNode.appendChild(html);
            }
            break;
    } /* case */
    return true;
}
function prototyping() {
     var r, html, s, a, ret = false;
    //Prototyping additions
    if (((typeof HTMLElement) != 'undefined')
        && methodExists(HTMLElement,'prototype')) {
        if (!HTMLElement.prototype.id) {
            HTMLElement.prototype.id = function() {
                if (methodExists(this,'getAttribute'))
                    return this.getAttribute('id');
            }; /* function def */
        } /* prototype.id */
        if (!HTMLElement.prototype.className) {
            HTMLElement.prototype.className = function() {
                if (methodExists(this,'getAttribute'))
                    return this.getAttribute('class');
            }; /* function def */
        } /* prototype.className */
        if (!HTMLElement.prototype.innerText) {
            HTMLElement.prototype.__defineGetter__('innerText', function() {
                var i;
                var text = '', errstep = 0;
                if (this.childNodes && (errstep = 1)) {
                    for (i = 0; i < this.childNodes.length; i++){
                        if (memberExists(this.childNodes[i],'nodeType')
                            && this.childNodes[i].nodeType == 3
                            && memberExists(this.childNodes[i],'nodeValue'))
                            text += this.childNodes[i].nodeValue;
                        else {
                            if (memberExists(this.childNodes[i],'nodeType')
                                && this.childNodes[i].nodeType == 1
                                && memberExists(this.childNodes[i],'innerText'))
                                text += this.childNodes[i].innerText;
                        }
                    } /* for */
                    return text;
                }
            } /* funtion def */ );
        } /* prototype.innerText */
    } /* HTMLElement */
    if ((typeof encodeURIComponent) == 'undefined') {
        encodeURIComponent = function(txt) { return escape(txt);}
    }
    if ((typeof decodeURIComponent) == 'undefined') {
        decodeURIComponent = function(txt) { return unescape(txt);}
    }
    return true;
}
prototyping();
/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------  */



/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------  */
function ajax() {
   var req;
   try {req = new XMLHttpRequest();} catch (e) {
   try {req = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {
   try {req = new ActiveXObject("Microsoft.XMLHTTP");}
       catch (failed) {req = null;}}}
   return req;
}
function clicktrack(obj,code) {
    try {
        var req = ajax();
        var url = 'http://' + window.location.hostname + '/clicktrack.php?href=' + encodeURIComponent(obj.href) + 
            '&ref=' + encodeURIComponent(window.location.href) +
            '&code=' + encodeURIComponent(code);
        req.open('GET', url, false);
        req.send('');  
    } catch(e) {} 
    return true;
}
/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------  */

