// pledge form javascript
$(document).ready(function(){
	// hide hidden things 
	$('.hideme').hide();
	// show shown things 
	$('.showme').show();
	// show toggle behavior
	$('.show').click(function() {
		if($(this).attr("href") != '' || $(this).attr("title") != ''){
			var showID = '';
			if($(this).attr("href") != ''){
				showID = $(this).attr("href");
			}
			if($(this).attr("title") != ''){
				showID = '#' + $(this).attr("title");
			}
			//alert("showID = " + showID);
			$(showID).show("fast");
		}else{
			$(this).next().show("fast");
		}
		//$(this).hide();
		if($(this).hasClass("hide-prev")) $(this).prev().hide();
		if($(this).is("input")){
			return true;
		}else{
			return false;	
		}
	});
	// hide toggle behavior
	$('.hide').click(function() {
		if($(this).hasClass("target")){
			var hideID = '';
			if($(this).attr("href") != ''){
				hideID = $(this).attr("href");
			}
			if($(this).attr("title") != ''){
				hideID = '#' + $(this).attr("title");
			}
			$(hideID).hide("fast");
		}else{
			$(this).next().hide("fast");
		}
	});
	// Disable review button
	$('.make-changes').click(function() {
		$('#pledgeform').show("slow");
		$('#pledgereview').hide("slow");
		return false;
	});
	// if the form is prepopulated, and bill me is checked, hide the credit card section
	if($('#payment-billme').is(':checked')){
		$('#credit-card').hide();
	}
	// Everything with a class of question, when you click on it, launches a popup window
	$('.question').click(function() {
		var newwin = window.open($(this).attr('href'), "LaunchWindow", "toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes, width=450, height=500"); 
		newwin.focus();
		return false;
	});
	// confirm that they really want to join the britcom club
	$('input.plus25').click(function(){
		var pledge = $('#PledgeAmount').val();
		var tot = parseInt(pledge) + 25;
		if ($(this).is(':checked')) {
			var msg = "This will add $25 dollars to your pledge amount";
			//if($(this).attr('id').toLowerCase() == 'britcom'){
				//msg = msg + ' for a total of $' + tot;	
			//}
			msg = msg + '.';
			if (confirm(msg)){
				$(this).attr('checked', "checked");
		}else{
			$(this).attr('checked', "");
		}
	}
	});
});