
///////////////////////////////////////////////////////////////////////
// Canvi de l'alçada del iframe, en funció de la pàgina carregada    //
///////////////////////////////////////////////////////////////////////
function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

///////////////////////////////////////////////////////////////////////
// Calcula l'alçada de la nova pàgina carregada al iframe            //
///////////////////////////////////////////////////////////////////////
function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 10 + "px";
  }
}

///////////////////////////////////////////////////////////////////////
// Carrega una nova pàgina al iframe                                 //
///////////////////////////////////////////////////////////////////////
function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;
    return false;
  }
  else return true;
}

///////////////////////////////////////////////////////////////////////
// Funció que es crida quan la pàgina s'ha carregat dins l'iframe    // 
//       (serveix per controlar el tamany del iframe )               //
///////////////////////////////////////////////////////////////////////
function goSetHeight() {
  if (parent == window) return;
  // no way to obtain id of iframe object doc loaded into? no parentNode or parentElement or ...
  else parent.setIframeHeight('ifrm');
}

/*
Open Centered Popup Window Script-
© DHTML Shock (www.dhtmlshock.com)
To add more shock to your site, visit www.DHTML Shock.com
*/

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
