// * * * * * * * * Created By; Rhett Eiffler * * * * * * * *
// copyright Rhett Eifler 2000 & Beyond
// Lasted Updated: 21st of May 2005


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function ; ShowDate;                                             \\
//  Variables ; no variables                                         \\
//                                                                   \\
//  Writes to calling page the current date in the following format  \\
//      "Last revised on DD/MM/YYYY"                                 \\
//  Including the following copyright information                    \\
//      "Copyright YYYY, R.F. & S.L. Eiffler"                        \\
//                                                                   \\
//  If an error occurs retrieving the date information the format    \\
//  changes to the default date display, and copyright year to 2000  \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function ShowDate ()
{
  var Last = "Last revised on: ";
  var FileDate = new Date(document.lastModified);
  var CopyStart = "Copyright &copy ";
  var CopyEnd = " R.F. & S.L. Eiffler";

  if ( FileDate.getTime() != 0 ) { // Successfully got date...
    Month = FileDate.getMonth() +1     // Add one because Array starts at 0...
    Year = FileDate.getFullYear()
    if ( Year < 2000  ) Year = Year + 100 // Add 100 if NOT Y2K
    DateMessage = Last + FileDate.getDate() + "/" + Month + "/" + Year
    CopyMessage = CopyStart + Year + CopyEnd;
    document.writeln(CopyMessage + "<br>" + DateMessage);
  }
  else { // Use Default Date format...
    CopyMessage = CopyStart + "2003" + CopyEnd;
    DateMessage = Last + FileDate
    document.writeln(CopyMessage + "<br>" + DateMessage); // Just put simple date out
  }
} // End of ShowDate Function



// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function; MailCheck(FORM_DATA AS form);                          \\
//  Variables ; form -- Varialbes from form                          \\
//  Checks form details before passing to the Mailcheck php script.  \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function MailCheck (form)
{
  re = /\r\n/g; // identifies Newline from textarea

  if ( form.id.value.length < 1 ) { // Name must be > 0 chars long... ie;"D"
    alert ("Please enter your name!");
    form.id.focus();
  }
  else { // Name is OK, check email
    if ( form.email.value.indexOf("@") ==-1 ) { // Email is NOT Correct Format...
      alert ("Please enter your email address!");
      form.email.focus();
    }
    else // Name & Email Are OK, Check Message
    {
      if ( form.msg.value.length < 1 ) // Message is to Short
      {
        alert ("Please enter your message!");
        form.msg.focus();
      }
      else // All Sections are fine run script now...
      {
        // convert newlines to special chars first...
        str = form.msg.value;
        message = str.replace(re, "\\nL"); // replaces newlines with the string "\n"
        open("http://www.tandara.com/cgi-bin/ezmail.pl?name=" + form.id.value + "&email=" + form.email.value + "&message=" + message,'ShowSent','toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=0,width=390,height=190,screenx=200,screeny=200,top=200,left=200')
//R        open("http;//www.tandara.com/scripts/mailform2.php?name=" + form.id.value + "&message=" + form.msg.value + "&email=" + form.email.value,'ShowSent','toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=0,width=390,height=190,screenx=200,screeny=200,top=200,left=200')
        form.reset.click();
      }
    }
  }
} // End of MailCheck Function



// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function ; Changer;                                              \\
//  Variables ; None                                                 \\
//                                                                   \\
//  TBA (P.S. i'm not sure either...)                                \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function Changer ()
{
  open("secure.html",'EditMode','toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=0,width=590,height=590,screenx=200,screeny=200,top=200,left=200')
} // End of Open Edit Function



// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function ; hideCasp;                                             \\
//  Variables ; None                                                 \\
//                                                                   \\
//  Simply tries to hide the email address shown on the page         \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function hideCasp ()
{
    caspEmail=('casp' + 'ian' + '@' + 'tand' + 'ara' + '.com');
	document.writeln("<a href=\"mailto:" + caspEmail + "?subject=caspian enquiries\" class=\"email\"><img src=\"images/email.gif\" border=\"0\"><br><span class=\"email\">caspian@tandara.com </span></a>");
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function ; Heading(PAGE_ID AS integer);                          \\
//  Variables ; mnu --- Page ID that is used to chose menu image.    \\
//                                                                   \\
//  Simply write the heading of the page that calls it               \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function Heading (mnu)
{
  var src_path="http://www.tandara.com/";
  //var src_path="./"; // Used for local testing...

  if (typeof mnu == 'undefined') {
    mnu = "0";
  }
  document.writeln ("      <table bgcolor=\"#ffffff\" cellpadding=0 cellspacing=0 border=0 width=\"750\">\n");
  document.writeln ("      <tr>\n");
  document.writeln ("        <td><img src=\"" + src_path + "images/title.jpg\" alt=\"Welcome to www.tandara.com\"></td>\n");
  document.writeln ("      </tr>\n");
  document.writeln ("      <tr>\n");
  if ( mnu == 1 ) { // Index page only needs counter!
    document.writeln ("        <td valign=top><img src=\"" + src_path + "images/menu" + mnu + ".jpg\" usemap=\"#Button.Map\" border=0 alt=\"Navigation Bar Loading... Please Wait\"><img src=\"" + src_path + "cgi-bin/counter.pl?index\" height=\"1\" width=\"1\">");
  }
  else {
    document.writeln ("        <td valign=top><img src=\"" + src_path + "images/menu" + mnu + ".jpg\" usemap=\"#Button.Map\" border=0 alt=\"Navigation Bar Loading... Please Wait\">");
  }
  document.writeln ("</td>\n");
  document.writeln ("      </tr>\n");
  document.writeln ("      </table>\n");
} // End of Heading Function


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function ; Tailing                                               \\
//  Variables ; None                                                 \\
//                                                                   \\
//  Simply write the tail of the page that calls it                  \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function Tailing ()
{
  var src_path="http://www.tandara.com/";
  //var src_path="./"; // Used for local testing...

  document.writeln ("    <img src=\"http://www.tandara.com/images/stripe.gif\" alt=\"Seperator bar\"><br>\n");
  document.writeln ("    <span class=\"rights\">[</span><a href=\"http://www.tandara.com/index.html\" class=\"rights\"><span class=\"rights\"> Home & News</a> | </span>\n");
  document.writeln ("    <a href=\"" + src_path + "caspian.html\" class=\"rights\"><span class=\"rights\">The Caspian Horse</a> | </span>\n");
  document.writeln ("    <a href=\"" + src_path + "tandara.html\" class=\"rights\"><span class=\"rights\">About Tandara</a> | </span>\n");
  document.writeln ("    <a href=\"" + src_path + "forsale.php?f=lines\" class=\"rights\"><span class=\"rights\">Tandara Blood Lines</a> | </span>\n");
  document.writeln ("    <a href=\"" + src_path + "forsale.php?f=colts\" class=\"rights\"><span class=\"rights\">Colts for Sales</a> | </span>\n");
  document.writeln ("    <a href=\"" + src_path + "forsale.php?f=fillies\" class=\"rights\"><span class=\"rights\">Fillies for Sale</a> | </span>\n");
  document.writeln ("    <a href=\"" + src_path + "contacts.html\" class=\"rights\"><span class=\"rights\">Contact Us</a> ]</span><br><br>\n");
  document.writeln ("    <span class=\"rights\"><script language=\"javascript\">ShowDate ();</script></span>\n");

  document.writeln ("<map name=\"button.map\">\n");
  document.writeln ("  <area shape=rect coords=\"23,0,126,26\" title=\"Home & News\" href=\"" + src_path + "index.html\">\n");
  document.writeln ("  <area shape=rect coords=\"128,0,230,26\" title=\"About the Caspian Horse\" href=\"" + src_path + "caspian.html\">\n");
  document.writeln ("  <area shape=rect coords=\"233,0,334,26\" title=\"About the Tandara Stud\" href=\"" + src_path + "tandara.html\">\n");
  document.writeln ("  <area shape=rect coords=\"337,0,438,26\" title=\"Blood Lines at Tandara\" href=\"" + src_path + "forsale.php?f=lines\">\n");
  document.writeln ("  <area shape=rect coords=\"441,0,543,26\" title=\"Colts for Sale\" href=\"" + src_path + "forsale.php?f=colts\">\n");
  document.writeln ("  <area shape=rect coords=\"544,0,646,26\" title=\"Fillies for Sale\" href=\"" + src_path + "forsale.php?f=fillies\">\n");
  document.writeln ("  <area shape=rect coords=\"648,0,750,26\" title=\"contact us\" href=\"" + src_path + "contacts.html\" -->\n");
  document.writeln ("</map>\n");
} // End if Trailing Info


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
//                                                                   \\
//  Function ; Tailing                                               \\
//  Variables ; None                                                 \\
//                                                                   \\
//  Simply write the news items, allowing updates without changing   \\
//  front page                                                       \\
//                                                                   \\
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \\
function show_news ()
{

  var  news = new Array();
  var  dates = new Array();
  var looks = new Array("bright","pale");
  var swap = 0;
  var i = 0;
  var j = 0;

  // fill the news & dates arrays
  dates[0] = "1st of Jan 2003";
  news[0] = "New site under contruction, any suggestions welcome.";
  dates[1] = "5th of Feb 2003";
  news[1] = "New look site up and running. Tell us what you think.";
  dates[2] = "1st of May 2003";
  news[2] = "Online Contact form has been disables, but you can still email, phone or fax us.";
  dates[3] = "13th of Jul 2003";
  news[3] = "New online message centre up and running.";
  dates[4] = "2nd of Feb 2004";
  news[4] = "Sad News Cheleken Musha passes. Find out more <a href=\"musha.html\">here</a>.";

  // show each news item
  j = 4;
  for (i=0;i<5; i++)
  {

    swap = 0;
    if (i%2)
    {
      var swap = 1;
    }
    document.writeln ("        <tr>");
    document.writeln ("          <td width=\"2%\"> </td>");
    document.writeln ("          <td class=\"" + looks[swap] + "_news\">&nbsp; " + dates[j] + "</td><td class=\"" + looks[swap] + "_news\">&nbsp; </td><td class=\"" + looks[swap] + "_news\">" + news[j] + "</td>");
    document.writeln ("        </tr>");
    j--;
  }
} // End of news items