// footer.js

var i;
var gnPosTitle;
var gnLenTitle;

gsPageName = document.location.pathname.toLowerCase ();
//document.write ('Name = ', gsPageName, '<BR>');

gnPosLast = gsPageName.length - 1;
//document.write ('Pos = ', gnPosLast, '<BR>');

gcNameLast = gsPageName.substr (gnPosLast, 1);
//document.write ('Last = &gt;', gcNameLast, '&lt;<BR>');

if (gcNameLast == '/')
{
    gsPageName = '/welcome';
}
//document.write ('Name = ', gsPageName, '<BR>');

gnPosTitle = 1;
gnLenPage = gsPageName.length;
//document.write ('Len = ', gnLenPage, '<BR>');
for (i = gnLenPage; i > 1; i--)
{
	tcNameChar = gsPageName.substr (i, 1);
	if ((tcNameChar == '/') || (tcNameChar == '\\'))
	{
		gnPosTitle = i + 1;
		break;
	}
}
//document.write ('Pos = ', gnPosTitle, '<BR>');
gnLenTitle = gnLenPage - gnPosTitle;
gsPageTitle = gsPageName.substr (gnPosTitle, gnLenTitle);
//document.write ('Title = ', gsPageTitle, '<BR>');

gsPageSubject = 'MTC: ' + document.title + ' (' + gsPageTitle + ')';

//HostAnnounce ();

//document.write ('<BR><CENTER>');

// CREATE OUTER TABLE WITH A BORDER AND 1 DATA CELL CONTAINING THE INNER TABLE
document.write ('<TABLE Border="1" Width="100%" CellPadding="0" CellSpacing="0"><TR><TD>');

// CREATE INNER TABLE
document.write ('<CENTER><TABLE Border="0" Width="100%" CellPadding="3" CellSpacing="0"><TR>');

MenuBar ();

// MAILTO LINK
document.write ('<TD Class="MenuLink" Align="center" vAlign="middle">');
// IF CURRENT DOCUMENT IS NOT THIS DOCUMENT # IN LIST, PRINT AS LINK
document.write ('<A Class="MenuLink" HREF="http://www.muscovytrading.com/staff.html">Contact Us</A>');
document.write ('</TD>');

// CLOSE INNER TABLE
document.write ('</TR></TABLE>');
// CLOSE OUTER TABLE
document.write ('</TD></TR></TABLE>');
document.write ('</CENTER>');

// COPYRIGHT NOTICE
document.write ('<TABLE Border="0" Width="100%" CellPadding=3 CellSpacing=0>');
document.write ('<TR>');

document.write ('<TD Width=35% Align="left" vAlign="middle">');
document.write ('&nbsp;');
document.write ('</TD>');

document.write ('<TD Width=30% Class="FootLinkBold" Align="Center" vAlign="bottom">');
document.write ('<B Class=TinyBlack>Web Services Provided by<BR><A Class=TinyBlack Href="http://www.stcllp.com"><IMG Src="/stc.gif" Border="0" Align="Bottom" Align="Center" Alt="[Services by STC Systems]"><BR>STC Systems</B> </A>');
document.write ('</TD>');

document.write ('<TD Width=35% vAlign="Middle" Class=TinyBlack>');
tsToday = new Date();
tsYear = tsToday.getFullYear();
document.write ('Copyright &copy; 2002-' + tsYear + ' Muscovy Trading Company');
document.write ('</TD>');

document.write ('</TR>');
document.write ('</TABLE>');
//document.write ('</CENTER>');

function sendTo(tsName,tsPage)
{
    tsSubject = "[MTC] Web Contact";
    gbDebugMode = 'F';
    if (gbDebugMode == 'T')
    {
	document.write ('<TABLE Border=1><TR><TD>Name :' + tsName + ':</TD></TR></TABLE>');
	document.write ('<TABLE Border=1><TR><TD>Position :' + tsPage + ':</TD></TR></TABLE>');
    }
    if (tsPage == null)
    {
	tsPage = '';
    }
    else
    {
	tsPage = tsPage.toLowerCase();
	tnPosBR = tsPage.indexOf("<br>");
	if (tnPosBR > -1)
	{
	    tsPage = tsPage.substring(0, tnPosBR);
	}
	tnPosCom = tsPage.indexOf(",");
	if (tnPosCom > -1)
	{
	    tsPage = tsPage.substring(0, tnPosCom);
	}
    }
    if(!mie)
    {
	pageX=window.pageXOffset;
	pageW=window.innerWidth;
	pageY=window.pageYOffset;
	pageH=window.innerHeight;
    }
    else
    {
	pageX=window.document.body.scrollLeft;
	pageW=window.document.body.offsetWidth-8;
	pageY=window.document.body.scrollTop;
	pageH=window.document.body.offsetHeight;
    } 
    //document.write ("(" + pageX + " x " + pageY + ")" + mie + "<BR>");
    //document.write ("(" + pageW + " x " + pageH + ")" + mie + "<BR>");

     //document.write ("<BR>&lt;" + tsName + "&gt;");
    // 00000000001111
    // 01234567890123
    // Foster, Michael

    // INITIAL -->M
    tsName1 = tsName.substring(0,1);

    // LOWER CASE FIRST NAME/INITIAL
    // -->m
    // -->michael
    tsName1 = tsName1.toLowerCase();

    ///////////////////////////////////////////////////////////////
    // FULL NAME IN LOWER CASE
    tsNameFull = tsName.toLowerCase();
    tnLenFull = tsNameFull.length;
    // -->0000000000111111
    // -->0123456789012345
    // -->michael foster[]
    //OLD
    tnPosSpc = tsPage.indexOf(" ");
    tsTmpPage = tsPage.substring(0, tnPosSpc) + tsPage.substring(tnPosSpc+1, 9999); 
    tsPage = tsTmpPage;

    tnPosComma = tsNameFull.indexOf(",");

    //OLD
    //tnLenFirst = tsNameFirst.length;
    tsNameLast = tsNameFull.substring(0, tnPosComma); 
    tnLenLast = tsNameLast.length;
    tnPosBracket = tsName.indexOf("[");
    tnNameEnd = tnLenFull - tnPosBracket;
    //OLD
    //tsNameLast = tsNameFull.substring(tnPosSpace + 1, tnLenFull - tnLenFirst - tnNameEnd - 1);
    tsNameFirst = tsNameFull.substring(tnPosComma + 1, tnLenFull - tnLenLast - tnNameEnd - 1);

    gnLenPage = tsPage.length;

    gnPos1 = tsName.indexOf("[");
    gnLenName = tsName.length - (tsName.length - gnPos1);

    // -->7
    gnPos = tsName.indexOf(" ");
    if (gnPos > -1)
    {
	//tsName2 = tsName.substring(gnPos + 1, tsName.length);
	tsName2 = tsName.substring(gnPos + 1, gnLenName);
	// -->Foster
    }
    else
    {
	tsName2 = tsName.substring(1, gnLenName);
    }

    // IF INITIAL PASSED
    if ((tsName.length - gnPos1) > 2)
    {
	tsName3 = tsName1 + tsName.substring(gnPos1 + 1, 1) + tsName2;
    }
    else
    {
	tsName3 = tsName1 + tsName2;
    }
    tsName3 = tsName2 + '.' + tsNameLast;
    tsName3 = tsName3.toLowerCase();
    //tnPosSpace = tsName3.indexOf(" ");
    // -->foster

    // -->mfoster


    tsName4 = tsName.substring(0, gnPos1);
    if (gbDebugMode == 'T')
    {
	document.write ('<TABLE Border=1><TR><TD>Name1 :' + tsName1 + ':</TD></TR></TABLE>');
	document.write ('<TABLE Border=1><TR><TD>Name2 :' + tsName2 + ':</TD></TR></TABLE>');
	document.write ('<TABLE Border=1><TR><TD>Name3 :' + tsName3 + ':</TD></TR></TABLE>');
	document.write ('<TABLE Border=1><TR><TD>Name4 :' + tsName4 + ':</TD></TR></TABLE>');
	document.write ('<TABLE Border=1><TR><TD>Position :' + tsPage + ':</TD></TR></TABLE>');
    }
    gsDomain = "muscovytrading.com";
    gnLeft = (pageW / 2) - 100;
    gnTop = (pageH / 2) - 75;
    //document.write ("(" + gnLeft + " x " + gnTop + ")" + mie + "<BR>");
//onclick="NewWindow(this.href,'name','400','400','yes');return false">Website Abstraction</a>


    newWindow ('', 'Contact', '300', '200', 'yes');
//    aPopUp = window.open ('', 'Contact', 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=200,height=200,top='+gnTop+',left='+gnLeft);
    ndoc = aPopUp.document;

    //return (tsName3 + '@' + gsDomain);
    astr = '<HTML><HEAD><BR><TITLE>ODPA Contact</TITLE>';
    astr += '</HEAD>';
    astr += '<SCRIPT>';
    astr += 'function closeNote(which)';
    astr += '{';
    astr += 'self.close()';
    astr += '}';
    astr += '</SCRIPT>';
    astr += '<BODY BackGround=/images/parchtan.jpg>';
    astr += '<CENTER>';
    astr += '<B>Contact<BR>' + tsName4 + '</B><BR>select e-Mail address for<BR>';
    astr += '<TABLE>';

//    astr += '<TR>';
//    astr += '<TH>';
//    astr += 'First->' + tsNameFirst + '<  Last->' + tsNameLast + '<';
//    astr += '</TH>';
//    astr += '</TR>';

    astr += '<TR>';
    astr += '<TD>';
    //if (gnLenPage == 0)
    //{
	//astr += '<A Href=\"mailto:' + tsName3 + '@' + gsDomain + '\" onClick=\"closeNote()\">';
	astr += '<A Href=\"mailto:' + tsName3 + '@' + gsDomain + '?subject=' + tsSubject + '\" onClick=\"closeNote()\">';
    //}
    //else
    //{
	//astr += '<A Href=\"mailto:' + tsName3 + '@' + gsDomain + '?subject=' + tsPage + '\" onClick=\"closeNote()\">';
//	astr += '<A Href=\"mailto:' + tsNameFirst + '.' + tsNameLast + '@' + gsDomain + '?subject=' + tsPage + '\" onClick=\"closeNote()\">';
 //   }
    astr += '<IMG Src=\"/images/btn_member.gif\" Border=0></A>';
    astr += '</TD>';
    astr += '<TD>&nbsp;-or-&nbsp;</TD>';
    astr += '<TD>';
    //astr += '<A Href=\"http://www.' + gsDomain + '/members/' + tsName3 + '.html\" Target=\"_blank\" onClick=\"closeNote()\">';
    astr += '<A Href=\"mailto:' + tsPage + '@' + gsDomain + '?subject=' + tsSubject + '\" onClick=\"closeNote()\">';
    astr += '<IMG Src=\"/images/btn_position.gif\" Border=0></A>';
    astr += '</TD>';
    astr += '</TR>';
    astr += '</TABLE>';
    astr += '<BR>';
    //astr += '<FORM><INPUT Type=\"Button\" Value=\"Close\" onClick=\"self.close()\"></FORM>';
    astr += '<A Href="#close" onClick=\"self.close()\"><IMG Src=\"/images/btn_close.gif\" Border=0></A>';
    //astr += '<FORM><INPUT Type=\"Button\" Value=\"Close\" Name=\"closeBtn\" onClick=\"closeNote()\"></FORM>';
    astr += '</CENTER></BODY></HTML>';
    ndoc.write(astr);
    if (gbDebugMode == 'T')
    {
	document.write ('<TABLE Border=1><TR><TD>Position :' + tsPage + ':</TD></TR></TABLE>');
    }
    ndoc.close();
    self.aNoteWin = aPopUp;

    //document.write ('<A Href=\"mailto:' + tsName3 + '@' + gsDomain + '\">');
    //document.write ('<IMG Src=\"/images/clickml1.gif\"></A>');
    //document.write ('<A Href=\"http://www.' + gsDomain + '/members/' + tsName3 + '.html\" Target=\"_blank\">');
    //document.write ('<IMG Src=\"/images/clickml2.gif\"></A>');
    return;
}
    
function newWindow(mypage,myname,w,h,scroll)
{
    LeftPosition = (screen.width) ? (screen.width-w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height-h) / 2 : 0;
    settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition
    +', toolbar=no, directories=no, location=no, status=no, menubar=no, scrollbars='
    +scroll+', resizable=no';
    //aPopUp = window.open(mypage, myname, settings);
    aPopUp = window.open(mypage, 'Contact', settings);
} 
