<!--
function newwindow()
{
	msgWindow = open(action + '?process=addr_only&cmd=msg_new&utoken=' + putoken,'ADDRESSBOOK','width=600,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes','POPUP');
	if (msgWindow.opener == null) msgWindow.opener = self;
        if (msgWindow.opener.sendform == null) msgWindow.opener.sendform = document.sendform;
	msgWindow.focus();
}

function setTitle(){
	window.top.document.title = title + " - Create new message";
}

function setSig(){
	document.sendform.addsig.value = "off";
	for (var i = 1;document.sendform._default_profile.options[i];i++){
		if (document.sendform._default_profile.options[i].selected)
			document.sendform.addsig.value = "on";
	}
}

function setBody(url){
	if(parent.frames[1].itembody != "true"){
		parent.frames[1].document.location.replace(url);
	}
}

var sending1 = new Image();
var sending2 = new Image();
sending1.src = nwimg + "/sending.gif";
sending2.src = nwimg + "/send.gif";

function sendingOff(){
	document.sendImg.src = sending2.src;
	setTimeout("sending()", 500);
}

function sending(){
	document.sendImg.src = sending1.src;
	setTimeout("sendingOff()", 500);
}

function mySend(cmd){
	if(!window.parent.frames[1].init_done){
		alert("Please wait until the page has fully loaded");
		return;
	}
	if(cmd=="send"){
		var to = document.sendform.to.value;
		if(document.sendform.to.value.length < 2){
			if(document.sendform.bcc.value.length < 2){
				if(document.sendform.cc.value.length < 2){
					alert("You need to enter either a To:, CC: or BCC: address to send to");
					return;
				}
			}
		}
		if(to.substr(to.length-4, to.length) == '@sms') {
			size = window.parent.frames[1].document.bodyform.message.value.length + document.sendform.from.value.length + document.sendform.subject.value.length;
			if (size >= 150) {
				alert("When sending to an '@sms' address your email MUST be less than 150 characters\nCharacters Used: " + size);
				return;
			}
		}

		if (max_email_send_size > 0) {
			var msg_size = 1000 + total_attach_est + window.parent.frames[1].document.bodyform.message.value.length;
			if (max_email_send_size < msg_size) {
				alert("Email to large send, please reduce the size or remove attachments");
				return;
			}
		}

		sending();
		if(isdraft && document.sendform._del_draft.checked){
			document.sendform.cmd.value = 'delitem-' + uidl;
			document.sendform.process.value = cmd;
			document.sendform.myuidl.value = '';
		}
		else
			document.sendform.cmd.value = cmd;
		if (a_s == 'true') {
			document.sendform.sender.value = document.sendform.from.value;
		}
	}
	else
		document.sendform.cmd.value = cmd;
	document.sendform.message.value = window.parent.frames[1].document.bodyform.message.value;
	document.sendform.submit();
}

function saveDraft(){
	document.sendform.message.value = window.parent.frames[1].document.bodyform.message.value;
	if(isdraft){
		if (confirm("Do you wish to replace the current Draft message?")) {
			document.sendform.cmd.value = 'delitem-' + uidl;
			document.sendform.process.value = "save_draft";
			document.sendform.submit();
			return;
		}
	}
	document.sendform.cmd.value = "save_draft";
	document.sendform.submit();
}

function hotkey(event){
	switch (event.keyCode) {
	   case 10 : // Ctrl-Enter || Ctrl-Shift-J - send
			mySend("send");
			break;
	   case 2 : // Ctrl-Shift-B - open address book
			newwindow();
			break;
	   case 19 : // Ctrl-Shift-S - check spelling
			mySend("spell_check");
			break;
	   case 1 : // Ctrl-Shift-A - add attachment
			mySend("add_attach");
			break;
	   default :
			break;
	}
}

function hotkeyoverload(){
	hotkey(event);
}

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

function wys_update()
{
	if (wys) {
		window.parent.frames[1].wys_update();
	}
}

function do_wys()
{
	wys_update();
	document.sendform.message.value = window.parent.frames[1].document.bodyform.message.value;
	document.sendform.not_new.value = "true";
	document.sendform.cmd.value = "attach_msg";
	if (wys) {
		document.sendform.msg_alternative.value="";
//		document.sendform.content_type.options[0].selected = true;
		document.sendform._auto_wysiwyg.value="false";
	}
	else {
		document.sendform.msg_alternative.value="true";
		document.sendform._auto_wysiwyg.value="true";
	}
	parent.frames[1].itembody = "false";
	document.sendform.submit();
}
//-->