$(function() {
	//Убираем класс по фокусу
	$('.req').focus(function () {
         $(this).removeClass('form_focus');
    });
    $('.req').blur(function () {
         if($.trim($(this).val()) == '') {
         	$(this).addClass('form_focus');
         }
         if($('.form_focus').length == 0) {
         	$('button[name="go_submit"]').attr('disabled', false);
         } else {
         	$('button[name="go_submit"]').attr('disabled', true);
         }
    });
    
    // Галерея новых фоток
     $("div#new_photo").carousel( {
       	autoSlide: true, 
        autoSlideInterval: 8000,
        dispItems: 3,
        effect: "fade"
	} );
	
	// Обновление рейтинга
	setTimeout(function() { setInterval(refresh_rating, 15000) }, 15000);

});

function check_anket_form() {
	if(!check_anket()) {
		return false;
	} else if ($('#photos').val() == null) {
		alert('Вы не загрузили ни одной фотографии!');
		return false;
	}
	return true;
}

function check_anket() {
	if($.trim($('input[name="family"]').val()) == '') {
		alert('Введите Фамилию!');
		return false;
	} else if($.trim($('input[name="name"]').val()) == '') {
		alert('Введите Имя!');
		return false;
	} else if($.trim($('[name="age"]').val()) == '') {
		alert('Укажите Ваш возраст!');
		return false;
	} else if($.trim($('input[name="country"]').val()) == '') {
		alert('Введите Cтрану!');
		return false;
	} else if($.trim($('input[name="city"]').val()) == '') {
		alert('Введите Город!');
		return false;
	} else if($.trim($('input[name="school"]').val()) == '') {
		alert('Введите Учебное заведение!');
		return false;
	} else if($.trim($('textarea[name="adress"]').val()) == '') {
		alert('Введите Адрес!');
		return false;
	} else if($.trim($('input[name="phone2"]').val()) == '') {
		alert('Введите Телефон школы!');
		return false;
	} else if($.trim($('input[name="teacher"]').val()) == '') {
		alert('Введите ФИО Классного руководителя!');
		return false;
	} else {
		return true;
	}
	return false;
}


	stepcarousel.setup({
galleryid: 'mygallery', //id of carousel DIV
beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
panelclass: 'panel', //class of panel DIVs each holding content
paginateid: 'mygallery-paginate',
autostep: {enable:true, moveby:1, pause:3000},
panelbehavior: {speed:500, wraparound:true, persist:true},
defaultbuttons: {enable: true, moveby: 1, leftnav: ['/js/jquery/step/back.gif', -5, 80], rightnav: ['/js/jquery/step/next.gif', -20, 80]},
statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
contenttype: ['ajax', '/new_photo_car.php'],//['inline'] //content setting ['inline'] or ['ajax', 'path_to_external_file']
navbuttonsname: ['Назад', 'Вперед'],
navbuttonsplace: ['eugenia']
});

function change_image (item, status) {
	var pic = new Image();
	pic.src = '/i/graycircle.png';
	if (status) item.src = '/i/graycircle.png';
	else item.src = '/i/opencircle.png';
}
