/**
 * Throws an alert if any of the mandatory fields is empty.
 *
 * The param mandatory_fields contains the ids of all mandatory fields separated with space.
 *
 * @author  Ralf Kramer, Alex Koshel
 * @param   string  mandatory_fields:  a list of mandatory form fields seperated by a whitespace
 * @return  boolean
 */
function validateForm( mandatory_fields, message )
{
    field_array = mandatory_fields.split(" ");
    empty_fields = "";
    for( i = 0; i < field_array.length; i++ )
    {
        var field = document.getElementById( field_array[i] );
        if( field.value == "" )
        {
            field.style.border = '1px dotted red';
            empty_fields = empty_fields + field_array[i];
        }
        else
            field.style.border = '1px dotted green';
    }

    if( empty_fields.length > 2 )
    {
        alert( message );
        return false;
    }

    return true;
}

function isNumber( elementID, message )
{
    element = document.getElementById( elementID );

    if( element.value.match( '^[0-9]*$' ) == null )
    {
        this.isShown = true
        alert( message );

        element.style.border    = '1px dotted red';
        element.value           = '';
        element.focus();
    }
    else
    {
        if( this.isShown )
            msisdn.style.border = '1px dotted green';
    }
}

function redirect( url )
{
    window.location.href = url;
}

function confirmDelete( url, question )
{
    if( confirm( question ) )
        window.location.href = url;
}