
var _ddlQuoteType, _txtBuyingPriceForB, _txtSellingPriceForS;
var _txtBuyingPriceForBS, _txtSellingPriceForBS;

function Initialise(ddlQuoteType, txtBuyingPriceForB, txtSellingPriceForS, txtBuyingPriceForBS, txtSellingPriceForBS)
{
    _ddlQuoteType = document.getElementById(ddlQuoteType);
    _txtBuyingPriceForB = document.getElementById(txtBuyingPriceForB);
    _txtSellingPriceForS = document.getElementById(txtSellingPriceForS);
    _txtBuyingPriceForBS = document.getElementById(txtBuyingPriceForBS);
    _txtSellingPriceForBS = document.getElementById(txtSellingPriceForBS);
    SwitchQuoteControls();
}

function CheckForm()
{
    if (_ddlQuoteType.options[_ddlQuoteType.selectedIndex].value == 1)
    {
        if (isInteger(_txtBuyingPriceForB.value) == false)
        {
            alert("Please enter a numeric value for the price you are paying for this property.");
            _txtBuyingPriceForB.select();
            _txtBuyingPriceForB.focus();
            return false;
        }
    }

    if ((_ddlQuoteType.options[_ddlQuoteType.selectedIndex].value) == 2)
    {
        if (isInteger(_txtSellingPriceForS.value) == false)
        {
            alert("Please enter a numeric value for the price you are selling this property for.");
            _txtSellingPriceForS.select();
            _txtSellingPriceForS.focus();
            return false;
        }
    }

    if ((_ddlQuoteType.options[_ddlQuoteType.selectedIndex].value) == 3)
    {
        if (isInteger(_txtBuyingPriceForBS.value)== false)
        {
            alert("Please enter a numeric value for the price you are paying for this property.");
            _txtBuyingPriceForBS.select();
            _txtBuyingPriceForBS.focus();
            return false;
        }

        if (isInteger(_txtSellingPriceForBS.value) == false)
        {
            alert("Please enter a numeric value for the price you are selling this property for.");
            _txtSellingPriceForBS.select();
            _txtSellingPriceForBS.focus();
            return false;
        }
    }
    return true;
}

function SwitchQuoteControls()
{
    var b01 = document.getElementById('dphB01');
    var b02 = document.getElementById('dphB02');
    var s01 = document.getElementById('dphS01');
    var s02 = document.getElementById('dphS02');
    var bs01 = document.getElementById('dphBS01');
    var bs02 = document.getElementById('dphBS02');

    if (_ddlQuoteType.selectedIndex == 0)
    {
        b01.style.display = 'block';
        b02.style.display = 'block';
        s01.style.display = 'none';
        s02.style.display = 'none';
        bs01.style.display = 'none';
        bs02.style.display = 'none';
    }
    else if (_ddlQuoteType.selectedIndex == 1)
    {
        b01.style.display = 'none';
        b02.style.display = 'none';
        s01.style.display = 'block';
        s02.style.display = 'block';
        bs01.style.display = 'none';
        bs02.style.display = 'none';
    }
    else
    {
        b01.style.display = 'none';
        b02.style.display = 'none';
        s01.style.display = 'none';
        s02.style.display = 'none';
        bs01.style.display = 'block';
        bs02.style.display = 'block';
    }
}
