// для опроса

function addField(btn) {
        tr = btn;
        while (tr.tagName != 'TR') tr = tr.parentNode;
        var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
        checkFieldForLast();
}

function checkFieldForLast() {
        btns = document.getElementsByName('drop_answer');
        for (i = 0; i < btns.length; i++){
            btns[i].disabled = false;
        }
        if (btns.length<=2) {
            btns[0].disabled = true;
            btns[1].disabled = true;
        }
}

function dropField(btn) {
        tr = btn;
        while (tr.tagName != 'TR') tr = tr.parentNode;
        tr.parentNode.removeChild(tr);
        checkFieldForLast();
}

function putcounter() {
    data = {
        'target': 'http://80.93.59.65/giftest/counter/timer.gif?mr='+Math.random(),
        'docURL': document.URL,
        'docPTH': window.location.pathname,
        'hostNM': window.location.hostname,
        'screen': screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth),
        'xrefer': document.referrer,
        'option': "border=0 width=1 height=1 alt='' title='FF'"
    }
    var image = new Image()
    image.src = data['target']+"&ref="+data['xrefer']+"&pp="+data['docPTH']+"&sw="+data['screen']+"&hn="+data['hostNM']
    image.border=0;image.width=1;image.height=1;image.alt='';image.title='FF'
    return 0
}

var init = function() {
    if (typeof arguments.callee.instance=='undefined') {
        arguments.callee.instance = new function() {
            setInterval('putcounter()', 30000)
            console.log('counter was set')
        }
    }
    return arguments.callee.instance
}

// ff, opera
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}
// ie
/*@cc_on @*/
/*@if (@_win32)*/
document.write("<script id=__ie_onload defer src=javascript:void(0)>");
document.write("<\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        init();
    }
};
/*@end @*/
// safari
if (/WebKit/i.test(navigator.userAgent)) {
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            delete _timer;
            init();
        }
    }, 10);
}
// others
window.onload = init;


