/*
 * This is a set of functions to allow the movement and manipulation of options
 * in a javascript select object.
 *
 * Copyright (C) 2003 by John Glorioso, Zitego Solutions, LLC
 * <jglorioso@zitego.com>. All rights reserved.
 *
 * Redistribution and use in source forms, with or without modification, are
 * permitted provided that the following condition is met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * @author John Glorioso
 * @version $Id: string_validation_funcs.js,v 1.1 2006/09/27 04:09:31 jglorioso Exp $
 */

function isNull(val)
{
    return ( val == null || val == void(0) );
}

function isNotNull(val)
{
    return !isNull(val);
}

function isEmpty(val)
{
    return (isNull(val) || val == "");
}

function isLongerThen(val, len)
{
    return (isNotNull(val) && val.length > len);
}

function isNotEmpty(val)
{
    return !isEmpty(val);
}

function isNumericNotNull(val)
{
    return isNumeric(val);
}

function isNumericOrNull(val)
{
    return ( isNull(val) || isNumeric(val) );
}

function isNotNumeric(val)
{
    return isNaN(val);
}

function matches(val, re)
{
    return ( isNotNull(val) && isNotNull(re) && val.match(re) != null );
}

function doesNotMatch(val, re)
{
    return !matches(val, re);
}

function isNumeric(val)
{
    return !isNaN(val);
}