var rollOverArr=new Array();

setrollover('images/m1a_h.gif','landlord');
setrollover('images/m2a_h.gif','tenants');
setrollover('images/m3a_h.gif','properties');
setrollover('images/m4a_h.gif','about');
setrollover('images/m5a_h.gif','contact');
setrollover('images/m6a_h.gif','register');
setrollover('images/m7a_h.gif','services');

function setrollover(OverImgSrc,pageImageName)
{
if (! document.images)return;
if (pageImageName == null)
    pageImageName = document.images[document.images.length-1].name;
rollOverArr[pageImageName]=new Object;
rollOverArr[pageImageName].overImg = new Image;
rollOverArr[pageImageName].overImg.src=OverImgSrc;
}

function rollover(pageImageName)
{
if (! document.images)return;
if (! rollOverArr[pageImageName])return;
if (! rollOverArr[pageImageName].outImg)
    {
    rollOverArr[pageImageName].outImg = new Image;
    rollOverArr[pageImageName].outImg.src = document.images[pageImageName].src;
    }
document.images[pageImageName].src=rollOverArr[pageImageName].overImg.src;
}

function rollout(pageImageName)
{
if (! document.images)return;
if (! rollOverArr[pageImageName])return;
    document.images[pageImageName].src=rollOverArr[pageImageName].outImg.src;
}

function currenturl()
{
  var sPath = window.location.pathname;
  var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
  var href = new String(window.location.href);
  var hrefParts = href.split('?');
  var parm = new String(hrefParts[1]);
  document.login.page.value = sPage;
  document.login.parm.value = parm;
} 

function myReset() {
}

function checkemail() {
	var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

    if (document.login.Email.value == '' || document.login.Email.value == null) {
        alert('You must enter a Email');
        return false;
	} else {
      document.getElementById('forgotpass').href="forgotpassword.php?email="+document.login.Email.value+"&page="+sPage;
      return true;
	}  
}

function CheckLoggedIn(PropertyID,Userid) {
    if (!Userid) {
        window.alert('You cannot read more detail about this property.\r You must be registered or logged in');
        return false;
    }
    else {
        return true;
    }
}

function RegSubmit() {
    var emailID=document.register.email;
	
    if (document.register.firstname.value == '' || document.register.firstname.value == null) {
	    alert('You must enter a First Name');
        return false;
    }
    if (document.register.surname.value == '' || document.register.surname.value == null) {
	    alert('You must enter a Surname');
        return false;
    }
    if (document.register.telephone.value == '' || document.register.telephone.value == null) {
	    alert('You must enter a Telephone Number');
        return false;
    }
    if (document.register.mobile.value == '' || document.register.mobile.value == null) { 
	    alert('You must enter a Mobile Number');
        return false;
    }
	if (document.register.email.value == '' || document.register.email.value == null) {
        alert('You must enter a Email');
        return false;
	}
    if (document.register.password.value == '' || document.register.password.value == null) { 
	    alert('You must enter a Password');
        return false;
    }
    if (document.register.tc.checked == false) { 
	    alert('You must agreee to the Terms and Conditions');
        return false;
    }

	if ((emailID.value==null)||(emailID.value=="")){
		alert("You must enter an Email address");
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		return false;
	}
    return true;
}

function AccSubmit() {
    var emailID=document.update.email;
	
    if (document.update.firstname.value == '' || document.update.firstname.value == null) {
	    alert('You must enter a First Name');
        return false;
    }
    if (document.update.surname.value == '' || document.update.surname.value == null) {
	    alert('You must enter a Surname');
        return false;
    }
    if (document.update.telephone.value == '' || document.update.telephone.value == null) {
	    alert('You must enter a Telephone Number');
        return false;
    }
    if (document.update.mobile.value == '' || document.update.mobile.value == null) { 
	    alert('You must enter a Mobile Number');
        return false;
    }
	if ((emailID.value==null)||(emailID.value=="")){
		alert("You must enter an Email address");
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		return false;
	}
    if (document.update.email.value == '' || document.update.email.value == null) {
        alert('You must enter a Email');
        return false;
	}
    if (document.update.password.value == '' || document.update.password.value == null) { 
	    alert('You must enter a Password');
        return false;
    }
    return true;
}

function ContactSubmit() {
    var emailID=document.contact.email;
	
    if (document.contact.name.value == '' || document.contact.name.value == null) {
	    alert('You must enter a Name');
        return false;
    }
    if (document.contact.telephone.value == '' || document.contact.telephone.value == null) {
	    alert('You must enter a Telephone Number');
        return false;
    }
	if ((emailID.value==null)||(emailID.value=="")){
		alert("You must enter an Email address");
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		return false;
	}
    if (document.contact.message.value == '' || document.contact.message.value == null) {
	    alert('You must enter a Message');
        return false;
    }
    return true;
}

function UserSubmit() {
    var emailID=document.update.email;
	var updatetype=document.update.update.options[document.update.update.selectedIndex].value;

	if (updatetype == 'Modify') {
       if (document.update.firstname.value == '' || document.update.firstname.value == null) {
          alert('You must enter a First Name');
          return false;
      }
      if (document.update.surname.value == '' || document.update.surname.value == null) {
	     alert('You must enter a Surname');
         return false;
      }
	  if (document.update.telephone.value == '' || document.update.telephone.value == null) {
	     alert('You must enter a Telephone Number');
         return false;
      }
	  if (document.update.mobile.value == '' || document.update.mobile.value == null) { 
	     alert('You must enter a Mobile Number');
         return false;
      }
	  if ((emailID.value==null)||(emailID.value=="")){
	     alert("You must enter an Email address");
         return false;
  	  }
	  if (echeck(emailID.value)==false){
	     emailID.value="";
	     return false;
      }
      if (document.update.email.value == '' || document.update.email.value == null) {
         alert('You must enter a Email');
         return false;
  	  }
	}
    return true;
}

function PartnerSubmit() {
	var updatetype=document.partner.update.options[document.partner.update.selectedIndex].value;

	if (updatetype != 'Delete') {
       if (document.partner.name.value == '' || document.partner.name.value == null) {
          alert('You must enter a Name');
          return false;
       }
	   
       if (document.partner.description.value == '' || document.partner.description.value == null) {
	      alert('You must enter a Description');
          return false;
       }
	   
       if (updatetype == 'Add') {
          if (document.partner.logo.value == '' || document.partner.logo.value == null) {
	         alert('You must enter a Partner Logo');
             return false;
          }
	   
          if (document.partner.slogo.value == '' || document.partner.slogo.value == null) { 
	         alert('You must enter a Small Partner Logo');
             return false;
          }
	   }
	}
    return true;
}

function UKSubmit() {
	var updatetype=document.property.update.options[document.property.update.selectedIndex].value;

	if (updatetype != 'Delete') {
		
       if (document.property.address1.value == '' || document.property.address1.value == null) {
          alert('You must enter an Address');
          return false;
       }
	   
       if (document.property.town.value == '' || document.property.town.value == null) {
	      alert('You must enter a Town');
          return false;
       }

       if (document.property.county.value == '' || document.property.county.value == null) {
	      alert('You must enter a County');
          return false;
       }

       if (document.property.region.value == '' || document.property.region.value == null) {
	      alert('You must enter a Region');
          return false;
       }

       if (document.property.postcode.value == '' || document.property.postcode.value == null) {
	      alert('You must enter a Postcode');
          return false;
       }

       if (document.property.country.value == '' || document.property.country.value == null) {
	      alert('You must enter a Country');
          return false;
       }

       if(isNaN(document.property.price.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Price Field."); 
         document.property.price.focus(); 
         return false; 
       }

       if(isNaN(document.property.bedroom.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Bedroom Field."); 
         document.property.bedroom.focus(); 
         return false; 
       }
	   
       if(isNaN(document.property.bathroom.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Bathroom Field."); 
         document.property.bathroom.focus(); 
         return false; 
       }

       if (updatetype == 'Add') {
          if (document.property.picture1.value == '' || document.property.picture1.value == null) {
	         alert('You must enter a file in Picture1');
             return false;
          }
	   }
	}
    return true;
}

function OverseasSubmit() {
	var updatetype=document.overseas.update.options[document.overseas.update.selectedIndex].value;

	if (updatetype != 'Delete') {
       if (document.overseas.address1.value == '' || document.overseas.address1.value == null) {
          alert('You must enter an Address');
          return false;
       }
	   
       if (document.overseas.town.value == '' || document.overseas.town.value == null) {
	      alert('You must enter a Town');
          return false;
       }

       if (document.overseas.county.value == '' || document.overseas.county.value == null) {
	      alert('You must enter a County');
          return false;
       }

       if (document.overseas.region.value == '' || document.overseas.region.value == null) {
	      alert('You must enter a Region');
          return false;
       }

       if (document.overseas.postcode.value == '' || document.overseas.postcode.value == null) {
	      alert('You must enter a Postcode');
          return false;
       }

       if (document.overseas.country.value == '' || document.overseas.country.value == null) {
	      alert('You must enter a Country');
          return false;
       }

       if (document.overseas.buy.checked == false) {
	      alert('You must tick this Property as Buy');
          return false;
       }

       if (document.overseas.type.value == '' || document.overseas.type.value == null) {
	      alert('You must enter a Type');
          return false;
       }

       if (document.overseas.description.value == '' || document.overseas.description.value == null) {
	      alert('You must enter a Description');
          return false;
       }

       if (document.overseas.smalldesc.value == '' || document.overseas.smalldesc.value == null) {
	      alert('You must enter a Small Description');
          return false;
       }

       if(isNaN(document.overseas.price.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Price Field."); 
         document.overseas.price.focus(); 
         return false; 
       }

       if(isNaN(document.overseas.bedroom.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Bedroom Field."); 
         document.overseas.bedroom.focus(); 
         return false; 
       }
	   
       if(isNaN(document.overseas.bathroom.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Bathroom Field."); 
         document.overseas.bathroom.focus(); 
         return false; 
       }
	   
       if (document.overseas.preview1.value == '' || document.overseas.preview1.value == null) {
	      alert('You must enter a preview Description');
          return false;
       }

       if (document.overseas.main1.value == '' || document.overseas.main1.value == null) {
	      alert('You must enter a main description');
          return false;
       }

       if (updatetype == 'Add') {
          if (document.overseas.picture1.value == '' || document.overseas.picture1.value == null) {
	         alert('You must enter a file in Picture1');
             return false;
          }
	   }
	}
    return true;
}

function LettingSubmit() {
	var updatetype=document.letting.update.options[document.letting.update.selectedIndex].value;

	if (updatetype != 'Delete') {
       if (document.letting.address1.value == '' || document.letting.address1.value == null) {
          alert('You must enter an Address');
          return false;
       }
	   
       if (document.letting.town.value == '' || document.letting.town.value == null) {
	      alert('You must enter a Town');
          return false;
       }

       if (document.letting.county.value == '' || document.letting.county.value == null) {
	      alert('You must enter a County');
          return false;
       }

       if (document.letting.region.value == '' || document.letting.region.value == null) {
	      alert('You must enter a Region');
          return false;
       }

       if (document.letting.postcode.value == '' || document.letting.postcode.value == null) {
	      alert('You must enter a Postcode');
          return false;
       }

       if (document.letting.country.value == '' || document.letting.country.value == null) {
	      alert('You must enter a Country');
          return false;
       }

       if (document.letting.let.checked == false) {
  	      alert('You must tick this Property as Let');
          return false;
       }
	   
       if (document.letting.type.value == '' || document.letting.type.value == null) {
	      alert('You must enter a Type');
          return false;
       }

       if (document.letting.description.value == '' || document.letting.description.value == null) {
	      alert('You must enter a Description');
          return false;
       }

       if (document.letting.smalldesc.value == '' || document.letting.smalldesc.value == null) {
	      alert('You must enter a Small Description');
          return false;
       }

       if(isNaN(document.letting.price.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Price Field."); 
         document.letting.price.focus(); 
         return false; 
       }

       if(isNaN(document.letting.bedroom.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Bedroom Field."); 
         document.letting.bedroom.focus(); 
         return false; 
       }
	   
       if(isNaN(document.letting.bathroom.value)) 
       { 
         alert("Invalid format.\n\nOnly numbers are allowed in the Bathroom Field."); 
         document.letting.bathroom.focus(); 
         return false; 
       }
	   
       if (document.letting.preview1.value == '' || document.letting.preview1.value == null) {
	      alert('You must enter a preview Description');
          return false;
       }

       if (document.letting.main1.value == '' || document.letting.main1.value == null) {
	      alert('You must enter a main description');
          return false;
       }

       if (updatetype == 'Add') {
          if (document.letting.picture1.value == '' || document.letting.picture1.value == null) {
	         alert('You must enter a file in Picture1');
             return false;
          }
	   }
	}
    return true;
}

function DeveloperSubmit() {
    if (document.contact.surname.value == '' || document.contact.surname.value == null) {
	    alert('You must enter a Surname');
        return false;
    }
    if (document.contact.company.value == '' || document.contact.company.value == null) {
	    alert('You must enter a Company');
        return false;
    }
    if (document.contact.telephone.value == '' || document.contact.telephone.value == null) {
	    alert('You must enter a Telephone Number');
        return false;
    }
    if (document.contact.comments.value == '' || document.contact.comments.value == null) {
	    alert('You must enter a Comment');
        return false;
    }
    return true;
}

function popUp(URL,Pwidth,Pheight) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + Pwidth +',height=' + Pheight + ',left = 390,top = -100');");
} 

function SearchSubmit() {
//	alert('Started Search Check');
	
    if(isNaN(document.searchf.pricemin.value)) 
    { 
      alert("Invalid format.\n\nOnly numbers are allowed in the Minimum Price Field."); 
      document.searchf.pricemin.focus(); 
      return false; 
    }
    if(isNaN(document.searchf.pricemax.value)) 
    {
      alert("Invalid format.\n\nOnly numbers are allowed in the Maximum Price Field."); 
      document.searchf.pricemax.focus(); 
      return false; 
    }
    return true;
}

function sm_jump(objSelect){
   if (objSelect.selectedIndex<0) return false; 
   var objOpt = objSelect.options[objSelect.selectedIndex]; 
   window.location.href=objOpt.value;
}

function movepic(img_src) {
document.mainpic.src=img_src;
}

function Enlargemainpic(){
document.getElementById('bigPicSrc').src = document.getElementById('mainpic').src;
document.getElementById('mainpic').style.display = 'none';
document.getElementById('bigPic').style.display = 'inline';
document.getElementById('enlarge').style.display = 'none';
document.getElementById('reduce').style.display = 'inline';
}

function Reducemainpic(){
document.getElementById('bigPic').style.display = 'none';
document.getElementById('mainpic').style.display = 'inline';
document.getElementById('enlarge').style.display = 'inline';
document.getElementById('reduce').style.display = 'none';
}