 function Preload() {
 	var args = Preload.arguments;
	document.imageArray = new Array(args.length);
	for(var i=0; i<args.length; i++) {
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	} // End For
 } // EOF

//=========== FORM CHECKER ============================
function	checkNews(box)	{
	if(box=="yes")	{
		document.frmMembership.chkNewsYes.checked=true;
		document.frmMembership.chkNewsNo.checked=false;
		return;
	}
	if(box=="no")	{
		document.frmMembership.chkNewsNo.checked=true;
		document.frmMembership.chkNewsYes.checked=false;
		return;
	}
}	// EOF checkNews()

function	checkReports(box)	{
	if(box=="yes")	{
		document.frmMembership.chkReportsYes.checked=true;
		document.frmMembership.chkReportsNo.checked=false;
		return;
	}
	if(box=="no")	{
		document.frmMembership.chkReportsNo.checked=true;
		document.frmMembership.chkReportsYes.checked=false;
		return;
	}
}	// EOF checkReports()


// ============= Check Form contents ============
function submitIt(ApptForm) {
	var f = document.frmMembership;
	
/*	// Not used here
	// Check they have put in their name
	if (Trim(f.txtName.value).length < 3) {
	  alert("NAME PROBLEM \n\nThere appears to be something wrong with your name. \n\nPlease enter your name (and any other missing details) \nor press the 'Cancel' button to leave the form. \n\n    Thank you.");
	  f.txtName.focus();
	  f.txtName.select();
	  return false; 
	} //endif
*/

	// Check that they have asked to receive something...
	if((f.chkNewsNo.checked) && (f.chkReportsNo.checked))	{
		alert("Please select to receive either News Letters and/or Market Reports\n\nor press Cancel to leave the Registration screen");
		return false;
	} // End if nothing checked


	// Check that they have entered SOME method of communication...
	// If (News OR Reports are requested) AND (Address AND Email are empty)
	if((f.chkNewsYes.checked || f.chkReportsYes.checked)	&& ((f.txtAddress.value.length==0) && (f.txtEmail.value.length==0))) {
		alert("To receive the News letter or Market Reports we need \n\n either:     a postal address\n\n       or:     an email address");
		f.txtEmail.select();
		f.txtEmail.focus();
		return false;
	}	// End If no contact


	// Check for valid e-mail address
	if (Trim(f.txtEmail.value).length > 1) {
	 if (!validEmail(f.txtEmail.value)) {
	  alert("E-MAIL ADDRESS PROBLEM \n\nYour email address appears to be incorrectly formatted. \n\nPlease either correct the error, or remove the email address altogether. \n\n    Thank you.");
  	f.txtEmail.focus();
	  f.txtEmail.select();
	  return false; 
	 } // End if valid email
	} // End if email > 1
	return true;
} // EOF submitIt(


// === Check cp_Edit_Member form ======================
function EditMember() {
	var f = document.frmMembership;

	// Check they have put in a Surname
	if (Trim(f.txtSurname.value).length < 3) {
	  alert("Please enter a Name for this Member \nor press the 'Cancel' button to leave the editing window. \n\n    Thank you.");
	  f.txtSurname.focus();
	  f.txtSurname.select();
	  return false; 
	} //endif

	// Check that they have been checked to receive something...
	if((f.chkNewsNo.checked) && (f.chkReportsNo.checked))	{
		if(confirm("This Member will not receive Newsletters or Market Reports.\n\nAre you sure?"))	{
		return true;
		} else {
		return false;	
		} // End If
	} // End if nothing checked


	// Check that they have entered SOME method of communication...
	// If (News OR Reports are requested) AND (Address AND Email are empty)
	if((f.chkNewsYes.checked || f.chkReportsYes.checked)	&& ((f.txtAddress.value.length==0) && (f.txtEmail.value.length==0))) {
		alert("To receive the News letter or Market Reports you need \n\n either:     a postal address\n\n       or:     an email address");
		f.txtEmail.select();
		f.txtEmail.focus();
		return false;
	}	// End If no contact


	// Check for valid e-mail address
	if (Trim(f.txtEmail.value).length > 1) {
	 if (!validEmail(f.txtEmail.value)) {
	  alert("E-MAIL ADDRESS PROBLEM \n\nThe email address appears to be incorrectly formatted. \n\nPlease either correct the error, or remove the email address altogether. \n\n    Thank you.");
  	f.txtEmail.focus();
	  f.txtEmail.select();
	  return false; 
	 } // End if valid email
	} // End if email > 1

	return true;
} // EOF EditMember()
//=======================================


// ============== Email checker ==============
function validEmail(email)  {
 invalidChars = " /:,;";

if ((email == "") || (email == " ")) {
alert("No email");
  return false;
  } // endif
  
  for (i=0; i<invalidChars.length; i++) {
   badChar = invalidChars.charAt(i);
   if (email.indexOf(badChar,0) > -1) {
    return false;
   } //endif
  } //endfor

	atPos = email.indexOf("@",1)

	if (atPos == -1) {
  	return false;
	} //endif

	if (email.indexOf("@",atPos+1) > -1) {
	 return false;
	 } //endif

	periodPos = email.indexOf(".",atPos)

	if (periodPos == -1) {
	  return false;
  } //endif

	if (periodPos+3 > email.length) {
  	return false;
  } // endif

// if it gets this far...
	return true
} //End of email check function

//=============================================

function LTrim(str) {
     // We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
      var whitespace = new String(" \t\n\r");

      var s = new String(str);

    if (whitespace.indexOf(s.charAt(0)) != -1) {
          // We have a string with leading blank(s)...
		 var j=0, i = s.length;
      // Iterate from the far left of string until we
      // don't have any more whitespace...
          while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;

 	// Get the substring from the first non-whitespace
     // character to the end of the string...
         s = s.substring(j, i);
         }
           return s;
    } // EOF LTrim()

function RTrim(str)   {
   // We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
     var whitespace = new String(" \t\n\r");
 	var s = new String(str);

     if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...
		var i = s.length - 1;       // Get length of string
	// Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        i--;

	// Get the substring from the front of the string to
	// where the last non-whitespace character is...
         s = s.substring(0, i+1);
    }
	return s;
 }	// eof RTrim()

function Trim(str)	{
	return RTrim(LTrim(str));
}	// EOF Trim()


	function goto(fileName)	{
		window.location.href = fileName;
	} // EOF goto()


// ================ NUMERIC section ================

// Check if something is numeric
function isNum(passedVal)	{
	if(passedVal =="")	{
		return false;
	}
	for (i=0; i<passedVal.length; i++)	{
		if (passedVal.charAt(i) < "0") 	{
			return false;
		}
		if (passedVal.charAt(i) > "9")	{
			return false;
		}
	}
	return true;
}	// End - isNum(passedVal)


// Check if the first character is a zero
function checkZero(thisBox)	{
//	var myBox; myBox = document.newvac_page1.salary;

	if (thisBox.value.charAt(0) == 0)	{
		errorMsg("You must enter a numeric value for Salary/Rate.", thisBox);
	   }else{
	   return;
	}
}	// End - checkZero(thisBox)



// only allow numeric entry
function keyCheck(eventObj, obj)
{
	var keyCode; 	var str=obj.value
	// Check For Browser Type
	if (document.all){ 
		keyCode=eventObj.keyCode
	}
	else{
		keyCode=eventObj.which
	}
	if(keyCode==46){ 
		if (str.indexOf(".")>0){
			return false
		}
	}
	if((keyCode<48 || keyCode >58)   &&   (keyCode != 46)){ // Allow only integers and decimal points
		return false
	}
	return true
}	// End - keyCheck(eventObj, obj)

// ========== End of NUMERIC section


// =================== MM_ functions ===============

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
  var obj=MM_findObj(objStr);
  if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
// == End Of MM_ functions ===============

