// JavaScript Document

function changeStyle(id, cid){
	if (cid == 1)
		document.getElementById('menu_'+id).className = 'menu_activ';
		else
			document.getElementById('menu_'+id).className = '';
}

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) return false
	 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false
 	 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || ldot+1==lstr) return false
	 if (str.indexOf(at,(lat+1))!=-1) return false
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
	 if (str.indexOf(dot,(lat+2))==-1) return false		
	 if (str.indexOf(" ")!=-1) return false
	
	return true					
}


function checkForm(){
	var t=0;
	document.getElementById('inpNume').className = '';
	document.getElementById('inpPNume').className = '';
	document.getElementById('inpEmail').className = '';
	if (document.contact.nume.value == "") document.getElementById('inpNume').className = 'error';
		else t++;
	if (document.contact.prenume.value == "") document.getElementById('inpPNume').className = 'error';
		else t++;	
	if (!echeck(document.contact.email.value)) document.getElementById('inpEmail').className = 'error';
		else t++;
		
	if (t==3 ) document.contact.submit();
	return false;
}
