// JavaScript Document Date-->25/06/2003
var leasesalesFeeUnder150000 =440.00;// Solicitors leasesalesFee between £0-150000
var leasesalesFeeOver150001 =440.00;// Solicitors leasesalesFee between £150001-250000
var leasesalesFeeOver250001 =440.00;// Solicitors leasesalesFee between £250001-350000
var leasesalesFeeOver350001 =440.00;// Solicitors leasesalesFee between £350001-450000
var leasesalesFeeOver450001 =440.00;// Solicitors leasesalesFee 450001-550000
var leasesalesFeeOver550001 ="By Negotiation";// Solicitors leasesalesFee 450001+
var vATPercent =0.175;//VAT percent
var priceIncludingVat =1.175;//percentage for cost+VAT
var leaseBuyFeeUnder150000 =440.00;// Solicitors buy fee between £0-150000 exclude vat
var leaseBuyFeeOver150001 =440.00;// Solicitors  buy fee between £150001-250000 exclude vat
var leaseBuyFeeOver250001 =440.00;// Solicitors buy fee between £250001-350000 exclude vat
var leaseBuyFeeOver350001 =440.00;// Solicitors buy between £350001-450000 exclude vat
var leaseBuyFeeOver450001 =440.00;// Solicitors leasesalesFee 450001-550000
var telegraphicTransferFee = 25.00; //exclude avt
var landSearchFee = 4.00; //exclude vat
var bankruptcyFee = 1.00; //exclude vat

function calculateVAT (fee)
{
var vatAmount = fee * vATPercent;//Calculate the amount of VAT payable
vatAmount = vatAmount.toFixed(2);//round to 2 digital longs
return vatAmount;
}

function totalAmount (fee)
{
var vat = fee * vATPercent;//Calculate the amount of VAT payable
var total = fee + vat;//round to 2 digital longs
total = total.toFixed(2);//round to 2 digital longs
return total;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function house_fees_Validator(theForm){
	var checkOK = "0123456789-.,";
	var checkStr = theForm.finaltotal.value;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++){
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length){
		allValid = false;
		break;
	}
	if (ch == "."){
		allNum += ".";
		decPoints++;
	}
	else if (ch != ",")
		allNum += ch;
	}
	if (!allValid){
		alert("Please enter only digit characters in the \"finaltotal\" field.");
		theForm.finaltotal.focus();
		return (false);
	}
	
	if (decPoints > 1){
		alert("Please enter a valid number in the \"finaltotal\" field.");
		theForm.finaltotal.focus();
		return (false);
	}
	return (true);
}

function computeVAT (fee)
{
var vatAmount = fee * 1.175;//Calculate the amount of VAT payable
vatAmount = Math.round(vatAmount*100)/100//round to 2 digital longs
return vatAmount;
}

function leaseCompute(form){   
	//setup variables
	var val1 = parseInt(form.house2.value, 10)  
	var companyFee = 0
	var stp = 0
	var landregistry = 0
	var moneytransfer = 29.38
	var landregistrysearch = 8.00  
	var bankruptcysearch = 2.00 

 
	//companyFee Function
	
	if ((val1 <= 150000) ){
		companyFee = leaseBuyFeeUnder150000;
		companyFee = computeVAT(companyFee) ;
	}     
	if ((val1 >= 150001) && (val1<=250000)) 
	{
		companyFee = leaseBuyFeeOver150001;
		companyFee = computeVAT(companyFee) ;
	}     
	if ((val1 >= 250001) && (val1<=350000)) 
	{
		companyFee = leaseBuyFeeOver250001;
		companyFee = computeVAT(companyFee) ;
	}   
	if ((val1 >= 350001) && (val1<=450000)) 
	{
		companyFee = leaseBuyFeeOver350001;
		companyFee = computeVAT(companyFee) ;
	}   
	if ((val1 >= 450001) && (val1<=550000)) 
	{
		companyFee = leaseBuyFeeOver450001;
		companyFee = computeVAT(companyFee) ;
	}  
	if ((val1 <= 550000)){  		  
		//Stamp Duty  Function
		if ((val1 < 0) || (val1 > 9999999)) {      
			alert("Surely your house isn't worth that amount!!!")   


		}   
		
		if ((val1 <= 125000)){
			stp = 0
		}     
		if ((val1 >= 125001) && (val1<=250000)) {
			stp = (form.house2.value)*0.01
		}       
		
		if ((val1 >= 250001) && (val1<=500000)) {
			stp = (((form.house2.value)*0.03))
		}    
		
		if (val1 >= 500001) {
			stp = (((form.house2.value)*0.04))
		}   
		// end of stamp duty function
		
		//Land Registry function
		if ((val1 <= 50000)){
			landregistry = 40
		}     
		if ((val1 >= 50001) && (val1<=80000)){
			landregistry = 60
		}     
		if ((val1 >= 80001) && (val1<=100000)){
			landregistry = 100
		}   
		if ((val1 >= 100000) && (val1<=200000)){
			landregistry = 150
		}   
		if ((val1 >= 200001) && (val1<=500000)){
			landregistry = 250
		}   
		if ((val1 >= 500001) && (val1<=1000000)){
			landregistry = 450
		}
		if ((val1 >= 1000001)){
			landregistry = 750
		}        
		//end of land registry function
		 form.result1.value=companyFee
		 form.finaltotal.value =Math.round(form.result1.value*100)/100;
			
		 form.result2.value=stp 
		 form.result2.value =Math.round(form.result2.value*100)/100;
	  
		 form.result3.value=landregistry 
		 form.result3.value =Math.round(form.result3.value*100)/100;
	
		 form.result4.value=moneytransfer 
		 form.result4.value =Math.round(form.result4.value*100)/100;
	 
		 form.result5.value=landregistrysearch 
		 form.result5.value =Math.round(form.result5.value*100)/100;
	 
		 form.result6.value=bankruptcysearch  
		 form.result6.value =Math.round(form.result6.value*100)/100;
		 
		 form.finaltotal.value=companyFee+stp+landregistry+moneytransfer+landregistrysearch+bankruptcysearch
		 form.finaltotal.value =Math.round(form.finaltotal.value*100)/100;
		} else {
      		//companyFee = 470.00
      		alert("Please ring us for a personalised quote")   
      } 
    }   
    //--end hiding here -->
    <!-- hide the script from old browsers --
	
	function leaseComputesale(form) 
    {   
    //setup variables
    
      var val1 = parseInt(form.house.value, 10) 
      
      var companyFee = 0
      var officecopyentries = 0

    //companyFee Function
    
      if ((val1 <= 150000) ) 
      {
      		companyFee = leasesalesFeeUnder150000;
			companyFee = computeVAT(companyFee) ;
      }     
      if ((val1 >= 150001) && (val1<=250000)) 
      {
      		companyFee = leasesalesFeeOver150001;
			companyFee = computeVAT(companyFee) ;
      }     
      if ((val1 >= 250001) && (val1<=350000)) 
      {
      		companyFee = leasesalesFeeOver250001;
			companyFee = computeVAT(companyFee) ;
      }   
      if ((val1 >= 350001) && (val1<=450000)) 
      {
      		companyFee = leasesalesFeeOver350001;
			companyFee = computeVAT(companyFee) ;
      }   
      if ((val1 >= 450001) && (val1<=550000)) 
      {
      		companyFee = leasesalesFeeOver450001;
			companyFee = computeVAT(companyFee) ;
      }   
	  if ((val1 >= 550001)) 
      {
      		//companyFee = 470.00
      		alert("Please ring us for a personalised quote")   
      }
	  
	  if (val1 <= 550000)
	  {
     
		//End of companyFee Function
		//Office copy entries function
		  officecopyentries= 12.00 
		//end of Office copy entries function
		
		 form.result1.value=companyFee
		 form.finaltotal.value =Math.round(form.result1.value*100)/100;
	
		 form.result4.value=officecopyentries 
		 form.result4.value =(Math.round(form.result4.value*100)/100);
		 
		 form.finaltotal.value=companyFee+officecopyentries
		 form.finaltotal.value =Math.round(form.finaltotal.value*100)/100;
		} else {
		   	form.result4.value = '';
		  	form.finaltotal.value = '';	
		}
    }   
    //--end hiding here -->
document.write('<h1>CALCULATE LEASEHOLD COSTS HERE</h1><p>Calculate your conveyancing and other costs of selling or buying a residential property using our specially designed calculators.</p><table border="0" cellspacing="0" cellpadding="0" align="center" width="600" class="innerTable"><tr><td><td >&nbsp;</td><td>&nbsp;</td></tr><tr><td >&nbsp;</td><td ><h1><center><font color="#000000">Leasehold Sale Costs Calculator</font></span></h1><form name=saleform onSubmit="MM_validateForm(\'house\',\'\',\'RisNum\');return document.MM_returnValue"><table border="0" cellspacing="0" cellpadding="3" align="center"><tr> <td>&nbsp;</td><td ><img src="/options/1a/images/spacer.gif" width="1" height="1"></td><td>&nbsp;</td></tr><tr><td >&nbsp;</td><td class="innerTable"  nowrap>Input your estimated property sale price and click calculate.<br><font size="1">(PLEASE DO NOT USE COMMAS</font>)<div align="center"><br>£&nbsp; <input size=10 name=house maxlength="20">&nbsp;<input onClick=leaseComputesale(this.form) type=button value=Calculate name="button"></div></td><td >&nbsp;</td></tr><tr><td>&nbsp;</td><td >&nbsp;</td><td>&nbsp;</td></tr></table><table border=0 class="innerTable"><tr><td class="calText">Mark Young & Co (including VAT)&nbsp;&nbsp;&nbsp;&nbsp;</td><td >&pound;<input type="text" name="result1" value="" onFocus="this.blur()" maxlength="20" size="10">&nbsp;&nbsp;</td></tr><tr><td class="calText">Office Copy Entries</td><td >&pound;<input type="text" name="result4" value="" onFocus="this.blur()" maxlength="20" size="10">&nbsp;&nbsp;</td></tr><tr><td class="calText"><b>Total Cost</b></td><td ><b>&pound;<input type="text" name="finaltotal" value="" onFocus="this.blur()" maxlength="20" size="10">*</b></td></tr><tr> <td class="calText">*Telegraphic Transfer fee may be applicable<br></td> <td >&pound;');
document.write(totalAmount(telegraphicTransferFee));
document.write('</td></tr></table><table width="50%" border="0" align="center" cellpadding="2" cellspacing="0"><tr><td><div align="center"><input type="reset" name="Reset" value="Reset"></div></td></tr></table></form></td><td >&nbsp;</td></tr><tr><td>&nbsp;</td><td >&nbsp;</td><td>&nbsp;</td></tr></table><br><table border="0" cellspacing="0" cellpadding="0" align="center" width="600" class="innerTable"><tr><td>&nbsp;</td><td >&nbsp;</td><td>&nbsp;</td></tr><tr><td >&nbsp;</td><td > <h1><center><span ><font color="#000000">Leasehold Purchase Costs Calculator</font></span></h1><form name=house_fees onSubmit="return house_fees_Validator(this)"><table border="0" cellspacing="0" cellpadding="3" align="center"><tr><td>&nbsp;</td><td >&nbsp;</td><td></td></tr><tr><td >&nbsp;</td><td class="innerTable"  nowrap>Input your estimated property purchase price and click calculate.<br><font size="1">(PLEASE DO NOT USE COMMAS)</font><br><div align="center"> £&nbsp;<input name=house2 maxlength="40" size="10">&nbsp;<input onClick=leaseCompute(this.form) type=button value=Calculate name="button"></div></td><td >&nbsp;</td></tr><tr><td>&nbsp;</td><td >&nbsp;</td><td>&nbsp;</td></tr></table><br><table border=0 class="innerTable"><tr> <td class="calText">Mark Young & Co (including VAT)</td><td >£ <input name=result1 size="10" maxlength="30" TYPE="text">&nbsp;&nbsp;</td></tr><tr> <td class="calText">Stamp Duty (a Government tax)</td><td >£ <input name=result2 size="10" maxlength="30">&nbsp;&nbsp;</td></tr><tr> <td class="calText">Land Registry (to register you as the new owner)</td><td >£ <input name=result3 size="10" maxlength="30">&nbsp;&nbsp;</td></tr><tr> <td class="calText">Charges (for arranging transfer of money via telegraphic transfer)&nbsp;&nbsp;&nbsp;&nbsp;</td><td >£ <input name=result4 size="10" maxlength="30">&nbsp;&nbsp;</td></tr><tr> <td class="calText">Land Registry Searches</td><td >£ <input name=result5 size="10" maxlength="30">&nbsp;&nbsp;</td></tr><tr> <td class="calText">Bankruptcy Searches (cost for each applicant)</td><td >£ <input name=result6 size="10" maxlength="30">&nbsp;&nbsp;</td></tr><tr> <td class="calText"><b>Total Cost</b></td><td ><b>£ <input  name=finaltotal size="10" maxlength="30">*</b></td></tr><tr> <td class="calText">*Local Authority Search also applicable, between &pound;100 and &pound;200</td><td >&nbsp;</td></tr></table><table width="50%" height="40" border="0" align="center" cellpadding="2" cellspacing="0"><tr><td><div align="center"><input type="reset" name="Reset" value="Reset"></div></td></tr></table></form></td><td >&nbsp;</td></tr><tr><td>&nbsp;</td><td >&nbsp;</td><td>&nbsp;</td></tr></table>');