/* ----------------------------------------------------
 * onload.js
 * Copyright (c) 2010 WisdomGroup. All Rights Reserved.
 * ---------------------------------------------------- */

jQuery.fn.extend({
	
	labelSelect:function() {
		this.click(function (){
			$(this).parent().children("label").addClass("inactive").removeClass("active");
			$(this).removeClass("inactive").addClass("active");
		});
	},
	
	setRecuringAmount:function() {
		this.bind("change keyup", function (){$("input[name=a3]").val(this.value);});
	},
	
	customAmount:function() {
		this.click(function (){
			$(this).parent().children("label, input[type=radio]").remove();
			$("#s_other").removeAttr("disabled").show().focus().before("<span class='dollar'>$</span>");
		});		
	}
	
});

$(function() {
	
	// Add proper active or inactive classes upon label clicks
	$("#d_amount label, #d_type label").labelSelect();
	
	// Mirror the recuring amount variable based on the one-time amount variable
	$("#d_amount input[name=amount]").setRecuringAmount();
	
	// Show text box to enable entry of custom donation level
	$("#d_amount label[for=s_other]").customAmount();
	
	// For IE6
	$("input[type=radio]").addClass("radio-button");
	$("input[type=text]").addClass("text-input");
	$("input[type=image]").addClass("image-input");
	
});