<!--
var menuframe = null;
var menuform = null;

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

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

function redirectf(){
	findMenu();
	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 || (navigator.userAgent.indexOf("MSIE") >= 0 && navigator.userAgent.indexOf("Mac") >= 0) ){
		setTimeout('menuform.not_new.value = "";menuform.redirect.value = "";', 1000);
	}else{
		menuform.not_new.value = "";
		menuform.redirect.value = "";
	}
	return;
}

function fwd_reply(cmd){
	findMenu();
	menuform.my_from.value = "";
	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 || (navigator.userAgent.indexOf("MSIE") >= 0 && navigator.userAgent.indexOf("Mac") >= 0) ){
		setTimeout('menuform.not_new.value = "";menuform.redirect.value = "";', 1000);
	}else{
		menuform.not_new.value = "";
		menuform.redirect.value = "";
	}
	return;
}

function clickAddress(address){
	findMenu();
	menuform.my_from.value = address;
//	menuform.myuidl.value = document.email.myuidl.value;
	menuform.myuidl.value = "";
	menuform.not_new.value = "false";
	menuform.encode_text.value = "my_from";
	menuform.target = menuframe.openWindow();
	mylistsubmit("msg_new");
	if(netscape_version.indexOf("4.") >= 0 || (navigator.userAgent.indexOf("MSIE") >= 0 && navigator.userAgent.indexOf("Mac") >= 0) ){
		setTimeout('menuform.not_new.value = "";menuform.redirect.value = "";menuform.encode_text.value = "";', 1000);
	}else{
		menuform.not_new.value = "";
		menuform.redirect.value = "";
		menuform.encode_text.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){
				var url = action + "?cmd=add_reject&reject=" + h_from + "&page=listf2&utoken=" + utoken;
				window.opener.location = url;
			}
			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 do_accept(){
	window.location = action + "?cmd=add_accept&process=item-" + uidl + "&require_lock=true&get_attach_id=true&folder=" + fld + "&java_email=true&accept=" + h_from + "&utoken=" + utoken;
}

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 get_select(d)
{
	data = "";
	for (i=0;i<d.length;i++) {
		if (d[i].selected) {
			data = d[i].text;
			if (!data.length)
				data = d[i].value;
		}
	}
	return data;
}

function myMove(){
	if(b_next)
		document.location=b_next+"&domoveuid="+uidl+"&dstfld="+document.email.dstfld_sel.value+"&&";
	else {
		document.email.cmd.value = "moveitem-" + uidl;
		document.email.listcmd.value = "list";
		document.email.dstfld.value = get_select(document.email.dstfld_sel);
		document.email.page.value = "framelist";
		document.email.target = "framelist";
//		document.email.domoveuid.value = uidl;
		document.email.submit();

		window.close();
	}
}
//-->