// funções javascript : agromineira
// by raphael hardt v1.0

function deletaConf(linkdel) {
	if (confirm('Tem certeza que deseja deletar este item?')) {
		location = linkdel;
	}
}
function replc(str) {
	return str.replace(/,/g, '.');
}
function obrig() { //frm, frm.campo1, nome_cpo1,frm.campo2, nome_cpo2, ...
	var i,obj,objf,a=obrig.arguments;
	var x = "";
	
	for (i=1;i<(a.length-1);i+=2) {
		//obj=document.getElementById(a[i]);
		obj=a[i];
		if (obj) {
			if (obj.type=="file" || obj.type=="textarea") { if (obj.value=="") {x+="\""+a[i+1]+"\"\n"; if (!objf) objf=obj;} }
			if (obj.type=="text") { 
				if (obj.lang=="nm" ) {if (replc(obj.value)==0) {x+="\""+a[i+1]+"\"\n"; if (!objf) objf=obj;}} else {if (obj.value=="") {x+="\""+a[i+1]+"\"\n"; if (!objf) objf=obj;}} }
			if (obj.type=="checkbox") { if (obj.checked==false) {x+="\""+a[i+1]+"\"\n"; if (!objf) objf=obj;}}
			if (obj.type=="radio" || obj.type=="select") { if (obj.value==0) {x+="\""+a[i+1]+"\"\n"; if (!objf) objf=obj;}}
		}
	}
	if (x) { alert("Preencha os campos obrigatorios:\n\n"+x); objf.focus(); return false; } else { return true; }
}

function conta(obj, span) {
	document.getElementById(span).innerHTML = obj.value.length;
}

function verifChars(obj, maxc) {
	var d=document;
	if (obj.value.length>maxc) {
		alert("O campo texto ultrapassou o limite de caracteres!");
		obj.focus();
		return false;
	} else {
		return obrig(d.frm, d.frm.nome, 'Nome', d.frm.email, 'E-mail', d.frm.assunto, 'Assunto', d.frm.texto, 'Mensagem');
	}
}