function validateTelepnone(Number){
    var stripped = Number.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
//   if (isNaN(parseInt(stripped))){ 
	for (var i = 0; i< stripped.length; i++)
	{
		if (isNaN(parseInt(stripped.substr(i,1)))) 
		     return false;
    }	 
	var maxlength=9
	if (Number.length<maxlength){
	return false;
	}
	return true;
}
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.all['FromName'].value) || !validateEmail(document.all['email'].value) ||  !validateEmail(document.all['to'].value)){
    alert(' *Please, fill in all mandatory fields and correct Email address');
    return false;
  }   
return true;
}
function checkSendPage(){
if(!validateEmail(document.getElementById("from_input").value)){
alert("נא למלא כתובת דוא''ל חוקית בשדה כתובת השולח");
return false;
}
if(!validateEmail(document.getElementById("Friend_input").value)){
alert("נא למלא כתובת דוא''ל חוקית בשדה כתובת הנמען");
return false;
}
//subject_input
if(document.getElementById("subject_input").value==''){
alert("נא למלא נושא להודעה");
return false;
}
return true;
}

function SendContactForm(formname)
{	
	
	if (document.getElementById("First_name").value=="")
	{
			alert('Please fill in First Name');
			document.getElementById("First_name").focus();		
			return;
	}
	else if (document.getElementById("Last_name").value=="")
	{
			alert('Please fill in Last Name');
			document.getElementById("Last_name").focus();		
			return;
	}
	else if (document.getElementById("Country").value=="USA" && document.getElementById("State").value=="choose")
	{
			alert('Please choose a state');
			document.getElementById("State").focus();		
			return;
	}
	
	if (document.getElementById("Email").value=="")
	{
			alert('Please fill in Email');
			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('Please fill in correct Email');
			document.getElementById("Email").focus();		
			return;
		}
	if (document.getElementById("Phone").value=="")
	{
			alert('Please fill in Phone');
			document.getElementById("Phone").focus();		
			return;
	}		
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}

function checkContactFrm(){

if(document.getElementById("tbFullname").value==""){
alert("שם מלא הינו שדה חובה");
document.getElementById("tbFullname").focus();
return false;
}
if(document.getElementById("tbCompany").value==""){
alert("חברה הינו שדה חובה");
document.getElementById("tbCompany").focus();
return false;
}
if(document.getElementById("tbEmail").value==""){
alert("דוא''ל הינו שדה חובה");
document.getElementById("tbEmail").focus();
return false;
}
if(!validateEmail(document.getElementById("tbEmail").value)){
alert("הכתובת אינה תקינה");
document.getElementById("tbEmail").focus();
return false;
}
if(document.getElementById("tbTel").value==""){
alert("טלפון הינו שדה חובה");
document.getElementById("tbTel").focus();
return false;
}
if(!validateTelepnone(document.getElementById("tbTel").value)){
alert("מספר הטלפון אינו חוקי");
document.getElementById("tbTel").focus();
return false;
}

return true;
}

function SendDownloadForm(formname)
{	
	
	if (document.getElementById("First_name").value=="")
	{
			alert('Please fill in First Name');
			document.getElementById("First_name").focus();		
			return;
	}
	else if (document.getElementById("Last_name").value=="")
	{
			alert('Please fill in Last Name');
			document.getElementById("Last_name").focus();		
			return;
	}
	else if (document.getElementById("Country").value=="USA" && document.getElementById("State").value=="choose")
	{
			alert('Please choose a state');
			document.getElementById("State").focus();		
			return;
	}
	else if (document.getElementById("Company").value=="")
	{
			alert('Please fill in Company');
			document.getElementById("Company").focus();		
			return;
	}
	if (document.getElementById("Email").value=="")
	{
			alert('Please fill in Email');
			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('Please fill in correct Email');
			document.getElementById("Email").focus();		
			return;
		}
	if (document.getElementById("Phone").value=="")
	{
			alert('Please fill in Phone');
			document.getElementById("Phone").focus();		
			return;
	}		
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}

function SendDemoForm(formname)
{	
	
	if (document.getElementById("First_name").value=="")
	{
			alert('Please fill in First Name');
			document.getElementById("First_name").focus();		
			return;
	}
	else if (document.getElementById("Last_name").value=="")
	{
			alert('Please fill in Last Name');
			document.getElementById("Last_name").focus();		
			return;
	}
	else if (document.getElementById("Job_Title").value=="")
	{
			alert('Please fill in Job Title');
			document.getElementById("Job_Title").focus();		
			return;
	}
	else if (document.getElementById("Industry").value=="choose")
	{
			alert('Please choose an Industry');
			document.getElementById("Industry").focus();		
			return;
	}
	else if (document.getElementById("Company").value=="")
	{
			alert('Please fill in Company');
			document.getElementById("Company").focus();		
			return;
	}
	else if (document.getElementById("Country").value=="USA" && document.getElementById("State").value=="choose")
	{
			alert('Please choose a state');
			document.getElementById("State").focus();		
			return;
	}
	
	if (document.getElementById("Email").value=="")
	{
			alert('Please fill in Email');
			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('Please fill in correct Email');
			document.getElementById("Email").focus();		
			return;
		}
	if (document.getElementById("Phone").value=="")
	{
			alert('Please fill in Phone');
			document.getElementById("Phone").focus();		
			return;
	}		
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}
function TestDataCheck(){

	if (document.getElementById("strSearchAgent").value=="")
	{
	 alert(' חובה להזין מילת חיפוש');
		return false;
	}

return true;
}

    





function checkGeneralContact(){
if(!strTrim(document.getElementById("full_name").value)){
alert('Please fill in Full Name');
document.getElementById("full_name").focus();
return false;
}


//Email
if(document.getElementById("email").value==""){
alert("Please fill in Email");
document.getElementById("email").focus();
return false;
}
if(!validateEmail(document.getElementById("email").value)){
alert("Please fill in correct Email");
return false;
}

//Company
if(!strTrim(document.getElementById("company").value)){
alert('Please fill in Company');
document.getElementById("company").focus();
return false;
}

return true;
}
