// JavaScript Document

function addName()
{
	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("A böngésződ nem támogatja az AJAX kéréseket.");
		  return false;
		  }
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState == 4){
			document.getElementById("classNames").innerHTML = xmlHttp.responseText;
		}
	}
	for( i = 0; i < document.tabloRegForm.studentGender.length; i++ )
	{
	if( document.tabloRegForm.studentGender[i].checked == true )
		var val = document.tabloRegForm.studentGender[i].value;
		document.tabloRegForm.studentGender[i].checked = false;
	}
	xmlHttp.open("GET","index.php?module=tabloverseny&action=ajax&ajax_request=addname&name="+document.getElementById("studentName").value + "&gender=" + val  ,true);
	if (val)
	  document.getElementById("studentName").value = '';
	//xmlHttp.open("GET","index.php?module=regisztracio&ajax_request&username=Eddie&password=Murphy21",true);
	xmlHttp.send(null);
}

function deleteName(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("A böngésződ nem támogatja az AJAX kéréseket.");
		  return false;
		  }
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState == 4){
			document.getElementById("classNames").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","index.php?module=tabloverseny&action=ajax&ajax_request=deletename&id="+id ,true);
	//xmlHttp.open("GET","index.php?module=regisztracio&ajax_request&username=Eddie&password=Murphy21",true);
	xmlHttp.send(null);
}

