function isBlank(s)
{
    if (s.length == 0)
        return true;
        
    for(i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (c != ' ') return false;
    }
    return true;
}

function isInteger(s)
{
    if (s.length == 0)
        return false;
        
    for(i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if ((c < '0') || (c > '9')) return false;
    }
    return true;
}

function isSignedInteger(s)
{
    if (s.length == 0)
        return false;
        
    var c = s.charAt(0);
    if (((c < '0') || (c > '9')) && (c != '-') && (c != '+')) return false;

    for(i = 1; i < s.length; i++)
    {
        c = s.charAt(i);
        if ((c < '0') || (c > '9')) return false;
    }
    return true;
}

function isFloatingPt(s)
{
    if (s.length == 0)
        return false;

    var dpoccurs = 0;        
    for(i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (((c < '0') || (c > '9')) && (c != '.')) return false;
        if (c == '.')
            dpoccurs++;
    }
    
    if (dpoccurs > 1)
        return false;
        
    return true;
}


function CheckValues()
{
    if ((document.CalResults.convType.value) == 1)
    {
        if (isInteger(document.CalResults.BuyingPrice.value)==false)
        {
            alert("Please enter a numeric value for the price you are paying for this property.");
            document.CalResults.BuyingPrice.select();
            document.CalResults.BuyingPrice.focus();
            return false;
        }

    }

    if ((document.CalResults.convType.value) == 2)
    {
        if (isInteger(document.CalResults.SellingPrice.value)==false)
        {
            alert("Please enter a numeric value for the price you are selling this property for.");
            document.CalResults.SellingPrice.select();
            document.CalResults.SellingPrice.focus();
            return false;
        }
    }

    if ((document.CalResults.convType.value) == 3)
    {
        if (isInteger(document.CalResults.BuyingPrice.value)==false)
        {
            alert("Please enter a numeric value for the price you are paying for this property.");
            document.CalResults.BuyingPrice.select();
            document.CalResults.BuyingPrice.focus();
            return false;
        }

        if (isInteger(document.CalResults.SellingPrice.value)==false)
        {
            alert("Please enter a numeric value for the price you are selling this property for.");
            document.CalResults.SellingPrice.select();
            document.CalResults.SellingPrice.focus();
            return false;
        }
    }

    return true;
}

function CalResults_onSubmit()
{
return CheckValues()
}


