function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
    var $next =  $active.next().length ? $active.next() : $('#slideshow DIV:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch()", 5000 );
});

var update_povinne = function(){

	if($(".neosobni:checked").size()){
		$('tr.email td span.povinne').html("*");
		$('tr.telefon td span.povinne').html("");
		$('tr.jmeno td span.povinne').html("*");
		$('tr.prijmeni td span.povinne').html("*");
		$('tr.ulice td span.povinne').html("*");
		$('tr.mesto td span.povinne').html("*");
		$('tr.psc td span.povinne').html("*");
	}	
	if($("#dodani12:checked").size()){
		$('tr.telefon td span.povinne').html("*");
	}
	if($(".osobni:checked").size()){
		$('tr.email td span.povinne').html("*");
		$('tr.telefon td span.povinne').html("");
		$('tr.jmeno td span.povinne').html("");
		$('tr.prijmeni td span.povinne').html("");
		$('tr.ulice td span.povinne').html("");
		$('tr.mesto td span.povinne').html("");
		$('tr.psc td span.povinne').html("");
	}
	
	$('label.error').html("");

} 

$('document').ready(function(){

	$('.form_adresa').validate({
		rules: {
			email: {
				required: true,
				email: true	
			},
			telefon: {
				required: {
				    depends: function(element) {
						return $(".prepravce_ppl:checked").size()
					}
                }
			},
			jmeno: {
				required: {
					depends: function(element) {
						return $(".neosobni:checked").size()
					}
				}
			},
			prijmeni: {
				required: {
					depends: function(element) {
						return $(".neosobni:checked").size()
					}
				}
			},
			ulice: {
				required: {
					depends: function(element) {
						return $(".neosobni:checked").size()
					}
				}
			},
			mesto: {
				required: {
					depends: function(element) {
						return $(".neosobni:checked").size()
					}
				}
			},
			psc: {
				required: {
					depends: function(element) {
						return $(".neosobni:checked").size()
					}
				}
			}
		},
		messages: {
			email: {
				required: "Vyplňte prosím email ve správném formátu"
			},
			telefon: {
				required: "Vyplňte prosím svůj telefon"
			},
			jmeno: {
				required: "Vyplňte prosím své křestní jméno"
			},
			prijmeni: {
				required:  "Vyplňte prosím své příjmení"
			},
			ulice: {
				required: "Vyplňte prosím ulici a číslo domu"
			},
			mesto: {
				required: "Vyplňte prosím město"
			},
			psc: {
				required: "Vyplňte prosím poštovní směrovací číslo"
			}
		}
	});	

   $('input[name=dodani]').click(function(){
   		var dodani = $(this).val();
   		update_povinne();
   		dodani_zmenit(dodani);
   });
   
   update_povinne();

});
