function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  // alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		  //  alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		  //  alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		  //  alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		  //  alert("Invalid E-mail ID")
		    return false
		 }
		 if (ldot==lstr-1){
			return false
		 }

 		 return true					
	}

function checkForm()
{
	if(!document.getElementById('nume').value)
	{
		alert('Va rugam completati numele dvs!');
		return false;
	}
	if(!isValidEmail(document.getElementById('email').value))
	{
		alert('Adresa de email nu este valida!');
		return false;
	}
	return true;
}
function isValidEmail(str){

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
function checkSendToFriendForm()
{
	if(!document.getElementById('name').value)
	{
		alert('Va rugam introduceti numele!');
		return false;
	}
	if(!document.getElementById('surname').value)
	{
		alert('Va rugam introduceti prenumele');
		return false;
	}
	if(!document.getElementById('cnp').value)
	{
		alert('Va rugam introduceti CNP-ul');
		return false;
	}
	if(!isValidEmail(document.getElementById('email_inreg').value))
	{
		alert('Adresa de email nu este valida!');
		return false;
	}
	return true;
}
 /*
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}

function isValidEmail(address) {
   var reg = /^[^@]+@[^@]+.[a-z]{2,}$/i;
   //var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {
      
      return false;
   }else{
	return true;
   }
}*/
function isValidEmailsr(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
function IsNumeric(value) {
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
}

function checktheForm()
{
	//var emailID=document.frmSample.txtEmail
	if(!document.getElementById('name').value)
	{
		alert('Va rugam introduceti numele');
		return false;
	}
	if(!document.getElementById('surname').value)
	{
		alert('Va rugam introduceti prenumele');
		return false;
	}
	if(!document.getElementById('cnp').value)
	{
		alert('Va rugam introduceti CNP-ul');
		return false;
	}
	if(!document.getElementById('cnp').value)
	{
		alert('Campul "CNP" este obligatoriu!');
		return false;
	}
	if(!IsNumeric(document.getElementById('cnp').value))
	{
		alert('Campul "CNP" trebuie sa contina numai cifre!');
		return false;
	}
	if(echeck(document.getElementById('email_inreg').value)==false)
	{
		alert('Adresa de email nu este valida!');
		return false;
	}

	if(!document.getElementById('phone').value)
	{
		alert('Va rugam introduceti numarul de telefon');
		return false;
	}
	if(!IsNumeric(document.getElementById('phone').value))
	{
		alert('Campul "Telefon" trebuie sa contina numai cifre!');
		return false;
	}
	if(!document.getElementById('phone').value)
	{
		alert('Campul "Telefon" este obligatoriu!');
		return false;
	}
	if(document.getElementById('state').value=='-1')
	{
		alert('Va rugam introduceti Judetul/Sectorul');
		return false;
	}
	if(!document.getElementById('city').value)
	{
		alert('Va rugam introduceti orasul de livrare');
		return false;
	}
	if(!document.getElementById('address').value)
	{
		alert('Va rugam introduceti adresa de livrare');
		return false;
	}
	
	if(!IsNumeric(document.getElementById('zip_code').value))
	{
		alert('Campul "Cod postal" trebuie sa contina numai cifre!');
		return false;
	}
	if(document.getElementById('zip_code').value.length>0 && document.getElementById('zip_code').value.length!=6)
	{
		alert('Codul postal trebuie sa fie compus din 6 cifre!');
		return false;
	}
	if(!document.getElementById('over18').checked)
	{
		alert('Trebuie sa aveti peste 18 ani pentru a putea lansa o comanda!');
		return false;
	}
	return true;
}