$(document).ready(function(){

$('#presovani2').hide();
$('#liveni2').hide();
$('#fert2').hide();
$('#nadvratne2').hide();

$('#presovani').click(function(){ $('#presovani2').slideToggle('fast'); return false; });
$('#liveni').click(function(){ $('#liveni2').slideToggle('fast'); return false; });
$('#fert').click(function(){ $('#fert2').slideToggle('fast'); return false; });
$('#nadvratne').click(function(){ $('#nadvratne2').slideToggle('fast'); return false; });



var myPhoto = new Array(
"images/slideshow/1.jpg",
"images/slideshow/2.jpg",
"images/slideshow/3.jpg",
"images/slideshow/4.jpg");


var thisPhoto = 0;


$('#sledeci').click(function() { 

	thisPhoto++;
	if (thisPhoto == myPhoto.length) {
		thisPhoto = 0;
	}

	$('#slika').fadeOut('fast',function() { $(this).css({ 'background':'url('+myPhoto[thisPhoto]+') no-repeat top left' }); });
	$('#slika').fadeIn('normal');
	
	return false;
							 });

$('#prethodni').click(function() { 

	
	if (thisPhoto == 0) {
		thisPhoto = myPhoto.length ;
	}
	thisPhoto--;

	$('#slika').fadeOut('fast',function() { $(this).css({ 'background':'url('+myPhoto[thisPhoto]+') no-repeat top left' }); });
	$('#slika').fadeIn('normal');
	
	return false;
							 });



var validator = $("#contForm").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true,
			},
			poruka: "required"
		},
		messages: {
			name: " ",
			email:" ",
			poruka: " "
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			
		
		$.get("salji.php",   { name: $("#name").val(), email: $("#email").val(), poruka: $("#poruka").val() },
   	function(data){
			$(".success_msg").show("slow");
	}
	
	
);
				
			
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});


});
