function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}

function cargaContenido()
{
	var valor=document.getElementById("select_0").value;
	if(valor==0)
	{
		// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
		combo=document.getElementById("select_1");
		combo.length=0;
		var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Urtea...";
		combo.appendChild(nuevaOpcion);	combo.disabled=true;
	}
	else
	{
		ajax=nuevoAjax();
		ajax.open("GET", "select_dependientes_proceso.php?seleccionado="+valor, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				// Mientras carga elimino la opcion "Elige pais" y pongo una que dice "Cargando"
				combo=document.getElementById("select_1");
				combo.length=0;
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Kargatzen...";
				combo.appendChild(nuevaOpcion); combo.disabled=true;	
			}
			if (ajax.readyState==4)
			{ 
				document.getElementById("fila_2").innerHTML=ajax.responseText;
			} 
		}
		ajax.send(null);
	}
}

function cargaContenido2()
{
	var valor=document.getElementById("select_01").value;
	combo=document.getElementById("select_11");
	if(valor==0) {
		// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
		combo.length=0;
		var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Urtea...";
		combo.appendChild(nuevaOpcion);	combo.disabled=true;
	} else {
		ajax=nuevoAjax();
		ajax.open("GET", "select_dependientes_proceso1.php?seleccionado="+valor, true);
		ajax.onreadystatechange=function() { 
			if (ajax.readyState==1) {
				// Mientras carga elimino la opcion "Elige pais" y pongo una que dice "Cargando"
				combo.length=0;
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Kargatzen...";
				combo.appendChild(nuevaOpcion); combo.disabled=true;	
			}
			if (ajax.readyState==4) document.getElementById("fila_3").innerHTML=ajax.responseText;
		}
		ajax.send(null);
	}
}

var req;
function callback() {
	if(req.readyState == 4) {
		if(req.status == 200) {
			response = req.responseText;
			document.getElementById("calendar").innerHTML = response;
		} else alert("There was a problem retrieving the data:\n" + req.statusText);
	}
} 
function navigate(month,year) {
        var url = "calendar.php?month="+month+"&year="+year;
        if(window.XMLHttpRequest) req = new XMLHttpRequest();
        else if(window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        req.open("GET", url, true);
        req.onreadystatechange = callback;
        req.send(null);
}

var req2;
function callback2() {
	if(req2.readyState == 4) {
		if(req2.status == 200) {
			response = req2.responseText;
			document.getElementById("calendar2").innerHTML = response;
		} else alert("There was a problem retrieving the data:\n" + req2.statusText);
	}
} 
function navigate2(month,year) {
	var url = "calendar_agenda.php?month="+month+"&year="+year;
	if(window.XMLHttpRequest) req2 = new XMLHttpRequest();
	else if(window.ActiveXObject) {
			req2 = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req2.open("GET", url, true);
	req2.onreadystatechange = callback2;
	req2.send(null);
}

function cambia_pestana(x) {
	document.getElementById('cpest1').className='inactiva';
	document.getElementById('cpest2').className='inactiva';
	document.getElementById('pest1').className='pestana_cerrada';
	document.getElementById('pest2').className='pestana_cerrada';

	document.getElementById('cpest'+x).className='activa';
	document.getElementById('pest'+x).className='pestana_abierta';
}

function validaComentario() {
	if (document.getElementById('izena').value=='') {
		alert("Sartu zure izena");
		document.getElementById('izena').focus();
		return false;
	}
	if (document.getElementById('eposta').value=='') {
		alert("Sartu zure posta elektronikoa");
		document.getElementById('eposta').focus();
		return false;
	}
	return true;
}


/*===Scroll de imagenes===*/
var numElem=0;
var timerID=0;

function it(nE) {
	numElem=nE;
	x=document.getElementById("scroll_dentro");
	x.style.width=((109*numElem)+2) + "px";
	/*x=document.getElementById("galeria_ul");
	x.style.width=((83*numElem)+2) + "px";*/
}
function st() {
	/*Parar el movimiento*/
	clearTimeout(timerID);
}
function dr() {
	/*Mover a la derecha*/
	clearTimeout(timerID);
	timerID=setTimeout("dcha()", 50);
}
function di() {
	/*Mover a la izquierda*/
	clearTimeout(timerID);
	timerID=setTimeout("izda()", 50);
}
function dcha() {
	x=document.getElementById("scroll_dentro");
	if ( (109*numElem+parseInt(x.style.left)) >= 377 ) {
		x.style.left=(parseInt(x.style.left)-10) + "px";
		timerID=setTimeout("dcha()", 50);
	}
}
function izda() {
	x=document.getElementById("scroll_dentro");
	if ( parseInt(x.style.left) <= 0 ) {
		x.style.left=(parseInt(x.style.left)+10) + "px";
		timerID=setTimeout("izda()", 50);
	}
}
/*===/Scroll de imagenes===*/

function cambiagrande(img,pie,width) {
	document.getElementById('imagen_grande').src='idb/galeria/'+img;
	document.getElementById('imagen_grande').style.width=width+'px';
	document.getElementById('pie_grande').innerHTML=pie;
}

function cambiagrande2(img,pie,width) {
	document.getElementById('imagen_grande').src='idb/articulos/'+img;
	document.getElementById('imagen_grande').style.width=width+'px';
	document.getElementById('pie_grande').innerHTML=pie;
}

/*===Scroll de imagenes===*/
var numElem=0;
var timerID=0;

function it2(nE) {
	numElem=nE;
	x=document.getElementById("scroll_dentro");
	x.style.width=((109*numElem)+2) + "px";
}
function st2() {
	/*Parar el movimiento*/
	clearTimeout(timerID);
}
function dr2() {
	/*Mover a la derecha*/
	clearTimeout(timerID);
	timerID=setTimeout("dcha()", 50);
}
function di2() {
	/*Mover a la izquierda*/
	clearTimeout(timerID);
	timerID=setTimeout("izda()", 50);
}
function dcha2() {
	x=document.getElementById("scroll_dentro");
	if ( (109*numElem+parseInt(x.style.left)) >= 377 ) {
		x.style.left=(parseInt(x.style.left)-10) + "px";
		timerID=setTimeout("dcha2()", 50);
	}
}
function izda2() {
	x=document.getElementById("scroll_dentro");
	if ( parseInt(x.style.left) <= 0 ) {
		x.style.left=(parseInt(x.style.left)+10) + "px";
		timerID=setTimeout("izda2()", 50);
	}
}
/*===/Scroll de imagenes===*/

function cambiagrande(img,pie,width) {
	document.getElementById('imagen_grande').src='idb/galeria/'+img;
	document.getElementById('imagen_grande').style.width=width+'px';
	document.getElementById('pie_grande').innerHTML=pie;
}

function cambiagrande2(img,pie,width) {
	document.getElementById('imagen_grande').src='idb/articulos/'+img;
	document.getElementById('imagen_grande').style.width=width+'px';
	document.getElementById('pie_grande').innerHTML=pie;
}
