
//SwfCabin 
//Ajax vote system to take care of the votes without reloading the page

function sendVote(vote, id)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      var status=xmlHttp.responseText;

      //Standard Errors messages 
      if(status==1){
       //remove the voting options
       document.getElementById('votebtns').style.display = 'none';  
       alert("You are the author, you cannot vote on your own submission");
      }
      if(status==2){
        //remove the voting options
       document.getElementById('votebtns').style.display = 'none';  
       alert("You have already voted on this submission");
      }

      if(!(status==1 || status==2))
      { 
          alert("Thank you, your vote has been submitted");

          //remove the voting options
          document.getElementById('votebtns').style.display = 'none';  

          //refresh the vote counter
          document.getElementById('currvote').innerHTML=status;
         
      }
       
   
      }
    }
  xmlHttp.open("GET","proccessvote.php?vote="+ vote +"&id="+ id +"",true);
  xmlHttp.send(null);
  }