// JavaScript Document
function cambiaFondo(elem, p){
	if(p==1){
document.getElementById(elem.id).className='lblMenuOn';
	}else{
document.getElementById(elem.id).className='lblMenuOff'		
	}
}
function ira(elem){
	document.location.href='?option='+elem.id;
}
function abremail(){
	document.location.href='mailto:filc@campinabaja.com';
}
function cambiaclass(elem, p){
	if(p==1){
document.getElementById(elem.id).className='lblNoticiasOn';
	}else{
document.getElementById(elem.id).className='lblNoticiasOff'		
	}
}
function muestraNoticia(idNoticia){

if(location.href.indexOf('noticias')==-1){
	location.href='?option=noticias&idNoticia='+idNoticia;
}else{
	dadatos(idNoticia);
}

}
function muestraPrensa(idNoticia){
if(location.href.indexOf('prensa')==-1){
	location.href='?option=prensa&idNoticia='+idNoticia;
}else{
	daprensa(idNoticia);
}

}
function dadatos(idNoticia){
	var aleatorio=Math.random();
document.getElementById('textoNoticia').innerHTML="<div align='center'><img src='../images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='antetituloPortada'>Cargando informaci&oacute;n...</span></div>";
ajax=nuevoAjax(); 
ajax.open("GET", "damenoticia.php?idNoticia="+idNoticia+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
	devuelto=ajax.responseText.split("|");
    document.getElementById('tituloNoticia').innerHTML=devuelto[0];
	document.getElementById('textoNoticia').innerHTML=devuelto[1];
	document.getElementById('imagenNoticia').innerHTML=devuelto[2];
   } 
} 
ajax.send(null) 
} 
function daprensa(idNoticia){
	var aleatorio=Math.random();
document.getElementById('textoNoticia').innerHTML="<div align='center'><img src='../images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='antetituloPortada'>Cargando informaci&oacute;n...</span></div>";
ajax=nuevoAjax(); 
ajax.open("GET", "dameprensa.php?idNoticia="+idNoticia+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
	devuelto=ajax.responseText.split("|");
    document.getElementById('tituloNoticia').innerHTML=devuelto[0];
	document.getElementById('textoNoticia').innerHTML=devuelto[1];
	document.getElementById('imagenNoticia').innerHTML=devuelto[2];
   } 
} 
ajax.send(null) 
} 
function nuevoAjax(){ 
  var xmlhttp=false; 
  try { 
   // Creación del objeto ajax para navegadores diferentes a Explorer 
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch (e) { 
   // o bien 
   try { 
     // Creación del objet ajax para Explorer 
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { 
     xmlhttp = false; 
   } 
  } 

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
   xmlhttp = new XMLHttpRequest(); 
  } 
  return xmlhttp; 
} 
function addComponente(){
	if((document.getElementById('Componentes_nombre').value=="")||(document.getElementById('Componentes_instrumento').value=="")){
		alert ("introduce el nombre y el instrumento del componente");
		return;
	}
document.getElementById('componentes').innerHTML+="<img src=\"admin/images/del.png\" alt=\"Quitar Componente\" onclick=\"quitarComponente('"+document.getElementById('Componentes_nombre').value+" - "+document.getElementById('Componentes_instrumento').value+"');\" />"+document.getElementById('Componentes_nombre').value+" - "+document.getElementById('Componentes_instrumento').value+"<br /> ";
document.getElementById('Componentes_nombre').value="";
document.getElementById('Componentes_instrumento').value="";
document.getElementById('Componentes_nombre').focus();
}
function quitarComponente(compo){
//alert(compo);
var nuevoValor="";
valorInicio=document.getElementById('componentes').innerHTML.split("<BR>");
for (i=0;i<valorInicio.length-1;i++){ 
    if (valorInicio[i].indexOf(compo)==-1){
		nuevoValor+=valorInicio[i]+"<BR>";
	}
} 
document.getElementById('componentes').innerHTML=nuevoValor;
}

function MM_validateForm() { //v4.0
//sacar a los compnentes
Componentes=document.getElementById('componentes').innerHTML;
Componentes=Componentes.replace('<BR>',' - ');
Componentes=Componentes.replace('<br />',' - ');
Componentes=Componentes.replace(/<[^>]+>/g,'');
document.getElementById('Componentes').value=Componentes;
  
if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	if (!document.getElementById('acepto').checked){
							  errors='- Debes haber leido y aceptar las bases del festival.\n';
							  }
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(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+' debe ser una dirección de correo electrónico.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' debe ser un número.\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+' es necesario.\n'; }
    } if (errors) {alert('Se han encontrado los siguientes errores:\n'+errors);
    document.MM_returnValue = (errors == '');
  }else{ document.form1.submit();}
} }
function cargatemas(idGrupo){
	document.getElementById('centrada').style.visibility="visible";
	var aleatorio=Math.random();
document.getElementById('centrada').innerHTML="<div align='center'><img src='../images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='txtTitulo'>Cargando informaci&oacute;n...</span></div>";
ajax=nuevoAjax(); 
ajax.open("GET", "dametemas.php?idGrupo="+idGrupo+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
    document.getElementById('centrada').innerHTML=ajax.responseText;
	   } 
} 
ajax.send(null) 
} 
function cierradiv(elem){
		document.getElementById('centrada').style.visibility="hidden";
}