function ShowHide(id){
if (id != '') {
	var itm = null;
	var pitm= null;
	if (document.getElementById) { 
  		itm = document.getElementById(id); 
	} else if (document.all) { 
		itm = document.all[id]; 
	} else if (document.layers) { 
		itm = document.layers[id]; 
	}
   	if (!itm) { /* do nothing */ 
	} else if (itm.style) {
   		if (itm.style.display == "none") { 
			itm.style.display = "block"; 
		} else { 
			itm.style.display = "none";
		}
    } else { itm.visibility = "show"; }
 }
}
function GetWidth() {
	if (self.innerWidth) {
		return self.innerWidth;
	} else
	if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientWidth;
	} else
	if (document.body) {
		return document.body.clientWidth;
	}
}
function setnulltext(this_, mess, typ) {
	if (typ == 0) {
		if (this_.value == mess) {this_.value = ""};
	} else {
		if (this_.value == "") {this_.value = mess};
	}
}
function gebi (this_) {
	return document.getElementById(this_).value;
}

function bi (this_) {
	return document.getElementById(this_);
}
function blockdiv (this_) {
	document.getElementById(this_).style.display = 'block';
}
function nonediv (this_) {
	document.getElementById(this_).style.display = 'none';
}
function ShowMenu(mm) {
	blockdiv('menu'+mm);	
}
function ChClassA (this_, m) {
	this_.style.background = 'url(./i/am'+m+'.jpg) repeat-y #FFFFFF';
}
function ChClassD (this_, m) {
	this_.style.background = 'url(./i/dm'+m+'.jpg) repeat-y #FFFFFF';
}
function AddZayvka(type_) {
	var nm = bi('nm').value;
	var dtdr = bi('dtdr').value;
	var email = bi('email').value;
	var phone = bi('phone').value;
//	var dt = bi('dt').value;
//	var tm = bi('tm').value;
	var prich = bi('prich').value;
	var filial = bi('filial').value;
	
	var _error_ = 0;
	prich = prich.replace(/\n/, "<br>");
	

	if (nm == '' || nm == 'Ваше имя')
		{bi('nm').style.backgroundColor = '#FFAAAA'; 	_error_ = 1;} else {bi('nm').style.backgroundColor = '#FFFFFF';}
	if (dtdr == '' || dtdr == 'Дата рождения')
		{bi('dtdr').style.backgroundColor = '#FFAAAA'; _error_ = 1;} else {bi('dtdr').style.backgroundColor = '#FFFFFF';}
	if (email == '' || email == 'Е-mail')
		{bi('email').style.backgroundColor = '#FFAAAA'; _error_ = 1;} else {bi('email').style.backgroundColor = '#FFFFFF';}
	if (phone == '' || phone == 'Контактный телефон')
		{bi('phone').style.backgroundColor = '#FFAAAA'; _error_ = 1;} else {bi('phone').style.backgroundColor = '#FFFFFF';}
/*
	if (dt == '' || dt == 'Предпочтительная дата')	
		{bi('dt').style.backgroundColor = '#FFAAAA';	_error_ = 1;} else {bi('dt').style.backgroundColor = '#FFFFFF';}
	if (tm == '' || tm == 'Предпочтительное время')	
		{bi('tm').style.backgroundColor = '#FFAAAA';	_error_ = 1;} else {bi('tm').style.backgroundColor = '#FFFFFF';}
*/
	if (prich == '' || prich == 'Причина обращения')	
		{bi('prich').style.backgroundColor = '#FFAAAA';	_error_ = 1;} else {bi('prich').style.backgroundColor = '#FFFFFF';}
	if (_error_ == 0) {
//		myAjax('./zayavka.php?type='+type_+"&nm="+nm+"&dtdr="+dtdr+"&email="+email+"&phone="+phone+"&dt="+dt+"&tm="+tm+"&prich="+prich, 'zapis_na_priem');
		myAjax('./zayavka.php?type='+type_+"&nm="+nm+"&dtdr="+dtdr+"&email="+email+"&phone="+phone+"&filial="+filial+"&prich="+prich, 'zapis_na_priem');
	} else {
		alert('Заполните поля указаные поля');
        return false;
	}

}
function ShowHideM(id){
	for(var i=0; i<menu_al.length; i++) {
		if (document.getElementById('m'+menu_al[i]) != null ) {
			if (document.getElementById('m'+menu_al[i]).style.display == 'block' && id != menu_al[i]) {
				nonediv('m'+menu_al[i]);
			}
		}
	}
	if (document.getElementById('m'+id).style.display == 'block') {
		nonediv('m'+id);
	} else {
		blockdiv('m'+id);
	}
}
function ShowHideMr(id){
	for(var i=0; i<menu_al_r.length; i++) {
		if (document.getElementById('mr'+menu_al_r[i]) != null ) {
			if (document.getElementById('mr'+menu_al_r[i]).style.display == 'block' && id != menu_al_r[i]) {
				nonediv('mr'+menu_al_r[i]);
			}
		}
	}
	if (document.getElementById('mr'+id).style.display == 'block') {
		nonediv('mr'+id);
	} else {
		blockdiv('mr'+id);
	}
}
