
function validateEmail(email) {
	var matches = email.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
	return (matches != null && email == matches[0]);
}
function strTrim(str){
  str=str.replace(/(^\s*)|(\s*$)/g, "");
  if (str.length==0){
    return false;
  }
  return true;
} 
 
function checkForm(){
	  if(!strTrim(document.getElementById("full_name").value) ||  !validateEmail(document.getElementById("email").value) || !strTrim(document.getElementById("message").value) || !validateEmail(document.all['to'].value)){
    alert(' *Please, fill in all mandatory fields and correct Email address');
    return false;
  }   
return true;
}

function checkContactHomeForm(e)
{
	
	if(!strTrim(e.elements["full_name"].value))
	{
		alert("Please Fill your full name")
		return false;
	}
	if(!validateEmail(e.elements["email"].value))
	{
		alert("invalid email")
		return false;
	}
	var sFull_name = e.elements["full_name"].value;
	var s =sFull_name;
	if (sFull_name.indexOf(" ")!=-1)
	{
		s = sFull_name.split(" ");
		
		if(s.length>1)
		{
			 //alert(s[0] +"\n" + s[1]);
			 e.elements["first_name"].value = s[0];
			 e.elements["last_name"].value = s[1];
		}
		else
		{
			e.elements["first_name"].value = sFull_name;
		}
	}
	else
	{
		e.elements["first_name"].value = sFull_name;
	}
	
	return true;
}

function checkContactForm(e)
{
	if(!strTrim(e.elements["first_name"].value))
	{
		alert("אנא הזן שם פרטי")
		return false;
	}
	if(!strTrim(e.elements["last_name"].value))
	{
		alert("אנא הזן שם משפחה")
		return false;
	}
	if(!validateEmail(e.elements["email"].value))
	{
		alert("האימייל אינו חוקי")
		return false;
	}
	if(!strTrim(e.elements["message"].value))
	{
		alert("אנא כתוב הודעה")
		return false;
	}
	
	return true;
}

function CheckRightForm(formname)
{
	if (document.getElementById("full_name").value.length==0)
	{
			alert('אנא כתוב את שמך');
			document.getElementById("first_name").focus();		
			return false;
	}
	if (!validateEmail(document.getElementById("email").value))
	{
			alert('כתובת האימייל אינה תקינה');
			document.getElementById("email").focus();		
			return false;
	}
	if (document.getElementById("phone").value.length==0)
	{
			alert('אנא כתוב מספר טלפון');
			document.getElementById("phone").focus();		
			return false;
	}
		
	if (document.getElementById("message").value.length==0)
	{
			alert('אנא כתוב הודעה');
			document.getElementById("message").focus();		
			return false;
	}
	
	eval("document.forms['"+formname+"'].submit()");
	return true;
}
function SendContactForm(formname)
{
	if (document.getElementById("RecipientName").value=="")
	{
			alert('חובה למלא את שם החבר');
			document.getElementById("RecipientName").focus();		
			return;
	}
	
	
	if (document.getElementById("to").value=="")
	{
			alert('חובה למלא את כתובת הדוא"ל של חברך');
			document.getElementById("to").focus();		
			return;
	}	
		else if((document.getElementById("to").value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('כתובת הדוא"ל של חברך אינה תקינה');
			document.getElementById("to").focus();		
			return;
		}
	if (document.getElementById("FromName").value=="")
	{
			alert('חובה למלא את שמך');
			document.getElementById("FromName").focus();		
			return;
	}
	if (document.getElementById("email").value=="")
	{
			alert('חובה למלא את כתובת הדוא"ל שלך');
			document.getElementById("email").focus();		
			return;
	}	
		else if((document.getElementById("email").value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('כתובת הדוא"ל אינה תקינה');
			document.getElementById("email").focus();		
			return;
		}	
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}


function SendRegistrationForm(formname)
{
	
	 if (document.getElementById("FirstName").value=="")
	{
			alert('Please, fill in First Name');
			document.getElementById("FirstName").focus();		
			return;
	}
	else if (document.getElementById("LastName").value=="")
	{
			alert('Please, fill in Last Name');
			document.getElementById("LastName").focus();		
			return;
	}
	else if (document.getElementById("Institution").value=="")
	{
			alert('Please, fill in Institution');
			document.getElementById("Institution").focus();		
			return;
	}
	else if (document.getElementById("Phone").value=="")
	{
			alert('Please, fill in Phone');
			document.getElementById("Phone").focus();		
			return;
	}
	if (document.getElementById("EmailAddress").value=="")
	{
			alert('Please, fill in Email Address');
			document.getElementById("EmailAddress").focus();		
			return;
	}	
		else if((document.getElementById("EmailAddress").value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('Please fill in correct Email');
			document.getElementById("EmailAddress").focus();		
			return;
		}
	if (document.getElementById("Country").value=="choose")
	{
			alert('Please, choose a country');
			document.getElementById("Country").focus();		
			return;
	}
		
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}

function ShowClubForm(e)
{
var point = fGetXY(e);
var div = document.getElementById("ClubForm");
var eTopBanner = document.getElementById("TopBanner");
div.style.left = point.x+  "px";
div.style.top = point.y + e.height + "px";

div.style.display = (eTopBanner.attributes["class"].value=="TopBannerBgPlus") ? "block" : "none";
eTopBanner.attributes["class"].value=(div.style.display =="none") ? "TopBannerBgPlus" : "TopBannerBgMinus";
}


function fGetXY(aTag){
  var oTmp = aTag;
  var pt = new Point(0,0);
  do {
	pt.x += oTmp.offsetLeft;
	pt.y += oTmp.offsetTop;
	oTmp = oTmp.offsetParent;
  } while(oTmp.tagName!="BODY");
  return pt;
}
function Point(iX, iY)
{
	this.x = iX;
	this.y = iY;
}
var lastHomeID = null;
var lastTrHomeID = null;
function ShowHomeMenu(e,id)
{
	if(id==lastHomeID && document.getElementById(id).style.display=='block')
	{
		
		document.getElementById(id).style.display = 'none';
	}
	else
	{
	if(lastHomeID!=null&&lastHomeID!=id)document.getElementById(lastHomeID).style.display = 'none';
	if(lastTrHomeID!=null&&lastTrHomeID!="tr_"+id)document.getElementById(lastTrHomeID).style.display = 'block';
	//if(document.getElementById(id).style.display=='block'){document.getElementById(id).style.display = 'none'}
	e.attributes["class"].value='MenuHomeBGselected';
	var el = document.getElementById(id);
	var tr = document.getElementById("tr_"+id);
	var point = fGetXY(e);
	if(!document.all)
	{
		el.style.left = point.x +  "px";
	}
	else
	{
		el.style.right = point.x-4 +  "px";
	}
	el.style.top = point.y + 35 +"px";/**/
	//tr.style.display='none';
	el.style.display='block';
	lastHomeID = id;
	lastTrHomeID = "tr_"+id;
	}
	
	
}
var lastLeftID = null;
var lastTrLeftID = null;

function ShowLeftMenu(e,id)
{
	if(id==lastLeftID && document.getElementById(id).style.display=='block')
	{
		
		document.getElementById(id).style.display = 'none';
	}
	else
	{
	if(lastLeftID!=null&&lastLeftID!=id)document.getElementById(lastLeftID).style.display = 'none';
	if(lastTrLeftID!=null&&lastTrHomeID!="tr_"+id)document.getElementById(lastTrLeftID).style.display = 'block';
	//if(document.getElementById(id).style.display=='block'){document.getElementById(id).style.display = 'none'}
	//e.attributes["class"].value='MenuLeftBGselected';
	var el = document.getElementById(id);
	var tr = document.getElementById("tr_"+id);
	//tr.style.display='none';
	el.style.display='block';
	lastLeftID = id;
	lastTrLeftID = "tr_"+id;
	}
	
	
}
function GetinnerText(obj)
{
	if(document.all){
    return obj.innerText ;
	} else{ 
			return obj.textContent ;
	}
}
function SetInnerText(obj,val)
{
	if(document.all){
     obj.innerText = val ;
	} else{
			 obj.textContent = val ;
	}
}

function showLogin()
{
	var help = document.getElementById("loginhelp");
	
	if(document.getElementById("PreClub").style.display=="none")
	{
		document.getElementById("PreClub").style.display = "block";
		document.getElementById("logindiv").style.display = "none";
		SetInnerText(help,"חבר במועדון? לחץ להתחברות");
		
	}
	else
	{
		document.getElementById("PreClub").style.display="none";
		document.getElementById("logindiv").style.display = "block";
		SetInnerText(help,"להרשמה");
	}
}