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_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_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_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]+"'");
}

//  ============== BJ's functions ============================

	function showThis(thePage)	{
		window.location.href= thePage ;
	} // EOF showThis()

/*
// PREVENT COPYING FROM THE SITE ============
function blockError(){
	return true;
} // EOFblockError()

window.onerror = blockError;

var message="";
function clickIE() {
	if (document.all) {
		(message);
		return false;
	} // Endif all
} // EOF clickIE()

function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			(message);
			return false;
		} // Endif which
	} // Endif layers
} // EOF clickNS(e)

if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
 }else{
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
} // Endif layers

document.oncontextmenu=new Function("return false")

function disableselect(e){
	return false
} // EOF disableselect(e)

function reEnable(){
	return true
} // EOF reEnable()

document.onselectstart=new Function ("return false");

if (window.sidebar){
	document.onmousedown=disableselect
	document.onclick=reEnable
} // Endif sidebar

//========= END OF COPY PROTECTION ==================================
*/

// Replacement for MM_preloadImages
 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
	 

function showSite(url)	{
	// Get current window width and height
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth*0.9;
  winH = window.innerHeight*0.9;
 } // endif appName==Netscape)
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth*0.9;
  winH = document.body.offsetHeight*0.9;
 } // endif appName ==Microsoft
} // endif version > 3

	siteWin = window.open(url,"myWin","width="+winW+",height="+winH+",top=30,left=30,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes")
} // eof showSite


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()


// ============= Check Form contents ============
function submitIt(ApptForm) {
	// Check they have put in their name
	if (Trim(frmContact.txtName.value).length == 0) {
	  alert("NO NAME \n\n Please enter your name. \n\n    Thank you.");
	  frmContact.txtName.focus();
	  frmContact.txtName.select();
	  return false; 
	} //endif

// Check for the existence of an email address
	var strEmail;
	strEmail = Trim(frmContact.txtEmail.value).length;
	if (strEmail == 0)	{
		alert("NO EMAIL ADDRESS \n\n Please enter your email address. \n\n    Thank you.");
	  frmContact.txtEmail.focus();
	  frmContact.txtEmail.select();
		return false;
	} // End If no email address

	// Check for valid e-mail address
	if (Trim(frmContact.txtEmail.value).length > 1) {
	 if (!validEmail(frmContact.txtEmail.value)) {	// see function below
	  alert("E-MAIL ADDRESS PROBLEM \n\nYour email address appears to be incorrectly formatted. \n\nPlease make sure your email address is in the correct format. \n\n    Thank you.");
  frmContact.txtEmail.focus();
	  frmContact.txtEmail.select();
	  return false; 
	 } // End if valid email
	} // End if email > 1

	// Check they have put in a Subject

	if (Trim(frmContact.txtSubject.value).length == 0) {
	  alert("NO SUBJECT \n\nPlease enter a brief Subject for this Enquiry. \n\n    Thank you.");
	  frmContact.txtSubject.focus();
	  frmContact.txtSubject.select();
	  return false; 
	} //endif no Subject

// Check for an actual message
	if (Trim(frmContact.txtMessage.value).length == 0) {
	alert("NO ENQUIRY \n\n Please ask us anything regarding the services we offer. \n\n");
	  frmContact.txtMessage.focus();
	  frmContact.txtMessage.select();
	  return false; 
	} //endif no Message


//========================================================================//
	// Check that they have entered SOME method of communication... // NOT USED as phone is Optional
//	var totalComms;
//	totalComms = Trim(frmContact.txtPhone.value).length + Trim(frmContact.txtEmail.value).length;
//	if (totalComms == 0)	{
//		alert("CONTACT PROBLEM \n\n You have not provided the means to contact you. \n\nPlease enter either a phone number or an email address. \n\n    Thank you.");
//	  frmContact.txtEmail.focus();
//	  frmContact.txtEmail.select();
//		return false;
//	} // End If no communication

	// Check for a phone number	// NOT USED IN THIS SITE as it is Optional
//	if (ApptForm.ByPhone.checked) {
//	 if (!phoneOK(ApptForm.HomePhone.value) && !phoneOK(ApptForm.WorkPhone.value) ) {
//		  alert("PHONE NUMBER PROBLEM \n\n Oops...you have asked us to contact you by phone, but you have not entered a phone number. \n\nPlease either enter a phone number, or de-select the Phone checkbox. \n\n    Thank you.");
//	  ApptForm.HomePhone.focus();
//	  ApptForm.HomePhone.select();
//	  return false; 
//  } // end of if !phone
// } // End of if ByPhone checked
//===========================================================================//

// If it gets this far...
		return true;
} //End of submit form function


// ============== Check Email format ==============
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

	// Added 22/4/07
	// if there are two dots together
	twoDotsPos = email.indexOf("..",atPos)
	if (twoDotsPos > -1 ) {
	  return false;
  } //endif

// if it gets this far...
	return true
} //End of email check function

//=============================================

// ============= Check Expo Form contents ============
function checkExpo(RegForm) {
	// Check they have put in their name
	if (Trim(frmRegister.txtName.value).length < 3) {
	  alert("NAME PROBLEM \n\nSorry - we need a Name before you can be registered \n\n    Thank you.");
	  frmRegister.txtName.focus();
	  frmRegister.txtName.select();
	  return false; 
	} //endif

	// Check that they have entered SOME method of communication...
	var totalComms;
	totalComms = Trim(frmRegister.txtPhone.value).length + Trim(frmRegister.txtEmail.value).length;

	if (totalComms == 0)	{
		alert("CONTACT PROBLEM \n\n You have not provided the means to contact you. \n\nPlease enter either a phone number or an email address. \n\n    Thank you.");
	  frmRegister.txtEmail.focus();
	  frmRegister.txtEmail.select();
		return false;
	} // End If no communication

	// Check for valid e-mail address
	if (Trim(frmRegister.txtEmail.value).length > 1) {
	 if (!validEmail(frmRegister.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.");
  frmRegister.txtEmail.focus();
	  frmRegister.txtEmail.select();
	  return false; 
	 } // End if valid email
	} // End if email > 1
	return true;
} //EOF checkExpo(RegForm)

function gotoPage(p)	{
	switch (p)	{
		case 1:
			document.location.href="siteMap.asp";
			break

		case 2:
			document.location.href="contactus.asp";
			break

		case 24:
			document.location.href="external_links.asp";
			break

		default:
			// do nothing
	} // end switch

} // EOFgotoSiteMap()

//============= EOF ==================
