function calcSavings(){
	
	var theprice = calculateSavings.price.value;
    var percentage = calculateSavings.selectC.value;
	theprice = theprice.replace(",", "")
	theprice = theprice.replace("£", "")
	var aba = (theprice * percentage) / 100
	var baa = aba * .175
	var tbd = baa + aba
	calculateSavings.pay.value = "£" + aba + " (Commission)"
	calculateSavings.vat.value = "£" + baa + " (at 17.5%) "
	calculateSavings.total.value = "£" + tbd
	calculateSavings.save.value= "£" + tbd
}

function doCook(){
	
	var theCookie = getcookie("uName")
	var userName = theCookie.replace("+"," ")
	
if(getcookie("uID")){
document.write("<span class='smallerFont'>Welcome "+ userName + "</span><br>");
document.write("<span class='smallerFont'><a href='http://www.estateagents.co.uk/member/users/index.asp'><b>My Area</b></a> | <a href='http://www.estateagents.co.uk/member/users-logout.asp'><b>Signout</b></a></span>");
} else {
document.write("<span class='smallerFont'>You are not signed in<br>")
document.write("<a href='http://www.estateagents.co.uk/member/users-login.html'><b>Sign-in</b></a> | <a href='http://www.estateagents.co.uk/member/users-register.html'><b>Register</b></a> </span>")
}
}

function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}
function getcookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;
if(!getcookie(name)){
return false;
}
else{
return true;
}
}

function CalculateRepayment(){
	var loanamount= formCalc.muamount.value;
    var interest= formCalc.muinterest.value;
	var term =getmenuvalue(formCalc.muterm);
	var I= interest/12;
	var X=1/(1+I/100);
	var N= term *12;
formCalc.txtrepay.value = formatnumber(loanamount*(X-1)/(Math.pow(X,N+1)-X));
formCalc.txtinterest.value=formatnumber((loanamount-loanamount*Math.pow(X,N))*(X-1)/(Math.pow(X,N+1)-X));
}	
function getmenuvalue(obj){
 return (obj.options[obj.selectedIndex].value);
}

function CalculateDetails(price, interest){
	var loanamount= (price/100) * 90;
    var interest= interest;
	var term = 25;
	var I= interest/12;
	var X=1/(1+I/100);
	var N= term *12;
document.write("£" + formatnumber(loanamount*(X-1)/(Math.pow(X,N+1)-X)));

}	
function getmenuvalue(obj){
 return (obj.options[obj.selectedIndex].value);
}

function formatnumber(n) {
	return Math.round(n*100)/100;
}
// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

function MsgOkCancel(message) 
{ 
var fRet; 
fRet = confirm('Are you sure?'); 
alert(fRet); 
}


var newwindow;
function delURL(url)
{
	newwindow=window.open(url,'name','height=100,width=300');
	if (window.focus) {newwindow.focus()}
}

function guides(url)
{
	newwindow=window.open(url,'name','height=100,width=400');
	if (window.focus) {newwindow.focus()}
}


function calculator(url)
{
	newwindow=window.open(url,'name','height=530,width=800');
	if (window.focus) {newwindow.focus()}

}

function feedback(url)
{
	newwindow=window.open(url,'name','height=300,width=400, scrollbars=1');
	if (window.focus) {newwindow.focus()}

}
function info(url)
{
	newwindow=window.open(url,'name','height=300,width=400,scrollbars=1');
	if (window.focus) {newwindow.focus()}

}
function instruct(url)
{
	newwindow=window.open(url,'name','height=700,width=650, scrollbars=1');
	if (window.focus) {newwindow.focus()}

}
function costs(url)
{
	newwindow=window.open(url,'name','height=700,width=820, scrollbars=1');
	if (window.focus) {newwindow.focus()}

}
function addProperty(url)
{
	newwindow=window.open(url,'name','height=100,width=300');
	if (window.focus) {newwindow.focus()}

}

function stopEmailUpdates(url)
{
	newwindow=window.open(url,'name','height=150,width=300');
	if (window.focus) {newwindow.focus()}

}
function startEmailUpdates(url)
{
	newwindow=window.open(url,'name','height=150,width=300');
	if (window.focus) {newwindow.focus()}

}
function deleteSearch(url)
{
	newwindow=window.open(url,'name','height=120,width=300');
	if (window.focus) {newwindow.focus()}

}
function floorplan(url)
{
	newwindow=window.open(url,'name','height=75,width=330');
	if (window.focus) {newwindow.focus()}

}

function schoolsInfo(url)
{
	newwindow=window.open(url,'name','height=350,width=500');
	if (window.focus) {newwindow.focus()}

}

function brochure(url)
{
	newwindow=window.open(url,'name','height=75,width=330');
	if (window.focus) {newwindow.focus()}

}
function deleteProperty(url)
{
	newwindow=window.open(url,'name','height=120,width=300');
	if (window.focus) {newwindow.focus()}

}
function seeimage(url)
{
	newwindow=window.open(url,'name','height=300,width=250');
	if (window.focus) {newwindow.focus()}
}

function saveSearch(url)
{
	newwindow=window.open(url,'name','height=400,width=300');
	if (window.focus) {newwindow.focus()}
}
function emailUpdates(url)
{
	newwindow=window.open(url,'name','height=400,width=300');
	if (window.focus) {newwindow.focus()}
}

function map(url)
{
	newwindow=window.open(url,'name','height=620,width=601');
	if (window.focus) {newwindow.focus()}
}
// link style change
var cur_link;
function doLinkClass(lnk) {
  if (lnk && lnk.blur) lnk.blur();	// remove marquee
  if (!lnk || cur_link == lnk) return;
  if (cur_link) cur_link.className = "done";
  lnk.className = "on";
  cur_link = lnk;
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(lnk,id) {
  doLinkClass(lnk);
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}

function init(id,lyr) {
  var lnk = getElemRefs(id);
  swapLayers(lnk,lyr);
}

function validateDropdown() { 
if (document.AddProperty.city.selectedIndex == 0) { 
alert("Please choose a city/town, or choose the nearest town/city to the actual location."); 
document.AddProperty.city.focus(); 
return false; 
} 
} 

function validateDropdown2() { 
if (document.AddProperty.county.value >-1 && document.AddProperty.county.value<9) { 
alert("Please choose a County."); 
document.AddProperty.county.focus(); 
return false; 
} 
} 
function ShowTB(obj,id){
 txt=document.AddProperty.PropertyType.value;
 if (txt.match('0')){
  document.getElementById(id).style.visibility='visible';
  
 } else {
  document.getElementById(id).style.visibility='hidden';
 }
}

function ShowTBOn(obj,id){
  document.getElementById(id).style.visibility='visible';
}
function ShowTBOff(obj,id){
  document.getElementById(id).style.visibility='hidden';
}

var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

function isValid(parm,val) {
if (parm == ""){
	alert ("Enter a correct price") 
	return true;
	
}

for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}

function validatePrice(parm) {return isValid(parm,numb);}
function isLower(parm) {return isValid(parm,lwr);}
function isUpper(parm) {return isValid(parm,upr);}
function isAlpha(parm) {return isValid(parm,lwr+upr);}
function isAlphanum(parm) {return isValid(parm,lwr+upr+numb);} 

function showText(){
var oDiv=document.getElementById('previewDiv');
var sUserInput=document.getElementById('userText').value;
var reNewLines=/[\n\r]/g;
oDiv.innerHTML=sUserInput.replace(reNewLines, "<br />");
}

function numRows()
{
var therows=0
var thetext = document.AddProperty.details.value 
var str = thetext.replace(/\n/g,"<br/>\n");

document.AddProperty.details.value = str

return false;
} 


function numRowsEmail()
{
var therows=0
var thetext = document.sendemail.textarea.value 
var str = thetext.replace(/\n/g,"<br/>\n");
document.sendemail.textarea.value = str

return false;
} 

function numRowsEmailR()
{
	
}

function numRowsReview()
{
var therows=0
var thetext = document.review.review.value 
var str = thetext.replace(/\n/g,"<br/>\n");

document.review.review.value = str
//alert (str)
return false;
} 


function htmlize(str){
        str = str.replace(/\&/g,"&amp;");
        str = str.replace(/\</g,"&lt;");
        str = str.replace(/\>/g,"&gt;");
        str = str.replace(/\"/g,"&quot;");
        str = str.replace(/\n/g,"<br/>\n");
        return str;
}

<!-- Begin rotator
var slideimages=new Array()
var slidelinks=new Array()
function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
slideimages[i]=new Image()
slideimages[i].src=slideshowimages.arguments[i]
}
}

function slideshowlinks(){
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks[i]=slideshowlinks.arguments[i]
}

function gotoshow(){
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}

function showImg(url)
{
	newwindow=window.open(url,'name','height=350,width=623');
	if (window.focus) {newwindow.focus()}

}

function showImg_(url)
{
	newwindow=window.open(url,'name','height=440,width=500');
	if (window.focus) {newwindow.focus()}

}

function cConv(url)
{
	newwindow=window.open(url,'name','height=210,width=295');
	if (window.focus) {newwindow.focus()}

}
//-->
