// common.js - Shared functions for pyeung.com

// Global Variables
varColor001 = "8d0c0f"; // Color of top bar
varColor002 = "fff3ab"; // Color of main background
varColor003 = "000000"; // Color of separator bar

// function titleBar(txt, alignment)
// Displays a blue title bar
// txt = Text string
// alignment - "RIGHT" or "CENTER", default is "LEFT"

function titleBar(txt, alignment) {
   document.write('<table width=490><tr bgcolor=0000ff>');
   if (alignment == 'RIGHT') document.write('<td align=right>')
      else if (alignment == 'CENTER') document.write('<td align=center>')
      else document.write('<td align=left>');
   document.write('<font color=ffffff><b>');
   document.write(txt);
   document.write('</b></font></td></tr></table>');
}

// function IEBrowserVersion()
// Returns Internet Explorer browser version number

function IEBrowserVersion() {
   version=0
   if (navigator.appVersion.indexOf("MSIE")!=-1) {
      temp=navigator.appVersion.split("MSIE")
      version=parseFloat(temp[1])
   }
   return(version)
}

// function initPage(arrEntries, articleTitle)
// Draws logo bar and menu on top of each page
// Added search function - 22-Sep-03
// Added "You Are Here" - 27-Dec-06

function initPage(parArrEntries, parArticleTitle) {

   squote = "'";
   varPlatform = navigator.platform;

   sitemap_on = new Image(85,85);
   sitemap_off = new Image(85,85);
   sitemap_on.src = "http://www.pyeung.com/graphics/compass-rose-on.jpg";
   sitemap_off.src = "http://www.pyeung.com/graphics/compass-rose-off.jpg";

   switch (varPlatform) {
      case "WinCE":
         document.write('<div class="centered">');
         document.write('&nbsp;</td></tr></table>');

         document.write('<table width="100%"><tr><td bgcolor=' + varColor001 + '>');
         document.write('<a href="http://www.pyeung.com">');
         document.write('<img border=0 alt="Patrick Yeung - Technology Consulting" src="http://www.pyeung.com/graphics/pyeungtitle.jpg">');
         document.writeln('</td></tr>');
         document.write('<tr><td bgcolor=' + varColor001 + '>');
         document.write('<form action="http://www.pyeung.com/search.asp" name="searchBox" method=get>');
         document.write('<input type="text" size="15" name="searchPhrase">');
         document.write('&nbsp;<input type="submit" value="Search">');
         document.write('</form>');
         document.writeln('</td></tr>');

         document.write('<tr><td><table width="100%" bgcolor=ffffff><tr><td class="ppc" width=35px valign=top><b>Menu</b></td><td> ');
         document.write('<a class="ppc" href="http://www.pyeung.com">Home</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/pages/cables/toc.asp">Cables</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/pages/cisco/toc.asp">Cisco</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/pages/ip/toc.asp">IP&nbsp;Info</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/qvga/index.html">PPC&nbsp;Sites</a> ');
         document.writeln('</td></tr></table></td></tr><tr><td bgcolor=' + varColor002 + '>');
      break;
      case "PSP":
         document.write('<div class="centered"><table width=480><tr><td bgcolor=' + varColor001 + '>');
         document.write('<a href="http://www.pyeung.com">');
         document.write('<img border=0 alt="Patrick Yeung - Technology Consulting" src="http://www.pyeung.com/graphics/pyeungtitle.jpg">');
         document.write('</a>');
         document.writeln('</td></tr>');
         document.write('<tr><td bgcolor=' + varColor001 + '>');
         document.write('<form action="http://www.pyeung.com/search.asp" name="searchBox" method=get>');
         document.write('<input type="text" size="15" name="searchPhrase">');
         document.write('&nbsp;<input type="submit" value="Search">');
         document.write('</form>');
         document.writeln('</td></tr>');
         document.write('<tr><td><table width=480 bgcolor=ffffff><tr><td class="ppc" width=35px valign=top><b>Menu</b></td><td> ');
         document.write('<a class="ppc" href="http://www.pyeung.com">Home</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/pages/cables/toc.asp">Cables</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/pages/cisco/toc.asp">Cisco</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/pages/ip/toc.asp">IP&nbsp;Info</a> ');
         document.write('<a class="ppc" href="http://www.pyeung.com/qvga/index.html">PPC&nbsp;Sites</a> ');
         document.writeln('</td></tr></table></td></tr><tr><td bgcolor=' + varColor002 + '>');
      break;
      default:
         if (navigator.appName == "Netscape" && parseFloat(navigator.appVersion) < 5.0) {
            tableWidth="740";
         } else {
            tableWidth="755";
         }

         document.write('<script type="text/javascript" language="JavaScript1.2" src="http://www.pyeung.com/scripts/stm31.js"></script>');
         document.write('<div class="centered">');
         document.write('<table width=' + tableWidth + ' bgcolor=' + varColor001 + ' cellpadding=4 cellspacing=4><tr>');
         document.write('<td width=400 valign=bottom>');
         document.write('<a href="http://www.pyeung.com">');
         document.write('<img border=0 alt="Patrick Yeung - Technology Consulting" src="http://www.pyeung.com/graphics/pyeungtitle.jpg">');
         document.write('</a><br><br>');
         document.write('<form action="http://www.pyeung.com/search.asp" name="searchBox" method=get>');
         document.write('<input type="text" size="30" name="searchPhrase">');
         document.write('&nbsp;<input type="submit" value="Search">');
         document.write('</form>');
         document.write('</td><td width=300 align=right valign=bottom>');
         document.write('</td><td align=center>')
         document.write('<a class="sitemap" href="http://www.pyeung.com/sitemap.html" onMouseOver="rollIn(' + squote + 'sitemap_' + squote + ')" onMouseOut="rollOut(' + squote + 'sitemap_' + squote + ')">');
         document.write('Site Map<br><img border=0 src="http://www.pyeung.com/graphics/compass-rose-off.jpg" name="sitemap_" alt="pyeung.com - Site Map"></a><br>');
         document.write('</td></tr></table>');

         document.write('<table width=' + tableWidth + ' bgcolor=' + varColor001 + ' cellpadding=0 cellspacing=0><tr><td class="YouAreHere">');
         if (parArrEntries != null) {
            siteYouAreHere(parArrEntries, parArticleTitle);
         } else {
            if (location.href == "http://www.pyeung.com/" ) {
               document.write("<font style='color:cccc66;'>&nbsp;You are here:</font>&nbsp;&nbsp;Home");
            }
         }
         document.write('&nbsp;</td></tr></table>');

         document.write('<table width=' + tableWidth + ' cellspacing=0 cellpadding=0>');
         document.write('<tr align=left valign=top><td bgcolor=' + varColor003 + '>');
         document.write('<img src="http://www.pyeung.com/graphics/blank.gif" height=10>');
         document.writeln('</td></tr></table>');
         document.write('');   
         if (navigator.appName == "Netscape" && parseFloat(navigator.appVersion) < 5.0) {
            netscapeDrawMenu();
         } else {
            document.writeln('<table width=' + tableWidth + ' cellpadding=0 cellspacing=0><tr><td bgcolor=' + varColor002 + '>');

            document.writeln('<script language="JavaScript1.2" src="http://www.pyeung.com/scripts/menu.js"></script>');
            document.writeln('</td></tr></table>');
         }
         document.writeln('<script language="JavaScript">document.searchBox.searchPhrase.focus();</script>');
         document.writeln('<table width=' + tableWidth + ' height=90% cellpadding=0 cellspacing=0><tr valign=top><td bgcolor=' + varColor002 + ' style="z-index:10;">');
      }
}

// function postPage()
// Closes off table portion of each page

function postPage() {

   varPlatform = navigator.platform;
   

   lastModified = document.lastModified;
   lastModifiedDate = Date.parse(lastModified);

   document.write('</td></tr><tr><td bgcolor=' + varColor002 + '>');
   document.write('<div style="font-size:7pt;">');
   document.write('&nbsp;&nbsp;Last Updated on ');

   if (lastModifiedDate == 0) {
      document.write('Unknown');
   } else {
      strDate = new Date(lastModified);
      document.write(monthOfYear(strDate.getMonth()) + " ");
      document.write(strDate.getDate() + ", ");
      document.write(strDate.getFullYear());
   }

   document.write('<br>&nbsp;&nbsp;&copy;1997-2008 Copyright. Website design and content within pyeung.com are the properties of Patrick P. Yeung.&nbsp;&nbsp;&nbsp;(San Francisco, CA, USA)');
   document.write('</div>');
   document.writeln('</td></tr></table></div>');

}

// function siteYouAreHere(arrEntries, articleTitle)
// Prints "You Are Here" site information
// arrEntries - Array of entries, links to parent pages
// articleTitle - Text for article title

function siteYouAreHere(arrEntries, articleTitle) {

   document.write("<font style='color:cccc66;'>&nbsp;You are here:</font>&nbsp;&nbsp;");
   while (arrEntries.length) {
      document.write("<a class='YouAreHere' href='" + arrEntries[1] + "'>" + arrEntries[0] + "</a>" );
      arrEntries.shift();
      arrEntries.shift();
      document.write("&nbsp;&nbsp;>&nbsp;&nbsp;");
   }
   document.write(articleTitle);
}

// function rollIn(picture)
// Rollover image function - displays the "on" image

function rollIn(picture) {
   document[picture].src = eval(picture + "on.src");
}

// function rollOut(picture)
// Rollover image function - displays the "off" image

function rollOut(picture) {
   document[picture].src = eval(picture + "off.src");
}

// function netscapeDrawMenu

function netscapeDrawMenu() {
stm_bm(["menu3ea0",400,"http://www.pyeung.com/scripts/","blank.gif",0,"","",0,0,0,0,50,1,0,0,""],this);
stm_bp("p0",[0,4,0,0,1,4,0,8,69,"",-2,"",-2,90,1,1,"#3e647e","transparent","",3,0,0,"#ffffff"]);
stm_ai("p0i0",[0,"Home  ","","",-1,-1,0,"http://www.pyeung.com","_self","","Home Page - www.pyeung.com","","",0,0,0,"http://www.pyeung.com/scripts/arrow_d.gif","http://www.pyeung.com/scripts/arrow_d.gif",8,7,0,0,1,"#ffffff",1,"#ffffff",1,"http://www.pyeung.com/scripts/xp3.gif","http://www.pyeung.com/scripts/xp4.gif",3,3,1,1,"#cccccc","#9690a8","#000000","#000000","bold 8pt Arial","bold 8pt Arial",0,0]);
stm_bp("p1",[1,4,-1,0,1,4,0,0,69,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.52)",-2,"",-2,58,1,1,"#3e647e","transparent","",3,0,0,"#000000"]);
stm_aix("p1i0","p0i0",[0,"Downloads","","",-1,-1,0,"http://www.pyeung.com/downloads.html","_self","","Download Page","","",0,0,0,"","",0,0,0,0,1,"#ffffff",1,"#ffffff",1,"http://www.pyeung.com/scripts/xp3.gif","http://www.pyeung.com/scripts/xp4.gif",3,3,1,1,"#cccccc","#999999"]);
stm_aix("p1i1","p1i0",[0,"Sandbox","","",-1,-1,0,"http://www.pyeung.com/sandbox","_self","","Patrick\'s Sandbox"]);
stm_ep();
stm_ai("p0i1",[6,1,"#993300","",0,0,0]);
stm_aix("p0i2","p1i0",[0,"Cables   ","","",-1,-1,0,"http://www.pyeung.com/pages/cables/toc.asp","_self","","","","",0,0,0,"http://www.pyeung.com/scripts/arrow_d.gif","http://www.pyeung.com/scripts/arrow_d.gif",8,7]);
stm_bpx("p2","p1",[]);
stm_aix("p2i0","p1i0",[0,"Crossover Cable","","",-1,-1,0,"http://www.pyeung.com/pages/cables/crossover.html","_self","","Crossover Cable Diagram"]);
stm_aix("p2i1","p1i0",[0,"Ethernet Cable","","",-1,-1,0,"http://www.pyeung.com/pages/cables/ethernet.html","_self","","Ethernet Cable Diagram"]);
stm_ep();
stm_aix("p0i3","p0i1",[]);
stm_aix("p0i4","p0i2",[0,"Cisco        ","","",-1,-1,0,"http://www.pyeung.com/pages/cisco/toc.asp","_self","","Cisco Information"]);
stm_bpx("p3","p1",[]);
stm_aix("p3i0","p1i0",[0,"IOS Routers","","",-1,-1,0,"","_self","","Routers and IOS"]);
stm_aix("p3i1","p1i0",[0,"Switches","","",-1,-1,0,"","_self","","Catalyst Switches"]);
stm_aix("p3i2","p1i0",[0,"PIX/ASA Firewalls","","",-1,-1,0,"","_self","","PIX/ASA Firewalls"]);
stm_aix("p3i3","p1i0",[0,"CSS Load Balancers","","",-1,-1,0,"","_self","","CSS Load Balancers"]);
stm_ep();
stm_aix("p0i5","p0i1",[]);
stm_aix("p0i6","p0i2",[0,"Web Dev","","",-1,-1,0,"http://www.pyeung.com/pages/webdev/index.html","_self","","","","",0,0,0,"http://www.pyeung.com/scripts/arrow_d.gif","http://www.pyeung.com/scripts/arrow_d.gif",7]);
stm_bpx("p4","p1",[]);
stm_aix("p4i0","p1i0",[0,"ASP Information","","",-1,-1,0,"http://www.pyeung.com/pages/webdev/asp/toc.asp","_self","","ASP Front Page"]);
stm_aix("p4i1","p1i0",[0,"Character Codes","","",-1,-1,0,"http://www.pyeung.com/pages/webdev/html/charactercode.html","_self","","HTML Character Codes"]);
stm_aix("p4i2","p1i0",[0,"HTML Color Names","","",-1,-1,0,"http://www.pyeung.com/pages/webdev/html/htmlcolornames.html","_self","","HTML Color Names"]);
stm_aix("p4i3","p1i0",[0,"Javascript Information","","",-1,-1,0,"http://www.pyeung.com/pages/webdev/javascript/toc.asp","_self","","Javascript Information"]);
stm_aix("p4i4","p1i0",[0,"Web Safe Color Chart","","",-1,-1,0,"http://www.pyeung.com/pages/webdev/html/websafecolors.html","_self","","Web Safe Color Chart"]);
stm_ep();
stm_aix("p0i7","p0i1",[]);
stm_aix("p0i8","p0i2",[0,"IP Information ","","",-1,-1,0,""]);
stm_bpx("p5","p1",[]);
stm_aix("p5i0","p1i0",[0,"IP Well-Known Port Numbers","","",-1,-1,0,"http://www.pyeung.com/pages/ip/portnumbers.html","_self","","Well-Known Port Number List"]);
stm_aix("p5i1","p1i0",[0,"SMTP Mail Server Test","","",-1,-1,0,"http://www.pyeung.com/pages/ip/mailtest.html","_self","","How to Test Connectivity to an SMTP Mail Server"]);
stm_aix("p5i2","p1i0",[0,"Subnetting Cheat Sheet","","",-1,-1,0,"http://www.pyeung.com/pages/ip/subnet.html","_self","","Subnetting Cheat Sheet"]);
stm_ep();
stm_aix("p0i9","p0i1",[]);
stm_aix("p0i10","p0i8",[0,"Linux/UNIX  "]);
stm_bpx("p6","p1",[1,4,-1,0,1,4,0,8]);
stm_aix("p6i0","p1i0",[0,"Linux                   ","","",-1,-1,0,"http://www.pyeung.com/pages/unix/linux/toc.asp","_self","","Linux Information"]);
stm_aix("p6i1","p0i2",[0,"Solaris","","",-1,-1,0,"","_self","","","","",0,0,0,"http://www.pyeung.com/scripts/arrow_r.gif","http://www.pyeung.com/scripts/arrow_r.gif"]);
stm_bpx("p7","p1",[1,2]);
stm_aix("p7i0","p1i0",[0,"OS Patch Management","","",-1,-1,0,"http://www.pyeung.com/pages/unix/solaris/ospatching.html","_self","","Solaris Patch Management"]);
stm_ep();
stm_ep();
stm_aix("p0i11","p0i1",[]);
stm_aix("p0i12","p0i8",[0,"Microsoft ","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/index.html"]);
stm_bpx("p8","p6",[]);
stm_aix("p8i0","p6i1",[0,"Access","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/office/access/toc.asp"]);
stm_bpx("p9","p7",[]);
stm_aix("p9i0","p1i0",[0,"Pot Pourri","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/office/access/potpourri.html","_self","","Various Helpful Tips for MS Access"]);
stm_aix("p9i1","p1i0",[0,"Progress Bar","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/office/access/progressbar.html","_self","","How to Insert a Progress Bar"]);
stm_ep();
stm_aix("p8i1","p1i0",[0,"Exchange","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/msexchange/toc.asp","_self","","","","",0,0,0,"http://www.pyeung.com/scripts/arrow_r.gif","http://www.pyeung.com/scripts/arrow_r.gif",8,7,0,0,1,"#ffffff",1,"#ffffff",1,"xp3.gif"]);
stm_bpx("p10","p7",[]);
stm_aix("p10i0","p1i0",[0,"Cell Phone Text Message Forwarding","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/msexchange/forwardtocellphone.html","_self","","Exchange 2000/2003 Forward Text Messages to Cell Phones"]);
stm_aix("p10i1","p1i0",[0,"Customize OWA URL (Exchange 2000/2003)","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/msexchange/owa2kurl.html","_self","","How to change the URL for Outlook Web Access"]);
stm_aix("p10i2","p1i0",[0,"Outlook Web Access 5.5 Setup","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/msexchange/owa55setup.html","_self","","How-To Guide for Setting Up OWA 5.5"]);
stm_aix("p10i3","p1i0",[0,"OWA 2000 Password Change","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/msexchange/owa2kpassword.html","_self","","Outlook Web Access 2000 - Changing Passwords"]);
stm_ep();
stm_aix("p8i2","p6i1",[0,"Windows Server"]);
stm_bpx("p11","p7",[]);
stm_aix("p11i0","p1i0",[0,"Creating Hard Links","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/win2k/hardlinks.html","_self","","How to Create Hard Links with Windows 2000"]);
stm_aix("p11i1","p1i0",[0,"Create User-Defined Service","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/win2k/userdefinedservice.html","_self","","How To Set Up a User-Defined Service"]);
stm_ep();
stm_aix("p8i3","p6i1",[0,"Windows NT"]);
stm_bpx("p12","p7",[]);
stm_aix("p12i0","p1i0",[0,"Automatic NT Login","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/winnt/autoadminlogin.html","_self","",""]);
stm_aix("p12i1","p11i1",[0,"Create User-Defined Service","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/winnt/userdefinedservice.html"]);
stm_aix("p12i2","p1i0",[0,"NetBIOS Codes","","",-1,-1,0,"http://www.pyeung.com/pages/microsoft/winnt/netbioscodes.html","_self","","NetBIOS Code Chart"]);
stm_ep();
stm_ep();
stm_aix("p0i13","p0i1",[]);
stm_aix("p0i14","p0i8",[0,"Security  ","","",-1,-1,0,"http://www.pyeung.com/pages/security/toc.asp"]);
stm_bpx("p13","p1",[]);
stm_aix("p13i0","p1i0",[0,"Security Cheat Sheet","","",-1,-1,0,"http://www.pyeung.com/pages/security/security.html","_self","","Security Cheat Sheet"]);
stm_aix("p13i1","p1i0",[0,"Windows 95/98/ME on the Internet","","",-1,-1,0,"http://www.pyeung.com/pages/security/win9x-internet.html","_self","","Security Issues with Windows 95/98/ME"]);
stm_ep();
stm_aix("p0i15","p0i1",[]);
stm_aix("p0i16","p1i0",[0,"About      ","","",-1,-1,0,"http://www.pyeung.com/about.html","_self","","About Patrick Yeung"]);
stm_ep();
stm_em();
}


// function newBrowser

function newBrowser(url, p_Width, p_Height) {

   agent = navigator.userAgent;
   windowName = "pyeung2";
   params  = "";
   params += "toolbar=0,";
   params += "location=0,";
   params += "directories=0,";
   params += "status=0,";
   params += "menubar=0,";
   params += "scrollbars=0,";
   params += "resizable=0,";
   params += "top=92,";
   params += "left=0,";
   if (p_Width == "null") {
      params += "width=500,";
      params += "height=350";
   } else {
      params += "width=" + p_Width+ ",";
      params += "height=" + p_Height;
   }

   // close the window to vary the window size
   if (typeof(win) == "object" && !win.closed) {
      win.close();
   }

   win = window.open(url, windowName , params);

   if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
      win = window.open(url, windowName , params);
   }

   if (!win.opener) {
      win.opener = window;
   }

   // bring the window to the front
   win.focus();	
}

// function imageWindow

function imageWindow(parImage, parTitle, parWidth, parHeight) {

   agent = navigator.userAgent;
   windowName = "preview";
   params  = "";
   params += "toolbar=0,";
   params += "location=0,";
   params += "directories=0,";
   params += "status=0,";
   params += "menubar=0,";
   params += "scrollbars=0,";
   params += "resizable=0,";
   params += "top=92,";
   params += "left=0,";
   if (parWidth == "null") {
      params += "width=500,";
      params += "height=350";
   } else {
      params += "width=" + parWidth+ ",";
      params += "height=" + parHeight;
   }

   // close the window to vary the window size
   if (typeof(win) == "object" && !win.closed) {
      win.close();
   }

   win = window.open("", windowName , params);

   if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
      win = window.open("", windowName , params);
   }

   if (!win.opener) {
      win.opener = window;
   }

   win.document.open("text/html","replace");
   win.document.write("<html><head><title>" + parTitle + "</title></head><body>");
   win.document.write("<img src='" + parImage + "'>");
   win.document.write("</body></html>");
   win.document.close();

   // bring the window to the front
   win.focus();	
}

function dayOfWeek(parDay) {

   switch(parDay) {
      case 0:  strDay = "Sunday"; break;
      case 1:  strDay = "Monday"; break;
      case 2:  strDay = "Tuesday"; break;
      case 3:  strDay = "Wednesday"; break;
      case 4:  strDay = "Thursday"; break;
      case 5:  strDay = "Friday"; break;
      case 6:  strDay = "Saturday"; break;
      default: strDay = "Unexpected Value: Day";
   }
   return strDay;
}

function monthOfYear(parMonth) {

   switch(parMonth) {
      case  0: strMonth = "January"; break;
      case  1: strMonth = "February"; break;
      case  2: strMonth = "March"; break;
      case  3: strMonth = "April"; break;
      case  4: strMonth = "May"; break;
      case  5: strMonth = "June"; break;
      case  6: strMonth = "July"; break;
      case  7: strMonth = "August"; break;
      case  8: strMonth = "September"; break;
      case  9: strMonth = "October"; break;
      case 10: strMonth = "November"; break;
      case 11: strMonth = "December"; break;
      default: strMonth = "Unexpected Value: Month";
   }
   return strMonth;
}

