//seznam souboru na strance
var itemsArray = new Array;

//zajisteni existence metody Array.indexOf()
if (!Array.prototype.indexOf)
{
	Array.prototype.indexOf = function(elt /*, from*/)
	{
		var len = this.length;

		var from = Number(arguments[1]) || 0;
		from = (from < 0)
   		? Math.ceil(from)
   		: Math.floor(from);
		if (from < 0)
			from += len;

		for (; from < len; from++)
		{
			if (from in this &&
    			this[from] === elt)
  			return from;
		}
		return -1;
	};
};

function createXmlHttpRequestObject()
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)

    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}
// vytvarim asynchroni HTTP pozadavek pouzivajici the XMLHttpRequest objekt
function process(id)
{
  var xmlHttp = createXmlHttpRequestObject();
	// proceed only if the xmlHttp object isn't busy
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    // execute the php page from the server
    xmlHttp.open("GET", "modules/tableadmin2/external/mmedia_counter.php?item=" + id, true);
    // define the method to handle server responses
    xmlHttp.onreadystatechange = handleServerResponse;
    // make the server request
    xmlHttp.send(null);
 }
  else
    // if the connection is busy, try again after one second
    setTimeout('process()', 1000);
}

// executed automatically when a message is received from the server
function handleServerResponse()
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4)
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200)
    {
			
    }
    // a HTTP status different than 200 signals an error
    else
    {
      alert("Je problem s pristupem na server: " + xmlHttp.statusText);
    }
  }
}
function test(id_prehravac)
{
	var myListener = new Object();
	myListener.id_prehravace = id_prehravac;

	function getFlashObject()
	{
	    return document.getElementById(myListener.id_prehravace);
	}

	return myListener;
}
