/*-----------------------------------------------------------------------------
 * set_selection.js
 *-----------------------------------------------------------------------------
 * Author:   Estelle Winterflood
 * Email:    cubecart@expandingbrain.com
 * Store:    http://cubecart.expandingbrain.com
 *-----------------------------------------------------------------------------
 * This file is common to several CubeCart 4 mods:
 * - Fully Flexible Contact Forms
 * - Advanced Contact Forms
 * - possibly more to come...
 *-----------------------------------------------------------------------------
 * Date:     January 3, 2008
 *-----------------------------------------------------------------------------
 * SOFTWARE LICENSE AGREEMENT:
 * You must own a valid license for this modification to use it on your
 * CubeCart™ store. Licenses for this modification can be purchased from
 * Estelle Winterflood using the URL above. One license permits you to install
 * this modification on a single CubeCart installation only. This non-exclusive
 * license grants you certain rights to use the modification and is not an
 * agreement for sale of the modification or any portion of it. The
 * modification and accompanied documentation may not be sublicensed, sold,
 * leased, rented, lent, or given away to another person or entity. This
 * modification and accompanied documentation is the intellectual property of
 * Estelle Winterflood.
 *-----------------------------------------------------------------------------
 * DISCLAIMER:
 * The modification is provided on an "AS IS" basis, without warranty of
 * any kind, including without limitation the warranties of merchantability,
 * fitness for a particular purpose and non-infringement. The entire risk
 * as to the quality and performance of the Software is borne by you.
 * Should the modification prove defective, you and not the author assume 
 * the entire cost of any service and repair. 
 *-----------------------------------------------------------------------------
 */

function setSelection(element_name, option_value) {
    if (option_value == '')
        return;
    elems = document.getElementsByName(element_name);
    for (var i=0; elems && i<elems.length; i++) {
        el = elems[i];
        if (el && !el.length && el.value == option_value) {
            el.checked = true;
        } else if (el) {
            for (var j=0; j < el.length; j++) {
                if (el[j].value == option_value) {
                    if (el.options) el[j].selected = true;
                    else el[j].checked = true;
                }
            }
        }
    }
}


