$(function(){
	$("a[rel*=lightbox]").lightBox({
		imageLoading: "/img/lightbox/loading.gif",
		imageBtnClose: "/img/lightbox/close.gif",
		imageBtnPrev: "/img/lightbox/prev.gif",
		imageBtnNext: "/img/lightbox/next.gif",
		imageBlank: "/img/lightbox/blank.gif",
		txtImage: "",
		txtOf: "/"
	});
	$("#signup_day").change(function(){
		$.post(
			"/ajax_signup.php",
			{ "day": $("#signup_day").val() },
			function(data){
				// létszám
				if ($("#signup_number").find("option").length!=data.max_signup_number) {
					var signup_number_i = $("#signup_number").find("option").length;
					while(signup_number_i>data.max_signup_number) {
						$("#signup_number").find("option:last").remove();
						signup_number_i--;
					}
					while(signup_number_i<data.max_signup_number) {
						signup_number_i++;
						$("#signup_number").append('<option value="'+signup_number_i+'">'+signup_number_i+'</option>');
					}
				}
				// from_time
				if ($("#signup_time_from").find("option:first").val()!=data.from_time_from || $("#signup_time_from").find("option:last").val()!=data.from_time_to) {
					var from_time = $("#signup_time_from").val();
					var from_time_i_str = "";
					$("#signup_time_from").find("option").remove();
					for (var from_time_i=data.from_time_from; from_time_i<=data.from_time_to; from_time_i++) {
						from_time_i_str = (from_time_i<10 ? "0"+from_time_i : from_time_i)+":00";
						$("#signup_time_from").append('<option value="'+from_time_i+'">'+from_time_i_str+'</option>');
					}
					$("#signup_time_from").val(from_time);
				}
				// to_time
				if ($("#signup_time_to").find("option:first").val()!=data.to_time_from || $("#signup_time_to").find("option:last").val()!=data.to_time_to) {
					var to_time = $("#signup_time_to").val();
					var to_time_i_str = "";
					$("#signup_time_to").find("option").remove();
					for (var to_time_i=data.to_time_from; to_time_i<=data.to_time_to; to_time_i++) {
						to_time_i_str = (to_time_i<10 ? "0"+to_time_i : to_time_i)+":00";
						$("#signup_time_to").append('<option value="'+to_time_i+'">'+to_time_i_str+'</option>');
					}
					//$("#signup_time_to").val(to_time);
				}
				$("#signup_time_to option:last").attr("selected", "selected");
			},
			"json"
		);
	});
	//if ($("#signup_day").attr("id")) $("#signup_day").change();
/*
	var myOptions = {
    val1 : 'text1',
    val2 : 'text2'
};
$.each(myOptions, function(val, text) {
    $('#mySelect').append(
        $('<option></option>').val(val).html(text)
    );
});
*/
});

(function($) {
	$.fn.equalHeight = function(){
		var height = 0,
		reset = $.browser.msie ? "1%" : "auto";
		return this
		.css("height", reset)
		.each(function() {
			height = Math.max(height, this.offsetHeight);
		})
		.css("height", height)
		.each(function() {
			var h = this.offsetHeight;
			if (h > height) {
				$(this).css("height", height - (h - height));
			};
		});
	};
})(jQuery);

$(function(){
	$("#offers .box:nth-child(3n)").each(function() {
		$(this).prevAll(":lt(2)").andSelf().equalHeight();
	});
});
