

var number_of_areas = 8;
area = new Object(); area.length = number_of_areas - 1;

var number_of_bands = 7;
hmlr = new Object(); hmlr.length = number_of_bands - 1; 
band = new Object(); band.length = number_of_bands - 1;
remortgage = new Object(); remortgage.length = number_of_bands - 1;

var number_of_chg_bands = 5;
chg_band = new Object(); chg_band.length = number_of_chg_bands-1
house_chg = new Object(); house_chg.length = number_of_chg_bands-1
flat_chg = new Object(); flat_chg.length = number_of_chg_bands-1
remort_chg = new Object(); remort_chg.length = number_of_chg_bands-1

var high_chg_rate = 1;

chg_band[0] = 250000;
chg_band[1] = 400000;
chg_band[2] = 500000;
chg_band[3] = 750000;
chg_band[4] = 10000000;


house_chg[0] = 249;
house_chg[1] = 299;
house_chg[2] = 349;
house_chg[3] = 499;
house_chg[4] = 900;


flat_chg[0] = 249;
flat_chg[1] = 299;
flat_chg[2] = 349;
flat_chg[3] = 499;
flat_chg[4] = 900;



remort_chg[0] = 99;
remort_chg[1] = 99;
remort_chg[2] = 199;
remort_chg[3] = 349;
remort_chg[4] = 900;

area[0]='Other areas of England and Wales ,200.00,0.00';
area[1]='Havering,172.50,0.00';
area[2]='Barking & Dagenham,177.00,0.00';
area[3]='Lewisham ,150.00,0.00';
area[4]='Barnet ,288.00,0.00';
area[5]='Lambeth ,275.00,0.00';
area[6]='Southwark ,190.00,0.00';
area[7]='Islington ,200.00,0.00';



band[0]=50000; hmlr[0]=50; remortgage[0]=50;
band[1]=80000; hmlr[1]=80; remortgage[1]=50;
band[2]=100000; hmlr[2]=130; remortgage[2]=70;
band[3]=200000; hmlr[3]=200; remortgage[3]=90;
band[4]=500000; hmlr[4]=280; remortgage[4]=130;
band[5]=1000000; hmlr[5]=550; remortgage[5]=260;
band[6]=10000000; hmlr[6]=920; remortgage[6]=260;


var sdutylimit0 =125000
var sdutylimit1 = 250000;
var sdutyrate1 = 0.01;
var sdutylimit2 = 500000;
var sdutyrate2 = 0.03;
var sdutylimit3 = 1000000;
var sdutyrate3 = 0.04;
var sdutyrate4 = 0.05;

var banksrch = 4.00;
var hmlrpriority = 6.00;
var fdchargesale = 195.00;
var fdchargebuy = 195.00;
var regcopy = 12.00;
var pricelimit = 990000.00;
var vatrate = 15;

var transferfee =58.75;

//var property_type = "";

// ======== End of database inserted  ====
// Use of the script or the information within it without the written permission of the copyright holder is forbidden

image1 = new Image();
image1.src = "img/au_over.gif";

image2 = new Image();
image2.src = "img/dw_over.gif";

image3 = new Image();
image3.src = "img/np_over.gif";

image4 = new Image();
image4.src = "img/lp_over.gif";

image5 = new Image();
image5.src = "img/tp_over.gif";

var areasel = "";
var las = 0.00;
var cas = 0.00;
var hmlrrf = 0.00;
var sellprice = 0.00;
var buyprice = 0.00;
var mortgage = 0.00;
var grandsaletotal = 0.00;
var grandbuytotal = 0.00;
var grandremortgagetotal = 0.00;
var hmlrrem = 0.00;
//var property_type = 1;



function listareas(){
	//document.write('<OPTION VALUE="None" SELECTED>Select one area from list</OPTION>\n');
	for (i=0; i < number_of_areas; i+=1){
		areasel = getarea(i);
		index = i;
		document.write('<OPTION VALUE="',index,'">',areasel,'</OPTION>\n');
	}
	return null;
}

function gethmlr(price){
	var index = 0;
	if( price >= band[band.length]) {
		index= band.length ;
	}
	else{
		while (band[index] < price) {
			index+=1;
		}
	}
	hmlrrem = remortgage[index];
	return hmlr[index];
}

function nextpage(){
	var page = "Quote.cfm" ;
	//var prop_type = document.prices.property.value;
	var prop_type = document.prices.property.checked;
	sellprice = document.prices.sellprice.value;
	buyprice = document.prices.buyprice.value;
	mortgage = document.prices.mortgage.value
	if (mortgage >0 ) { page = "mortgage.cfm?mortgage=" + mortgage; }
	if (sellprice>0 ) { page = "sell.cfm?sellprice="+ sellprice + "&property_type=" + prop_type + "&buyprice=" + buyprice;}  
    if (buyprice >0 ) { page = "sell.cfm?sellprice="+ sellprice + "&property_type=" + prop_type + "&buyprice=" + buyprice;}
	//if (sellprice >= pricelimit) { page = "toohigh.htm"; }
	//if (buyprice >= pricelimit) { page = "toohigh.htm"; }
	//if (mortgage >= pricelimit) { page = "toohigh.htm"; }
	return page ;
}

function getParm(parm) {
    // returns value of parm from string
	var string = location.search.substring(1);
     var startPos = string.indexOf(parm + "=");
     if (startPos > -1) {
         startPos = startPos + parm.length + 1;
         var endPos = string.indexOf("&",startPos);
         if (endPos == -1)
             endPos = string.length;
         return unescape(string.substring(startPos,endPos));
		}
     return '';
 	}

function vat(value) {
	return Math.round(value * vatrate)/100 ; }

function pnp(value) {
	var string = (value * 1000+1)/1000 + ""
	return string.substr(0, string.indexOf(".")+3);
}

function charges(price, property_type,remortgage_flag){
	var conv_charge = 0.01 ;
	var index = 0 ;
	if (price >= chg_band[number_of_chg_bands-1]) {
		conv_charge = Math.round(high_chg_rate * price)/100 ; 
	}
	else {
		while (chg_band[index] <= price) {
			index+=1;
		}
		if (remortgage_flag == 0 ){
			if (property_type == "true"){
				conv_charge = flat_chg[index] ;
				}
			else {
				conv_charge = house_chg[index] ;
				}
			}
		else{
			conv_charge = remort_chg[index] ;
			}
	}
	return conv_charge ;
}

function showsellingcharges() {
var sellp = getParm('sellprice');
var prop_type = getParm('property_type');
fdchargesale = charges(sellp,prop_type,0);
document.writeln('<table width="58%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="25%"><a href="quote.cfm"><img src="images/purchase1.jpg" width="67" height="38" border="0"></a></td>                        <td width="25%"><a href="sale.cfm"><img src="images/saleon.jpg" width="67" height="38" border="0"></a></td>                        <td width="18%"><a href="both.cfm"><img src="images/saleandpurchase.jpg" width="67" height="38" border="0"></a></td>                        <td width="32%"><a href="remortgage.cfm"><img src="images/remortgage1.jpg" width="67" height="38" border="0"></a></td>         </tr>                    </table>');
document.writeln('<h3>Conveyancing Charges for Sale of Property Value &pound',sellp,'</h3>');
document.writeln('<table width="80%" bgcolor="f2f96d">  <tr><td class=quote><b>Our Charges</b></td></tr>');
tableline('Professional Charges',fdchargesale);
vatdue = vat(fdchargesale);
tableline('VAT at 17.5% thereon',vatdue);
tableline('<b>Total</b>', fdchargesale+vatdue );
 
  document.writeln('<tr><td class=quote colspan=3> <b>If the property is leasehold you will also need to pay the following fees</b></td><td class=quote></td></tr>');

	 tableline('Leasehold Fees ',94);

 document.writeln('<tr ><td colspan=3 class=quote align=justify><div align=justify>For Leasehold properties the landlord is likely to charge a Lessors Registration Fee. This fee is NOT included within the quote as it is at the landlords discretion and cannot be known without first contacting the landlord.</div> <br></td><td class=quote></td></tr>');
 document.writeln('<tr><td class=quote colspan=3><div align=justify>Other Disbursments may apply. These will be explained to you in the client care letter that will be posted to you</div></td><td class=quote></td></tr>');
 document.writeln('<tr><td class=quote colspan=3><div align=center><b>Instruct us now with No Obligations</b></div></td><td class=quote></td></tr>');

document.writeln('</table>');
 document.writeln('<BR>');
	 document.writeln('<BR>');
return null ;
}

function tableline(title,charge) {
	document.writeln('<tr align="right"><td class=quote>',title,':</td><td class=quote>&pound;</td><td class=quote>',pnp(charge),'</td></tr>');
}

function stampduty(price){
	var duty = 0;
	if (price > sdutylimit0) { duty = price * sdutyrate1 }
	if (price > sdutylimit1 ) { duty = price * sdutyrate2 }
	if (price > sdutylimit2 ) { duty = price * sdutyrate3 }
	return duty ;
}

function showbuyingcharges() {
var buyp = getParm('buyprice');
var prop_type = getParm('property_type');
					 document.writeln('<table width="58%" border="0" align="center" cellpadding="0" cellspacing="0"><tr> <td width="25%"><a href="quote.cfm"><img src="images/purchase1one.jpg" width="67" height="38" border="0"></a></td><td width="25%"><a href="sale.cfm"><img src="images/sale1.jpg" width="67" height="38" border="0"></a></td><td width="18%"><a href="both.cfm"><img src="images/saleandpurchase.jpg" width="67" height="38" border="0"></a></td><td width="32%"><a href="remortgage.cfm"><img src="images/remortgage1.jpg" width="67" height="38" border="0"></a></td></tr></table>');

document.writeln('<table width="80%" bgcolor="f2f96d">');
{
	 fdchargebuy = charges(buyp,prop_type,0);
	 
					 	 document.writeln('<h3>Conveyancing Charges for Purchase of Property Value &pound;',buyp,'</h3>');
	 document.writeln('<tr><td class=quote><b>Your Charges</font></td><td class=quote></td><td class=quote></td></tr>');
	 tableline('Professional Charges ',fdchargebuy);
	 vatdue = vat(fdchargebuy);
	 tableline('VAT at 17.5% thereon',vatdue);
	 tableline('Total',fdchargebuy+vatdue);
	 
	  document.writeln('<tr><td class=quote colspan=3> <b>If the property is leasehold you will also need to pay the following fees</b></td><td class=quote></td></tr>');

	 tableline('Leasehold Fees ',94);

 document.writeln('<tr ><td colspan=3 class=quote align=justify><div align=justify>For Leasehold properties the landlord is likely to charge a Lessors Registration Fee. This fee is NOT included within the quote as it is at the landlords discretion and cannot be known without first contacting the landlord.</div> <br></td><td class=quote></td></tr>');

	 document.writeln('<tr><td class=quote colspan=3><div align=justify>Other Disbursments may apply. These will be explained to you in the client care letter that will be posted to you</div></td><td class=quote></td></tr>');
 document.writeln('<tr><td class=quote colspan=3><div align=center><b>Instruct us now with No Obligations</b></div></td><td class=quote></td></tr>');


 }





	
	 document.writeln('</table>');
	
}

function showremortgagecharges() {
var buyp = getParm('mortgage');
document.writeln('<table width="80%" bgcolor="f2f96d">');
{
		 fdchargebuy = charges(buyp,false,1);
	 document.writeln('<h4>Conveyancing Charges for Remortgaging of Property Value &pound; ',buyp,'</h4>');
	 document.writeln('<table width="80%" bgcolor="#f2f96d" class=quote>  <tr><td class=quote><b>Our Charges</b></td><td class=quote></td><td class=quote></td></tr>');
	 tableline('Professional Charges',fdchargebuy);
	 vatdue = vat(fdchargebuy);
	 tableline('VAT at 17.5% thereon',vatdue);
	 tableline('Total',fdchargebuy+vatdue); 
	 document.writeln('<tr><td class=quote colspan=3> <b>If the property is leasehold you will also need to pay the following fees</b></td><td class=quote></td></tr>');

	 tableline('Leasehold Fees ',94);

 document.writeln('<tr ><td colspan=3 class=quote align=justify><div align=justify>For Leasehold properties the landlord is likely to charge a Lessors Registration Fee. This fee is NOT included within the quote as it is at the landlords discretion and cannot be known without first contacting the landlord.</div> <br></td><td class=quote></td></tr>');

		 document.writeln('<tr><td class=quote colspan=3><div align=justify>Other Disbursments may apply. These will be explained to you in the client care letter that will be posted to you</div></td><td class=quote></td></tr>');
 document.writeln('<tr><td class=quote colspan=3><div align=center><b>Instruct us now with No Obligations</b></div></td><td class=quote></td></tr>');

	 }
document.writeln('</table>');
}
