$(document).ready(function() {
		
	$("#txt_search").DefaultValue("Hledej na webu revita.cz");
	$("#contact_name").DefaultValue("Vaše jméno a příjmení");
	$("#contact_mailtel").DefaultValue("Váš e-mail nebo telefon");
	$("#contact_message").DefaultValue("Vaše zpráva pro nás");
	$("#contact_big_name").DefaultValue("Vaše jméno a příjmení");
	$("#contact_big_mailtel").DefaultValue("Váš e-mail nebo telefon");
	$("#contact_big_message").DefaultValue("Vaše zpráva pro nás");
	
	$("#msgerror_name").DefaultValue("Vaše jméno a příjmení");
	$("#msgerror_mailtel").DefaultValue("Váš e-mail nebo telefon");
	$("#msgerror_message").DefaultValue("Zpráva pro vývojáře");
	
	$(".fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'centerOnScroll' : true
	});
	
	$(".iframe").fancybox({
		'width'				: '75%',
		'height'			: '90%',
    'autoScale'     	: false,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	300, 
		'speedOut'		:	300, 
		'type'				: 'iframe',
		'centerOnScroll' : true
	});
	
  $('#header_slideshow').cycle({
		'fx': 'fadeZoom',
		'speed': 3000,
		'random': true,
		'startingSlide': 0,
		'delay': -5000,
		'pause': true
	});
	
	$("#header_logo a").mouseenter(function(){
			$(this).stop(true, true).animate({opacity: 1}, 200, function() {})
		});
	$("#header_logo a").mouseleave(function(){
		$(this).stop(true, true).animate({opacity: 0}, 200, function() {})
	});
	
	$("#header_slideshow .slide a").mouseenter(function(){
			$(this).animate({opacity: 0.7}, 400, function() {})
		});
	$("#header_slideshow .slide a").mouseleave(function(){
		$(this).animate({opacity: 1}, 200, function() {})
	});
	
	$('#content_main .hiding_box').css({height: '30px'});
	$('#content_main .hiding_box').click(function() {
		if($(this).css('height')=='30px')
		{
			$('#content_main .hiding_box').css({height: '30px'});
			$('#content_main .hiding_box').attr('id', '');
			$("h2", this).attr('id', 'unhide_h2');
			$(this).css({height: 'auto'});
			var daveheight = $(this).css('height');
			$(this).css({height: '30px'});
			$(this).animate({height: daveheight}, 500);
			$(this).attr('id', 'unhide');
			var offset = $("#unhide").offset();
			$('html,body').animate({scrollTop: offset.top}, 500);
		}
	});
	
	$('#btn_cechy').click(function() {
		if($('.box_cechy').css('height')=='30px')
		{
			$('#content_main .hiding_box').css({height: '30px'});
			$('#content_main .hiding_box').attr('id', '');
			$("h2", this).attr('id', 'unhide_h2');
			$('.box_cechy').css({height: 'auto'});
			var daveheight = $('.box_cechy').css('height');
			$('.box_cechy').css({height: '30px'});
			$('.box_cechy').animate({height: daveheight}, 500);
			$('.box_cechy').attr('id', 'unhide');
			var offset = $("#unhide").offset();
			$('html,body').animate({scrollTop: offset.top}, 500);
		}
	});
	
	$('#btn_morava').click(function() {
		if($('.box_morava').css('height')=='30px')
		{
			$('#content_main .hiding_box').css({height: '30px'});
			$('#content_main .hiding_box').attr('id', '');
			$("h2", this).attr('id', 'unhide_h2');
			$('.box_morava').css({height: 'auto'});
			var daveheight = $('.box_morava').css('height');
			$('.box_morava').css({height: '30px'});
			$('.box_morava').animate({height: daveheight}, 500);
			$('.box_morava').attr('id', 'unhide');
			var offset = $("#unhide").offset();
			$('html,body').animate({scrollTop: offset.top}, 500);
		}
	});
		
	$color = '#c5120d';
	$speed = 500;
	$bitch_news = false;
	$again_news = false;
	$('.new').cycle({ 
		fx:  'fade',
		speed:   1500, 
		timeout: 5000,
		delay: -1000,
		//sync: 0,
		pause:   1,
		before: function(curr,next,opts){
			$('.new_button').stop(true,true).animate({backgroundColor: '#afafaf'}, $speed, function() {});
			if($again_news==false)
			{
				if(opts.currSlide==0&&$bitch_news==false){$('#new_'+parseInt(opts.currSlide+1)).animate({backgroundColor: $color}, $speed, function() {}); $bitch_news = true;}
				else if(opts.currSlide==0&&$bitch_news==true){$('#new_'+parseInt(opts.currSlide+2)).animate({backgroundColor: $color}, $speed, function() {}); $bitch_news = true;}
				else{$('#new_'+parseInt(opts.currSlide+2)).animate({backgroundColor: $color}, $speed, function() {}); $bitch_news = false; $again_news = true;}
			}
			else
			{
				if(opts.currSlide==2){$('#new_'+parseInt(opts.currSlide-1)).animate({backgroundColor: $color}, $speed, function() {});}
				else if(opts.currSlide==0&&$bitch_news==true){$('#new_'+parseInt(opts.currSlide+2)).animate({backgroundcolor: $color}, $speed, function() {});}
				else{$('#new_'+parseInt(opts.currSlide+2)).animate({backgroundColor: $color}, $speed, function() {});}
			}
		}});
	
});
