function checkFaq() {
		var required = {
			"fio"	:	"Вы не ввели своё имя",
			"eadres":	"Вы не ввели E-mail",
			"quest"	:	"Вы не ввели вопрос"
		};
	
		for (var i in required) {
			var el = document.getElementById(i);
			if (!el.value) {
				alert(required[i]);
				el.focus();
				return false;
			}
		}
		return true;
}

function checkCom() {
		var required = {
			"fioC"	:	"Вы не ввели своё имя",
			"eadresC":	"Вы не ввели E-mail",
			"questC"	:	"Вы не ввели вопрос"
		};
	
		for (var i in required) {
			var el = document.getElementById(i);
			if (!el.value) {
				alert(required[i]);
				el.focus();
				return false;
			}
		}
		return true;
}

function checkSearch(id) {
		if (!id) {
			id = '';
		}
		var value = $("#search_string"+id).attr('value');
		if(!value || (value == 'поиск...'))  {
			alert('Не заполнена строка поиска');
			$("#search_string"+id).focus();
			return false;
		}
		return true;
}

function showAddress (select) {
    $('#selectAddress').html('<select disabled><option value="">Не выбрано</option></select>');
    $('#selectTimes').html('<select disabled><option value="">Не выбрано</option></select>');
    
    if ($(select).val()) {
		$('#selectAddress').html($('#a'+$(select).val()).html());
    }
    if($('#selectAddress select').val()) {
		$('#selectTimes').html($('#t'+$('#selectAddress select').val()).html());
    }

    
}

function showTimes (select) {
    $('#selectTimes').html('<select disabled><option value="">Не выбрано</option></select>');
    if ($(select).val()) {
		$('#selectTimes').html($('#t'+$(select).val()).html());
    }
    
}

function checkBullet() {
	if (!$('.bullet-form form #selectAddress #addr').val()) {
		alert("Вы не выбрали адрес музея");
		return false;
	}
	
	if (!$('.bullet-form form #selectTimes #timer').val()) {
		alert("Вы не выбрали время посещения");
		return false;
	}

    var required = {
			/*"selectAddress"	:	"Вы не выбрали адрес музея",
			"selectTimes":	"Вы не выбрали время посещения",/**/
			"fioB"	:	"Вы не ввели представились",
			"eadresB"	:	"Вы не ввели Email"
		};

		for (var i in required) {
			var el = document.getElementById(i);
			if (!el.value) {
				alert(required[i]);
				el.focus();
				return false;
			}
		}

		if (!isValidEmail($('#eadresB').val(), 1)) {
		    alert('Введен не корректный адрес');
		    $('#eadresB').focus();
		    return false;
		}
		return true;
}

function isValidEmail (email, strict) {
     if ( !strict ) email = email.replace(/^\s+|\s+$/g, '');
     return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
}

