
function $(el) {return document.getElementById(el)}

function toggleQ(id) {
	if ($('question'+id).style.display == "none")
		$('question'+id).style.display = "block"
	else if ($('question'+id).style.display == "block")
		$('question'+id).style.display = "none"
}

function toggleContact(id) {
	if ($('contact'+id).style.display == "none")
		$('contact'+id).style.display = "block"
	else if ($('contact'+id).style.display == "block")
		$('contact'+id).style.display = "none"
}
	
function toggleAsk() {
	if ($('formDiv').style.display == "none")
		$('formDiv').style.display = "block"
	else if ($('formDiv').style.display == "block")
		$('formDiv').style.display = "none"
}

function isTxt(str) {
	var Txt1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var Txt2 = new RegExp("^[^0-9]{3,25}$");
	return (!Txt1.test(str) & Txt2.test(str));
}
	
function validate(form) {
	if (!isTxt(form.name.value)) {
		alert("Не указано Ваше Ф.И.О.");
		form.name.focus();
		form.name.select();
		return false;
	}
	if (!isTxt(form.email.value)) {
		alert("Не указан Ваш E-mail");
		form.name.focus();
		form.name.select();
		return false;
	}
	if (!form.text.value ) {
		alert("Не указан ваш вопрос");
		form.text.focus();
		form.text.select();
		return false;
	}
	return true
}

function changeBg(num, name) {
	$('cars'+num).style.background = "url(imgs/cars/" + name + ".jpg) right no-repeat"
}
function changeBg2(num, name) {
	$('cars'+num).style.background = "url(imgs/cars/" + name + ".jpg) left no-repeat"
}

function changeWeight(obj) {
	if (obj.style.fontWeight == "normal" || obj.style.fontWeight == "" || obj.style.fontWeight == 400)
		obj.style.fontWeight = "bold"
	else if (obj.style.fontWeight == "bold" || obj.style.fontWeight == 700)
		obj.style.fontWeight = "normal"
}

function showMap(num) {
	var map = $('map'+num)
	if (!map) return
	map.style.visibility = "visible"
	if ($('highlight')) {
		$('highlight').innerHTML = $('area'+num).title
		$('highlight').style.visibility = "visible"
	}
}

function hideMap(num) {
	var map = $('map'+num)
	if (!map) return
	map.style.visibility = "hidden"
	if ($('highlight')) $('highlight').style.visibility = "hidden"
}

function openRegion(name) {
	location.href=name
}