function getTamanoVentana() {
      var Tamanyo = [0, 0];
      if (typeof window.innerWidth != 'undefined')
      {
        Tamanyo = [
            window.innerWidth,
            window.innerHeight
        ];
      }
      else if (typeof document.documentElement != 'undefined'
          && typeof document.documentElement.clientWidth !=
          'undefined' && document.documentElement.clientWidth != 0)
      {
        Tamanyo = [
            document.documentElement.clientWidth,
            document.documentElement.clientHeight
        ];
      }
      else   {
        Tamanyo = [
            document.getElementsByTagName('body')[0].clientWidth,
            document.getElementsByTagName('body')[0].clientHeight
        ];
      }
      return Tamanyo;
}

function redireccionar (path) {
    var tam = getTamanoVentana();
    var alto = parseFloat(tam[1]);
    if (alto >= 1050) {
        window.location = path + 'res/1400x1050.jsp';
    } else if (alto >= 960) {
        window.location = path + 'res/1280x960.jsp';
    } else if (alto >= 768) {
        window.location = path + 'res/1024x768.jsp';
    } else if (alto >= 720) {
        window.location = path + 'res/960x720.jsp';
    } else {
        window.location = path + 'res/800x600.jsp';
    }
}

function centrar (ancho,alto,resx,resy) {
    var margenIzquierdo = parseFloat((ancho-resx)/2);
    var margenSuperior = parseFloat((alto-resy)/2);
    if (margenIzquierdo < 0) {
        margenIzquierdo = 0;
    }
    if (margenSuperior < 0) {
        margenSuperior = 0;
    }
    //alert ("Margen Izquierdo: " + margenIzquierdo);
    //alert ("Margen Superior: " + margenSuperior);
    document.body.style.marginLeft = margenIzquierdo + "px";
    document.body.style.marginTop = margenSuperior + "px";
    if (ie || ie7) {
        if (document.getElementById('imageContainer') != null) {
            var antesTop = parseFloat(document.getElementById('imageContainer').style.top);
            var antesLeft = parseFloat(document.getElementById('imageContainer').style.left);
            var margenSuperior2 = antesTop + margenSuperior;
            var margenIzquierdo2 = antesLeft + margenIzquierdo;
            document.getElementById('imageContainer').style.top = margenSuperior2 + "px";
            document.getElementById('imageContainer').style.left = margenIzquierdo2 + "px";
        }
    }
}
