$(document).ready(function(){
	$.post('../MembershipNumbers', function(data){
		$('#membership_gauge').slider({
			orientation: "vertical",
			disabled: true,
			min: 0,
			max: 1000,
			value: data,
			range: "min"
		});
	});
	$('.terms').click(function(){
		$('#terms').dialog({
			modal: true,
			closeText: 'hide',
			width: '600px',
			show: 'blind',
			hide: 'blind',
			overflow: 'auto',
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
		return false;
		
	});
	$.post('campaigns/index', function(data){
		$('#email_form').html(data);
	});
	$('#send_email').button().click(function(){
		$('#email_form').dialog({
			modal: true,
			closeText: 'hide',
			width: '600px',
			show: 'blind',
			hide: 'blind',
			overflow: 'auto'
		});
	});
/*	$('#EmailAddForm').validate();
	$('#EmailAddForm').submit(function(){
		if($(this).valid()){
			$.ajax({
				url: '/emails/add',
				type: 'POST',
				data: $("#EmailAddForm").serialize(),
				success: function(){
					$('#email_form').dialog('close');
				}
			});
			return false;
		}
		else{
			return false;
		}
	}); */
	$('#news_feed').jCarouselLite({
		vertical: true,
		auto: 3000,
		visable: 1,
		speed: 500,
		circle: true
	});
	
	$('.take_the_pledge').html('Click here to take the pledge');
	$('.take_the_pledge').css('cursor', 'pointer');
	$('.take_the_pledge').click(function(){
		$('.pledge_form').slideToggle();
	});
	$('#PledgeIndexForm').validate();
	$('#EmployerTargetForm').validate();
	
	/* css hacks for non JS compliant sites */
	$('#news_feed').css('max-height', '300px');
	$('.pledge_form').css({
		'display': 'none'
	});
	$('#bubble').css({
		'display': 'block'
	});
	$('#membership_gauge').css({
		'display': 'block'
	});
	$('#send_email').css({
		'display': 'block'
	});
});

