$().ready(function(){
	/*$('#t2 ul li').hover(function(){
		$(this).addClass('nav-mouseover');
	}, function(){
		$(this).removeClass('nav-mouseover');
	});*/
	
	//bloki z grafiką na głównej - odbladzanie onhover
	var squares = $('div.b');
	squares.prepend('<div class="shade"> </div>');

	squares.click(function(){
		document.location = $(this).find('a').attr('href');
	});

	squares.hover(function(){
		$(this).children('.shade').hide();
	}, function(){
		$(this).children('.shade').show();
	});
	
	
	//select z liczbą ludzi w forularzu zgłoszenia
	var personsSelect = $('#training_application_quantity');
	personsSelect.change(function(){
		adjustPersons($(this).val());
	});
	if(personsSelect.length) adjustPersons(personsSelect.val());
	
	function adjustPersons(no){
		var selectTableRow = personsSelect.parents('tr');
		selectTableRow.nextAll('tr:has(input[id^=training_application_person_])').remove();
		for(var i=parseInt(no); i>0; i--){
			selectTableRow.after([
			'<tr>',
			'<th>',
			'<label for="training_application_person_'+i+'">Imię i Nazwisko '+i+'</label>',
			'</th>',
			'<td>',
			'<input id="training_application_person_'+i+'" type="text" name="training_application[person_'+i+']"/>',
			'</td>',
			'</tr>'
			].join(''));
		}
	};
});