var ihavevoted = 0;

function getXMLHttp() {
    var xmlHttp
    try {
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    return xmlHttp;
}

function vote_ask(id, rate) {
    var http = false;
    if (navigator.appName == "Microsoft Internet Explorer") {
        http = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        http = new XMLHttpRequest();
    }
    http.open("GET", "/vote_ask.php?id=" + id + "&rate=" + rate, true);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {
            document.getElementById(id).innerHTML = http.responseText;
        }
    }
    http.send(null);
}

function vote_answer(id, rate) {
    var http = false;
    if (navigator.appName == "Microsoft Internet Explorer") {
        http = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        http = new XMLHttpRequest();
    }
    http.open("GET", "/vote_answer.php?id=" + id + "&rate=" + rate, true);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {
            document.getElementById("r" + id).innerHTML = http.responseText;
        }
    }
    http.send(null);
}

function report(id, tip) {
    var http = false;
    if (navigator.appName == "Microsoft Internet Explorer") {
        http = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        http = new XMLHttpRequest();
    }
    http.open("GET", "/report.php?id=" + id + "&tip=" + tip, true);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {
            alert("Thank You for Reporting!");
            document.getElementById(tip + "" + id).innerHTML = http.responseText;
        }
    }
    http.send(null);
}

function show_answer(id) {
    if (id == 1) {
        $('#formular2').hide();
        document.getElementById('cucu').innerHTML = "<a href=\"#\" onclick=\"show_answer('2')\" ><img src=\"answer.jpg\"  /></a>";
        $('#formular1').fadeIn("slow");
    }
    if (id == 2) {
        $('#formular2').fadeIn("slow");
        document.getElementById('cucu').innerHTML = "<a href=\"#\" onclick=\"show_answer('1')\" ><img src=\"answer.jpg\"  /></a>";
        $('#formular1').hide();
    }
}
