function popUpload(url, largura, altura) {
	window.open(url,'popUpload','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+largura+',height='+altura+',screenX=150,screenY=150,top=150,left=150')
}

function valida(formulario) {
	var msg = 'Por favor corrija os seguintes campos:\n';
	var tipo = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
	if (formulario.nome.value == '') {
		alert(msg+'Nome.\n');
		return false;
	}
	if (formulario.email.value == '') {
		alert(msg+'Email.\n');
		return false;
	} else if (!tipo.test(formulario.email.value)) {
		alert("Favor informar um email válido.")
		return false;
	}
	/*if (formulario.cnpjValidado.value == '') {
		alert(msg+'CNPJ / CPF.\n');
		return false;
	}*/
	if (formulario.dddTel.value == '' || formulario.tel1.value == '' || formulario.tel2.value == '') {
		alert(msg+'Telefone.\n');
		return false;
	}
	return true;
}


function ValidaAnuncio(formulario) {
	var msg = 'Por favor corrija os seguintes campos:\n';
	
	if (formulario.nome.value == '') {
		alert(msg+'Nome.\n');
		return false;
	}
	if (formulario.descricao.value == '') {
		alert(msg+'Descrição.\n');
		return false;
	}
	if (formulario.telefone.value == '') {
		alert(msg+'Telefone.\n');
		return false;
	}
	if (formulario.linkUrl.value == '') {
		alert(msg+'Link.\n');
		return false;
	}
	if (formulario.pagina.value == '') {
		alert(msg+'Página.\n');
		return false;
	}
	if (formulario.sessao.value == '') {
		alert(msg+'Sessão.\n');
		return false;
	}
	if (formulario.tipoPagamento[0].checked == '' && formulario.tipoPagamento[1].checked == '') {
		alert(msg+'Forma de Pagamento.\n');
		return false;
	}
	return true;
}

function mostraFormato(urlImg,idFormato) {
	enderecoCompleto = 'http://www.portalbarradatijuca.com.br/anuncie/anuncioFormatos/'+urlImg;
	
	//displayMala();
	document.getElementById('previewFormato').src = enderecoCompleto;
	document.getElementById('formatoEscolhido').value = idFormato;
	
	//manda o select pro index 0 caso tenha sido selecionado outro
	var obj = document.getElementById('formato');
	if(obj.options[obj.selectedIndex].index != 0) {
		document.getElementById('formato').selectedIndex = 0;
	}
}

function mostraPagamentos(tipo) {
	if (tipo == 'avista') {
		document.getElementById('cartao').style.display="none";
	} else if (tipo == 'cartao') {
		document.getElementById('cartao').style.display="block";
	}
}

