function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className = this.className.replace(" over", "");
				}
			}			
		}
	}
}

function checkAll(frm, chk) {
	var form = frm.elements;
	for(i=0; i<form.length; i++) {
		if (form[i].type == 'checkbox') {
			form[i].checked = chk;
		}
	}
}

function redirect(url) {
	location.href = url;
}

function openSendWin(sendId, sessionId) {
	var w = 300;
	var h = 225;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	window.open('msgs_send_queue.php?id='+sendId+'&sid='+sessionId, 'MessageSender', 'left='+l+',top='+t+',width='+w+',height='+h+',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');
}
function openDateWin() {
	var w = 425;
	var h = 75;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	window.open('timestamp_creator.php', 'TimestampCreator', 'left='+l+',top='+t+',width='+w+',height='+h+',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');
}

function numbersOnly(myfield, e) {
	var key;
	var keychar;
	
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	
	keychar = String.fromCharCode(key);
	
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27)) // control keys
		return true;
	else if ((("0123456789").indexOf(keychar) > -1)) // numbers
		return true;
	else
		return false;
}

function hideLoadingMsg() {
	if (document.getElementById) // DOM3 = IE5, NS6
		document.getElementById('loadingMsg').style.visibility = 'hidden';
	else {
		if (document.layers) // Netscape 4
			document.loadingMsg.visibility = 'hidden';
		else // IE 4
			document.all.loadingMsg.style.visibility = 'hidden';
	}
	
}

function hideMsg(msg, hide) {
	if (document.getElementById) // DOM3 = IE5, NS6
	{
		if ( hide )
			document.getElementById(msg).style.visibility = 'hidden';
		else
			document.getElementById(msg).style.visibility = 'visible';
	}
	else
	{
		if (document.layers) // Netscape 4
		{
			msgElement = eval("document."+msg);

			if ( hide )
				msgElement.visibility = 'hidden';
			else
				msgElement.visibility = 'show';
		}
		else // IE 4
		{
			msgElement = eval("document.all."+msg+".style");

			if ( hide )
				msgElement.visibility = 'hidden';
			else
				msgElement.visibility = 'visible';
		}
	}
}

function insertMsgCode(obj, val) {
	document.getElementById(obj).value += val;
	document.getElementById(obj).focus();
}

function styleMsg(msg, atr, val) {
	var str;
	if (document.getElementById) // DOM3 = IE5, NS6
	{
		if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0)
		{
			document.getElementById(msg).style.setAttribute(atr, val);
		}
		else
		{
			document.getElementById(msg).style.setProperty(atr, val, null);
		}
	}
	else
	{
		if (document.layers) // Netscape 4
		{
			eval("document."+msg+"."+atr+"="+val);
		}
		else // IE 4
		{
			eval("document.all."+msg+".style."+atr+"="+val);
		}
	}
}

function sendTestEmail(form, sessionId) {
	var sendTo = escape(form.test_send_to.value);
	var w = 350;
	var h = 125;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;

	window.open('msgs_send_test.php?email='+sendTo+'&sid='+sessionId, 'SendTestMessage', 'left='+l+',top='+t+',width='+w+',height='+h+',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');
}

function manageAttachments(sessionId) {
	var w = 600;
	var h = 400;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;

	window.open('msgs_attach.php?sid='+sessionId, 'ManageAttachments', 'left='+l+',top='+t+',width='+w+',height='+h+',toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');
}

function SpamCheck(sessionId) {
	var w = 700;
	var h = 450;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;

	window.open('plugins/spamcheck/spamcheck.php?sid='+sessionId, 'SpamCheck', 'left='+l+',top='+t+',width='+w+',height='+h+',toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0');
}

