var fee;
function comma(S)
{
 var l,S,X;
  while (S != "")
 {
 
 

  l = S.length-3
  

  X = S.substr(l, 3) + (X>"" ? ','+X : '')

  
  S = S.substr(0, l)

  
  
  
 }
 return X;
}



function validate_form ( )
{
    valid = true;

	    if ( document.eform.Name.value == "" )
	    {
		alert ( "Please fill in the 'Your Name' box." );
		valid = false;
	    }
	    
	    
	if ( document.eform.Add1.value == "" )
	{
	    alert ( "Please fill in the 'Address 1' box." );
	    valid = false;
	}

	if ( document.eform.County.value == "" )
	{
	    alert ( "Please fill in the 'County' box." );
	    valid = false;
	}
	if ( document.eform.Postcode.value == "" )
	{
	    alert ( "Please fill in the 'Postcode' box." );
	    valid = false;
	}
	if ( document.eform.Tel.value == "" )
	{
	    alert ( "Please fill in the 'Telephone Number' box." );
	    valid = false;
	}
	
	if ( document.eform.ivalue.value == "" )
	{
	    alert ( "Please fill in the 'Gross Value' box." );
            valid = false;
	}
    
	
	if(!valid)
	{
     	return valid;
	}
	else
	{
	calc(document.eform.ivalue.value)
	return true;
	}
     
     

   
}







function calc(value)
{

 value=value.replace(/£/,"")
  value=value.replace(/\$/,"")
 value=value.replace(/\,/g,"");
 value=value.replace(".00","")
 
 var f,name,Add1,town,county,pcode,tel;
 
 if ((value > 0) && (value <= 400000))
 {
	  fee = 0.02*value;
	  
	  if(fee<1500)
	  {
	  fee=1500;
	  }
	

 }
 else if ((value > 400000)&&(value <= 750000))
 {
 
  fee = 400000*0.02 + (0.01*value);
  

 }
 else if ((value > 750000)&&(value <= 2000000))
 {

 tmpval=value-750000;
 sub1val= 0.02*400000;
 sub2val= 0.01*350000;
 sub3val= 0.005*tmpval;
 fee = sub1val+sub2val+sub3val;
 
 }
 else if (value > 2000000)
 {
 tmpval=value-2000000;
 sub1val= 0.02*400000;
 sub2val= 0.01*350000;
 sub3val= 0.005*1250000;
 sub4val= 0.001*tmpval
 fee = sub1val+sub2val+sub3val+sub4val;
 }


  
 var f = String(fee);
 var v= String(value);
 
 f = comma(f);
 v = comma(v);
 


 name = document.eform.Name.value;
 if (!document.eform.Add2.value)
  Add = document.eform.Add1.value;
 else
  Add = document.eform.Add1.value + "<br>" + document.eform.Add2.value;

 town = document.eform.Town.value;
 county = document.eform.County.value;
 pcode = document.eform.Postcode.value;
 tel = document.eform.Tel.value;

 document.write("<html><head><title>An Estimate for " + name + "</title></head><body>");
  document.write("<img src=http://server12.sitewizard.co.uk/sites/awlaw/template/sitelogo.gif><br><br>");
  
  

  var currentTime = new Date()
  var month = currentTime.getMonth() + 1
  var day = currentTime.getDate()
  var year = currentTime.getFullYear()
  document.write("Date: " + day + "/" + month + "/" + year)


  
 document.write("<br>An estimate for " + name + ", of<br>");
 document.write(Add + "<br>" + town + "<br>");
 document.write(county + "<br>" + pcode + "<br><br>");
 document.write("Telephone Number: " + tel + "<p>");
 document.write("Gross Value of Estate \(before debts, liabilities and expenses are taken off\)<br> £" + v + "<br>");
 

 

 
 document.write("Legal Costs to be charged by this firm for work specified below*<br> £" + f.replace(/\,\./gi,".") + " + VAT<p>");
 

 document.write("Please print off a copy of this estimate and produce it to this firm when making contact or calling.<p>");
 document.write("*This figure does not show the \“Hourly Rate Charges\” added by many Solicitors as it is included in the figure we show here!");
  document.write("<br><br><b> Note: The quote remains valid for 3 months following the date hereof<br><br>");
 document.write("</b>");

  document.write("Obtaining valuations and balances of assets at date of death");
  document.write("<br><br>Obtaining details of any liabilities of the deceased at date of death");
  document.write("<br><br>Completion of Inland Revenue form IHT200 and remittance of inheritance tax payable (if any) in order to obtain the Grant of Probate");
  document.write("<br><br>Preparation of Oath for Executor(s)");
  document.write("<br><br>Preparation and submission of application for Grant of Probate");
  document.write("<br><br>Requesting funds from relevant banks and financial institutions (if applicable)");
  document.write("<br><br>Settling any liabilities of the deceased (if applicable)");
  document.write("<br><br>Preparing estate accounts");
  document.write("<br><br>Distributing the estate under the terms of the Will ");
  document.write("<br><br> ");
  document.write("<br><br>The work that is not included for the above fees is as follows:");
  document.write("<br><br> ");
  document.write("<br><br>Negotiations with The Inland Revenue");
  document.write("<br><br>Payment of Interest on taxes to government departments");
  document.write("<br><br>Post-death variations of the Will if required by a beneficiary");
  document.write("<br><br>IHT 216 if required (uplift of Nil Rate Band)");
  document.write("<br><br>In respect of probate matters there will also be certain additional expenses (called disbursements) which you have to pay such as probate fees and fees for settling and registering documents. We will obtain your approval before incurring a disbursement of the sum of £1000.00 plus VAT or more.");
  document.write("<br><br>Disbursements will include:");
  document.write("<br><br>1.         Oath Fees                                £7");
  document.write("<br><br>2.         Office Copies                           £8");
  document.write("<br><br>3.         Settling Fee                              £10");
  document.write("<br><br>4.         Court Fees (approx)                 £60");
  document.write("<br><br>5.         Valuation fees or other professional services   ");
  document.write("<br><br>The charges that we make will cover the work that we have been instructed to undertake. If instructed to undertake additional work we shall need to make additional charges. We will provide you with an estimate of what they are likely to be as we go along.");

 
 document.write("</body></html>");
}


