//divLoadName : facultatif, div relative associé à l'iframe pour gérer les temps de preload = '' pour ne pas utiliser

function loadIframe(iframeName, url, divLoadName) {
	if (divLoadName!='')
	{
	loadWaitMessage(iframeName,divLoadName);
	}  
  if ( window.frames[iframeName] ) {  
    window.frames[iframeName].location = url;
    return false;
  }
  else return true;
}


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;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  clearTimeout(resizeTimer);
  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
				var loc = iframeWin.location.toString();
				if (docHt) 
					{
						iframeEl.style.height = docHt + "px";
					}
  }
}

//en début de chrgement de l'iframe
function loadWaitMessage(iframeName,divLoadName)
{
	objIframe=document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
	objIframe.style.height = 0 + "px";
	//global.js MM
	objDiv=MM_findObj(divLoadName);
	objDiv.style.display="block";
}


resizeTimer=0;
//en fin de chargement de l'iframe, appelé en fin du fichier contenu dans l'iframe
function unLoadWaitMessage(iframeName,divLoadName)
{
	if (divLoadName!='')
	{
	objDiv=MM_findObj(divLoadName);
	objDiv.style.display="none";
	}
	
	//si mac, laisser du temps au iframeEl.style.height = auto avant de resizer l'iframe, sinon le docHT sous mac est mal calculé lors du passage 
	// d'un iframe à un autre
	if (navigator.platform.substring(0,3)!="Win")
	{
		var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
		 if (iframeEl) 
			{
			iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
			resizeTimer=setTimeout("setIframeHeight('" + iframeName + "')",200);
			}
	}
	else
	{		
	setIframeHeight(iframeName);
	}
}