$(document).ready(function() { 
    // Toggle the registration lists
    $(".registration_item").click( function() {
	// console.log("I got clicked.");
	$(this).children().toggle();
    });

    //Handle jquery change event for IE
    if ($.browser.msie) {
    	$("#copy_personal").click(function() {
    	    this.blur();
    	    this.focus();
    	});
    }

    // Copy personal to billing information
    $("#copy_personal").change(function() {
	//console.log("I got clicked.");
	if(this.checked) {
	    //console.log("I am checked.");
	    $("#bill_name").val($("#student_name").val());
	    $("#bill_street_1").val($("#street_1").val());
	    $("#bill_street_2").val($("#street_2").val());
	    $("#bill_city").val($("#city").val());
	    $("#bill_state").val($("#state").val());
	    $("#bill_zip").val($("#zip").val());
	} else {
	    //console.log("not any more.");
	    $("#bill_name").val("");
	    $("#bill_street_1").val("");
	    $("#bill_street_2").val("");
	    $("#bill_city").val("");
	    $("#bill_state").val("");
	    $("#bill_zip").val("");
	}
	
    });

    //Handle jquery change event for IE
    if ($.browser.msie) {
    	$("#send_invoice").click(function() {
    	    this.blur();
    	    this.focus();
    	});
    }

    // Copy personal to billing information
    $("#send_invoice").change(function() {
	//console.log("I got clicked.");
	if(this.checked) {
	    //console.log("I am checked.");
	    $('#bill_card_type').attr('disabled', 'true');
	    $('#exp').attr('disabled', 'true');
	    $('#card').attr('disabled', 'true');
	    $('#cvv2').attr('disabled', 'true');
	    $('#charge-bill').attr('disabled', 'true');
	    $('#invoice-bill').removeAttr('disabled', 'true');
	   
	} else {
	    //console.log("not any more.");
	    $('#bill_card_type').removeAttr('disabled', 'true');
	    $('#exp').removeAttr('disabled', 'true');
	    $('#card').removeAttr('disabled', 'true');
	    $('#cvv2').removeAttr('disabled', 'true');
	    $('#charge-bill').removeAttr('disabled', 'true');
	    $('#invoice-bill').attr('disabled', 'true');
	}
	
    });


// Validate IP Forms with jQuery Validate plugin.
    $("#class_registration_form").validate();
    $("#register-bill").validate();
    

});
