
var total = 0;

// Check all checkboxes on a report
function checkAll() {

	// Variables
	var value;
	var elements;
	
	// Get all the elements
	elements = getElementsByClass("report_checkbox");
	
	// See if the current box has been checked
	if (document.getElementById('select_main').checked) {
		
		value = true;

	} else {
		
		value = false;
		
	}
	
	for (var count=0; count<elements.length; count++) {
		
		elements[count].checked = value;
		id = elements[count].id.split("-");
		checkRow(id[1]);
	
	}

}

function checkRow(element) {
	
	var price = 0;
	if (document.getElementById('cell-' + element + '-user_ID')) {
		price = parseFloat(document.getElementById('cell-' + element + '-user_ID').innerHTML);
	}

	if (document.getElementById('checkbox-' + element).checked == true) {
		
		total = total + price;
		document.getElementById('row-' + element).className = "row-highlight";
		
	} else {
		
		total = total - price;
		document.getElementById('row-' + element).className = "row-standard";
	
	}
	
	// If the total box exists, then update it with the new value
	if (document.getElementById('report-total')) {
		
		document.getElementById('report-total').innerHTML = '&pound;' + total;
		
	}
	
}

var fields = new Array();

// Hide/Show elements on the profile pages
function toggle(field) {
	
	if (fields[field] != true) {
		
		document.getElementById(field).style.display = 'block';
		fields[field] = true;
		document.getElementById(field + '_link').style.display = 'none';
		
	} else {

		document.getElementById(field).style.display = 'none';
		fields[field] = false;
		document.getElementById(field + '_link').style.display = 'block';
	
	}

}

// THEMOOSE - FAULTY 
// 01/09/07 - I cannot get the form submit to work, by making the delete button use an onclick check
// and javascript submit it submits the form without passing any values, not even a $_POST is 
// available. I can think of no way to achieve this thus I have moved the delete button to be out of
// the way in the hope that it makes it less likely to accidently click on. G Donaldson.
function deleteWarning() {
	
	var check = confirm("Are you sure you wish to delete these rows?");
	if (check == true) {
		document.getElementById('report').submit();
	} else {
		//return false;
	}
	
}
