function abreAlert(texto)
{
  document.getElementById("mensaje_alert").innerHTML = texto; 
  document.getElementById("fondo_semi").style.display = "block";
  document.getElementById("ma_content").style.display = "block";
  ocultaSelects();
  window.location.href = "#";
}

function cierraAlert()
{
  document.getElementById("fondo_semi").style.display = 'none';
  document.getElementById("ma_content").style.display = 'none';
  ocultaSelects();
  if(document.getElementById("flash_udt_f"))
  {
    document.getElementById("flash_udt_f").style.visibility = "visible";
  }
}

function ocultaSelects()
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    var the_inputs = document.getElementsByTagName("select");
    var the_textfields = new Array();

    for(var n=0; n<the_inputs.length; n++)
    {
      if(the_inputs[n].style.visibility == "visible" || the_inputs[n].style.visibility == "")
      {
        the_inputs[n].style.visibility = "hidden";
      }
      else
      {
        the_inputs[n].style.visibility = "visible";
      }
    }
  }
}


function buscar()
{
	//var formu = document.formBuscador;
	var formu = document.getElementById("formBuscador");
	if ( formu.categbuscador.options[formu.categbuscador.selectedIndex].value == "?" )
	{
		alert( "Debe de seleccionar una categoría sobre la que se realizará la búsqueda." );
		formu.categbuscador.focus();
		return false;
	}
	if ( formu.txtbuscador.value == "" )
	{
		alert( "Debe de escribir el contenido que desea buscar." );
		formu.txtbuscador.focus();
		return false;
	}
	return true;
}

function abrir( htmlfile, nombre, wndWidth, wndHeight, barrascroll, resizable )
{	
  	var popWnd; //Objeto ventana de popup
	var maxWidth = screen.width-10;
	var maxHeight = screen.height-56;

	//Preprocesado de parametros
	if ( wndHeight == 0 ) wndHeight = maxHeight;
	if ( wndWidth == 0 ) wndWidth = maxWidth;

	//Calculo de la posicion para centrar la ventana
	var posX = maxWidth/2 - wndWidth/2;
	var posY = maxHeight/2 - wndHeight/2;

	if (popWnd) popWnd.close();
	var popWnd = open(htmlfile, nombre, 'resizable=' + resizable + ',toolbar=0,scrollbars=' + barrascroll + ',location=0,directories=0,status=0,menubar=0,width='+wndWidth+',height='+wndHeight+',screenX=0,screenY=0,left='+posX+',top='+posY);
	popWnd.focus();
}

function abrirRegulacionComiteIntercentros( id )
{
	var htmlfile = "_content/comiteintercentros.php?id=" + id;
	abrir( htmlfile, 'comiteintercentros', 600, 400, 1, 1 );
}

function imprimirNoticia( id )
{
	var htmlfile = "imprimir-noticia.php?id=" + id;
	abrir( htmlfile, 'imprimirnoticia', 800, 600, 1, 1 );
}

function enviarAmigo()
{
	var htmlfile = "enviar-amigo.php?url=" + escape( location.href );
	abrir( htmlfile, 'enviaramigo', 549, 622, 1, 0 );
}

function checkFormAfiliate( formName )
{
	var formu = eval( "document." + formName );
	if ( formu.nombre.value == "" )
	{
		alert( "Debe de rellenar el campo nombre." );
		formu.nombre.focus();
		return false;
	}
	if ( formu.apellidos.value == "" )
	{
		alert( "Debe de rellenar el campo apellidos." );
		formu.apellidos.focus();
		return false;
	}
	if ( formu.provincia.value == "" )
	{
		alert( "Debe de rellenar el campo provincia." );
		formu.provincia.focus();
		return false;
	}
	if ( formu.telefono.value == "" )
	{
		alert( "Debe de rellenar el campo teléfono." );
		formu.telefono.focus();
		return false;
	}
	return true;	
}

function verFotoGrande( i, f, t, pieFoto )
{
	//abrir( "verfotogr.php?i=" + i + "&f=" + f + "&t=" + t, 'fotogr', 1050, 810, 1, 1 );
	abreAlert( "<img width=\"800\" height=\"600\" style=\"padding-bottom:4px;\" src=\"verfotogr.php?i=" + i + "&f=" + f + "&t=" + t + "\" /><br />" + pieFoto );
}