// buscar des de qualsevol pàgina
//
function buscador() {
  var t=document.buscar.text.value;
  opcions="";
  if (t.length<=2) {
    alert("Aviso:\n\nDebe indicar un texto de más de 2 caracteres.");
  }
    else { document.buscar.submit(); }
}
//
// gestió de capes/submenús
//
function mostrar(nomcapa) {
  document.getElementById(nomcapa).style.visibility="visible";
  setTimeout("amagar('"+nomcapa+"');",10000);
} 
function amagar(nomcapa)  {
  document.getElementById(nomcapa).style.visibility="hidden";
} 
//
// selecció full d'estils (mida de la font)
//
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}
//
//
function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
//
//
function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
      && a.getAttribute("rel").indexOf("alt") == -1
      && a.getAttribute("title")
      ) return a.getAttribute("title");
  }
  return null;
}
//
//
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
//
//
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
//
//
window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
//
//
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
//
//
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
//
//
// validar una data
function validardata(dia) {
  var llargada=dia.length;
  var correcte=true;
  var dia1= new String(dia);
  var anyy= new String(dia1.substring(dia1.lastIndexOf("/")+1,dia1.length))
  var mes= new String(dia1.substring(dia1.indexOf("/")+1,dia1.lastIndexOf("/")))
  var dia= new String(dia1.substring(0,dia1.indexOf("/")))
  if ((llargada>0) && (llargada<8)) { correcte=false; }
  if (isNaN(anyy) || anyy.length<4 || parseFloat(anyy)<1900) { correcte=false; }
  if (isNaN(mes) || parseFloat(mes)<1 || parseFloat(mes)>12) { correcte=false; }
  if (isNaN(dia) || parseInt(dia)<1 || parseInt(dia)>31) { correcte=false; }
  if (mes==4 || mes==6 || mes==9 || mes==11 || mes==2) {
    if (mes==2 && dia > 28 || dia>30) { correcte=false; }
  }
  if (dia=="") { correcte=true; }
  return correcte;
}
//
// obrir finestra nova amb paràmetres
function obrir(p,f,w,h) {
  parametres="width="+w+",height="+h+",scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,directories=no";
  open(p,f,parametres);
}
//
function marcarcamperror(nomcamp) {
  //alert("marcar: "+nomcamp);
  document.getElementById(nomcamp).style.background="#FFFF80";
}
function desmarcarcamperror(nomcamp) {
  //alert("desmarcar: "+nomcamp);
  document.getElementById(nomcamp).style.background="#ffffff";
}
//
//
function ocultarFilaaaa(num,ver) {
  dis= ver ? '' : 'none';
  tab=document.getElementById('taulaentrada');
  tab.getElementsByTagName('tr')[num].style.display=dis;
}
function ocultarColumnaaaa(num,ver) {
  dis= ver ? '' : 'none';
  fila=document.getElementById('taulaentrada').getElementsByTagName('tr');
  for(i=0;i<fila.length;i++)
    fila[i].getElementsByTagName('td')[num].style.display=dis;
}
//
//
function amagaelement(identificador) {
  document.getElementById(identificador).style.display="none";
}
//
//
function deixarescriure(ncamp,camp,campaltres) {
  idioma=document.getElementById('idiomatreball').value;
  if (idioma=="ca") { textavis="Per escriure en aquest camp, comproveu que el valor no estigui al desplegable anterior, cas que no estigui, seleccioneu \"altres\" del desplegable (està al final) i escriviu"; }
  if (idioma=="es") { textavis="Para escribir en este campo, comprueba que el valor no esté en el desplegable anterior, caso que no esté, selecciona \"otros\" del desplegable (está al final) y escribe"; }
  valorcamp=""+document.getElementById(camp).value+"";
  //alert(valorcamp);
  if (valorcamp=="") {
    alert(textavis);
    document.getElementById(campaltres).value="";
    return false;
  }
    else {
      if (valorcamp-0 != 0) {
        alert(textavis);
        document.getElementById(campaltres).value="";
        return false;
      }
    }
}
//
//
//
function passaparam(ii,d,m,a,sel) { //paràmetre cercar activitats agenda
	//ii=mes i any
	//d=dia
	//m=mes
	//a=any
	document.agenda.ii.value=ii;
	document.agenda.d.value=d;
	document.agenda.m.value=m;
	document.agenda.a.value=a;
	document.agenda.sel.value=sel;
	//
	document.agenda.submit();
}
//

// per a highslide ****************************************
    hs.graphicsDir = 'highslide/graphics/';
    window.onload = function() {
        hs.preloadImages(5);
    }
//
//
// per a easySlider1 ****************************************
$(document).ready(function(){	
  $("#slider").easySlider({
	auto: true,
	continuous: true 
  });
});
//



