/**
 * Rock, Paper, Scissors llc.
 *
 * scripts.js
 *
 * General javascripts needed for each project
 *
 * LICENSE: This source file is subject to version 1.0 of the 
 * Rock, Paper, Scissors llc. license that is available through 
 * the world-wide-web at the following URI:
 * http://www.123shoot.com/license/1_0.txt.  If you did not receive 
 * a copy of the Rock, Paper, Scissors llc. License and are unable 
 * to obtain it through the web, please send a note to 
 * support@123shoot.com so we can mail you a copy immediately.
 *
 * @category   js
 * @author     Scott Lively <scott@123shoot.com>
 * @copyright  2010 Rock, Paper, Scissors llc.
 * @license    http://www.123shoot.com/license/1_0.txt  RPS License 1.0
 */


/**
 * function dayfill
 *
 * fills the day id dropdown select box with the correct number of days
 * depending on which month the user selected from the month dropdown select box.
 */
function dayfill(monthid, dayid, yearid)
{
    var month = document.getElementById(monthid).value;
    var day = document.getElementById(dayid).value;
    var year = document.getElementById(yearid).value;
    if (month == 2) {
        if(year%4 == 0) {
            var days = 29;
        } else {
            var days = 28;
        }
    } else if (month == 4 || month == 6 || month == 9 || month == 11) {
        var days = 30;
    } else {
        var days = 31;
    }
    
    document.getElementById(dayid).options.length=1;
    
    if(day > days) {
        day = days;
    }
    
    var i=1;
    for (i=1;i<=days;i++) {
        if(i == day) {
            document.getElementById(dayid).options[i-1] = new Option(i,i, true, true);							
        } else {
            document.getElementById(dayid).options[i-1] = new Option(i,i);							
        }
    }
}

/**
 * function toggleDivs
 *
 * this function shows/hides two Divs onClick
 *
 */
function toggleDivs(showDiv, hideDiv)
{
    document.getElementById(showDiv).style.display = '';
    document.getElementById(hideDiv).style.display = 'none';
}
