var dinner = {
	photo : {
		slide : function(){
			var $active = $('#slideshow IMG.active');

			if ($active.length == 0)
				$active = $('#slideshow IMG:last');
		
			var $next = $active.next().length ? $active.next()
					: $('#slideshow IMG:first');
		
			$active.addClass('last-active');
		
			$next.css( {
				opacity : 0.0
			}).addClass('active').animate( {
				opacity : 1.0
			}, 1000, function() {
				$active.removeClass('active last-active');
			});
		}
	},
	
	reservation : {
		submit : function(id, customdata){
			var form, formvalues, postvalues = '';
			
			form 		= $(id);
			formvalues 	= form.serialize();
			
			if(customdata){
				postvalues = formvalues + '&' + $.param(customdata);
			}else{
				postvalues = formvalues;
			}
			
			$.post(
				form.attr('action'),
				postvalues,
				function(r){
					if(r.type == 'ok'){
						id.reset();
					}
					
					$('#msg-container').html(r.msg);
					
				}
			);
			
			return;
		}
	}
};
(function($){
	$.fn.iLabel = function(options){
		var defaults 	= {classOnActive : 'iLabelActive', classOnFocus : 'iLabelFocus'};
		var options 	= $.extend({}, defaults, options);
		
		return this.each(function(){
			var elm = $(this);
			
			if($(this).val() === ''){
				$(this).val($(this).attr('title'));
			}
			
			$(this).focus(function(){
				if($(this).val() === $(this).attr('title')){
					$(this)
						.val('')
						.addClass(options.classOnFocus);
				}
			});
			
			$(this).blur(function(){
				if($(this).val() === ''){
					$(this)
						.val($(this).attr('title'))
						.removeClass(options.classOnFocus);
				}
			});
			
			$(this).bind('change',function(){
				if($(this).val() !== $(this).attr('title')){
					$(this).addClass(options.iLabelActive);
				}
			});
			
		});
	}
})(jQuery);
