// Version

// Menu
function InitMenu(menu)
{
    if (!document.all || !document.getElementById(menu)) return;
	navRoot = document.getElementById(menu);
	for (i=0; navRoot && i<navRoot.childNodes.length; i++) 
	{
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") 
		{
			node.onmouseover=function() {	this.className+=" over";	}
			node.onmouseout=function() 	{	this.className=this.className.replace(" over", "");	}
		}
	}
}

//Initialize
function Initialize()
{
    InitMenu("menu");
    InitMenu("submenu");
    InitMenu("leftmenu1");
    InitMenu("leftmenu2");
    InitMenu("leftmenu3");
    InitMenu("leftmenu4");
    
    var strFile = "";
	var strURL = new String(window.location);
	if (strURL.indexOf(".com/")==-1)  strFile = strURL.substr(strURL.indexOf("AASoft/")+ ("AASoft/").length);
	else strFile = strURL.substr(strURL.indexOf(".com/") + 5);
	if (strFile.indexOf("#")!=-1) strFile = strFile.substr(0, strFile.indexOf("#"));
	if(!strFile) strFile = "index.htm";    
	
    var strSite = "http://www.aamailsoft.com/";
	var link = document.getElementById("idlink");
	if (link) link.href = strSite + strFile;    
}

window.onload=Initialize;

//Write current year
function Year()
{
	var today = new Date();
	document.write(today.getFullYear());
}

// H2Title
function H2Title(idObject, nWidth, nTopMargin, nBottomMargin)
{
    var subfolder = false;
    var url = new String(window.location);
    
    if (url.indexOf("/smtp-server/")!=-1  ||
        url.indexOf("/mail-server/")!=-1  ||
        url.indexOf("/file-sharing/")!=-1 ||
        url.indexOf("/bulk-mailer/")!=-1)
        
    {
        subfolder = true;
     }

    var obj = document.getElementById(idObject);
    if (!obj) return;
    var strText = obj.innerHTML;
    
    if (nWidth==-1) nWidth=250;
    if (nTopMargin==-1) nTopMargin=10;
    if (nBottomMargin==-1) nBottomMargin = 8;
    
    var strHtml = "";
    strHtml += ("<table width=" + nWidth + " border=0 cellspacing=0 cellpadding=0>");
    strHtml += ("<tr><td height=" + nTopMargin + ">");
  	strHtml += ("<tr><td>"); 
    strHtml += ("  <table width=100%% border=0 cellpadding=0 cellspacing=1>");
    strHtml += ("  <tr><td valign='bottom'>" + strText);
    strHtml += ("  <tr><td height=3>");
    strHtml += ("  </table>");
    strHtml += ("  <tr><td>"); 
    strHtml += ("    <table width=100% border=0 cellspacing=0 cellpadding=0>");
    strHtml += ("    <tr><td width=120>");
    strHtml += ("              <table width=100%% border=0 cellpadding=0 cellspacing=0>");
    strHtml += ("              <tr>"); 
    strHtml += ("                  <td width=27><img src='images/tit_img1.gif' width=27 height=3></td>");
    strHtml += ("                  <td bgcolor=#0496D2><img src='images/tit_img3.gif'></td>");
    strHtml += ("                  <td width=67><img src='images/tit_img2.gif' width=67 height=3></td>");
    strHtml += ("              </table>");
    strHtml += ("        <td background='images/tit_imgbg.gif'><img src='images/tit_imgbg.gif' width=1 height=3></td>");
    strHtml += ("    </table>");
    strHtml += ("<tr><td height=" + nBottomMargin + ">");
    strHtml += ("</table>");   

    if (subfolder) 
    {
        strHtml = strHtml.replace("images/tit_imgbg.gif", "../images/tit_imgbg.gif"); 
        strHtml = strHtml.replace("images/tit_img1.gif", "../images/tit_img1.gif"); 
        strHtml = strHtml.replace("images/tit_img2.gif", "../images/tit_img2.gif"); 
        strHtml = strHtml.replace("images/tit_img3.gif", "../images/tit_img3.gif"); 
    }
    
    obj.innerHTML = strHtml;
}

function submitQuestion()
{
	var form = document.forms[0];
	if (form.nickname.value.length<=1)
	{
		alert("Please input your name!");
		form.nickname.focus();
		return;
	}
	if (form.email.value.length<=1 ||
		form.email.value.indexOf('@')==-1)
	{
		alert("Please input your email address!");
		form.email.focus();
		return;
	}
	if (form.note.value.length<=16)
	{
		alert("Please input valid question content!");
		form.note.focus();
		return;
	}
	form.submit();
}

function DisplayTopMenu(idMenu, isFAQ)
{
    var obj = document.getElementById(idMenu);
    if (!obj) return;
 
    var strFile = "";
    var subFolder = false;
	var strURL = new String(window.location);
    
    if (strURL.indexOf("/smtp-server/")!=-1  ||
        strURL.indexOf("/mail-server/")!=-1  ||
        strURL.indexOf("/file-sharing/")!=-1 ||
        strURL.indexOf("/bulk-mailer/")!=-1)
    {
        subFolder = true;
    }
     
	if (strURL.lastIndexOf("/")==-1)  strFile = "index.htm";
	else strFile = strURL.substr(strURL.lastIndexOf("/") + 1);
	if (strFile.indexOf("#")!=-1) strFile = strFile.substr(0, strFile.indexOf("#"));
	if(!strFile) strFile = "index.htm";    
        
    var strMenu = "";
        
    strMenu += ("<table cellspacing=0 cellpadding=0 border=0>");
    strMenu += ("<tr>");
    strMenu += ("<td><table cellspacing=0 cellpadding=0 border=0><tr><td height=5><tr><td><a href=http://www.aamailsoft.com><img border=0 src=../images/home.gif border=0></a></table>");
    strMenu += ("<td>");
    strMenu += ("<ul id='menu' style='margin-left:0px; margin-top:0px; margin-right:0px; margin-bottom: 0px;'>");
    
    var strHome = ("<li><a href='../index.htm' accesskey='a' xxxstylexxx><span><b>Home</b></span></a>&nbsp;<font color=white>|</font>");
    if (strHome.indexOf(strFile)!=-1) strHome = strHome.replace("xxxstylexxx", "style='color:yellow'");
    strMenu += strHome;

    
    var strDownload = ("<li><a href='../download.htm' accesskey='c' xxxstylexxx><span><b>Downloads</b></span></a>&nbsp;<font color=white>|</font></li>");
    if (strDownload.indexOf(strFile)!=-1) strDownload = strDownload.replace("xxxstylexxx", "style='color:yellow'");
    strMenu += strDownload;
    
    var strPurchase = ("<li><a href='../purchase.htm' accesskey='d' xxxstylexxx><span><b>Purchase</b></span></a>&nbsp;<font color=white>|</font>");
    if (strPurchase.indexOf(strFile)!=-1) strPurchase = strPurchase.replace("xxxstylexxx", "style='color:yellow'");
    strMenu += strPurchase;
    
    strMenu += ("<ul>");
    strMenu += ("	<li><a href='../mail-server/purchase.htm'>&nbsp; Order AA Mail Server</a></li>");
         
    strMenu += ("</ul>");
    strMenu += ("</li>");
    
    var strSupport = ("<li><a href='../support.htm' accesskey='r' xxxstylexxx><span><b>Support</b></span></a>&nbsp;<font color=white>|</font>");
    if (isFAQ || strSupport.indexOf(strFile)!=-1) strSupport = strSupport.replace("xxxstylexxx", "style='color:yellow'");
    strMenu += strSupport;
    
    strMenu += ("<ul>");
    strMenu += ("	<li><a href='../mail-server/support.htm' target=_blank>&nbsp; AA Mail Server FAQs</a></li>");
    
    strMenu += ("</ul>");
    strMenu += ("</li>");
    
    var strContact = ("<li><a href='../contact.htm' accesskey='d' xxxstylexxx><span><b>Contact Us</b></span></a>&nbsp;<font color=white></font></li>");    
    if (strContact.indexOf(strFile)!=-1) strContact = strContact.replace("xxxstylexxx", "style='color:yellow'");
    strMenu += strContact;
    
    strMenu += ("</ul>");
    strMenu += ("<td width=12>");
    strMenu += ("</table>");
    
    while(!subFolder && strMenu.indexOf("../")!=-1) strMenu = strMenu.replace("../", "");
    obj.innerHTML = strMenu;
}

function ShowTopLeftTree(idMenu)
{
    var obj = document.getElementById(idMenu);
    if (!obj) return;
        
    var strFile = "";
	var strURL = new String(window.location);
	if (strURL.lastIndexOf("/")==-1)  strFile = "index.htm";
	else strFile = strURL.substr(strURL.lastIndexOf("/") + 1);
	if (strFile.indexOf("#")!=-1) strFile = strFile.substr(0, strFile.indexOf("#"));
	if(!strFile) strFile = "index.htm";    

    var strMenu = "";
    
    strMenu += ("<table border=0 align=center class=left width=200 bgcolor=white cellspacing=0 cellpadding=0>");
    strMenu += ("<tr><td height=18 align=center bgColor=#D6D9DB background=images/bg_menu.gif class=white11></td>");
    strMenu += ("<tr><td colspan=3 class=size10 align=center height=22 style='border-bottom: 1px dotted;' xvalign=top>");
    
    var arrLinkUrl  = new Array();
    var arrLinkTxt  = new Array();
    
    arrLinkUrl[0]   = "index.htm";
    arrLinkTxt[0]   = "Home";
    arrLinkUrl[1]   = "download.htm";
    arrLinkTxt[1]   = "Downloads";        
    arrLinkUrl[2]   = "purchase.htm";
    arrLinkTxt[2]   = "Purchase";      
    
    for (var i=0; i<arrLinkUrl.length; i++)
    {
        var strLink = ("<a href=" + arrLinkUrl[i] + " class=gray10>" + arrLinkTxt[i] + "</a>");
        if (strLink.indexOf(strFile)!=-1) strLink = strLink.replace("gray10", "red10");
        if (i<arrLinkUrl.length-1) strLink += "  | ";
        strMenu += (strLink);        
    }
    
    strMenu +=("<tr><td height=12>");        
    strMenu +=("<tr><td>");
        
    strMenu +=("<table border=0 width=100% align=center bgcolor=white cellspacing=0 cellpadding=0>");
    
    strMenu +=("<tr><td align=right width=36><img src=images/clearitem.gif align=absmiddle><td class=gray11> ");
    strMenu +=("<a class=gray11 href=mail-server/index.htm><b>AA Mail Server</b></a><br>");
    strMenu +=("<tr><td><td class=size10>");
    strMenu +=("<a class=gray10 href=mail-server/index.htm>Introduction</a> | ");
    strMenu +=("<a class=gray10 href=mail-server/purchase.htm>Order</a> | ");
    strMenu +=("<a class=gray10 href=mail-server/support.htm>FAQs</a>");
    strMenu +=("<tr height=12><td>");

    strMenu +=("</table>");

    strMenu +=("<tr><td height=15>");
    strMenu +=("</table>");
    
    obj.innerHTML = strMenu;
}

