<!-- Beechwoods Conveyancing script -->
<!-- Version 01.00.00 -->
<!-- Date: March 2009 -->
<!-- Author: Neil -->
<!-- Copyright: Copyright 2009 Janet Systems Ltd. -->
<!-- URL: http://www.janetsystems.co.uk -->

function conveyancing() {
    
}
function CalcFees(){
    if (isNaN(document.getElementById("houseAmount").value)){
        alert("Not a number");
        return false;
    }
    document.getElementById("conveyancingInner").style.display="none";
    document.getElementById("conveyancingResultsBuy").style.display="none";
    document.getElementById("conveyancingResultsSell").style.display="none";
    document.getElementById("conveyancingFeesBuy").style.display="none";
    document.getElementById("conveyancingFeesSell").style.display="none";
    if (document.getElementById("buy").checked==true){
        Buy();
    }
    else {
        Sell();
    }
    return false;
}
function Back(){
    document.getElementById("conveyancingInner").style.display="block";
    document.getElementById("conveyancingResultsBuy").style.display="none";
    document.getElementById("conveyancingResultsSell").style.display="none";
    document.getElementById("conveyancingFeesBuy").style.display="none";
    document.getElementById("conveyancingFeesSell").style.display="none";
    return false;
}

function Buy(){
    document.getElementById("conveyancingResultsBuy").style.display="block";
    document.getElementById("conveyancingFeesBuy").style.display="block";

    var houseAmount = parseInt(document.getElementById("houseAmount").value);

    document.getElementById("headBuy").innerHTML = 'The fees of Beechwood Solicitors for purchasing a house costing &pound;' + houseAmount + ' are as follows:';
    
    //Beechwoods Fees;
    document.getElementById("Fees_Buying").innerHTML = '&pound;' + parseCurrency(Fees_Buying) + '';
    
    //Stamp Duty
    var StampDuty = 0;
    if(houseAmount<StampDuty_l1 + 1) StampDuty= houseAmount * StampDuty_v1 / 100;
    if(houseAmount>(StampDuty_l1)  && houseAmount<(StampDuty_l2 + 1)) StampDuty= houseAmount * StampDuty_v2 / 100;
    if(houseAmount>(StampDuty_l2)  && houseAmount<(StampDuty_l3 + 1)) StampDuty= houseAmount * StampDuty_v3 / 100;
    if(houseAmount>(StampDuty_l3)) StampDuty= houseAmount * StampDuty_v4 / 100;
    document.getElementById("StampDuty").innerHTML = '&pound;' + parseCurrency(StampDuty) + '';
    
    //Land Registry
    var LandRegistry = 0;
    if(houseAmount<LandRegistry_1) LandRegistry=50.00;
    if(houseAmount>LandRegistry_1  && houseAmount<(LandRegistry_2 + 1)) LandRegistry= LandRegistry_v1;
    if(houseAmount>LandRegistry_2  && houseAmount<(LandRegistry_3 + 1)) LandRegistry= LandRegistry_v2;
    if(houseAmount>LandRegistry_3  && houseAmount<(LandRegistry_4 + 1)) LandRegistry= LandRegistry_v3;
    if(houseAmount>LandRegistry_4  && houseAmount<(LandRegistry_5 + 1)) LandRegistry= LandRegistry_v4;
    if(houseAmount>LandRegistry_5  && houseAmount<(LandRegistry_6 + 1)) LandRegistry= LandRegistry_v5;
    if(houseAmount>(LandRegistry_6)) LandRegistry = LandRegistry_v6;
    document.getElementById("LandRegistry").innerHTML = '&pound;' + parseCurrency(LandRegistry) + '';
    
    //VAT
    var VAT = (Fees_Buying) * VATrate / 100;
	
	//  work out the fees buying including VAT
	var incVAT = Fees_Buying + VAT;
	
    document.getElementById("Fees_Buying").innerHTML = '&pound;' + parseCurrency(incVAT) + '';
     
    //Telegraphic Transfer
    document.getElementById("TelegraphicTransfer_Buying").innerHTML = '&pound;' + parseCurrency(TelegraphicTransfer) + '';
    
    //Bankruptcy Searches
    document.getElementById("BankruptcySearches_Buying").innerHTML = '&pound;' + parseCurrency(BankruptcySearches) + '';
    
    //Land registry New Owner
    document.getElementById("NewOwner_Buying").innerHTML = '&pound;' + parseCurrency(NewOwner) + '';
    
    //Land registry searches
    document.getElementById("LandRegistrySearches").innerHTML = '&pound;' + parseCurrency(LandRegistrySearches) + '';
    
    //TotalFees
    var TotalFees = (TelegraphicTransfer + incVAT + LandRegistry + LandRegistrySearches + StampDuty + NewOwner + BankruptcySearches)
	<!--alert(TelegraphicTransfer + " + " + incVAT + " + " + LandRegistry + " + " + LandRegistrySearches + " + " + StampDuty + " + " + NewOwner + " + " + BankruptcySearches + " = " + TotalFees)-->
    document.getElementById("TotalFees_Buying").innerHTML = '&pound;' + parseCurrency(TotalFees) + '';
}

function Sell(){
    document.getElementById("conveyancingResultsSell").style.display="block";
    document.getElementById("conveyancingFeesSell").style.display="block";
    
    var houseAmount = parseInt(document.getElementById("houseAmount").value);
    document.getElementById("headSell").innerHTML = 'The fees of Beechwood Solicitors for selling a  house costing &pound;' + houseAmount + ' are as follows:';
    
    //Beechwoods Fees;
    document.getElementById("Fees_Selling").innerHTML = '&pound;' + parseCurrency(Fees_Selling) + '';
    
    //Office Copy Entries;
    document.getElementById("OfficeCopy_Selling").innerHTML = '&pound;' + parseCurrency(OfficeCopy) + '';
    
    //NET
    var NET = Fees_Selling + OfficeCopy;
    document.getElementById("NET_Selling").innerHTML = '&pound;' + parseCurrency(NET) + '';
    
    //VAT
    var VAT = (Fees_Selling + OfficeCopy) * VATrate
    document.getElementById("VAT_Selling").innerHTML = '&pound;' + parseCurrency(VAT) + '';
    
    //Telegraphic Transfer
    //document.getElementById("TelegraphicTransfer_Selling").innerHTML = parseCurrency(TelegraphicTransfer) + 'p';
    
    //Bankruptcy Searches
    //document.getElementById("BankruptcySearches_Selling").innerHTML = parseCurrency(BankruptcySearches) + 'p';
    
    //Land registry New Owner
    //document.getElementById("NewOwner_Selling").innerHTML = parseCurrency(NewOwner) + 'p';
    
    //TotalFees
    var TotalFees = (Fees_Selling + OfficeCopy + VAT);
    document.getElementById("TotalFees_Selling").innerHTML = '&pound;' + parseCurrency(TotalFees) + '';

}
function parseCurrency(n_value) {
    // validate input
	
	num = isNaN(n_value) || n_value === '' || n_value === null ? 0.00 : n_value;
	return parseFloat(num).toFixed(2);
}
