function initData(context) {
	$('input.focusToggle, textarea.focusToggle, .textToggle').make('searchInput');
	$('a.printMe').make('myPrint');
	$('a.sendMe').make('sendMe');
	$('.sendMeForm').make('sendMeForm');
	$('div.rychlaNavigace').make('rychlaNavigace');
	$('#mainMenu li.unfold.hasChildren').make('submenu');
	$('.suggestForm').make('suggest', {url: langURL+'ajax/suggest/', form: true});
	$('div.carousel').make('carousel');
	$('.formUI').make('formUI');
	$('.pollVote').make('poll');
};

$(document).ready(function() {
	//lang nastavení
	langURL = "/"+lang.lang_url;

	//initialize modules
	initData();
	
	$('form.niceForm').each(function () {
		$('div.formUIContent', this).append('<div class="formUIError formUIError-token">'+ lang.web_CaptchaGenericError +'</div>')
		
		$(this).append('<input type="hidden" name="ups" value="0" />');
		
		$(this).keypress(function (e) {
			closure = $(e.target).closest('form');
			$('input[name=ups]', closure).val( Number($('input[name=ups]', closure).val()) + 1 )
			if ( $(e.target).is('input, select') && e.which == 13 ) {
				e.returnValue = false;
				e.cancel = true;
				e.stopPropagation();
				e.stopImmediatePropagation();
				e.preventDefault();
				//console.log('enter pressed');
				return false;
			}
		});
	});
	
	//vyjíždění topStripe menu
	$('#topStripe div.menu li').hover(function () {
		$(this).animate({'line-height': '40px', 'height': '40px'}, {'duration': 200, 'queue': false});
	}, function () {
		$(this).animate({'line-height': '40px', 'height': '34px'}, {'duration': 200, 'queue': false});
	});

	//dictionary
	$('div.dictionarySideLetters a').click(function () {
		this.xcontext = $(this).closest('div.webSideDictionary');
		$(this.xcontext).find('div.content').empty();
		$(this.xcontext).find('a').removeClass('active');
		$(this).addClass('active');
		$(this.xcontext).append('<div class="loadingAjax center"><img src="/images/loading.gif" alt="" /></div>');
		$.ajax({
			type: 'POST', 
			url: langURL +'ajax/dictionary/', 
			data: {letter: $(this).attr('rel') },
			dataType: 'html', 
			context: this,
			success: function (data) {
				$(this.xcontext).find('div.loadingAjax').remove();
				$(this.xcontext).find('div.content').append(data);
			}
		});
		return false;
	});
	$('div.webSideDictionary dt').live('hover',
		function () {
			$(this).closest('dl').find('dd').hide();
			$(this).next('dd').show();
		}
	);

	//zobrazit znaky hesla
	$('input.showPasswordInput').showPassword('input.showPassword');

	//link to open in new window
	$('a[rel=external]').attr('target', '_blank');

	//go back
	$('a.takeMeBack, a.goBack').click(function () {
		window.history.go(-1);
	});

	//newsletter
	$('form.newsletterAjax').submit( function() {
		$(this).append('<div class="loading"></div>');
		$.ajax({
			url: langURL + "ajax/newsletter/",
			type: "POST", 
			data: {email: $('input[name=email]', this).val()},
			dataType: 'html',
			success: myScope(function(data) {
				$('input[name=email]', this).attr('value', '');
				$('div.message, div.loading', this).remove();
				$(this).prepend('<div class="message">'+data+'</div>');
				$('.message', this).click(function(){$(this).fadeOut(200);});
			}, this)
		});
		return false;
	});

	//gallery
	$('a[rel=gallery]').fancybox({
		'mouse-wheel': false,
		'swing': false,
		'titleShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'showNavArrows'	: false,
		'speedIn':400, 
		'speedOut':200 
	});

	//gallery group
	$('a[rel=galleryGroup]').fancybox({
		'mouse-wheel': true,
		'swing': true,
		'transitionIn':'elastic',
		'transitionOut':'elastic',
		'speedIn':400, 
		'speedOut':200, 
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) { 
			return '<span id="fancybox-title-over">'+ lang.fotogalerie_Image +' '+ (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}

	});

});

