function checkPage1()
{
    var returnVal = 1;

    returnVal &= CheckDropDown("type");
    returnVal &= CheckDropDown("interest");

    return !!returnVal;
}

function checkPage2()
{
    var returnVal = 1;

    returnVal &= CheckDropDown("capacity");
    returnVal &= CheckRadio("height", 5);
    returnVal &= CheckRadio("engine", 6);
    returnVal &= CheckRadio("inoutdoor", 3);
    returnVal &= CheckText("name");
    returnVal &= CheckText("company");
    returnVal &= CheckText("city");
    returnVal &= CheckDropDown("state");
    returnVal &= CheckText("zip");
    returnVal &= CheckPhone();
    returnVal &= CheckText("email");


    if (returnVal == 0)
    {
        $("#errorNotify")[0].style.visibility = "visible";
        $("#errorNotify")[0].style.display = "inline";
    }

    return !!returnVal;
}

function CheckDropDown(id)
{
    if ($("#" + id)[0] == undefined)
    {
        return 1;
    }

    if ($("#" + id)[0].selectedIndex == 0)
    {
        $("#" + id + "Error")[0].style.visibility = "visible";
        $("#" + id + "Error")[0].style.display = "inline";
        return 0;
    }
    else
    {
        $("#" + id + "Error")[0].style.visibility = "hidden";
        $("#" + id + "Error")[0].style.display = "none";
        return 1;
    }
}

function CheckRadio(id, num)
{
    var selected = 0;
    for (var i = 1; i <= num; i++)
    {
        var elemId = "#" + id + "_" + i;
        if ($(elemId)[0].checked == true)
        {
            selected = 1;
            break;
        }
    }

    if (selected == 0)
    {
        $("#" + id + "Error")[0].style.visibility = "visible";
        $("#" + id + "Error")[0].style.display = "inline";
        return 0;
    }
    else
    {
        $("#" + id + "Error")[0].style.visibility = "hidden";
        $("#" + id + "Error")[0].style.display = "none";
    }

    return selected;
}

function CheckText(id)
{
    if ($("#" + id)[0] == undefined)
    {
        return 1;
    }

    if ($("#" + id)[0].value.length == 0)
    {
        $("#" + id + "Error")[0].style.visibility = "visible";
        return 0;
    }
    else
    {
        $("#" + id + "Error")[0].style.visibility = "hidden";
        return 1;
    }
}

function CheckPhone()
{
      // Mexican Phone
    if ($("#phone2").length == 0 )
    {
        if ($("#phone")[0].value.length == 0)
        {
            $("#phoneError")[0].style.visibility = "visible";
            return 0;
        }
        else
        {
            $("#phoneError")[0].style.visibility = "hidden";
            return 1;
        }
    }
    else
    {
        if ($("#phone")[0].value.length == 0 ||
            $("#phone2")[0].value.length == 0 ||
            $("#phone3")[0].value.length == 0)
        {
            $("#phoneError")[0].style.visibility = "visible";
            return 0;
        }
        else
        {
            $("#phoneError")[0].style.visibility = "hidden";
            return 1;
        }
    }
}