$(document).ready(function() {



	//eshop promo
	//hlavička
	$('#eshopButton').click(function () {
		if ( $('#eshopPromo').css('display') == 'none' ) {
			$(this).effect("bounce", { direction:'down', times:5 }, 300);
			$('body').append('<div class="nOverlay"></div>');
			$('div.nOverlay').css('height', $(document).height() ).click(function (e) {
				if (e.target == this) {
					$('div.nOverlay').hide(500);
					$('#eshopPromo').hide(500);
				}
			});
			$('body').keypress(function (event) {
				if (event.which == 27) {
					$('div.nOverlay').hide(500);
					$('#eshopPromo').hide(500);
				}
			});
			$('#eshopPromo').delay(0).show(500);
		}
		else {
			$('div.nOverlay').hide(500);
			$('#eshopPromo').hide(500);
		}
	});
	//hp
	$('#eshopPromo').each(function () {
		
		if ( $(this).css('display') == 'block' ) {
			
			$('body').append('<div class="nOverlay"></div>');
			$('div.nOverlay').css('height', $(document).height() ).click(function (e) {
				if (e.target == this) {
					$('div.nOverlay').hide(500);
					$('#eshopPromo').hide(500);
				}
			});
			$('body').keypress(function (event) {
				if (event.which == 27) {
					$('div.nOverlay').hide(500);
					$('#eshopPromo').hide(500);
				}
			});
			$('#eshopPromo').delay(500).show(500);
		}
	});
	$('area.closeMe').live('click', function () {
		$('div.nOverlay').hide(500);
		$('#eshopPromo').hide(500);
		return false;
	})
	
	$(".bannerGalerie").make('bannerGalerie');

	$('form.validateMe').make('formValidate', {
		errorClass: 'alert', 
		activateClass: 'validate'
	});

	$('#contactForm-bottom').make('kontaktniForm');

	$('.tabs').make('tabsNT');
	$('.bublina').make('bublina');
	$('.lightbox').lightBox();
	// $('.lightbox').load('lightBox',function () { $('.lightbox').lightBox(); }); 
	$('.anketa').make('anketa');

	$('div.calendar').make('calendar');
	$('div.moves').make('moves');
	$('div.foot-menu').make('movesPartneri');
	$('.focusToggle').make('searchInput');
	$('textarea.elastic').elastic();
	$("#fdialog").dialog({
		modal: false,
		title: 'Nevyplněné položky',
		autoOpen: false,
		buttons: {
			Ok: function() {
				$(this).dialog('close');
			}
		}
	});

	$('div.carousel').make('carousel');

	$("#fdialog-jmeno").dialog({ 
		modal: true, 
		title: 'Nevyplněné položky', 
		autoOpen: false, 
		buttons: { 
			Ok: function() { 
				$(this).dialog('close'); 
			} 
		} 
	});

	$("#fdialog-email").dialog({ 
		modal: true, 
		title: 'Nevyplněné položky', 
		autoOpen: false, 
		buttons: { 
			Ok: function() { 
				$(this).dialog('close'); 
			} 
		} 
	});

	$("#fdialog-telefon").dialog({ 
		modal: true, 
		title: 'Nevyplněné položky', 
		autoOpen: false, 
		buttons: { 
			Ok: function() { 
				$(this).dialog('close'); 
			} 
		} 
	});

	$("#fdialog-soucet").dialog({ 
		modal: true, 
		title: 'Nevyplněné položky', 
		autoOpen: false, 
		buttons: { 
			Ok: function() { 
				$(this).dialog('close'); 
			} 
		} 
	});

	$("#fdialog-text").dialog({ 
		modal: true, 
		title: 'Nevyplněné položky', 
		autoOpen: false, 
		buttons: { 
			Ok: function() { 
				$(this).dialog('close'); 
			} 
		} 
	});
	
	$('#contactForm form').submit(function() {
		if ((($('input[name=name]', this).attr('value') == '') || ($('input[name=surname]', this).attr('value') == '') || ($('input[name=email]', this).attr('value') == '') || ($('input[name=phone]', this).attr('value') == '') || ($('input[name=capt]', this).attr('value') != 6) || ($('textarea[name=text].pov', this).val() == '')) == true) {
			$("#fdialog").dialog('open');
			return false;
		}
	});
	
	$('a[rel=blank]').attr('target', '_blank');
	
	
});
