<!-- funciones comunes -->

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

var bw=new lib_bwcheck()

function fechahoy() {
  var diasemana = new Array('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado');
  var nombremes = new Array('enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre');
  var ahora;
  var fecha = new Date();
  var anio = fecha.getYear();
  var mes = fecha.getMonth();
  var dia = fecha.getDay();
  var num = fecha.getDate();
  if (anio < 2000) anio += 1900;
  ahora = diasemana[dia] + ", " + num + " de " + nombremes[mes] + " de " + anio;
  return ahora;
}



/*
function cabecera() {
document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#002E7C">  <tr>    <td background="../img/logo_fn.gif"><img border="0" src="img/nada.gif" width="15" height="1"></td>    <td background="../img/logo_fn.gif" align="center"><a href="http://www.mapya.es"><img border="0" src="img/logo_lg2.gif" width="82" height="68" hspace="15"></a></td>    <td background="../img/logo_fn.gif"><img border="0" src="img/logo_lg1.gif" width="340" height="68"></td>    <td valign="bottom" background="../img/logo_fn2.gif">    <img border="0" src="img/logo_fr.gif" width="28" height="67"></td>    <td align="left" valign="bottom" background="../img/logo_fn2.gif">    <table border="0" cellpadding="0" cellspacing="0" background="../img/logo_fn3.gif">	<form ACTION="../../../indexa/pag1.asp" METHOD="POST" onsubmit="return Valida(this)">        <tr>        <td><font face="Verdana" color="#FFFFFF" size="1">buscador</font></td>        <td>        <img border="0" src="img/nada.gif" width="10" height="1"></td>        <td class="buscador">        <input type="text" name="SearchString" size="10" class="buscador"></td>        <td>        <img border="0" src="img/nada.gif" width="10" height="1"></td>        <td>        <input type="image" name="buscar" border="0" src="/gs_web/img/lupa2.gif" width="21" height="16"></td>        <td>        <img border="0" src="img/nada.gif" width="1" height="1"></td>        </tr>    	</form>        <tr>        <td colspan="6"><img border="0" src="img/nada.gif" width="1" height="10"></td>      </tr>    </table>    </td>    <td align="left" valign="bottom" background="../img/logo_fn2.gif"><img border="0" src="img/nada.gif" width="1" height="1"></td>  </tr></table>');}
*/



function cabecera() {
	
    fecha = fechahoy();
	if(fecha){fecha= 'M.A.P.A. '+ fecha} else {fecha=''}
	var parte = '<table border="0"  cellpadding="0" cellspacing="0" bgcolor="#2F312C" width="100%" height="80"><tr><td rowspan="2"><img height="1" width="30" src="img/nada.gif"></img></td><td rowspan="2" ><a href="http://www.mapya.es"><img border="0" height="70" width="396" src="img/escudo1.gif"></img></a></td><td colspan="7" height="64"><div class="fecha1" valign="bottom">' + fecha + '</div></td></tr><tr><td height="16" colspan="11"></td></tr></table>'				
	
	document.write(parte);
    return parte;
}


function nueva(url,Id,ancho,alto) 
{ 
var opciones="left=50,top=50,width="+ancho+",height="+alto
i= 0; 
var ventanas = new Array();

ventanas[0]=0;
ventanas[1]=0;
ventanas[2]=0;

for (i=0;i<2;i++)
{
	if (ventanas[i]==1){eval('mi_ventana1'+i).close();}
	}

if(Id==0)	{
	ventanas[0] = 1;
	graf0 = window.open(url,'grafico',opciones); 
	graf0.focus();
 	}
else if(Id==1)	{
	ventanas[1] = 1; 
	graf1 = window.open(url,'grafico',opciones); 
	graf1.focus();
 	}
else if(Id==2)	{
	ventanas[2] = 1; 
	graf2 = window.open(url,'grafico',opciones); 
	graf2.focus();
 	}	
}



function Valida(formulario) 
{ var checkStrg = formulario.SearchString.value; 
  if (formulario.SearchString.value == "")  {
    alert("Escriba un valor");
    formulario.SearchString.focus();
    return (false);
  }

  if (checkStrg.length < 3)  {
    alert("La consulta debe tener mas de 2 letras.");
    formulario.SearchString.focus();
    return (false);
  }
  return (true);
}

function pie() {
document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr height="20"><td width="20"></td><td height="20"><img height="2" width="2" src="img/separador.gif"></td><td width="6" height="20"><img height="2" width="2" src="img/separador.gif"></td><td height="20"><img height="2" width="2" src="img/separador.gif"></td><td height="20"><img height="2" width="2" src="img/separador.gif"></td></tr><tr><td width="0"></td><td valign="middle"><img src="img/escudo.gif" width="39" height="31" border="0"></td><td class="fondoceldas" width="6"><img height="2" width="2" src="../../../../../../../web/comunes/pesca1/comunes/img/separador.gif"></td><td><img src="img/separador.gif" width="5" height="2" border="0"></td> <td class="cuerpo8"><span class="cuerpo8"><a href="http://www.mapya.es" class="cuerpo8">P&aacute;gina principal | </a><a href="http://www.mapya.es/notas/listanotas.asp" class="cuerpo8"> &Uacute;ltima noticia |</a><a href="http://www.mapya.es/biblioteca/abwebp.exe" class="cuerpo8">Bibliotecas del M.A.P.A. |</a><a href="http://w4.mapya.es/tiendamapya/iniciotienda.jsp" class="cuerpo8">Tienda virtual |</a><a href="http://enesa.mapya.es/pls/enesa/pwe" class="cuerpo8">E.N.E.S.A. |</a><a href="http://from.mapya.es" class="cuerpo8">F.R.O.M. |</a><a href="http://www-fega.mapya.es:2560/pags/fg_inicio.htm" class="cuerpo8">F.E.G.A. |</a><a href="http://www.mapya.es/aao/default.htm" class="cuerpo8"> A.A.O. |</a><a href="http://www.mapya.es/info/pags/correo/correo1.htm" class="cuerpo8"> Sugerencias y preguntas</a></span></td></tr></table><p align="center"><font face="Verdana" size="1"><span class="cuerpo8">&copy; Ministerio de Agricultura, Pesca y Alimentaci&oacute;n 2003</span></font></p><p></p></td></tr>');
}



function enciende(obj){
	if(bw.ns4!=1){

var obj1= obj + obj ;

	document.getElementById(obj).style.backgroundColor="#9A9381";
	document.getElementById(obj1).style.backgroundColor="#9A9381";


}
}


function apaga(obj){
	if(bw.ns4!=1){

var obj1= obj + obj ;

	document.getElementById(obj).style.backgroundColor="#FFFFFF";
	document.getElementById(obj1).style.backgroundColor="#FFFFFF";

}
}

// funcion para abrir ventanas PARAMETROS:nombre de la pagina, ancho de la ventana, alto de la ventana
function abreVentana(pag,ancho, alto)
{
	if (ventana!=null)
	{
		ventana.close();
	}
	ventana = window.open(pag,"ventana","toolbar=no,status=no,resizable=no,scrollbars=no,width=" + ancho + ",height= " + alto + ",top=50,left=50");
	ventana.focus();
}


