// JavaScript Document


function showSelection( id, num )
{
    obj = document.getElementById( id );
    obj.className = "volba"+num+" sel";
}

function hideSelection( id, num )
{
    obj = document.getElementById( id );
    obj.className = "volba"+num;
}


function getSection( id, id_sel )
{
    var url_parameters = "";
    url_parameters += "id=" + id ;
//alert(url_parameters);
    if (window.XMLHttpRequest)
    {
        http_request = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        try
        {
          http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (error)
        {
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    http_request.onreadystatechange = function() { getSelection_processRequest(http_request); };
    http_request.open('POST', '/pages/volby_zmena.php', true);
    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http_request.send(url_parameters);

	if( id_sel > 0 )
	{
		for(i=1; i<=4; i++)
		{
			if( id_sel == i )
			{
				idobj = "sel"+i;
				showSelection( idobj, i );
				if( i>1 )
				{
					obj = document.getElementById( "box_menu_"+i );
					obj.className = "fll show";
				}
			}
			else
			{
				idobj = "sel"+i;
				hideSelection( idobj, i );
				if( i>1 )
				{
					obj = document.getElementById( "box_menu_"+i );
					obj.className = "fll hide";
				}
			}
		}
		if( id_sel > 1 )
		{
			obj = document.getElementById( "subsel"+id_sel+"a" );
			obj.className = "act";
			obj = document.getElementById( "subsel"+id_sel+"b" );
			obj.className = "";
		}
	}
	else
	{
		for(i=2; i<=4; i++)
		{
			if( id == i+"a" )
			{
				obj = document.getElementById( "subsel"+i+"a" );
				obj.className = "act";
				obj = document.getElementById( "subsel"+i+"b" );
				obj.className = "";
			}
			else
			{
				obj = document.getElementById( "subsel"+i+"a" );
				obj.className = "";
				obj = document.getElementById( "subsel"+i+"b" );
				obj.className = "act";
			}
		}
	}
//    var ajaxRing = document.getElementById("anketa_actual");
//    ajaxRing.innerHTML = '<img src="/img/ajax_ring_big.gif" />';
}

function getSelection_processRequest(httpRequest)
{
//    alert(httpRequest.readyState);
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
//      alert("Hlasovani OK");
      var mistoZobrazeni = document.getElementById("box_menu_icons");
      mistoZobrazeni.innerHTML = httpRequest.responseText;
    }
    else
    {
        alert("Chyba pri nacitani stranky"+ httpRequest.status +":"+ httpRequest.statusText);
    }
  }
}

