function init(){
var ld=(document.all);
var tmp=(document.all);
tmp=document.all.load.style;
ld=document.all.boat.style;
tmp.display="none";
ld.display="inline";
}

function Upcase(frmObj){
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0) {
   for (index = 0; index < strLen; index++) {
      if (index == 0) {
         tmpChar = tmpStr.substring(0,1).toUpperCase();
         postString = tmpStr.substring(1,strLen);
         tmpStr = tmpChar + postString;
      }
      else {
         tmpChar = tmpStr.substring(index, index+1);
         if (tmpChar == " " && index < (strLen-1)) {
            tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
            preString = tmpStr.substring(0, index+1);
            postString = tmpStr.substring(index+2,strLen);
            tmpStr = preString + tmpChar + postString;
         }
         }
       }
}
frmObj.value = tmpStr;
}

function dispboatbtns(fld,divid){
	if (fld.value == "BLANK"){
		divid.display="none";
		return;
	}
	divid.display="inline";
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function changeHREF(t, ind, img){

currentSel = document.getElementById(t);
currentSel.href = currentImage(ind, img);

}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function currentImage(ind, img) { //v3.0
  a = parseInt(ind.value);
  ind.value = a;
  return (img.value + ind.value + '.jpg');
}

function nextImage(ind, tot, img) { //v3.0
  a = parseInt(ind.value);
  b = parseInt(tot.value);
  a = a + 1;
  if (a > b) {a = 1};
  ind.value = a;
  return (img.value + ind.value + '.jpg');
}

function prevImage(ind, tot, img) { //v3.0
  a = parseInt(ind.value);
  b = parseInt(tot.value);
  a = a - 1;
  if (a < 1) {a = b};
  ind.value = a;
  return (img.value + ind.value + '.jpg');
}


function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1){
		   alert("Invalid email address");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid email address");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Invalid email address");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Invalid email address");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Invalid email address");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Invalid email address");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Invalid email address");
		    return false;
		 }

 		 return true;					
	}

var dtCh= "/";
var minYear=2009;
var maxYear=2010;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {;
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30};
		if (i==2) {this[i] = 29};
   } 
   return this;
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy");
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
return true;
}

function ValBR(){
	
    if ((document.brochure.send.value=="1")||(document.brochure.ADDRESS.value=="")){
		alert("Please enter your name and address");
		document.brochure.ADDRESS.focus();
		return false;
	}

 }

function ValML(){
	
    if ((document.maillist.name.value=="")||(document.maillist.name.value=="your name")){
		alert("Please enter your name");
		document.maillist.name.focus();
		return false;
	}
	
	if (echeck(document.maillist.emailL.value)==false){
		document.maillist.emailL.focus();
		return false;
	}


 }

function ValBKRF(){
	
	var emailID=document.ThisForm.EMAIL.value;
	var dt=document.ThisForm.startdate1.value;
    var boat=document.ThisForm.BOAT1.value;
		
	if (isDate(dt)==false){
		document.ThisForm.startdate1.focus();
		return false;
	}

    if (boat=="BLANK"){
		alert("Please select a boat");
		document.ThisForm.BOAT1.focus();
		return false;
	}

    if ((document.ThisForm.forename.value=="1")||(document.ThisForm.FORENAME.value=="")){
		alert("Please enter your forename");
		document.ThisForm.FORENAME.focus();
		return false;
	}

    if ((document.ThisForm.surname.value=="1")||(document.ThisForm.SURNAME.value=="")){
		alert("Please enter your surname");
		document.ThisForm.SURNAME.focus();
		return false;
	}

	if ((emailID==null)||(emailID=="")){
		alert("Please enter your email address");
		document.ThisForm.EMAIL.focus();
		return false;
	}

    if (document.ThisForm.email.value=="1"){
		alert("Please enter your email address");
		document.ThisForm.EMAIL.focus();
		return false;
	}

	if (echeck(emailID)==false){
		document.ThisForm.EMAIL.focus();
		return false;
	}


 }

function ValMBKF(){
	
	var emailID=document.ThisForm.EMAIL.value;
	var dt=document.ThisForm.startdate.value;
    var boat=document.ThisForm.BOAT.value;
	
    if ((document.ThisForm.bnum.value=="1")||(document.ThisForm.booknum.value=="")){
		alert("Please enter your booking number");
		document.ThisForm.booknum.focus();
		return false;
    }
	
	if (isDate(dt)==false){
		document.ThisForm.startdate.focus();
		return false;
	}

    if (boat=="BLANK"){
		alert("Please select a boat");
		document.ThisForm.BOAT.focus();
		return false;
	}

    if ((document.ThisForm.forename.value=="1")||(document.ThisForm.FORENAME.value=="")){
		alert("Please enter your forename");
		document.ThisForm.FORENAME.focus();
		return false;
	}

    if ((document.ThisForm.surname.value=="1")||(document.ThisForm.SURNAME.value=="")){
		alert("Please enter your surname");
		document.ThisForm.SURNAME.focus();
		return false;
	}
	    if ((document.ThisForm.address1.value=="1")||(document.ThisForm.ADDRESS1.value=="")){
		alert("Please enter your full address");
		document.ThisForm.ADDRESS1.focus();
		return false;
}
	    if ((document.ThisForm.address2.value=="1")||(document.ThisForm.ADDRESS2.value=="")){
		alert("Please enter your full address");
		document.ThisForm.ADDRESS2.focus();
		return false;
}
	    if ((document.ThisForm.region.value=="1")||(document.ThisForm.REGION.value=="")){
		alert("Please enter your region/county/state");
		document.ThisForm.REGION.focus();
		return false;
}
	    if ((document.ThisForm.country.value=="1")||(document.ThisForm.COUNTRY.value=="")){
		alert("Please enter your country");
		document.ThisForm.COUNTRY.focus();
		return false;
}
	    if ((document.ThisForm.postcode.value=="1")||(document.ThisForm.POSTCODE.value=="")){
		alert("Please enter your postal/zip code");
		document.ThisForm.POSTCODE.focus();
		return false;
}

	if ((emailID==null)||(emailID=="")){
		alert("Please enter your email address");
		document.ThisForm.EMAIL.focus();
		return false;
	}

    if (document.ThisForm.email.value=="1"){
		alert("Please enter your email address");
		document.ThisForm.EMAIL.focus();
		return false;
	}

	if (echeck(emailID)==false){
		document.ThisForm.EMAIL.focus();
		return false;
	}

    if (document.ThisForm.ExpMon.value=="X"){
		alert("Please enter your expiry month");
		document.ThisForm.ExpMon.focus();
		return false;
	}
	
    if (document.ThisForm.ExpYr.value=="X"){
		alert("Please enter your expiry year");
		document.ThisForm.ExpYr.focus();
		return false;
	}
	
    if (checkCreditCard(document.ThisForm.CardNumber.value, document.ThisForm.CardType.value)==false){
		alert(ccErrors[ccErrorNo]);
		document.ThisForm.CardNumber.focus();
		return false;
	}
	
    if (ValInt(document.ThisForm.Card_SecNo)==false){
		alert("Please enter your 3 digit number");
		document.ThisForm.Card_SecNo.focus();
		return false;
	}

    if (ValInt(document.ThisForm.Pay_Amount)==false){
		alert("Please enter your payment amount");
		document.ThisForm.Pay_Amount.focus();
		return false;
	}

 }


function ValIRF(){
	
	var emailID=document.ThisForm.EMAIL.value;

    if ((document.ThisForm.forename.value=="1")||(document.ThisForm.FORENAME.value=="")){
		alert("Please enter your forename");
		document.ThisForm.FORENAME.focus();
		return false;
	}

    if ((document.ThisForm.surname.value=="1")||(document.ThisForm.SURNAME.value=="")){
		alert("Please enter your surname");
		document.ThisForm.SURNAME.focus();
		return false;
	}

	if ((emailID==null)||(emailID=="")){
		alert("Please enter your email address");
		document.ThisForm.EMAIL.focus();
		return false;
	}

	if (echeck(emailID)==false){
		document.ThisForm.EMAIL.focus();
		return false;
	}

    if (document.ThisForm.EXTRA_INFO.value==""){
		alert("Please enter your message or question");
		document.ThisForm.EXTRA_INFO.focus();
		return false;
	}

 }

function ValInt(o)
   {
var sText = o.value
var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_clearTextfield(objName,objTag,newText) { //v3.0
  var obj = MM_findObj(objName); 
  var obj2 = MM_findObj(objTag);
  if (obj2.value == 1) obj.value = newText;
   obj2.value = ""; 
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function totalnum() {

var m=0,f=0;

if (parseInt(document.ThisForm.TMALES.value)) m=parseInt(document.ThisForm.TMALES.value);
if (parseInt(document.ThisForm.TFEMALES.value)) f=parseInt(document.ThisForm.TFEMALES.value);

document.ThisForm.TOTAL.value = m + f;

}

//-->

<!--

function paymeth1() {

if (document.ThisForm.Pay_Meth1.checked == true) {

document.ThisForm.Pay_Meth2.checked = false;

   }

}

//-->


function paymeth2() {

if (document.ThisForm.Pay_Meth2.checked == true) {

document.ThisForm.Pay_Meth1.checked = false;

   }

}

 
function popwin(page,w,h,title) {

if (screen.width < 1024) {
             windowprops = 'height=' + h + ',width=' + w + ",location=no,staus=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,screenX=0,screenY=0";}
else {
             windowprops = 'height=' + h + ',width=' + w + ",location=no,status=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,screenX=0,screenY=0";}

window.open(page, title, windowprops)

}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

	// Flooble.com's Animated Text script. Will animate a specified 
	// bit of text (determined by the ID of containing tag) by 
	// highlighting it with specified color one character at a time 
	// in a moving pattern.
	//
	// Summary of use: 
	//     call animate(tagID, color); where "tagID" is the ID 
	//     of the tag that contains text to be animated,
	//     and "color" is the color to use to highlight the text with.
	//
	// For more information, and detailed instructions, see 
	//     http://www.flooble.com/scripts/animate.php
	//
	// Copyright (c) 2002 by Animus Pactum Consulting Inc.
	// This script comes with no warranties whatsoever. 
	// Animus Pactum Consulting will not be responsible
	// for any damages resulting from its use.

        var ie4 = false;
        if(document.all) {
                ie4 = true; 
        }       
        function setContent(name, value) {
                var d;  
                if (ie4) { 
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }       
                d.innerHTML = value;    
        }       

	function getContent(name) {
		var d;
                if (ie4) {
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }
                return d.innerHTML;
	}

        function setColor(name, value) {
                var d;  
                if (ie4) { 
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }
                d.style.color = value;  
        }

	function getColor(name) {
                var d;
                if (ie4) {
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }
                return d.style.color;
        }

        function animate(name, col) {
		var value = getContent(name);
		if (value.indexOf('<span') >= 0) { return; }
		var length = 0;
                var str = '';
		var ch;
		var token = '';
		var htmltag = false;	
                for (i = 0; i < value.length; i++) {
			ch = value.substring(i, i+1);
			if (i < value.length - 1) { nextch = value.substring(i+1, i+2); } else { nextch = ' '; }
			token += ch;
			if (ch == '<' && '/aAbBpPhHiIoOuUlLtT'.indexOf(nextch) >= 0) { htmltag = true; }
			if (ch == '>' && htmltag) { htmltag = false; }
			if (!htmltag && ch.charCodeAt(0) > 30 && ch != ' ' && ch != '\n') {		
                        	str += '<span id="' + name + '_' + length + '">' + token + '</span>';
				token = '';
				length++;
			}
                }
                setContent(name, str);
                command = 'animateloop(\'' + name + '\', ' + length + ', 0, 1, \'' + col + '\')';
                setTimeout(command , 100);
        }

        function animateloop(name, length, ind, delta, col) {
		var next = ind + delta;
		if (next >= length) { delta = delta * -1; next = ind + delta; }
		if (next < 0) { delta = delta * -1; next = ind + delta; }
                setColor(name + '_' + ind, getColor(name + '_' + next));
                setColor(name + '_' + next, col);
                command = 'animateloop(\'' + name + '\', ' + length + ', ' + next + ', ' + delta + ', \'' + col + '\')';
                setTimeout(command , 100);
        }
