function update_file(variabila)
{
	var file_field = document.getElementById('my_file_element');
	file_field.value = variabila;
}

function update_fake(variabila)
{
	var file_field = document.getElementById('fake_element');
	file_field.value = variabila;
}
function download_file(id,password)
{
	if(password == 'yes')
	{
		var pass = prompt("Password","");
		if (pass!=null && pass.length!=0)
		{
			window.location='download.php?action=download&file='+ id +'&password=' + pass;
		}
	}
	else
	window.location='download.php?action=download&file='+ id;
}
function delete_file(id,password)
{
	okdelete=confirm("Are you sure you want to delete this file?");
	if (okdelete==true)
	{
		if(password == 'yes')
		{
			var pass = prompt("Password","");
			if (pass!=null && pass.length!=0)
			{
				window.location='download.php?action=delete&file='+ id +'&password=' + pass;
			}
		}
		else
		window.location='download.php?action=delete&file='+ id;
	}
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq() {
    http.open('get', 'statistici.php');
    http.onreadystatechange = handleResponse;
    http.send(null);
	setTimeout("sndReq()", 40000); // Recursive JavaScript function calls sndReq() every second
}

function handleResponse() {
    if(http.readyState == 4)
    {
        var response = http.responseText;
        document.getElementById("info").innerHTML = response;
    }
}
