
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 validateCelepnone(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=10
	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( !validateEmail(document.all['to'].value)) {
    alert('send to value is not vailed or empty');
	document.all['to'].focus();
    return false;
  }
  
  /*if( !validateEmail(document.getElementById("frmemai").value)) {
    alert('from value is not vailed or empty');
	//document.getElementById("frmemai").focus();
    return false;
  }*/
  

  return true;
}
function checkFrm(){
	if( document.getElementById('company').value=="") {
    alert('you must fill in company name');
	document.contactFrm['company'].focus();
    return;
  }
  if( document.getElementById('fullname').value=="") {
    alert('you must fill in full name');
	document.contactFrm['fullname'].focus();
    return;
  }

  //jobtitle
  if( document.getElementById('jobtitle').value=="") {
    alert('you must fill in a jobtitle');
	document.contactFrm['jobtitle'].focus();
    return;
  }
  if( !validateTelepnone(document.all['phone'].value)) {
    alert('you must fill in phone number ');
	document.all['phone'].focus();
    return false;
  }
  if( !validateTelepnone(document.contactFrm['fax'].value)) {
    alert('you must fill in fax number');
	document.contactFrm['fax'].focus();
    return;
  }
  if( document.getElementById('address').value=="") {
    alert('you must fill in address name');
	document.contactFrm['address'].focus();
    return;
  }
  //city
  if( document.getElementById('city').value=="") {
    alert('you must fill in city name');
	document.contactFrm['city'].focus();
    return;
  }
  
  if(!validateEmail(document.contactFrm['email'].value)) {
    alert('e-mail address is not vaild');
	document.contactFrm['email'].focus();
    return;
  }
  
  //street
  
  //houseNum
  if( document.getElementById('intrest').value=="") {
    alert('you must select an intrest value');
	document.contactFrm['intrest'].focus();
    return;
  }
  
  document.contactFrm.submit();
  
  //phone
  /*if(document.getElementById('course').value=='')
	 {
	 	alert('אנא בחר קורס');
		return false;
		}*/ 
}