// *****************************************************************************
// *  Filename:  w_validate_public_use_file.js
// *  Purpose :  This file contains validations for the Public Data File Screen
// *  Author :   Ashok Guntu 
// *  CM Info :  $Header: 
// *             $Log: w_validate_public_use_file.js,v $
// *             Revision 1.2  2003/09/19 21:00:16  wrighte
// *             Operations SCR 293 - The java script file could not find the utility.  Added a 'js/' to the path name for the file.
// *
// *             Revision 1.1.1.1  2003/05/05 20:15:43  guntua
// *             OPS SCR 228, New Files created for info web
// *
// *            
// *
//******************************************************************************

var  urlpath = window.location.protocol + "//" + window.location.host + "/";
document.write("<script language='JavaScript' src='"+ urlpath + "js/w_form_util.js'></script>")

//------------------------------------------------------------
// This function validates the Post Data Bank Correspondence 
// screen.
// Returns : TRUE - valid
//           FALSE - invalid with error messages.
//----------------------------------------------------------------
function validatePublicUseFile(form)
{
    statu = true;
    err_msg = "";
    len = 500;
    var format_checked = false;

    if (form.format.length)
    {
        for (i = 0; i < form.format.length; i++)
        {
            if (form.format[i].checked)
            {
                format_checked = true;
                 break;
            }
        }
    }
    else
    {
        if(form.format.checked)
        {
            format_checked = true;
        } 
    }

    


    if (isEmptyStr (form.name))
    {
        setError("Must enter a name.");
    }

    if (isEmptyStr (form.city))
    {
        setError("Must enter a city.");
    }

    if (isEmptyStr (form.state))
    {
        setError("Must select a state.");
    }

    if (isEmptyStr (form.email))
    {
        setError("Must enter a valid email.");
    }

    if (!format_checked)
    {
        setError("Must select a download format.");
    }

   
    alertMsg();
    return statu;
}


// ----------------------------------------------
// This function populates the alert message.
// Returns : TRUE - valid
//           FALSE - invalid with error messages.
// ----------------------------------------------
function alertMsg()
{
    if (statu == false)
    {
	    alert(err_msg);
    }
}


