/*$(window).load(function() {
    $('#slider').nivoSlider();
});*/


$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:800, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
});

jQuery(function($){
	
	$('.circle').mosaic({
		opacity		:	0.8			//Opacity for overlay (0-1)
	});
	
	$('.fade').mosaic();
	
	$('.bar').mosaic({
		animation	:	'slide'		//fade or slide
	});
	
	$('.bar2').mosaic({
		animation	:	'slide'		//fade or slide
	});
	
	$('.bar3').mosaic({
		animation	:	'slide',	//fade or slide
		anchor_y	:	'top'		//Vertical anchor position
	});
	
	$('.cover').mosaic({
		animation	:	'slide',	//fade or slide
		hover_x		:	'400px'		//Horizontal position on hover
	});
	
	$('.cover2').mosaic({
		animation	:	'slide',	//fade or slide
		anchor_y	:	'top',		//Vertical anchor position
		hover_y		:	'80px'		//Vertical position on hover
	});
	
	$('.cover3').mosaic({
		animation	:	'slide',	//fade or slide
		hover_x		:	'400px',	//Horizontal position on hover
		hover_y		:	'300px'		//Vertical position on hover
	});

});






$(document).ready(function() {

	$("a[rel=gallery]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Attēls ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
});

function submit_form()
{
	$("#note").fadeOut();
	
	var name = $("#name").val();
	var email = $("#email").val();
	var subject = $("#subject").val();
	var answer = $("#answer").val();
	var message = $("#message").val();
	
	var math_string = $("#question").attr("title");
	var math = parseInt(math_string[0]) + parseInt(math_string[2]);
	
	if(name == "" || email == "" || answer == "")
	{
		$("#note").html("Lūdzu, aizpildiet visus obligātos lauciņus!");
		$("#note").fadeIn();
	}
	else if(parseInt(answer) != math)
	{
		$("#note").html("Lūdzu, pareizi izrēķiniet vienādojumu!");
		$("#note").fadeIn();
	}
	else
	{
		$.ajax({
			type: 'post',
		  	url: '/data/mail.php',
			data: 'name=' + name + '&email=' + email + '&subject=' + subject + '&message=' + message,
		  	success: function(res) {
				if(res == "1")
				{
					$("#ajax-contact-form").delay(100).slideUp(1000);
					$("#note").html("Ziņa veiksmīgi nosūtīta.").animate({'color':'#8DD343'},300);
				}
				else
					$("#note").html("Ziņu neizdevās nosūtīt.");
				$("#note").fadeIn();
			}
		});
	}

}





