// JavaScript Document

function ajaxFunction(start) { 

  // instantiate ajax
  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;
	  }
	}
  }
  
  // update html content if request has been returned
  xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState == 4) {
      var poll_content = MM_findObj('poll_content');
	  poll_content.innerHTML = xmlHttp.responseText;
    }
  }
  
  // add form fields and their value to var params
  // so we can pass the fields in the url
  var poll_form = MM_findObj('poll_form');
  var params = 'start=' + start;
  if (poll_form.vote != null) {
    for (i = 0; i < poll_form.vote.length; i++) {
	  if (poll_form.vote[i].checked) {
	    params += '&vote=' + poll_form.vote[i].value;	
	  }
    }
  }
  
  // send request
  xmlHttp.open("GET", "/php_inc/poll.php?"+params, true);
  xmlHttp.send(null);

} // end ajaxFunction







function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}