function setOptions(o) {
    var d = new Date(),
        i,
        m,
        monthMax,
        monthNames,
        monthSel = document.forms.selector.month,
        opt,
        yearSel = document.forms.selector.year;
    monthNames = [
        'January',
        'February',
        'March',
        'April',
        'May',
        'June',
        'July',
        'August',
        'September',
        'October',
        'November',
        'December'
    ];
    while (monthSel.length > 0) {
        monthSel.remove(0);
    }
    if (yearSel.value == d.getFullYear()) {
        opt = new Option('Select Month');
        monthSel.add(opt, null);
        monthMax = d.getMonth();
        for (i = 0; i <= monthMax; i++) {
            m = i + 1;
            opt = new Option(monthNames[i], (m < 10 ? '0' : '') + m);
            monthSel.add(opt, null);
        }
    } else if (yearSel.value.length == 0) {
        opt = new Option('Select Year');
        monthSel.add(opt, null);
    } else {
        opt = new Option('Select Month');
        monthSel.add(opt, null);
        for(i = 0; i < 12; i++) {
            m = i + 1;
            opt = new Option(monthNames[i], (m < 10 ? '0' : '') + m);
            monthSel.add(opt, null);
        }
    }
}

function enable() {
    var monthValue = document.forms.selector.month;
    if (monthValue) {
        document.forms.selector.sub.disabled = false;
    } else {
        document.forms.selector.sub.disabled = true;
    }
}

function urlGen() {
    var date = new Date();
        month = document.forms.selector.month.value,
        monthNum = parseInt(month, 10),
        year = document.forms.selector.year.value,
        yearNum = parseInt(year, 10);
    if (yearNum < 2003 || yearNum > date.getFullYear) {
        year = date.getFullYear();
    }
    if (monthNum < 1 || monthNum > 12) {
        month = '01';
    }
    window.location = '/component/story/month_' + year + month + '.html';
}

function nav(form) {
    window.location = '?option=com_story' +
        '&view=sel' +
        '&task0=location_' + form.selector.value +
        '&Itemid=137';
}

