/*
 * selecttimes.js
 *
 * Desc: Implements dynamic updates of a <select> block.
 *
 * Author: Ivan Radley
 *
 * Usage:
 *      Place in between <head> </head> tags:
 *
 *          <script type="text/javascript" language="javascript" src="[PATH]/selecttimes.js"></script>
 *
 *      Place in between <body> </body> tags:
 *
 *          <select name="times" id="times"></select>
 *
 * Copyright © Webtonic 2007
 * www.webtonic.com.au
 */

function selectTimes(clinic, id) {

	if (document.getElementById) { // DOM3 = IE5, NS6
        var select = document.getElementById(id);
        removeAllOptions(select);

        if (clinic == 'clinic_city') {
            addOption(select, "1:00pm - 6:00pm Wednesdays");
            addOption(select, "2:00pm - 6:00pm Thursdays");
        } else {
            addOption(select, "10:00am - 7:00pm Tuesdays");
            addOption(select, "10:00am - 3:00pm Saturdays");
        }
    }
}

function removeAllOptions(select)
{
	while (select.options.length)
	{
		select.remove(0);
	}
}

function addOption(select, value)
{
	var optn = document.createElement("option");
    optn.text = value;
	optn.value = value;
	select.options.add(optn);
}

