function check_selected(formid) {
	var e = document.forms[formid].elements;
	var allchecked = true;

	for (var i=0; i<e.length; i++) {
		if (e[i].type == "checkbox") {
			if (!e[i].checked) {
				allchecked = false;
			}
		}
	}
}

function hilite_row(formid, chkbox,docheck) {
	var e = chkbox;

    while (e && e.tagName != "TR") {
		e = e.parentNode;
	}

	if (chkbox.checked) e.className = "tr_hilighted";
	else e.className = "tr_normal";

	if (docheck) check_selected(formid);
}

function selectallcheckboxes(formid,val) {
	var e = document.forms[formid].elements;
	for (var i=0; i<e.length; i++) {
		if (e[i].type == "checkbox") {
			e[i].checked = val;
			hilite_row(formid, e[i],false);
		}
	}

	check_selected(formid);
}

function opensmallwin(url) {
	if(navigator.appVersion.substring(0,1) <3) return false ;

	remote = window.open(url,"small","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=200,height=150");

	self.name = "mainwin";
	remote.focus();

	return true;
}

function openlargewin(url) {
	if(navigator.appVersion.substring(0,1) <3) return false ;

	remote = window.open(url,"large","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=560");

	self.name = "mainwin";
	remote.focus();

	return true;
}


function manage_attachments(parentformid) {
	document.getElementById(parentformid).add_attachment.value = 1;

	submitform(parentformid);

}


function deletewarning(msg) {
	return(confirm("Are you sure you want to delete " + msg + "?"));
}

function do_stuff(url) {
 	remote = window.open(url,"mgrsubwin","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=400");
	remote.focus();
}

function submitform(parentformid) {
	document.getElementById(parentformid).submit();
	return true;
}

function openmgrsubwin(url) {
	remote = window.open(url,"mgrsubwin","toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=400");
	remote.focus();
	return true;
}

function submitform2(e) {
    var frm = document.forms[e];

    if (frm) frm.submit();
}


