//--------------------------------------------------
// Selects correct radio button on focus of other text input
// Adds validation to the form
// requires jquery for the selectors
// $(document).ready is a jquery function for after page has loaded
$(document).ready(
function ()
{

    // change DD
    $("#amount").change(function () {
        if ($('#amount').val() == 0) {
            $(".other_amount").removeClass("hide_option");
        }
        else {
       	    $(".other_amount").addClass("hide_option");
        }
    });
        
    
    // valiation DD
    $("#add_to_cartDD").submit(function() {
      
      if ($('#amount').val() == 0) {
        if ($('#other_amountDD').val() >= 3) {           
           return true;
        }        
        $('#other_amountDD').css("border", "1px solid #F00");
        $('.overlabel').css({"font-weight" : "bold", "color" : "#F00"});
        return false;
      }      
      return true;
    });
            
    
    // hide this initially
    if ($('#amount').val() == 0) {
	$(".other_amount").removeClass("hide_option");
    }
    else {
        $(".other_amount").addClass("hide_option");
    }
    
    // show this initially
    $("#how_helps").removeClass("hide");
              
}
)
