function modalwindow_show(theaction)
	{
	theBody = document.getElementsByTagName('body')[0];
	theBody.setAttribute('onresize','modalwindow_resize();');
	//theBody.style.overflow = 'hidden';

	theOverlayBg = document.createElement('div');
	theOverlayBg.setAttribute('id','modalwindow__overlaybg');
	theOverlay = document.createElement('div');
	theOverlay.setAttribute('id','modalwindow__overlay');
	theOverlay.setAttribute('onclick','modalwindow_hide();');

	theIframe = document.createElement('iframe');
	theIframe.setAttribute('id','modalwindow');
	theIframe.setAttribute('name','modalwindow');
	theIframe.setAttribute('frameborder','0');
	if (theaction.substring(1,7) == 'http://')
		{
		theIframe.setAttribute('src',theaction);
		theIframe.setAttribute('style','width:750px;height:400px;');
		}
	else
		{ theIframe.setAttribute('src',theaction); }
	theOverlay.appendChild(theIframe);
	
	theTransparantBg = document.createElement('div');
	theTransparantBg.setAttribute('id','modalwindow__iframetransparant');
	
	theBody.appendChild(theOverlayBg);
	theBody.appendChild(theTransparantBg);
	theBody.appendChild(theOverlay);
	
	objOverlayBg = document.getElementById('modalwindow__overlaybg');
	objOverlayBg.style.visibility = 'visible';
	objOverlayBg.style.display = 'block';
	objOverlayBg.style.position = 'absolute';
	objOverlayBg.style.left = '0px';
	objOverlayBg.style.top = '0px';
	objOverlayBg.style.zIndex = '9996';
	
	objOverlay = document.getElementById('modalwindow__overlay');
	objOverlay.style.visibility = 'visible';
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.left = '0px';
	objOverlay.style.top = '0px';
	objOverlay.style.zIndex = '9998';
	
	objTransparantBg = document.getElementById('modalwindow__iframetransparant');
	objTransparantBg.style.display = 'block';
	objTransparantBg.style.position = 'absolute';
	objTransparantBg.style.left = '0px';
	objTransparantBg.style.top = '0px';
	objTransparantBg.style.zIndex = '9997';

	if (document.getElementById)
		{
		objOverlayBg.style.width = document.getElementsByTagName('body')[0].offsetWidth + 'px';
		objOverlay.style.width = document.getElementsByTagName('body')[0].offsetWidth + 'px';
		}
	else if (document.all)
		{
		objOverlayBg.style.width = document.getElementsByTagName('body')[0].pixelWidth + 'px';
		objOverlay.style.width = document.getElementsByTagName('body')[0].pixelWidth + 'px';
		}
	objOverlayBg.style.height = '100%';
	objOverlay.style.height = '100%';
	
	window.scrollTo(0,0);
	}

function modalwindow_hide()
	{
	if (document.getElementById('modalwindow__overlay'))
		{
		theBody = document.getElementsByTagName('body')[0];
		theElementToRemove = document.getElementById('modalwindow__iframetransparant');
		theBody.removeChild(theElementToRemove);
		theElementToRemove = document.getElementById('modalwindow__overlay');
		theBody.removeChild(theElementToRemove);
		theElementToRemove = document.getElementById('modalwindow__overlaybg');
		theBody.removeChild(theElementToRemove);
		}
	
	document.getElementsByTagName('body')[0].removeAttribute('onresize');
	//document.getElementsByTagName('body')[0].style.overflow = 'auto';
	}

function modalwindow_resize()
	{
	if (document.getElementById('modalwindow__overlay'))
		{
		if (document.getElementById)
			{
			document.getElementById('modalwindow__overlaybg').style.width = document.getElementsByTagName('body')[0].offsetWidth + 'px';
			document.getElementById('modalwindow__overlay').style.width = document.getElementsByTagName('body')[0].offsetWidth + 'px';
			}
		else if (document.all)
			{
			document.getElementById('modalwindow__overlaybg').style.width = document.getElementsByTagName('body')[0].pixelWidth + 'px';
			document.getElementById('modalwindow__overlay').style.width = document.getElementsByTagName('body')[0].pixelWidth + 'px';
			}
		document.getElementById('modalwindow__iframetransparant').style.left = (modalwindow_getpos(document.getElementById('modalwindow'))[0] - 10) + 'px';
		document.getElementById('modalwindow__iframetransparant').style.top = (modalwindow_getpos(document.getElementById('modalwindow'))[1] - 10) + 'px';
		document.getElementById('modalwindow__overlaybg').style.height = '100%';
		document.getElementById('modalwindow__overlay').style.height = '100%';
		}
	}

function modalwindow_reload()
	{
	theUrl = document.location.href;
	document.location.href = theUrl;
	}
	
function modalwindow_setsize(theWidth)
	{
	theObj = document.getElementById('modalwindow');
	theObjTrans = document.getElementById('modalwindow__iframetransparant');
	
	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
	
	if (theObj && !window.opera)
		{
		theObj.style.display = 'block';
		if (theObj.contentDocument && theObj.contentDocument.body.offsetHeight) //ns6 syntax
			{
			theHeight = theObj.contentDocument.body.offsetHeight + FFextraHeight;
			}
		else if (theObj.Document && theObj.Document.body.scrollHeight) //ie5+ syntax
			{
			theHeight = theObj.Document.body.scrollHeight;
			}
		}
	if (theWidth < 100) { theWidth = 300; }

	theObj.style.width = theWidth + 'px';
	theObj.style.height = theHeight + 'px';
	
	theObjTrans.style.width = (theWidth + 20) + 'px';
	theObjTrans.style.height = (theHeight + 20) + 'px';
	
	// --- Check window innerheight size
	theWindow = modalwindow_getwindowsize();
	if (theHeight > (theWindow[1] - 40))
		{
		theObj.style.height = (theWindow[1] - 40) + 'px';
		theObjTrans.style.height = ((theWindow[1] - 40) + 20) + 'px';
		}

	theObjTrans.style.left = (modalwindow_getpos(theObj)[0] - 10) + 'px';
	theObjTrans.style.top = (modalwindow_getpos(theObj)[1] - 10) + 'px';
	
	return false;
	}
	

function modalwindow_getwindowsize()
	{
	// --- Copyright: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
	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;
		}
	var theArr = new Array();
	theArr[0] = myWidth;
	theArr[1] = myHeight;
	return theArr;
	}

function modalwindow_getpos(theCurrObj)
	{
	var theArr = new Array();
	theArr[0] = 0;
	theArr[1] = 0;

	ml = 0;
	mt = 0;
	if (theCurrObj)
		{
		if (document.getElementById)
			{
			ml = theCurrObj.offsetLeft;
			mt = theCurrObj.offsetTop;
			var theObjParent = theCurrObj.offsetParent;  
			while (theObjParent != null)
				{
				ml += theObjParent.offsetLeft;
				mt += theObjParent.offsetTop;
				theObjParent = theObjParent.offsetParent;
				}
			}
		else if (document.all)
			{
			ml = theCurrObj.style.pixelLeft;
			mt = theCurrObj.style.pixelTop;
			var theObjParent = theCurrObj.parentElement;  
			while (theObjParent != null)
				{
				ml += theObjParent.style.pixelLeft;
				mt += theObjParent.style.pixelTop;
				theObjParent = theObjParent.parentElement;
				}
			}
		}

	theArr[0] = ml;
	theArr[1] = mt;

	return theArr;
	}
