// JavaScript Document
var  $D = function(id) 
{
	return document.getElementById(id);
}

function valida()
{
		var retorno = '0';
		retorno += abreDiv('nome');
		//retorno += abreDiv('endereco');
		//retorno += abreDiv('complemento');
		//retorno += abreDiv('numero');
		//retorno += abreDiv('cidade');
		//retorno += abreDiv('cep');
		//retorno += abreDiv('uf');
		//retorno += abreDiv('tel');
		//retorno += abreDiv('cel');
		retorno += abreDiv('email');
		//retorno += abreDiv('conheceu');
		//retorno += abreDiv('descricao');
		//alert(retorno);
		if(retorno!='0')
		{
			return false;	
		}
}
function abreDiv(id)
{
	if($D(id).value=='')
	{
		$D('divValida['+id+']').style.display = '';
		$D(id).focus();
		return 1;
	}else
	{
		$D('divValida['+id+']').style.display = 'none';
		return '';
	}
}

function validaEmail(id)
{
	if($D(id).value!='')
	{
		$D('divValida[email]').style.display = 'none';
		var email = $D(id).value;
		if(email.indexOf("@")==-1 || email.indexOf(".")==-1)
		{	
			$D('divValida[emailCorreto]').style.display = '';
			$D(id).focus();
			return false;
		}
		
	}
}




function mudaDDD(id,nextId)
{
	var ddd = $D(id).value;
	if(ddd.length == 2)
	{
		$D(nextId).focus();
	}
}

function mudaTel(id,nextId)
{
	var tel = $D(id).value;
	if(tel.length == 4)
	{
		$D(id).value = tel+'-';
	}
	else if(tel.length == 9)
	{
			$D(nextId).focus();
	}
}


function limpaForm()
{
	document.form1.reset();	
}

