// JavaScript Document
function rollOver(objId)
{var imgPath = '/images/buttons/'+objId+'on.jpg';
	document.getElementById(objId).src = imgPath;
}

function rollBack(objId)
{var imgPath = '/images/buttons/'+objId+'off.jpg';

	if(Lnk!='Lnk'+objId) document.getElementById(objId).src = imgPath;
}

var arrImg = new Array();
function preloadImages() 
{var intTemp = preloadImages.arguments;
	for(i=0; i<intTemp.length;i++) 
	{
  		arrImg[i] = new Image();
  		arrImg[i].src = preloadImages.arguments[i];
	}
}

function emailCheck (emailStr,fieldVal) {
var errStr = "";
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
errStr = fieldVal+" seems incorrect (check @ and .'s)"
return errStr;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
errStr = "The username contains invalid characters in "+fieldVal
return errStr;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
errStr = "The domain name contains invalid characters in "+fieldVal
return errStr;
   }
}
if (user.match(userPat)==null) {
errStr = "The username doesn't seem to be valid in "+fieldVal
return errStr;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
errStr = "Destination IP address is invalid in "+fieldVal
return errStr;
   }
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
errStr = "The domain name does not seem to be valid in "+fieldVal
return errStr;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
errStr = "The address must end in a well-known domain or two letter " + "country in "+fieldVal
return errStr;
}

if (len<2) {
errStr = "This address is missing a hostname in "+fieldVal
return errStr;
}

errStr = ""
return errStr;
}

function resize(intw, inth, id)
{
	var maxWidth = intw;
	var maxHeight = inth;
	var newWidth;
	var newHeight;
	var img = document.getElementById(id);
	var fWidth = img.width;
	var fHeight = img.height;
	if(fWidth > maxWidth || fHeight > maxHeight)
	{
		if(fWidth/maxWidth > fHeight/maxHeight)
		{
			newWidth = maxWidth;
			newHeight = fHeight * maxWidth / fWidth;
		}
		else
		{
			newHeight = maxHeight;
			newWidth = fWidth * maxHeight / fHeight;
		}
	}
	else
	{
		newWidth = fWidth;
		newHeight = fHeight;
	}
	img.width = newWidth;
	img.height = newHeight;
	img.style.visibility ='visible';
}

function priceRentValues()
{ var doc = document.frmPropertySearch;
	if(doc.trans_type.value=='1')
	{
		document.getElementById('span1').innerText = 'Price';
		doc.price.options.length = 0;
		doc.price.options[0] = new Option('Any','Any');
		doc.price.options[1] = new Option('\u00A3100k pcm - \u00A3200k pcm',' Between 100000 AND 200000');
		doc.price.options[2] = new Option('\u00A3200k pcm - \u00A3300k pcm',' Between 200000 AND 300000');
		doc.price.options[3] = new Option('\u00A3300k pcm - \u00A3400k pcm',' Between 300000 AND 400000');
		doc.price.options[4] = new Option('\u00A3400k pcm - \u00A3500k pcm',' Between 400000 AND 500000');
		doc.price.options[5] = new Option('above \u00A3500k pcm',' > 500000');
	}
	else
	{
		document.getElementById('span1').innerText = 'Rent';
		doc.price.options.length = 0;
		doc.price.options[0] = new Option('Any','Any');
		doc.price.options[1] = new Option('Upto \u00A3500 pcm',' <= 500');
		doc.price.options[2] = new Option('\u00A3500 pcm - \u00A31000 pcm',' Between 500 AND 1000');
		doc.price.options[3] = new Option('\u00A31000 pcm - \u00A31500 pcm',' Between 1000 AND 1500');
		doc.price.options[4] = new Option('above \u00A31500 pcm',' > 1500');
	}
}

function resetForm()
{var doc = document.frmPropertySearch;
	document.getElementById('span1').innerText = 'Price';
	doc.price.options.length = 0;
	doc.price.options[0] = new Option('Any','Any');
	doc.price.options[1] = new Option('\u00A3100k - \u00A3200k',' Between 100000 AND 200000');
	doc.price.options[2] = new Option('\u00A3200k - \u00A3300k',' Between 200000 AND 300000');
	doc.price.options[3] = new Option('\u00A3300k - \u00A3400k',' Between 300000 AND 400000');
	doc.price.options[4] = new Option('\u00A3400k - \u00A3500k',' Between 400000 AND 500000');
	doc.price.options[5] = new Option('above \u00A3500k',' > 500000');
	
	document.getElementById('trans_type').selectedIndex=0;
	document.getElementById('location').selectedIndex=0;
	document.getElementById('bedroom').selectedIndex=0;
	document.getElementById('price').selectedIndex=0;

}

function setSearch()
{
	document.frmPropertySearch.currentPage.value =1;
	document.frmPropertySearch.action= '/properties/property-results.asp';
	document.frmPropertySearch.submit();
}

function mmLoadMenus() {
  if (window.mm_menu_0916014116_0) return;
  window.mm_menu_0916014116_0 = new Menu("root",122,20,"Arial, Helvetica, sans-serif",11,"#191919","#FFFFFF","#C8C8C8","#A41B2A","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_0916014116_0.addMenuItem("BUYING","location='/sales/buying.asp'");
  mm_menu_0916014116_0.addMenuItem("SELLING","location='/sales/selling.asp'");
  mm_menu_0916014116_0.addMenuItem("SELLERS&nbsp;CHECKLIST","location='/sales/sellers-checklist.asp'");
  mm_menu_0916014116_0.addMenuItem("HIPs","location='/sales/home-information-pack.asp'");
  mm_menu_0916014116_0.addMenuItem("WHY&nbsp;CHOOSE&nbsp;US","location='/sales/why-choose-us.asp'");
  mm_menu_0916014116_0.fontWeight="bold";
  mm_menu_0916014116_0.hideOnMouseOut=true;
  mm_menu_0916014116_0.bgColor='#FFFFFF';
  mm_menu_0916014116_0.menuBorder=0;
  mm_menu_0916014116_0.menuLiteBgColor='#FFFFFF';
  mm_menu_0916014116_0.menuBorderBgColor='#FFFFFF';
	
 window.mm_menu_0916014117_0 = new Menu("root",122,20,"Arial, Helvetica, sans-serif",11,"#191919","#FFFFFF","#C8C8C8","#A41B2A","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_0916014117_0.addMenuItem("RENTING","location='/lettings/renting.asp'");
  mm_menu_0916014117_0.addMenuItem("LANDLORDS","location='/lettings/landlords.asp'");
  mm_menu_0916014117_0.addMenuItem("LEASING","location='/lettings/leasing.asp'");
  mm_menu_0916014117_0.addMenuItem("EPC","location='/lettings/epc.asp'");
  mm_menu_0916014117_0.addMenuItem("FAQs","location='/lettings/faqs.asp'");
  mm_menu_0916014117_0.addMenuItem("REGULATIONS","location='/lettings/regulations.asp'");
  mm_menu_0916014117_0.addMenuItem("SPECIAL&nbsp;OFFERS","location='/lettings/special-offers.asp'");
  mm_menu_0916014117_0.addMenuItem("WHY&nbsp;CHOOSE&nbsp;US","location='/lettings/why-choose-us.asp'");
  mm_menu_0916014117_0.fontWeight="bold";
  mm_menu_0916014117_0.hideOnMouseOut=true;
  mm_menu_0916014117_0.bgColor='#FFFFFF';
  mm_menu_0916014117_0.menuBorder=0;
  mm_menu_0916014117_0.menuLiteBgColor='#FFFFFF';
  mm_menu_0916014117_0.menuBorderBgColor='#FFFFFF';
  
  window.mm_menu_0916014118_0 = new Menu("root",122,20,"Arial, Helvetica, sans-serif",11,"#191919","#FFFFFF","#C8C8C8","#A41B2A","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_0916014118_0.addMenuItem("INSURANCE","location='/mortgages/insurance.asp'");
  //mm_menu_0916014118_0.addMenuItem("FINANCIAL&nbsp;CLAIMS&nbsp;REVIEW","window.open('http://www.cartelclientreview.co.uk/', '_blank');");
  mm_menu_0916014118_0.addMenuItem("MORTGAGES","location='/mortgages/mortgages.asp'");
  mm_menu_0916014118_0.fontWeight="bold";
  mm_menu_0916014118_0.hideOnMouseOut=true;
  mm_menu_0916014118_0.bgColor='#FFFFFF';
  mm_menu_0916014118_0.menuBorder=0;
  mm_menu_0916014118_0.menuLiteBgColor='#FFFFFF';
  mm_menu_0916014118_0.menuBorderBgColor='#FFFFFF';
  
mm_menu_0916014118_0.writeMenus();
}

function findProperty()
{
	if(document.getElementById('property_ref').value=='') alert('Please enter property ref or street name or postcode to find a property.');
	else 
	{
		document.frmPropertySearch.currentPage.value =1;
		document.frmFindProperty.action ='/properties/property-results.asp';
		document.frmFindProperty.submit();
	}
}

function validateValuation()
{var doc = document.frmValuation
 var err = false;
	if(doc.vr_name.value=='')
	{
		alert('please enter your name');
		err = true;
		return false;
	}
	if(doc.vr_phone.value=='' && doc.vr_email.value=='')
	{
		alert('Please provide atleast one contact method phone or email');
		err = true;
		return false;
	}
	if(doc.vr_email.value!='')
	{var enemail = emailCheck(doc.vr_email.value,'email address');
		if(enemail)
		{
			alert(enemail);
			err = true;
			return false;
		}
	}
	if(err == false)
	{
		doc.action = '/valuation-request-confirmation.asp';
		doc.submit();
	}
}