// JavaScript Document

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3
	

function setOnClickEvent(popimage){
	//alert("The code is:"+popimagecode);
	document.getElementById('SlideShow').onclick = function(){
	popImage(popimage,'');

 return false;
};
}



function setOnClickEvent1(popimage){
	//alert("The code is:"+popimagecode);
	document.getElementById('SlideShow1').onclick = function(){
	popImage(popimage,'');

 return false;
};
}

function runSlideShow(){
	if (document.images.SlideShow)
	{

	   if (document.all){
		  document.images.SlideShow.style.filter="blendTrans(duration=2)"
		  document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
		  document.images.SlideShow.filters.blendTrans.Apply()      
	   }
	   document.images.SlideShow.src = preLoad[j].src;
		//alert("The value is:"+PicOnClick[j]);
		//setOnClickEvent(PicOnClick[j]);

	   if (document.all){
		  document.images.SlideShow.filters.blendTrans.Play()
	   }
	   j = j + 1
	   if (j > (p-1)) j=0
	   t = setTimeout('runSlideShow()', slideShowSpeed)
	}   
	else if (document.images.SlideShow1)
	{
	   if (document.all){
		  document.images.SlideShow1.style.filter="blendTrans(duration=2)"
		  document.images.SlideShow1.style.filter="blendTrans(duration=crossFadeDuration)"
		  document.images.SlideShow1.filters.blendTrans.Apply()      
	   }
		document.images.SlideShow1.src = preLoad[j].src;
		setOnClickEvent1(PicOnClick[0]);
		if (document.all){
		  document.images.SlideShow1.filters.blendTrans.Play()
	   }
	}

}

function revealImage(displayname,popupname){

	 document.images.SlideShow1.src = displayname;
	 setOnClickEvent1(popupname);
}




function getRandom(maxPic) {
     var randNum = 0;
     var img = "<img src='resources/photos/generic/" ;
     var img1 = ".jpg'";
     var preimg = "<TR><TD align='center'>";
	 var after = "</TD></TR>";			
     var mynum = new  String;
     var mynum2;
     var mynum3;
     
     mynum = randNew(maxPic);
     mynum2 = randNew(maxPic);
    
     while (mynum == mynum2) {		
          mynum2 = randNew(maxPic)
     } 
     mynum3 = randNew(maxPic);
     while (mynum == mynum3 || mynum2 == mynum3) {
          mynum3 = randNew(maxPic)
     } 


	     document.write(preimg + img + mynum + img1 + after + preimg + img + mynum2 + img1 + after + preimg + img + mynum3 + img1 + after);
   

}

function randNew(maxPics) {
	//getRandom can produce duplicates so check they are unique
	randNum = 0;
	while (randNum > maxPics || randNum < 1) {
          randNum = (Math.round((Math.random() * 10)))
     }      
	return (randNum);
}

	


function formContactValidator(theForm) { 

  if (theForm.title.value.length == 0)
  {
    alert("Please enter a value for the title");
    theForm.title.focus();
    return (false);
  }
  
  if (theForm.firstname.value.length == 0)
  {
    alert("Please enter your first name");
    theForm.firstname.focus();
    return (false);
  }

  if (theForm.surname.value.length == 0)
  {
    alert("Please enter your surname");
    theForm.surname.focus();
    return (false);
  } 

	var zToCheck;
	zToCheck = theForm.emailaddress.value;
	
	  var zRegExp;
	  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

	  if (zToCheck.search(zRegExp) == -1)
	  {
		alert("An email address must be supplied. Please enter a valid email ADDRESS in the email address field");
		theForm.emailaddress.focus();
		return (false);
	  }	

  if (theForm.maincontactnumber.value.length == 0)
  {
    alert("Please enter a contact telephone");
    theForm.maincontactnumber.focus();
    return (false);
  } 

  if (theForm.referal.value.length == 0)
  {
    alert("Please select how you found us");
    theForm.referal.focus();
    return (false);
  }   
 
   if (theForm.propertyaddress.value.length == 0)
  {
    alert("Please enter the address of the property");
    theForm.propertyaddress.focus();
    return (false);
  }  

   if (theForm.propertypostcode.value.length == 0)
  {
    alert("Please enter the post code of the property");
    theForm.propertypostcode.focus();
    return (false);
  }

   if (theForm.propertybedrooms.value.length == 0)
  {
    alert("Please state how many bedrooms the property has");
    theForm.propertybedrooms.focus();
    return (false);
  }

   if (theForm.propertybathrooms.value.length == 0)
  {
    alert("Please state how many bathrooms the property has");
    theForm.propertybathrooms.focus();
    return (false);
  }

   if (theForm.propertytye.value.length == 0)
  {
    alert("Please select the property type");
    theForm.propertytye.focus();
    return (false);
  }

var radioWithAgents = document.forms[0].propertyestateagents;
var valueWithAgents;

for (var i = 0; i < radioWithAgents.length; i++)
	{
		if (radioWithAgents[i].checked == true){

			valueWithAgents = radioWithAgents[i].value;
		}
	}

 
	if (valueWithAgents == "yes")
	{
	   if (theForm.agentscontractlength.value.length == 0)
	  {
		alert("Please state how long is left on this contract");
		theForm.agentscontractlength.focus();
		return (false);
	  } 
	}

   if (theForm.propertypriceguide.value.length == 0)
  {
    alert("Please state the property price guide");
    theForm.propertypriceguide.focus();
    return (false);
  }  
 
   if (theForm.propertylowestprice.value.length == 0)
  {
    alert("Please state the lowest acceptable price for the property");
    theForm.propertylowestprice.focus();
    return (false);
  }  
 
   if (theForm.repairsneeded.value.length == 0)
  {
    alert("Please state what repairs are required on the property");
    theForm.repairsneeded.focus();
    return (false);
  }  

   if (theForm.propertysourceofvalue.value.length == 0)
  {
    alert("Please state the 'source of value' of the property");
    theForm.propertysourceofvalue.focus();
    return (false);
  }
 
  
return (true);
}




function popImage(imageURL,imageTitle){
	
	
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultPopUpWidth  = 600;
defaultPopUpHeight = 600;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultPopUpWidth+',height='+defaultPopUpHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width='+defaultPopUpWidth+',height='+defaultPopUpHeight+',left='+PositionX+',top='+PositionY;

if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Garrett Axford</title><style>body{background-color: #fff; text-align:center;margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo('+defaultPopUpWidth+','+defaultPopUpHeight+');');
//writeln('width='(document.body.clientWidth-document.images[0].width)+');');
//writeln('height='(document.body.clientHeight-document.images[0].height)+');');

writeln('width='+defaultPopUpWidth+'-(document.body.clientWidth-document.images[0].width);');
writeln('height='+defaultPopUpHeight+'-(document.body.clientHeight-document.images[0].height);');

writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["GarrettAxford"].width;');
writeln('window.innerHeight=document.images["GarrettAxford"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('</sc'+'ript>');
if (!AutoClose) 
writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();self.focus()">')
else 
writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();self.focus()" onblur="self.close()">');
writeln('<img name="GarrettAxford" src='+imageURL+' style="display:block"></body></html>');
close();		
}}