// JavaScript Document

function runBatchUpdate($this,$proofs)
{
	var $action = $this.value;
	var $values = '';
	var $chkboxs = false;
	
	for (i=$proofs.length-1; i > -1; i--) {
		if ($proofs[i].checked)
		{
			$values += $proofs[i].value + ',';
			$chkboxs = true;
		}
	}
	
	if($chkboxs==false && $proofs.value!=null)
	{
		$values = $proofs.value + ',';
		$chkboxs = true;
	}
	
	if($chkboxs)
	{
		// Remove trailing comma
		$values = $values.substring(0,$values.length-1);
		$valuesarry = $values.split(',');
		if($action=='3') {
			$decision = confirm("Are you sure you wish to delete the "+$valuesarry.length+" proof(s)? This action cannot be undone.");
		} else {
			$decision = confirm("Are you sure you wish to archive the "+$valuesarry.length+" proof(s)?");
		}
		if($decision)
		{
			switch($action)
			{
				case '1':
					window.location = "admin_account.php?archive=true&status=8&archiveids="+$values;
					break;
				case '2':
					window.location = "admin_account.php?archive=true&status=9&archiveids="+$values;
					break;
				case '3':
					window.location = "admin_account.php?delete=true&deleteids="+$values;
					break;
				case '4':
					window.location = "admin_account.php?archive=true&status=11&archiveids="+$values;
					break;
			}
		} else {
			document.getElementById($this.id).options[0].selected = true;
		}
	} else {
		alert('No proofs were selected.');
		document.getElementById($this.id).options[0].selected = true;
	}
}

function deleteProof(id)
{
	var conf = confirm('Are you sure you wish to delete the proof? This action cannot be undone.');
	if(conf)
	{
		window.location='admin_account.php?deleteids=' + id;
	}
}