var xmlhttp;

function processVote(str,append,action)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="/includes/vote.php";
url=url+"?school_id="+str;
url=url+"&appendage="+append;
if(action == undefined)
    action = undefined;
else
    url=url+"&action="+action;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function CopyToClipboard(topic_id)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="/includes/vote.php";
url=url+"?topic_id="+topic_id;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
var resp = xmlhttp.responseText;
if(resp == "exit")
    {
    document.getElementById("ccc").focus();
    document.getElementById("ccc").select();
    return 0;
    }
var rowID = resp.replace(/^\s+|\s+$/g, '');

var rankTest=rowID.substring(0,4);
//document.getElementById("ttt").innerHTML = rankTest;

if(rankTest == "dupl")
{
    document.getElementById("boxHide").style.display="none";
    document.getElementById("boxShowThankYou").style.display="";
    document.getElementById("boxShowThankYou").innerHTML="<br>Vote already received.  Thank you!<br>";
    return 0;
}

if(rankTest == "rank")
{
    /*
    rowID = rowID.substring(4);
    var x = document.getElementById(rowID).innerHTML;
    var y = parseFloat(x) - 1;
    document.getElementById(rowID).innerHTML = y;
            */
    incomingRating = rowID.substring(4);

    

    document.getElementById("imagesHide").style.display="";
    if(incomingRating == 2)
        document["hat2"].src="../../images/ChefStar2on.gif";
    if(incomingRating == 3)
        {
        document["hat2"].src="../../images/ChefStar2on.gif";
        document["hat3"].src="../../images/ChefStar3on.gif";
        }
     if(incomingRating == 4)
        {
        document["hat2"].src="../../images/ChefStar2on.gif";
        document["hat3"].src="../../images/ChefStar3on.gif";
        document["hat4"].src="../../images/ChefStar4on.gif";
        }
     if(incomingRating == 5)
        {
        document["hat2"].src="../../images/ChefStar2on.gif";
        document["hat3"].src="../../images/ChefStar3on.gif";
        document["hat4"].src="../../images/ChefStar4on.gif";
        document["hat5"].src="../../images/ChefStar5on.gif";
        }

    
    document.getElementById("boxHide").style.display="none";
    document.getElementById("boxShowThankYou").style.display="";
}
/*
else
{
    var x = document.getElementById(rowID).innerHTML;
    var y = parseFloat(x) + 1;
    document.getElementById(rowID).innerHTML = y;
}
*/
}

}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}