function cambia(id) 
{
    elem=document.getElementById("img"+id);
    elsrc=elem.src;
    if(elsrc.indexOf("p.jpg") > 0) elsrc=elsrc.replace("p.jpg","g.jpg");
    else{elsrc=elsrc.replace("p.JPG","g.JPG");}
    
    if(elsrc.indexOf("flickr") > 0)
        {
        elsrc=elsrc.replace(/_s\./,"\.");
        fotofli = new Image();
        fotofli.src = elsrc;
        altoestimado = fotofli.height;
        if(altoestimado==0)altoestimado=parseInt((elem.height * elem.widthg)/elem.width);
        
        }
        else
        altoestimado = parseInt((elem.height * elem.widthg)/elem.width);

    sig="";ant="";
    idsig = id + 1;if(idsig > num_fotos)idsig=1;
    if(id < num_fotos) sig="<a style=float:right href='#' onclick='cambia(" + eval(id+1) + ");return false;'>Siguiente</a>";
    if(id > 1) ant="<a style=float:left href='#' onclick='cambia(" + eval(id-1) + ");return false;'>Anterior</a>";
    document.getElementById("fotobig").innerHTML = "<a href=# onclick='cambia(idsig);return false;'><img border=0 id=lafoto height=" + altoestimado+ " width=" + elem.widthg + " src='"+ elsrc + "' onload='carga_piefoto(" + id +")'></a>" + "<div id=pie class=normal style=width:" + elem.widthg + "px;height:" + 50 + "px >" + document.getElementById("text"+id).innerHTML + "<br>" + sig + ant +"<br class='separataClear'/></div>";
    document.getElementById("fotobig").style.height=altoestimado+"px";    
    return false;
} 

function carga_piefoto(id)
{
    google_ad_width = 468;google_ad_height = 60;
    google_color_border = "F2F8FB";google_color_bg = "F2F8FB";
    mif = document.createElement("IFRAME");
    mif.src = "/ad2.htm?galeria";
    mif.marginWidth=0;
    mif.marginHeight=0;
    mif.frameBorder=0;
    mif.width=google_ad_width;
    mif.style.marginTop="1em";
    mif.style.clear="both";
    mif.scrolling="no";
    mif.height=google_ad_height;
    mif.allowTransparency;
    document.getElementById("pie").appendChild(mif);
    if(!ie){document.getElementById("pie").style.height=document.getElementById("pie").offsetHeight+google_ad_height+15;} /* en moz no quiere coger el alto*/ /* bajar el pie*/ 
    if(typeof(alto)!="undefined") 
        { extrafoto=document.getElementById("lafoto").height - altofoto;
        if(extrafoto>0) { xTop("pfoot",alto + extrafoto);} 
        } 
    altofoto=document.getElementById("lafoto").height; 
}

