var minAncho = 478;
var minAlto = 338;

var homeReservaActual = 0;

var winName = "titulo";
var win = null;

function AbreN( theURL, ancho, alto )
{
    var h = (screen.width-ancho)/2;
    var v = (screen.height-alto)/2;
    var windowprops = "top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes, resizable=no,width="+ancho+",height="+alto+",left="+h+", top="+v;
    
    if (win)
    {
        win.close();
    }
    
    win = window.open(theURL, winName, windowprops);
}

function Actualiza()
{
    var w = document.getElementById( 'flash' );
    
    ancho = alto = 0;
    
    if( typeof( window.innerWidth ) == 'number' )
    {
        ancho = window.innerWidth;
        alto = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        ancho = document.documentElement.clientWidth;
        alto = document.documentElement.clientHeight;
    }
    else if( document.body &&( document.body.clientWidth || document.body.clientHeight ) )
    {
        ancho = document.body.clientWidth;
        alto = document.body.clientHeight;
    }
    
    w.style.width = ancho < minAncho ? minAncho + "px" : "100%";
    w.style.height = alto < minAlto ? minAlto + "px" : "100%";
}

function CambiaFondo( idElemento, imagen, bucle )
{
    document.getElementById( idElemento ).style.background = "url(" + imagen + ") " + bucle;
}


function CambiaHomeReserva( cual )
{
    document.getElementById( 'homeReserva' + homeReservaActual ).style.display = "none";
    
    homeReservaActual = cual;
    
    document.getElementById( 'homeReserva' + homeReservaActual ).style.display = "block";
}

function CambiaImg( idElemento, imagen )
{
    document.getElementById( idElemento ).src = imagen;
}

function Inicia( ancho, alto, img, ver )
{
    if( ver==0 )
    {
        var w = document.getElementById( 'noFlash' );
        w.innerHTML = "<img src=\""+img+"\" alt=\"Animación Lacerplus\" border=\"0\">";
    }
   
    minAncho = ancho;
    minAlto = alto;
    window.onresize=function(){Actualiza ();}
    Actualiza();
}

function EntregaDomicilio()
{
    if( document.getElementById( 'entrega1' ).checked == true )
    {
        document.getElementById( 'datosEntrega' ).style.display = "block";
    }
    else
    {
        document.getElementById( 'datosEntrega' ).style.display = "none";
    }
}

function IniciaHomeReservas()
{
    homeReservaActual = 1;
    
    document.getElementById( 'homeReserva' + homeReservaActual ).style.display = "block";
}

function str_replace( search, replace, subject )
{
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}