var acttag;
var owntag;
var action;

function act(action,webroot,id) {
	var url=webroot+'ajax/bootact.php?action='+action+'&id='+id;
	acttag='act'+id;
	owntag='own'+id;
	if (action=='del') {
		var check = confirm('Deleting a bootleg from your list also deletes all your private entries for this bootleg! Are you sure?');
		if (check) {
			document.getElementById(owntag).innerHTML = '';
			makeBRequest(url);
		}
	} else {
		document.getElementById(owntag).innerHTML = '<a href="'+webroot+'mypages/pboot.php?bid='+id+'" onmouseover="tooltip.show(\''+webroot+'ajax/pbootinfo.php?bid='+id+'\',null,\'left\');"onmouseout="tooltip.hide();"><img src="'+webroot+'images/icons/check.gif" title="I have this bootleg"/></a>';
		makeBRequest(url);
	}
}

function makeBRequest(url) {
	if(window.XMLHttpRequest) {
		request = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		request = new ActiveXObject("MSXML2.XMLHTTP");
	}
	sendBRequest(url);
}

function sendBRequest(url) {
	request.onreadystatechange = onBResponse;
	request.open("GET", url, true);
	request.send(null);
}

function checkBReadyState(obj) {
	if(obj.readyState == 1) { 
		document.getElementById(acttag).innerHTML = '..'; 
	}
	if(obj.readyState == 4) {
		if(obj.status == 200) {
			return true;
		}
		else {
			document.getElementById(acttag).innerHTML = "failed";
		}
	}
}

function onBResponse() {
	if(checkBReadyState(request)) {
		response = request.responseText;
		document.getElementById(acttag).innerHTML = response;
	}
}