DOM2Event.initRegistration(window);
window.addEventListener("load", tape_scheduler_toggle, false);

function tape_scheduler_toggle(event) {
	event = new DOM2Event(event, window.event, this);
    if (!document.getElementsByTagName) return;
	
	if (document.frmasset && document.frmasset.mod_tableedit__enable_tape_scheduler && document.frmasset.mod_tableedit__enable_tape_scheduler.value == "False") {
		// It's there and it's false so we need to hide the associated controls...
		tape_scheduler_toggle_tr(document.frmasset.mod_tableedit_asset_backup_period);
		tape_scheduler_toggle_tr(document.frmasset.mod_tableedit_asset_last_backup_date);
		tape_scheduler_toggle_tr(document.frmasset.mod_tableedit_asset_next_retrieval_date);
	}

	if (document.frmasset && document.frmasset.mod_tableedit__enable_tape_scheduler)
		document.frmasset.mod_tableedit__enable_tape_scheduler.parentNode.parentNode.style.display = "none";
}

function tape_scheduler_toggle_tr(tr_td_child) {
	if (tr_td_child && tr_td_child.parentNode && tr_td_child.parentNode.parentNode) {
		var tr = tr_td_child.parentNode.parentNode;
		tr.childNodes[1].style.color = "#AAAAAA";
		tr.childNodes[1].innerHTML = "The tape scheduler is not enabled."
	}
}
