
var oReq = new XMLHttpRequest();
var page;
var type;
var level;
var count;
var mimetype;
//var path;
oReq.addEventListener("load", downloadComplete);

addEventListener('message', function(e) 
{
	if(typeof e.data !== "object") return;
	
	page = e.data.page;
	type = e.data.type;
	level = e.data.level;
	count = e.data.count;
	mimetype = type == "zoomSVG" ? "image/svg+xml" : "image/jpeg";
	//path = e.data.path;
	oReq.open("GET", e.data.path);
	oReq.overrideMimeType(mimetype);
	oReq.send();
}, false);

function downloadComplete(e)
{
	postMessage({page: page, type: type, level: level, count: count, message: type + ' loaded for page : ' + page});
}