// Date pickers
$.extend(DateInput.DEFAULT_OPTS, {
	stringToDate: function(string) {
		var matches;
		if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
			return new Date(matches[1], matches[2] - 1, matches[3]);
		} else {
			return null;
		};
	},

	dateToString: function(date) {
		var month = (date.getMonth() + 1).toString();
		var dom = date.getDate().toString();
		if (month.length == 1) month = "0" + month;
		if (dom.length == 1) dom = "0" + dom;
		return date.getFullYear() + "-" + month + "-" + dom;
	}
});
$(function(){
	$('.date_input').date_input();
});

// Gallery
$(function() {
	$('#gallery.full').jcarousel({
		scroll: 1,
		animation: 600,
		wrap: 'last',
		buttonNextHTML: "<a id='gallery_nextbtn' title='Scroll forward'>Forward &raquo;</a>",
		buttonPrevHTML: "<a id='gallery_prevbtn' title='Scroll backward'>&laquo; Backward</a>"
	});

	
	$('#gallery.full img').mouseover(function(i, e){
		var img = $(this);
		var container = $(this).parent();

		var imgsize = $(this).height();
		var containersize = $(this).parent().height();

		if (imgsize > containersize) {
			$(container).animate({
				'height': imgsize
			})
		}
	});
	
	
	$('#gallery.full img').mouseout(function(i, e){
		var container = $(this).parent();

		$(container).animate({
			'height': 480
		});
	});
});


// Prices
$(function() {
	$('#prices tbody td.service').mouseover(function(){
		$(this).addClass('hover');
	}).mouseout(function(evt){
		$(this).removeClass('hover');
	});
});
