//===== FB Design functions =================
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
} // EOF newImage()

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}	// End for
	} // End if
} // EOF changeImages()

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		commercial_new_04_over = newImage("images_commercial_new/commercial_new_04-over.gif");
		commercial_new_06_over = newImage("images_commercial_new/commercial_new_06-over.gif");
		commercial_new_08_over = newImage("images_commercial_new/commercial_new_08-over.gif");
		commercial_new_10_over = newImage("images_commercial_new/commercial_new_10-over.gif");
		commercial_new_12_over = newImage("images_commercial_new/commercial_new_12-over.gif");
		commercial_new_22_over = newImage("images_commercial_new/commercial_new_22-over.gif");
		commercial_new_24_over = newImage("images_commercial_new/commercial_new_24-over.gif");
		commercial_new_25_over = newImage("images_commercial_new/commercial_new_25-over.gif");
		commercial_new_26_over = newImage("images_commercial_new/commercial_new_26-over.gif");
		commercial_new_27_over = newImage("images_commercial_new/commercial_new_27-over.gif");
		FB_Design_Home_Page_C_OL_29_over = newImage("images_commercial_new/FB-Design-Home-Page-C-OL-39.gif");
		preloadFlag = true;
	} // end if
} // EOF preloadImages()
//======================= End of  FB Design functions ======================================================

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) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); 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 newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
} // EOF newImage()

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}	// End for
	} // End if
} // EOF changeImages()

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		commercial_new_04_over = newImage("images_commercial_new/commercial_new_04-over.gif");
		commercial_new_06_over = newImage("images_commercial_new/commercial_new_06-over.gif");
		commercial_new_08_over = newImage("images_commercial_new/commercial_new_08-over.gif");
		commercial_new_10_over = newImage("images_commercial_new/commercial_new_10-over.gif");
		commercial_new_12_over = newImage("images_commercial_new/commercial_new_12-over.gif");
		commercial_new_22_over = newImage("images_commercial_new/commercial_new_22-over.gif");
		commercial_new_24_over = newImage("images_commercial_new/commercial_new_24-over.gif");
		commercial_new_25_over = newImage("images_commercial_new/commercial_new_25-over.gif");
		commercial_new_26_over = newImage("images_commercial_new/commercial_new_26-over.gif");
		commercial_new_27_over = newImage("images_commercial_new/commercial_new_27-over.gif");
		FB_Design_Home_Page_C_OL_29_over = newImage("images_commercial_new/FB-Design-Home-Page-C-OL-39.gif");
		preloadFlag = true;
	} // end if
} // EOF preloadImages()
//  ============== 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 < 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.");
	  frmContact.txtName.focus();
	  frmContact.txtName.select();
	  return false; 
	} //endif

	// Check that they have entered SOME method of communication...
	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
//	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


	// Check for valid e-mail address
	if (Trim(frmContact.txtEmail.value).length > 1) {
	 if (!validEmail(frmContact.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.");
  frmContact.txtEmail.focus();
	  frmContact.txtEmail.select();
	  return false; 
	 } // End if valid email
	} // End if email > 1
	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

// 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)


//============= EOF ==================
