<!--

/**  Function: null clearInput(ele, val)
*    ---------------------------------------------------------------- 
*    Purpose:           clear an input
*    Arguments:         ele			- str, the name of the element to clear
*						val			- str, the default value that should be cleared
*    Returns/Assigns:   none
*/

function clearInput(ele, val){
	if(ele.value == val){
		ele.value='';
	}
}


/**  Function: null openWin(windowURL, windowName, windowFeatures)
*    ---------------------------------------------------------------- 
*    Purpose:           opens a new window and sets its properties
*    Arguments:         windowURL			- str, the url
*						windowName			- str, the window name
*						windowFeatures		- str, the features of the window
*    Returns/Assigns:   none
*/

function openWin(windowURL, windowName, windowFeatures){
	window.open(windowURL, windowName, windowFeatures);
}


/**  Function: null zoomMap(inc, postcode)
*    ---------------------------------------------------------------- 
*    Purpose:           allows to diplay the zoomable map from multimap.com when using postcode
*    Arguments:         inc			- str, the level of the zoom
*    					          postcode			- str, the postcode of the map
*    Returns/Assigns:   none
*/

var delta=2;
function zoomMap(inc, postcode) {
	newdelta=delta+inc;
	if(newdelta<0){alert("You cannot zoom in any further");return;}
	else{delta=newdelta;}
	document.getElementById('mapimg').src="http://www.multimap.com/clients/gif.cgi?client=fishergerman&pc="+postcode+"&height=375&width=375&icon=red_house&ds="+delta;
}


/**  Function: null zoomMapC(inc, lat, lot)
*    ---------------------------------------------------------------- 
*    Purpose:           allows to diplay the zoomable map from multimap.com when useing coordinates
*    Arguments:         inc			- str, the level of the zoom
*    					          latitude, longitude	- str, the latitude, longitude of the map
*    Returns/Assigns:   none
*/

function zoomMapC(inc, lat, lon) {
	newdelta=delta+inc;
	if(newdelta<0){alert("You cannot zoom in any further");return;}
	else{delta=newdelta;}
	document.getElementById('mapimg').src="http://www.multimap.com/clients/gif.cgi?client=fishergerman&lat="+lat+"&lon="+lon+"&height=375&width=375&icon=red_house&ds="+delta;
}

/**  Function: null displayAerialPhoto(delta, postcode)
*    ---------------------------------------------------------------- 
*    Purpose:           display aerial photo map from multimap.com when useing postcode
*    Arguments:         
*    					          
*    Returns/Assigns:   none
*/

function displayAerialPhoto(delta, postcode) {
	document.getElementById('mapimg').src="http://www.multimap.com/clients/photo.cgi?client=fishergerman&pc="+postcode+"&jpg=1&height=375&width=375&icon=red_house&ds="+delta;
}

/**  Function: null displayAerialPhotoC(delta, lat, lot)
*    ---------------------------------------------------------------- 
*    Purpose:           display aerial photo map from multimap.com when useing coordinates
*    Arguments:         
*    					          
*    Returns/Assigns:   none
*/

function displayAerialPhotoC(delta, lat, lon) {
	document.getElementById('mapimg').src="http://www.multimap.com/clients/photo.cgi?client=fishergerman&lat="+lat+"&lon="+lon+"&jpg=1&height=375&width=375&icon=red_house&ds="+delta;
}

/**  Function: null displayTypeMap(postcode)
*    ---------------------------------------------------------------- 
*    Purpose:           display map or aerial map from postcode and zoom options (+ / -) are removed when aerial map is set
*    Arguments:         
*    					          
*    Returns/Assigns:   none
*/

function displayTypeMap(postcode) {
	var kindMap = document.getElementById('kindMap').value; 
	
	switch(kindMap){
		case '1':
			kindMap = 2;
			document.getElementById('zoomOption').style.display = "block"; 
			document.getElementById('mapimg').src="http://www.multimap.com/clients/gif.cgi?client=fishergerman&pc="+postcode+"&height=375&width=375&icon=red_house&ds="+delta;
			break;
		case '2':			
			kindMap = 1;
			document.getElementById('zoomOption').style.display = "none"; 
			document.getElementById('mapimg').src="http://www.multimap.com/clients/photo.cgi?client=fishergerman&pc="+postcode+"&jpg=1&height=375&width=375&icon=red_house&ds=-1";
			break;
	}
	
	document.getElementById('kindMap').value = kindMap;	
}

/**  Function: null displayTypeMapC(lat, lon)
*    ---------------------------------------------------------------- 
*    Purpose:           display map or aerial map from coordinates and zoom options (+ / -) are removed when aerial map is set
*    Arguments:         
*    					          
*    Returns/Assigns:   none
*/

function displayTypeMapC(lat, lon) {
	var kindMap = document.getElementById('kindMap').value; 
	
	switch(kindMap){
		case '1':
			kindMap = 2;
			document.getElementById('zoomOption').style.display = "block"; 
			document.getElementById('mapimg').src="http://www.multimap.com/clients/gif.cgi?client=fishergerman&lat="+lat+"&lon="+lon+"&height=375&width=375&icon=red_house&ds="+delta;
			break;
		case '2':
			kindMap = 1;
			document.getElementById('zoomOption').style.display = "none"; 
			document.getElementById('mapimg').src="http://www.multimap.com/clients/photo.cgi?client=fishergerman&lat="+lat+"&lon="+lon+"&jpg=1&height=375&width=375&icon=red_house&ds=-1";
			break;
	}
	
	document.getElementById('kindMap').value = kindMap;	
}

/**  Function: null writeEmail(user, domain, subject, text)
*    ---------------------------------------------------------------- 
*    Purpose:           writes an email address in a mailto link
*						if no 'text' is supplied it just writes the <a href="mailto:user@domain">
*						if 'text' is supplied it writes <a href="mailto:user@domain">text</a>
*						if 'subject' is supplied it writes <a href="mailto:user@domain?subject=subject">text</a>
*    Arguments:         user			- str, the username for the email address
*						domain			- str, the domain name of the email address
*						subject			- str, any subject line required
*						text			- str, text for the link
*    Returns/Assigns:   writes a mailto link
*/

function writeEmail(user, domain, subject, text){
	// open up a mailto and combine the user and domain into an email address
	document.write('<a href="mailto:' + user + '@' + domain);
	if(subject){
		// if there's a subject tack it on
		document.write('?subject=' + subject);
	}
	document.write('">');
	if(text){
		// if there's text for the link add it and close the link
		document.write(text + '</a>');
	}
}

//Following functions are used for the property search map

var defaultImage = new Image();
defaultImage.src = "/images/map.gif";

function load_map(currentArea){
	var el = document.getElementById('ukmap');
	el.src = "/images/map" + currentArea + ".gif"; 
	var el1 = document.getElementById('infoBox');
	if(currentArea == 'area_0'){
		el1.value = "Knutsford, Chester, Warrington, Nantwich, Hale, Saddleworth, Manchester, Flintshire.";
	}
	if(currentArea == 'area_1'){
		el1.value = 'Stafford, Shrewsbury, Telford, Rugeley, Uttoxeter, Stoke on Trent, Market Drayton, Whitchurch.';
	}
	if(currentArea == 'area_2'){
		el1.value = 'Ashby de la Zouch, Buxton, Bakewell, Chesterfield, Ashbourne, Derby, Burton on Trent, Lichfield, Tamworth.';
	}
	if(currentArea == 'area_3'){
		el1.value = 'Market Harborough, Northampton, Wellingborough, Kettering, Uppingham, Melton Mowbray, Lutterworth.';
	}
	if(currentArea == 'area_4'){
		el1.value = 'Banbury, Chipping Norton, Witney, Deddington, Buckingham, Towcester, Rugby, Stratford on Avon.';
	}
	if(currentArea == 'area_5'){
		el1.value = 'Evesham, Worcester, Hereford, Ross on Wye, Tewkesbury, Cheltenham, Moreton in Marsh, Broadway, Herefordshire, Monmouthshire ';
	}
	if(currentArea == 'area_6'){
		el1.value = 'Newark, Grantham, Nottinghamshire, Lincoln, Spalding, Market Rasen and Sleaford.';
	}
	if(currentArea == 'area_7'){
		el1.value = 'St Helens, Liverpool, Southport, Preston, Bolton, Wigan, Warrington, Ormskirk, Skelmersdale, Widnes, Formby, Haydock and Leigh.';
	}
	if(currentArea == 'area_8'){
		el1.value = 'Thame, Aylesbury, Milton Keynes, High Wycombe, Buckinghamshire, Oxfordshire, Bedfordshire, Hertfordshire.';
	}
}

function load_default_map(){
	var el = document.getElementById('ukmap');
	el.src = defaultImage.src;
	var el1 = document.getElementById('infoBox');
	el1.value = 'Click on a region on the map to select, and click again to de-select.';
}

function select_area(area){
	var el = document.getElementById(area);
	
	var el0 = document.getElementById('area_0');
	var el1 = document.getElementById('area_1');
	var el2 = document.getElementById('area_2');
	var el3 = document.getElementById('area_3');
	var el4 = document.getElementById('area_4');
	var el5 = document.getElementById('area_5');
	var el6 = document.getElementById('area_6');
	var el7 = document.getElementById('area_7');	
	var el8 = document.getElementById('area_8');
	
	var el9 = document.getElementById('area_9');
	
	var counties = document.getElementById('countyid');
	
	if(el.checked == false){
		el.checked = true;
		counties.disabled = true;		
	}else{ 
		el.checked = false;
		el9.checked = false;
		if(el0.checked != true && el1.checked != true && el2.checked != true && el3.checked != true  && el4.checked != true && el5.checked != true && el6.checked != true && el7.checked != true && el8.checked != true){
			counties.disabled = false;			
		}
	}
}

function select_county(elt){
	var el = document.getElementById(elt);
		
	var el0 = document.getElementById('area_0');
	var el1 = document.getElementById('area_1');
	var el2 = document.getElementById('area_2');
	var el3 = document.getElementById('area_3');
	var el4 = document.getElementById('area_4');
	var el5 = document.getElementById('area_5');
	var el6 = document.getElementById('area_6');
	var el7 = document.getElementById('area_7');
	var el8 = document.getElementById('area_8');
	
	if(el.value == 0){
		el0.disabled = false;
		el1.disabled = false;
		el2.disabled = false;
		el3.disabled = false;
		el4.disabled = false;
		el5.disabled = false;
		el6.disabled = false;		
		el7.disabled = false;	
		el8.disabled = false;
	}else{
		el0.disabled = true;
		el1.disabled = true;
		el2.disabled = true;
		el3.disabled = true;
		el4.disabled = true;
		el5.disabled = true;
		el6.disabled = true;
		el7.disabled = true;
		el8.disabled = true;
	}
}

function check_area(area){
	var el = document.getElementById(area);
	
	var el0 = document.getElementById('area_0');
	var el1 = document.getElementById('area_1');
	var el2 = document.getElementById('area_2');
	var el3 = document.getElementById('area_3');
	var el4 = document.getElementById('area_4');
	var el5 = document.getElementById('area_5');
	var el6 = document.getElementById('area_6');
	var el7 = document.getElementById('area_7');	
	var el8 = document.getElementById('area_8');
	
	var el9 = document.getElementById('area_9');
	
	var counties = document.getElementById('countyid');
	
	if(el.checked == true){
		counties.disabled = true;		
	}else{ 
		el9.checked = false;
		if(el0.checked != true && el1.checked != true && el2.checked != true && el3.checked != true && el4.checked != true && el5.checked != true && el6.checked != true && el7.checked != true && el8.checked != true){
			counties.disabled = false;			
		}
	}
}

function check_all_area(){
	var el = document.getElementById('area_9');
	
	var counties = document.getElementById('countyid');
	
	var el0 = document.getElementById('area_0');
	var el1 = document.getElementById('area_1');
	var el2 = document.getElementById('area_2');
	var el3 = document.getElementById('area_3');
	var el4 = document.getElementById('area_4');
	var el5 = document.getElementById('area_5');
	var el6 = document.getElementById('area_6');
	var el7 = document.getElementById('area_7');
	var el8 = document.getElementById('area_8');
	
	if(el.checked == true){		
		counties.disabled = true;
		
		el0.checked = true;
		el1.checked = true;
		el2.checked = true;
		el3.checked = true;
		el4.checked = true;
		el5.checked = true;
		el6.checked = true;
		el7.checked = true;
		el8.checked = true;
	}else{
		counties.disabled = false;
		 
		el0.checked = false;
		el1.checked = false;
		el2.checked = false;
		el3.checked = false;
		el4.checked = false;
		el5.checked = false;
		el6.checked = false;
		el7.checked = false;
		el8.checked = false;
	}
}

function select_all_type(){
	var el = document.getElementById('type_8');
	
	var el0 = document.getElementById('type_0');
	var el1 = document.getElementById('type_1');
	var el2 = document.getElementById('type_2');
	var el3 = document.getElementById('type_3');
	var el4 = document.getElementById('type_4');
	var el5 = document.getElementById('type_5');
	var el6 = document.getElementById('type_6');
	var el7 = document.getElementById('type_7');
	var el8 = document.getElementById('type_8');
	
	if(el.checked == true){
		el0.checked = true;
		el1.checked = true;
		el2.checked = true;
		el3.checked = true;
		el4.checked = true;
		el5.checked = true;
		el6.checked = true;
		el7.checked = true;
		el8.checked = true;
	}else{
		el0.checked = false;
		el1.checked = false;
		el2.checked = false;
		el3.checked = false;
		el4.checked = false;
		el5.checked = false;
		el6.checked = false;
		el7.checked = false;
		el8.checked = false;
	}
}

function twPopupImage(img, title, auteur, obj_id) { 
	// Compatible IE5+ / NN6+ / Mozilla
  oFenetre = window.open('','Image','width=400,height=400,toolbar=no,scrollbars=yes,resizable=no');  
  oFenetre.document.write("<html><head><title>"+titre+"</title></head>"); 
  oFenetre.document.write("<script type=\"text/javascript\">function twAjustePopUp() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+40); window.focus();} else { setTimeout('twAjustePopUp()',1000) } }</"+"script>");
  oFenetre.document.write("<body onload='twAjustePopUp()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>"); 
  oFenetre.document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><tr><td valign='middle' align='center'>"); 
  oFenetre.document.write("<img src='"+img+"' border='0' alt='"+auteur+"' title='"+auteur+"'>");
  oFenetre.document.write("</td></tr></table></body></html>"); 
  oFenetre.document.close(); 
} 

function twPopupImageStat(obj_id, obj_type) { 
	// Compatible IE5+ / NN6+ / Mozilla
	 window.open("/download/openWindow.php?obj_id="+obj_id+"&obj_type="+obj_type,"Image","width=1400,height=1400,toolbar=no,scrollbars=yes,resizable=no");
}


function openWinStat(obj_id, obj_type, windowName, windowFeatures){
	//window.open(windowURL, windowName, windowFeatures);
	window.open("/download/openWindow.php?obj_id="+obj_id+"&obj_type="+obj_type,windowName,windowFeatures);
}

function twAjustePopUp() {
  // Compatible IE5+ / NN6+ / Mozilla
  if (document.images[0].complete) {
    window.resizeTo(document.images[0].width+10,document.images[0].height+40);
    window.focus();
  } else { setTimeout('twAjustePopUp()',1000) }
}

function toggleSaleLet(show){
	var sale = document.getElementById("sale");
	var let = document.getElementById("let");
	if(show == "let"){
		sale.style.display = "none";
		let.style.display = "block";
		document.getElementById("saleLink").className = "";
		document.getElementById("letLink").className = "current";
	}else{
		sale.style.display = "block";
		let.style.display = "none";
		document.getElementById("saleLink").className = "current";
		document.getElementById("letLink").className = "";
	}
	
	
}

// -->