var doCalc,calcFields,errMsg;
function setCalcLang(_errMsg,f1,f2,f3) {
errMsg = _errMsg;calcFields = new Array(f1,f2,f3);}
function showEl(eID){document.getElementById(eID).style.display = "block";}
function hideEl(eID){document.getElementById(eID).style.display = "none";}
function notNumeric(q){return !(parseFloat(q))}
function cgetValue(eID,arrAt,_andShow){
	if (doCalc) {
		var theValue = document.getElementById(eID).value;
		if(notNumeric(theValue)) {
			if (_andShow) alert(errMsg.replace("^^",calcFields[arrAt]));
			doCalc=false;
		}
		else {
			return theValue;
		}
	}
}
function setValue(eID,v){if(v=='NaN')v='---';document.getElementById(eID).value=v;}
function getValue(eID){return document.getElementById(eID).value;}
function mcalc(andShow){
	var m_interest, m_minterest, m_months, m_years, m_capital;
	doCalc = true;
	m_interest = cgetValue("interest",0,andShow);
	m_years = cgetValue("years",1,andShow);
	m_capital = cgetValue("capital",2,andShow);
	if (doCalc) {
		m_months = m_years * 12;
		m_minterest = m_interest / 1200;
		m_mpay = m_capital * m_minterest / ( 1 - 1/Math.pow(1+m_minterest,m_months));
		setValue("months",m_months);
		setValue("payment",parseInt(m_mpay*100)/100);
		if (andShow) showEl("calcres");
	}
}
function doSearch(){
	if (getValue("rn")!="") 
		checkReference();
	else
		document.getElementById("searchForm").submit();
}
var bigimgID="propertyDetails__photoSlide__photo";
function unhidebigimg(){showEl("slideShow");}
function showbigimg(imgel){var _big = document.getElementById(bigimgID),bigsrc=imgel.src.replace("width=90",
"width=medium"),bigalt=imgel.alt;_big.src = bigsrc;_big.alt=bigalt;}

