/*******************************************************************************
 * Mòdul: general.js
 * Descripció: funcions de tipus general
 ******************************************************************************/ 

function centrarV(elementId) {
// centra el quadre en funció de l'alçada de la finestra del navegador
  var posicio;
  posicio = parseInt((windowHeight() - 532) / 2)
  if (posicio < 0) {posicio = 0;}
  document.getElementById(elementId).style.top = posicio + "px";
  document.getElementById(elementId).style.visibility = "visible";
}

function windowHeight() {
// obté l'alçada de la finestra de presentació del navegador
  var myWidth = 0, myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  return myHeight;
}

function chgImg(elementId, imageName)
// canvia la imatge de l'objecte especificat per un altre
{
  document.getElementById(elementId).src=imageName;
}

function chgLink(elementId, newLink)
// canvia el link de l'objecte especificat per un altre
{
  document.getElementById(elementId).href = newLink;
}

function chgVisibility(elementId, visibility)
// canvia la visibilitat de l'objecte especificat per l'especificat
{
  document.getElementById(elementId).style.visibility = visibility;
}
