
function doRequest_p(id)
{
	http_request_p[id] = false;

	if (window.XMLHttpRequest) // Opera, Mozilla, Safari, Netscape
	{
		http_request_p[id] = new XMLHttpRequest();

		if (http_request_p[id].overrideMimeType)
		{
              http_request_p[id].overrideMimeType('text/xml');
        }
	}
	else if (window.ActiveXObject)  // IE
	{
		try
		{
			http_request_p[id] = new ActiveXObject("Msxml2.XMLHTTP");
        }
		catch (e)
		{
			try
			{
				http_request_p[id] = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
}

function recapture_pic(id, folder)
{
	doRequest_p(id);

	var url = "ajax_request_new_preview.php?id="+id+"&folder="+folder+"&acache="+Math.round(Math.random()*100000);

	document.getElementById("pt_"+id).innerHTML = lang_wait;

	if (http_request_p[id])
	{
		http_request_p[id].onreadystatechange = function() {if ((http_request_p[id].readyState == 4) && (http_request_p[id].status == 200)) renew_pic(http_request_p[id].responseText); }
		http_request_p[id].open('GET', url, true);
		http_request_p[id].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request_p[id].send(null);
	}
	else
	{
		document.getElementById('pp').src=url+'&iframe=true';
	}
}

function renew_pic(info)
{
	var parts = info.split("|");

	//alert(parts[1]);

	//document.getElementById("pp_"+parts[0]).src = parts[1] + "?acache="+Math.round(Math.random()*100000);
    document.getElementById("pp_"+parts[0]).src = parts[1];
	//document.getElementById("pp_"+parts[0]).style.width = parts[2]+"px";
	//document.getElementById("pp_"+parts[0]).style.height = parts[3]+"px";

	document.getElementById("pt_"+parts[0]).innerHTML = lang_preview;
}
