if (thisPage == 'gallery'){
var rootUrl = "../";
} else {
var rootUrl = "";
}

document.write('<HTML><HEAD><TITLE>Skily Hills Olive Grove &amp; Funtion Centre</TITLE>');
document.write('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">');
document.write('<LINK REL="stylesheet" HREF="'+ rootUrl +'styles.css" TYPE="TEXT/CSS"></HEAD>');

// Code that checks forms have been filled in starts ////////////////////////////

function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// This is the function that performs form verification. It will be invoked
// from the onSubmit() event handler. The handler should return whatever
// value this function returns.
function verify(f)
{
    var msg;
    var empty_fields = "";
    var errors = "";

    // Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea") || (e.type == "radio")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }

            // Now check for fields that are supposed to be numeric.
            if (e.numeric || (e.min != null) || (e.max != null)) {
                var v = parseFloat(e.value);
                if (isNaN(v) ||
                    ((e.min != null) && (v < e.min)) ||
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null)
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null)
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted.
    // Otherwise return true.
    if (!empty_fields && !errors) return true;

    msg  = "______________________________________________________\n\n"
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "Please correct these error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
        msg += "- The following required field(s) are empty:"
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

// Code that checks forms have been filled in ends ////////////////////////////


document.write('<BODY BGCOLOR="#586108" TEXT="#333300" LINK="#586108" VLINK="#586108" ALINK="#339900" LEFTMARGIN="0" TOPMARGIN="0">');
document.write('<BR><TABLE WIDTH="700" BORDER="0" CELLSPACING="0" CELLPADDING="0" BACKGROUND="'+ rootUrl +'images/grain_pattern.gif" ALIGN="CENTER">');

document.write('<TR><TD WIDTH="18" VALIGN="TOP"><IMG SRC="'+ rootUrl +'images/cnr_top_left.gif" WIDTH="18" HEIGHT="18"></TD>');
document.write('<TD ROWSPAN="2"><A HREF="'+ rootUrl +'index.html"><IMG SRC="'+ rootUrl +'images/logo_sml.gif" WIDTH="317" HEIGHT="81" VSPACE="4" BORDER="0"></A><BR><center><IMG SRC="'+ rootUrl +'images/hex_586108.gif" WIDTH="658" HEIGHT="1" VSPACE="4"></TD>');

document.write('<TD VALIGN="TOP" ALIGN="RIGHT" WIDTH="18"><IMG SRC="'+ rootUrl +'images/cnr_top_rght.gif" WIDTH="18" HEIGHT="18"></TD></TR>');
  
document.write('<TR><TD WIDTH="18">&nbsp;</TD>');
document.write('<TD VALIGN="TOP" ALIGN="RIGHT" WIDTH="18">&nbsp;</TD></TR>');
document.write('<TR><TD>&nbsp;</TD><TD ALIGN="CENTER" VALIGN="TOP" HEIGHT="25">');

document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>');

if (thisPage == 'function'){
document.write('<TD><li CLASS="navSelected"><b>Function Centre</B></TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'function.html" CLASS="nav2">Function Centre</A></B></TD>');
}

if (thisPage == 'tours'){
document.write('<TD><li CLASS="navSelected"><b>Peter\'s Tours</B></TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'tours.html" CLASS="nav2">Peter\'s Tours</A></B></TD>');
}

if (thisPage == 'grove'){
document.write('<TD><li CLASS="navSelected"><b>Olive Grove</B></TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'grove.html" CLASS="nav2">Olive Grove</A></B></TD>');
}

if (thisPage == 'history'){
document.write('<TD><li CLASS="navSelected"><b>History</B>&nbsp;&nbsp;</TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'history.html" CLASS="nav2">History</A></B>&nbsp;&nbsp;</TD>');
}

if (thisPage == 'form'){
document.write('<TD><li CLASS="navSelected"><b>Order Olive Oil</B></TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'form.html" CLASS="nav2">Order Olive Oil</A> &nbsp;&nbsp;</B></TD>');
}

if (thisPage == 'map'){
document.write('<TD><li CLASS="navSelected"><b>Location Map</B></TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'map.html" CLASS="nav2">Location Map</A></B></TD>');
}

if (thisPage == 'contact'){
document.write('<TD><li CLASS="navSelected"><b>Contact</B></TD>');
} else {
document.write('<TD><li><B><A HREF="'+ rootUrl +'contact.html" CLASS="nav2">Contact</A></B></TD>');
}

document.write('</TR></TABLE>');
      
document.write('<IMG SRC="'+ rootUrl +'images/hex_586108.gif" WIDTH="658" HEIGHT="1" VSPACE="4"></TD><TD>&nbsp;</TD></TR><TR> <TD>&nbsp;</TD><TD VALIGN="TOP">');
