var cb_checked = false;
function toggleCheckboxes(name)
{
    if(this.cb_checked == false)
        this.cb_checked = true;
    else
        this.cb_checked = false;

    var cb = document.getElementsByName(name);

    for (var i = 0; i < cb.length; i++)
    {
        cb[i].checked = this.cb_checked;
    }

}


/**
 * Throws an alert if any of the mandatory field is empty
 *
 * The param mandatory_fields contains the id's of all mandatory fields.
 *
 * @author  Ralf Kramer
 * @param   string  mandatory_fields:  a list of mandatory form fields seperated by a whitespace
 * @return  boolean
 */
function hasEmptyFields( 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 true;
    }

    return false;
}
