function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 

function changecoords() {
    	rr1c="0,"+(document.getElementById('georgicavsvasilica').height-44)+","+(document.getElementById('georgicavsvasilica').width/2+3)+","+document.getElementById('georgicavsvasilica').height;
	rr2c=(document.getElementById('georgicavsvasilica').width/2+6)+","+(document.getElementById('georgicavsvasilica').height-44)+","+(document.getElementById('georgicavsvasilica').width)+","+document.getElementById('georgicavsvasilica').height;
	document.getElementById('rr1').coords=rr1c;
	document.getElementById('rr2').coords=rr2c;
}

function dovote(id,n) {
if(id=='0')
{
document.getElementById('scor').style.opacity = 0;
opacity('scor', 0, 100, 1500);
vote(id,n);
}
changecoords();
if(id!='0')
{
opacity('scor', 100, 0, 1500);
vote(id,n);
setTimeout("vote('0'); opacity('scor', 0, 100, 1500);",1600);
}
}

var xmlhttp = false;
try {
//If the javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
//If not, then use the older active x object.
try {
//If we are using IE.
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
//Else we must be using a non-IE browser.
xmlhttp = false;
}
}
//If we are using a non-IE browser, create a JavaScript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
//A variable used to distinguish whether to open or close the calendar.

function vote(id,n) {
//The location we are loading the page into.
var objID = "scor";
var serverPage = "action/dovotebeta.php?id=" + id +"&userptrew=" + n;
var obj = document.getElementById(objID);
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
