function isNotEmpty(elem){
	var str = elem.value;
	var re = /.+/;
	
	if(!str.match(re)){
		alert("Пожалуйста, заполните все поля отмеченные *!");
		return false;
		}
	else{
		return true;
	}
}


function isEMailAddr(elem){
	var str = elem.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	
	if(!str.match(re)){
		alert("Неправильно введен адрес электронной почты!");
		return false;
		}
	else{
		return true;
	}
}

function validateForm(form){
	if(isNotEmpty(form.nameF)){
		if(isNotEmpty(form.questionF)){
			if(isNotEmpty(form.email) && isEMailAddr(form.email)){
				return true;
			}
		}
	}
	return false		
}

function validateFormBronone(form){
	if(isNotEmpty(form.gtown)){
		if(isNotEmpty(form.dayF)){
			if(isNotEmpty(form.mounthF)){
				if(isNotEmpty(form.yearF)){
					if(isNotEmpty(form.hourF)){
						if(isNotEmpty(form.minF)){
							if(isNotEmpty(form.gname_guest1)){
								if(isNotEmpty(form.gname_contact)){
									if(isNotEmpty(form.gtelph_contact)){
										return true;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return false		
}
function validateFormBrongroup(form){
	if(isNotEmpty(form.gname_bron)){
		if(isNotEmpty(form.gtown)){
			if(isNotEmpty(form.dayF)){
				if(isNotEmpty(form.mounthF)){
					if(isNotEmpty(form.yearF)){
						if(isNotEmpty(form.day_outF)){
							if(isNotEmpty(form.mounth_outF)){
								if(isNotEmpty(form.year_outF)){
									if(isNotEmpty(form.gtelph_contact)){
										if(isNotEmpty(form.gfax_contact)){
											if(isNotEmpty(form.email) && isEMailAddr(form.email)){
												return true;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return false		
}

function validateFormTobookair(){
	return true;
}
function validateFormcontact(form){
	if(isNotEmpty(form.name)){
		if(isNotEmpty(form.message)){
			if(isNotEmpty_(form.email) && isEMailAddr(form.email)){
					return true;
			}
		}
	}
	return false		
}

function Resize(width, height){
		window.resizeTo(width, height);
	
}
function windowsOpen(url,width,height){
width+=17; height+=3;
var status = 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, scrollbars=1, Resizable=0, Copyhistory=0, Width=' + width + ',Height=' + height;
window.open(url, 'newWin', status);
}
function ChangeTown(){
	var val1 = 'asd';
	document.guest.gtown.value = val1; 
	alert("asd");
}

function Rezalt(){
var val1 = document.raschet.townF.value;
var sum =  val1 ;
document.raschet.gtown.value = val1;

}

var brname=navigator.appName, BrVer='';
if(brname.substring(0,2)=="Mi")
	BrVer='E';
var timer = 0;
lastid = -1;

function show(id)
{
	if(!((document.all)?document.all['menu'+id]:document.getElementById('menu'+id)))
		return;
	clearTimeout(timer);
	if((id != lastid) && (lastid!=-1))
		((document.all)?document.all['menu'+lastid]:document.getElementById('menu'+lastid)).style.visibility = 'hidden';
	hideElement("SELECT1", document.getElementById('menu'+lastid));
	lastid = id;
	((document.all)?document.all['menu'+lastid]:document.getElementById('menu'+lastid)).style.visibility = 'visible';
}

function hidden(id)
{
	if(!((document.all)?document.all['menu'+id]:document.getElementById('menu'+id)))
		return;
	showElement("SELECT1");
	timer = setTimeout("if('"+id+"' == '"+lastid+"'){((document.all)?document.all['menu"+lastid+"']:document.getElementById('menu"+lastid+"')).style.visibility = 'hidden';}", 500)
}


function GetPos(el)
{
	if (!el || !el.offsetParent)return false;
	var res=Array()
	res["left"] = el.offsetLeft;
	res["top"] = el.offsetTop;
	var objParent = el.offsetParent;
	while (objParent.tagName.toUpperCase()!="BODY")
	{
		res["left"] += objParent.offsetLeft;
		res["top"] += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	res["right"]=res["left"]+el.offsetWidth;
	res["bottom"]=res["top"]+el.offsetHeight;
	return res;
}

function hideElement(elName, Menu)
{
	if(BrVer!='E') return;
	for (i = 0; i < document.all.tags(elName).length; i++)
	{
		Obj = document.all.tags(elName)[i];
		if(!(pMenu=GetPos(Menu)))continue;
		if(!(pObj=GetPos(Obj)))continue;

		if(pObj["left"]<pMenu["right"] && pMenu["left"]<pObj["right"] && pObj["top"]<pMenu["bottom"] && pMenu["top"]<pObj["bottom"])
			Obj.style.visibility = "hidden";
	}
}

function showElement(elName)
{
	if(BrVer!='E') return;
	for (i = 0; i < document.all.tags(elName).length; i++)
	{
		obj = document.all.tags(elName)[i];
		if (!obj || !obj.offsetParent)continue;
		if(obj.style.visibility=="hidden")
			obj.style.visibility = "visible";
	}
}

function preView($url){
	document.formroute.action=$url;
}
function ChangeUser(){
	var face = document.formroute.faceF.value;
	if(face == 'ЧАСТНОЕ ЛИЦО'){
		document.getElementById("tobookperson").style.display="block";
		document.getElementById("tobookorganization").style.display="none";
		document.getElementById("tobookcorporation").style.display="none";
	}
	if(face == 'ОРГАНИЗАЦИЯ'){
		document.getElementById("tobookperson").style.display="none";
		document.getElementById("tobookorganization").style.display="block";
		document.getElementById("tobookcorporation").style.display="none";
	}
	if(face == 'КОРП0РАТИВНЫЙ КЛИЕНТ'){
		document.getElementById("tobookperson").style.display="none";
		document.getElementById("tobookorganization").style.display="none";
		document.getElementById("tobookcorporation").style.display="block";
	}
	if(face == ' '){
		document.getElementById("tobookperson").style.display="block";
		document.getElementById("tobookorganization").style.display="none";
		document.getElementById("tobookcorporation").style.display="none";
	}
}
function ChangePay1(){
	var face = document.formroute.gpay1.value;
	if(face == 'Наличными курьеру'){
		document.getElementById("tobookpay1").style.display="block";
	}
	else{
		document.getElementById("tobookpay1").style.display="none";
	}
}
function ChangePay2(){
	var face = document.formroute.gpay2.value;
	if(face == 'Наличными курьеру'){
		document.getElementById("tobookpay2").style.display="block";
	}
	else{
		document.getElementById("tobookpay2").style.display="none";
	}
}

function ChangePay3(){
	var face = document.formroute.gpay3.value;
	if(face == 'Наличными курьеру'){
		document.getElementById("tobookpay3").style.display="block";
	}
	else{
		document.getElementById("tobookpay3").style.display="none";
	}
}


