row_toggle.js 1.78 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
function fr_toggle(id, prefix) {
	if (!prefix)
		prefix = 'fr';

	var checkbox = document.getElementById(prefix + 'c' + id);
	checkbox.checked = !checkbox.checked;
	fr_bgcolor(id, prefix);
}

function fr_bgcolor(id, prefix) {
	if (!prefix)
		prefix = 'fr';

	var row = document.getElementById(prefix + id);
	var checkbox = document.getElementById(prefix + 'c' + id);
	var cells = row.getElementsByTagName('td');
	var cellcnt = cells.length;

	for (i = 0; i < cellcnt; i++) {
		// Check for cells with frd id only
		if (cells[i].id == prefix + 'd' + id)
			cells[i].style.backgroundColor = checkbox.checked ? "#FFFFBB" : "#FFFFFF";
	}
	//cells[7].style.backgroundColor = checkbox.checked ? "#FFFFBB" : "#990000";
}

function fr_insline(id, on, prefix) {
	if (!prefix)
		prefix = 'fr';

	var row = document.getElementById(prefix + id);
	var prevrow;
	if (id != 0) {
		prevrow = document.getElementById(prefix + (id-1));
	} else {
		prevrow = document.getElementById(prefix + 'header');
	}

39
	var cells = row.getElementsByTagName("td");
Ad Schellevis's avatar
Ad Schellevis committed
40
	var prevcells = prevrow.getElementsByTagName("td");
41

Ad Schellevis's avatar
Ad Schellevis committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
	for (i = 0; i <= prevcells.length - 1; i++) {
		if (prevcells[i].id == prefix + 'd' + (id-1)) {
			if (on) {
				prevcells[i].style.borderBottom = "3px solid #990000";
				prevcells[i].style.paddingBottom = ((id != 0) ? 2 : 3) + "px";
			} else {
				prevcells[i].style.borderBottom = "1px solid #999999";
				prevcells[i].style.borderBottomWidth = "1px";
				prevcells[i].style.paddingBottom = ((id != 0) ? 4 : 5) + "px";
			}
		}
	}

	for (i = 0; i <= cells.length - 1; i++) {
		if (cells[i].id == prefix + 'd' + (id)) {
			if (on) {
				cells[i].style.borderTop = "2px solid #990000";
				cells[i].style.paddingTop = "2px";
			} else {
				cells[i].style.borderTopWidth = 0;
				cells[i].style.paddingTop = "4px";
			}
		}
	}
}