// JavaScript Document

function save_topics(project_id,topic_type,result_id,user_id,lang)
{
  
  if (topic_type == 'name')
  {
    var topic = document.getElementById('project_'+project_id+'_name').value;
  }
  else if (topic_type == 'id')
  {
    var select = document.getElementById('project_'+project_id+'_id');
    var topic = select.options[select.selectedIndex].value;
  }
    
  var url = "ajax/user_projects_ajax.php?topic_type="+topic_type+"&result_id="+result_id+"&user_id="+user_id+"&project_id="+project_id+"&topic="+topic+"&lang="+lang;
  sendRequest_topic(url);
}
/*var xmlHttp;

function createXMLHttpRequest()
{
	try 
  { 
    return new ActiveXObject("Msxml2.XMLHTTP"); 
  } 
  catch (e) 
  {
    try 
    { 
      return new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    catch (e) 
    {
      try 
      { 
        return new XMLHttpRequest(); 
      } 
      catch(e) 
      {
      	alert("Your browser does not support AJAX!");
	      return null;
      }
    }
  }
}*/

function stateChanged_topic() 
{ 
  if (xmlHttp.readyState==4)
  { 
    document.getElementById('choose_topic').innerHTML=xmlHttp.responseText;
    confirm('Vaše zadanie bolo zmenené.');
  }
}

function sendRequest_topic(url)
{
	xmlHttp = createXMLHttpRequest();

	if (xmlHttp)
	{
	  xmlHttp.onreadystatechange=stateChanged_topic;
		xmlHttp.open("GET", url, true);
		xmlHttp.send("");
		//return xmlhttp.responseText;
	}
}