// Detecta se é o IE porque o .focus() não funciona no Firefox
var detect = navigator.userAgent.toLowerCase();

function redirect(url){ 
	window.location = url;
}

function validarPesquisa(){
	if (window.formPesquisa.tfPesquisa.value == ""){
		if(detect.indexOf('msie')+1>0){window.formPesquisa.tfPesquisa.focus();}
		return false;
	}
}

function validarNewsletter(){
	if (window.formNewsletter.tfEMail.value == ""){
		if(detect.indexOf('msie')+1>0){window.formNewsletter.tfEMail.focus();}
		return false;
	}
}

function validarInscricaoSeminario() {

    var seleccionado = false;
    var radios = document.getElementsByName("rbSocio");
    for (var i = 0; i < radios.length; i++) {
        if (radios[i].checked) {
            seleccionado = true;
        }
    }
    if (!seleccionado) {
        alert("Campo 'SÃ³cio' Ã© de preenchimento obrigatÃ³rio.");
        return false;
    }

	if (window.formSeminarioSend.tfNome.value == ""){
		if(detect.indexOf('msie')+1>0){
			window.formSeminarioSend.tfNome.focus();
			alert("Campo 'Nome' Ã© de preenchimento obrigatÃ³rio.");
		}
		return false;
	}
	if (window.formSeminarioSend.tfContacto.value == ""){
		if(detect.indexOf('msie')+1>0){
			window.formSeminarioSend.tfContacto.focus();
			alert("Campo 'Telefone' Ã© de preenchimento obrigatÃ³rio.");
		}
		return false;
    }
	if (window.formSeminarioSend.tfEmail.value == ""){
		if(detect.indexOf('msie')+1>0){
			window.formSeminarioSend.tfEmail.focus();
			alert("Campo 'E-mail' Ã© de preenchimento obrigatÃ³rio.");
		}
		return false;
	}

    seleccionado = false;
    var checkbox = document.getElementsByName("cbSeminario");
    for (var i = 0; i < checkbox.length; i++) {
        if (checkbox[i].checked) {
            seleccionado = true;
        }
    }
    if (!seleccionado) {
        alert("DeverÃ¡ seleccionar pelo menos um seminÃ¡rio.");
        return false;
    }
}

function validarPesquisaDirectorioLateral()
{
	if (document.getElementById("tfDirectorio").value == ""){
		document.getElementById("tfDirectorio").focus();
		return false;
	}
}

function validarPesquisaDirectorioPAILateral()
{
	if (document.getElementById("tfDirectorioPAI").value == ""){
		document.getElementById("tfDirectorioPAI").focus();
		return false;
	}
}

function openPopup(path, popup, param, w, h){
	OpenWin = window.open("/popup/"+path+"/"+popup+".asp?"+param,"popup","left=370,top=100,height="+h+",width="+w+",toolbar=no,menubar=no,location=no,scrollbars =yes,resize=yes");
	//OpenWin = window.showModalDialog("inc/"+path+"/popup/"+popup+".asp","Clientes","dialogHeight: 400px; dialogWidth: 600px; dialogTop: 100px; dialogLeft: 370px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
	OpenWin.focus();
}


function expand(elemento)
{
	if(elemento.className == "hide")
	{
		elemento.className = "show";
	}
	else
	{
		elemento.className = "hide";
	}
}

function expandNoticia(noticia, imagem)
{
	if(document.getElementById(noticia).className == "hide")
	{
		document.getElementById(noticia).className = "show";
		document.getElementById(imagem).src = "/imagens/Icon-Menos.gif"
	}
	else
	{
		document.getElementById(noticia).className = "hide";
		document.getElementById(imagem).src = "/imagens/Icon-Mais.gif"
	}
}

