
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["principal"];

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="no"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers


var haut = 0;	//hauteur du iframe

var url_contenu = "";		// url complet du contenu du iframe "contenu"
var url_principal = "";		// url complet du contenu du iframe "principal"


function resizeCaller() 
{
	//alert ("dans resizeCaller");


	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++)
	{
		if (document.getElementById)
		resizeIframe(iframeids[i])
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no")
		{
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			if (tempobj)
			{
				tempobj.style.display="block";
			}	
		}

		// jl modif	
//		resizeIframeParent(iframeids[i]);


		//
		// recherche les url des pages contenu
		//
		// url principal	
		var url_principal = window.location.href; 

url_contenu = url_principal;
//alert (url_principal);

/*		// url contenu	avec IE: folders/xx/xx/documents.xxx
		//				avec IE url absolu  http://urlcomplet.xxx
		//				avec firefox: http://urlcomplet.xxx
		// 				avec firefox: prendre ce choix 
		url_contenu = tempobj.src;
		//alert (url_contenu);

		if (url_contenu.substring(0,4) == 'http')
		{
			//url complet
		}
		else	//url relatif au folder
		{
			url_contenu = url_principal + url_contenu;
		}
		//alert (url_contenu);
*/

	
	}// fin for
	
	window.scrollTo(0,0);	
}



function resizeIframe(frameid)
{
	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera)
	{
		currentfr.style.display="block";
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
		{
		currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
		haut = currentfr.height;
		}
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
		{
		currentfr.height = currentfr.Document.body.scrollHeight;
		haut = currentfr.height;
		}

		/*else if(document.all && document.all.Document.body.offsetHeight) //(document.all && !window.opera)
		{
			currentfr.height = currentfr.Document.body.offsetHeight;
			haut = currentfr.height;
			//var vH = (document.all && !window.opera)? iframeWindow.document.body.scrollHeight:iframeWindow.document.documentElement.offsetHeight;
		}
		*/
		//alert ("haut resize: " + haut)

/*		
 //code sans le try
		//
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent)
		{
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
*/


		try
		{
			//
			if (currentfr.addEventListener)
				currentfr.addEventListener("load", readjustIframe, false)
			else if (currentfr.attachEvent)
			{
				currentfr.detachEvent("onload", readjustIframe) // Bug fix line
				currentfr.attachEvent("onload", readjustIframe)
			}
		}
		catch(err)
		{
			return;
		}




	} // fin if
}// fin fonction


function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}


function loadintoIframe(iframeid, url){
	if (document.getElementById)
	{
		document.getElementById(iframeid).src=url;
		url_contenu = url;
		
		//
		resizeCaller();
	}
}



function get_url_contenu()
{
	return url_contenu;
}




if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller



/////////////////////////////////////////////////////////////////////////////////
//


// autre version
function adjustIFrameSize(iframeWindow)
{
	var iframeElement = parent.document.getElementById(iframeWindow.name);
	var vH = (document.all && !window.opera)? iframeWindow.document.body.scrollHeight:iframeWindow.document.documentElement.offsetHeight;

	iframeElement.style.height = (vH > 20)? vH + "px":0;

}


////////////////////////////////////////////////////
/*
//
The parent page has a javascript function like this:

function insertIt() {
var _y = document.getElementById('framediv');
var _x = window.frames[0].document.body.innerHTML;
_y.innerHTML = _x
}
Then, the parent page has a div with the id "framediv" which is placed where the contents of the iframe should appear on the page.
The iframe element is then placed inside the div, like this:

<div id="framediv">
<iframe onload="insertIt();" src="/somewhere/content.htm" frameborder="no" width="555px" scrolling="no">
</div> 
//
*/
function insertIt() 
{
	var _y = document.getElementById('principal');
	var _x = window.frames[0].document.body.innerHTML;
	_y.innerHTML = _x
} 
//
////////////////////////////////////////////////////





