/**
 * Function for locking objects
 */

var xmlHttp;
// Create xmlHttp Object
try
{
	// Firefox, Opera 8.0+, Safari
	xmlHttp = new XMLHttpRequest();
}
catch (e)
{
	try
	{
		// Internet Explorer
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = null;
		}
	}
}

function lockObject( id )
{
	xmlHttp.open("GET", "/objects/lock/"+id, false); // synchronous request 
	xmlHttp.send(null);
	
	if (xmlHttp.status == 200)
	{
		if (xmlHttp.responseText == '1')
		{
			return true;
		}
		alert( xmlHttp.responseText );
	}
	return false;
}

function renewLock( id )
{
	xmlHttp.open("GET", "/objects/renew/"+id, true); // synchronous request 
	xmlHttp.send(null);	
	setTimeout("renewLock("+id+")", 120000); // 2 minutes
	return true;
}