﻿jQuery(function() {
	
    /*
    Ride of Respect Form 2011
    */

    // Check that there are enough spaces in the timeslot selected
	jQuery("#bikes").keyup(function() {
        var i = jQuery('#times option:selected').text().replace(" spaces available)", "")
        if (jQuery(this).val() > parseInt(i.substr(15, (i.length - 15)))) {
            alert('There are not enough spaces on that arrival time for that many bikes.\nPlease select another arrival time or reduce the amount of bikes.');
        }
    });

    // Calculate total cost for riders
    jQuery('#riders').keyup(function() { jQuery('#total').html( jQuery('#riders').val() * 10 ); });

});
