function envia(){
	form = document.forms['enquete'];
	chk = false;

	for(i=0;i<=4;i++){
		if (eval("form.resposta_" + i)){
			if (eval("form.resposta_" + i + ".checked == true")){
				chk = true;
				break;
			}
		}
	}

	if (chk == false){
		alert("Selecione uma resposta");
	} else {
		jan = window.open('about:blank','enquete','width=300,height=300;');
		form.target = "enquete";
		form.submit();
		jan.focus();
	}
}

function seleciona(id){
	form = document.forms['enquete'];
	for(i=0;i<=4;i++){
		if (eval("form.resposta_" + i)){
			if (i != id){
				eval("form.resposta_"+ i +".checked = false");
			}
		}
	}
}

if (navigator.appVersion.substring(0,1) >= 3) {
	off = new Image;
	off.src = "/imagens/off.gif";

	on = new Image;
	on.src = "/imagens/on.gif";
}

function namorados_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function ResultadoEnquete(id){
	jan = window.open('enquete.php?id_enquete='+ id +'&acao=resultado','enquete','width=300,height=180;');
	jan.focus();
}

function thebasement(id){
	jan = window.open('the_basement.htm','thebasement','width=300,height=180;');
	jan.focus();
}

function TurnImg(mode,img){
	if (document.images){
		document.images[img].src = eval(mode + ".src");
	}
}

function mOvr(src,clrOver) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}

function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}

function mClk(src,clrActive) {
	if(event.srcElement.tagName=='TD'){
		src.bgColor = clrActive;
	}
}

function envia_blog (acao){
	form = document.forms['blog'];
	if (acao == "insere"){
		erro = true;
		for(i=0;i< form.categoria.length;i++){
			if (form.categoria[i].checked == true){
				erro = false;
				break;
			}
		}
		if (form.titulo.value.length == 0){
			alert("Preencha o campo \"título\"!");
			erro = true;
		} else if (erro == true){
			alert("Selecione uma categoria para o seu blog!");
			erro = true;
		} else if (form.login.value.length < 3){
			alert("O campo \"login\" deve ter no mínimo 3 caracteres!");
			erro = true;
		} else if (form.senha.value.length < 3){
			alert("O campo \"senha\" deve ter no mínimo 3 caracteres!");
			erro = true;
		} else if (form.senha.value != form.senha1.value){
			alert("As senhas digitadas não são iguais!");
			erro = true;
		}
	}
	if (!erro) {
		form.acao.value = acao;
		form.submit();
	}
}

function publica_blog(){
	form = document.forms['blog'];
	if (form.nome.value.length == 0){
		alert("Preencha o nome de usuário!");
	} else if (form.mensagem.value.length == 0){
		alert("Preencha o campo mensagem!");
	} else {
		form.submit();
	}
}

function divulga_blog(){
	form = document.forms['blog'];
	if (form.destinatario1.value.length == 0 && form.destinatario2.value.length == 0 && form.destinatario3.value.length == 0){
		alert("Preencha o nome de pelo menos um destinatário");
	} else if (form.destinatario1.value.length != 0 && form.email1.value.length == 0){
		alert("Preencha o e-mail do primeiro destinatário!");
	} else if (form.destinatario2.value.length != 0 && form.email2.value.length == 0){
		alert("Preencha o e-mail do segundo destinatário!");
	} else if (form.destinatario3.value.length != 0 && form.email3.value.length == 0){
		alert("Preencha o e-mail do terceiro destinatário!");
	} else if (form.destinatario4.value.length != 0 && form.email4.value.length == 0){
		alert("Preencha o e-mail do quarto destinatário!");
	} else if (form.destinatario5.value.length != 0 && form.email5.value.length == 0){
		alert("Preencha o e-mail do quinto destinatário!");
	} else if (form.destinatario6.value.length != 0 && form.email6.value.length == 0){
		alert("Preencha o e-mail do sexto destinatário!");
	} else if (form.destinatario7.value.length != 0 && form.email7.value.length == 0){
		alert("Preencha o e-mail do sétimo destinatário!");
	} else if (form.destinatario8.value.length != 0 && form.email8.value.length == 0){
		alert("Preencha o e-mail do oitavo destinatário!");
	} else if (form.destinatario9.value.length != 0 && form.email9.value.length == 0){
		alert("Preencha o e-mail do nono destinatário!");
	} else {
		form.submit();
	}
}

function popup(url,wname,width,height){
	jan = window.open(url, wname, 'scrollbars=yes,width='+ width +',height='+ height);
	jan.focus()
}

function submit_webmail(){
	//jan = window.open("about:blank","webmail","scrollbars=yes,width=800,height=500");
	//document.forms['webmail'].target = "webmail";
	document.forms['webmail'].submit();
	//jan.focus();
}

function submit_indique(){
	form = document.forms[2];
	
	if (form.nome_remetente.value == 0){
		alert("Preencha o campo \"Seu nome\"");
	} else if (form.email_remetente.value == 0){
		alert("Preencha o campo \"Seu e-mail\"");
	} else if (form.nome_destinatario.value == 0){
		alert("Preencha o campo \"Nome do destinatário\"");
	} else if (form.email_destinatario.value == 0){
		alert("Preencha o campo \"e-mail do destinatário\"");
	} else {
		form.submit();
	}
}

function submit_contato(){
	form = document.forms['contato'];
	if (form.nome.value.length == 0){
		alert("Preencha o campo \"nome\"!");
		form.nome.focus();
	} else if (form.email.value.length == 0){
		alert("Preencha o campo \"e-mail\"!");
		form.email.focus();
	} else if (!isEmail(form.email.value)){
		alert("E-mail inválido!");
		form.email.focus();
	} else if (form.comentario.value.length == 0){
		alert("Preencha o campo \"comentários\"!");
		form.comentario.focus();
	} else {
		form.submit();
	}

}

function isEmail(email){
	var suportado = 0;
	EmailInv = false;
	
	if (window.RegExp) {
		var tempReg = /a/;
		if (tempReg.test("a")){
			suportado = 1;
		}
	}
	
	if (!suportado){
		if(((email.indexOf(".") <= 0) || (email.indexOf("@") <= 0)) || ((email.lastIndexOf(".") == (email.length - 1)) || (email.lastIndexOf("@") == (email.length -1)))){
			EmailInv = true;
		}
	}else{
		var tmp1 = /(@.*@)|(\.\.)|(@\.)|(^\.)/;
		var tmp2 = /^.+@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
		if(tmp1.test(email) || !tmp2.test(email)){
			EmailInv = true;
		}
	}

	if (EmailInv)
		return false;
	else
		return true;
}

function submit_busca_site(){
        form = document.forms['busca_site'];
        if (form.nome.value.length == 0 && form.categoria.selectedIndex == 0){
                alert("Preencha o nome do site e/ou selecione uma categoria!");
        } else {
                jan = window.open('about:blank','popsites','width=780,height=500');
                form.target = 'popsites';
                form.submit();
        }
}

function mapa()
{
window.open("http://www.wiseup.com.br/campanhas/pop/0304_02/index.php","wu_mapa","toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=700,height=400");
}
