function redirectSearch(page){
	var url = window.location.href;
  if (top.frames.length < 1){
    top.location =  'http://www.ayuntamientolazubia.com/lazubia/interna.jsp?url='+page;
	}
}

function autofitIframe(id)
{
	if (!window.opera && !document.mimeType && document.all && document.getElementById)
		{
		var x=this.document.body.offsetHeight;
		x=x+20;
		x=x+"px";
		parent.document.getElementById(id).style.height=x;
		parent.document.getElementById('leftcolInt').style.height=x;
	}
	else if(document.getElementById) 
	{
		if (navigator.appVersion.indexOf("Win")!=-1)
			{
			var x=this.document.body.scrollHeight;
			x=x+5;
			if(x<650){
				x=650;
				}
			x=x+"px";
			parent.document.getElementById(id).style.height=x;
			parent.document.getElementById('leftcolInt').style.height=x;
			}
		else
			{
			var x=this.document.body.scrollHeight;
			x=x+10;
			if(x<650){
				x=650;
				}
			x=x+"px";
			parent.document.getElementById(id).style.height=x;
			parent.document.getElementById('leftcolInt').style.height=x;
			}
	}
}

function autofitIframeIndex(id)
{
	if (!window.opera && !document.mimeType && document.all && document.getElementById)
		{
		var x=this.document.body.offsetHeight;
		x=x+20;
		x=x+"px";
		parent.document.getElementById(id).style.height=x;
		parent.document.getElementById('leftcol').style.height=x;
		parent.document.getElementById('rightcol').style.height=x;
	}
	else if(document.getElementById) 
	{
		if (navigator.appVersion.indexOf("Win")!=-1)
			{
			var y=this.document.body.scrollHeight;
			x=y+5;
			x=x+"px";
			parent.document.getElementById(id).style.height=x;
			
			y=y+120;
			y=y+"px";
			parent.document.getElementById('leftcol').style.height=y;
			parent.document.getElementById('rightcol').style.height=y;
			}
		else
			{
			var y=this.document.body.scrollHeight;
			x=y+10;
			x=x+"px";
			parent.document.getElementById(id).style.height=x;
			
			y=y+120;
			y=y+"px";
			parent.document.getElementById('leftcol').style.height=y;
			parent.document.getElementById('rightcol').style.height=y;
			}
	}
}

function autoIframe(){ 
	var x = 0;
	
	///////////// reset iframe size for Opera //////////////
	if(navigator.userAgent.indexOf("Opera")!=-1){
	this.document.body.scrollHeight = this.document.body.offsetHeight
	}
	/////////////////////IE, Opera///////////////////////////////
	var y = this.document.body.scrollHeight;
	while (x < y){
		x+=1;
	}
	parent.document.getElementById("cuerpo").style.height = x
	
	///////////////////// Firefox //////////////////////////////
	if(navigator.userAgent.indexOf("Firefox")!=-1){
	parent.ifrm.frameElement.height = this.document.body.scrollHeight+5;
	}
}

function oculta(div)
{
	var lista=document.getElementById(div);
	lista.style.display="none";
}

function muestra(div)
{	
	var lista=document.getElementById(div);
	lista.style.display="block";
}

function cambia(div)
{	
	var lista=document.getElementById(div);
	if (lista.style.display=="block")
		lista.style.display="none";
	else
		lista.style.display="block";
}

function IsNumeric(valor)
{
  var log=valor.length;
  var sw="S";
  for (x=0; x<log; x++)
  {
    v1=valor.substr(x,1);
    v2 = parseInt(v1);
    //Compruebo si es un valor numérico
    if (isNaN(v2))
    {
      sw= "N";
    }
  }
  if (sw=="S")
  {
    return true;
  }
  else
  {
    return false;
  }
}
//------------------------------------------------------------------------------------------
var primerslap=false;
var segundoslap=false;


function FormatearFecha(fecha)
{
  var longitud = fecha.length;
  var dia;
  var mes;
  var ano;

  if ((longitud>=2) && (primerslap==false))
  {
    dia=fecha.substr(0,2);
    if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00"))
    {
      fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7);
      primerslap=true;
    }
    else
    {
      fecha="";
      primerslap=false;
    }
  }
  else
  {
    dia=fecha.substr(0,1);
    if (IsNumeric(dia)==false)
    {
      fecha="";
    }
    if ((longitud<=2) && (primerslap=true))
    {
      fecha=fecha.substr(0,1);
      primerslap=false;
    }
  }
  if ((longitud>=5) && (segundoslap==false))
  {
    mes=fecha.substr(3,2);
    if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00"))
    {
      fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4);
      segundoslap=true;
    }
    else
    {
      fecha=fecha.substr(0,3);
      segundoslap=false;
    }
  }
  else
  {
    if ((longitud<=5) && (segundoslap=true))
    {
      fecha=fecha.substr(0,4);
      segundoslap=false;
    }
  }
  if (longitud>=7)
  {
    ano=fecha.substr(6,4);
    if (IsNumeric(ano)==false)
    {
      fecha=fecha.substr(0,6);
    }
    else
    {
      if (longitud==10)
      {
        if ((ano==0) || (ano<1000) || (ano>9999)) {
          fecha=fecha.substr(0,6);
        }
      }
    }
  }

  if (longitud>=10)
  {
    fecha=fecha.substr(0,10);
    dia=fecha.substr(0,2);
    mes=fecha.substr(3,2);
    ano=fecha.substr(6,4);
    // Año no viciesto y es febrero y el dia es mayor a 28
    if ( (ano%4 != 0) && (mes ==02) && (dia > 28) )
    {
      fecha=fecha.substr(0,2)+"/";
    }
  }
return (fecha);
}