
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 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 checkchars(cur){
//change max length to determine below
//var maxlength=9
//if (cur.chars.value.length<maxlength){
//return false
//}
//}

   

function checkForm(){
  if( !strTrim(document.all['First_Name'].value)) {
    alert(' First Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if( !strTrim(document.all['Last_Name'].value)) {
    alert( 'Last Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if( !strTrim(document.all['Company_Name'].value)) {
    alert(' Company Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if( !strTrim(document.all['Job_Position'].value)) {
    alert(' Job Position is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if(validateTelepnone(document.all['Telephone_No'].value)==false) {
    alert('Telephone Number in incorrect Format');
	document.all['Telephone_No'].focus();
    return false;
  }
  if(!validateEmail(document.all['Email'].value)) {
    alert('E-mail in incorrect Format');
	document.all['Email'].focus();
    return false;
  }
  if(!strTrim(document.all['Choose_Service'].options[document.all['Choose_Service'].selectedIndex].value)) {
    alert(' Please Choose Service Type');
	document.all['Choose_Service'].focus();
    return false;
  }
  if(!strTrim(document.all['Where_Did_You_Hearied_About_Us'].options[document.all['Where_Did_You_Hearied_About_Us'].selectedIndex].value)) {
    alert('aaa ');
	document.all['Choose_Service'].focus();
    return false;
  }
 document.ContactForm.submit();
  return true;
}

function checkFormINAction(){
  if( !strTrim(document.all['First_Name'].value)) {
    alert('First Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if( !strTrim(document.all['Last_Name'].value)) {
    alert('Last Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if( !strTrim(document.all['Company_Name'].value)) {
    alert('Last Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if( !strTrim(document.all['Job_Position'].value)) {
    alert('Job Position is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
  if(validateTelepnone(document.all['Telephone_No'].value)==false) {
    alert('Telephone Number in incorrect Format');
	document.all['Telephone_No'].focus();
    return false;
  }
  if(!validateEmail(document.all['Email'].value)) {
    alert('דואר אלקטרוני שגוי');
	document.all['Email'].focus();
    return false;
  }
   
 document.ContactForm.submit();
  return true;
}


function checkFormRight()
{
if( !strTrim(document.all['First_Name'].value)) {
    alert(' First Name is Required Field');
	document.all['First_Name'].focus();
    return false;
  }
if(validateTelepnone(document.all['Telephone_No'].value)==false) {
   alert('Telephone Number in incorrect Format');
   document.all['Telephone_No'].focus();
   return false;
  }
   if(!validateEmail(document.all['Email'].value)) {
    alert('E-mail in incorrect Format');
	document.all['Email'].focus();
    return false;
  }
  
  document.ContactFormRIGHT.submit();
  return true;
}


function TestDataCheck(){
	
	var sRetURL = "http://www.pionet.co.il/SaveData.asp?first_name=" + encodeURIComponent(document.all['first_name'].value);
	sRetURL += "&last_name=" + encodeURIComponent(document.all['last_name'].value);
	sRetURL += "&company=" + encodeURIComponent(document.all['company'].value);
	sRetURL += "&title=" + encodeURIComponent(document.all['title'].value);
	sRetURL += "&phone="  + document.all['phone'].value;
	sRetURL += "&email=" + document.all['email'].value; 
	sRetURL += "&00N20000001ykuw=" + encodeURIComponent(document.all['00N20000001ykuw'].value); 
	sRetURL +=  "&URL=" + encodeURIComponent(document.all['URL'].value);
	sRetURL += "&00N20000001ykv6=" + encodeURIComponent(document.all['00N20000001ykv6'].value);
	sRetURL += "&00N20000001yxKb=" + encodeURIComponent(document.all['00N20000001yxKb'].value);
	sRetURL += "&source=PIONET";
	sRetURL += "&retURL=" + document.all['retURL'].value;
	if (document.all['confirm_newsletter'].checked)
			sRetURL += "&confirm_newsletter=on";
  if( !strTrim(document.all['first_name'].value)) {
    alert(' First Name is Required Field');
	document.all['first_name'].focus();
    return false;
  }
  if( !strTrim(document.all['last_name'].value)) {
    alert( 'Last Name is Required Field');
	document.all['last_name'].focus();
    return false;
  }
  if( !strTrim(document.all['company'].value)) {
    alert(' Company Name is Required Field');
	document.all['company'].focus();
    return false;
  }
  if( !strTrim(document.all['title'].value)) {
    alert(' Job Position is Required Field');
	document.all['title'].focus();
    return false;
  }
  if(validateTelepnone(document.all['phone'].value)==false) {
    alert('Telephone Number in incorrect Format');
	document.all['phone'].focus();
    return false;
  }
  if(!validateEmail(document.all['email'].value)) {
    alert('E-mail in incorrect Format');
	document.all['email'].focus();
    return false;
  }
  if(!strTrim(document.all['00N20000001ykuw'].options[document.all['00N20000001ykuw'].selectedIndex].value)) {
    alert(' Please Choose Service Type');
	document.all['00N20000001ykuw'].focus();
    return false;
  }
  if(!strTrim(document.all['00N20000001ykv6'].options[document.all['00N20000001ykv6'].selectedIndex].value)) {
    alert(' Please Choose Service Type');
	document.all['00N20000001ykv6'].focus();
    return false;
  }
  document.all["retURL"].value = sRetURL;
  return true;
}




function TestDataCheckFormRight(){
	
	
  if( !strTrim(document.all['first_name'].value)) {
    alert(' First Name is Required Field');
	document.all['first_name'].focus();
    return false;
  }
  if(validateTelepnone(document.all['phone'].value)==false) {
    alert('Telephone Number in incorrect Format');
	document.all['phone'].focus();
    return false;
  }
  if(!validateEmail(document.all['email'].value)) {
    alert('E-mail in incorrect Format');
	document.all['email'].focus();
    return false;
  }
  if(!strTrim(document.all['00N20000001ykuw'].options[document.all['00N20000001ykuw'].selectedIndex].value)) {
    alert(' Please Choose Service Type');
	document.all['00N20000001ykuw'].focus();
    return false;
  }
  return true;
}


function SendContactForm(formname)
{
	
	 if (document.getElementById("full_name").value=="")
	{
			alert('חובה להקליד את השם');
			document.getElementById("full_name").focus();		
			return;
	}
	else if (document.getElementById("phone_number").value=="")
	{
			alert('חובה להקליד את מספר הטלפון');
			document.getElementById("phone_number").focus();		
			return;
	}				
	if (document.getElementById("email_address").value=="")
	{
			alert('חובה להקליד את כתובת הדואר האלקטרוני');
			document.getElementById("email_address").focus();		
			return;
	}	
	else if((document.getElementById("email_address").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_address").focus();		
		return;
	}	
	
	if (document.getElementById("app_subject").value=="")
	{
			alert('חובה להקליד את סיבת הפנייה');
			document.getElementById("app_subject").focus();		
			return;
	}	
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');		
		eval("document.forms['"+formname+"'].submit()");
	}
}

