/*--------------------------------------------------------------------------*/
/*  ResizeDiv
 *  (c) 2009 Thijs van der Laan, BiSC Nederland BV
 *
 *  This is typically used to make a border line (Target) to the size of
 *  one of the two divs (src1 or src2) which is the longest to the buttom
 *  of the the screen, if it smaller of the browser screen it is extended
 *  to the bottom of the browserscreen. Extra defines a standard number
 *  pixes which is added to the calculated size of Target
/*--------------------------------------------------------------------------*/
function ResizeDiv(Target,Src1,Src2,Extra)
{
	var oTarget,oSrc1,oSrc2,oMin;
	var TargetHeight=0;
	var TargetTop=0;
	var Src1Height=0;
	var Src1Top=0;
	var Src2Height=0;
	var Src2Top=0;

	var ExtraHeight = parseInt(Extra);
	var TheHeight=0;
	var sHeight=0;
	var Trace=0;
	
	
	oTarget = FO(Target) ;	// master (view area)
	oSrc1 = FO(Src1) ;			// child (content area)
	oSrc2 = FO(Src2) ;			// pijltjes


	TargetTop=parseInt(oTarget.offsetTop);		
	TargetHeight=parseInt(oTarget.offsetHeight);


	Src1Top=parseInt(oSrc1.offsetTop);
	Src1Height=parseInt(oSrc1.offsetHeight);

	Src2Top=parseInt(oSrc2.offsetTop);
	Src2Height=parseInt(oSrc2.offsetHeight);
	sHeight=parseInt(document.documentElement.clientHeight)-1;

	if(Trace!=0)
	{
		alert("screen="+sHeight);
		alert("TargetTop="+TargetTop);
		alert("TargetHeight="+TargetHeight);
		alert("Src1Top="+Src1Top);
		alert("Src1Height="+Src1Height);
		alert("Src2Top="+Src2Top);
		alert("Src2Height="+Src2Height);	
		alert("ExtraHeight="+ExtraHeight);	
	}

	TargetHeight=TargetHeight+TargetTop;
	Src1Height=Src1Height+Src1Top;
	Src2Height=Src2Height+Src2Top;

	TheHeight=Src1Height;
	
	if(TheHeight<Src2Height)
	{
		TheHeight=Src2Height;
	}

	if(TheHeight<sHeight)
	{
		TheHeight=sHeight;
	}

	TheHeight=TheHeight-TargetTop+ExtraHeight;

	oTarget.style.height=TheHeight+'px';
}

function FO(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

