// A very effective way to prevent users nicking your images etc.

function blockError(){
	return true;
} // EOF

window.onerror = blockError;

var message="";
///////////////////////////////////
function clickIE() {
	if (document.all) {
		(message);
		return false;
	}
} // EOF

function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			(message);
			return false;
		}
	}
} // EOF

if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
 }else{
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
} // Endif

document.oncontextmenu=new Function("return false")
// --> 

function disableselect(e){
	return false
} // EOF

function reEnable(){
	return true
} // EOF

document.onselectstart=new Function ("return false");

if (window.sidebar){
	document.onmousedown=disableselect
	document.onclick=reEnable
} // Endif
// =================================================================================
function bj_preloadImages()	{
	if (document.images)	{
	  pic1= new Image(); 
	  pic1.src="images/pointers/home1.jpg"; 
	  pic2= new Image(); 
	  pic2.src="images/pointers/home2.jpg"; 
	  pic3= new Image(); 
	  pic3.src="images/pointers/About1.jpg"; 
	  pic4= new Image(); 
	  pic4.src="images/pointers/About2.jpg"; 
	  pic5= new Image(); 
	  pic5.src="images/pointers/contact1.jpg"; 
	  pic6= new Image(); 
	  pic6.src="images/pointers/contact2.jpg"; 
	  pic7= new Image(); 
	  pic7.src="images/pointers/avail1.jpg"; 
	  pic8= new Image(); 
	  pic8.src="images/pointers/avail2.jpg"; 
	  pic9= new Image(); 
	  pic9.src="images/pointers/levels1.jpg"; 
	  pic10= new Image(); 
	  pic10.src="images/pointers/levels2.jpg";
	  pic11= new Image(); 
	  pic11.src="images/pointers/infoLand1.jpg";
	  pic12= new Image(); 
	  pic12.src="images/pointers/infoLand2.jpg";
	  pic13= new Image(); 
	  pic13.src="images/pointers/infoTens1.jpg";
	  pic14= new Image(); 
	  pic14.src="images/pointers/infoTens2.jpg";
	  pic15= new Image(); 
	  pic15.src="images/pointers/tandc1.jpg";
	  pic16= new Image(); 
	  pic16.src="images/pointers/tandc2.jpg";
	  pic17= new Image(); 
	  pic17.src="images/pointers/insurance1.jpg";
	  pic18= new Image(); 
	  pic18.src="images/pointers/insurance2.jpg";
	  pic19= new Image(); 
	  pic19.src="images/pointers/holidays1.jpg";
	  pic20= new Image(); 
	  pic20.src="images/pointers/holidays2.jpg";
	  pic21= new Image(); 
	  pic21.src="images/pointers/rooms1.jpg";
	  pic22= new Image(); 
	  pic22.src="images/pointers/rooms2.jpg";
	  pic23= new Image(); 
	  pic23.src="images/OfficeFront.jpg";
	  pic24= new Image(); 
	  pic24.src="images/Victory Hill_336x86.jpg";
	} // Endif images
} // EOF  bj_preloadImages()

//====================================================================
  //The JavaScript function isDate checks whether the text entered in a field has 
  //the date format MM/DD/YYYY, displaying an error message and returning a value 
  //of “false” if it does not.
 
function isDate(theElement, theName) {
// This function checks if the text entered in a field 
// has the format MM/DD/YYYY. 
// Only the format is checked, not the date itself.

 var date_regex = /^\d{1,2}\/\d{1,2}\/\d{4}$/;

// ^ indicates start of expression
// \d{1,2} - the \d means digits and {1,2} means 1 or 2 digits
// $ indicates end f expression

 if (date_regex.test(theElement.value))  {
		var theDay = theElement.value.substring(0,2);
		// Remove leading zero
		if(theDay.substring(0,1) == "0")	{theDay = theDay.substring(1,2)}
				
		var theMonth = theElement.value.substring(3,5);

 if((parseInt(theDay) > 31) || (parseInt(theDay) < 3) || (parseInt(theMonth) > 12) || (parseInt(theMonth) < 1)) {
			alert(theName + ": " + theElement.value + " is incorrect");
		  theElement.focus();
		  return(false);
		} // endif day > 31

	return true;

  }else{
		// failed date_regex.test()
  	alert(theName + ": " + theElement.value + " is not in the format 'dd/mm/yyyy'   ");
	  theElement.focus();
	  return(false);
 } // endif date_regex.test()
} //EOF isDate()

//=========================


// --- Standard Macromedia Javascript 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]+"'");
}	// EOF function MM_goToURL()

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;
} // EOF MM_findObj(n, d)

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
} // EOF MM_showHideLayers()

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_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;
} // MM_swapImgRestore()

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];}
} // MM_swapImage()

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
} // MM_displayStatusMsg(msgStr)

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
} // EOF MM_callJS(jsStr)


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();
} // EOF MM_reloadPage(init)


//  ============== BJ's functions ===========================================================

// Used in LetsRent =================== 
 function showSite(ID)	{
  var siteAddress;
   switch(ID)	{
    case "1":
     siteAddress = "http://www.letsure.co.uk/";
     break
    case "2":
     siteAddress = "http://www.findaproperty.co.uk/letsrenthomes/index.html";
     break
    case "3":
     siteAddress = "http://www.rightmove.co.uk/forrent/15475";
     break
    case "4":
     siteAddress = "http://www.fish4homes.co.uk";
     break
    case "5":
     siteAddress = "http://www.arla.co.uk/";
     break
   default:
   // do nothing
  } // end switch
	window.open(siteAddress,"siteWin","scrollbars=yes,resizable=yes");
 } // EOF showSite()


//--------------------------------------------------------
// IMAGE ROTATION 
// Load images
adImages = new Array("images/rotating/Our_Garden.jpg","images/rotating/NareHotel.jpg","images/rotating/swans.jpg","images/rotating/StMawes.JPG")

// Load status line texts
quote = new Array("This is Image 1","This is Image 2","This is Image 3","This is Image 4")

// Load links if images are made 'live'
adURL = new Array ("www.javascripts.com","www.javascripts.com","www.javascripts.com","www.javascripts.com","www.javascripts.com","www.javascripts.com")

thisAd = 0
imgCt = adImages.length
quoteCt = quote.length

function rotate() {
  if (document.images) {
    if (document.cycle.complete) {
	  thisAd++
	  if (thisAd == imgCt && thisAd == quoteCt) {
	    thisAd = 0
	  } // endif
	  document.cycle.src = adImages[thisAd];
   //   window.defaultStatus = quote[thisAd];  // Not using the Status line here
	} // endif

// This sets the interval to which the images and quotes are rotated. 1000 equals 1 second
	setTimeout("rotate()", 4000) // 4 seconds
  } // endif
} // EOF rotate()

 function rotateLink() { 
	window.parent.location.href = "http://" + adURL[thisAd] ;
	} // EOF rotateLink()

// End of Image Rotation

//------------------------------------------------------------

	function setPoint(myNum)	{	// Adjust any number to 2 decimal places
		var myResult;
		var dotPos;
		var LpPrice;
		var backLen
		var backChars;
		var frontEnd

		// If no dot, add one to the end.
		myNum = myNum.toString();
		if(myNum.indexOf(".") == -1)	{
			myNum = myNum + ".";
		} // endif

		dotPos = myNum.indexOf("."); 		// get the dot position
		frontEnd = myNum.substring(0,dotPos)  // get the LH numbers

		LpPrice = myNum.length;	// get the whole length

// Get the number of chars after the dot
		backChars = myNum.substring(dotPos+1);
		backLen = backChars.length;

if(backLen == 0)	{	// no chars after the point
		myNum = myNum + "00";
}
if(backLen == 1)	{
		myNum = myNum + "0"; // one char after the point
}
if(backLen > 2) { // more than 2 chars after the point, get the first 2.
	myNum = frontEnd + "." + backChars.substring(0,3);
}

		myResult = myNum;
		document.writeln(myResult);
		return;
} // EOF setPoint()



// Date mechanism
function showDate()	{

// Date 1	- construct the date
dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
	now = new Date;
theHour = now.getHours();
theMinutes = now.getMinutes();
   ampm = "";

if (theMinutes > 9)	{
	theMinutes = theMinutes;
 }else{
	theMinutes = "0" + theMinutes;
} // end if

if (theHour > 0 && theHour < 13)	{
	theHour = theHour;
	ampm = "AM";
 	}else{
	theHour = theHour - 12;
	ampm = "PM"
} // end if

// Date 2 - show the date
document.write(dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate() + " ");
document.write("&nbsp;&nbsp;");
document.write(theHour + ":" + theMinutes + ampm);

} // EOF ShowDate


function doReload()	{
	window.location.href = window.location.href;
} // eof doReload()


//function addbookmark(){
//	var bookmarkurl="http://www.gladiatorit.com";
//	var bookmarktitle="GladiatorIT Computer Professionals Ltd";
//	if (document.all)
//	window.external.AddFavorite(bookmarkurl,bookmarktitle);
//} //EOF addbookmark()


function LTrim(str) {
     // We don't want to trim 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()

//==== FORM CHECKS ==================

// Generic error message.
function errorMsg(msg, offendingBox)	{
	var words, testmsg; 
	
	words = "Sorry, but you have made the following error: \n";
	words += "_____________________________________________\n\n";
	words += msg + "\n\n";
	
	alert(words);
	offendingBox.focus();
	offendingBox.select();
	return false;

}	// End - errorMsg(msg, offendingBox)


// ================ 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



//===================== EMAIL section =================

function validEmail(email)	{
	var Email = email.value
	var invalidChars; invalidChars = " /:,;"
	var badChar;
	var atPos;
	var periodPos;
	
// see if it is empty
	if (Email == "")	{
		errorMsg("You have not entered an email address.", email);
	}
	
// see if it contains any of the invalid characters
	for (i=0; i<invalidChars.length; i++)	{
		badChar = invalidChars.charAt(i);
		if (Email.indexOf(badChar,0) > -1)	{
			errorMsg("The email address is not correctly formatted: \n\n You have entered an invalid character, probably one of the following:\n\n/ : , ;  or a blank space", email);
		}
	}

// see if it contains only one '@' and in the right place
	atPos = Email.indexOf("@",1);
	if (atPos == -1)	{
		errorMsg("The email address is not correctly formatted: \n\n The '@' character is missing", email);
	}

	if (Email.indexOf("@",atPos+1) > -1)	{
		errorMsg("The email address is not correctly formatted: \n\n There are too many '@' characters", email);
	}
	
// check for '.' at the right places
	periodPos = Email.indexOf(".",atPos);
	if (periodPos == -1) 	{
		errorMsg("The email address is not correctly formatted: \n\n The '.' is missing after the '@' character", email);
	}
	if (periodPos+3 > Email.length)	{
		errorMsg("The email address is not correctly formatted: \n\n The '.' may be in the wrong place...or\n\n the address may not be complete", email);
	}
	
	if(Email.indexOf("@.") > 1)	{
		errorMsg("The email address is not correctly formatted: \n\n You have not put any letters between the  '@' character and the '.'", email);
	}
		if(Email.indexOf(".@") > 1)	{
		errorMsg("The email address is not correctly formatted: \n\n You have not put any letters between the  '.' and the '@' character", email);
	}
		if(Email.indexOf("..") > 1)	{
		errorMsg("The email address is not correctly formatted: \n\n You have put two '.'s together", email);
	}
	
	return;	// if it gets this far, all is probably OK...
	
}	// End validEmail(email)
	
//===================== END of  EMAIL section =================


// ============== Image management functions ================

function getFileExt(filename)	{
	dotIsAt = filename.lastIndexOf(".");
	ext = filename.substring(dotIsAt+1,filename.length);
	if ((ext=="jpg")||(ext=="JPG")||(ext=="gif")||(ext=="GIF")){
		return true;
		}else{
		msg =  "\nSorry, your image file must have the extension: '.JPG' or '.GIF'  \n\n";
		msg = msg + "                            Please try again."; 
		alert(msg);
		window.history.back();
	}	// End if 
}	//EOF getFileExt()


var blankImg;
blankImg = "../../images/dots/transparent.gif"

function makeBlank1()	{
	document.all.frmProducts.img1.src = blankImg;
	document.all.frmProducts.hidUseBlank1.value = 1;
	document.all.frmProducts.hidSave1.value = 1;
}
function makeBlank2()	{
	document.all.frmProducts.img2.src = blankImg;
	document.all.frmProducts.hidUseBlank2.value = 1;
	document.all.frmProducts.hidSave2.value = 1;
}
function makeBlank3()	{
	document.all.frmProducts.img3.src = blankImg;
	document.all.frmProducts.hidUseBlank3.value = 1;
	document.all.frmProducts.hidSave3.value = 1;
}
function makeBlank4()	{
	document.all.frmProducts.img4.src = blankImg;
	document.all.frmProducts.hidUseBlank4.value = 1;
	document.all.frmProducts.hidSave4.value = 1;
}
//----------------------------------------

function setImage1(filename)	{
	if (getFileExt(filename)){	// See above
		document.all.frmProducts.img1.src = filename;
		document.all.frmProducts.hidUseBlank1.value = 0;
		document.all.frmProducts.hidSave1.value = 1;
	//	document.all.frmProducts.hidPicName.value = filename;	     (not used)
	} //End if getFileExt()
}	//EOF setImage1()


function Restore1(filename)	{
	img = "U_images/" + filename;
	document.all.frmProducts.img1.src = img;
	document.all.frmProducts.hidUseBlank1.value = 0;
	document.all.frmProducts.hidSave1.value = 0;
}

function setImage2(filename)	{
	if (getFileExt(filename)){	// See above
		document.all.frmProducts.img2.src = filename;
		document.all.frmProducts.hidUseBlank2.value = 0;
		document.all.frmProducts.hidSave2.value = 1;
	} //End if
}	//EOF setImage2()

function Restore2(filename)	{
	img = "U_images/" + filename;
	document.all.frmProducts.img2.src = img;
	document.all.frmProducts.hidUseBlank2.value = 0;
	document.all.frmProducts.hidSave2.value = 0;
}
function setImage3(filename)	{
	if (getFileExt(filename)){	// See above
		document.all.frmProducts.img3.src = filename;
		document.all.frmProducts.hidUseBlank3.value = 0;
		document.all.frmProducts.hidSave3.value = 1;
	} //End if
}	//EOF setImage3()

function Restore3(filename)	{
	img = "U_images/" + filename;
	document.all.frmProducts.img3.src = img;
	document.all.frmProducts.hidUseBlank3.value = 0;
	document.all.frmProducts.hidSave3.value = 0;
}
function setImage4(filename)	{
	if (getFileExt(filename)){	// See above
		document.all.frmProducts.img4.src = filename;
		document.all.frmProducts.hidUseBlank4.value = 0;
		document.all.frmProducts.hidSave4.value = 1;
	} //End if
}	//EOF setImage4()

function Restore4(filename)	{
	img = "U_images/" + filename;
	document.all.frmProducts.img4.src = img;
	document.all.frmProducts.hidUseBlank4.value = 0;
	document.all.frmProducts.hidSave3.value = 0;
}
//============= EOF ==================
	function formCheck()	{
		var d = document.frmProducts;
		if(d.txtArea.value.length == 0)	{
			alert("Please enter an Area for your new holiday property.  ");
			document.location.href="#1";
			d.txtArea.focus();
			return false;
		} // endif no name
		
		if(!d.txtPrice.value == "0" )	{ 
			if(!isNum(d.txtPrice.value))	{
				alert("Please enter a number in the Price box");
				d.txtPrice.focus();
				d.txtPrice.select();
				return false;
			} // end if not numeric
		} // end if not 0

/*  Date field checks
if(!document.frmProducts.txtRegDate.value.length ==0)	{
	if(!isDate(document.frmProducts.txtRegDate, "Registration Date"))	{
		return false;
		} // endif Not isDate(regDate)
} // endif RegDate > 0

if(!document.frmProducts.txtFromDate.value.length ==0)	{
	if(!isDate(document.frmProducts.txtFromDate, "Available From"))	{
		return false;
	} // endif Not isDate(FromDate)
} // endif txtFromDate > 0

if(!document.frmProducts.txtLetDate.value.length ==0)	{
	if(!isDate(document.frmProducts.txtLetDate, "Date Let"))	{
		return false;
	} // endif not Not isDate(LetDate)
} // endif txtLetDate > 0
*/

return true;
	} // EOF formCheck()
//========================================================================