// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject(); 
var showErrors = true;
var cache = new Array();
// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    // try every prog id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
    {
      try 
      { 
        // try to create XMLHttpRequest object
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {}
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}
// make asynchronous HTTP request using the XMLHttpRequest object 
function vote_forward_bak(id,s)
{
	iid=id;
	ds=s;
	//alert(iid);
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    
    // execute the quickstart.php page from the server
    xmlHttp.open("GET", "catalog/function_forward.php?id=" + iid +"&s="+ds+"&t="+ Math.random(), true);  
    // define the method to handle server responses
    xmlHttp.onreadystatechange = handleServerResponsef;
    // make the server request
    xmlHttp.send(null);
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('vote_forward(iid,ds)', 1000);
}

// executed automatically when a message is received from the server
function handleServerResponsef() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
	  
      xmlResponse = xmlHttp.responseText;
	  if(xmlResponse !=''){
	  alert(xmlResponse);
	    if(xmlResponse=='恭喜你投票成功'){
	     window.location.href = 'index.php';
		}
	  }else{
	  alert('nothing');
	  }
	}
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function displayError($message)
{
  // ignore errors if showErrors is false
  if (showErrors)
  {
    // turn error displaying Off
    showErrors = false;
    // display error message
 
    alert("Error encountered: \n" + $message);
    // retry validation after 10 seconds
    //setTimeout("validate_glinkster();", 10000);
  }
}