$(document).ready(function() {
	$('a.poll-result').click(function() { this.href += '?height=405&width=600'; });
	
	$('a.show-hide-link')
		.text(getLinkText())
		.click(function() {
			$('li.additional-photo a:empty').each(function() { $(this).html('<img src="' + this.href + '?thu=1" alt="' + this.title + '" />'); });
			$('li.additional-photo').toggle();
			$(this).text(getLinkText());
			return false;
		});

	// Форма заявки на обучение
	$('#edu_speciality option').removeAttr('selected');
	$('#edu_speciality optgroup').hide();
	$('#edu_speciality optgroup.speciality_' + $('input[name=edu_level]:checked').attr('id')).show();
	$('input[name=edu_level]').click(function() {
		$('#edu_speciality option').removeAttr('selected');
		$('#edu_speciality optgroup').hide();
		$('#edu_speciality optgroup.speciality_' + this.id).show();
		$('#edu_level_text').val(
			$(this).parent().find('label').text()
		);
	});

	// Форма заявления на удаленное обучение
	$('.questionnaire .textbox:not(#birth_date, #ege_present_date, #education_date, #personal #passport_date), .questionnaire textarea').each(function() {
		inputPlaceholder(this);
	});
	$('#birth_date, #ege_present_date, #education_date, #personal #passport_date').datepicker({ changeYear: true, changeMonth: true, yearRange: '-60:+0' });
});

function closePollResults() {
	tb_remove();
	$('a.poll-result').attr('href', $('a.poll-result').attr('href').split('?')[0]);	
}

var linkTexts = ['Больше изображений', 'Меньше изображений'];
var linkTextIndex = 1;

function getLinkText() {
	linkTextIndex = (linkTextIndex + 1) % 2;
	return linkTexts[linkTextIndex];
}