<!--
/*
* Box Model Fix 0.7 (c) by Thor Larholm, www.jscript.dk
*
*/

/* Docs pasted from webpage linked to from above
So how does it work? There are 3 functions, FixBoxModel, FixBoxModelCollection
and FixBoxModelStyle. FixBoxModel iterates through all stylesheets, calling
FixBoxModelCollection with each style collection. FixBoxModelCollection
recursively checks for imports, then calls FixBoxModelStyle with each rules
style object as argument. FixBoxModelStyle then calculates the proper box size.

FixBoxModel is called automatically right after it is inserted, so just put the
script right after your style declarations and forget about it, and you're done.
If you want to, call it onload or whenever - it will only correct the box size
once. That is, unless you specify the bForce argument, which forces it to
recalculate (for advanced users only, if you have dynamically changed padding
and margin). This also means that any inline styles will not be corrected, only
those specified or imported in STYLE and LINK elements.

If you want to correct elements that have inline styles, just call the
FixBoxModelStyle function with the elements style object as argument.
*/

function FixBoxModel(bForce){
	if(!window.external)return;
	var compat = document.compatMode;
	if(typeof compat=="string"&&compat!="BackCompat")return;
	for(var i=0, S=document.styleSheets, il=S.length, C, R; i<il; i++){
		C = S[i]; if(!C) continue;
		FixBoxModelCollection( C, bForce );
	}
}

function FixBoxModelCollection( oStyleCol, bForce ){
	var I = oStyleCol.imports;
	for(var a=0, al=(I?I.length:0); a<al; a++){
		FixBoxModelCollection( I[a], bForce );
	}
	var R = oStyleCol.rules; if(!R) return;
	for(var j=0, jl=R.length, CR, CS; j<jl; j++){
		CR = R[j]; if(!CR) continue;
		// Bailout if we hit a form element to prevent breakages in MSIE 5.5 win
		if (CR.selectorText.match('(INPUT|SELECT|TEXTAREA|TD|IMG)')) continue;
		CS = CR.style; if(!CS) continue;
		FixBoxModelStyle( CS, bForce );
	}
}

function FixBoxModelStyle(oStyle, bForce){
	if(!oStyle|| (oStyle.FixBoxModelDone&&!bForce) ) return;
	var p = FixBoxModel_parseInt;
	var cWidth = p(oStyle.width), cHeight = p(oStyle.height);
	var wBorder = p(oStyle.borderLeftWidth) + p(oStyle.borderRightWidth);
	var hBorder = p(oStyle.borderTopWidth) + p(oStyle.borderBottomWidth);
	var wPadding = p(oStyle.paddingLeft) + p(oStyle.paddingRight);
	var hPadding = p(oStyle.paddingTop) + p(oStyle.paddingBottom);
	if(wBorder>0||wPadding>0) oStyle.width = cWidth + wBorder + wPadding;
	if(hBorder>0||hPadding>0) oStyle.height = cHeight + hBorder + hPadding;
	oStyle.FixBoxModelDone = true;
}

function FixBoxModel_parseInt( s ){
	return parseInt(s,10)||0;
}

// Now we fix the bloody box model on WinIE
if (bw.ie) FixBoxModel();

//-->