function checkMixed()
{
	var repaymentType = document.getElementById("repaymentType").value;
	//determines if fields for capturing a mixed repayment are needed		
	var mixedFields1 = document.getElementById("mixed-fields-1");
	var mixedFields2 = document.getElementById("mixed-fields-2");
	var mixedFields3 = document.getElementById("mixed-fields-3");
	if(repaymentType == 2)
	{		
		mixedFields1.style.display = "block";
		mixedFields2.style.display = "block";
		if (mixedFields3 != null)
		{
			mixedFields3.style.display = "block";
		}
		document.getElementById("repaymentAmount").value = "";
		document.getElementById("interestAmount").value = "";
	}
	else
	{
		mixedFields1.style.display = "none";
		mixedFields2.style.display = "none";
		if (mixedFields3 != null)
		{
			mixedFields3.style.display = "none";
		}
	}
}
function hideBlock(){
document.write('<sty'+  'le> #mixed-fields-1 , #mixed-fields-2 , #mixed-fields-3 {display:none;}</st'+ 'yle>');
}
//ph added
function showHideLendingCap()
{
	var selectedProduct = document.getElementById("selectedProduct").value;
	var selectedReason = document.getElementById("reason").value;
	var profProductsList = document.getElementById("profProducts").value;
	var lendingCap = document.getElementById("lendingCapDiv");
	
	//if the selected product is in the list of professional products, and the Reason is a remortgage, then show the lendingCap message
	if(isNumberInList(selectedProduct, "profProducts") && selectedReason == "3")
	{
		lendingCap.style.display = "";
	}
	else
	{
		lendingCap.style.display = "none";
	}
}

// nicola graham added
function showHideProfRmorLendingCap()
{
	var selectedReason = document.getElementById("reason").value;
	var selectedProductType = document.getElementById("productType").value;	
	var profRmorLendingCap = document.getElementById("profRmorLendingCapDiv");
	
	// get the values of the purchase price and loan amount, stripping
	// out the commas
	var purchasePrice = document.getElementById("propertyValue").value;
	var purchasePriceNumber = purchasePrice.replace(/,/, "");	
	var loanAmount = document.getElementById("howMuchLikeToBorrow").value;
	var loanAmountNumber = loanAmount.replace(/,/, "");
	
	// now calc the ltv
	var ltv = (loanAmountNumber/purchasePriceNumber) * 100;
	
	// if the user selected 'remortgage' and 'professional' and the ltv is 
	// greater than 75% and less than or equall to 100, show the lendingCap message
	
	if (isNaN(ltv))
	{
		profRmorLendingCap.style.display = "none";
	}
	else
	{
		if(ltv > 75 && ltv <= 100
			&& selectedReason == "3" && selectedProductType == "3")
		{
			profRmorLendingCap.style.display = "";
		}
		else
		{
			profRmorLendingCap.style.display = "none";
		}
	}
}


//this function checks to see if a item is one of the options in a list.
function isNumberInList(tmpItem, tmpList)
{
	var tmpField = eval(document.getElementById(tmpList));
	var strReturn = false;

	for(i=0; i<tmpField.options.length; i++)
	{
		if(tmpField.options[i].value == tmpItem)
		{
			strReturn = true;
		}
	}

	return strReturn;
}
