var RecaptchaOptions = {
	theme : 'blackglass',
	custom_theme_widget: 'recaptcha_widget',
	custom_translations : {
		instructions_visual : "Opište znaky z obrázku:",
		instructions_audio : "Poslouchejte:",
		play_again : "Přehrát znovu",
		cant_hear_this : "Není nic slyšet?",
		visual_challenge : "Zastavit",
		audio_challenge : "Přehrát",
		refresh_btn : "Zobrazit jiný kód",
		help_btn : "Nápověda (en)",
		incorrect_try_again : "Zkuste to znovu.",
	},
	lang: 'en'
};

$().ready(function() {
	var DocHeight = $('#document').height();
	var WinHeight = $(window).height();
	var WinWidth = $(window).width();
	var PopupHeight = (WinHeight - (WinHeight / 8));
	var PopupDefaultTop = ((WinHeight - PopupHeight) / 2);
	var Popup = '';

	function ClosePopup() {
		$('#bg').hide();
		if ($(Popup).size() == 1) {
			$(Popup).animate({'top': (PopupHeight * -1)});
		}
		Popup = '';
	}

	$('#bg').css('height', DocHeight);
	$('#elements .popup').css('height', PopupHeight);
	$('#elements .popup .inner .sub').css('height', (PopupHeight - 150));

	if (WinHeight > DocHeight) {
		$('#document, #bg').css('height', WinHeight);
	}

	$('#document .boxes .box').hover(function() {
		$(this).addClass('bh hand');
	},
	function() {
		$(this).removeClass('bh hand');
	});

	$('#abs_menu div[class^="abs_"]').hover(function() {
		$(this).addClass('hand').animate({'padding-left': 25});
	},
	function() {
		$(this).removeClass('hand').animate({'padding-left': 15});
	});

	$('#document .boxes .box[name], #abs_menu div[class^="abs_"][name]').click(function() {
		if (Popup) {
			ClosePopup();
		}

		if ($(this).attr('name')) {
			Popup = '#elements #popup_' + $(this).attr('name');
			//var scrolltop = $(window).scrollTop(); // if not fixed
			var scrolltop = 0; // if fixed

			if ($(Popup).size() == 1) {
				$('#bg').show();
				$(Popup).css('top', (PopupHeight * -1)).show();
				$(Popup).animate({'top': (scrolltop + PopupDefaultTop)});
				$(Popup).css('left', ((WinWidth - 800) / 2));
			} else {
				Popup = '';
			}
		}
	});

	$('#bg').click(function() {
		ClosePopup();
	});

	$(document).keypress(function(e) {
		if (Popup && e.keyCode == 27) {
			ClosePopup();
		}
	});

	$('#form button').attr('disabled', true);
	$('#form input, #form textarea').change(function(){
		var ok = true;
		$('#form input, #form textarea').each(function() {
			if ($(this).val() == '') {
				ok = false;
			}
		});
		if (ok) {
			$('#form button').attr('disabled', false);
		} else {
			$('#form button').attr('disabled', true);
		}
	});
});

