
function calcsize(){
	var feet = document.register.metres.value;
	metres = feet * 10.7639104;
	metres = Math.round(metres);
	if(metres>0){
		document.register.size.value = metres;
	}
	setTimeout("calcsize()", 1000); 
}


function timer(){
	width=document.body.clientWidth;
	height=document.body.offsetHeight;
	
	document.height=height;
	document.width=width;
}

function validateRegistrationFormresidential() {
  var okSoFar=true
  var whaterror = "Before you register:\n"
  
    if (document.register.firstname.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'first name' field!\n" 
  }
  
    if (document.register.surname.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'surname' field!\n" 
  }

    if (document.register.tel.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'telephone number' field!\n" 
  }

    if (document.register.postcode.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'Postcode' field!\n" 
  }

    if (document.register.tel.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'Telephone number' field!\n" 
  }

      if (document.register.email.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please fill in your e-mail address!\n" 
  } else {

  var foundAt = document.register.email.value.indexOf("@",0)
  foundAt = foundAt + document.register.email.value.indexOf(".",0)
  if (foundAt < 1 && okSoFar) {
   	 okSoFar = false
   	 whaterror=whaterror+"Please Enter a Valid Email Address\n"
  	}
  }
  
  if (document.register.email2.value!=document.register.email.value) {
    okSoFar=false
    whaterror=whaterror+"Please make sure the email confirmation\r\nfield is the same as the email field\n" 
  } 
  
  if (okSoFar==true) {
    document.register.submit()
  } else {
  alert (whaterror)
  }
}

function validateRegistrationFormcommercial() {
  var okSoFar=true
  var whaterror = "Before you register:\n"
  
    if (document.register.firstname.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'first name' field!\n" 
  }
  
    if (document.register.surname.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'surname' field!\n" 
  }

    if (document.register.tel.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please complete the 'telephone number' field!\n" 
  }

      if (document.register.email.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please fill in your e-mail address!\n" 
  } else {

  var foundAt = document.register.email.value.indexOf("@",0)
  foundAt = foundAt + document.register.email.value.indexOf(".",0)
  if (foundAt < 1 && okSoFar) {
   	 okSoFar = false
   	 whaterror=whaterror+"Please Enter a Valid Email Address\n"
  	}
  }
  
  if (document.register.email2.value!=document.register.email.value) {
    okSoFar=false
    whaterror=whaterror+"Please make sure the email confirmation\r\nfield is the same as the email field\n" 
  } 
  
  if (okSoFar==true) {
    document.register.submit()
  } else {
  alert (whaterror)
  }
}

function validateJob() {
  var okSoFar=true
  var formname='request';
  var whaterror = "Before you submit this form:\n\n"
  
    if (document.forms[formname].title.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the job title\n" 
  }
  
    if (document.forms[formname].description.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the job description\n" 
  }

	if(document.forms[formname].email.value!=""){
	  var foundAt = document.forms[formname].email.value.indexOf("@",0)
	  var dot = document.forms[formname].email.value.indexOf(".",0)
	  if ((foundAt < 1 || dot<1) && okSoFar) {
	   	 okSoFar = false
	   	 whaterror=whaterror+"Please enter a valid e-mail address\n"
	  }
}
  
    if (okSoFar==true) {
    document.forms[formname].submit()
  } else {
  alert (whaterror)
  }
}



function validateContactForm(){
  var okSoFar=true
  var formname='request';
  var whaterror = "Before you submit this enquiry:\n\n"
  
    if (document.forms['contact'].name.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter your name\n" 
  }
  
      if (document.forms['contact'].message.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter your enquiry\n" 
  }

      if (document.forms['contact'].email.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter your e-mail address!\n" 
  } else {

  var foundAt = document.forms['contact'].email.value.indexOf("@",0)
  var dot = document.forms['contact'].email.value.indexOf(".",0)
  if ((foundAt < 1 || dot<1) && okSoFar) {
   	 okSoFar = false
   	 whaterror=whaterror+"Please enter a valid e-mail address\n"
  	}
  }
  
    if (okSoFar==true) {
    document.forms['contact'].submit()
  } else {
  alert (whaterror)
  }
}

function validateApplicationForm(){
  var okSoFar=true
  var formname='request';
  var whaterror = "Before you submit this form:\n\n"
  
    if (document.forms['contact'].name.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter your name\n" 
  }
  
      if (document.forms['contact'].Telephone.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter your telephone number\n" 
  }

      if (document.forms['contact'].Email.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter your e-mail address!\n" 
  } else {

  var foundAt = document.forms['contact'].Email.value.indexOf("@",0)
  var dot = document.forms['contact'].Email.value.indexOf(".",0)
  if ((foundAt < 1 || dot<1) && okSoFar) {
   	 okSoFar = false
   	 whaterror=whaterror+"Please enter a valid e-mail address\n"
  	}
  }
  
    if (okSoFar==true) {
    document.forms['contact'].submit()
  } else {
  alert (whaterror)
  }
}


/*  CELL OVERS  */
function cOver(button){
	button.style.backgroundColor='#DADADA';
	//button.style.borderTop='1px solid #AAAAAA';
	button.style.borderBottom='1px solid #AAAAAA';
}

function cOut(button){
	button.style.backgroundColor='#EFEFEF';
	//button.style.borderTop='1px solid white';
	button.style.borderBottom='1px solid #D4D4D4';
}


/*  Search results  */
function resOver(button){
	button.style.backgroundColor='#F4F4F4';
	//button.style.borderTop='1px solid #AAAAAA';
	button.style.border='1px solid #F21742';
}

function resOut(button){
	button.style.backgroundColor='white';
	//button.style.borderTop='1px solid white';
	button.style.border='1px solid silver';
}


//--Menus

function menuOver(button){
	button.style.backgroundColor='black';
}

function menuOut(button){
	button.style.backgroundColor='#F21742';
}

function showmenu(menuname){
	document.getElementById(menuname).style.visibility='visible';
}
function hidemenu(menuname){
	document.getElementById(menuname).style.visibility='hidden';
}


function linkto(url){
	if(url){
		document.location.href=url;
	}else{
		alert('No URL assigned');
	}
}

// Popup window with image in it
function imagePrev(image){
	popWin=window.open('image.php?image='+image, 'popwin', 'WIDTH=450,HEIGHT=450');
	popWin.focus();
}


function validateResProp() {
  var okSoFar=true
  var formname='request';
  var whaterror = "Before you submit this form:\n\n"
  
    if (document.forms[formname].town.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the town\n" 
  }
  
      if (document.forms[formname].county.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the county\n" 
  }
  
      if (document.forms[formname].postcode.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the postcode\n" 
  }
  
      if (document.forms[formname].price.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the price\n" 
  }
  
      if (document.forms[formname].description.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter a description\n" 
  }

  
    if (okSoFar==true) {
    document.forms[formname].submit()
  } else {
  alert (whaterror)
  }
}


function validateCommProp() {
  var okSoFar=true
  var formname='request';
  var whaterror = "Before you submit this form:\n\n"
  
    if (document.forms[formname].town.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the town\n" 
  }
  
      if (document.forms[formname].county.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the county\n" 
  }
  
  
      if (document.forms[formname].price_sale.value=="" && document.forms[formname].price_let.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter a sale or rental price\n" 
  }
  
        if (document.forms[formname].size.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter the size\n" 
  }
  
      if (document.forms[formname].description.value=="") {
    okSoFar=false
    whaterror=whaterror+"Please enter a description\n" 
  }

  
    if (okSoFar==true) {
    document.forms[formname].submit()
  } else {
  alert (whaterror)
  }
}

function deleteconfirm(del){ 
	if (
		confirm("Are you sure you wish to permanently delete this item?\n\nOK = Yes - Cancel = No")){ 
		window.location=del;
	}
} 

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.01
  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 && d.getElementById) x=d.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];}
}