var undoValue;

function valfield(exp) {
	var srcEL,re,x; 
	srcEL = (valfield.arguments.length>1) ? valfield.arguments[1] : window.event.srcElement;
	x = exp;
	// macro definition
	re = /<empty>/gi; x = x.replace(re,"(<f>.value!=='')");
	re = /<numeric>/gi; x = x.replace(re,"(!(isNaN(<f>.value)))");
	re = /<quantity>/gi; x = x.replace(re,"(!((isNaN(<f>.value)) || (Math.round(<f>.value)!=<f>.value) || (<f>.value<=0)))");
	re = /<date>/gi; x = x.replace(re,"(isDate(<f>.value))");
	
	// replace the field property
	re = /<f>/gi;	x = x.replace(re,"srcEL");
	if (!(eval(x))) {
		alert("ערך לא תקין");
		srcEL.value=undoValue
		return false;
	}
	return true;
}
																												
function setUndoValue() {
	var v;
	v = (setUndoValue.arguments.length>0) ? setUndoValue.arguments[1] : window.event.srcElement.value;
	undoValue=v;
}

function isDate(dt) {
	var s,d;
	s = /(-|\.|[ ])/gi; dt = dt.replace(s,'/');
	d = dt.split("/");
	if (d.length!=3) return false;
	if ((d[0]<1) || (d[0]>31) || (d[1]<1) || (d[1]>12) || ((d[2].length % 2)==1)  || (d[2].length>4)) return false;
	if (d[2].length==2) d[2] = ((d[2]>30) ? '19' : '20') + d[2];
	var  ok = new Boolean ;
	ok = (((d[1]==1) || (d[1]==3) ||  (d[1]==5) || (d[1]==7) || (d[1]==8) || (d[1]==10) || (d[1]==12)) && (d[0]<=31));
	ok = ok || (((d[1]==4) || (d[1]==6) || (d[1]==9) || (d[1]==11)) && (d[0]<=30));
	ok = ok || ((d[1]==2) && (d[0]<=(((d[2] % 4)==0) ? 29 : 28)));
	return ok;
}

function viewbig(id){

	var wnd;
	wnd=window.open("viewpic.asp?id="+id,"_blank","directories=no,height=445,width=567,location=no,menubar=no,resizable=no,scrollbars=no,status=0,toolbar=0");

}
function viewjok(id){

	var wnd;
	wnd=window.open("viewjok.asp?id="+id,"_blank","directories=no,height=487,width=620,location=no,menubar=no,resizable=no,scrollbars=no,status=0,toolbar=0");

}
function checkLogin()
{
var login,pass
login = document.logForm.ulog.value
pass = document.logForm.upass.value
if (login.length < 5)
	{
	alert("אנא הקלד את שם משתמש");
	}
	else if (pass.length < 5)
	{
	alert("אנא הקלד סיסמא");
	}
	else
	{
	document.logForm.submit()
	}
}

function checkFormReg()
{

var fname, email, country, phone,lname,adrr,login,pass

fname = document.regForm.fname.value
email = document.regForm.mail.value
city = document.regForm.city.value
phone = document.regForm.phone.value
lname= document.regForm.lname.value
adrr = document.regForm.adrr.value
login = document.regForm.login.value
pass = document.regForm.pass.value
	if (fname.length < 2)
	{
	alert(".אנא הקלד את שמך");
	}
	else if (lname.length < 2)
	{
	alert("אנא הקלד את שם המשפחה");
	}
	else if (login.length < 5)
	{
	alert("שם משתמש קצר מ 5 תווים");
	}
	else if (pass.length < 5)
	{
	alert("סיסמא קצר מ 5 תווים");
	}
	else if (email.indexOf('@')<1 || email.indexOf('.',email.indexOf('@'))-email.indexOf('@')<2 || email.length-1==email.lastIndexOf('.'))
	{
	alert(".כתובת דואר אלקטרוני שגויה");
	}
	else if (phone.length < 9)
	{
	alert(".מספר טלפון שגוי");
	}
	else
	{
	document.regForm.submit()
	}
}
function checkFormClub()
{

var fname, email, country, phone,lname,adrr,login,pass

fname = document.regForm.fname.value
email = document.regForm.mail.value
city = document.regForm.city.value
phone = document.regForm.phone.value
lname= document.regForm.lname.value
adrr = document.regForm.adrr.value
	if (fname.length < 2)
	{
	alert(".אנא הקלד את שמך");
	}
	else if (lname.length < 2)
	{
	alert("אנא הקלד את שם המשפחה");
	}
	
	else if (email.indexOf('@')<1 || email.indexOf('.',email.indexOf('@'))-email.indexOf('@')<2 || email.length-1==email.lastIndexOf('.'))
	{
	alert(".כתובת דואר אלקטרוני שגויה");
	}
	else if (phone.length < 9)
	{
	alert(".מספר טלפון שגוי");
	}
	else
	{
	document.regForm.submit()
	}
}
function jp_com(com,arg) {
	
		if(com == "map") {
		window.open("map.asp","_blank","directories=no,height=680,width=800,location=no,menubar=no,resizable=no,scrollbars=yes,status=0,toolbar=0");
		}	
}
function reserv_frm(){
var fname, phone,isphone
fname=document.rev.nam.value;
phone=document.rev.phone.value;
isphone=/^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/;
	if (fname.length < 2 || fname.length > 25)
	{
	alert(".אנא הקלד את שמך");
	}
	else if (!isphone.test(phone) || phone.length < 9 || phone.length >12)
	{
	alert(".מספר טלפון שגוי");
	}
	else
	{
	document.rev.submit()
	}
}