﻿
/***********************************************
* 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 [iFrameId] or [] for none:
var iFrameId = "dynamicIFrame";
var loadingId = "loading";

//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

function resizeCaller()
{
	//alert('resizeCaller');
	document.getElementById(iFrameId).style.display = "block"
	resizeIframeOnLoad()
	document.getElementById(loadingId).innerHTML = '';
	document.getElementById(loadingId).style['display'] = 'none';
}

function resizeIframeOnLoad()
{
	//alert('resizeIframeOnLoad');
	var currentfr = document.getElementById(iFrameId)
	if (currentfr && !window.opera)
	{
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight + FFextraHeight;
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;

		if (currentfr.addEventListener)
		{
			currentfr.addEventListener("load", resizeIframeOnLoad, false)
		}
		else if (currentfr.attachEvent)
		{
			currentfr.detachEvent("onload", resizeIframeOnLoad) // Bug fix line
			currentfr.attachEvent("onload", resizeIframeOnLoad)
		}
		currentfr.onIFrameResize = resizeIframe;
		currentfr.onShowToolTip = showToolTip
	}
}

function resizeIframe()
{
	//alert('resizeIframe');
	var currentfr = document.getElementById(iFrameId)
	if (currentfr && !window.opera)
	{
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight + FFextraHeight;
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;

		if (currentfr.contentWindow && currentfr.contentWindow.document)
		{
			// Zoek naar de DIV van de date-time picker. Die moet afsonderlijk behandeld worden.
			var datepickerDiv = currentfr.contentWindow.document.getElementById('ui-datepicker-div');
			if (datepickerDiv != null)
			{
				if (datepickerDiv.offsetHeight + datepickerDiv.offsetTop > currentfr.height)
					currentfr.height = datepickerDiv.offsetHeight + datepickerDiv.offsetTop;
			}

			// Zoek naar de DIV van de date-time picker. Die moet afsonderlijk behandeld worden.
			var blockUIDiv = currentfr.contentWindow.document.getElementById('camperDetailsPopUp');
			if ((blockUIDiv != null) && (blockUIDiv.offsetParent != null))
			{
				if (blockUIDiv.offsetHeight + blockUIDiv.offsetTop + blockUIDiv.offsetParent.offsetTop > currentfr.height)
					currentfr.height = blockUIDiv.offsetHeight + blockUIDiv.offsetTop + blockUIDiv.offsetParent.offsetTop;
			}
		}
	}
}

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload = resizeCaller

function showToolTip(toolTip)
{
	//alert('showToolTip');
	$.blockUI(
	{
		message: "<div id='pu' style='padding: 4px;'>" + toolTip + "<div><div style='font-size: 9px;'>(klik op dit scherm om te sluiten)</div>",
		timeout: 60000,
		css:
		{
			cursor: 'pointer',
			width: '80%',
			left: '10%'
		}
	});

	$("#pu").click(function() { $.unblockUI(); });
}
