$(document).ready(function() {	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});
});


function captcha() {
	$.post('/index/captcha', null,
	function(data) {
			$("#recaptcha").hide();
        	$("#recaptcha").html(data);
        	$("#recaptcha").show();
    	}
	);
}

function checkContactForm(){
	var errMsg = '';
	
	var name = $.trim($("input[name='name']").val());
	var email = $.trim($("input[name='email']").val());
	var message = $.trim($("textarea[name='message']").val());
	
	if (email.length == 0 || email == 'Ваш email'){
		errMsg += 'Необходимо заполнить поле Ваш email\n';
	} 
	
	if (!checkmail(email)){
		errMsg += 'Необходимо корректно заполнить поле ваш email\n';
	}
	
	if (message.length == 0 || message == 'Текст сообщения'){
		errMsg += 'Необходимо заполнить поле текст сообщения\n';
	}
	
	if (name.length == 0 || name == 'Ваше имя'){
		errMsg += 'Необходимо заполнить поле Ваше имя\n';
	}
	
	if (errMsg.length == 0)
	return true;
	
	alert(errMsg);
	return false;
}


function checkmail(email) {
	var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
	return (reg.exec(email)!=null)
} 
