$(document).ready(function(){
	$('#text a.fancy').fancybox({
		'transitionIn'   : 'fade',
		'transitionOut'  : 'fade',
		'titlePosition'  : 'over',
		'padding'        : '0',
		'width'          : '410',
		'height'         : '291',
		'overlayShow'    : false,
		'onStart'        : function(){
			$('#left-ref-inner').fadeOut('fast');
		},
		'onClosed'       : function(){
			$('#left-ref-inner').fadeIn('normal');
		}
	});

	$('#header-flash-1').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/napsali-o-nas.swf'}).find('span').hide();
	$('#header-flash-2').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reference.swf'}).find('span').hide();
	$('#header-flash-3').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/kontakt.swf'}).find('span').hide();

	if ($('#body').hasClass('en')) {
		$('#header-flash-0').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/homepage-en.swf'}).find('span').hide();
		$('#header-flash-0-1').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/graficke-studio-dtp-en.swf'}).find('span').hide();
		$('#header-flash-0-2').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/marketing-komunikace-en.swf'}).find('span').hide();
		$('#header-flash-0-3').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reklamni-predmety-en.swf'}).find('span').hide();
		$('#header-flash-0-4').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/prezentacni-systemy-en.swf'}).find('span').hide();
		$('#header-flash-0-5').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/ofsetovy-malonakladovy-tisk-en.swf'}).find('span').hide();
		$('#header-flash-0-6').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/signmaking-velkoplosny-tisk-en.swf'}).find('span').hide();
		$('#header-flash-0-7').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/webdesign-multimedia-en.swf'}).find('span').hide();
		$('#header-flash-0-8').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/veletrhy-eventy-en.swf'}).find('span').hide();
		$('#header-flash-0-9').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reklamni-pc-mysi-usb-en.swf'}).find('span').hide();
	}
	else if ($('#body').hasClass('pl')) {
		$('#header-flash-0').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/homepage-pl.swf'}).find('span').hide();
		$('#header-flash-0-1').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/graficke-studio-dtp-pl.swf'}).find('span').hide();
		$('#header-flash-0-2').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/marketing-komunikace-pl.swf'}).find('span').hide();
		$('#header-flash-0-3').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reklamni-predmety-pl.swf'}).find('span').hide();
		$('#header-flash-0-4').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/prezentacni-systemy-pl.swf'}).find('span').hide();
		$('#header-flash-0-5').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/ofsetovy-malonakladovy-tisk-pl.swf'}).find('span').hide();
		$('#header-flash-0-6').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/signmaking-velkoplosny-tisk-pl.swf'}).find('span').hide();
		$('#header-flash-0-7').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/webdesign-multimedia-pl.swf'}).find('span').hide();
		$('#header-flash-0-8').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/veletrhy-eventy-pl.swf'}).find('span').hide();
		$('#header-flash-0-9').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reklamni-pc-mysi-usb-pl.swf'}).find('span').hide();
	}
	else {
		$('#header-flash-0').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/homepage.swf'}).find('span').hide();
		$('#header-flash-0-1').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/graficke-studio-dtp.swf'}).find('span').hide();
		$('#header-flash-0-2').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/marketing-komunikace.swf'}).find('span').hide();
		$('#header-flash-0-3').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reklamni-predmety.swf'}).find('span').hide();
		$('#header-flash-0-4').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/prezentacni-systemy.swf'}).find('span').hide();
		$('#header-flash-0-5').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/ofsetovy-malonakladovy-tisk.swf'}).find('span').hide();
		$('#header-flash-0-6').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/signmaking-velkoplosny-tisk.swf'}).find('span').hide();
		$('#header-flash-0-7').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/webdesign-multimedia.swf'}).find('span').hide();
		$('#header-flash-0-8').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/veletrhy-eventy.swf'}).find('span').hide();
		$('#header-flash-0-9').flash({width: '100%', height: '100%', bgcolor: '#000000', src: '/img/flash/reklamni-pc-mysi-usb.swf'}).find('span').hide();
	}
	
	$('#text .module').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
	
	$('#aboutus tr').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
	
	$('#text ul li').wrapInner('<span />');
	
	$('#left-ref div.study a').click(function(){
		if ($(this).hasClass('opened'))
			$(this).text('více informací »').removeClass('opened').next('div.study-info').animate({
				opacity: '0',
				height: 'toggle'
			}, 'normal');
		else
			$(this).text('« méně informací').addClass('opened').next('div.study-info').css('opacity', '0').slideDown(1).animate({
				opacity: '1'
			}, 'normal');
	});
	
	$('#footer-icons-inside').hover(function(){
		$(this).stop().animate({left: '0px'}, 500);
	}, function(){
		$(this).stop().animate({left: '-483px'}, 500);
	});
	
	if (!$('#contact-form-inner').hasClass('active'))
		$('#contact-form-inner').stop().animate({height: 'toggle'}, 1);
	$('#contact-form-handle').click(function(){
		$('#contact-form-inner').stop().animate({height: 'toggle'});
// 		if ($(this).hasClass('opened'))
// 			$(this).text('více informací »').removeClass('opened').next('div.study-info').animate({
// 				opacity: '0',
// 				height: 'toggle'
// 			}, 'normal');
// 		else
// 			$(this).text('« méně informací').addClass('opened').next('div.study-info').css('opacity', '0').slideDown(1).animate({
// 				opacity: '1'
// 			}, 'normal');
 		return false;
	});
	
	$('#send').hover(function(){
		$(this).css('backgroundPosition', '0 -10px').css('cursor', 'pointer').css('cursor', 'hand');
	}, function(){
		$(this).css('backgroundPosition', '0 0').css('cursor', 'auto');
	});
	
	/////////////////////////////////////////////////////////////////////////////
	// facebox
	/////////////////////////////////////////////////////////////////////////////
	
	// $('a[rel*=facebox]').facebox();
	
	/////////////////////////////////////////////////////////////////////////////
	// kontaktní formulář 2
	/////////////////////////////////////////////////////////////////////////////
	
	var wrap = $('#wrap-contact-form');
	var bttn = $('#button-contact-form');
	bttn.click(function()
	{
		// zobraz
		if (wrap.css('right') == '-300px')
		{
			wrap.animate({
				opacity: 0.9,
				right: '-32px'
			},800);
		}
		// skryj
		else
		{
			wrap.animate({
				opacity: 1,
				right: '-300px'
			},800);
		}
	});
	
	/////////////////////////////////////////////////////////////////////////////
	// NIVO SLIDER
	/////////////////////////////////////////////////////////////////////////////
	
	$('#wrap-nivo-slider').nivoSlider({
		'effect': 'fade',
      'directionNav': false,
      'directionNavHide': true,
      'controlNav': false,
      'animSpeed': '0',
		'pauseTime': '10000',
		'prevText': '',
      'nextText': ''
	});
	 
});

////////////////////////////////////////////////////////////////////////////////
// kontrola kontaktního formuláře 2
////////////////////////////////////////////////////////////////////////////////

function check_form()
{
	var res = true;
	var name = $('#jmeno');
	var mail = $('#email');
	var msg = $('#vzkaz');
	
	// kontrola vstupního pole
	function empty(id)
	{
		var res = false;
		if (id.val() == '') res = true;
		return res;
	}
	
	// kontrola e-mailové adresy
	function check_email(email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   return reg.test(email);
	}
	
	// výchozí rámeček
	name.css('border','1px solid #aaa');
	mail.css('border','1px solid #aaa');
	msg.css('border','1px solid #aaa');
		
	// chybový rámeček
	if (empty(name))
	{
		name.css('border','1px solid red');
		res = false;
	}
	
	if (check_email(mail.val()) == false)
	{
		mail.css('border','1px solid red');
		res = false;
	}
	
	if (empty(msg))
	{
		msg.css('border','1px solid red');
		res = false;
	}
	
	return res;
}

