var auid, categorie, inmatriculare;
function auto_menu_toogle (id) {
	if (auid==id) {
		document.getElementById("inmatriculare_"+auid).style.display="none";
		auid=0;
	}
	else {
		if (auid) {
			document.getElementById("inmatriculare_"+auid).style.display="none";
		}
		document.getElementById("inmatriculare_"+id).style.display="block";
		auid=id;
	}
}

function adauga_auto (categorie,inmatriculare) {
	if (categorie==1 || categorie==2 || categorie==3 || categorie==4 || categorie==5 || categorie==6) {
		document.add_auto.action="adauga.php?page=auto&categ="+categorie+"&inmatr="+inmatriculare;
		if (document.getElementById('marca').value=='0') document.getElementById('formansw').innerHTML='Marca trebuie selectata!';
		else if (document.getElementById('tipul').value=='') document.getElementById('formansw').innerHTML='Campul pentru tip trebuie completat!';
		else if (categorie!=3 && document.getElementById('carburatie').value=='0') document.getElementById('formansw').innerHTML='Tipul de carburatie trebuie selectat!';
		else if (document.getElementById('culoare').value=='') document.getElementById('formansw').innerHTML='Campul pentru culoare trebuie completat!';
		else if (document.getElementById('capacitate').value=='') document.getElementById('formansw').innerHTML='Campul pentru capacitate trebuie completat!';
		else if (document.getElementById('an_fabricatie').value=='0') document.getElementById('formansw').innerHTML='Anul fabricatiei trebuie selectat!';
		else if (document.getElementById('rulaj').value=='') document.getElementById('formansw').innerHTML='Campul pentru kilometri parcursi trebuie completat!';
		else if (document.getElementById('pret').value=='') document.getElementById('formansw').innerHTML='Pretul de vanzare trebuie specificat!';
		else if (inmatriculare==2 || inmatriculare==3) {
				if (document.getElementById('primainmatriculare_luna').value=='0') document.getElementById('formansw').innerHTML='Luna primei inmatriculari trebuie selectata!';
				else if (document.getElementById('primainmatriculare_an').value=='0') document.getElementById('formansw').innerHTML='Anul primei inmatriculari trebuie selectat!';
				else if (inmatriculare==3) {
					if (document.getElementById('rate_ramase').value=='') document.getElementById('formansw').innerHTML='Numarul de rate ramase trebuie mentionate!';
					else if (document.getElementById('rata').value=='') document.getElementById('formansw').innerHTML='Campul pentru rate/luna trebuie completat!';
					else if (document.getElementById('val_reziduala').value=='') document.getElementById('formansw').innerHTML='Valoarea reziduala trebuie mentionata!';
					else document.add_auto.submit();
				}
				else document.add_auto.submit();
			}
		else document.add_auto.submit();
	}
}
