/* LiveWhale Website Effects */
/* Requires jQuery */

$(function() { // on DOM ready
	$('#callout_showmore').attr('href','#').toggle(function() { // reset the link to an anchor and on click
		$('#callout').animate({width:630,marginLeft:-360}); // slide the callout out
		return false; // and cancel the anchor click
	},function() { // or
		$('#callout').animate({width:330,marginLeft:-60}); // slide the callout out
		return false; // and cancel the anchor click
	});
	$('#callout form').live('submit',function() {
		var form = $(this);
		form.css('opacity','0.5').find('input').attr('disabled');
		$.post('?',form.serialize(),function(response) {
			var results = $(response).find('#callout_more');
			if(results.find('form').length) { // if there's still a form
				results.find('p').eq(0).addClass('error');
				$('#callout_more').html(results.html()); // it's an error!		
			} else { // if success
				$('#callout_showmore').click();
				results.find('a').attr('id','callout_showmore');
				$('#callout_start').html(results.html());
			}
		});
		return false;
	});
});