function filtra(){
    document.getElementById("formFiltre").submit();
}

function filtraArticles(){
    document.getElementById("formFiltreArticles").submit();
}	
function envia(){
    document.getElementById("formEnviar").submit();
}	
function buscar(){
    document.getElementById("formBuscar").submit();
}
function comentar(){
    document.getElementById("formComentar").submit();
}
function resultats(){
    document.getElementById("content").value=document.getElementById("selectCategoria").value;
    document.getElementById("formCategories").submit();
}
function selectCategory(nCategory,blnLlistat){
    document.getElementById("contentCategoria").value=nCategory;
    if(blnLlistat)
	    document.getElementById("llistat").value=nCategory;
    document.getElementById("formFiltreCategories").submit();
}

function filtraCategories(){
    document.getElementById("formFiltreCategories").submit();
}

function doAnunciar(){
    document.getElementById("formFerAnunci").submit();
}

function replica(codi,pos){
    document.getElementById("afercomentari").focus();
    document.getElementById("nom_comentari").focus();
    comentaris=(document.getElementsByName("divAutor")[pos]).innerHTML;
    var moment=(document.getElementsByName("txtData")[pos]).innerHTML;
    var hora=(document.getElementsByName("txtHora")[pos]).innerHTML;
    document.getElementById("respostade").innerHTML=" en resposta al d'en " + comentaris + " del " + moment + " a les " + hora;
    document.getElementById("replica").value=codi;
}	
function vota(){
    var resposta=0;
    if(document.getElementById("frmEnquesta").opcioEnquesta[0]!=null && document.getElementById("frmEnquesta").opcioEnquesta[0].checked)
	resposta=1;
    if(document.getElementById("frmEnquesta").opcioEnquesta[1]!=null && document.getElementById("frmEnquesta").opcioEnquesta[1].checked)
	resposta=2;
    if(document.getElementById("frmEnquesta").opcioEnquesta[2]!=null && document.getElementById("frmEnquesta").opcioEnquesta[2].checked)
	resposta=3;
    if(document.getElementById("frmEnquesta").opcioEnquesta[3]!=null && document.getElementById("frmEnquesta").opcioEnquesta[3].checked)
	resposta=4;
    if(document.getElementById("frmEnquesta").opcioEnquesta[4]!=null && document.getElementById("frmEnquesta").opcioEnquesta[4].checked)
	resposta=5;
    if(document.getElementById("frmEnquesta").opcioEnquesta[5]!=null && document.getElementById("frmEnquesta").opcioEnquesta[5].checked)
	resposta=6;

    if(resposta==0)
	alert('Cal seleccionar alguna resposta !');
    else  	
	document.getElementById("frmEnquesta").submit();
}

function abreVentanaOrigen(url)
 { 
   var ventanaor
   ventanaor = window.open(url,'segundoBrowser','titlebar=0,location=0,resizable=0,scrollbars=auto,hotkeys=0,width=600,height=650,top=0,left=0');
 }

function abreVentanaOrigenSize(url, width, height)
 { 
   var ventanaor
   ventanaor = window.open(url,'segundoBrowser','titlebar=0,location=0,resizable=0,scrollbars=0,hotkeys=0,width=' + width + ',height=' + height + ',top=0,left=0');
 }	 

function ocultamenu(){
    var menu = document.getElementById("seccions");
    menu.style.display = "none";
}

function despliega(){
    var menu = document.getElementById("seccions");
    menu.style.display=(menu.style.display!="block")?"block":"none";
}

function enviarContacte(){
    if(""==document.getElementById("contacteNom").value){
	alert('Hauries d\'especificar el teu nom !');
	document.getElementById("contacteNom").setFocus();
    }else if(""==document.getElementById("contacteEmail").value){
	alert('Hauries d\'especificar la teva adreça de correu electrònic !');
	document.getElementById("contacteEmail").focus();
    }else
	document.getElementById("formContacteElements").submit();
}

if(typeof(Shadowbox)!="undefined"){
    Shadowbox.loadSkin('classic', '../../js/shadowbox/skin');
    Shadowbox.loadPlayer(['html'], '../../js/shadowbox');
}

function initPortal(){
    if(typeof(Shadowbox)!="undefined")
        Shadowbox.init();
}


function addEvent2(obj, evType, fn, useCapture){
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    }
    else {
        alert("No es pot carregar addEvent:" + fn );
        window.onload=useCapture;
        return false;
    }
}

addEvent2(window, 'load', initPortal);