
//--------------------------------------------------------------------------------------
/* Validate the format of an email address */

function checkEmail(email) {
    var atIndex;
    var dotIndex;
    atIndex=email.value.indexOf("@");
    dotIndex=email.value.lastIndexOf(".");
    if (atIndex<1 || dotIndex<1 || dotIndex-atIndex<2 || email.value.length-dotIndex<3 || email.value.length-dotIndex>4)
        return false;
    else
	return true;
}

//--------------------------------------------------------------------------------------
/* Function to set focus in specified element. */

function fixElement(element, message) {
    alert(message);
    element.focus();
}

//--------------------------------------------------------------------------------------
function toProperCase(theString) {

    var alphabet_lcase = "abcdefghijklmnopqrstuvwxyz";
    var alphabet_ucase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var ptr;    var currChar;
    var prevChar=null;
    var lboChar=null;
    var newString="";

    if (theString == null)
        return;

    for (ptr = 0; ptr<theString.length; ptr++) {
	currChar = theString.charAt(ptr);
	if ((alphabet_lcase.search(prevChar) != -1) || (alphabet_ucase.search(prevChar) != -1)) 
	currChar=currChar.toLowerCase();
	    else
	currChar=currChar.toUpperCase();

	//Convert trailing capitals after apostrophe e.g. Lord'S to Lord's
        if (prevChar == "'" && alphabet_lcase.search(lboChar) != -1)
		currChar=currChar.toLowerCase();
	newString=newString+currChar;
	lboChar = prevChar;
        prevChar = currChar;
    }
    return newString;
}

//--------------------------------------------------------------------------------------
function openDialog(htmlfile) {

    window.status="";
    if (window.showModelessDialog) {
        strFeatures = "dialogWidth=360px;dialogHeight=495px;resizable=yes;"
                + "center=yes;border=thin;help=no;status=no"
        strTitle=window.showModelessDialog(htmlfile, "MyDialog", strFeatures);
        return false; }
    else
	return true;
}

//--------------------------------------------------------------------------------------
//Set status bar message
function setMsg(msg) {

	window.status = msg
	return true
}


//--------------------------------------------------------------------------------------
function newItem(expiryDate)
{
	exp = new Date(expiryDate);
	cur = new Date();
	if (cur.getTime() < exp.getTime())
	    document.write('<img src=\"img\\new.gif\" width=31 height=12 border=0 alt=\"new\">' );
}

//--------------------------------------------------------------------------------------
// Check Feedback Form
function checkfeedbackform() {

missinginfo = "";
if (document.feedback.recipient.value == "") {missinginfo += "-  Select a Recipient"}
if (document.feedback.sendername.value == "") {missinginfo += "\n-  Your Name"}
if ((document.feedback.senderemail.value == "") || (document.feedback.senderemail.value.indexOf('@') == -1) || (document.feedback.senderemail.value.indexOf('.') == -1)) {missinginfo += "\n-  Your email address"}
if ((document.feedback.sendercomments.value == "") && (document.feedback.newsletter.checked == "0")) {missinginfo += "\n-  Your Enquiry"}
if (document.feedback.verifytext.value.length != 4) {missinginfo += "\n-  The Security Code"}
if (missinginfo != "") {
  missinginfo = "Please correctly enter the following:\n" + missinginfo + "\n_____________________________";
  alert(missinginfo);
  return false;
  }
else {
//  missinginfo = "Thank you for completing the form.";
//  if (document.feedback.newsletter.checked == "1") {missinginfo += "\nYou will receive the next newsletter."}
//  missinginfo += "\n_____________________________";
//  alert(missinginfo);
  return true;
  }
}


//--------------------------------------------------------------------------------------
// Draw menu bar

function DrawMenuBar() {

var HTMLStr;
var quot='"';

HTMLStr="<font face='Arial' size='2'><a href='index.htm' class='link01'>Home</a>&nbsp;" + 
"     |&nbsp; <a href='sailing.htm' class='link01'>Sailing</a>&nbsp;" +
"     |&nbsp; <a href='wsurf.htm' class='link01'>Windsurfing</a>&nbsp;" +
"     |&nbsp; <a href='angling.htm' class='link01'>Angling</a>&nbsp;" +
"     |&nbsp; <a href='youths.htm' class='link01'>Youths</a>&nbsp;" +
"     |&nbsp; <a href='social.htm' class='link01'>Social</a>&nbsp; " +
"     |&nbsp; <a href='about.htm' class='link01'>About</a>&nbsp; " +
"     |&nbsp; <a href='calendar.htm' class='link01'>Diary</a>&nbsp;" +
"     |&nbsp; <a href='links.htm' class='link01'>Links</a>&nbsp;" +
"     |&nbsp; <a href='gallery.htm' class='link01'>Gallery</a>&nbsp;" +
"     |&nbsp; <a href='contact.htm' class='link01'>Contact</a></font>" 

document.write(HTMLStr);
}