// JavaScript Document

function submitenter(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13){
	   myfield.form.submit();
	   return false;
	   }
	else
	   return true;
}

function set_link_art(){
	document.getElementById('link').value = document.getElementById('arts').value;
}
function set_link_cat(){
	document.getElementById('link').value = document.getElementById('cats').value;
}

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("Adresa de mail invalida!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Adresa de mail invalida!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Adresa de mail invalida!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Adresa de mail invalida!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Adresa de mail invalida!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Adresa de mail invalida!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Adresa de mail invalida!")
		    return false
		 }

 		 return true					
}

function nameempty()
{
    if ( document.form1.nume.value == '' )
    {
        alert('Introduceti numele!');
        return false;
    }
	 if ( document.form1.prenume.value == '' )
    {
        alert('Introduceti prenumele!');
        return false;
    }
	 if ( document.form1.telefon.value == '' )
    {
        alert('Introduceti telefonul!');
        return false;
    }
	 if ( document.form1.mesaj.value == '' )
    {
        alert('Introduceti o adresa!');
        return false;
    }
	if ((document.form1.email.value==null)||(document.form1.email.value=="")){
		alert("Introduceti o adresa de e-mail!")
		document.form1.email.focus()
		return false
	}
	if (echeck(document.form1.email.value)==false){
		document.form1.email.value=""
		document.form1.email.focus()
		return false
	}
	
}
