function $c(text) {
	console.log(text);
}

Event.observe(window, 'load', function() {
	$$('.recipePDF').each(function(s) {
		Event.observe(s, 'click', showPDF);
	});
	$$('.recipePrint').each(function(s) {
		Event.observe(s, 'click', printRecipe);
	});
});

function galleryScroll(which) {
	var re = /(\d+)$/;
	var imgNum = re(which.id)[1];
	var theGallery = $('gallery-' + re($($(which).ancestors()[0]).id)[1]);//woah
	var sibs = $(which).siblings();
	var imgWidth = theGallery.getWidth() / (sibs.length + 1);
	var scrollX = 0 - (imgNum - 1) * imgWidth;
	
	//toggle nav
	sibs.each(function(item) {
		item.removeClassName('gallery_nav_disabled');
		item.addClassName('gallery_nav');
	});
	which.removeClassName('gallery_nav');
	which.addClassName('gallery_nav_disabled');
	
	//animate
	new Effect.Move(theGallery.id, {
		x: scrollX, y: 0, mode: 'absolute',
		transition: Effect.Transitions.sinoidal,
		duration: 0.5
	});
}

function showPDF(e) {
	postNumArr = /PDF_(\d+)$/.exec(Event.element(e).id);
	postNum = postNumArr[1];
	window.location.href='/make_pdf?pn=' + postNum;
}

function printRecipe(e) {
	postNumArr = /print_(\d+)$/.exec(Event.element(e).id);
	postNum = postNumArr[1];
	recipeWindow = window.open('/print-recipe/' + postNum,"recipeWindow",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=800,screenX=0,screenY=0');
	recipeWindow.focus();
}
