/*  yoga.js, last tweaked November 2009  */


/*  In the function below the window-width sniffer fails in IE 5 for Mac, which nobody uses anymore anyway, 
 *  but it works fine in over a dozen other browsers that howtocreate.co.uk and I have tested. 
 *
 *  This function first reads the pixel width of the window, depending on the browser. When it finds the 
 *  usual wider window, it writes the #left_lotus stylesheet ID and attributes into the document's HTML. 
 *  It simultaneously turns off display of #right_lotus, which would otherwise be displayed by default. 
 *  Yoga.css then uses the ID of #left_lotus to position and display it. (That styling could also have 
 *  been done here in the document.write.)
 *
 *  The original source and most testing for the first part of this is at http://www.howtocreate.co.uk.
*/
                                                               //
function displayLotus() {                                      // Read the window width:
  var winWidth = 0;                                            //   First declare the variable.
  if (typeof (window.innerWidth) == 'number') {                //   For all browsers except IE, test for 
    winWidth = window.innerWidth;                              //   property existence and then get it.
  }                                                            //   If that fails...
  else if (document.documentElement && document.documentElement.clientWidth){ // for IE 6+ in strict mode
    winWidth = document.documentElement.clientWidth;           //   test if object & property exist.
  }                                                            //   And if that fails...
  else if (document.body && document.body.clientWidth ) {      //   for IE 4 and 5-7 in quirks mode
    winWidth = document.body.clientWidth;                      //   test if object & property exist.
  }                                                            // Test the window width, then  
  if (winWidth > 870) {                                        //   write the image ID and attributes
    document.write( "<img id='left_lotus' src='wikilotus146x100.png' width='146' height='100'>" 
    + "<style>#right_lotus{display:none}</style>" );           //   and override the default style.
  }                                                            // 
}


/*  This function just produces today's date, seen on each page at the top of the right-hand column.
 *
 *  JavaScript's built-in object Date contains the methods getDay and getMonth which return integers. 
 *  To translate those integers into words, Sunday for example, this script uses each integer to access 
 *  that element of an array of days. 
 *
 *  The script in the HTML simply invokes this function as document.write(showDate());
 *  Since it runs in the browser, it depends on the user's computer calendar being correct.
*/

function showDate() {                                       // 
  var dateObject = new Date();                              // Construct a new dateObject.
  var daysArray = ['Sunday','Monday','Tuesday',             // 
    'Wednesday','Thursday','Friday','Saturday'];            // Create an array of days
  var monthsArray = ['Jan','Feb','March','April','May',     //   and an array of months.
    'June','July','August','Sept','Oct','Nov','Dec'];       //
  var dateString =                                          // Build the string to be written:
    'Today is '                                             // Two methods are used in two arrays:
    + daysArray[dateObject.getDay()] + ', '                 //   element [0] becomes 'Sunday' and
    + monthsArray[dateObject.getMonth()] + ' '              //   element [0] becomes 'Jan'.
    + dateObject.getDate() + ', '                           // Method getDate returns 1 thru 31 and
    + dateObject.getFullYear() + '.';                       //   getFullYear returns the 4-digit year.
  return dateString;                                        // Define the function's return value.
}                                                           //

