
function OpenWindow (type,loc,handle)
{
var wnd="";
var myWindow = window.open (loc, wnd, "resizable=yes,scrollbars=yes,status=0,width=440,height=270");
if (navigator.appName=='Netscape') { myWindow.focus(); }
if (handle==1) { return myWindow; }
}
var numAttachments = 0;
var whitespace = "\t\n\r ";
var defaultEmptyOK = false;
var invalidAddrChars = "\\\/\"<>(),;:$&!\`\'^*|[]{}";
var invalidDomainChars = "\\\/\"<>(),;:$&!\`\'^*@|{}";
var emptyAddr = true;
var ErrorAddrChars = "";
var ToVal = "";var CCVal = "";var BccVal = "";
var numAttachments = 0;
<!--- hide script from old browsers
function dele(){
var i = 0, j;
for (j=0; j<5; j++)
if (document.Send.oo[j].checked == true) i = j;
if (i==0)
document.Send.MFrom.value = "";
if (i==1)
document.Send.MTo.value = "";
if (i==2)
document.Send.MCC.value = "";
if (i==3)
document.Send.MBCC.value = "";
if (i==4)
document.Send.MReplyTo.value = "";
document.Send.tolist.options[0].selected = true;
}
function vesetfn(fn,dc) {
dc.Send.Mvfn.value = fn;
}
// add to to or cc from opened window, dc mean window.opener.document
function wsetto(str,dc) {
var option;
var i;
if (dc.Send.oo[0].checked == true){
if (dc.Send.MFrom.value != "")
dc.Send.MFrom.value = ", " + dc.Send.MFrom.value;
dc.Send.MFrom.value = str + dc.Send.MFrom.value;
}
if (dc.Send.oo[1].checked == true){
if (dc.Send.MTo.value != "")
dc.Send.MTo.value = ", " + dc.Send.MTo.value;
dc.Send.MTo.value = str + dc.Send.MTo.value;
}
if (dc.Send.oo[2].checked == true){
if (dc.Send.MCC.value != "")
dc.Send.MCC.value = ", " + dc.Send.MCC.value;
dc.Send.MCC.value = str + dc.Send.MCC.value;
}
if (dc.Send.oo[3].checked == true){
if (dc.Send.MBCC.value != "")
dc.Send.MBCC.value = ", " + dc.Send.MBCC.value;
dc.Send.MBCC.value = str + dc.Send.MBCC.value;
}
if (dc.Send.oo[4].checked == true){
if (dc.Send.MReplyTo.value != "")
dc.Send.MReplyTo.value = ", " + dc.Send.MReplyTo.value;
dc.Send.MReplyTo.value = sel.options[i].value + dc.Send.MReplyTo.value;
}
}
function setto(sel) {
var option;
var i;
for (i=0; i<sel.options.length; i++) {
if (sel.options[i].selected==true) {
if (document.Send.oo[0].checked == true){
if (document.Send.MFrom.value != "")
document.Send.MFrom.value = ", " + document.Send.MFrom.value;
document.Send.MFrom.value = sel.options[i].value + document.Send.MFrom.value;
}
if (document.Send.oo[1].checked == true){
if (document.Send.MTo.value != "")
document.Send.MTo.value = ", " + document.Send.MTo.value;
document.Send.MTo.value = sel.options[i].value + document.Send.MTo.value;
}
if (document.Send.oo[2].checked == true){
if (document.Send.MCC.value != "")
document.Send.MCC.value = ", " + document.Send.MCC.value;
document.Send.MCC.value = sel.options[i].value + document.Send.MCC.value;
}
if (document.Send.oo[3].checked == true){
if (document.Send.MBCC.value != "")
document.Send.MBCC.value = ", " + document.Send.MBCC.value;
document.Send.MBCC.value = sel.options[i].value + document.Send.MBCC.value;
}
if (document.Send.oo[4].checked == true){
if (document.Send.MReplyTo.value != "")
document.Send.MReplyTo.value = ", " + document.Send.MReplyTo.value;
document.Send.MReplyTo.value = sel.options[i].value + document.Send.MReplyTo.value;
}
}
}
if (sel.options[0].selected==true){
dele();
}
}
// end hiding from old browsers -->
function ChangeStationery(){
var s = "";
var sStationery = "";
var sNew = "";
var bFoundTable = false;
var nIndex = 0;
var nLen = 0;
sStationery = self.document.Send.StationeryID.options[self.document.Send.StationeryID.selectedIndex].value;
sNew = "<table border=0 width=100% bgcolor=#FFFFFF background=\"stationery/" + sStationery + "\"><tr><td>\n";
if (navigator.appName!='Netscape')
{
s = self.document.Send.msg.html;
nLen = s.length;
nIndex = s.indexOf("\n");
sFirstLine = s.substring(0,nIndex);
if( sFirstLine.indexOf("TABLE")!=-1 )
bFoundTable = true;
if( bFoundTable != true )
{
sNew += sFirstLine;
}
sNew += s.substring(nIndex,nLen);
if( bFoundTable != true )
{
sNew += "\n</td></tr></table>";
}
self.document.Send.msg.html = sNew;
}
}
function setBody(sBody){
self.document.Send.msg.html = sBody;
}
function Preview()
{
var	i = 0;
var	j = 0;
var	charsSinceLastNewline = 0;
var	s = "";
var	s1 = "";
var	s2 = "";
if (navigator.appName!='Netscape')
s = self.document.Send.msg.html;
else s = document.Send.MText.value;
while ( i < s.length )
{
if ( s.charAt(i) == "\n" )
{
charsSinceLastNewline = 0;
i++;
}
else if ( charsSinceLastNewline == 80 )
{
for (j = 80;
s.charAt(i) != " " && s.charAt(i) != "\t" && j > 0;
j--, i--);
if ( j == 0 )
{
for (i = i + 80;
i < s.length && s.charAt(i) != " " &&
s.charAt(i) != "\t" && s.charAt(i) != "\n";
i++);
if ( i < s.length )
{
s1 = s.substring (0,i);
s2 = s.substring (i+1,s.length);
s = s1 + "\n" + s2;
i++;
charsSinceLastNewline = 0;
}
}
else
{
s1 = s.substring (0,i);
s2 = s.substring (i+1,s.length);
s = s1 + "\n" + s2;
i++;
charsSinceLastNewline = 0;
}
}
else
{
i++;
charsSinceLastNewline++;
}
}
document.HiddenPreviewForm.MFrom.value = document.Send.MFrom.value;
document.HiddenPreviewForm.MTo.value = document.Send.MTo.value;
document.HiddenPreviewForm.MCC.value = document.Send.MCC.value;
document.HiddenPreviewForm.MSubject.value = document.Send.MSubject.value;
document.HiddenPreviewForm.MText.value = s;
document.HiddenPreviewForm.Stationery.value = document.Send.StationeryID.options[document.Send.StationeryID.selectedIndex].value;
document.HiddenPreviewForm.ContentType.value = document.Send.ContentType.value;
previewWindow = window.open("/null.htm", "HtmlPreview", "resizable=yes,scrollbars=yes,scrolling=auto,status=0,width=600,height=500");
document.HiddenPreviewForm.submit();
if (navigator.appName=='Netscape') { previewWindow.focus(); }
}
function SpellCheck()
{
var mtext;
if (navigator.appName!='Netscape')
mtext = self.document.Send.msg.html;
else mtext = document.Send.MText.value;
if (mtext.length == 0)
{
alert("Message is empty!");
}
else
{
document.SpellCheckForm.MText.value = mtext;
spellWin = window.open("/null.htm", "SpellCheck", "resizable=yes,scrollbars=yes,scrolling=auto,status=0,width=600,height=500");
document.SpellCheckForm.submit();
if (navigator.appName=='Netscape') { spellWin.focus(); }
}
}
function VoiceMail()
{
voiceWin = window.open("/null.htm", "VoiceMail", 'resizable=yes,scrollbars=yes,scrolling=auto,status=0,width=620,height=400');
document.VoiceMailForm.submit();
if (navigator.appName=='Netscape') { voiceWin.focus(); }
}
function inneradd(url)
{
innerWin = window.open(url, "grouplist", 'resizable=yes,scrollbars=yes,scrolling=auto,status=0,width=620,height=400');
if (navigator.appName=='Netscape') { innerWin.focus(); }
}
function vmail(url)
{
innerWin = window.open(url, "vmail", 'resizable=yes,scrollbars=yes,scrolling=auto,status=1,width=620,height=400');
if (navigator.appName=='Netscape') { innerWin.focus(); }
}
function AddSignature()
{
var mtext;
if (navigator.appName!='Netscape')
mtext = self.document.Send.msg.html;
else mtext = document.Send.MText.value;
signatureWin = window.open("/null.htm", "AddSignature", "resizable=yes,scrollbars=yes,scrolling=auto,status=0,width=600,height=500");
document.AddSignatureForm.submit();
signatureWin.focus();
}
function ValidRecip()
{
if (validateRecips())
SendMail();
}
function ValidateScheduling()
{
if (validateRecips())
SendMail();
}
function isEmpty(s)
{
if (s == null || s.length == 0) return true;
return false;
}
function isWhitespace(s)
{   var i,c;
// Is s empty?
if (isEmpty(s)) return true;
// Search through string's characters one by one
// until we find a non-whitespace character.
// When we do, return false; if we don't, return true.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
c = s.charAt(i);
if (whitespace.indexOf(c) != -1 ) return true;
}
// All characters are whitespace.
return false;
}
function isEmail (s)
{
if (isEmpty(s))
if (isEmail.arguments.length == 1) return defaultEmptyOK;
else return (isEmail.arguments[1] == true);
// is s whitespace?
if (isWhitespace(s)) return false;
/*
// there must be >= 1 character before @, so we
// start looking at character position 1
// (i.e. second character)
var i = 1;
var sLength = s.length;
// look for @
while ((i < sLength) && (s.charAt(i) != "@"))
{ i++
}
if ((i >= sLength) || (s.charAt(i) != "@")) return false;
else i += 2;
// look for .
while ((i < sLength) && (s.charAt(i) != "."))
{ i++
}
// there must be at least one character after the .
if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
else return true;
*/
return true;
}
function isEmailChars(s)
{
var i;
var usrName,domainName;  //break the email address into two parts for testing
ErrorAddrChars = "";
if (isEmpty(s))
if (isEmailChars.arguments.length == 1) return defaultEmptyOK;
else return (isEmailChars.arguments[1] == true);
// is s whitespace?
if (isWhitespace(s)) return false;
// Search through string's characters one by one
// until we find an invalid character.
// When we do, return false; if we don't, return true.
// breaking the email address into two substrings for char testing
i = s.indexOf('@');
usrName = s.substring(0,i);
domainName = s.substring(i,s.length);
// Check that current character before @ is valid
for (i=0;i < usrName.length; i++)
{
if (invalidAddrChars.indexOf(usrName.charAt(i)) != -1 )
{
ErrorAddrChars += usrName;
emptyAddr = false;
}
if ( ErrorAddrChars.length > 0 ) return false;
}
// Check that current character after @ is valid
for (i=1;i < domainName.length; i++)
{
if (invalidDomainChars.indexOf(domainName.charAt(i)) != -1 )
{
ErrorAddrChars += domainName;
emptyAddr = false;
}
if ( ErrorAddrChars.length > 0 ) return false;
}
return true;
}
function SendMail()
{
var redirTo;
document.Send.SendAction.value = "Send";
document.Send.submit();
}
function RespUpdate()
{
//Clear Parsestring
ParseString = "";
BuildWhenParseString();
if ( CheckForBlankFields())
{
return true;
}
return false;
}
function Postpone()
{
var to = null;
var cc = null;
var bcc = null;
window.globalValid = false;
to  = subaliases(self.document.Send.MTo.value,"To");
cc  = subaliases(self.document.Send.MCC.value,"Cc");
bcc = subaliases(self.document.Send.MBCC.value,"Bcc");
if (to!=null)
self.document.Send.MTo.value = to;
if (cc!=null)
self.document.Send.MCC.value = cc;
if (bcc!=null)
self.document.Send.MBCC.value = bcc;
if (navigator.appName!='Netscape')
self.document.Send.MText.value = self.document.Send.msg.html;
document.Send.SendAction.value = "SaveDraft";
document.Send.target = "savedraft";
savedraftWin = window.open("/null.htm", "savedraft", "resizable=yes,scrollbars=yes,scrolling=auto,status=0,width=400,height=300");
document.Send.submit();
document.Send.target = "_self";
}
function setStationery()
{
list = document.Send.StationeryID;
for (i=0; i<list.length; i++)
{
if (list.options[i].value == '')
{
list.selectedIndex = i;
break;
}
}
}
function CloseThis()
{
self.close();
}
var globalValid = true;
function validateRecips()
{
var to = null;
var cc = null;
var bcc = null;
var fax = null;
var toValid = false;
var ccValid = false;
var bccValid = false;
var faxValid = false;
window.globalValid = false;
to  = subaliases(self.document.Send.MTo.value,"To");
toValid = window.globalValid;
cc  = subaliases(self.document.Send.MCC.value,"Cc");
ccValid = window.globalValid;
bcc = subaliases(self.document.Send.MBCC.value,"Bcc");
bccValid = window.globalValid;
faxValid = true;
if ((to==null && emptyAddr==true))
{
alert ("You must provide a valid e-mail address in the To: field.");
return false;
}
if (toValid && ccValid && bccValid && faxValid)
{
if (to!=null)
self.document.Send.MTo.value = to;
if (cc!=null)
self.document.Send.MCC.value = cc;
if (bcc!=null)
self.document.Send.MBCC.value = bcc;
if (navigator.appName!='Netscape'){
   if(self.document.Send.ChangeTmpl.selectedIndex==0){
      self.document.Send.MText.value = self.msg.Composition.document.body.innerHTML;
   }else{
	  self.document.Send.MText.value = self.msg.Composition.document.body.innerText;
   }
}
}
return (toValid && ccValid && bccValid && faxValid);
}

function subaliases(str,field)
{
var returnlist = null;
var temp = null;
var tok = null;
var temp2 = null;
var errmsg = null;
window.globalValid = true;
temp = strtok(str,";,");
tok = trimtokens(temp,";,");
ErrorAddrChars = "";
while(tok!=null)
{
// if the token is a valid email address, leave it alone
// else see if it is in the list
if (valid_email_address(tok))
email = tok;
else
email = getemailaddr(tok);
if (email==null)
{
window.globalValid = false;
errmsg = "The \"Email "+field+":\" field must contain a valid e-mail address.";
if ( ErrorAddrChars.length > 0 )
{
errmsg += "\n" + "Illegal character(s) used in email address:" + ErrorAddrChars + "\n";
}
alert (errmsg);
}
else
{
if (returnlist==null)
returnlist = email;
else
{
temp = returnlist+","+email;
returnlist = temp;
}
}
temp = strtok(null,";,");
tok = trimtokens(temp,";,");
}
return returnlist;
}
function valid_email_address(addr)
{
var valid = true;
var l_angle = 0;
var r_angle = 0;
var temp;
l_angle = addr.indexOf("<");
r_angle = addr.indexOf(">");
if (l_angle==-1 && r_angle==-1)
{
temp = addr;
}
else if ( (l_angle+1) < r_angle)
{
temp = addr.substring(l_angle+1,r_angle-1)
}
valid = is_simple_address(temp);
if (valid)
{
valid = isEmailChars(temp);
}
return valid;
}
function is_simple_address(addr)
{
var good_address = true;
var at_sign = 0;
var space = 0;
space = addr.indexOf(" ");
at_sign = 1;
if (space>=0 || at_sign<=0 || at_sign==(addr.length-1) || !isEmail(addr))
good_address = false;
return good_address;
}
/************************************/
/* START_FAX_SERVICE_CODE */
/************************************/
function validFaxRecips(str,field)
{
var returnlist = null;
var temp = null;
var tok = null;
var temp2 = null;
var faxNum = null;
window.globalValid = true;
temp = strtok(str,";,");
tok = trimtokens(temp,";,");
while(tok!=null)
{
// if the token is a valid Fax #, leave it alone
// else see if it is in the list
if (valid_fax_num(tok))
faxNum = tok;
else
{
faxNum = getFaxNum(tok);
// if an invalid fax # was found in the personal address book,
// simply return with the valid flag set to false.
if (faxNum == -1)
{
window.globalValid = false;
return null;
}
}
if (faxNum==null)
{
window.globalValid = false;
alert("");
}
else
{
if (returnlist==null)
returnlist = faxNum;
else
{
temp = returnlist+","+faxNum;
returnlist = temp;
}
}
temp = strtok(null,";,");
tok = trimtokens(temp,";,");
}
return returnlist;
}
function valid_fax_num(tok)
{
var valid = true;
var l_angle = 0;
var r_angle = 0;
var temp;
valid = is_simple_faxnum(tok);
if (!valid)
{
l_angle = tok.indexOf("<");
r_angle = tok.indexOf(">");
if (l_angle==-1 && r_angle==-1)
{
valid = false;
}
else if ( (l_angle+1) < r_angle)
{
temp = tok.substring(l_angle+1,r_angle-1)
valid = is_simple_faxnum(temp);
}
}
return valid;
}
function is_simple_faxnum(tok)
{
var faxNum_ok = true;
if (tok.length == 0)
faxNum_ok = false;
else
{
for (i=0;i<tok.length;i++)
{
c = tok.charAt(i);
if ( (c<"0" || c>"9") && c!="-" && c!="." && c!="(" && c!=")" && c!=" ")
{
faxNum_ok = false;
break;
}
}
}
return faxNum_ok;
}
function getFaxNum(tok)
{
var faxNum = null;
var faxOffset = 0;
return faxNum;
}
function AddToFax()
{
var name = null;
var temp = null;
var faxRecip = null;
for (var i = 0; i < document.Send.addresses.length; i++)
{
if (document.Send.addresses.options[i].selected)
{
document.Send.addresses.options[i].selected = false;
temp = strtok(document.Send.addresses.options[i].value, "<");
name = trimtokens(temp," ");
faxRecip = getFaxNum(name);
if (faxRecip == null)
alert('Selecting a distribution list as a fax recipient is not supported.');
else if (faxRecip != -1)
{
if (document.Send.MFax.value == "")
{
document.Send.MFax.value = faxRecip;
}
else
{
document.Send.MFax.value = document.Send.MFax.value + ", " +
faxRecip;
}
}
}
}
}
/************************************/
/* END_FAX_SERVICE_CODE */
/************************************/
function strtok(str,tokens)
{
var ltok;
var localstr;
var tempindex;
var temp;
if (str==null && staticstr==null)
return null;
if (str!=null)
staticstr = str;
localstr = trimtokens(staticstr,tokens);
minindex = 9999;
for (iii=0;iii<tokens.length;iii++)
{
if (localstr!=null)
{
tempindex = localstr.indexOf(tokens.charAt(iii));
if (tempindex<minindex && tempindex>=0)
minindex = tempindex;
}
}
if (minindex!=999 && localstr!=null)
{
ltok = localstr.substring(0,minindex);
staticstr = localstr.substring(minindex+1,localstr.length);
}
else
{
ltok = staticstr;
staticstr = null;
}
if (ltok.length<1)
return null;
else
return ltok;
}
strtok.staticstr = null;
function trimtokens(str,tokens)
{
var tempindex = 9999;
var minindex = 9999;
var keeplooking = true;
var quit = true;
var localtoks = tokens+" ";
if (str==null)
return str;
// leading tokens
while(keeplooking==true)
{
quit = true;
for (iii=0;iii<localtoks.length;iii++)
{
if (str.charAt(0)==localtoks.charAt(iii))
{
quit = false;
temp = str.substring(1,str.length);
str = temp;
}
}
if (quit==false)
keeplooking = true;
else
keeplooking = false;
}
//trailing tokens
keeplooking = true;
while(keeplooking==true)
{
quit = true;
for (iii=localtoks.length-1;iii>=0;iii--)
{
if (str.charAt(str.length-1)==localtoks.charAt(iii))
{
quit = false;
temp = str.substring(0,str.length-1);
str = temp;
}
}
if (quit==false)
keeplooking = true;
else
keeplooking = false;
}
return str;
}
function getemailaddr(tok)
{
var addr = null;
var temp = null;
var build_addr = false;
// return null or last list in companyAddressBook
return addr;
}
function ConvertSignatureID()
{
document.Send.SignatureID.value = document.NetscapeSignature.SignatureID.options[document.NetscapeSignature.SignatureID.selectedIndex].value;
}
function SubmitForTranslate()
{
if ( document.Send.translate.selectedIndex == 0 && document.Toolbar.translate.selectedIndex == 0 ) return;
if ( document.Toolbar.translate.selectedIndex != 0 )
document.Send.translate.selectedIndex = document.Toolbar.translate.selectedIndex;
if ( document.Send.translate.selectedIndex != 0 )
{
Translate = window.open('/tpl/Message/211PMYVZR/Translate_blank', 'Translate', 'resizable=yes,toolbar=no,menubar=no,width=550,height=525');
document.MsgTranslate.MText.value = document.Send.MText.value;
document.MsgTranslate.translate.value = document.Send.translate.options[document.Send.translate.selectedIndex].value;
}
document.MsgTranslate.submit();
}
function PopulateToField()
{
var addr;
addr = window.opener.WriteMailPopUp_Mto;
if (addr.length>0)
{
document.Send.MTo.value = addr;
}
}
