station = ''
xmlobj = ''

function initHTTPObj()
{
	if (window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	}
	
	return xmlhttp
}

function RequestChange() {
    if (xmlobj.readyState == 4) {
        if (xmlobj.status == 200) {
			voteSent()
        } else {
            alert("There was a problem sending your report !\n" + req.statusText);
        }
    }
}

function voteSent()
{
	if (xmlobj.responseText == 'ok') {
		dname = 'voteid_'+station
		if (document.all) {
			vote_id = document.all[dname]
		}
		if (document.getElementById) {
			vote_id = document.getElementById(dname)
		}
		vote_id.innerHTML="<span class='advanced'>Thank You !</span>"
	}
}

function sendVote (station_id, vote)
{
	xmlobj = initHTTPObj()
	if (xmlobj)
		xmlobj.onreadystatechange = RequestChange;
	
	station = station_id
	xmlobj.open("GET", webroot+'/extra/vote/'+station_id+'/?vote='+vote, true);
	xmlobj.send('');
}
