<!--
if(window.opener){
	var menuframe = window.opener.parent.frames[0];
}
else{
	var menuframe = window.parent.parent.frames[0]
}
var menuform = menuframe.document.menu;

function mylistsubmit(cmd){
	menuform.folder.value = folder;
	menuform.listcmd.value = cmd;
	menuform.cmd.value = "show";
	menuform.page.value = "framenew";
	menuform.submit();
}

function redirectf(){
	menuform.myuidl.value = document.email.myuidl.value;
	menuform.not_new.value = "true";
	menuform.redirect.value = "true";
	menuform.target = menuframe.openWindow();
	mylistsubmit('forward_edit-' + document.email.myuidl.value);
	if(netscape_version.indexOf("4.") >= 0){
		setTimeout(1000,'menuform.not_new.value = "";menuform.redirect.value = "";');
	}else{
		menuform.not_new.value = "";
		menuform.redirect.value = "";
	}
	return;
}

function fwd_reply(cmd){
	menuform.myuidl.value = document.email.myuidl.value;
	menuform.not_new.value = "true";
	menuform.target = menuframe.openWindow();
	mylistsubmit(cmd + document.email.myuidl.value);
	if(netscape_version.indexOf("4.") >= 0){
		setTimeout(1000,'menuform.not_new.value = "";menuform.redirect.value = "";');
	}else{
		menuform.not_new.value = "";
		menuform.redirect.value = "";
	}
	return;
}

function clickAddress(address){
	menuform.myuidl.value = document.email.myuidl.value;
	menuform.not_new.value = "false";
	menuform.target = menuframe.openWindow();
	mylistsubmit("forward_edit-" + document.email.myuidl.value);
	if(netscape_version.indexOf("4.") >= 0){
		setTimeout(1000,'menuform.not_new.value = "";menuform.redirect.value = "";');
	}else{
		menuform.not_new.value = "";
		menuform.redirect.value = "";
	}
	return;
}


function myprint(){
	window.open(action + "?cmd=item-" + uidl + "&page=print&folder=" + fld + "&utoken=" + utoken,"print","width=470,height=400,toolbar=no,location=no,directories=no,status=no,menubar=yes,resizable=yes,scrollbars=yes");
}

function hotkey(event){
	//alert(event.keyCode);
	switch (netscape_version ? event.which : event.keyCode) {
	   case 4 : // d - delete
			if(window.opener){
				window.opener.location = delitem + "next_popup&&";
				window.close();
			}
			else{
				window.parent.location = delitem + "next_preview&&";
			}
			break;
	   case 18 : // t - reply
			fwd_reply('msg_reply-');
			if(window.opener){
				window.close();
			}
			break;
	   case 1 : // a - replyall
			fwd_reply('msg_replyall-');
			if(window.opener){
				window.close();
			}
			break;
	   case 7 : // g - resend
			resend();
			if(window.opener){
				window.close();
			}
			break;
	   case 6 : // f - forward
			fwd_reply('forward_edit-');
			if(window.opener){
				window.close();
			}
			break;
	   case 5 : // e - redirect
			if(window.opener){
				redirectf();
				window.close();
			}
			else{
				redirectf();
			}
			break;
	   case 2 : // b - add to address book
			mysubmit('saveaddrbook-' + uidl);
			break;
	   case 14 : // n - add to recent addresses
			mysubmit('saveaddr-' + uidl);
			break;
	   case 16 : // p - print
			myprint();
			break;
	   case 91 : // [ - prev
			if(b_prev)
				document.location = b_prev;
			else
				alert('This is the first message in this folder');
			break;
	   case 93 : // ] - next
			if(b_next)
				document.location = b_next;
			else
				alert('This is the last message in this folder');
			break;
	   default :
			break;
	}
}

function hotkeyoverload(event){
	hotkey(event);
}

function do_command(command, msg)
{	
	if (top.stats) {
		if (top.stats.document) {
			top.stats.Message(msg);
		}
	}
	window.location = command;
}

function mysubmit(cmd)
{
	document.email.cmd.value = cmd;
	document.email.submit();
}

function mysubmit_layout(cmd, msg)
{
	if (top.stats) {
		if (top.stats.document) {
			top.stats.Message(msg);
		}
	}
	document.layout.cmd.value = cmd;
	document.layout.submit();
}

function do_reject(){
	if(confirm("Do you want to permanently delete this email and all other emails from this address?")){
		if(window.parent.frames[0] && window.parent.frames[0].document.List){
			window.parent.frames[0].location = action + "?cmd=add_reject&reject=" + h_from + "&utoken=" + utoken;
		}
		else{
			if(window.opener && window.opener.document.List){
				window.opener.location = action + "?cmd=add_reject&reject=" + h_from + "&page=listf2&utoken=" + utoken;
			}
			else{
				if(window.opener && window.opener.frames[0].document.List){
					window.opener.frames[0].location = action + "?cmd=add_reject&reject=" + h_from + "&utoken=" + utoken;
				}
			}
			window.close();
		}
	}
}

function getUID(){
	var now = new Date();
	var rnd = Math.random() + "";
	rnd = rnd.substring(0, rnd.indexOf('.')) + rnd.substring(rnd.indexOf('.')+1,rnd.length);
	return now.getMilliseconds() + "_" + rnd;
}

function press_email(address){
	var UID = getUID();
	var addr = address;
	
	at = address.indexOf('@');
	if (at >= 0) {
		q = address.indexOf('?',at);
		if (q >= 0) {
			addr = address.substr(0,q);
			temp = address.substr(q);

			at = temp.indexOf('body=');
			if (at >= 0) {
				at += 5;
				q = temp.indexOf('&',at);
				if (q >= 0)
					value = temp.substring(at,q);
				else
					value = temp.substr(at);

				addr = addr + '&my_body=' + value;
			}
			at = temp.indexOf('subject=');
			if (at >= 0) {
				at += 8;
				q = temp.indexOf('&',at);
				if (q >= 0)
					value = temp.substring(at,q);
				else
					value = temp.substr(at);

				addr = addr + '&my_subject=' + value;
			}
		}
	}


	window.open((action + "?cmd=show&page=framenew&listcmd=msg_new&utoken=" + utoken + "&my_from=" + addr),UID,'left=20,top=20,width=750,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=no');
}


if(netscape_version){
	document.captureEvents(Event.KEYPRESS);
	document.onkeypress = hotkey;
}

function myMove(){
	document.email.cmd.value = "moveitem-" + uidl;
	document.email.listcmd.value = "list";
	document.email.page.value = "framelist";
	document.email.target = "framelist";
	document.email.submit();
	if(b_next)
		document.location=b_next;
	else
		window.close();
}
//-->